[Devel] [PATCH] KVM: x86: add a stub for MSR_PLATFORM_INFO

Denis Plotnikov dplotnikov at virtuozzo.com
Thu Jun 6 15:49:02 MSK 2019



On 06.06.2019 15:40, Roman Kagan wrote:
> On Thu, Jun 06, 2019 at 03:11:10PM +0300, Denis Plotnikov wrote:
>>
>>
>> On 06.06.2019 14:31, Roman Kagan wrote:
>>> On Thu, Jun 06, 2019 at 11:36:45AM +0300, Denis Plotnikov wrote:
>>>> This is done to prevent windows guest crashing while running
>>>> PassMark benchmark which calls rdmsr(0xce) - MSR_PLATFORM_INFO
>>>> from PassMark driver.
>>>>
>>>> The reason why the test driver does so is unclear, since
>>>> MSR_PLATFORM_INFO is used to calibrate tsc for certain Intel Atom
>>>> cpus (please, refer to try_msr_calibrate_tsc in arch/x86/kernel/tsc_msr.c).
>>>>
>>>> Anyway, KVM so far didn't have MSR_PLATFORM_INFO MSR implemented and
>>>
>>> KVM has it implemented since 4.12.  Why not just backport it?
>> But for another purpose: "KVM: x86: virtualize cpuid faulting"
>> Isn't worth to backport now. Will get that functionality later while
>> rebasing to newer RHEL
> 
> Doesn't it apply cleanly?  The rebase is easier if you don't need to
> modify the patch.
> 
> Roman.
No, it doesn't. That's why I decided to it that way.

Denis
> 
>>>> this didn't cause any problems with guest crashes on both Linux and Windows
>>>> platforms. So, the only reason why the crashes started now is that
>>>> the customer started using PassMark test on KVM platform recently.
>>>>
>>>> https://jira.sw.ru/browse/PSBM-95187
>>>>
>>>> Signed-off-by: Denis Plotnikov <dplotnikov at virtuozzo.com>
>>>> ---
>>>>    arch/x86/kvm/cpuid.h | 1 -
>>>>    arch/x86/kvm/x86.c   | 7 +++++++
>>>>    2 files changed, 7 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h
>>>> index c4996e57d10c..fb0c6ab257cf 100644
>>>> --- a/arch/x86/kvm/cpuid.h
>>>> +++ b/arch/x86/kvm/cpuid.h
>>>> @@ -121,5 +121,4 @@ static inline bool guest_cpuid_is_amd(struct kvm_vcpu *vcpu)
>>>>    	best = kvm_find_cpuid_entry(vcpu, 0, 0);
>>>>    	return best && best->ebx == X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx;
>>>>    }
>>>> -
>>>>    #endif
>>>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>>>> index f1230a251add..b855f03477f4 100644
>>>> --- a/arch/x86/kvm/x86.c
>>>> +++ b/arch/x86/kvm/x86.c
>>>> @@ -1018,6 +1018,7 @@ static u32 emulated_msrs[] = {
>>>>    	MSR_IA32_MCG_EXT_CTL,
>>>>    	MSR_IA32_SMBASE,
>>>>    	MSR_AMD64_VIRT_SPEC_CTRL,
>>>> +	MSR_PLATFORM_INFO,
>>>>    };
>>>>    
>>>>    static unsigned num_emulated_msrs;
>>>> @@ -2300,6 +2301,9 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>>>>    			return 1;
>>>>    		vcpu->arch.osvw.status = data;
>>>>    		break;
>>>> +	case MSR_PLATFORM_INFO:
>>>> +		return 1;
>>>> +		break;
>>>>    	default:
>>>>    		if (msr && (msr == vcpu->kvm->arch.xen_hvm_config.msr))
>>>>    			return xen_hvm_config(vcpu, data);
>>>> @@ -2517,6 +2521,9 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>>>>    			return 1;
>>>>    		msr_info->data = vcpu->arch.osvw.status;
>>>>    		break;
>>>> +	case MSR_PLATFORM_INFO:
>>>> +		msr_info->data = 0;
>>>> +		break;
>>>>    	default:
>>>>    		if (kvm_pmu_is_valid_msr(vcpu, msr_info->index))
>>>>    			return kvm_pmu_get_msr(vcpu, msr_info->index, &msr_info->data);
>>>> -- 
>>>> 2.17.0
>>>>
>>
>> -- 
>> Best,
>> Denis

-- 
Best,
Denis



More information about the Devel mailing list