Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 774ead3a authored by Avi Kivity's avatar Avi Kivity
Browse files

KVM: Disable vapic support on Intel machines with FlexPriority



FlexPriority accelerates the tpr without any patching.

Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent b93463aa
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -1653,6 +1653,11 @@ static void svm_check_processor_compat(void *rtn)
	*(int *)rtn = 0;
	*(int *)rtn = 0;
}
}


static bool svm_cpu_has_accelerated_tpr(void)
{
	return false;
}

static struct kvm_x86_ops svm_x86_ops = {
static struct kvm_x86_ops svm_x86_ops = {
	.cpu_has_kvm_support = has_svm,
	.cpu_has_kvm_support = has_svm,
	.disabled_by_bios = is_disabled,
	.disabled_by_bios = is_disabled,
@@ -1661,6 +1666,7 @@ static struct kvm_x86_ops svm_x86_ops = {
	.check_processor_compatibility = svm_check_processor_compat,
	.check_processor_compatibility = svm_check_processor_compat,
	.hardware_enable = svm_hardware_enable,
	.hardware_enable = svm_hardware_enable,
	.hardware_disable = svm_hardware_disable,
	.hardware_disable = svm_hardware_disable,
	.cpu_has_accelerated_tpr = svm_cpu_has_accelerated_tpr,


	.vcpu_create = svm_create_vcpu,
	.vcpu_create = svm_create_vcpu,
	.vcpu_free = svm_free_vcpu,
	.vcpu_free = svm_free_vcpu,
+2 −1
Original line number Original line Diff line number Diff line
@@ -192,7 +192,7 @@ static inline int cpu_has_secondary_exec_ctrls(void)
		CPU_BASED_ACTIVATE_SECONDARY_CONTROLS);
		CPU_BASED_ACTIVATE_SECONDARY_CONTROLS);
}
}


static inline int cpu_has_vmx_virtualize_apic_accesses(void)
static inline bool cpu_has_vmx_virtualize_apic_accesses(void)
{
{
	return (vmcs_config.cpu_based_2nd_exec_ctrl &
	return (vmcs_config.cpu_based_2nd_exec_ctrl &
		SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES);
		SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES);
@@ -2565,6 +2565,7 @@ static struct kvm_x86_ops vmx_x86_ops = {
	.check_processor_compatibility = vmx_check_processor_compat,
	.check_processor_compatibility = vmx_check_processor_compat,
	.hardware_enable = hardware_enable,
	.hardware_enable = hardware_enable,
	.hardware_disable = hardware_disable,
	.hardware_disable = hardware_disable,
	.cpu_has_accelerated_tpr = cpu_has_vmx_virtualize_apic_accesses,


	.vcpu_create = vmx_create_vcpu,
	.vcpu_create = vmx_create_vcpu,
	.vcpu_free = vmx_free_vcpu,
	.vcpu_free = vmx_free_vcpu,
+3 −1
Original line number Original line Diff line number Diff line
@@ -684,9 +684,11 @@ int kvm_dev_ioctl_check_extension(long ext)
	case KVM_CAP_USER_MEMORY:
	case KVM_CAP_USER_MEMORY:
	case KVM_CAP_SET_TSS_ADDR:
	case KVM_CAP_SET_TSS_ADDR:
	case KVM_CAP_EXT_CPUID:
	case KVM_CAP_EXT_CPUID:
	case KVM_CAP_VAPIC:
		r = 1;
		r = 1;
		break;
		break;
	case KVM_CAP_VAPIC:
		r = !kvm_x86_ops->cpu_has_accelerated_tpr();
		break;
	default:
	default:
		r = 0;
		r = 0;
		break;
		break;
+1 −0
Original line number Original line Diff line number Diff line
@@ -329,6 +329,7 @@ struct kvm_x86_ops {
	void (*check_processor_compatibility)(void *rtn);
	void (*check_processor_compatibility)(void *rtn);
	int (*hardware_setup)(void);               /* __init */
	int (*hardware_setup)(void);               /* __init */
	void (*hardware_unsetup)(void);            /* __exit */
	void (*hardware_unsetup)(void);            /* __exit */
	bool (*cpu_has_accelerated_tpr)(void);


	/* Create, but do not attach this VCPU */
	/* Create, but do not attach this VCPU */
	struct kvm_vcpu *(*vcpu_create)(struct kvm *kvm, unsigned id);
	struct kvm_vcpu *(*vcpu_create)(struct kvm *kvm, unsigned id);