Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1554057

[RFC 23/55] KVM: arm64: Forward WFX to the guest hypervisor

Path csiph.com!goblin2!goblin.stu.neva.ru!news.unit0.net!news.panservice.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod
From Jintack Lim <jintack@cs.columbia.edu>
Newsgroups linux.kernel
Subject [RFC 23/55] KVM: arm64: Forward WFX to the guest hypervisor
Date Mon, 09 Jan 2017 07:30:01 +0100
Message-ID <sXBCV-wl-7@gated-at.bofh.it> (permalink)
References <sXBCV-wl-3@gated-at.bofh.it>
X-Original-To christoffer.dall@linaro.org, marc.zyngier@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, vladimir.murzin@arm.com, suzuki.poulose@arm.com, mark.rutland@arm.com, james.morse@arm.com, lorenzo.pieralisi@arm.com, kevin.brodsky@arm.com, wcohen@redhat.com, shankerd@codeaurora.org, geoff@infradead.org, andre.przywara@arm.com, eric.auger@redhat.com, anna-maria@linutronix.de, shihwei@cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org
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; bh=U5HC7ruizG/OI6UbmUN50LCxpsRmvtR53XHpI3gTmzU=; b=Xdp1G4L5VWcdAWCqNHbab5QcmzUvrnDU/DwilR0y9DPEhn14M2jFlJORDkKnWBeqCx k+H3y0SxqDUXBVhjxojZYLkIV/tq65WvRYff0dm4Cl6/a4vPK5s1hy7k/GzcqNEBEk/l /8CzanpiadnOjs2uuqG2ihLOKZKP7pboer9WDAURK3iPj+RB/MkgYzgyBBawKQuxWyhl YyMJDNCGjsOlVGGdefKCkqxmRfTKqNZc6VnPT1EiVi+1gYUkJJUJonlLRW7hCROw8xYh IdD9xUZNKtta4FVuqXt6pVRSVLA1KWd/nMUcJWhSkeKJRGo5ZwggfB9iCsc/sgTyzsfr 5ztg==
X-Gm-Message-State AIkVDXKduWLtUuuFWyprBiT56prqPYehUpTmQsfArx8CTYkvNejxvrN56vRc/IFLiifPrgqigl4CybuZ2i9OxBGFYEuz021mBz31GFbLMHM10tP15+BV3g6K3gswSUy2tZ35vZ5K4SUOUfjE9us6uPSU4+o=
X-Received by 10.237.59.150 with SMTP id r22mr80937462qte.162.1483943162310; Sun, 08 Jan 2017 22:26:02 -0800 (PST)
X-Received by 10.237.59.150 with SMTP id r22mr80937427qte.162.1483943162146; Sun, 08 Jan 2017 22:26:02 -0800 (PST)
X-Mailer git-send-email 1.9.1
X-No-Spam-Score Local
X-Scanned-By MIMEDefang 2.78 on 128.59.72.16
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 70
Organization linux.* mail to news gateway
X-Original-Cc jintack@cs.columbia.edu
X-Original-Date Mon, 9 Jan 2017 01:24:19 -0500
X-Original-Message-ID <1483943091-1364-24-git-send-email-jintack@cs.columbia.edu>
X-Original-References <1483943091-1364-1-git-send-email-jintack@cs.columbia.edu>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1554057

Show key headers only | View raw


Forward exceptions due to WFI or WFE to the guest hypervisor if the
guest hypervisor has set corresponding virtual HCR_EL2.TWX bits.

Signed-off-by: Jintack Lim <jintack@cs.columbia.edu>
---
 arch/arm64/include/asm/kvm_nested.h |  1 +
 arch/arm64/kvm/handle_exit.c        | 11 ++++++++++-
 arch/arm64/kvm/handle_exit_nested.c | 18 ++++++++++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/kvm_nested.h b/arch/arm64/include/asm/kvm_nested.h
index 620b4d3..8d36935 100644
--- a/arch/arm64/include/asm/kvm_nested.h
+++ b/arch/arm64/include/asm/kvm_nested.h
@@ -2,4 +2,5 @@
 #define __ARM64_KVM_NESTED_H__
 
 int handle_hvc_nested(struct kvm_vcpu *vcpu);
+int handle_wfx_nested(struct kvm_vcpu *vcpu, bool is_wfe);
 #endif
diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
index ce6d2ef..046fdf8 100644
--- a/arch/arm64/kvm/handle_exit.c
+++ b/arch/arm64/kvm/handle_exit.c
@@ -101,7 +101,16 @@ static int handle_smc(struct kvm_vcpu *vcpu, struct kvm_run *run)
  */
 static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run)
 {
-	if (kvm_vcpu_get_hsr(vcpu) & ESR_ELx_WFx_ISS_WFE) {
+	bool is_wfe = !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_WFx_ISS_WFE);
+#ifdef CONFIG_KVM_ARM_NESTED_HYP
+	int ret = handle_wfx_nested(vcpu, is_wfe);
+
+	if (ret < 0 && ret != -EINVAL)
+		return ret;
+	else if (ret >= 0)
+		return ret;
+#endif
+	if (is_wfe) {
 		trace_kvm_wfx_arm64(*vcpu_pc(vcpu), true);
 		vcpu->stat.wfe_exit_stat++;
 		kvm_vcpu_on_spin(vcpu);
diff --git a/arch/arm64/kvm/handle_exit_nested.c b/arch/arm64/kvm/handle_exit_nested.c
index a6ce23b..871ecfc 100644
--- a/arch/arm64/kvm/handle_exit_nested.c
+++ b/arch/arm64/kvm/handle_exit_nested.c
@@ -25,3 +25,21 @@ int handle_hvc_nested(struct kvm_vcpu *vcpu)
 {
 	return kvm_inject_nested_sync(vcpu, kvm_vcpu_get_hsr(vcpu));
 }
+
+/*
+ * Inject wfx to the nested hypervisor if this is from the nested VM and
+ * the virtual HCR_EL2.TWX is set. Otherwise, let the host hypervisor
+ * handle this.
+ */
+int handle_wfx_nested(struct kvm_vcpu *vcpu, bool is_wfe)
+{
+	u64 hcr_el2 = vcpu_el2_reg(vcpu, HCR_EL2);
+
+	if (vcpu_mode_el2(vcpu))
+		return -EINVAL;
+
+	if ((is_wfe && (hcr_el2 & HCR_TWE)) || (!is_wfe && (hcr_el2 & HCR_TWI)))
+		return kvm_inject_nested_sync(vcpu, kvm_vcpu_get_hsr(vcpu));
+
+	return -EINVAL;
+}
-- 
1.9.1

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[RFC 23/55] KVM: arm64: Forward WFX to the guest hypervisor Jintack Lim <jintack@cs.columbia.edu> - 2017-01-09 07:30 +0100

csiph-web