]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
test-cpuid-faulting: Update to avoid using test_wants_user_mappings
authorAndrew Cooper <andrew.cooper3@citrix.com>
Sat, 2 Mar 2024 02:28:45 +0000 (02:28 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Sun, 3 Mar 2024 00:13:29 +0000 (00:13 +0000)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
tests/cpuid-faulting/main.c

index 56ee49e54d5f8a7e5a614f5a36023908e757c775..42b3fb10b07a73d9956ce176afcb784b6c16d9d5 100644 (file)
 
 const char test_title[] = "Guest CPUID Faulting support";
 
-bool test_wants_user_mappings = true;
+static unsigned long stub_cpuid(void)
+{
+    unsigned long fault = 0, tmp;
+
+    asm volatile("1: cpuid; 2:"
+                 _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec])
+                 : "=a" (tmp), "+D" (fault)
+                 : "a" (0), [rec] "p" (ex_record_fault_edi)
+                 : "ebx", "ecx", "edx");
+
+    return fault;
+}
+
+static unsigned long stub_force_cpuid(void)
+{
+    unsigned long fault = 0, tmp;
+
+    asm volatile(_ASM_XEN_FEP
+                 "1: cpuid; 2:"
+                 _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec])
+                 : "=a" (tmp), "+D" (fault)
+                 : "a" (0), [rec] "p" (ex_record_fault_edi)
+                 : "ebx", "ecx", "edx");
+
+    return fault;
+}
 
-unsigned long stub_cpuid(void)
+static unsigned long __user_text stub_user_cpuid(void)
 {
-    unsigned int fault = 0, tmp;
+    unsigned long fault = 0, tmp;
 
     asm volatile("1: cpuid; 2:"
                  _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec])
@@ -38,9 +63,9 @@ unsigned long stub_cpuid(void)
     return fault;
 }
 
-unsigned long stub_fep_cpuid(void)
+static unsigned long __user_text stub_user_force_cpuid(void)
 {
-    unsigned int fault = 0, tmp;
+    unsigned long fault = 0, tmp;
 
     asm volatile(_ASM_XEN_FEP
                  "1: cpuid; 2:"
@@ -60,10 +85,10 @@ static void test_cpuid(bool exp_faulting)
     if ( stub_cpuid() )
         xtf_failure("Fail: kernel cpuid faulted\n");
 
-    if ( IS_DEFINED(CONFIG_PV) && stub_fep_cpuid() )
+    if ( IS_DEFINED(CONFIG_PV) && stub_force_cpuid() )
         xtf_failure("Fail: kernel pv cpuid faulted\n");
 
-    if ( xtf_has_fep && stub_fep_cpuid() )
+    if ( xtf_has_fep && stub_force_cpuid() )
         xtf_failure("Fail: kernel emulated cpuid faulted\n");
 
     /*
@@ -72,13 +97,13 @@ static void test_cpuid(bool exp_faulting)
     unsigned long exp = exp_faulting ? EXINFO_SYM(GP, 0) : 0;
     const char *exp_fail_str = exp_faulting ? "didn't fault" : "faulted";
 
-    if ( exec_user(stub_cpuid) != exp )
+    if ( exec_user(stub_user_cpuid) != exp )
         xtf_failure("Fail: user cpuid %s\n", exp_fail_str);
 
-    if ( IS_DEFINED(CONFIG_PV) && exec_user(stub_fep_cpuid) != exp )
+    if ( IS_DEFINED(CONFIG_PV) && exec_user(stub_user_force_cpuid) != exp )
         xtf_failure("Fail: user pv cpuid %s\n", exp_fail_str);
 
-    if ( xtf_has_fep && exec_user(stub_fep_cpuid) != exp )
+    if ( xtf_has_fep && exec_user(stub_user_force_cpuid) != exp )
         xtf_failure("Fail: user emulated cpuid %s\n", exp_fail_str);
 }