]> xenbits.xensource.com Git - xtf.git/commitdiff
test-pv-iopl: Update to avoid using test_wants_user_mappings
authorAndrew Cooper <andrew.cooper3@citrix.com>
Sat, 2 Mar 2024 01:41:28 +0000 (01:41 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Sun, 3 Mar 2024 00:13:29 +0000 (00:13 +0000)
Create a second set stubs, and place them in .text.user.

No change in test behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
tests/pv-iopl/main.c

index b78acff26c6e1fe9240cb8357b68dcc68b4e61cc..bb68bb45fdc44c17e03fce2c57b7c75a7c9e1092 100644 (file)
@@ -42,8 +42,6 @@
 
 const char test_title[] = "PV IOPL emulation";
 
-bool test_wants_user_mappings = true;
-
 static unsigned long stub_cli(void)
 {
     unsigned long fault = 0;
@@ -56,6 +54,18 @@ static unsigned long stub_cli(void)
     return fault;
 }
 
+static unsigned long __user_text stub_user_cli(void)
+{
+    unsigned long fault = 0;
+
+    asm ("1: cli; 2:"
+         _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec])
+         : "+a" (fault)
+         : [rec] "p" (ex_record_fault_eax));
+
+    return fault;
+}
+
 static unsigned long stub_outb(void)
 {
     unsigned long fault = 0;
@@ -68,12 +78,25 @@ static unsigned long stub_outb(void)
     return fault;
 }
 
+static unsigned long __user_text stub_user_outb(void)
+{
+    unsigned long fault = 0;
+
+    asm ("1: outb %b0, $0x80; 2:"
+         _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec])
+         : "+a" (fault) /* Overloaded as the input to OUTB */
+         : [rec] "p" (ex_record_fault_eax));
+
+    return fault;
+}
+
 static const struct insn {
     const char *name;
     unsigned long (*fn)(void);
+    unsigned long (*user_fn)(void);
 } insns[] = {
-    { "cli",  stub_cli,  },
-    { "outb", stub_outb, },
+    { "cli",  stub_cli,  stub_user_cli,  },
+    { "outb", stub_outb, stub_user_outb, },
 };
 
 enum mode { KERN, USER };
@@ -108,7 +131,7 @@ static void run_test(const struct test *t)
 
             /* Run insn in userspace. */
             exp = t->should_fault(USER, iopl) ? EXINFO_SYM(GP, 0) : 0;
-            got = exec_user(insn->fn);
+            got = exec_user(insn->user_fn);
 
             if ( exp != got )
                 xtf_failure("Fail: user %s, expected %pe, got %pe\n",
@@ -152,7 +175,7 @@ static const struct test hypercall = {
     .should_fault = hypercall_should_fault,
 };
 
-static void nop(void){}
+static void __user_text nop(void) {}
 static void vmassist_set_iopl(unsigned int iopl)
 {
     /*