lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <cc0892c8066e421aba3a603edaf0a39a@baidu.com>
Date:   Thu, 30 Apr 2020 09:50:08 +0000
From:   "Li,Rongqing" <lirongqing@...du.com>
To:     Xiaoyao Li <xiaoyao.li@...el.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "x86@...nel.org" <x86@...nel.org>, "hpa@...or.com" <hpa@...or.com>,
        "bp@...en8.de" <bp@...en8.de>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "joro@...tes.org" <joro@...tes.org>,
        "jmattson@...gle.com" <jmattson@...gle.com>,
        "wanpengli@...cent.com" <wanpengli@...cent.com>,
        "vkuznets@...hat.com" <vkuznets@...hat.com>,
        "sean.j.christopherson@...el.com" <sean.j.christopherson@...el.com>,
        "pbonzini@...hat.com" <pbonzini@...hat.com>
Subject: 答复: [PATCH][v2] kvm: x86: emulate APERF/MPERF registers



> -----邮件原件-----
> 发件人: Xiaoyao Li [mailto:xiaoyao.li@...el.com]
> 发送时间: 2020年4月30日 14:49
> 收件人: Li,Rongqing <lirongqing@...du.com>; linux-kernel@...r.kernel.org;
> kvm@...r.kernel.org; x86@...nel.org; hpa@...or.com; bp@...en8.de;
> mingo@...hat.com; tglx@...utronix.de; joro@...tes.org;
> jmattson@...gle.com; wanpengli@...cent.com; vkuznets@...hat.com;
> sean.j.christopherson@...el.com; pbonzini@...hat.com
> 主题: Re: [PATCH][v2] kvm: x86: emulate APERF/MPERF registers
> 
> On 4/29/2020 1:46 PM, Li RongQing wrote:
> > Guest kernel reports a fixed cpu frequency in /proc/cpuinfo, this is
> > confused to user when turbo is enable, and aperf/mperf can be used to
> > show current cpu frequency after 7d5905dc14a
> > "(x86 / CPU: Always show current CPU frequency in /proc/cpuinfo)"
> > so we should emulate aperf mperf to achieve it
> >
> > the period of aperf/mperf in guest mode are accumulated as emulated
> > value, and add per-VM knod to enable emulate mperfaperf
> >
> > diff v1:
> > 1. support AMD
> > 2. support per-vm capability to enable
> >
> [...]
> > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index
> > 851e9cc79930..1d157a8dba46 100644
> > --- a/arch/x86/kvm/svm.c
> > +++ b/arch/x86/kvm/svm.c
> > @@ -4310,6 +4310,12 @@ static int svm_get_msr(struct kvm_vcpu *vcpu,
> struct msr_data *msr_info)
> >   	case MSR_F10H_DECFG:
> >   		msr_info->data = svm->msr_decfg;
> >   		break;
> > +	case MSR_IA32_MPERF:
> > +		msr_info->data = vcpu->arch.v_mperf;
> > +		break;
> > +	case MSR_IA32_APERF:
> > +		msr_info->data = vcpu->arch.v_aperf;
> > +		break;
> >   	default:
> >   		return kvm_get_msr_common(vcpu, msr_info);
> >   	}
> > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index
> > 91749f1254e8..b05e276e262b 100644
> > --- a/arch/x86/kvm/vmx/vmx.c
> > +++ b/arch/x86/kvm/vmx/vmx.c
> > @@ -1914,6 +1914,12 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu,
> struct msr_data *msr_info)
> >   		    !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP))
> >   			return 1;
> >   		goto find_shared_msr;
> > +	case MSR_IA32_MPERF:
> > +		msr_info->data = vcpu->arch.v_mperf;
> > +		break;
> > +	case MSR_IA32_APERF:
> > +		msr_info->data = vcpu->arch.v_aperf;
> > +		break;
> 
> They are same for both vmx and svm, you can put them in
> kvm_get_msr_common()
> 

Ok

> BTW, are those two MSR always readable regardless of guest's CPUID?

It should be, not sure if there is abnormal

thanks
-LiRongQing

> >   	default:
> >   	find_shared_msr:
> >   		msr = find_msr_entry(vmx, msr_info->index);
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ