From patchwork Tue Sep 15 10:46:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Scull X-Patchwork-Id: 11776125 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 4AAFD6CA for ; Tue, 15 Sep 2020 10:57:55 +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 C69DD206DC for ; Tue, 15 Sep 2020 10:57:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JPnWrDEw"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="If96wXl6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C69DD206DC 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:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Zwb70+kRve0RmGvu55HVRgTRYoSzjsU1LG5Qfjf1D5Y=; b=JPnWrDEw6hYaVHeNfrOckH1po zVKDtSErWA584dNNl65B2JIjeL/Q3T/8afSe7fPGxq0qTKG0Ri+ttBHBYFyQUajniRY6yCwK7kQeZ 1JPda/sBxzCZ1V0Xx4XWcD2t0nSpQlremJrUZCabTghFe1EKcHXA9KPfAqMmIqgg3IA/Zyx2mxN9I tJhQJcGtWwbDcK7iSZPJq6TJAPTTIEPOtmHKlJ+RgikrdqFkGaPrIULt0lCcoMaMh1vy5B8AQL/ZG SLosOEBa437eNONDjKMzrWYLr/EeFTzpdZqhlDL5kMX0IzfCglXvchxiuj+qBK0boyiKpqsZE1qx1 2+PZH7PMA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kI8e1-000532-6b; Tue, 15 Sep 2020 10:57:06 +0000 Received: from mail-qk1-x74a.google.com ([2607:f8b0:4864:20::74a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kI8UI-0000oo-2t for linux-arm-kernel@lists.infradead.org; Tue, 15 Sep 2020 10:47:03 +0000 Received: by mail-qk1-x74a.google.com with SMTP id j5so2529534qka.7 for ; Tue, 15 Sep 2020 03:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=M4t7/aE6p0+zSqWpJ/GkDS2dH4/bNt3D09RKrZvVsWE=; b=If96wXl6ODP+VW2e9WWYWL0Wz6sxW3Dxd3nIqXfEY9Be3sqIzMbsV8Ypf6p1aZ3193 s8zNVmbu9xDUXm5fSlKcu5its1VWPw10ydcgjTxMoLs+w/2phj59zMk7yJXAaC4HMhVw SxsK9E8o+E0fO/SVkhRSrzDa5MFybmghlB75QcHQt2KtygcNq6NQPsK6iY6h79tBepKy Zzdgk/D9Z4i8XGxaf7ASIfUDNAJkJdYfksS6BE80wt1JUhYuPDu8OFsCfCRGkINpZfwY jX9VLCD83d+/kh6dhW5SM866WFwNkbgmb6eGxrUIABh7Irz1wKqYZ4nWf7HU1hMVyplS ZQVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=M4t7/aE6p0+zSqWpJ/GkDS2dH4/bNt3D09RKrZvVsWE=; b=VcF5D6x0WlcjcPxxWi9zji7llNgiz9CXGkrtcNVoRo/5BHvPo97bDPq+4P78rifhkB ta8Vapj84JqkFxIzuFV9O05KvaYoCu9OVwH3Ixzswtr4hn1zfJJwUtMl3PvcI7AzTcqC Tery98oEbNDkAdNNLi6GQ0nNK2Fzo/NZLMetuusX49O0znyZgjIVm9bm+uKq2W8MM0Po AyEju+j0c8H8o5MK1wezrFOJt7XsS3q1rme4J863NyeAPIyktzQccG5ylkKz+SQKheTx c9k9ktWSziQYBQGBqQ6Q/Ck8LzwFm3EzwdkuWX9fAY363PMu5iY8TurjUq1wqtnNG0VQ cNBA== X-Gm-Message-State: AOAM531v1EeHYXX4vQCl5oYeL6LXOeh6YY3oWz/kNLwQnCAzwziodfMo zDAvO50P/b/+iEBEva1RWbsqJGMa4pY= X-Google-Smtp-Source: ABdhPJzgtS4JfTokLsKtVQIUtfePIakOjzCus0ug3hsYcWKoTAhRuGa7cEgC6Cum/zOLTX0+1HMafuIipB0= X-Received: from ascull.lon.corp.google.com ([2a00:79e0:d:109:4a0f:cfff:fe4a:6363]) (user=ascull job=sendgmr) by 2002:ad4:458f:: with SMTP id x15mr1149968qvu.33.1600166817315; Tue, 15 Sep 2020 03:46:57 -0700 (PDT) Date: Tue, 15 Sep 2020 11:46:28 +0100 In-Reply-To: <20200915104643.2543892-1-ascull@google.com> Message-Id: <20200915104643.2543892-5-ascull@google.com> Mime-Version: 1.0 References: <20200915104643.2543892-1-ascull@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH v4 04/19] KVM: arm64: Choose hyp symbol based on context From: Andrew Scull To: kvmarm@lists.cs.columbia.edu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200915_064702_255456_794DBE2E X-CRM114-Status: GOOD ( 13.21 ) X-Spam-Score: -7.7 (-------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-7.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:74a 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 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 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-arm-kernel@lists.infradead.org, kernel-team@android.com, suzuki.poulose@arm.com, maz@kernel.org, Sudeep Holla , james.morse@arm.com, Andrew Scull , catalin.marinas@arm.com, David Brazdil , will@kernel.org, julien.thierry.kdev@gmail.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Make CHOOSE_HYP_SYM select the symbol of the active hypervisor for the host, the nVHE symbol for nVHE and the VHE symbol for VHE. The nVHE and VHE hypervisors see their own symbols without prefixes and trigger a link error when trying to use a symbol of the other hypervisor. Cc: David Brazdil Signed-off-by: Andrew Scull --- arch/arm64/include/asm/kvm_asm.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h index 6f98fbd0ac81..a952859117b2 100644 --- a/arch/arm64/include/asm/kvm_asm.h +++ b/arch/arm64/include/asm/kvm_asm.h @@ -60,10 +60,24 @@ DECLARE_KVM_VHE_SYM(sym); \ DECLARE_KVM_NVHE_SYM(sym) +#if defined(__KVM_NVHE_HYPERVISOR__) + +#define CHOOSE_HYP_SYM(sym) CHOOSE_NVHE_SYM(sym) +#define CHOOSE_NVHE_SYM(sym) sym +/* The nVHE hypervisor shouldn't even try to access VHE symbols */ +extern void *__nvhe_undefined_symbol; +#define CHOOSE_VHE_SYM(sym) __nvhe_undefined_symbol + +#elif defined(__KVM_VHE_HYPERVISOR) + +#define CHOOSE_HYP_SYM(sym) CHOOSE_VHE_SYM(sym) #define CHOOSE_VHE_SYM(sym) sym -#define CHOOSE_NVHE_SYM(sym) kvm_nvhe_sym(sym) +/* The VHE hypervisor shouldn't even try to access nVHE symbols */ +extern void *__vhe_undefined_symbol; +#define CHOOSE_NVHE_SYM(sym) __vhe_undefined_symbol + +#else -#ifndef __KVM_NVHE_HYPERVISOR__ /* * BIG FAT WARNINGS: * @@ -77,10 +91,9 @@ */ #define CHOOSE_HYP_SYM(sym) (is_kernel_in_hyp_mode() ? CHOOSE_VHE_SYM(sym) \ : CHOOSE_NVHE_SYM(sym)) -#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_VHE_SYM(sym) sym +#define CHOOSE_NVHE_SYM(sym) kvm_nvhe_sym(sym) + #endif /* Translate a kernel address @ptr into its equivalent linear mapping */