From patchwork Wed Dec 9 13:17:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 11961359 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=-16.7 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, URIBL_BLOCKED,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 8F1A0C1B0E3 for ; Wed, 9 Dec 2020 13:19:23 +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 513E3207C8 for ; Wed, 9 Dec 2020 13:19:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 513E3207C8 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=zuLX2UuMAR+pkVm9lRClK05eLVKiPRv/sVJjtvCvP8I=; b=vu3CYSSIIKK+byYmsLpGnt8U8 +2nBgth1w8Cpo9+dWb46+CXAiYcWZyrLJL7XWYyiOtTUV3KsEC/W7DWBW0uCsWpy/ewD+BwwZXiee c1EJPjl/9x6DZ3LJ17ru+sqbeqofdMSaRwJniUZEMj+Kf3vPQBr73hEuH1ySTxADJ4La12aRgy+TI pDCPssnYV0EeR5phVQftooE6oqCxqf06uuRB+itM0Kj4fyPAMZG/PlBqlriXVOS1OdZrQHGDb6eqc be2PlaYsBQq6ieAErP99759dCFyp2FgRHy/a4j0dF4W3yz9eSwR9M5bXt7FLc0JO6WU6aHhMdTOOb +mqY5RhFw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmzM8-0003Fh-J1; Wed, 09 Dec 2020 13:18:08 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmzLx-0003By-PE for linux-arm-kernel@lists.infradead.org; Wed, 09 Dec 2020 13:17:58 +0000 Received: by mail-wm1-x343.google.com with SMTP id a3so1636226wmb.5 for ; Wed, 09 Dec 2020 05:17:57 -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=eC3dfrduk9N3bItne4Bt2OJ3xFC82tVD26IiWD/PAzc=; b=ZhdHHWTrxybOS3ckjtAmTjfzvZosyvpJGZcwcPadU5OeCIPFNwt1A3F29cIGChqQBi 5+cQAEs0QKUeKAH+f6I3IbNBTY+dZ6M6X2DC4cxNXVKRlCLMUyoGV/iIJJQ++TGYt7cN HWQ+ttLyL29Ckl0l8dhFUEMOYLBhF9H7F62yggNGMq9+pE6vz7cxq3JDXBa2owu7dv4q Fek1uPRomzQ3VbhTcMdLcgYbIayHaX/zgPY0yjxJGjH8qB7QIFZfIrOdceHWn3ldY3Zg lbhHMVOb92NEJeoEnF/6sQXRszqVs+xGV8veUIdFoDvVQ0ts2N+ory1Vz2SwyYpZ+x2n csmg== 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=eC3dfrduk9N3bItne4Bt2OJ3xFC82tVD26IiWD/PAzc=; b=bodHlaBwVQKImwV4vbyZmZCUhK/WVtjm2e5vmaIUyHVxr2tKrq8m52T5VrjOsnb0yT VdxeFdLLjrQ5A0hyj0RQGW8OFkmtaLQlxJR5h4cJ25AC/GJ3H5kMWblDra4gHjebqbGn TNBYGkywI+3dTmeQNyER4JQR2Oao9dO3UEp5m/oDX+Lh0DyTtoLopwuNcVC36Bu0HXmg reJKYGCVDm6GzopdsGBWOnNF11wcPvY9LLwXCNIQwzE2DUXuCuRFy7FTpFNNGfuLNebS nVzVLRzFfINFGiR5ouTl8tvm/5yO1qtsLfKahIQ9TFUUh2t7b3PuecQq9f4kGEIvIRB1 zFSw== X-Gm-Message-State: AOAM530TecHkcbNqF64EohA5xuNidXUZkQDEpgxknrHVS2Fja6eyAZga SzaXicdjnflHu6aLEK9xjCVA4g== X-Google-Smtp-Source: ABdhPJyJlAdG9Q2cJj2wx1wE7lWFVUjh7hiYEXBuQsKX5NFis+JOymoWzsrCIbt9tGIBYhRtb6nAqw== X-Received: by 2002:a1c:2c4:: with SMTP id 187mr2810150wmc.187.1607519876443; Wed, 09 Dec 2020 05:17:56 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:9d1b:d0eb:db43:6cd2]) by smtp.gmail.com with ESMTPSA id d8sm3211263wrp.44.2020.12.09.05.17.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Dec 2020 05:17:55 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [PATCH 3/9] KVM: arm64: Set up .hyp.rodata ELF section Date: Wed, 9 Dec 2020 13:17:40 +0000 Message-Id: <20201209131746.85622-4-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201209131746.85622-1-dbrazdil@google.com> References: <20201209131746.85622-1-dbrazdil@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201209_081757_883466_A1CD8FD5 X-CRM114-Status: GOOD ( 15.45 ) 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: kernel-team@android.com, 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 43af13968dfd..f294f2048955 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 6e637d2b4cfb..c244e57f9cd9 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1745,11 +1745,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) }