public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	Wanpeng Li <wanpeng.li@hotmail.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: fix backward migration with async_PF
Date: Thu, 1 Feb 2018 20:10:41 +0100	[thread overview]
Message-ID: <20180201191040.GD26932@flask> (raw)
In-Reply-To: <a4fa9a87-cc4e-73d6-e248-192ab167b2c2@redhat.com>

2018-02-01 13:09-0500, Paolo Bonzini:
> On 01/02/2018 12:50, Radim Krčmář wrote:
> > Guests on new hypersiors might set KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT
> > bit when enabling async_PF, but this bit is reserved on old hypervisors,
> > which results in a failure upon migration.
> > 
> > Guests at least expect that KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT might not
> > be present when booting, so we allow userspace to handle migration
> > compatibility by adding a KVM CPUID flag that determines the presence of
> > KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT.
> > 
> > Fixes: 52a5c155cf79 ("KVM: async_pf: Let guest support delivery of async_pf from guest mode")
> > Cc: <stable@vger.kernel.org>
> > Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> 
> This has to be documented in Documentation/virtual/kvm/cpuid.txt.

Will add, also to the MSR if we agree on v2.

> > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> > index 4c3103f449a3..c16740a06f0c 100644
> > --- a/arch/x86/kvm/x86.c
> > +++ b/arch/x86/kvm/x86.c
> > @@ -2139,8 +2139,10 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)
> >  {
> >  	gpa_t gpa = data & ~0x3f;
> >  
> > -	/* Bits 3:5 are reserved, Should be zero */
> > -	if (data & 0x38)
> > +	/* Bits 3:5 are reserved, Should be zero. */
> > +	if (data & 0x38 ||
> > +	    (data & KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT &&
> > +	     !guest_kvm_cpuid_has(vcpu, KVM_FEATURE_ASYNC_PF_VMEXIT)))
> >  		return 1;
> >  
> >  	vcpu->arch.apf.msr_val = data;
> > 
> 
> This check will break migration if the source guest and host both have
> the recent kernels which support KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT, so
> I am not sure about it.  Otherwise, the patch is okay!

Good point, breaking forward migration is worse than doing nothing.

A compromise solution would be to drop the feature check from the
hypervisor.  Newer guests would work everywhere and there would be no
change to old systems, so v4.13-v4.15 guests could at least upgrade.

Slightly better than doing nothing, IMO,

thanks.

  reply	other threads:[~2018-02-01 19:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-01 17:50 [PATCH] KVM: x86: fix backward migration with async_PF Radim Krčmář
2018-02-01 18:09 ` Paolo Bonzini
2018-02-01 19:10   ` Radim Krčmář [this message]
2018-02-01 19:33     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180201191040.GD26932@flask \
    --to=rkrcmar@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=wanpeng.li@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox