[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200211192739.GA1761914@rani.riverdale.lan>
Date: Tue, 11 Feb 2020 14:27:39 -0500
From: Arvind Sankar <nivedita@...m.mit.edu>
To: Borislav Petkov <bp@...en8.de>
Cc: Arvind Sankar <nivedita@...m.mit.edu>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
linux-kernel@...r.kernel.org, Michael Matz <matz@...e.de>
Subject: Re: [PATCH v2] x86/boot: Use 32-bit (zero-extended) move for
z_output_len
On Tue, Feb 11, 2020 at 07:15:59PM +0100, Borislav Petkov wrote:
> On Tue, Feb 11, 2020 at 12:33:33PM -0500, Arvind Sankar wrote:
> > z_output_len is the size of the decompressed payload (i.e. vmlinux +
> > vmlinux.relocs) and is generated as an unsigned 32-bit quantity by
> > mkpiggy.c.
> >
> > The current movq $z_output_len, %r9 instruction generates a
> > sign-extended move to %r9. Using movl $z_output_len, %r9d will instead
> > zero-extend into %r9, which is appropriate for an unsigned 32-bit
> > quantity. This is also what we already do for z_input_len, the size of
> > the compressed payload.
>
> Yes, thanks.
>
> What I'll also add to this is the fact that
>
> init_size: .long INIT_SIZE # kernel initialization size
>
> where z_output_len participates in through INIT_SIZE is a 32-bit
> quantity determined by the ".long" so even if something made
> z_output_len bigger than 32-bit by explicitly using MOVABS so that it
> builds fine, you'd still get:
>
> arch/x86/boot/header.S: Assembler messages:
> arch/x86/boot/header.S:568: Warning: value 0x10103b000 truncated to 0x103b000
>
> as a warning.
Yes, this is just a "neatening" patch to use a more appropriate
instruction. There would have to be a lot of work to allow kernels to be
bigger than 2Gb, they're currently limited to at most 1Gb (or even 0.5Gb
if KASLR is disabled) by KERNEL_IMAGE_SIZE definition in
asm/page_64_types.h and there are checks in the linker script and a
bunch of other places, so the decompressed length can't be much bigger
than that.
>
> Btw, while poking at this, we found out that the MOV really remains
> MOV and not MOVABS if gas doesn't know what the quantity behind the
> z_output_len symbol is, as it is a symbol assignment. Which, AFAIU, with
> ELF64 objects, it should be using 8-byte quantities in the symbol table
> to accommodate such assignments. But for some reason it doesn't.
>
> Anyway, Michael can correct me if I'm still imprecise here.
For absolute symbols that it sees in the same file it does use 64-bit
immediate move for movq if necessary, but otherwise seems to need the
explicit opcode.
>
> Thx.
>
> --
> Regards/Gruss,
> Boris.
>
> https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists