From patchwork Thu Aug 20 10:34:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Scull X-Patchwork-Id: 11726049 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 DBC79722 for ; Thu, 20 Aug 2020 10:39:18 +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 B44E320639 for ; Thu, 20 Aug 2020 10:39:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="E5Ni1hCl"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="Jindr9pC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B44E320639 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=XxMW4tgWGUduncVn7vczsMxDHlxIuim2Lnaa/2oQrOc=; b=E5Ni1hClWsUhl3r2AvU6PpkxN PVkJyrZUc/GS0IJugDc0grAODtrzAOhZsI9lH9klNsXKrc0dkJRaDCmqaWTKIyAlLKxgUzvr1l1Ij LggnGJtHgI9mL2j1WR03O3YHqVKZAbIyvhXCsWgjt0DoYtoaZTSHiE9ioRsNDDV3Fg7ouUjV2htPL zGnPmHjVVSYNji7np1TESGZcl1u7btENcGy91JFJxH3gtljAZJNDLLWnfNIXvUpiYY9jYLZC3yFJC d5/5Y9Q1Ns0gWhFGt0du0lTcz17gZ8xNUCA+l3wOKF/nLgQtHMa4rh8cOR9bKtT6vKKE6DovEYny+ eAPRvywZQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8hy8-0003is-QK; Thu, 20 Aug 2020 10:38:53 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8hvQ-0002Bk-Kr for linux-arm-kernel@lists.infradead.org; Thu, 20 Aug 2020 10:36:06 +0000 Received: by mail-wr1-x44a.google.com with SMTP id r29so507388wrr.10 for ; Thu, 20 Aug 2020 03:36:02 -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=Ii9zN72fbL1jNjFgtBff2Ivpkwsgf22REuUFgnGUMjw=; b=Jindr9pCOTI7BkHFOZrt7dPin1P9XAuaGpCEJXrxhTPBg769YCvJu2Y+p0sIHhUe0a m/mu4IUAoynf61YMQvuYWosZLzW6+gBVzqkRO2m+9FAlx2PlILA9EjDrojh4AHbxR++a 4B7Xa5guHbJpBMFlEFKxiyAqI+X970sogPNvXic+hARIRUltbagQdhmD0ax58gT5Dw6i twfHRMbLt0Evuyoc7j4WBoXHukbVcOFmuFq02MCpj9k3qhz1AqW6Si7WW/3/AL/VKego q7AdHWUcMwcw+nMt6JnMi2eHbX12F57PAP+wgnjmdw/nDNO3IbL2XcRl6uV33vDfhS2L dqZQ== 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=Ii9zN72fbL1jNjFgtBff2Ivpkwsgf22REuUFgnGUMjw=; b=jcj75bcHQomRIWYUBnwdQzavzxJzqGLtcNSKGXttGQgcrnW7WmKFdW6ItEMwyt7+jr D9Hqo6fG/qR/CIc10TNyS5ew8hcvk/L1y0DUiK9xeJBJejmXDqNxPZgTvQAIq3dWNTCQ A7M6B95nPnf8A05AGnlySADW+wiqbQRtuB3DIyOs8ipeIuikfjlrQ8nF56nWzWVTttT0 ihB73d8Z8++7Kxgj+mOlsIEEbRfpIB619LQCOXUsoYeX6Gt+H2XDlgaHgDx+fDW9u32D CNRDvNjoP8ZAvSVOoqT+6F1UNhnkJmIljoogieu2pZ01pj2ikk1JUBYYW0zY/UR98KVK R9Xg== X-Gm-Message-State: AOAM532JQWufBZ1yaMlUtX0DVPVdaW7F1NsVXlXoBSrP9xcHtpqSjEER q9V85bFzsmsubnN9GXgnxLKSrr6kudI= X-Google-Smtp-Source: ABdhPJxPNB+5u/RQcdi2M5ECef0JwtsHREpvlNV0aRevkqYpffhDYmOP41w94M1uuVN9yBJhZljPKl3ReRg= X-Received: from ascull.lon.corp.google.com ([2a00:79e0:d:109:4a0f:cfff:fe4a:6363]) (user=ascull job=sendgmr) by 2002:a5d:494b:: with SMTP id r11mr2697698wrs.419.1597919761823; Thu, 20 Aug 2020 03:36:01 -0700 (PDT) Date: Thu, 20 Aug 2020 11:34:45 +0100 In-Reply-To: <20200820103446.959000-1-ascull@google.com> Message-Id: <20200820103446.959000-20-ascull@google.com> Mime-Version: 1.0 References: <20200820103446.959000-1-ascull@google.com> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [PATCH v2 19/20] KVM: arm64: nVHE: Fix pointers during SMCCC convertion 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-20200820_063604_865087_DF7F76B6 X-CRM114-Status: GOOD ( 13.04 ) 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 [2a00:1450:4864:20:0:0:0:44a listed in] [list.dnswl.org] -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -0.0 SPF_PASS SPF: sender matches SPF record 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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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, 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 The host need not concern itself with the pointer differences for the hyp interfaces that are shared between VHE and nVHE so leave it to the hyp to handle. As the SMCCC function IDs are converted into function calls, it is a suitable place to also convert any pointer arguments into hyp pointers. This, additionally, eases the reuse of the handlers in different contexts. Signed-off-by: Andrew Scull --- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 12 ++++++------ arch/arm64/kvm/hyp/nvhe/switch.c | 2 -- arch/arm64/kvm/hyp/nvhe/tlb.c | 2 -- arch/arm64/kvm/vgic/vgic-v3.c | 4 ++-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c index 13093df70c87..78d7afcefbb8 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -27,7 +27,7 @@ static void handle_host_hcall(unsigned long func_id, struct kvm_vcpu *vcpu = (struct kvm_vcpu *)host_ctxt->regs.regs[1]; - ret = __kvm_vcpu_run(vcpu); + ret = __kvm_vcpu_run(kern_hyp_va(vcpu)); goto out; } @@ -41,21 +41,21 @@ static void handle_host_hcall(unsigned long func_id, phys_addr_t ipa = host_ctxt->regs.regs[2]; int level = host_ctxt->regs.regs[3]; - __kvm_tlb_flush_vmid_ipa(mmu, ipa, level); + __kvm_tlb_flush_vmid_ipa(kern_hyp_va(mmu), ipa, level); break; } case KVM_HOST_SMCCC_FUNC(__kvm_tlb_flush_vmid): { struct kvm_s2_mmu *mmu = (struct kvm_s2_mmu *)host_ctxt->regs.regs[1]; - __kvm_tlb_flush_vmid(mmu); + __kvm_tlb_flush_vmid(kern_hyp_va(mmu)); break; } case KVM_HOST_SMCCC_FUNC(__kvm_tlb_flush_local_vmid): { struct kvm_s2_mmu *mmu = (struct kvm_s2_mmu *)host_ctxt->regs.regs[1]; - __kvm_tlb_flush_local_vmid(mmu); + __kvm_tlb_flush_local_vmid(kern_hyp_va(mmu)); break; } case KVM_HOST_SMCCC_FUNC(__kvm_timer_set_cntvoff): { @@ -89,14 +89,14 @@ static void handle_host_hcall(unsigned long func_id, struct vgic_v3_cpu_if *cpu_if = (struct vgic_v3_cpu_if *)host_ctxt->regs.regs[1]; - __vgic_v3_save_aprs(cpu_if); + __vgic_v3_save_aprs(kern_hyp_va(cpu_if)); break; } case KVM_HOST_SMCCC_FUNC(__vgic_v3_restore_aprs): { struct vgic_v3_cpu_if *cpu_if = (struct vgic_v3_cpu_if *)host_ctxt->regs.regs[1]; - __vgic_v3_restore_aprs(cpu_if); + __vgic_v3_restore_aprs(kern_hyp_va(cpu_if)); break; } default: diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c index b7abe66fde22..0d8187358565 100644 --- a/arch/arm64/kvm/hyp/nvhe/switch.c +++ b/arch/arm64/kvm/hyp/nvhe/switch.c @@ -176,8 +176,6 @@ int __kvm_vcpu_run(struct kvm_vcpu *vcpu) pmr_sync(); } - vcpu = kern_hyp_va(vcpu); - host_ctxt = &__hyp_this_cpu_ptr(kvm_host_data)->host_ctxt; host_ctxt->__hyp_running_vcpu = vcpu; guest_ctxt = &vcpu->arch.ctxt; diff --git a/arch/arm64/kvm/hyp/nvhe/tlb.c b/arch/arm64/kvm/hyp/nvhe/tlb.c index 69eae608d670..544bca3072b7 100644 --- a/arch/arm64/kvm/hyp/nvhe/tlb.c +++ b/arch/arm64/kvm/hyp/nvhe/tlb.c @@ -54,7 +54,6 @@ void __kvm_tlb_flush_vmid_ipa(struct kvm_s2_mmu *mmu, dsb(ishst); /* Switch to requested VMID */ - mmu = kern_hyp_va(mmu); __tlb_switch_to_guest(mmu, &cxt); /* @@ -108,7 +107,6 @@ void __kvm_tlb_flush_vmid(struct kvm_s2_mmu *mmu) dsb(ishst); /* Switch to requested VMID */ - mmu = kern_hyp_va(mmu); __tlb_switch_to_guest(mmu, &cxt); __tlbi(vmalls12e1is); diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c index 76e2d85789ed..9cdf39a94a63 100644 --- a/arch/arm64/kvm/vgic/vgic-v3.c +++ b/arch/arm64/kvm/vgic/vgic-v3.c @@ -662,7 +662,7 @@ void vgic_v3_load(struct kvm_vcpu *vcpu) if (likely(cpu_if->vgic_sre)) kvm_call_hyp(__vgic_v3_write_vmcr, cpu_if->vgic_vmcr); - kvm_call_hyp(__vgic_v3_restore_aprs, kern_hyp_va(cpu_if)); + kvm_call_hyp(__vgic_v3_restore_aprs, cpu_if); if (has_vhe()) __vgic_v3_activate_traps(cpu_if); @@ -686,7 +686,7 @@ void vgic_v3_put(struct kvm_vcpu *vcpu) vgic_v3_vmcr_sync(vcpu); - kvm_call_hyp(__vgic_v3_save_aprs, kern_hyp_va(cpu_if)); + kvm_call_hyp(__vgic_v3_save_aprs, cpu_if); if (has_vhe()) __vgic_v3_deactivate_traps(cpu_if);