lkml.org 
[lkml]   [2022]   [Jun]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCHv4 3/3] x86/tdx: Handle load_unaligned_zeropad() page-cross to a shared page
Date
From: Dave Hansen
> Sent: 16 June 2022 00:35
>
> On 6/15/22 15:52, Kirill A. Shutemov wrote:
> >> + vaddr = (unsigned long)insn_get_addr_ref(&insn, regs);
> >> + if (vaddr / PAGE_SIZE != (vaddr + size) / PAGE_SIZE)
> > Oops. I just realized it has off-by-one. It supposed to be:
> >
> > if (vaddr / PAGE_SIZE != (vaddr + size - 1) / PAGE_SIZE)
>
> That was bugging me. Glad you caught this.
>
> Wouldn't this be more obviously correct?
>
> if (ALIGN_DOWN(vaddr, PAGE_SIZE) !=
> ALIGN_DOWN(vaddr + size, PAGE_SIZE))
> ...
>
> I don't think we have a PAGE_ALIGN_DOWN().

Or:
if ((vaddr ^ (vaddr + size - 1)) >> PAGE_SHIFT)

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
\
 
 \ /
  Last update: 2022-06-16 08:36    [W:0.127 / U:24.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site