Re: [PATCH v9 2/3] x86, apicv: add virtual x2apic support

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

 



On Thu, Jan 10, 2013 at 08:31:51AM +0000, Zhang, Yang Z wrote:
> Gleb Natapov wrote on 2013-01-10:
> > On Thu, Jan 10, 2013 at 03:26:07PM +0800, Yang Zhang wrote:
> >> +static void vmx_enable_virtual_x2apic_mode(struct kvm_vcpu *vcpu)
> >> +{
> >> +	u32 exec_control;
> >> +	int msr;
> >> +	struct vcpu_vmx *vmx = to_vmx(vcpu);
> >> +
> >> +	if (!cpu_has_vmx_virtualize_x2apic_mode())
> >> +		return;
> >> +
> >> +	exec_control = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
> >> +	/* virtualize x2apic mode relies on tpr shadow */
> >> +	if (!(exec_control & CPU_BASED_TPR_SHADOW))
> >> +		return;
> >> +
> >> +	exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);
> >> +	exec_control &= ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;
> >> +	exec_control |= SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE;
> >> +	vmcs_write32(SECONDARY_VM_EXEC_CONTROL, exec_control);
> >> +	vmx->virtual_x2apic_enabled = true;
> >> +
> >> +	if (!cpu_has_vmx_virtual_intr_delivery())
> >> +		return;
> >> +
> >> +	for (msr = 0x800; msr <= 0x8ff; msr++)
> >> +		vmx_intercept_for_msr_read(msr, false, false);
> >> +
> >> +	/* APIC ID */
> >> +	vmx_intercept_for_msr_read(0x802, false, true);
> > Why are you enabling apic id read intercept?
> Current code to read apic id in x2apic mode has some hacks:
> 
> if (apic_x2apic_mode(apic))
>        val = kvm_apic_id(apic);
> else
>        val = kvm_apic_id(apic) << 24;
> 
> static inline int kvm_apic_id(struct kvm_lapic *apic)
> {
>         return (kvm_apic_get_reg(apic, APIC_ID) >> 24) & 0xff;
> }
> 
> According SPEC, in x2apic mode, the whole id reg is used, but in KVM, it only use the highest eight bits.
> 
Correct. Put the comment above apic id intercept that we do that since
in x2apic mode apic id is not correctly reflected in apic page.

> >> +	/* TMCCT */
> >> +	vmx_intercept_for_msr_read(0x839, false, true);
> >> +	/* TPR */
> >> +	vmx_intercept_for_msr_write(0x808, false, false);
> >> +	/* EOI */
> >> +	vmx_intercept_for_msr_write(0x80b, false, false);
> >> +	/* SELF-IPI */
> >> +	vmx_intercept_for_msr_write(0x83f, false, false);
> >> +
> >> +}
> >> +
> > 
> > --
> > 			Gleb.
> 
> 
> Best regards,
> Yang
> 

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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