The high-bandwidth helpers contain inline assembly which temporarily uses
%bp as a VMware ABI register. Keeping that assembly in vmware.h duplicates
it in callers.

Move both helpers to vmware.c and export them for the vmwgfx module.
Preserve their unwind hints and remove the redundant caller-wide objtool
annotations from vmwgfx.

Preserve the argument sequence from commit e0e022004bbe ("x86/vmware:
Fix i386 high-bandwidth hypercall arguments").

Signed-off-by: Zack Rusin <[email protected]>
---
 arch/x86/include/asm/vmware.h       | 62 +-------------------------
 arch/x86/kernel/cpu/vmware.c        | 68 +++++++++++++++++++++++++++++
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c |  3 --
 3 files changed, 70 insertions(+), 63 deletions(-)

diff --git a/arch/x86/include/asm/vmware.h b/arch/x86/include/asm/vmware.h
index fb011cef01e7..f3ffe358d2a3 100644
--- a/arch/x86/include/asm/vmware.h
+++ b/arch/x86/include/asm/vmware.h
@@ -253,12 +253,6 @@ unsigned long vmware_hypercall7(unsigned long cmd, 
unsigned long in1,
        return out0;
 }
 
-#ifdef CONFIG_X86_64
-#define VMW_BP_CONSTRAINT "r"
-#else
-#define VMW_BP_CONSTRAINT "m"
-#endif
-
 /*
  * High bandwidth calls are not supported on encrypted memory guests.
  * The caller should check cc_platform_has(CC_ATTR_MEM_ENCRYPT) and use
@@ -266,66 +260,14 @@ unsigned long vmware_hypercall7(unsigned long cmd, 
unsigned long in1,
  * This assumption simplifies HB hypercall implementation to just I/O port
  * based approach without alternative patching.
  */
-static inline
 unsigned long vmware_hypercall_hb_out(unsigned long cmd, unsigned long in2,
                                      unsigned long in3, unsigned long in4,
                                      unsigned long in5, unsigned long in6,
-                                     u32 *out1)
-{
-       unsigned long out0;
-
-       asm_inline volatile (
-               UNWIND_HINT_SAVE
-               "mov %[in6], %%" _ASM_AX "\n\t"
-               "push %%" _ASM_BP "\n\t"
-               UNWIND_HINT_UNDEFINED
-               "mov %%" _ASM_AX ", %%" _ASM_BP "\n\t"
-               "mov %[magic], %%eax\n\t"
-               "rep outsb\n\t"
-               "pop %%" _ASM_BP "\n\t"
-               UNWIND_HINT_RESTORE
-               : "=&a" (out0), "=b" (*out1)
-               : "b" (cmd),
-                 "c" (in2),
-                 "d" (in3 | VMWARE_HYPERVISOR_PORT_HB),
-                 "S" (in4),
-                 "D" (in5),
-                 [in6] VMW_BP_CONSTRAINT(in6),
-                 [magic] "i" (VMWARE_HYPERVISOR_MAGIC)
-               : "cc", "memory");
-       return out0;
-}
-
-static inline
+                                     u32 *out1);
 unsigned long vmware_hypercall_hb_in(unsigned long cmd, unsigned long in2,
                                     unsigned long in3, unsigned long in4,
                                     unsigned long in5, unsigned long in6,
-                                    u32 *out1)
-{
-       unsigned long out0;
-
-       asm_inline volatile (
-               UNWIND_HINT_SAVE
-               "mov %[in6], %%" _ASM_AX "\n\t"
-               "push %%" _ASM_BP "\n\t"
-               UNWIND_HINT_UNDEFINED
-               "mov %%" _ASM_AX ", %%" _ASM_BP "\n\t"
-               "mov %[magic], %%eax\n\t"
-               "rep insb\n\t"
-               "pop %%" _ASM_BP "\n\t"
-               UNWIND_HINT_RESTORE
-               : "=&a" (out0), "=b" (*out1)
-               : "b" (cmd),
-                 "c" (in2),
-                 "d" (in3 | VMWARE_HYPERVISOR_PORT_HB),
-                 "S" (in4),
-                 "D" (in5),
-                 [in6] VMW_BP_CONSTRAINT(in6),
-                 [magic] "i" (VMWARE_HYPERVISOR_MAGIC)
-               : "cc", "memory");
-       return out0;
-}
-#undef VMW_BP_CONSTRAINT
+                                    u32 *out1);
 #undef VMWARE_HYPERCALL
 
 #endif
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index f7ab9e7902cf..7cfc894f0663 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -30,12 +30,14 @@
 #include <linux/reboot.h>
 #include <linux/static_call.h>
 #include <linux/sched/cputime.h>
+#include <asm/asm.h>
 #include <asm/div64.h>
 #include <asm/x86_init.h>
 #include <asm/hypervisor.h>
 #include <asm/cpuid/api.h>
 #include <asm/timer.h>
 #include <asm/apic.h>
+#include <asm/unwind_hints.h>
 #include <asm/vmware.h>
 #include <asm/svm.h>
 
@@ -67,6 +69,72 @@ struct vmware_steal_time {
 static unsigned long vmware_tsc_khz __ro_after_init;
 static u8 vmware_hypercall_mode     __ro_after_init;
 
+#ifdef CONFIG_X86_64
+#define VMW_BP_CONSTRAINT "r"
+#else
+#define VMW_BP_CONSTRAINT "m"
+#endif
+
+unsigned long vmware_hypercall_hb_out(unsigned long cmd, unsigned long in2,
+                                     unsigned long in3, unsigned long in4,
+                                     unsigned long in5, unsigned long in6,
+                                     u32 *out1)
+{
+       unsigned long out0;
+
+       asm volatile(UNWIND_HINT_SAVE
+               "mov %[in6], %%" _ASM_AX "\n\t"
+               "push %%" _ASM_BP "\n\t"
+               UNWIND_HINT_UNDEFINED
+               "mov %%" _ASM_AX ", %%" _ASM_BP "\n\t"
+               "mov %[magic], %%eax\n\t"
+               "rep outsb\n\t"
+               "pop %%" _ASM_BP "\n\t"
+               UNWIND_HINT_RESTORE
+               : "=&a" (out0), "=b" (*out1)
+               : "b" (cmd),
+                 "c" (in2),
+                 "d" (in3 | VMWARE_HYPERVISOR_PORT_HB),
+                 "S" (in4),
+                 "D" (in5),
+                 [in6] VMW_BP_CONSTRAINT(in6),
+                 [magic] "i" (VMWARE_HYPERVISOR_MAGIC)
+               : "cc", "memory");
+       return out0;
+}
+EXPORT_SYMBOL_GPL(vmware_hypercall_hb_out);
+
+unsigned long vmware_hypercall_hb_in(unsigned long cmd, unsigned long in2,
+                                    unsigned long in3, unsigned long in4,
+                                    unsigned long in5, unsigned long in6,
+                                    u32 *out1)
+{
+       unsigned long out0;
+
+       asm volatile(UNWIND_HINT_SAVE
+               "mov %[in6], %%" _ASM_AX "\n\t"
+               "push %%" _ASM_BP "\n\t"
+               UNWIND_HINT_UNDEFINED
+               "mov %%" _ASM_AX ", %%" _ASM_BP "\n\t"
+               "mov %[magic], %%eax\n\t"
+               "rep insb\n\t"
+               "pop %%" _ASM_BP "\n\t"
+               UNWIND_HINT_RESTORE
+               : "=&a" (out0), "=b" (*out1)
+               : "b" (cmd),
+                 "c" (in2),
+                 "d" (in3 | VMWARE_HYPERVISOR_PORT_HB),
+                 "S" (in4),
+                 "D" (in5),
+                 [in6] VMW_BP_CONSTRAINT(in6),
+                 [magic] "i" (VMWARE_HYPERVISOR_MAGIC)
+               : "cc", "memory");
+       return out0;
+}
+EXPORT_SYMBOL_GPL(vmware_hypercall_hb_in);
+
+#undef VMW_BP_CONSTRAINT
+
 unsigned long vmware_hypercall_slow(unsigned long cmd,
                                    unsigned long in1, unsigned long in3,
                                    unsigned long in4, unsigned long in5,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
index fd77ab6568cb..20ab4019680c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -24,7 +24,6 @@
  *
  */
 
-#include <linux/objtool.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -289,7 +288,6 @@ static int vmw_send_msg(struct rpc_channel *channel, const 
char *msg)
 
        return -EINVAL;
 }
-STACK_FRAME_NON_STANDARD_FP(vmw_send_msg);
 
 
 /**
@@ -384,7 +382,6 @@ static int vmw_recv_msg(struct rpc_channel *channel, void 
**msg,
 
        return 0;
 }
-STACK_FRAME_NON_STANDARD(vmw_recv_msg);
 
 
 /**

Reply via email to