From f72ae12455d71b73fc785024cacbdbe93ac13e11 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Fri, 1 Mar 2024 21:41:45 +0000 Subject: [PATCH] test-umip: Misc improvements, mostly for 32bit * Record the fault in %eax to avoid forcing a spill of %edi * Use testb $1 so %[fep] can be a memory operand referencing the parameter directly on the stack. * Render UMIP and FEP in the failure message. No functional change. Signed-off-by: Andrew Cooper --- tests/umip/main.c | 55 +++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/tests/umip/main.c b/tests/umip/main.c index 40ebc71..b2a96fa 100644 --- a/tests/umip/main.c +++ b/tests/umip/main.c @@ -19,84 +19,85 @@ bool test_wants_user_mappings = true; static unsigned long stub_sgdt(unsigned long force) { - exinfo_t fault = 0; + unsigned long fault = 0; desc_ptr tmp; - asm volatile("test %[fep], %[fep];" + asm volatile("testb $1, %b[fep];" "jz 1f;" _ASM_XEN_FEP "1: sgdt %[tmp]; 2:" _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) - : "+D" (fault), [tmp] "=m" (tmp) - : [fep] "q" (force), - [rec] "p" (ex_record_fault_edi)); + : "+a" (fault), [tmp] "=m" (tmp) + : [fep] "rm" (force), + [rec] "p" (ex_record_fault_eax)); return fault; } + static unsigned long stub_sidt(unsigned long force) { - exinfo_t fault = 0; + unsigned long fault = 0; desc_ptr tmp; - asm volatile("test %[fep], %[fep];" + asm volatile("testb $1, %b[fep];" "jz 1f;" _ASM_XEN_FEP "1: sidt %[tmp]; 2:" _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) - : "+D" (fault), [tmp] "=m" (tmp) - : [fep] "q" (force), - [rec] "p" (ex_record_fault_edi)); + : "+a" (fault), [tmp] "=m" (tmp) + : [fep] "rm" (force), + [rec] "p" (ex_record_fault_eax)); return fault; } static unsigned long stub_sldt(unsigned long force) { - exinfo_t fault = 0; + unsigned long fault = 0; unsigned int tmp; - asm volatile("test %[fep], %[fep];" + asm volatile("testb $1, %b[fep];" "jz 1f;" _ASM_XEN_FEP "1: sldt %[tmp]; 2:" _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) - : "+D" (fault), [tmp] "=r" (tmp) - : [fep] "q" (force), - [rec] "p" (ex_record_fault_edi)); + : "+a" (fault), [tmp] "=r" (tmp) + : [fep] "rm" (force), + [rec] "p" (ex_record_fault_eax)); return fault; } static unsigned long stub_str(unsigned long force) { - exinfo_t fault = 0; + unsigned long fault = 0; unsigned int tmp; - asm volatile("test %[fep], %[fep];" + asm volatile("testb $1, %b[fep];" "jz 1f;" _ASM_XEN_FEP "1: str %[tmp]; 2:" _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) - : "+D" (fault), [tmp] "=r" (tmp) - : [fep] "q" (force), - [rec] "p" (ex_record_fault_edi)); + : "+a" (fault), [tmp] "=r" (tmp) + : [fep] "rm" (force), + [rec] "p" (ex_record_fault_eax)); return fault; } static unsigned long stub_smsw(unsigned long force) { - exinfo_t fault = 0; + unsigned long fault = 0; unsigned int tmp; - asm volatile("test %[fep], %[fep];" + asm volatile("testb $1, %b[fep];" "jz 1f;" _ASM_XEN_FEP "1: smsw %[tmp]; 2:" _ASM_EXTABLE_HANDLER(1b, 2b, %P[rec]) - : "+D" (fault), [tmp] "=r" (tmp) - : [fep] "q" (force), - [rec] "p" (ex_record_fault_edi)); + : "+a" (fault), [tmp] "=r" (tmp) + : [fep] "rm" (force), + [rec] "p" (ex_record_fault_eax)); return fault; } @@ -146,10 +147,12 @@ static void test_insns(bool umip_active, bool force) } if ( ret != exp ) - xtf_failure("Fail: %s %s\n" + xtf_failure("Fail: %s %s (UMIP%c, FEP%c)\n" " expected %pe\n" " got %pe\n", user ? "user" : "supervisor", s->name, + umip_active ? '+' : '-', + force ? '+' : '-', _p(exp), _p(ret)); } -- 2.39.5