From: Andrew Cooper Date: Sat, 2 Mar 2024 01:41:28 +0000 (+0000) Subject: test-pv-iopl: Update to avoid using test_wants_user_mappings X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5fb6f83fb966b4d0b762dc293dd932907253bf18;p=people%2Fandrewcoop%2Fxen-test-framework.git test-pv-iopl: Update to avoid using test_wants_user_mappings Create a second set stubs, and place them in .text.user. No change in test behaviour. Signed-off-by: Andrew Cooper --- diff --git a/tests/pv-iopl/main.c b/tests/pv-iopl/main.c index b78acff..bb68bb4 100644 --- a/tests/pv-iopl/main.c +++ b/tests/pv-iopl/main.c @@ -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) { /*