public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] KVM: x86/xen: Fix return code when clearing vcpu_info and vcpu_time_info
@ 2021-03-01 12:53 David Woodhouse
  2021-03-01 12:53 ` [PATCH 2/2] KVM: x86/xen: Add support for vCPU runstate information David Woodhouse
  2021-03-01 17:34 ` [PATCH 1/2] KVM: x86/xen: Fix return code when clearing vcpu_info and vcpu_time_info Sean Christopherson
  0 siblings, 2 replies; 3+ messages in thread
From: David Woodhouse @ 2021-03-01 12:53 UTC (permalink / raw)
  To: kvm
  Cc: Paolo Bonzini, Ankur Arora, Joao Martins, Boris Ostrovsky,
	Sean Christopherson, graf, iaslan, pdurrant, aagch, fandree, hch

From: David Woodhouse <dwmw@amazon.co.uk>

When clearing the per-vCPU shared regions, set the return value to zero
to indicate success. This was causing spurious errors to be returned to
userspace on soft reset.

Also add a paranoid BUILD_BUG_ON() for compat structure compatibility.

Fixes: 0c165b3c01fe ("KVM: x86/xen: Allow reset of Xen attributes")
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 arch/x86/kvm/xen.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
index af8f6562fce4..77b20ff09078 100644
--- a/arch/x86/kvm/xen.c
+++ b/arch/x86/kvm/xen.c
@@ -187,9 +187,12 @@ int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
 		/* No compat necessary here. */
 		BUILD_BUG_ON(sizeof(struct vcpu_info) !=
 			     sizeof(struct compat_vcpu_info));
+		BUILD_BUG_ON(offsetof(struct vcpu_info, time) !=
+			     offsetof(struct compat_vcpu_info, time));
 
 		if (data->u.gpa == GPA_INVALID) {
 			vcpu->arch.xen.vcpu_info_set = false;
+			r = 0;
 			break;
 		}
 
@@ -206,6 +209,7 @@ int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
 	case KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO:
 		if (data->u.gpa == GPA_INVALID) {
 			vcpu->arch.xen.vcpu_time_info_set = false;
+			r = 0;
 			break;
 		}
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-01 17:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-01 12:53 [PATCH 1/2] KVM: x86/xen: Fix return code when clearing vcpu_info and vcpu_time_info David Woodhouse
2021-03-01 12:53 ` [PATCH 2/2] KVM: x86/xen: Add support for vCPU runstate information David Woodhouse
2021-03-01 17:34 ` [PATCH 1/2] KVM: x86/xen: Fix return code when clearing vcpu_info and vcpu_time_info Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox