Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1437863

Re: kvm: RDTSCP on AMD

From Eduardo Habkost <ehabkost@redhat.com>
Newsgroups linux.kernel
Subject Re: kvm: RDTSCP on AMD
Date 2016-07-06 19:40 +0200
Message-ID <rRYXL-3I6-3@gated-at.bofh.it> (permalink)
References <rRUr8-OO-17@gated-at.bofh.it> <rRUKu-1aw-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Jul 06, 2016 at 03:01:04PM +0200, Paolo Bonzini wrote:
> On 06/07/2016 14:44, Borislav Petkov wrote:
> > Hi guys,
> > 
> > how about this below to enable RDTSCP emulation on AMD? IOW, I'm staring
> > at
> > 
> >   33b5e8c03ae7 ("target-i386: Disable rdtscp on Opteron_G* CPU models")
> > 
> > in the qemu repo.
> > 
> > It seems to work here, RDTSCP in the guest gives me node and cpu as
> > vsyscall_set_cpu() in the guest kernel has set them.
> > 
> > Thoughts?
> > 
> > (Below is the simple qemu diff reenabling RDTSCP)
> > 
> > @@ -3919,6 +3935,7 @@ static int (*const svm_exit_handlers[])(struct vcpu_svm *svm) = {
> >  	[SVM_EXIT_STGI]				= stgi_interception,
> >  	[SVM_EXIT_CLGI]				= clgi_interception,
> >  	[SVM_EXIT_SKINIT]			= skinit_interception,
> > +	[SVM_EXIT_RDTSCP]			= rdtscp_interception,
> >  	[SVM_EXIT_WBINVD]                       = wbinvd_interception,
> >  	[SVM_EXIT_MONITOR]			= monitor_interception,
> >  	[SVM_EXIT_MWAIT]			= mwait_interception,
> 
> Nothing is needed in the kernel actually.  You can skip the intercept
> by running the guest with MSR_TSC_AUX set to the guest's expected value.
>  Which KVM does, except that it's botched so I need to apply the
> patch in https://lkml.org/lkml/2016/4/13/802.

Do you mean -cpu Opteron_G*,+rdtscp will be buggy on Linux v4.5?
(v4.5 reports rdtscp as supported in GET_SUPPORTED_CPUID)

Can we do something to make QEMU detect the buggy kernel before
allowing rdtscp to be enabled, or should we just tell people to
upgrade their kernel?

> 
> > ---
> > 
> > qemu diff:
> > 
> > ---
> > diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> > index 3bd3cfc3ad16..aa6d0d027d00 100644
> > --- a/target-i386/cpu.c
> > +++ b/target-i386/cpu.c
> 
> This is not enough because it's missing some backwards compatibility
> gunk (similar to the include/hw/i386/pc.h parts of 33b5e8c03ae), but
> it's enough for a proof of concept and to discuss it.
> 
> The main issue with this is that it would force a lockstep update of
> QEMU and kernel, which we try to avoid.  I'm not sure if we have a
> solution for this problem.  Eduardo?

We don't. Either we make QEMU require a newer kernel, or we need
a new CPU model. :(

-- 
Eduardo

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

kvm: RDTSCP on AMD Borislav Petkov <bp@alien8.de> - 2016-07-06 14:50 +0200
  Re: kvm: RDTSCP on AMD Paolo Bonzini <pbonzini@redhat.com> - 2016-07-06 15:10 +0200
    Re: kvm: RDTSCP on AMD Eduardo Habkost <ehabkost@redhat.com> - 2016-07-06 19:40 +0200
      Re: kvm: RDTSCP on AMD Paolo Bonzini <pbonzini@redhat.com> - 2016-07-06 23:30 +0200

csiph-web