From patchwork Thu Sep 3 13:53:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Scull X-Patchwork-Id: 11753667 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 52BC8618 for ; Thu, 3 Sep 2020 13:56:58 +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 28BD4208B3 for ; Thu, 3 Sep 2020 13:56:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TbsKTy1R"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="CumNjUfG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 28BD4208B3 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=qXouRajbEt8elRT7gVySGvUlbRcwZ8L4EmlaPLT+Kv0=; b=TbsKTy1R1HLEOLK8NCMxytkuV uHj2joIJrSFgxoCOymapsA91/zpGq66OJFVQhAVq7h66wKL3IrA8lTrON2dI7oIwozCXfgTEo9hRK MxHROYn7x8vHLNwVIsVvNWhqXB9fLbbtsKQyHhhbFZaNQk9CAN3e9ekSVfxaWgzpVp6BeII0FbLTL tyy7tHsxVPNDx0EcrLvaYlGnHBr1yiDj/Ko37XsuI/DvtjbWZqnl5pnuH6+lNbW5ySo4jGv9nHcp0 wfqWN8opq1zVt30PgB5xlysBWAeBE09/DsI5rhKX4psqvAJK6WwsvH22b3iPHplpTGy2cIwIXw/Kp bqAIIkCkg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDpjC-0003mu-Vh; Thu, 03 Sep 2020 13:56:39 +0000 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDpgZ-00029j-M5 for linux-arm-kernel@lists.infradead.org; Thu, 03 Sep 2020 13:53:57 +0000 Received: by mail-wm1-x34a.google.com with SMTP id 23so987055wmk.8 for ; Thu, 03 Sep 2020 06:53:52 -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=SSMgwsDERxeH1C9AIeHiykVI2xNip90xe/fTZ0SwDeI=; b=CumNjUfGOifQba/B20PBpMeVCu238q477osYFMnInIKZ39dhnbrvjngo7wBzWTmCKC Go4DwQ971jvo6zoBV9wicpTNNZJMvCU62KK1u0OD/uKpMG5+5WgdEICJv3u20hrRmYR9 jCSU0e4Pkv9CrEIKJVJ33WsLXWhLJAA8JyNaKPJfMCs6tIc/pzoRO3RCFQukKiuH7tqq hVWfEL7Qo6T0EsJIX1UKESlaAXs9inDivqh7Q3OzUy8INeqQmUcXj+aaNAkWzv0icVHs R8x68VIxvFrp09fsd9eThK3z6OGx3zPYL5X+2LSZ9LCCVMKjJqJiBB+ycX8V67mAq5mR rNwQ== 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=SSMgwsDERxeH1C9AIeHiykVI2xNip90xe/fTZ0SwDeI=; b=JdYE7ai9HbUskU/9vFZW+UADaNdgJwz4X3rXHsdvPQsEi08dtH0L5NN1grghhk0Jfk gMSIKqAkCs7ZE7jpWcEdm02ZDnbmBxjDsFknFGmK1l4kRUswCxKGvzJ7SWNkSYXzv02P sdm/M0P8A8Ds/RhHxzGf1QUnBeg8GyzFTt15kSfhRHGyFTF0KT0lAE/T4tt7JsCI6o6U c+sqmIcUInE7CoZDm0z8PdFLcmob01r6iR5DU7OtERDnkL3gyJm+cPL7YBoehS9S+so2 h1pqAmx0dTSFi4AJIEdj1c8/rRl81P2qpwUqsqlIB7SuynfZiNTolSQJyHsSXPVIodFv BS2w== X-Gm-Message-State: AOAM531YO+XH0ER6zbHnMv5xvFKlqUtMeyymGS+GpuCsJBKzqcskjSF+ DDzDTC76hzW6THdVARe6DzNWfvnapvc= X-Google-Smtp-Source: ABdhPJxOcTfOHi/LwXdsaDwL4B6glURhxFGbKkKrQXNsKtuhTeaH3Zh6brvCBzoCoiXV3lduNp3jGqzw+tM= X-Received: from ascull.lon.corp.google.com ([2a00:79e0:d:109:4a0f:cfff:fe4a:6363]) (user=ascull job=sendgmr) by 2002:a1c:8109:: with SMTP id c9mr2665815wmd.130.1599141232149; Thu, 03 Sep 2020 06:53:52 -0700 (PDT) Date: Thu, 3 Sep 2020 14:53:07 +0100 In-Reply-To: <20200903135307.251331-1-ascull@google.com> Message-Id: <20200903135307.251331-19-ascull@google.com> Mime-Version: 1.0 References: <20200903135307.251331-1-ascull@google.com> X-Mailer: git-send-email 2.28.0.402.g5ffc5be6b7-goog Subject: [PATCH v3 18/18] 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-20200903_095355_809161_22210963 X-CRM114-Status: GOOD ( 13.26 ) X-Spam-Score: -8.2 (--------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-8.2 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:34a 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_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.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.5 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 b4f6ae1d579a..6443ef91bff4 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);