linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arvind Sankar <nivedita@alum.mit.edu>
To: Borislav Petkov <bp@alien8.de>
Cc: Arvind Sankar <nivedita@alum.mit.edu>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	Michael Matz <matz@suse.de>
Subject: Re: [PATCH v2] x86/boot: Use 32-bit (zero-extended) move for z_output_len
Date: Tue, 11 Feb 2020 14:27:39 -0500	[thread overview]
Message-ID: <20200211192739.GA1761914@rani.riverdale.lan> (raw)
In-Reply-To: <20200211181559.GI32279@zn.tnic>

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

  reply	other threads:[~2020-02-11 19:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07 19:44 [PATCH 1/3] x86/boot/compressed/32: Simplify calculation of output address Arvind Sankar
2020-01-07 19:44 ` [PATCH 2/3] x86/boot/compressed/64: Use leal to initialize boot stack pointer Arvind Sankar
2020-02-12 12:04   ` [tip: x86/boot] x86/boot/compressed/64: Use LEA " tip-bot2 for Arvind Sankar
2020-01-07 19:44 ` [PATCH 3/3] x86/boot/compressed/64: Use 32-bit move for z_output_len Arvind Sankar
2020-02-11 16:17   ` Borislav Petkov
2020-02-11 17:33     ` [PATCH v2] x86/boot: Use 32-bit (zero-extended) " Arvind Sankar
2020-02-11 18:15       ` Borislav Petkov
2020-02-11 19:27         ` Arvind Sankar [this message]
2020-02-12  9:47           ` Borislav Petkov
2020-02-12 12:04       ` [tip: x86/boot] x86/boot/compressed/64: Use 32-bit (zero-extended) MOV " tip-bot2 for Arvind Sankar
2020-01-23 11:04 ` [tip: x86/asm] x86/boot: Simplify calculation of output address tip-bot2 for Arvind Sankar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200211192739.GA1761914@rani.riverdale.lan \
    --to=nivedita@alum.mit.edu \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matz@suse.de \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).