Re: [PATCHv11 05/19] x86/relocate_kernel: Use named labels for less confusion

From: Kirill A. Shutemov
Date: Tue Jun 04 2024 - 11:22:35 EST


On Tue, Jun 04, 2024 at 11:15:03AM +0200, Borislav Petkov wrote:
> On Mon, Jun 03, 2024 at 05:24:00PM -0700, H. Peter Anvin wrote:
> > Trying one more time; sorry (again) if someone receives this in duplicate.
> >
> > > > >
> > > > > diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
> > > > > index 56cab1bb25f5..085eef5c3904 100644
> > > > > --- a/arch/x86/kernel/relocate_kernel_64.S
> > > > > +++ b/arch/x86/kernel/relocate_kernel_64.S
> > > > > @@ -148,9 +148,10 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped)
> > > > > */
> > > > > movl $X86_CR4_PAE, %eax
> > > > > testq $X86_CR4_LA57, %r13
> > > > > - jz 1f
> > > > > + jz .Lno_la57
> > > > > orl $X86_CR4_LA57, %eax
> > > > > -1:
> > > > > +.Lno_la57:
> > > > > +
> > > > > movq %rax, %cr4
> >
> > If we are cleaning up this code... the above can simply be:
> >
> > andl $(X86_CR4_PAE | X86_CR4_LA54), %r13
> > movq %r13, %cr4
> >
> > %r13 is dead afterwards, and the PAE bit *will* be set in %r13 anyway.
>
> Yeah, with a proper comment. The testing of bits is not really needed.

I think it is better fit the next patch.

What about this?