Skip to content

Commit 3e8ea78

Browse files
author
Peter Zijlstra
committed
x86/vmx: Remove .fixup usage
In the vmread exceptin path, use the, thus far, unused output register to push the @fault argument onto the stack. This, in turn, enables the exception handler to not do pushes and only modify that register when an exception does occur. As noted by Sean the input constraint needs to be changed to "=&r" to avoid the value and field occupying the same register. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Paolo Bonzini <[email protected]> Reviewed-by: Josh Poimboeuf <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c9a34c3 commit 3e8ea78

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

arch/x86/kvm/vmx/vmx_ops.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ static __always_inline unsigned long __vmcs_readl(unsigned long field)
8080
* @field, and bounce through the trampoline to preserve
8181
* volatile registers.
8282
*/
83-
"push $0\n\t"
83+
"xorl %k1, %k1\n\t"
84+
"2:\n\t"
85+
"push %1\n\t"
8486
"push %2\n\t"
85-
"2:call vmread_error_trampoline\n\t"
87+
"call vmread_error_trampoline\n\t"
8688

8789
/*
8890
* Unwind the stack. Note, the trampoline zeros out the
@@ -93,13 +95,9 @@ static __always_inline unsigned long __vmcs_readl(unsigned long field)
9395
"3:\n\t"
9496

9597
/* VMREAD faulted. As above, except push '1' for @fault. */
96-
".pushsection .fixup, \"ax\"\n\t"
97-
"4: push $1\n\t"
98-
"push %2\n\t"
99-
"jmp 2b\n\t"
100-
".popsection\n\t"
101-
_ASM_EXTABLE(1b, 4b)
102-
: ASM_CALL_CONSTRAINT, "=r"(value) : "r"(field) : "cc");
98+
_ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_ONE_REG, %1)
99+
100+
: ASM_CALL_CONSTRAINT, "=&r"(value) : "r"(field) : "cc");
103101
return value;
104102
}
105103

0 commit comments

Comments
 (0)