[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9708d6cf72184b7788bfb95ea1f46faf@AcuMS.aculab.com>
Date: Thu, 16 Jun 2022 06:35:44 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Dave Hansen' <dave.hansen@...el.com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"mingo@...hat.com" <mingo@...hat.com>,
"bp@...en8.de" <bp@...en8.de>, "luto@...nel.org" <luto@...nel.org>,
"peterz@...radead.org" <peterz@...radead.org>
CC: "ak@...ux.intel.com" <ak@...ux.intel.com>,
"dan.j.williams@...el.com" <dan.j.williams@...el.com>,
"david@...hat.com" <david@...hat.com>,
"hpa@...or.com" <hpa@...or.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"sathyanarayanan.kuppuswamy@...ux.intel.com"
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
"seanjc@...gle.com" <seanjc@...gle.com>,
"thomas.lendacky@....com" <thomas.lendacky@....com>,
"x86@...nel.org" <x86@...nel.org>
Subject: RE: [PATCHv4 3/3] x86/tdx: Handle load_unaligned_zeropad() page-cross
to a shared page
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)
Powered by blists - more mailing lists