RE: [PATCH v2] KVM: x86/xen: Update Xen CPUID Leaf 4 (tsc info) sub-leaves, if present

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: David Woodhouse <dwmw2@xxxxxxxxxxxxx>
> Sent: 22 June 2022 14:48
> To: Durrant, Paul <pdurrant@xxxxxxxxxxxx>; x86@xxxxxxxxxx; kvm@xxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx
> Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>; Sean Christopherson <seanjc@xxxxxxxxxx>; Vitaly Kuznetsov
> <vkuznets@xxxxxxxxxx>; Wanpeng Li <wanpengli@xxxxxxxxxxx>; Jim Mattson <jmattson@xxxxxxxxxx>; Joerg
> Roedel <joro@xxxxxxxxxx>; Thomas Gleixner <tglx@xxxxxxxxxxxxx>; Ingo Molnar <mingo@xxxxxxxxxx>;
> Borislav Petkov <bp@xxxxxxxxx>; Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>; H. Peter Anvin
> <hpa@xxxxxxxxx>
> Subject: RE: [EXTERNAL][PATCH v2] KVM: x86/xen: Update Xen CPUID Leaf 4 (tsc info) sub-leaves, if
> present
> 
> On Wed, 2022-06-22 at 10:57 +0100, Paul Durrant wrote:
> > +void kvm_xen_set_cpuid(struct kvm_vcpu *vcpu)
> > +{
> > +	u32 base = 0;
> > +	u32 function;
> > +
> > +	vcpu->arch.xen.tsc_info_1 = NULL;
> > +	vcpu->arch.xen.tsc_info_2 = NULL;
> > +
> > +	for_each_possible_hypervisor_cpuid_base(function) {
> > +		struct kvm_cpuid_entry2 *entry = kvm_find_cpuid_entry(vcpu, function, 0);
> > +
> > +		if (entry &&
> > +		    entry->ebx == XEN_CPUID_SIGNATURE_EBX &&
> > +		    entry->ecx == XEN_CPUID_SIGNATURE_ECX &&
> > +		    entry->edx == XEN_CPUID_SIGNATURE_EDX) {
> > +			base = function;
> > +			break;
> > +		}
> > +	}
> 
> Please make it return if entry->eax < 3 here. There probably aren't any
> *good* reasons why a leaf at 0x40000x03 would exist and belong to some
> other entity (Hyper-V, etc.). Those other extra ranges of CPUID are
> generally aligned at multiples of 0x100, not just the *next* available
> leaf.
> 
> But I don't care. Unless eax on the main Xen leaf is 3 or more, the
> leaf at N+3 isn't yours to reason about :)
> 

According to https://lwn.net/Articles/301888 (which is ancient), the Microsoft TLFS and my copy of the Xen source code, it seems everyone does agree that the hypervisor base leaf EAX does specify the maximum leaf (in absolute terms rather than the offset) so I'll add that check into v3.

  Paul

> > +	if (!base)
> > +		return;
> > +
> > +	function = base | XEN_CPUID_LEAF(3);
> > +	vcpu->arch.xen.tsc_info_1 = kvm_find_cpuid_entry(vcpu, function, 1);
> > +	vcpu->arch.xen.tsc_info_2 = kvm_find_cpuid_entry(vcpu, function, 2);
> > +}
> > +




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux