From patchwork Tue Jan 5 18:05:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 12000021 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 F23D4C433DB for ; Tue, 5 Jan 2021 18:07:47 +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 B62CF22D50 for ; Tue, 5 Jan 2021 18:07:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B62CF22D50 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hKaXpSoodgaBMfJUUYiW/u4LeFlrQkFjGoEoV5M0H8I=; b=su4xQBf5bMBUym2UZYJo61Cze Io+dIEf42yBVNc+06r/16eX1b1bB1maXKLOlU9Exa+jbSVo2gMRSsUBpzbONelsL5jFgSzHgf46vu EVxgD4Qx6eQR3rGos91BzBPcChh7IooVR0nghUUFoKyZY0szJIsOKw/ZU1EhA6+URhuzuJg87q+iS qKnBQJYxRW1JYB1N4iM+OPmjIXjetVQP6vJWVZPoaGashGDxf0baFfisBliP6LqiuPLrtw7EPZybD 2m9WsmP6Yo1+cF3UW7ZY0qSpYb9bjDBoMktw7GP6F8VCqVWM0N5IaDnvz2rGa6YV/LVRCo9lqrkpv k9OYE8Wjg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kwqid-0001QW-EV; Tue, 05 Jan 2021 18:06:07 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kwqiV-0001Na-0z for linux-arm-kernel@lists.infradead.org; Tue, 05 Jan 2021 18:06:00 +0000 Received: by mail-wr1-x435.google.com with SMTP id r7so98550wrc.5 for ; Tue, 05 Jan 2021 10:05:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S3/rPCJUnMLfjD3b25qof1oX2WveJLOvFQJdod0fSPo=; b=Iwu0pUa0YSXjcvx3quDZYpB77l41vCMGRFORqWy3mdOa/tYLkPf0sYx8kmz5igXrc7 EU4nEErd4MlRE7fB6nlJW5P0YzdkYZgSeU0/6oFYl1RkFEgd5P2jgpY0Bgyi1Fz0ZcM3 DPF9ufE5GKcJX4cQ6HaVMXL+Cd41KOf50op+JJLWKpkUVUftEcZ5E0WpIhzQYaLFsGpZ hb0Xnie++//B0InrE4yYVNC/mCGpc7VnwmkMxk5lVpfIcEjuqfoc2E5yz/6UiMtwXJXV Aus9iwVc3FY9zZDo4Uyr9qzGwb0Afu4A/A9qUAxXw0wMoNQBbY9obdMD/rifda0qwk3k cJJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S3/rPCJUnMLfjD3b25qof1oX2WveJLOvFQJdod0fSPo=; b=RRhouTlc0ptlJqdgRBx/IdN9JG/WvwP1s7RBfpuXjs6vkGIRaE8EZnRGN+LcfnrTHh JxSxU8POtfEZQmt6Zz1oat3zVZ0XoDWNbr7/faGquRGPhXBk9jojgr29HYkeBUMspsIH 5C9fM70+7LbvH7CR04JfDlcww+FVQlSTpHuX2yLXHy2iV6X64NAwETo2BDK30w8DMnCF TxVwu2L/gWLLE5PnJgEcKM05OAg2h5X33vE2o69Lzd4gxEe4jSsHzL471JukRjUP+zpZ hd+Fvw42wKm42bJTonv/joRqANuDTSNzu8kw7zUCd/1A8621Mmc5JEo4lkgIRJA42M0H RLhQ== X-Gm-Message-State: AOAM531qjEA4c/f5NAlvxDfW4TPp2ZoKSGpS/ML01EfprHdDKRtIegv5 q3Wl/iVqTtL4lzFw/HQ1mvnA0w== X-Google-Smtp-Source: ABdhPJxc3qALx98DUhQZ7KCR6QZnBSsyO826Znz8Ic7DBsq+bseW6pwLsZMIeo64NXrlmnDKkKvMzQ== X-Received: by 2002:adf:83a6:: with SMTP id 35mr751393wre.274.1609869957580; Tue, 05 Jan 2021 10:05:57 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:4957:71a5:7b5c:c94f]) by smtp.gmail.com with ESMTPSA id z3sm830263wrn.59.2021.01.05.10.05.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Jan 2021 10:05:56 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [PATCH v2 2/8] KVM: arm64: Set up .hyp.rodata ELF section Date: Tue, 5 Jan 2021 18:05:35 +0000 Message-Id: <20210105180541.65031-3-dbrazdil@google.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210105180541.65031-1-dbrazdil@google.com> References: <20210105180541.65031-1-dbrazdil@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210105_130559_112287_B2DDDA0F X-CRM114-Status: GOOD ( 16.16 ) 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 , Suzuki K Poulose , Catalin Marinas , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Marc Zyngier , David Brazdil , Will Deacon , Ard Biesheuvel , Julien Thierry Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We will need to recognize pointers in .rodata specific to hyp, 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. 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 | 4 +++- 4 files changed, 11 insertions(+), 9 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 4c0b0c89ad59..9672b54bba7c 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 04c44853b103..de1af4052780 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1749,11 +1749,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 70ac48ccede7..cfdc59b4329b 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S +++ b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S @@ -14,6 +14,9 @@ SECTIONS { HYP_SECTION(.idmap.text) HYP_SECTION(.text) + HYP_SECTION(.data..ro_after_init) + HYP_SECTION(.rodata) + /* * .hyp..data..percpu needs to be page aligned to maintain the same * alignment for when linking into vmlinux. @@ -22,5 +25,4 @@ SECTIONS { HYP_SECTION_NAME(.data..percpu) : { PERCPU_INPUT(L1_CACHE_BYTES) } - HYP_SECTION(.data..ro_after_init) }