Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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) <peterz@infradead.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20211110101325.781308550@infradead.org

+7 -9
+7 -9
arch/x86/kvm/vmx/vmx_ops.h
··· 80 80 * @field, and bounce through the trampoline to preserve 81 81 * volatile registers. 82 82 */ 83 - "push $0\n\t" 83 + "xorl %k1, %k1\n\t" 84 + "2:\n\t" 85 + "push %1\n\t" 84 86 "push %2\n\t" 85 - "2:call vmread_error_trampoline\n\t" 87 + "call vmread_error_trampoline\n\t" 86 88 87 89 /* 88 90 * Unwind the stack. Note, the trampoline zeros out the ··· 95 93 "3:\n\t" 96 94 97 95 /* VMREAD faulted. As above, except push '1' for @fault. */ 98 - ".pushsection .fixup, \"ax\"\n\t" 99 - "4: push $1\n\t" 100 - "push %2\n\t" 101 - "jmp 2b\n\t" 102 - ".popsection\n\t" 103 - _ASM_EXTABLE(1b, 4b) 104 - : ASM_CALL_CONSTRAINT, "=r"(value) : "r"(field) : "cc"); 96 + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_ONE_REG, %1) 97 + 98 + : ASM_CALL_CONSTRAINT, "=&r"(value) : "r"(field) : "cc"); 105 99 return value; 106 100 } 107 101