[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201019171259.GC2701355@rani.riverdale.lan>
Date: Mon, 19 Oct 2020 13:12:59 -0400
From: Arvind Sankar <nivedita@...m.mit.edu>
To: Borislav Petkov <bp@...en8.de>
Cc: Arvind Sankar <nivedita@...m.mit.edu>, x86@...nel.org,
Joerg Roedel <jroedel@...e.de>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 1/4] x86/boot/64: Explicitly map boot_params and
command line
On Mon, Oct 19, 2020 at 04:51:15PM +0200, Borislav Petkov wrote:
> On Fri, Oct 16, 2020 at 04:04:01PM -0400, Arvind Sankar wrote:
> > Commits
> >
> > ca0e22d4f011 ("x86/boot/compressed/64: Always switch to own page table")
> > 8570978ea030 ("x86/boot/compressed/64: Don't pre-map memory in KASLR code")
> >
> > set up a new page table in the decompressor stub, but without explicit
> > mappings for boot_params and the kernel command line, relying on the #PF
> > handler instead.
> >
> > This is fragile, as boot_params and the command line mappings are
> > required for the main kernel. If EARLY_PRINTK and RANDOMIZE_BASE are
> > disabled, a QEMU/OVMF boot never accesses the command line in the
> > decompressor stub, and so it never gets mapped. The main kernel accesses
> > it from the identity mapping if AMD_MEM_ENCRYPT is enabled, and will
> > crash.
> >
> > Fix this by adding back the explicit mapping of boot_params and the
> > command line.
> >
> > Note: the changes also removed the explicit mapping of the main kernel,
> > with the result that .bss and .brk may not be in the identity mapping,
> > but those don't get accessed by the main kernel before it switches to
> > its own page tables.
> >
> > Signed-off-by: Arvind Sankar <nivedita@...m.mit.edu>
> > Reviewed-by: Joerg Roedel <jroedel@...e.de>
> > ---
> > arch/x86/boot/compressed/head_64.S | 3 +++
> > arch/x86/boot/compressed/ident_map_64.c | 24 +++++++++++++++++++++---
> > 2 files changed, 24 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
> > index 1c80f1738fd9..3976b4e92e1b 100644
> > --- a/arch/x86/boot/compressed/head_64.S
> > +++ b/arch/x86/boot/compressed/head_64.S
> > @@ -544,6 +544,9 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
> > pushq %rsi
> > call set_sev_encryption_mask
> > call load_stage2_idt
> > + /* Pass boot_params to initialize_identity_maps */
> > + popq %rdi
> > + pushq %rdi
>
> Any reason why you're not doing
>
> movq (%rsp), %rdi
>
> here instead?
>
No real reason. This will disappear anyway in the cleanup patch.
Powered by blists - more mailing lists