* [PATCH 1/2] KVM: x86/xen: Allow reset of Xen attributes
@ 2021-02-08 23:23 David Woodhouse
2021-02-08 23:23 ` [PATCH 2/2] KVM: x86/xen: Remove extra unlock in kvm_xen_hvm_set_attr() David Woodhouse
2021-02-09 10:02 ` [PATCH 1/2] KVM: x86/xen: Allow reset of Xen attributes Joao Martins
0 siblings, 2 replies; 5+ messages in thread
From: David Woodhouse @ 2021-02-08 23:23 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>
In order to support Xen SHUTDOWN_soft_reset (for guest kexec, etc.) the
VMM needs to be able to tear everything down and return the Xen features
to a clean slate.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
arch/x86/kvm/xen.c | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
index 39a7ffcdcf22..06fec10ffc4f 100644
--- a/arch/x86/kvm/xen.c
+++ b/arch/x86/kvm/xen.c
@@ -118,12 +118,17 @@ int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
break;
case KVM_XEN_ATTR_TYPE_SHARED_INFO:
+ if (data->u.shared_info.gfn == GPA_INVALID) {
+ kvm->arch.xen.shinfo_set = false;
+ r = 0;
+ break;
+ }
r = kvm_xen_shared_info_init(kvm, data->u.shared_info.gfn);
break;
case KVM_XEN_ATTR_TYPE_UPCALL_VECTOR:
- if (data->u.vector < 0x10)
+ if (data->u.vector && data->u.vector < 0x10)
r = -EINVAL;
else {
kvm->arch.xen.upcall_vector = data->u.vector;
@@ -152,10 +157,11 @@ int kvm_xen_hvm_get_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
break;
case KVM_XEN_ATTR_TYPE_SHARED_INFO:
- if (kvm->arch.xen.shinfo_set) {
+ if (kvm->arch.xen.shinfo_set)
data->u.shared_info.gfn = gpa_to_gfn(kvm->arch.xen.shinfo_cache.gpa);
- r = 0;
- }
+ else
+ data->u.shared_info.gfn = GPA_INVALID;
+ r = 0;
break;
case KVM_XEN_ATTR_TYPE_UPCALL_VECTOR:
@@ -184,6 +190,11 @@ int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
BUILD_BUG_ON(sizeof(struct vcpu_info) !=
sizeof(struct compat_vcpu_info));
+ if (data->u.gpa == GPA_INVALID) {
+ vcpu->arch.xen.vcpu_info_set = false;
+ break;
+ }
+
r = kvm_gfn_to_hva_cache_init(vcpu->kvm,
&vcpu->arch.xen.vcpu_info_cache,
data->u.gpa,
@@ -195,6 +206,11 @@ int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
break;
case KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO:
+ if (data->u.gpa == GPA_INVALID) {
+ vcpu->arch.xen.vcpu_time_info_set = false;
+ break;
+ }
+
r = kvm_gfn_to_hva_cache_init(vcpu->kvm,
&vcpu->arch.xen.vcpu_time_info_cache,
data->u.gpa,
@@ -222,17 +238,19 @@ int kvm_xen_vcpu_get_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
switch (data->type) {
case KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO:
- if (vcpu->arch.xen.vcpu_info_set) {
+ if (vcpu->arch.xen.vcpu_info_set)
data->u.gpa = vcpu->arch.xen.vcpu_info_cache.gpa;
- r = 0;
- }
+ else
+ data->u.gpa = GPA_INVALID;
+ r = 0;
break;
case KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO:
- if (vcpu->arch.xen.vcpu_time_info_set) {
+ if (vcpu->arch.xen.vcpu_time_info_set)
data->u.gpa = vcpu->arch.xen.vcpu_time_info_cache.gpa;
- r = 0;
- }
+ else
+ data->u.gpa = GPA_INVALID;
+ r = 0;
break;
default:
--
2.29.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] KVM: x86/xen: Remove extra unlock in kvm_xen_hvm_set_attr()
2021-02-08 23:23 [PATCH 1/2] KVM: x86/xen: Allow reset of Xen attributes David Woodhouse
@ 2021-02-08 23:23 ` David Woodhouse
2021-02-09 9:59 ` Paolo Bonzini
2021-02-09 10:03 ` Joao Martins
2021-02-09 10:02 ` [PATCH 1/2] KVM: x86/xen: Allow reset of Xen attributes Joao Martins
1 sibling, 2 replies; 5+ messages in thread
From: David Woodhouse @ 2021-02-08 23:23 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>
This accidentally ended up locking and then immediately unlocking kvm->lock
at the beginning of the function. Fix it.
Fixes: a76b9641ad1c ("KVM: x86/xen: add KVM_XEN_HVM_SET_ATTR/KVM_XEN_HVM_GET_ATTR")
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
arch/x86/kvm/xen.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
index 06fec10ffc4f..d8cdd84b1c0e 100644
--- a/arch/x86/kvm/xen.c
+++ b/arch/x86/kvm/xen.c
@@ -105,8 +105,6 @@ int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
mutex_lock(&kvm->lock);
- mutex_unlock(&kvm->lock);
-
switch (data->type) {
case KVM_XEN_ATTR_TYPE_LONG_MODE:
if (!IS_ENABLED(CONFIG_64BIT) && data->u.long_mode) {
--
2.29.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] KVM: x86/xen: Remove extra unlock in kvm_xen_hvm_set_attr()
2021-02-08 23:23 ` [PATCH 2/2] KVM: x86/xen: Remove extra unlock in kvm_xen_hvm_set_attr() David Woodhouse
@ 2021-02-09 9:59 ` Paolo Bonzini
2021-02-09 10:03 ` Joao Martins
1 sibling, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2021-02-09 9:59 UTC (permalink / raw)
To: David Woodhouse, kvm
Cc: Ankur Arora, Joao Martins, Boris Ostrovsky, Sean Christopherson,
graf, iaslan, pdurrant, aagch, fandree, hch
On 09/02/21 00:23, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
>
> This accidentally ended up locking and then immediately unlocking kvm->lock
> at the beginning of the function. Fix it.
>
> Fixes: a76b9641ad1c ("KVM: x86/xen: add KVM_XEN_HVM_SET_ATTR/KVM_XEN_HVM_GET_ATTR")
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
> arch/x86/kvm/xen.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
> index 06fec10ffc4f..d8cdd84b1c0e 100644
> --- a/arch/x86/kvm/xen.c
> +++ b/arch/x86/kvm/xen.c
> @@ -105,8 +105,6 @@ int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
>
> mutex_lock(&kvm->lock);
>
> - mutex_unlock(&kvm->lock);
> -
> switch (data->type) {
> case KVM_XEN_ATTR_TYPE_LONG_MODE:
> if (!IS_ENABLED(CONFIG_64BIT) && data->u.long_mode) {
>
Queued both, thanks.
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] KVM: x86/xen: Allow reset of Xen attributes
2021-02-08 23:23 [PATCH 1/2] KVM: x86/xen: Allow reset of Xen attributes David Woodhouse
2021-02-08 23:23 ` [PATCH 2/2] KVM: x86/xen: Remove extra unlock in kvm_xen_hvm_set_attr() David Woodhouse
@ 2021-02-09 10:02 ` Joao Martins
1 sibling, 0 replies; 5+ messages in thread
From: Joao Martins @ 2021-02-09 10:02 UTC (permalink / raw)
To: David Woodhouse, kvm
Cc: Paolo Bonzini, Ankur Arora, Boris Ostrovsky, Sean Christopherson,
graf, iaslan, pdurrant, aagch, fandree, hch
On 2/8/21 11:23 PM, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
>
> In order to support Xen SHUTDOWN_soft_reset (for guest kexec, etc.) the
> VMM needs to be able to tear everything down and return the Xen features
> to a clean slate.
>
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
> ---
> arch/x86/kvm/xen.c | 38 ++++++++++++++++++++++++++++----------
> 1 file changed, 28 insertions(+), 10 deletions(-)
>
> diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
> index 39a7ffcdcf22..06fec10ffc4f 100644
> --- a/arch/x86/kvm/xen.c
> +++ b/arch/x86/kvm/xen.c
> @@ -118,12 +118,17 @@ int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
> break;
>
> case KVM_XEN_ATTR_TYPE_SHARED_INFO:
> + if (data->u.shared_info.gfn == GPA_INVALID) {
> + kvm->arch.xen.shinfo_set = false;
> + r = 0;
> + break;
> + }
> r = kvm_xen_shared_info_init(kvm, data->u.shared_info.gfn);
> break;
>
>
> case KVM_XEN_ATTR_TYPE_UPCALL_VECTOR:
> - if (data->u.vector < 0x10)
> + if (data->u.vector && data->u.vector < 0x10)
> r = -EINVAL;
> else {
> kvm->arch.xen.upcall_vector = data->u.vector;
> @@ -152,10 +157,11 @@ int kvm_xen_hvm_get_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
> break;
>
> case KVM_XEN_ATTR_TYPE_SHARED_INFO:
> - if (kvm->arch.xen.shinfo_set) {
> + if (kvm->arch.xen.shinfo_set)
> data->u.shared_info.gfn = gpa_to_gfn(kvm->arch.xen.shinfo_cache.gpa);
> - r = 0;
> - }
> + else
> + data->u.shared_info.gfn = GPA_INVALID;
> + r = 0;
> break;
>
> case KVM_XEN_ATTR_TYPE_UPCALL_VECTOR:
> @@ -184,6 +190,11 @@ int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
> BUILD_BUG_ON(sizeof(struct vcpu_info) !=
> sizeof(struct compat_vcpu_info));
>
> + if (data->u.gpa == GPA_INVALID) {
> + vcpu->arch.xen.vcpu_info_set = false;
> + break;
> + }
> +
> r = kvm_gfn_to_hva_cache_init(vcpu->kvm,
> &vcpu->arch.xen.vcpu_info_cache,
> data->u.gpa,
> @@ -195,6 +206,11 @@ int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
> break;
>
> case KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO:
> + if (data->u.gpa == GPA_INVALID) {
> + vcpu->arch.xen.vcpu_time_info_set = false;
> + break;
> + }
> +
> r = kvm_gfn_to_hva_cache_init(vcpu->kvm,
> &vcpu->arch.xen.vcpu_time_info_cache,
> data->u.gpa,
> @@ -222,17 +238,19 @@ int kvm_xen_vcpu_get_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
>
> switch (data->type) {
> case KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO:
> - if (vcpu->arch.xen.vcpu_info_set) {
> + if (vcpu->arch.xen.vcpu_info_set)
> data->u.gpa = vcpu->arch.xen.vcpu_info_cache.gpa;
> - r = 0;
> - }
> + else
> + data->u.gpa = GPA_INVALID;
> + r = 0;
> break;
>
> case KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO:
> - if (vcpu->arch.xen.vcpu_time_info_set) {
> + if (vcpu->arch.xen.vcpu_time_info_set)
> data->u.gpa = vcpu->arch.xen.vcpu_time_info_cache.gpa;
> - r = 0;
> - }
> + else
> + data->u.gpa = GPA_INVALID;
> + r = 0;
> break;
>
> default:
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] KVM: x86/xen: Remove extra unlock in kvm_xen_hvm_set_attr()
2021-02-08 23:23 ` [PATCH 2/2] KVM: x86/xen: Remove extra unlock in kvm_xen_hvm_set_attr() David Woodhouse
2021-02-09 9:59 ` Paolo Bonzini
@ 2021-02-09 10:03 ` Joao Martins
1 sibling, 0 replies; 5+ messages in thread
From: Joao Martins @ 2021-02-09 10:03 UTC (permalink / raw)
To: David Woodhouse, kvm
Cc: Paolo Bonzini, Ankur Arora, Boris Ostrovsky, Sean Christopherson,
graf, iaslan, pdurrant, aagch, fandree, hch
On 2/8/21 11:23 PM, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
>
> This accidentally ended up locking and then immediately unlocking kvm->lock
> at the beginning of the function. Fix it.
>
> Fixes: a76b9641ad1c ("KVM: x86/xen: add KVM_XEN_HVM_SET_ATTR/KVM_XEN_HVM_GET_ATTR")
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
> ---
> arch/x86/kvm/xen.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
> index 06fec10ffc4f..d8cdd84b1c0e 100644
> --- a/arch/x86/kvm/xen.c
> +++ b/arch/x86/kvm/xen.c
> @@ -105,8 +105,6 @@ int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
>
> mutex_lock(&kvm->lock);
>
> - mutex_unlock(&kvm->lock);
> -
> switch (data->type) {
> case KVM_XEN_ATTR_TYPE_LONG_MODE:
> if (!IS_ENABLED(CONFIG_64BIT) && data->u.long_mode) {
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-02-09 10:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 23:23 [PATCH 1/2] KVM: x86/xen: Allow reset of Xen attributes David Woodhouse
2021-02-08 23:23 ` [PATCH 2/2] KVM: x86/xen: Remove extra unlock in kvm_xen_hvm_set_attr() David Woodhouse
2021-02-09 9:59 ` Paolo Bonzini
2021-02-09 10:03 ` Joao Martins
2021-02-09 10:02 ` [PATCH 1/2] KVM: x86/xen: Allow reset of Xen attributes Joao Martins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).