Patchwork [kvm-unit-test,2/3] KVM nVMX: test_vmcs_page_values() needs to accept a bit range

login
register
mail settings
Submitter Krish Sadhukhan
Date Dec. 6, 2018, 6:20 p.m.
Message ID <20181206182055.16927-3-krish.sadhukhan@oracle.com>
Download mbox | patch
Permalink /patch/674553/
State New
Headers show

Comments

Krish Sadhukhan - Dec. 6, 2018, 6:20 p.m.
... because various addresses need to be tested for various bit ranges.

Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Reviewed-by: Mihai Carabas <mihai.carabas@oracle.com>
---
 x86/vmx_tests.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
Jim Mattson - Dec. 6, 2018, 7:53 p.m.
On Thu, Dec 6, 2018 at 10:46 AM Krish Sadhukhan
<krish.sadhukhan@oracle.com> wrote:
>
>  ... because various addresses need to be tested for various bit ranges.
>
> Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
> Reviewed-by: Mihai Carabas <mihai.carabas@oracle.com>

If the low 12 bits don't have to be zero, then it isn't actually a
page reference.

Patch

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 76bf1f4..900dcf4 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -3488,12 +3488,12 @@  static void test_vmcs_page_values(const char *name,
 				  enum Encoding encoding,
 				  bool ignored,
 				  bool xfail_beyond_mapped_ram,
-				  u64 align)
+				  u64 align, u32 addr_start, u32 addr_end)
 {
 	unsigned i;
 	u64 orig_val = vmcs_read(encoding);
 
-	for (i = 0; i < 64; i++)
+	for (i = addr_start; i < addr_end; i++)
 		test_vmcs_page_addr(name, encoding, ignored,
 				    xfail_beyond_mapped_ram, 1ul << i,
 				    align);
@@ -3547,7 +3547,7 @@  static void test_vmcs_page_reference(u32 control_bit, enum Encoding field,
 		vmcs_write(CPU_EXEC_CTRL1, secondary | control_bit);
 	}
 	test_vmcs_page_values(field_name, field, false,
-			      xfail_beyond_mapped_ram, align);
+			      xfail_beyond_mapped_ram, align, 0, 64);
 	report_prefix_pop();
 
 	report_prefix_pushf("%s disabled", control_name);
@@ -3557,7 +3557,8 @@  static void test_vmcs_page_reference(u32 control_bit, enum Encoding field,
 		vmcs_write(CPU_EXEC_CTRL0, primary & ~CPU_SECONDARY);
 		vmcs_write(CPU_EXEC_CTRL1, secondary & ~control_bit);
 	}
-	test_vmcs_page_values(field_name, field, true, false, align);
+	test_vmcs_page_values(field_name, field, true, false, align,
+			      0, 64);
 	report_prefix_pop();
 
 	vmcs_write(field, page_addr);
@@ -3912,7 +3913,7 @@  static void test_posted_intr(void)
 	test_pi_desc_addr(0xc000, true);
 
 	test_vmcs_page_values("process-posted interrupts",
-	    POSTED_INTR_DESC_ADDR, false, false);
+	    POSTED_INTR_DESC_ADDR, false, false, PAGE_SIZE, 0, 64);
 
 	vmcs_write(CPU_EXEC_CTRL0, saved_primary);
 	vmcs_write(CPU_EXEC_CTRL1, saved_secondary);