Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1988892pxu; Tue, 24 Nov 2020 14:03:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzeadak3r08oyd++GTur0rKE9rPSUYlOce7/SNucKFUVLle5P116wHlOUjD1dnYSV9F6ojl X-Received: by 2002:a50:8714:: with SMTP id i20mr623650edb.200.1606255411482; Tue, 24 Nov 2020 14:03:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606255411; cv=none; d=google.com; s=arc-20160816; b=0DDL9nGb91C3UbpZF4fujNyYQiJHpnXpUaqpikcsY0i3eWtjQk8GLAIjtPnJXcMTuG HbvX+lCQqwdoELC6oTZllm7Umw1lmRWIbbw4Sy7IBhopCv2MqEeahOYx7usRKiBWlWqp 6sj8ZY5I4Ds4qY1NSl3TTCbwCs/EAPofk0ThkY6OtIINL13tSDy6KC9CYeY8svK2Cr6C 0BqDxDxJiJwk5OgkcSCtj36I2HHsJ0FB0zkW9hp6kyXrPy/OnUGnEoNPI/bqf2TF0H3/ FcYLzaNL8BKs4UPtWdAEXMhyYhsIoj+fIvq+ZyrKA0a5Kss+QZuiUhBBe5i6smRwq03O BBCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=PHXfGuW6l9M9OnK4+9WtMmB52TwkkLU554PWfkSN/ns=; b=NJPAMakI3vELKbeVVkAMuduvqovFAbDb0ySOdFit5A0qOSQaxo2XlJ76HIbjebCsqf W6eoLPNDzOf/a3BTj4NIbpZWJV8+ifH+kmUNTMY0S0BPXfyldj+4NZjw+HRNBzkRei5y 0f/gr+UtaCGjaGKZrpn+SLqwHE+blbWTzuRkQsoGKvYzd2lQW0qWpLRaP45gnoXer3qd Qm/XaXojmfzgjdWSk4+tNWinwgfKx4v1spl1X0R8C/01eyQMT1YFkkQbUY8h33UNT8xP 8PXghgZqTN4tTtNMiHXt73E/6URIATy8fpbVTr6JQ0gWp42FqrlqZJ0XmKjDvtu9YYt6 hT/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="c/IzzxHN"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si110978ejq.721.2020.11.24.14.03.08; Tue, 24 Nov 2020 14:03:31 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b="c/IzzxHN"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388368AbgKXNfu (ORCPT + 99 others); Tue, 24 Nov 2020 08:35:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:40178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725616AbgKXNfu (ORCPT ); Tue, 24 Nov 2020 08:35:50 -0500 Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3C9E720866 for ; Tue, 24 Nov 2020 13:35:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606224949; bh=av6mZG1ceIPJ1PjcHIA9oEIcJwL3MRA6RT952RIF28w=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=c/IzzxHNo4IQziRbNPD5QALDAFqNgdMqL1sDFeZKsTStphv4sZn47vf6n15kAT6tf +fSTBu+idchdTXllYjG9vB0LcRua+cY1Sf+WhD5AHtCm0rpvHhonyROp8QPzbKCHxQ 5NcwTBCR83CMpEqQykiUIWZ13LtEFApL+OueGi2g= Received: by mail-ot1-f51.google.com with SMTP id 11so6783271oty.9 for ; Tue, 24 Nov 2020 05:35:49 -0800 (PST) X-Gm-Message-State: AOAM531yvC9LgJZlPQKZ3mRfa58FH8NFBlThW7GHXuMh0PpyfZ+USk89 rEIR8LK4vIY+ec/Shb4Xki0NIndzoFXsm3+J7Pg= X-Received: by 2002:a05:6830:214c:: with SMTP id r12mr3115803otd.90.1606224948439; Tue, 24 Nov 2020 05:35:48 -0800 (PST) MIME-Version: 1.0 References: <20201119162543.78001-1-dbrazdil@google.com> <20201119162543.78001-2-dbrazdil@google.com> In-Reply-To: <20201119162543.78001-2-dbrazdil@google.com> From: Ard Biesheuvel Date: Tue, 24 Nov 2020 14:35:37 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 1/6] kvm: arm64: Set up .hyp.rodata ELF section To: David Brazdil Cc: kvmarm , Linux ARM , Linux Kernel Mailing List , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , Mark Rutland , Andrew Scull , Android Kernel Team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 19 Nov 2020 at 17:25, David Brazdil wrote: > > We will need to recognize pointers in .rodata specific to hyp, Why? > so > establish a .hyp.rodata ELF section. Merge it with the existing > .hyp.data..ro_after_init as they are treated the same at runtime. > Does this mean HYP .text, .rodata etc are all writable some time after the kernel .text/.rodata have been mapped read-only? That is not a problem per se, but it deserves being called out. > Signed-off-by: David Brazdil > --- > arch/arm64/include/asm/sections.h | 2 +- > arch/arm64/kernel/vmlinux.lds.S | 7 ++++--- > arch/arm64/kvm/arm.c | 7 +++---- > arch/arm64/kvm/hyp/nvhe/hyp.lds.S | 1 + > 4 files changed, 9 insertions(+), 8 deletions(-) > > diff --git a/arch/arm64/include/asm/sections.h b/arch/arm64/include/asm/sections.h > index 8ff579361731..a6f3557d1ab2 100644 > --- a/arch/arm64/include/asm/sections.h > +++ b/arch/arm64/include/asm/sections.h > @@ -11,7 +11,7 @@ extern char __alt_instructions[], __alt_instructions_end[]; > 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_rodata_start[], __hyp_rodata_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 4382b5d0645d..6f2fd9734d63 100644 > --- a/arch/arm64/kernel/vmlinux.lds.S > +++ b/arch/arm64/kernel/vmlinux.lds.S > @@ -31,10 +31,11 @@ jiffies = jiffies_64; > __stop___kvm_ex_table = .; > > #define HYPERVISOR_DATA_SECTIONS \ > - HYP_SECTION_NAME(.data..ro_after_init) : { \ > - __hyp_data_ro_after_init_start = .; \ > + HYP_SECTION_NAME(.rodata) : { \ > + __hyp_rodata_start = .; \ > *(HYP_SECTION_NAME(.data..ro_after_init)) \ > - __hyp_data_ro_after_init_end = .; \ > + *(HYP_SECTION_NAME(.rodata)) \ > + __hyp_rodata_end = .; \ > } > > #define HYPERVISOR_PERCPU_SECTION \ > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index d6d5211653b7..119c97e8900a 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -1688,11 +1688,10 @@ static int init_hyp_mode(void) > goto out_err; > } > > - err = create_hyp_mappings(kvm_ksym_ref(__hyp_data_ro_after_init_start), > - kvm_ksym_ref(__hyp_data_ro_after_init_end), > - PAGE_HYP_RO); > + err = create_hyp_mappings(kvm_ksym_ref(__hyp_rodata_start), > + kvm_ksym_ref(__hyp_rodata_end), PAGE_HYP_RO); > if (err) { > - kvm_err("Cannot map .hyp.data..ro_after_init section\n"); > + kvm_err("Cannot map .hyp.rodata section\n"); > goto out_err; > } > > diff --git a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S > index 5d76ff2ba63e..b0789183d49d 100644 > --- a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S > +++ b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S > @@ -17,4 +17,5 @@ SECTIONS { > PERCPU_INPUT(L1_CACHE_BYTES) > } > HYP_SECTION(.data..ro_after_init) > + HYP_SECTION(.rodata) > } > -- > 2.29.2.299.gdc1121823c-goog >