From patchwork Wed Nov 4 18:36:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 11881885 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=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 0217CC2D0A3 for ; Wed, 4 Nov 2020 18:39:04 +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 749A120739 for ; Wed, 4 Nov 2020 18:39:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="xaNT8PGN"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="pwS+yO9a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 749A120739 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=bJ9tw/2I3EKxC8ua06F7BRAh2VGjKeOCHTyRJFsjYpc=; b=xaNT8PGNXeOVEeoxvP7npZ3LE 6Y86AtSKmW3S93hrz/aJV0wYZssZOtY6xO8Pe4MF/E2RzvsnqCLLqlChn85QloZ9cRf0W6ahudLC6 vVZCV1SCJ3U1Qo7/52XJSSYv2IK7hzk/WXMTY2sihvDnfmwmw+cN09xEvAQUMSIasuY7Cmw/zMoa2 TafDznrkPZrlcmwfl36qoTAi0bfdEtROjV85RTj6wJyi4bY/PS8Ofq7e2UVqvpKkKP383d9Y+WrDj XUXWLhEHYLRon8GONVC6KSmDbZgq1LR0/kGJLRG+5IAXPOsEOP+hBCdQXRwbdLb54PgPz0EngL8yY gkRoHQLmg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaNel-0001ok-9C; Wed, 04 Nov 2020 18:37:15 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaNeO-0001fs-Iq for linux-arm-kernel@lists.infradead.org; Wed, 04 Nov 2020 18:36:53 +0000 Received: by mail-wm1-x342.google.com with SMTP id c9so3345641wml.5 for ; Wed, 04 Nov 2020 10:36:52 -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=/4FeYdmn3iB0IXLNt/H1CXu0UQ9fwGLnFLDS+u9FzHI=; b=pwS+yO9awK8oUBpQAVkLJuj63BH/WHRSAh1203sKJMLPgu/Z7WrtlqDJagBVCYrBaf EOF4SKuIVhlxAqijYs3lo1YFAo8JMGNuT2vGkFPRX2iSDKwMvMACiSGWDwM6hRJ50W30 rsJicMhiC6OYQ/2/CIUPbdAdRQpWJXMwejJYSsKhgwDaIDaZLSG1v9QGvqOLA1ErGg9d Iq0FStkmxGam8BquTREXKbmimi0koGzmcK9fr4eliQyQiNZJD/2xQZ2zt3TcJYss/+q2 PU8oK7Fyq8/xDdNN+GYMONZ2wzMa7EPpgD5F7CCcwZhZwvFOGbR9o6UrjPcEJN2uVbhb VRzw== 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=/4FeYdmn3iB0IXLNt/H1CXu0UQ9fwGLnFLDS+u9FzHI=; b=fiLZ/cjo3aZZBMosroTkJKJCH9WPiGsJi9aVeS1fwIjB/GFv5PBJEpVx40mcznYJEX H3IZJ9BbG11/ENdDws7EszItTpwEGjzn/shl6O5Ex1NPZrbILRNWENN4uBG50gfO7eou Y97ntd0ji/fLHE8jTPQK2sB57C7EyZUF2xT3XX4xP9QEnzF8Z4l+SYLlR9lKkhev7p7j kJ1reURSPcEsM4r/QDvcwGxSm8PyprbgjEoForhfjaKq4JVgvn2J7qBwl4RuplYUC0K+ 6YhC1OcSnvO+EM8c22JMPLXwmijdYN0PAWOTaUFNU5eRNNZiCjOI+tiEoBKFQ0cC/R1h hr8Q== X-Gm-Message-State: AOAM5314xdfsBCH4c/Z1nKL1LYqBAKykgqOQY1odbzenWzsvuuGyhMv+ V163azPrpQYnv9sPXfr59Uw6KSZkaQtUmr+F X-Google-Smtp-Source: ABdhPJx/hiCAz8Legoa47eblx4WAapjkBFpTOjmMETdF/oVexGY9XgUxpPgGgIkrhHQJMAw0LEe2bA== X-Received: by 2002:a05:600c:4147:: with SMTP id h7mr5966082wmm.186.1604515011165; Wed, 04 Nov 2020 10:36:51 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:c8d2:30f2:53c6:bc2]) by smtp.gmail.com with ESMTPSA id e25sm4070787wra.71.2020.11.04.10.36.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Nov 2020 10:36:50 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [RFC PATCH 06/26] kvm: arm64: Add .hyp.data ELF section Date: Wed, 4 Nov 2020 18:36:10 +0000 Message-Id: <20201104183630.27513-7-dbrazdil@google.com> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104183630.27513-1-dbrazdil@google.com> References: <20201104183630.27513-1-dbrazdil@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201104_133652_728809_A713BAA4 X-CRM114-Status: GOOD ( 19.91 ) 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 , Lorenzo Pieralisi , kernel-team@android.com, Suzuki K Poulose , Marc Zyngier , Quentin Perret , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Tejun Heo , Dennis Zhou , Christoph Lameter , David Brazdil , Will Deacon , Julien Thierry , Andrew Scull Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add rules for renaming a .data ELF section in KVM nVHE object files to .hyp.data, linking it into the kernel and mapping it in hyp at runtime. Signed-off-by: David Brazdil --- arch/arm64/include/asm/sections.h | 1 + arch/arm64/kernel/vmlinux.lds.S | 10 ++++++++++ arch/arm64/kvm/arm.c | 7 +++++++ arch/arm64/kvm/hyp/nvhe/hyp.lds.S | 3 +++ 4 files changed, 21 insertions(+) diff --git a/arch/arm64/include/asm/sections.h b/arch/arm64/include/asm/sections.h index 3994169985ef..255f76f592d7 100644 --- a/arch/arm64/include/asm/sections.h +++ b/arch/arm64/include/asm/sections.h @@ -11,6 +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_start[], __hyp_data_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 1bda604f4c70..a9a1612c084f 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -30,6 +30,13 @@ jiffies = jiffies_64; *(__kvm_ex_table) \ __stop___kvm_ex_table = .; +#define HYPERVISOR_DATA_SECTION \ + HYP_SECTION_NAME(.data) : { \ + __hyp_data_start = .; \ + *(HYP_SECTION_NAME(.data)) \ + __hyp_data_end = .; \ + } + #define HYPERVISOR_PERCPU_SECTION \ . = ALIGN(PAGE_SIZE); \ HYP_SECTION_NAME(.data..percpu) : { \ @@ -37,6 +44,7 @@ jiffies = jiffies_64; } #else /* CONFIG_KVM */ #define HYPERVISOR_EXTABLE +#define HYPERVISOR_DATA_SECTION #define HYPERVISOR_PERCPU_SECTION #endif @@ -207,6 +215,8 @@ SECTIONS EXIT_DATA } + HYPERVISOR_DATA_SECTION + PERCPU_SECTION(L1_CACHE_BYTES) HYPERVISOR_PERCPU_SECTION diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 5750ec34960e..8bb9fffe2a8f 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1602,6 +1602,13 @@ static int init_hyp_mode(void) goto out_err; } + err = create_hyp_mappings(kvm_ksym_ref(__hyp_data_start), + kvm_ksym_ref(__hyp_data_end), PAGE_HYP); + if (err) { + kvm_err("Cannot map hyp data section\n"); + goto out_err; + } + err = create_hyp_mappings(kvm_ksym_ref(__start_rodata), kvm_ksym_ref(__end_rodata), PAGE_HYP_RO); if (err) { diff --git a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S index bb2d986ff696..bc1664d365a9 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S +++ b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S @@ -16,4 +16,7 @@ SECTIONS { HYP_SECTION_NAME(.data..percpu) : { PERCPU_INPUT(L1_CACHE_BYTES) } + + /* Put after '.data..percpu' because its name matches the same regex. */ + HYP_SECTION(.data) }