lkml.org 
[lkml]   [2022]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFCv2 05/10] x86/mm: Provide untagged_addr() helper
On Thu, May 12, 2022 at 03:06:38PM +0200, Thomas Gleixner wrote:

> #define untagged_addr(addr) ({ \
> u64 __addr = (__force u64)(addr); \
> \
> __addr &= current->thread.lam_untag_mask; \
> (__force __typeof__(addr))__addr; \
> })
>
> No conditionals, fast _and_ correct. Setting this untag mask up once
> when LAM is enabled is not rocket science.

But that goes wrong if someone ever wants to untag a kernel address and
not use the result for access_ok().

I'd feel better about something like:

s64 __addr = (addr);
s64 __sign = __addr;

__sign >>= 63;
__sign &= lam_untag_mask;
__addr &= lam_untag_mask;
__addr |= __sign;

__addr;

Which simply extends bit 63 downwards -- although possibly there's an
easier way to do that, this is pretty gross.

\
 
 \ /
  Last update: 2022-05-12 16:25    [W:0.911 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site