diff mbox

[kvm-unit-tests,1/4] x86: vmx: restore primary controls in test_tpr_threshold early return

Message ID 20180718202651.19802-2-sean.j.christopherson@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sean Christopherson July 18, 2018, 8:26 p.m. UTC
test_tpr_threshold() could theoretically leave CPU_TPR_SHADOW set in
its early return path when none of the secondary controls needed for
the remaining tests are supported.

Fix the prefix for the TPR-enabled, sec_exec-disabled case.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 x86/vmx_tests.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Krish Sadhukhan July 18, 2018, 9:23 p.m. UTC | #1
On 07/18/2018 01:26 PM, Sean Christopherson wrote:
> test_tpr_threshold() could theoretically leave CPU_TPR_SHADOW set in
> its early return path when none of the secondary controls needed for
> the remaining tests are supported.
>
> Fix the prefix for the TPR-enabled, sec_exec-disabled case.
>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>   x86/vmx_tests.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index 6c73041..ab6e089 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -4085,13 +4085,15 @@ static void test_tpr_threshold(void)
>   	test_tpr_threshold_values();
>   	report_prefix_pop();
>   	vmcs_write(CPU_EXEC_CTRL0, vmcs_read(CPU_EXEC_CTRL0) | CPU_TPR_SHADOW);
> -	report_prefix_pushf("Use TPR shadow enabled");
> +	report_prefix_pushf("Use TPR shadow enabled, secondary controls disabled");
>   	test_tpr_threshold_values();
>   	report_prefix_pop();
>   
>   	if (!((ctrl_cpu_rev[0].clr & CPU_SECONDARY) &&
> -	    (ctrl_cpu_rev[1].clr & (CPU_VINTD  | CPU_VIRT_APIC_ACCESSES))))
> +	    (ctrl_cpu_rev[1].clr & (CPU_VINTD  | CPU_VIRT_APIC_ACCESSES)))) {
> +		vmcs_write(CPU_EXEC_CTRL0, primary);
>   		return;
> +	}
>   
>   	u32 secondary = vmcs_read(CPU_EXEC_CTRL1);
>   
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
diff mbox

Patch

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 6c73041..ab6e089 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -4085,13 +4085,15 @@  static void test_tpr_threshold(void)
 	test_tpr_threshold_values();
 	report_prefix_pop();
 	vmcs_write(CPU_EXEC_CTRL0, vmcs_read(CPU_EXEC_CTRL0) | CPU_TPR_SHADOW);
-	report_prefix_pushf("Use TPR shadow enabled");
+	report_prefix_pushf("Use TPR shadow enabled, secondary controls disabled");
 	test_tpr_threshold_values();
 	report_prefix_pop();
 
 	if (!((ctrl_cpu_rev[0].clr & CPU_SECONDARY) &&
-	    (ctrl_cpu_rev[1].clr & (CPU_VINTD  | CPU_VIRT_APIC_ACCESSES))))
+	    (ctrl_cpu_rev[1].clr & (CPU_VINTD  | CPU_VIRT_APIC_ACCESSES)))) {
+		vmcs_write(CPU_EXEC_CTRL0, primary);
 		return;
+	}
 
 	u32 secondary = vmcs_read(CPU_EXEC_CTRL1);