From patchwork Thu Sep 3 09:17:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 11752955 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 292FC14E5 for ; Thu, 3 Sep 2020 09:17:57 +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 F0AA4206C0 for ; Thu, 3 Sep 2020 09:17:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uPSKX+Ig"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="APLmMrE9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0AA4206C0 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+patchwork-linux-arm=patchwork.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: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:In-Reply-To:References:List-Owner; bh=wlZAoXoBGT2w9Z74DyflR1GX84E87KaVIc5pyQuBPic=; b=uPSKX+IgwoURjOd+/fUKaHrFw3 yG+7KoNNTaa+Phlad3SJ0xRjBy4fglqWSQQyDWFc6RsbnNfVAvm2LTNPYibWP2Q0WxkeLk2DYx74R ATl8URbuSfPg/Gqrhhbd2iovhppUgRjzql0/+kW+kItpzXtrbYtH9Pcfiy4QmTgaYqwgho/9r2794 rom7msq2gkOGfsLLsg7Atm6CN7wY2/TAZDb6ckUX6tiVraZBc6kv2yWUeBIrRIElqB6i7WwIMa7hG t7uygvrD0lgXaDlV9Z/smHJmyH5z5xVC/N2a+dGEUklup3WE/yfBY4Br7tuUiSSmfh0v3gEXmgWKU o995WNcQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDlNE-000415-J5; Thu, 03 Sep 2020 09:17:40 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDlNB-00040T-SF for linux-arm-kernel@lists.infradead.org; Thu, 03 Sep 2020 09:17:38 +0000 Received: by mail-ej1-x62f.google.com with SMTP id z22so2814927ejl.7 for ; Thu, 03 Sep 2020 02:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ybBiP+e417RFA7nMR4Bu7V33eb9o8gA61OetpUfftkQ=; b=APLmMrE9eEbfLFqGCI1U6UkzQSGgJVYT4fP69U8vY4IlnhXbOnr9RQuoxMki8HmaZ2 hKKQGLreepg4yFdemEkt4tTzSK31vCuqaa+W9k2u/u9b4F7KVEas6PBuxUVrrIHd7zV/ 83k8qYFhmmAueuH8UbIKhI4d0y51jhHFNYF7MZibLhrowrX7RKs0qA4jpeEV+fLRSHa3 LAkXEcSV6ctzyXlOPMd8Fc3wo9JJkJ6bwRk4wjYBhBa2pCVPkGdRYlRATOUWBEXYu1ud il6iZjUzLeM46Wwbgu3Qmmqltj3yRYqjHzSmkJyqufbPD/tdNc6KSK7+lqX0f2abBSob J2DA== 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:mime-version :content-transfer-encoding; bh=ybBiP+e417RFA7nMR4Bu7V33eb9o8gA61OetpUfftkQ=; b=Hz9EJTl6Op17/8lV1Swfe7LpviHr75+dJfIMMLi+F7xZyVA4X6qXsWRgybp7sDX8nm HQgYqldLqOhyKKx+/tnRHagzfn/iy0O2lzmPvPUqTC+EjFUhddinWyDELukyh09PfhGU IC4ggIDxGeG0lXsVt280lPCImwddotOfaBP8tDW1h5e2xUz4oGwl/lO/DAohh3yP7svm jyDCfMEQ9hc+MW9z+3KsvNKckXES3h5EGAU0DeSDBDiMYrJPPycFGxsVglpCRt3sRLp7 lzF71Ih4kkQqcQqm4omYr8tptiv5tvMvseSybhNNz12k3ELhfZDkh6DR6P+uOZ0Nn7sZ ZSjg== X-Gm-Message-State: AOAM532CtHaDg/+tknHW6AKLM3va8vZXLkTEcaxiCLGvTp1AzD24p2Gl f/lK30SJdHlEkMjwhlt0TwlcYg== X-Google-Smtp-Source: ABdhPJys1SWvJYPNpq0WObC+uy+nfuWZtybUHYnPbVexD1i1iV/lX+1rXLt1ldV/IBiG+6LOepfP3w== X-Received: by 2002:a17:906:a116:: with SMTP id t22mr1160350ejy.353.1599124654241; Thu, 03 Sep 2020 02:17:34 -0700 (PDT) Received: from localhost (dynamic-2a00-1028-919a-a06e-64ac-0036-822c-68d3.ipv6.broadband.iol.cz. [2a00:1028:919a:a06e:64ac:36:822c:68d3]) by smtp.gmail.com with ESMTPSA id x10sm2414585eds.21.2020.09.03.02.17.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Sep 2020 02:17:33 -0700 (PDT) From: David Brazdil To: Marc Zyngier , Catalin Marinas , Will Deacon , Dennis Zhou , Tejun Heo , Christoph Lameter , Arnd Bergmann Subject: [PATCH v2 00/10] Independent per-CPU data section for nVHE Date: Thu, 3 Sep 2020 11:17:02 +0200 Message-Id: <20200903091712.46456-1-dbrazdil@google.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200903_051737_940121_D28D2CB8 X-CRM114-Status: GOOD ( 16.48 ) X-Spam-Score: -16.2 (----------------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-16.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:62f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -7.5 USER_IN_DEF_SPF_WL From: address is in the default SPF white-list 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.5 ENV_AND_HDR_SPF_MATCH Env and Hdr From used in default SPF WL Match -0.5 DKIMWL_WL_MED DKIMwl.org - Medium sender 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: linux-arch@vger.kernel.org, Suzuki K Poulose , linux-kernel@vger.kernel.org, James Morse , Julien Thierry , David Brazdil , kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Introduce '.hyp.data..percpu' as part of ongoing effort to make nVHE hyp code self-contained and independent of the rest of the kernel. The series builds on top of the "Split off nVHE hyp code" series which used objcopy to rename '.text' to '.hyp.text' and prefix all ELF symbols with '__kvm_nvhe' for all object files under kvm/hyp/nvhe. The series is structured as follows: - patch 1: Modify generic PERCPU_* linker script macros to make it possible to define multiple per-CPU ELF sections with prefixed section and symbol names. - patch 2: Improve existing hyp build rules. This could be sent and merged independently of per-CPU but this series builds on it. - patches 3-4: Replace hyp helpers for accessing per-CPU variables with common helpers modified to work correctly in hyp. Per-CPU variables can now be accessed with one API anywhere. - patches 5-7: Where VHE and nVHE use per-CPU variables defined in kernel proper, move their definitions to hyp/ where they are duplicated and owned by VHE/nVHE, respectively. Non-VHE hyp code now refers only to per-CPU variables defined in its source files. Helpers are added so that kernel proper can continue to access nVHE hyp variables, same way as it does with other nVHE symbols. - patches 8-10: Introduce '.hyp.data..percpu' ELF section and allocate memory for every CPU core during KVM init. All nVHE per-CPU state is now grouped together in ELF and in memory. Introducing a new per-CPU variable does not require adding new memory mappings any more. nVHE hyp code cannot accidentally refer to kernel-proper per-CPU data as it only has the pointer to its own per-CPU memory. Patches are rebased on v5.9-rc3 and available in branch 'topic/percpu-v2' at: https://android-kvm.googlesource.com/linux Changes v1 -> v2: * 5.9-rc3 base * partially link hyp code, add linker script David Brazdil (10): Macros to override naming of percpu symbols and sections kvm: arm64: Partially link nVHE hyp code, simplify HYPCOPY kvm: arm64: Remove __hyp_this_cpu_read kvm: arm64: Remove hyp_adr/ldr_this_cpu kvm: arm64: Add helpers for accessing nVHE hyp per-cpu vars kvm: arm64: Duplicate arm64_ssbd_callback_required for nVHE hyp kvm: arm64: Create separate instances of kvm_host_data for VHE/nVHE kvm: arm64: Mark hyp stack pages reserved kvm: arm64: Set up hyp percpu data for nVHE kvm: arm64: Remove unnecessary hyp mappings arch/arm64/include/asm/assembler.h | 27 ++++-- arch/arm64/include/asm/kvm_asm.h | 74 ++++++++------- arch/arm64/include/asm/kvm_host.h | 2 +- arch/arm64/include/asm/kvm_mmu.h | 23 ++--- arch/arm64/include/asm/percpu.h | 33 ++++++- arch/arm64/include/asm/sections.h | 1 + arch/arm64/kernel/image-vars.h | 2 - arch/arm64/kernel/vmlinux.lds.S | 10 ++ arch/arm64/kvm/arm.c | 110 ++++++++++++++++++---- arch/arm64/kvm/hyp/hyp-entry.S | 2 +- arch/arm64/kvm/hyp/include/hyp/debug-sr.h | 4 +- arch/arm64/kvm/hyp/include/hyp/switch.h | 8 +- arch/arm64/kvm/hyp/nvhe/Makefile | 56 +++++------ arch/arm64/kvm/hyp/nvhe/hyp.lds.S | 19 ++++ arch/arm64/kvm/hyp/nvhe/switch.c | 8 +- arch/arm64/kvm/hyp/vhe/switch.c | 5 +- arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 4 +- arch/arm64/kvm/pmu.c | 13 ++- include/asm-generic/vmlinux.lds.h | 40 +++++--- 19 files changed, 304 insertions(+), 137 deletions(-) create mode 100644 arch/arm64/kvm/hyp/nvhe/hyp.lds.S --- 2.28.0.402.g5ffc5be6b7-goog