Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp654212ybh; Wed, 22 Jul 2020 09:45:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzscrBBruyWU+8H5Zr1gDk+mUOPG0vTn2/X4hQjLy8ws6ZXukZSpXOmtVUFLwtHzBXue8nX X-Received: by 2002:a17:906:3a04:: with SMTP id z4mr371905eje.441.1595436355843; Wed, 22 Jul 2020 09:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595436355; cv=none; d=google.com; s=arc-20160816; b=cp2OCV1cRvkh/0JA1+rlGWtvJKe6QegdXkWbn3Xz4TQVrXJhnrMxqKBV6KbaYu4ku9 yhdf5JBQ/RX3fnW6yr+sVPc+BIpMtowsy4EWKQy6/F8NY0numhBwLfYTguddumciipUJ jerD1FUbXdp1wnj38O16t7Cy7668aGkiaWwVKC3Ra5rqACKsMQ0kbY6IePX9oCs2memP E+w6Fo5TJqzFDPpBNcvqtT/r7SA54mZBIaBLqvqMPFqhQcLtzPafGYV/DeH6BxRPi+Dr yReT8+Rm14SPv9bx8rAWiVF0tlFP37JmV3G/ZdP9/sQlWmgd7HSv2c5RQD9jHWXfVqYH +M4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZXiAbLOq4ubRUcURJC9B1BLv2xJ+3CpTn0EBGii9veo=; b=UeD8hzWbdKDnUmfc63QLVEyOeMExMKVaOHIQ/H+ikAPs4XwoVD7HerQesb87xA4bB3 2bJszGnhMCLWIbgMJ/dsBudsqi2iIOPCfoL/8SuMddrIEa7wRTb7zzfpFZZ7+yCJNmyW QP4ue4MQZ2mQr5L8F7A6bx1etwel887xltroAFZVvwSz7jMtlZHjSBmYvEfDl1vZG0w8 e658wm5pfJsvSnumnPU8PY41lwa+Gf1vhUNWpVX0DIVGsWonPZKqowJe2852dP8TJv2h bHFofy8Mt9cJZn06IQ0Z4nlNOE29a9gg+ZvNRB63zZjBiYF6EuJWe5ZRv+JNyvLNRS1g 56hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FdmUXfPp; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c17si367664edr.237.2020.07.22.09.45.32; Wed, 22 Jul 2020 09:45:55 -0700 (PDT) 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=@google.com header.s=20161025 header.b=FdmUXfPp; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731199AbgGVQpN (ORCPT + 99 others); Wed, 22 Jul 2020 12:45:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731078AbgGVQpI (ORCPT ); Wed, 22 Jul 2020 12:45:08 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C31DFC0619DC for ; Wed, 22 Jul 2020 09:45:07 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id f7so2572347wrw.1 for ; Wed, 22 Jul 2020 09:45:07 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZXiAbLOq4ubRUcURJC9B1BLv2xJ+3CpTn0EBGii9veo=; b=FdmUXfPpY7o9uEYvSP5nVu4ofg8PL0EkzaQt7c+IphnlbncN6veKPYDXPYLTXRODhI 6vN22+BUNOewLPRoB+VyntfTGU4957QCwvCWV4Rw7/XkrQ5nCgRdII3n6ncKJXismyaG QS0jI990BiiNf12aOl1OO24EJqhL4eaTHvJhZbTDwwVFTC3dpmWz+SUWBIJik8UNPp67 ECuHSrQPykTUctnyqBj2l7S9VS7/jA1LuCpMeq71p8zbNS1+omtsRiI4ZMO+HJbglaMO Mum0PSJ1/kp1e9/TTPm0RAKKWXHtacAuaJYN4Yme80qiYihUdK+xHTp+LbJ5sEzZYVCJ fGDQ== 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=ZXiAbLOq4ubRUcURJC9B1BLv2xJ+3CpTn0EBGii9veo=; b=dEd7mqiHQ4Gn+4LuvfHFK2nEz1eVqB81N0jAdm5CwhvYQLdKLdluikS59YEPPExtKA 5/rQQoCl441oqcMNU04ySVnbbEe3yM4hSlc2fIDCfk8+6/2fZHFqKtqvFYYEl+JexSuj mUkdECwBqkxhENFo5qf0CnI2IzYERsaujQdTC5YUTJtXrJYayglt9cpKSdE+o90wEIzU hLlau4cab2GPaHNdL1aEk2O5GLGyQLoHUCjuyt8t/DwhRaDvh3TmBxI6JuqaCSK4K09H FZDZ36MYeKPHVUr5Y/gZPjAvl/lFGTTs9Qb5ZCjDxnZYty0UrZ0hDhBdz21CLk/iZDWr iAjQ== X-Gm-Message-State: AOAM531Yp5ZkWsL4YLcT+kjxi7ZqcEy03w9Bv8QeqwCqvbBLncmkvbw7 ebUUTvUP4I+fImIDoJbm7GHbhg== X-Received: by 2002:a5d:6288:: with SMTP id k8mr347278wru.373.1595436306334; Wed, 22 Jul 2020 09:45:06 -0700 (PDT) Received: from localhost ([2a01:4b00:8523:2d03:b0ee:900a:e004:b9d0]) by smtp.gmail.com with ESMTPSA id 33sm590292wri.16.2020.07.22.09.45.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jul 2020 09:45:05 -0700 (PDT) From: David Brazdil To: Catalin Marinas , Will Deacon , Marc Zyngier , Dennis Zhou , Tejun Heo , Christoph Lameter , Arnd Bergmann Cc: James Morse , Julien Thierry , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arch@vger.kernel.org, kernel-team@google.com, David Brazdil Subject: [PATCH 4/9] kvm: arm64: Add helpers for accessing nVHE hyp per-cpu vars Date: Wed, 22 Jul 2020 17:44:19 +0100 Message-Id: <20200722164424.42225-5-dbrazdil@google.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200722164424.42225-1-dbrazdil@google.com> References: <20200722164424.42225-1-dbrazdil@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Defining a per-CPU variable in hyp/nvhe will result in its name being prefixed with __kvm_nvhe_. Add helpers for declaring these variables in kernel proper and accessing them with this_cpu_ptr and per_cpu_ptr. Signed-off-by: David Brazdil --- arch/arm64/include/asm/kvm_asm.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h index bbd14e205aba..3d69cab873e4 100644 --- a/arch/arm64/include/asm/kvm_asm.h +++ b/arch/arm64/include/asm/kvm_asm.h @@ -60,9 +60,21 @@ DECLARE_KVM_VHE_SYM(sym); \ DECLARE_KVM_NVHE_SYM(sym) +#define DECLARE_KVM_VHE_PER_CPU(type, sym) \ + DECLARE_PER_CPU(type, sym) +#define DECLARE_KVM_NVHE_PER_CPU(type, sym) \ + DECLARE_PER_CPU(type, kvm_nvhe_sym(sym)) + +#define DECLARE_KVM_HYP_PER_CPU(type, sym) \ + DECLARE_KVM_VHE_PER_CPU(type, sym); \ + DECLARE_KVM_NVHE_PER_CPU(type, sym) + #define CHOOSE_VHE_SYM(sym) sym #define CHOOSE_NVHE_SYM(sym) kvm_nvhe_sym(sym) +#define this_cpu_ptr_nvhe(sym) this_cpu_ptr(&kvm_nvhe_sym(sym)) +#define per_cpu_ptr_nvhe(sym, cpu) per_cpu_ptr(&kvm_nvhe_sym(sym), cpu) + #ifndef __KVM_NVHE_HYPERVISOR__ /* * BIG FAT WARNINGS: @@ -75,12 +87,21 @@ * - Don't let the nVHE hypervisor have access to this, as it will * pick the *wrong* symbol (yes, it runs at EL2...). */ -#define CHOOSE_HYP_SYM(sym) (is_kernel_in_hyp_mode() ? CHOOSE_VHE_SYM(sym) \ +#define CHOOSE_HYP_SYM(sym) (is_kernel_in_hyp_mode() \ + ? CHOOSE_VHE_SYM(sym) \ : CHOOSE_NVHE_SYM(sym)) +#define this_cpu_ptr_hyp(sym) (is_kernel_in_hyp_mode() \ + ? this_cpu_ptr(&sym) \ + : this_cpu_ptr_nvhe(sym)) +#define per_cpu_ptr_hyp(sym, cpu) (is_kernel_in_hyp_mode() \ + ? per_cpu_ptr(&sym, cpu) \ + : per_cpu_ptr_nvhe(sym, cpu)) #else /* The nVHE hypervisor shouldn't even try to access anything */ extern void *__nvhe_undefined_symbol; -#define CHOOSE_HYP_SYM(sym) __nvhe_undefined_symbol +#define CHOOSE_HYP_SYM(sym) __nvhe_undefined_symbol +#define this_cpu_ptr_hyp(sym) &__nvhe_undefined_symbol +#define per_cpu_ptr_hyp(sym, cpu) &__nvhe_undefined_symbol #endif /* Translate a kernel address @ptr into its equivalent linear mapping */ -- 2.27.0