From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 A6513C43463 for ; Fri, 18 Sep 2020 09:25:26 +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 34ED620DD4 for ; Fri, 18 Sep 2020 09:25:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ArxXwlog"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="xU5lzR1G" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 34ED620DD4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BnmtjrNMPEt9OccuefwF69ln86OK6cFcBWCTZZ00caU=; b=ArxXwlogTA0nyvOg1XWSrEB5V duIE5I0fB7rkuLN4J7LRaK+SQwvFkD7K1fa07Nb2Pp+kuxptiCk0XdJriw4V16ViULhjD9/9NFeEe bJXejtAhmFmc8R8Pvkb+dfhlhiedggEIdLlENbpPi8eY0U39N2xRCLPoWN11wBstHx5n1NmkUb/A8 tIxK5CoK0l83tpB29TutVS5YrUH7AaZEkEE4fcmx4kKMgIGY075f0QlDHF/5JlwDvS+AnJueZoUi0 Nc1gROr9rXVrastXm6fBsypSG3aDU3lOM4Vl4jouRrCL8MXL9go9JOePMUQcLbPbLAsyDlkxoeEB2 G8vzuL+lA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJCck-0001BO-Nh; Fri, 18 Sep 2020 09:24:10 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJCch-0001AF-I7 for linux-arm-kernel@lists.infradead.org; Fri, 18 Sep 2020 09:24:08 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 238A120DD4; Fri, 18 Sep 2020 09:24:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600421046; bh=5BPFCutNa5VNQMibpDHHB+qvvOTgQcOE09RubxpF1GI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xU5lzR1Ga0PcfhABCdoUUHXJd6dN4fDFAU+RJC4XjY97A6xGaeDusE+AIxQe09UUe cjDXcplObHW/R0vJ/QWHVnEYHNiAmMG2eH98/7f5xG9jUnkaKa5fMSVYDlcCKKQY1K 3J3oarxI8eW8I9yOa/ZZSSr5YNbR3x/6bNNhLGVY= Date: Fri, 18 Sep 2020 10:24:01 +0100 From: Will Deacon To: David Brazdil Subject: Re: [PATCH v3 06/11] kvm: arm64: Add helpers for accessing nVHE hyp per-cpu vars Message-ID: <20200918092400.GF30834@willie-the-truck> References: <20200916173439.32265-1-dbrazdil@google.com> <20200916173439.32265-7-dbrazdil@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200916173439.32265-7-dbrazdil@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200918_052407_741555_6DD80288 X-CRM114-Status: GOOD ( 22.06 ) 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: Suzuki K Poulose , Catalin Marinas , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Marc Zyngier , Tejun Heo , Dennis Zhou , Christoph Lameter , kernel-team@android.com, kvmarm@lists.cs.columbia.edu, Julien Thierry Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Sep 16, 2020 at 06:34:34PM +0100, David Brazdil wrote: > 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 cf9456663289..abc03f386b40 100644 > --- a/arch/arm64/include/asm/kvm_asm.h > +++ b/arch/arm64/include/asm/kvm_asm.h > @@ -54,9 +54,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) nit: I'd probably stick a _sym suffix on these macros, to make it clear that they're just munging the symbol name rather than doing some completely different pcpu implementation. THat said, do you expect these to be used outside of the pcpu implementation? If not, I suggest some underscores as a prefix as well. > #ifndef __KVM_NVHE_HYPERVISOR__ > /* > * BIG FAT WARNINGS: > @@ -69,12 +81,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)) is_kernel_in_hyp_mode() reads a system register to determine the current exception level, so this doesn't seem like something we should be doing everytime here. Perhaps is_kernel_in_hyp_mode() should avoid read_sysreg() and instead use a non-volatile asm to allow the result to be cached by the compiler. Hmm. But I think that can be tackled as a future patch, so with the naming nits resolved: Acked-by: Will Deacon Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel