diff options
| -rw-r--r-- | arch/x86/kvm/Kconfig | 2 | ||||
| -rw-r--r-- | arch/x86/kvm/ioapic.c | 7 | ||||
| -rw-r--r-- | arch/x86/kvm/vmx/vmx.c | 16 | 
3 files changed, 20 insertions, 5 deletions
| diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig index 1bb4927030af..9fea0757db92 100644 --- a/arch/x86/kvm/Kconfig +++ b/arch/x86/kvm/Kconfig @@ -68,7 +68,7 @@ config KVM_WERROR  	depends on (X86_64 && !KASAN) || !COMPILE_TEST  	depends on EXPERT  	help -	  Add -Werror to the build flags for (and only for) i915.ko. +	  Add -Werror to the build flags for KVM.  	  If in doubt, say "N". diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c index 7668fed1ce65..750ff0b29404 100644 --- a/arch/x86/kvm/ioapic.c +++ b/arch/x86/kvm/ioapic.c @@ -378,12 +378,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)  		if (e->fields.delivery_mode == APIC_DM_FIXED) {  			struct kvm_lapic_irq irq; -			irq.shorthand = APIC_DEST_NOSHORT;  			irq.vector = e->fields.vector;  			irq.delivery_mode = e->fields.delivery_mode << 8; -			irq.dest_id = e->fields.dest_id;  			irq.dest_mode =  			    kvm_lapic_irq_dest_mode(!!e->fields.dest_mode); +			irq.level = false; +			irq.trig_mode = e->fields.trig_mode; +			irq.shorthand = APIC_DEST_NOSHORT; +			irq.dest_id = e->fields.dest_id; +			irq.msi_redir_hint = false;  			bitmap_zero(&vcpu_bitmap, 16);  			kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq,  						 &vcpu_bitmap); diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 40b1e6138cd5..26f8f31563e9 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -2338,6 +2338,17 @@ static void hardware_disable(void)  	kvm_cpu_vmxoff();  } +/* + * There is no X86_FEATURE for SGX yet, but anyway we need to query CPUID + * directly instead of going through cpu_has(), to ensure KVM is trapping + * ENCLS whenever it's supported in hardware.  It does not matter whether + * the host OS supports or has enabled SGX. + */ +static bool cpu_has_sgx(void) +{ +	return cpuid_eax(0) >= 0x12 && (cpuid_eax(0x12) & BIT(0)); +} +  static __init int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt,  				      u32 msr, u32 *result)  { @@ -2418,8 +2429,9 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,  			SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE |  			SECONDARY_EXEC_PT_USE_GPA |  			SECONDARY_EXEC_PT_CONCEAL_VMX | -			SECONDARY_EXEC_ENABLE_VMFUNC | -			SECONDARY_EXEC_ENCLS_EXITING; +			SECONDARY_EXEC_ENABLE_VMFUNC; +		if (cpu_has_sgx()) +			opt2 |= SECONDARY_EXEC_ENCLS_EXITING;  		if (adjust_vmx_controls(min2, opt2,  					MSR_IA32_VMX_PROCBASED_CTLS2,  					&_cpu_based_2nd_exec_control) < 0) |