From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47E70C433E6 for ; Mon, 1 Feb 2021 18:33:52 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F3E4564E3C for ; Mon, 1 Feb 2021 18:33:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3E4564E3C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FK9NjUFgfruFQu4wpdF6eFxePIenxerHyfKDFhdJChY=; b=a2+JINkfW3SG7EEibAWHOzv88 p7EmSy+YihgAvTnWLOdIdJ6NaYk+axi7HSVoNBjqYGrSFIaBlQKW8PNvN5s00vRn0GRyCUsq2u/sn E9XpZr6ceR8BUhSBSVQgkn5abh0/kgU9QLua+nPWS69+no7CoM0yPEnUiqRmf2Gb9zVExjuQOMf4O z5ww4ZZyz7tJNxk0eVxqI7ve8MDEwe6W6Ay7DGP9Qr/5sppmmld1NoUFJOXWRaUrIhD+DISpkk6Cc bpSJ/2X9fTE4h3i9dOLvunpSR7IJEu/KsAblq79tg3keMXeVExSd8pvbhbRcGR2gKSRiJCh6WdKVZ byrkLzxfg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6dzy-00010A-Ej; Mon, 01 Feb 2021 18:32:30 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6dzw-0000zh-14 for linux-arm-kernel@lists.infradead.org; Mon, 01 Feb 2021 18:32:29 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 297C364E3C; Mon, 1 Feb 2021 18:32:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612204346; bh=aw6UMl/5KezkQ6ePwIA2OgzehTIqm/PvcGa5HLSc7RM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UIYtjuYrMYJnisaYscglrtJrY5NnTqDs4gd/oAXQhAwGqdVVV26wgJj57oXG8Dp6C E7BBZQJVTuulgZC0xOaP/aGc151+92nph9fqGju8zxChrvdLJSRYLz/FbDBq/tbNYk ycRiEGAZsFA61DaRGOJxrYN7+TGOD/gMK/0yJRFk5BXcXD/PGmlUAgk1LdFEwXHuwP Sy0YJFcO1gupIQAB7EUaZVMolH5k+MP425Kzb4z7PQ/IzBjtMgGSL1YQIKCAs5zOME buU2T2Zr9S/i91ru96Ue6PPvU1gBCqpY7PjX/BQNrUfYqkC3xLK4K6ev0EcIC1v+6K Nwaujfwy+ep7A== Date: Mon, 1 Feb 2021 18:32:20 +0000 From: Will Deacon To: Quentin Perret Subject: Re: [RFC PATCH v2 07/26] KVM: arm64: Introduce a BSS section for use at Hyp Message-ID: <20210201183220.GE15632@willie-the-truck> References: <20210108121524.656872-1-qperret@google.com> <20210108121524.656872-8-qperret@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210108121524.656872-8-qperret@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210201_133228_250405_25127088 X-CRM114-Status: GOOD ( 22.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, kernel-team@android.com, Suzuki K Poulose , android-kvm@google.com, Catalin Marinas , Fuad Tabba , linux-kernel@vger.kernel.org, Rob Herring , James Morse , linux-arm-kernel@lists.infradead.org, Marc Zyngier , David Brazdil , Frank Rowand , kvmarm@lists.cs.columbia.edu, Julien Thierry Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jan 08, 2021 at 12:15:05PM +0000, Quentin Perret wrote: > Currently, the hyp code cannot make full use of a bss, as the kernel > section is mapped read-only. > > While this mapping could simply be changed to read-write, it would > intermingle even more the hyp and kernel state than they currently are. > Instead, introduce a __hyp_bss section, that uses reserved pages, and > create the appropriate RW hyp mappings during KVM init. > > Signed-off-by: Quentin Perret > --- > arch/arm64/include/asm/sections.h | 1 + > arch/arm64/kernel/vmlinux.lds.S | 7 +++++++ > arch/arm64/kvm/arm.c | 11 +++++++++++ > arch/arm64/kvm/hyp/nvhe/hyp.lds.S | 1 + > 4 files changed, 20 insertions(+) > > diff --git a/arch/arm64/include/asm/sections.h b/arch/arm64/include/asm/sections.h > index 8ff579361731..f58cf493de16 100644 > --- a/arch/arm64/include/asm/sections.h > +++ b/arch/arm64/include/asm/sections.h > @@ -12,6 +12,7 @@ extern char __hibernate_exit_text_start[], __hibernate_exit_text_end[]; > extern char __hyp_idmap_text_start[], __hyp_idmap_text_end[]; > extern char __hyp_text_start[], __hyp_text_end[]; > extern char __hyp_data_ro_after_init_start[], __hyp_data_ro_after_init_end[]; > +extern char __hyp_bss_start[], __hyp_bss_end[]; > extern char __idmap_text_start[], __idmap_text_end[]; > extern char __initdata_begin[], __initdata_end[]; > extern char __inittext_begin[], __inittext_end[]; > diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S > index 43af13968dfd..3eca35d5a7cf 100644 > --- a/arch/arm64/kernel/vmlinux.lds.S > +++ b/arch/arm64/kernel/vmlinux.lds.S > @@ -8,6 +8,13 @@ > #define RO_EXCEPTION_TABLE_ALIGN 8 > #define RUNTIME_DISCARD_EXIT > > +#define BSS_FIRST_SECTIONS \ > + . = ALIGN(PAGE_SIZE); \ > + __hyp_bss_start = .; \ > + *(.hyp.bss) \ Use HYP_SECTION_NAME() here? > + . = ALIGN(PAGE_SIZE); \ > + __hyp_bss_end = .; Should this be gated on CONFIG_KVM like the other hyp sections are? In fact, it might be nice to define all of those together. Yeah, it means moving things higher up in the file, but I think it will be easier to read. > #include > #include > #include > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index 3ac0f3425833..51b53ca36dc5 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -1770,7 +1770,18 @@ static int init_hyp_mode(void) > goto out_err; > } > > + /* > + * .hyp.bss is placed at the beginning of the .bss section, so map that > + * part RW, and the rest RO as the hyp shouldn't be touching it. > + */ > err = create_hyp_mappings(kvm_ksym_ref(__bss_start), I think it would be clearer to refer to __hyp_bss_start here ^^. You could always add an ASSERT in the linker script if you want to catch anybody adding something before the hyp bss in future. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel