Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1119945pxu; Thu, 8 Oct 2020 04:01:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5K+K9f3KazMBICrEm6vQyoNYTSw+aAEtE6RPRFxx+U+DQh8eC7j4uQpnr3Z6sA84KiqOX X-Received: by 2002:a17:906:170e:: with SMTP id c14mr8001818eje.275.1602154865997; Thu, 08 Oct 2020 04:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602154865; cv=none; d=google.com; s=arc-20160816; b=bp7tjyY72RT6XPAW3TqZVx9dyRgAsZjKj0YRmoQayJ24yHOO3u/MpobVNcTM/hM2xY UHQ39V2z4Aqhlfqdbs2aR6fAibLTHazFaQ5WT7BB63PXfsJTqdpQVbgPF+GuT+/yMLTC 9nyIL5fQ5oP1SU2C14K6gIwDO0Yn/AUvhTtlZfeVMiePwhjOFk7LucAgQSb0cpRJYyBK jyDODaQrprIpbdmlYJF4HRL8RbMHSIFyLQl1/IwwOLpMmm1pIfxjUSi31b8sLRicRL1q NMLpuNPzsF/qc12QQ2IYHctdDhNJ1X+d0WWiHLstsZJEzdsidaqhR/kjc62ahOaw8I5l OYfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=tVcWlYIlPTi7RaLbmpsXW3RP7dkGCbZL9ob5FkEQZHA=; b=R2aX/nPx906j+6Zk8ESeAeCD9GKH6infA3toHrNU1io+h8WvxpyEwFM4YNFrS6ARbg TT4xj7UG2QbHTDEf6h/BtAUUR/RRqAQAYtUo3Bbmglg9TZwMiTQ0WaBzt3vXsirSiRY7 /oZ/e8Tp2swgyvThLkNWCH3HdF6hTSfOO2Kdhm3bNPngHoJyjHgR7tzNg+VJuBSqMWHV AfLUPyqwjZsefz1k3PQFjGaTCaTcb5E8KZXLOZz4SRh7NzesGDNf+yvKfX1gMcqRlq4G PCL0SaNnHBw5bfq0cRKrjEXAiEN8mzeTWOX7+0VFOJ9GgXsIa9U6yGce6uHo/S4rRXo/ 9p1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ci27si4221636ejc.22.2020.10.08.04.00.42; Thu, 08 Oct 2020 04:01:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726065AbgJHJRd (ORCPT + 99 others); Thu, 8 Oct 2020 05:17:33 -0400 Received: from mx2.suse.de ([195.135.220.15]:43154 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725845AbgJHJRd (ORCPT ); Thu, 8 Oct 2020 05:17:33 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5BF58AD32; Thu, 8 Oct 2020 09:17:31 +0000 (UTC) Date: Thu, 8 Oct 2020 11:17:29 +0200 From: Joerg Roedel To: Arvind Sankar Cc: x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/5] x86/boot/64: Explicitly map boot_params and command line Message-ID: <20201008091729.GG3209@suse.de> References: <20201007195351.776555-1-nivedita@alum.mit.edu> <20201007195351.776555-5-nivedita@alum.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201007195351.776555-5-nivedita@alum.mit.edu> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 07, 2020 at 03:53:50PM -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 > --- > arch/x86/boot/compressed/ident_map_64.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/boot/compressed/ident_map_64.c b/arch/x86/boot/compressed/ident_map_64.c > index 070cda70aef3..8edeff0d9324 100644 > --- a/arch/x86/boot/compressed/ident_map_64.c > +++ b/arch/x86/boot/compressed/ident_map_64.c > @@ -150,10 +150,13 @@ void initialize_identity_maps(void) > } > > /* > - * New page-table is set up - map the kernel image and load it > - * into cr3. > + * New page-table is set up - map the kernel image, boot_params and the > + * command line, and load the new page-table into cr3. > */ Please extend this comment to state that boot_params and command-line need to be mapped here because they might not be touched (and thus mapped) before jumping to the uncompressed kernel image. Otherwise no one will remember why those need to be pre-mapped in a couple of years. With that change and the add_identity_map() call adjusted: Reviewed-by: Joerg Roedel