Check use I/O bitmap first before unconditional I/O exit
PATCH 1/1 Check use I/O bitmap first before unconditional I/O exit
Signed-off-by Zhihui Zhang <[email protected]>
--- arch/x86/kvm/vmx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/kvm/vmx.c +4 -4
@@ -6460,11 +6460,11 @@ static bool nested_vmx_exit_handled_io(struct kvm_vcpu *vcpu,int size;u8 b; -if (nested_cpu_has (vmcs12,CPU_BASED_UNCOND_IO_EXITING )) -return 1 ; - -if (!nested_cpu_has (vmcs12,CPU_BASED_USE_IO_BITMAPS )) +if (!nested_cpu_has (vmcs12,CPU_BASED_USE_IO_BITMAPS )) { +if (nested_cpu_has (vmcs12,CPU_BASED_UNCOND_IO_EXITING )) +return 1 ;return 0 ; + } exit_qualification =vmcs_readl (EXIT_QUALIFICATION );
Signature · 1 line
1.8.1.2
Quoted 1 line · Zhihui Zhang
Signed-off-by Zhihui Zhang <[email protected]>
You should explain the "why" here, e.g. point to the SDM section that requires this ordering.
Quoted 9 lines
--- arch/x86/kvm/vmx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)arch/x86/kvm/vmx.c +0
-0
arch/x86/kvm/vmx.c static bool nested_vmx_exit_handled_io(struct kvm_vcpu *vcpu, · line 6465
Quoted 10 lines
arch/x86/kvm/vmx.c +3
-4@@ -6460,11 +6460,11 @@ static bool nested_vmx_exit_handled_io(struct kvm_vcpu *vcpu,int size;u8 b; -if (nested_cpu_has (vmcs12,CPU_BASED_UNCOND_IO_EXITING )) -return 1 ; - -if (!nested_cpu_has (vmcs12,CPU_BASED_USE_IO_BITMAPS )) +if (!nested_cpu_has (vmcs12,CPU_BASED_USE_IO_BITMAPS )) { +if (nested_cpu_has (vmcs12,CPU_BASED_UNCOND_IO_EXITING )) +return 1 ;
Minor nit, but what about
if (!nested_cpu_has(vmcs12, CPU_BASED_USE_IO_BITMAPS))
return nested_cpu_has(vmcs12, CPU_BASED_UNCOND_IO_EXITING);
instead?
Logic is correct, thanks for addressing this.
Could you also write an according sub-test in kvm-unit-tests [1]? We are already checking IO bitmap accesses, but not yet unconditional PIO exiting. Would be great!
Jan
Quoted 6 lines
arch/x86/kvm/vmx.c +1
-0return 0 ; + } exit_qualification =vmcs_readl (EXIT_QUALIFICATION );