lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <dad9d6d52d5f0fabef85ae40ce293edfad530574.camel@intel.com>
Date: Wed, 23 Jul 2025 08:13:36 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "hpa@...or.com" <hpa@...or.com>, "thomas.lendacky@....com"
	<thomas.lendacky@....com>, "peterz@...radead.org" <peterz@...radead.org>,
	"tglx@...utronix.de" <tglx@...utronix.de>, "Hansen, Dave"
	<dave.hansen@...el.com>, "mingo@...hat.com" <mingo@...hat.com>,
	"bp@...en8.de" <bp@...en8.de>
CC: "Gao, Chao" <chao.gao@...el.com>, "Edgecombe, Rick P"
	<rick.p.edgecombe@...el.com>, "seanjc@...gle.com" <seanjc@...gle.com>,
	"x86@...nel.org" <x86@...nel.org>, "kas@...nel.org" <kas@...nel.org>,
	"sagis@...gle.com" <sagis@...gle.com>, "Chatre, Reinette"
	<reinette.chatre@...el.com>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, "Williams, Dan J" <dan.j.williams@...el.com>,
	"pbonzini@...hat.com" <pbonzini@...hat.com>, "kvm@...r.kernel.org"
	<kvm@...r.kernel.org>, "ashish.kalra@....com" <ashish.kalra@....com>,
	"Yamahata, Isaku" <isaku.yamahata@...el.com>, "nik.borisov@...e.com"
	<nik.borisov@...e.com>, "dwmw@...zon.co.uk" <dwmw@...zon.co.uk>
Subject: Re: [PATCH v4 1/7] x86/kexec: Consolidate relocate_kernel() function
 parameters

On Tue, 2025-07-22 at 00:53 +0000, Huang, Kai wrote:
> On Mon, 2025-07-21 at 17:44 -0700, H. Peter Anvin wrote:
> > On July 21, 2025 4:42:22 PM PDT, "Huang, Kai" <kai.huang@...el.com> wrote:
> > > On Mon, 2025-07-21 at 23:29 +0000, Huang, Kai wrote:
> > > > > On July 21, 2025 2:36:48 PM PDT, "Huang, Kai" <kai.huang@...el.com> wrote:
> > > > > > On Mon, 2025-07-21 at 16:27 -0500, Tom Lendacky wrote:
> > > > > > > > > > @@ -204,7 +202,7 @@
> > > > > SYM_CODE_START_LOCAL_NOALIGN(identity_mapped)
> > > > > > > > > >   	 * entries that will conflict with the now unencrypted memory
> > > > > > > > > >   	 * used by kexec. Flush the caches before copying the kernel.
> > > > > > > > > >   	 */
> > > > > > > > > > -	testq	%r8, %r8
> > > > > > > > > > +	testq	$RELOC_KERNEL_HOST_MEM_ACTIVE, %r11
> > > > > > > > > 
> > > > > > > > > Hmmm... can't both bits be set at the same time? If so, then this
> > > > > > > > > will fail. This should be doing bit tests now.
> > > > > > > > 
> > > > > > > > TEST instruction performs logical AND of the two operands,
> > > > > > > > therefore the above equals to:
> > > > > > > > 
> > > > > > > >  	set ZF if "R11 AND BIT(1) == 0".
> > > > > > > > 
> > > > > > > > Whether there's any other bits set in R11 doesn't impact the above, right?
> > > > > > > > 
> > > > > > > 
> > > > > > > Doh! My bad, yes, not sure what I was thinking there.
> > > > > > > 
> > > > > > 
> > > > > > Np and thanks! I'll address your other comments but I'll see whether
> > > > > > Boris has any other comments first.
> > > > > > 
> > > > > 
> > > > > You can use testb in this case to save 3 bytes, too.
> > > > 
> > > > Yeah I can do that, thanks for the info!
> > > 
> > > I just tried.  I need to do:
> > > 
> > > 	testb	$RELOC_KERNEL_HOST_MEM_ACTIVE, %r11b
> > > 
> > > in order to compile, otherwise using plain %r11 generates:
> > > 
> > > arch/x86/kernel/relocate_kernel_64.S:212: Error: `%r11' not allowed with
> > > `testb'
> > > 
> > > I'll do some test and if there's no problem I'll switch to use this way,
> > > assuming it still saves us 3-bytes.
> > > 
> > 
> > That works just fine.
> 
> Yeah I have now tested. Thanks :-)

Sorry for multiple emails.  One minor thing related to using testb:

With this patch there's one movl to R11:

    movl    $RELOC_KERNEL_PRESERVE_CONTEXT, %r11d

I think it would be better to make it consistent with testb:

    movb    $RELOC_KERNEL_PRESERVE_CONTEXT, %r11b

Please let me know if there's any concern?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ