Re: [PATCH v4 1/7] x86/kexec: Consolidate relocate_kernel() function parameters

From: H. Peter Anvin
Date: Mon Jul 21 2025 - 19:05:56 EST


On July 21, 2025 2:36:48 PM PDT, "Huang, Kai" <kai.huang@xxxxxxxxx> 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.