Re: [PATCH v3 09/22] KVM: Do processor compatibility check on resume

Yuan Yao
2022-09-05T09:27:21Z

On Mon, Sep 05, 2022 at 04:40:14PM +0800, Yuan Yao wrote:
> On Thu, Sep 01, 2022 at 07:17:44PM -0700, isaku.yamahata@intel.com wrote:
> > From: Isaku Yamahata <isaku.yamahata@intel.com>
> >
> > So far the processor compatibility check is not done on resume. It should
> > be done.
>
> The resume happens for resuming from S3/S4, so the compatibility
> checking is used to detecte CPU replacement, or resume from S4 on an
> different machine ?

By did experiments, I found the resume is called once on CPU 0 before
other CPUs come UP, so yes it's necessary to check it.

>
> >
> > Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
> > ---
> > virt/kvm/kvm_main.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> > index 0ac00c711384..fc55447c4dba 100644
> > --- a/virt/kvm/kvm_main.c
> > +++ b/virt/kvm/kvm_main.c
> > @@ -5715,6 +5715,13 @@ static int kvm_suspend(void)
> >
> > static void kvm_resume(void)
> > {
> > + if (kvm_arch_check_processor_compat())
> > + /*
> > + * No warning here because kvm_arch_check_processor_compat()
> > + * would have warned with more information.
> > + */
> > + return; /* FIXME: disable KVM */
> > +
> > if (kvm_usage_count) {
> > lockdep_assert_not_held(&kvm_count_lock);
> > hardware_enable_nolock((void *)__func__);
> > --
> > 2.25.1
> >