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=-15.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 D2454C433E2 for ; Wed, 16 Sep 2020 17:37:33 +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 6B31020672 for ; Wed, 16 Sep 2020 17:37:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="INsw5KVj"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="qo4UjMaG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B31020672 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=5ebkeWslDjUjWg3fuGKaIpM0Wa/Ps26YPyNmcAPNTUM=; b=INsw5KVjHUyhryCN3V09ssnKj 5i9oL0LPz1nWOKP2d4xp30GeysWG53vk80P3KKKezk1lQ7dI1e/vBGycAR5qeVeK3MciNnyfhh8I6 jcr5++WIkZ7s3SmMuiE0zKZNw/yGKhVNO5w/CjVnl1YfaW5d11CI7ZQsk6Z48HSwZMkyvD08yo8NC 5XVYKgCFuIGUby/PLGGG1hkkXuWj9jHI6++q6rAEkDzL7Sn8/m3Boj5bD6R5r6CjcMYwhbXRtvUKf 4FkmqFaVKJ/w1Kz3GufbLxvDa96ENEwpBLiW2512b6ICIUPJizPTngoZQkr0AP2iys2lARSYf7MQ/ NkB3Hi9HQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIbL8-00012l-Lp; Wed, 16 Sep 2020 17:35:30 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIbKc-0000tt-OC for linux-arm-kernel@lists.infradead.org; Wed, 16 Sep 2020 17:34:59 +0000 Received: by mail-wr1-x443.google.com with SMTP id o5so7706996wrn.13 for ; Wed, 16 Sep 2020 10:34:58 -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=jm9txujGRbU+DIE5pQGENaBdVyNjHKuT2OQRoaKu5mk=; b=qo4UjMaG+LBmqizh/dguDo/1ZgFI6RSCpgvcu7UWxVpteEpYt6NHNQhs2cLgolyhud x3Ot+cX0Sp2hdxCGGm2R7QvodsCr54yNugnLPLPt6pSz/0vqaUvUP1vkJImvPJavE1JU /KWaXjiMd2VyyjXhCcJVrjDOEZ7J/mXd9xq5tVPX0hBQl/hG2W1oMc+sNcdIQEjaEbyg P5irBhmyRSSZ3oYyYC65aFW/vOXx2S2ACJsVISa0BOHj761vLtFGseGu2WvmEE1bh+RI 4Uivcqab87R5WzqTKUqjgCu6wND91b07/46tLA512z6Ayp8j0YmNjO6b4dewhw1zZG7S pKyQ== 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=jm9txujGRbU+DIE5pQGENaBdVyNjHKuT2OQRoaKu5mk=; b=WajtAaZyxgl0tFy9LRc4HkOp6Wm6vOThihPfhWqHgExb0e9+T/3gDH1lG4Z46aUfSa CdzWawRWekWc3CJgcBivp+358FgrzD63W+Ug4RzrSwYWRNirmu3PU8J157KTp9hSG4kf DogAhwPN7E2so2S/8rzmEhrqDQLYjwS3sSRz6eT9sDYevPc5iMkNlNg9vN6wcALI08Ex M4YOyI7co55lmIfbV4E32ASmoMCV0NKiDv0AQDgCm9nKzi2aiVav7AIhp8aaatom/7bt t8eB2uAWUq9yu7MdNLUXwKHiwGNHGzQd9BuXbsyLREcnxwAzQxLIexJmd0os2Up+Bz0z +WUw== X-Gm-Message-State: AOAM530sGS2auMQjJrlzmrjUTjA/4QsgfsNeovES5HgwrStywqwufO+L SbV17/of0Ej0hvzClU8tC9b3Rg== X-Google-Smtp-Source: ABdhPJwU4kbhpWG5C/yjfJonDHsb6tdTDo9eAoD2gMl5GCOkrw+z409Io9EwIzx1e93E00CEZFWrkw== X-Received: by 2002:a05:6000:118a:: with SMTP id g10mr28697445wrx.67.1600277697172; Wed, 16 Sep 2020 10:34:57 -0700 (PDT) Received: from localhost ([2a01:4b00:8523:2d03:e49d:f6be:d31b:ad3c]) by smtp.gmail.com with ESMTPSA id v204sm6596978wmg.20.2020.09.16.10.34.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Sep 2020 10:34:56 -0700 (PDT) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [PATCH v3 06/11] kvm: arm64: Add helpers for accessing nVHE hyp per-cpu vars Date: Wed, 16 Sep 2020 18:34:34 +0100 Message-Id: <20200916173439.32265-7-dbrazdil@google.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200916173439.32265-1-dbrazdil@google.com> References: <20200916173439.32265-1-dbrazdil@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200916_133458_809270_93D6DB54 X-CRM114-Status: GOOD ( 15.03 ) 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: kernel-team@android.com, 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 , David Brazdil , Will Deacon , 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 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) + #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)) #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.618.gf4bc123cb7-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel