diff mbox

KVM: nVMX: Support direct APIC access from L2

Message ID 52AEEA42.7020608@siemens.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Kiszka Dec. 16, 2013, 11:55 a.m. UTC
It's a pathological case, but still a valid one: If L1 disables APIC
virtualization and also allows L2 to directly write to the APIC page, we
have to forcibly enable APIC virtualization while in L2 if the in-kernel
APIC is in use.

This allows to run the direct interrupt test case in the vmx unit test
without x2APIC.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 arch/x86/kvm/vmx.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Paolo Bonzini Dec. 18, 2013, 9:27 a.m. UTC | #1
Il 16/12/2013 12:55, Jan Kiszka ha scritto:
> It's a pathological case, but still a valid one: If L1 disables APIC
> virtualization and also allows L2 to directly write to the APIC page, we
> have to forcibly enable APIC virtualization while in L2 if the in-kernel
> APIC is in use.
> 
> This allows to run the direct interrupt test case in the vmx unit test
> without x2APIC.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  arch/x86/kvm/vmx.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index da04247..7c3ea63 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -7771,6 +7771,11 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
>  			else
>  				vmcs_write64(APIC_ACCESS_ADDR,
>  				  page_to_phys(vmx->nested.apic_access_page));
> +		} else if (vm_need_virtualize_apic_accesses(vmx->vcpu.kvm)) {
> +			exec_control |=
> +				SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;
> +			vmcs_write64(APIC_ACCESS_ADDR,
> +				page_to_phys(vcpu->kvm->arch.apic_access_page));
>  		}
>  
>  		vmcs_write32(SECONDARY_VM_EXEC_CONTROL, exec_control);
> 

Applied, thanks.

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

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index da04247..7c3ea63 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -7771,6 +7771,11 @@  static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
 			else
 				vmcs_write64(APIC_ACCESS_ADDR,
 				  page_to_phys(vmx->nested.apic_access_page));
+		} else if (vm_need_virtualize_apic_accesses(vmx->vcpu.kvm)) {
+			exec_control |=
+				SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;
+			vmcs_write64(APIC_ACCESS_ADDR,
+				page_to_phys(vcpu->kvm->arch.apic_access_page));
 		}
 
 		vmcs_write32(SECONDARY_VM_EXEC_CONTROL, exec_control);