Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp388755pxk; Thu, 3 Sep 2020 02:22:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMaF9IT+nIwZ+RPoiYvvacqLjITEqiUsjbQh5i5hs6eeqZRQ9KnMNWyEg7ljljeefBMHYQ X-Received: by 2002:a17:907:2168:: with SMTP id rl8mr1153322ejb.308.1599124935911; Thu, 03 Sep 2020 02:22:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599124935; cv=none; d=google.com; s=arc-20160816; b=w92Nhoam0QrapXnhOEWjWZY4KiAk2fJas4H+jHNfdMTundR1hU2cpIdzvIoMJxigyD UO2g5EBEsPAdZMtWUE6YXkB686A7CDhTu+SL8ZvyynX+5xDP2/5fyMeEuos4A9t4MCOY F0VFOBJF+B+TLJyEXfJQNjFZ0tG4P6hh9i+Q206o2lYUkdJv9nWZHj9rZKdYK4eqaYoO 55b88VAZ6TO5U76j/Bu88jMDcGzzye38z2/VedgyhnFRAlvjt/PZT4v8FxT5p9a3uzPG aXGz/w/axlsMkDn3wPvCBgKtQ/h+5k3dyBhFBEKA3qWuJe9l9edrXJKjTPQ6rCu/GV84 xmcg== 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=lr26ux0OOjKqBElJON72X2bDuUHIIFflkukJO3BWbvU=; b=V1pIrueg8IQ6GoPsEu8m03cqQPZV0z34FeyzoYO2IriTT6+oeWRJ1WwApyGDkR+urI jcy8p65x7eTT28cH5GSW3SOAWYPiaFgSMUPmghH/NuDtPJz310S6oXHRZEEaMPVWViRt VYYVdotLbfarGyRhEC6ZRuJAx2iVoftsqT/nZ/uJ8K4XiB/bwsSx9OSXfpU9xoaZnzVk KKDSsg4XhysHE7YFlFgiIvPwL4sLHJRM+P8S6EQnaGe3bLl6T1SwJV4MiBcsp66sONGM hAhfKLB5BxvwAWmWtulNCOv5Pr5ocsC4lvZBmR98n/r+vCU/VT+jW6jX+5C6KewPhiqm klPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ibaN6UVu; 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 y89si1244462ede.586.2020.09.03.02.21.52; Thu, 03 Sep 2020 02:22:15 -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=ibaN6UVu; 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 S1728442AbgICJSw (ORCPT + 99 others); Thu, 3 Sep 2020 05:18:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgICJR4 (ORCPT ); Thu, 3 Sep 2020 05:17:56 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C6C7C06124F for ; Thu, 3 Sep 2020 02:17:49 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id j11so2887481ejk.0 for ; Thu, 03 Sep 2020 02:17:49 -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=lr26ux0OOjKqBElJON72X2bDuUHIIFflkukJO3BWbvU=; b=ibaN6UVuyMWanD/p/syhzRmTyFuupe1wk12IPBNXGichEgTkklyUUzy7oxzAUVwF14 5bnjjmfHLlMy5ji9KSMCLbP7UER0UcEHRPFkukXNMEJrAXyWkKKhNA6xGa5CjZ55qrBn M1JIPvdv5M1d5OYPv0nEEBa9+CWY76zMCqtZxvvUXWq+fTYMqlOYzh0VOa8DBh4sIxIU gPAB3kITbTsjqhMnV9JKcuqDcJEd+mL27vzwiNl8NSdIRVhBbvONoim/RFqzbpZ1zGDX KdUU4dB2O45UnNf3T4r/QYNBddgXEb080EB4ixmCZwI96W4HF9pMuBnfG+4vo77c214P +hmg== 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=lr26ux0OOjKqBElJON72X2bDuUHIIFflkukJO3BWbvU=; b=NHNktXu8Azd/G46bElWrsf7+/h/tieI/0l2G4SyuYow47qNC9irNjyq0sEkZKFlyYc NQP0QOMY4P6b22f+v3frM2oUfY1bBG8dOYyqw7i6bUafbhIeNLlQUUhj7/4cVDUiFPpR tgP9dt4SVXn3En5kQa1k7pGSViULuIuwNV/JgvO12nmB89aqxVgGwbMLI/WbY/GFWaiE B6fIqi0hNSABfjzcSmmjjsD6mTUdwXnS6YK8yu4ayMRXjCzHt5hfP86UFxlRzaK8gpIZ 0viCnEE5arvYdhm0YGZyffkJOmqfkv1vDmUB/19a1HDRif0Dch3QHgA8CuwKKkq7D+F9 mMcg== X-Gm-Message-State: AOAM532qgt3AGvPuYgSy1EDm9Gx+ygR60Avi85B4h1d9OM1tVvgBhJEP AoiqePj6LZTd2OiMcZMdGjSY4A== X-Received: by 2002:a17:906:5856:: with SMTP id h22mr1120110ejs.480.1599124667692; Thu, 03 Sep 2020 02:17:47 -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 gw6sm2638439ejb.47.2020.09.03.02.17.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Sep 2020 02:17:46 -0700 (PDT) From: David Brazdil To: Marc Zyngier , Catalin Marinas , Will Deacon , 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@android.com, David Brazdil Subject: [PATCH v2 05/10] kvm: arm64: Add helpers for accessing nVHE hyp per-cpu vars Date: Thu, 3 Sep 2020 11:17:07 +0200 Message-Id: <20200903091712.46456-6-dbrazdil@google.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200903091712.46456-1-dbrazdil@google.com> References: <20200903091712.46456-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 469c0662f7f3..2b89817cdb01 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.28.0.402.g5ffc5be6b7-goog