[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/xstate: Rework xsetbv() to use asm goto()
commit 18f960208f57aeb3a50b69b3baddb1b86c2731d1 Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Fri Apr 18 16:19:59 2025 +0100 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Tue May 27 12:21:38 2025 +0100 x86/xstate: Rework xsetbv() to use asm goto() Switch to using a mnemonic, and asm_inline as there's EXTABLE metadata. Update the types, and adjust parameter names. The name xfeatures is specific to xcr0, so rename to val to be more generic, even if there isn't another writeable xcr yet. No functional change. Resolves: https://gitlab.com/xen-project/xen/-/work_items/212 Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/xstate.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c index 3d249518a1..e8e218caed 100644 --- a/xen/arch/x86/xstate.c +++ b/xen/arch/x86/xstate.c @@ -40,21 +40,22 @@ static DEFINE_PER_CPU(uint64_t, xcr0); /* Because XCR0 is cached for each CPU, xsetbv() is not exposed. Users should * use set_xcr0() instead. */ -static inline bool xsetbv(u32 index, u64 xfeatures) +static inline bool xsetbv(uint32_t xcr, uint64_t val) { - u32 hi = xfeatures >> 32; - u32 lo = (u32)xfeatures; - - asm volatile ( "1: .byte 0x0f,0x01,0xd1\n" - "3: \n" - ".section .fixup,\"ax\" \n" - "2: xor %0,%0 \n" - " jmp 3b \n" - ".previous \n" - _ASM_EXTABLE(1b, 2b) - : "+a" (lo) - : "c" (index), "d" (hi)); - return lo != 0; + uint32_t hi = val >> 32, lo = val; + + asm_inline goto ( + "1: xsetbv\n\t" + _ASM_EXTABLE(1b, %l[fault]) + : + : "a" (lo), "c" (xcr), "d" (hi) + : + : fault ); + + return true; + + fault: + return false; } bool set_xcr0(u64 xfeatures) -- generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |