2023-10-04 17:12:40

by Paul Durrant

[permalink] [raw]
Subject: [PATCH] KVM: xen: ignore the VCPU_SSHOTTMR_future flag

From: Paul Durrant <[email protected]>

Upstream Xen now ignores this flag [1], since the only guest kernel ever to
use it was buggy. By ignoring the flag the guest will always get a callback
if it sets a negative timeout which upstream Xen has determined not to
cause problems for any guest setting the flag.

[1] https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=19c6cbd909

Signed-off-by: Paul Durrant <[email protected]>
---
Cc: David Woodhouse <[email protected]>
Cc: Sean Christopherson <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: [email protected]
---
arch/x86/kvm/xen.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
index 40edf4d1974c..8f1d46df0f3b 100644
--- a/arch/x86/kvm/xen.c
+++ b/arch/x86/kvm/xen.c
@@ -1374,12 +1374,8 @@ static bool kvm_xen_hcall_vcpu_op(struct kvm_vcpu *vcpu, bool longmode, int cmd,
return true;
}

+ /* A delta <= 0 results in an immediate callback, which is what we want */
delta = oneshot.timeout_abs_ns - get_kvmclock_ns(vcpu->kvm);
- if ((oneshot.flags & VCPU_SSHOTTMR_future) && delta < 0) {
- *r = -ETIME;
- return true;
- }
-
kvm_xen_start_timer(vcpu, oneshot.timeout_abs_ns, delta);
*r = 0;
return true;
--
2.39.2


2023-10-04 17:20:10

by David Woodhouse

[permalink] [raw]
Subject: Re: [PATCH] KVM: xen: ignore the VCPU_SSHOTTMR_future flag

On Wed, 2023-10-04 at 17:11 +0000, Paul Durrant wrote:
> From: Paul Durrant <[email protected]>
>
> Upstream Xen now ignores this flag [1], since the only guest kernel ever to
> use it was buggy. By ignoring the flag the guest will always get a callback
> if it sets a negative timeout which upstream Xen has determined not to
> cause problems for any guest setting the flag.
>
> [1] https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=19c6cbd909
>
> Signed-off-by: Paul Durrant <[email protected]>

nit: I think the commit title should probably be 'KVM: x86:' and then
mention Xen somewhere in the rest of the line?

Reviewed-by: David Woodhouse <[email protected]>

> ---
> Cc: David Woodhouse <[email protected]>
> Cc: Sean Christopherson <[email protected]>
> Cc: Paolo Bonzini <[email protected]>
> Cc: Thomas Gleixner <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Borislav Petkov <[email protected]>
> Cc: Dave Hansen <[email protected]>
> Cc: "H. Peter Anvin" <[email protected]>
> Cc: [email protected]
> ---
>  arch/x86/kvm/xen.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
> index 40edf4d1974c..8f1d46df0f3b 100644
> --- a/arch/x86/kvm/xen.c
> +++ b/arch/x86/kvm/xen.c
> @@ -1374,12 +1374,8 @@ static bool kvm_xen_hcall_vcpu_op(struct kvm_vcpu *vcpu, bool longmode, int cmd,
>                         return true;
>                 }
>  
> +               /* A delta <= 0 results in an immediate callback, which is what we want */
>                 delta = oneshot.timeout_abs_ns - get_kvmclock_ns(vcpu->kvm);
> -               if ((oneshot.flags & VCPU_SSHOTTMR_future) && delta < 0) {
> -                       *r = -ETIME;
> -                       return true;
> -               }
> -
>                 kvm_xen_start_timer(vcpu, oneshot.timeout_abs_ns, delta);
>                 *r = 0;
>                 return true;


Attachments:
smime.p7s (5.83 kB)

2023-10-04 17:34:32

by Sean Christopherson

[permalink] [raw]
Subject: Re: [PATCH] KVM: xen: ignore the VCPU_SSHOTTMR_future flag

On Wed, Oct 04, 2023, David Woodhouse wrote:
> On Wed, 2023-10-04 at 17:11 +0000, Paul Durrant wrote:
> nit: I think the commit title should probably be 'KVM: x86:' and then
> mention Xen somewhere in the rest of the line?

I would also be ok if we start doing "KVM: x86/xen:", because it seems like y'all
are sending enough Xen specific changes that differentiating would be useful.

2023-10-04 17:44:28

by Paul Durrant

[permalink] [raw]
Subject: Re: [PATCH] KVM: xen: ignore the VCPU_SSHOTTMR_future flag

On 04/10/2023 18:34, Sean Christopherson wrote:
> On Wed, Oct 04, 2023, David Woodhouse wrote:
>> On Wed, 2023-10-04 at 17:11 +0000, Paul Durrant wrote:
>> nit: I think the commit title should probably be 'KVM: x86:' and then
>> mention Xen somewhere in the rest of the line?
>
> I would also be ok if we start doing "KVM: x86/xen:", because it seems like y'all
> are sending enough Xen specific changes that differentiating would be useful.

Ok, I'll send a v2 with an amended subject line.

Paul