Re: [PATCH] KVM: VMX: drop I/O permission bitmaps

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

 



On 08.12.2017 11:22, Quan Xu wrote:
> From: Quan Xu <quan.xu0@xxxxxxxxx>
> 
> Since KVM removes the only I/O port 0x80 bypass on Intel hosts,
> clear CPU_BASED_USE_IO_BITMAPS and set CPU_BASED_UNCOND_IO_EXITING
> bit. Then these I/O permission bitmaps are not used at all, so
> drop I/O permission bitmaps.
> 
> Signed-off-by: Jim Mattson <jmattson@xxxxxxxxxx>
> Signed-off-by: Radim Krčmář <rkrcmar@xxxxxxxxxx>
> Signed-off-by: Quan Xu <quan.xu0@xxxxxxxxx>
> ---
>  arch/x86/kvm/vmx.c |   17 +----------------
>  1 files changed, 1 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 2fd9a8c..3e4f760 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -771,8 +771,6 @@ enum segment_cache_field {
>  	FIELD(HOST_FS_SELECTOR, host_fs_selector),
>  	FIELD(HOST_GS_SELECTOR, host_gs_selector),
>  	FIELD(HOST_TR_SELECTOR, host_tr_selector),
> -	FIELD64(IO_BITMAP_A, io_bitmap_a),
> -	FIELD64(IO_BITMAP_B, io_bitmap_b),
>  	FIELD64(MSR_BITMAP, msr_bitmap),
>  	FIELD64(VM_EXIT_MSR_STORE_ADDR, vm_exit_msr_store_addr),
>  	FIELD64(VM_EXIT_MSR_LOAD_ADDR, vm_exit_msr_load_addr),
> @@ -943,8 +941,6 @@ static bool nested_vmx_is_page_fault_vmexit(struct vmcs12 *vmcs12,
>  static DEFINE_PER_CPU(spinlock_t, blocked_vcpu_on_cpu_lock);
>  
>  enum {
> -	VMX_IO_BITMAP_A,
> -	VMX_IO_BITMAP_B,
>  	VMX_MSR_BITMAP_LEGACY,
>  	VMX_MSR_BITMAP_LONGMODE,
>  	VMX_MSR_BITMAP_LEGACY_X2APIC_APICV,
> @@ -958,8 +954,6 @@ enum {
>  
>  static unsigned long *vmx_bitmap[VMX_BITMAP_NR];
>  
> -#define vmx_io_bitmap_a                      (vmx_bitmap[VMX_IO_BITMAP_A])
> -#define vmx_io_bitmap_b                      (vmx_bitmap[VMX_IO_BITMAP_B])
>  #define vmx_msr_bitmap_legacy                (vmx_bitmap[VMX_MSR_BITMAP_LEGACY])
>  #define vmx_msr_bitmap_longmode              (vmx_bitmap[VMX_MSR_BITMAP_LONGMODE])
>  #define vmx_msr_bitmap_legacy_x2apic_apicv   (vmx_bitmap[VMX_MSR_BITMAP_LEGACY_X2APIC_APICV])
> @@ -3632,7 +3626,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
>  #endif
>  	      CPU_BASED_CR3_LOAD_EXITING |
>  	      CPU_BASED_CR3_STORE_EXITING |
> -	      CPU_BASED_USE_IO_BITMAPS |
> +	      CPU_BASED_UNCOND_IO_EXITING |
>  	      CPU_BASED_MOV_DR_EXITING |
>  	      CPU_BASED_USE_TSC_OFFSETING |
>  	      CPU_BASED_INVLPG_EXITING |
> @@ -5445,10 +5439,6 @@ static void vmx_vcpu_setup(struct vcpu_vmx *vmx)
>  #endif
>  	int i;
>  
> -	/* I/O */
> -	vmcs_write64(IO_BITMAP_A, __pa(vmx_io_bitmap_a));
> -	vmcs_write64(IO_BITMAP_B, __pa(vmx_io_bitmap_b));
> -
>  	if (enable_shadow_vmcs) {
>  		vmcs_write64(VMREAD_BITMAP, __pa(vmx_vmread_bitmap));
>  		vmcs_write64(VMWRITE_BITMAP, __pa(vmx_vmwrite_bitmap));
> @@ -6751,14 +6741,9 @@ static __init int hardware_setup(void)
>  			goto out;
>  	}
>  
> -	vmx_io_bitmap_b = (unsigned long *)__get_free_page(GFP_KERNEL);
>  	memset(vmx_vmread_bitmap, 0xff, PAGE_SIZE);
>  	memset(vmx_vmwrite_bitmap, 0xff, PAGE_SIZE);
>  
> -	memset(vmx_io_bitmap_a, 0xff, PAGE_SIZE);
> -
> -	memset(vmx_io_bitmap_b, 0xff, PAGE_SIZE);
> -
>  	memset(vmx_msr_bitmap_legacy, 0xff, PAGE_SIZE);
>  	memset(vmx_msr_bitmap_longmode, 0xff, PAGE_SIZE);
>  
> 

Looks good to me.

We could now also drop

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index a5d2856eb28b..732e93332f4c 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -10639,7 +10639,6 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu,
struct vmcs12 *vmcs12,
         * Rather, exit every time.
         */
        exec_control &= ~CPU_BASED_USE_IO_BITMAPS;
-       exec_control |= CPU_BASED_UNCOND_IO_EXITING;

        vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, exec_control);

As this will be implicitly set by vmx_exec_control()

-- 

Thanks,

David / dhildenb



[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