[kvm-unit-tests,2/4] x86: vmx: shift TPR threshold when generating vTPR
diff mbox

Message ID 20180718202651.19802-3-sean.j.christopherson@intel.com
State New
Headers show

Commit Message

Sean Christopherson July 18, 2018, 8:26 p.m. UTC
The TPR thresold field stores its value in bits 3:0, while the vTPR's
effective value is in bits 7:4.  Shift the threshold value accordingly
when generating an "interesting" vTPR, otherwise we'll always use an
effective vTPR of 0, which is...uninteresting.

Cc: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 x86/vmx_tests.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Krish Sadhukhan July 18, 2018, 10:28 p.m. UTC | #1
On 07/18/2018 01:26 PM, Sean Christopherson wrote:
> The TPR thresold field stores its value in bits 3:0, while the vTPR's
> effective value is in bits 7:4.  Shift the threshold value accordingly
> when generating an "interesting" vTPR, otherwise we'll always use an
> effective vTPR of 0, which is...uninteresting.
>
> Cc: Krish Sadhukhan <krish.sadhukhan@oracle.com>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>   x86/vmx_tests.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index ab6e089..c4803a3 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -4010,9 +4010,9 @@ static void test_invalid_event_injection(void)
>    */
>   static void test_vtpr_values(unsigned threshold)
>   {
> -	try_tpr_threshold_and_vtpr(threshold, threshold - 1);
> -	try_tpr_threshold_and_vtpr(threshold, threshold);
> -	try_tpr_threshold_and_vtpr(threshold, threshold + 1);
> +	try_tpr_threshold_and_vtpr(threshold, (threshold - 1) << 4);
> +	try_tpr_threshold_and_vtpr(threshold, threshold << 4);
> +	try_tpr_threshold_and_vtpr(threshold, (threshold + 1) << 4);
>   }
>   
>   static void try_tpr_threshold(unsigned threshold)
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>

Patch
diff mbox

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index ab6e089..c4803a3 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -4010,9 +4010,9 @@  static void test_invalid_event_injection(void)
  */
 static void test_vtpr_values(unsigned threshold)
 {
-	try_tpr_threshold_and_vtpr(threshold, threshold - 1);
-	try_tpr_threshold_and_vtpr(threshold, threshold);
-	try_tpr_threshold_and_vtpr(threshold, threshold + 1);
+	try_tpr_threshold_and_vtpr(threshold, (threshold - 1) << 4);
+	try_tpr_threshold_and_vtpr(threshold, threshold << 4);
+	try_tpr_threshold_and_vtpr(threshold, (threshold + 1) << 4);
 }
 
 static void try_tpr_threshold(unsigned threshold)