x86/xen: Make save_fl() noinstr
authorPeter Zijlstra <peterz@infradead.org>
Thu, 24 Jun 2021 09:41:17 +0000 (11:41 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 17 Sep 2021 11:14:44 +0000 (13:14 +0200)
vmlinux.o: warning: objtool: pv_ops[30]: native_save_fl
vmlinux.o: warning: objtool: pv_ops[30]: __raw_callee_save_xen_save_fl
vmlinux.o: warning: objtool: pv_ops[30]: xen_save_fl_direct
vmlinux.o: warning: objtool: lockdep_hardirqs_off()+0x73: call to pv_ops[30]() leaves .noinstr.text section

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20210624095148.749712274@infradead.org
arch/x86/include/asm/paravirt.h
arch/x86/kernel/irqflags.S
arch/x86/xen/irq.c
arch/x86/xen/xen-asm.S

index 34da790ac429ef30ea6cc87a92704f3717e06546..cebec95a7124fdc245838e9081492533cb7e483e 100644 (file)
@@ -653,10 +653,10 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
  * functions.
  */
 #define PV_THUNK_NAME(func) "__raw_callee_save_" #func
-#define PV_CALLEE_SAVE_REGS_THUNK(func)                                        \
+#define __PV_CALLEE_SAVE_REGS_THUNK(func, section)                     \
        extern typeof(func) __raw_callee_save_##func;                   \
                                                                        \
-       asm(".pushsection .text;"                                       \
+       asm(".pushsection " section ", \"ax\";"                         \
            ".globl " PV_THUNK_NAME(func) ";"                           \
            ".type " PV_THUNK_NAME(func) ", @function;"                 \
            PV_THUNK_NAME(func) ":"                                     \
@@ -669,6 +669,9 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
            ".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \
            ".popsection")
 
+#define PV_CALLEE_SAVE_REGS_THUNK(func)                        \
+       __PV_CALLEE_SAVE_REGS_THUNK(func, ".text")
+
 /* Get a reference to a callee-save function */
 #define PV_CALLEE_SAVE(func)                                           \
        ((struct paravirt_callee_save) { __raw_callee_save_##func })
index 8ef35063964b1f543ee8bd4b3d8869a40cfa4d1a..760e1f293093f9b3573e74b84ead5f822990cbc7 100644 (file)
@@ -7,9 +7,11 @@
 /*
  * unsigned long native_save_fl(void)
  */
+.pushsection .noinstr.text, "ax"
 SYM_FUNC_START(native_save_fl)
        pushf
        pop %_ASM_AX
        ret
 SYM_FUNC_END(native_save_fl)
+.popsection
 EXPORT_SYMBOL(native_save_fl)
index dfa091d79c2e111aba1ba5947177be4230471867..9c71f43ba30324219830fa26c5ca674a882fa121 100644 (file)
@@ -24,7 +24,7 @@ void xen_force_evtchn_callback(void)
        (void)HYPERVISOR_xen_version(0, NULL);
 }
 
-asmlinkage __visible unsigned long xen_save_fl(void)
+asmlinkage __visible noinstr unsigned long xen_save_fl(void)
 {
        struct vcpu_info *vcpu;
        unsigned long flags;
@@ -40,7 +40,7 @@ asmlinkage __visible unsigned long xen_save_fl(void)
        */
        return (-flags) & X86_EFLAGS_IF;
 }
-PV_CALLEE_SAVE_REGS_THUNK(xen_save_fl);
+__PV_CALLEE_SAVE_REGS_THUNK(xen_save_fl, ".noinstr.text");
 
 asmlinkage __visible void xen_irq_disable(void)
 {
index aef4a1e8f33f760bfd621efeb8db6031445135b2..0883e39fee2e7755c284e1a350249a3b9ef93ce0 100644 (file)
@@ -57,22 +57,6 @@ SYM_FUNC_START(xen_irq_disable_direct)
        ret
 SYM_FUNC_END(xen_irq_disable_direct)
 
-/*
- * (xen_)save_fl is used to get the current interrupt enable status.
- * Callers expect the status to be in X86_EFLAGS_IF, and other bits
- * may be set in the return value.  We take advantage of this by
- * making sure that X86_EFLAGS_IF has the right value (and other bits
- * in that byte are 0), but other bits in the return value are
- * undefined.  We need to toggle the state of the bit, because Xen and
- * x86 use opposite senses (mask vs enable).
- */
-SYM_FUNC_START(xen_save_fl_direct)
-       testb $0xff, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask
-       setz %ah
-       addb %ah, %ah
-       ret
-SYM_FUNC_END(xen_save_fl_direct)
-
 /*
  * Force an event check by making a hypercall, but preserve regs
  * before making the call.
@@ -103,6 +87,22 @@ SYM_FUNC_START(check_events)
 SYM_FUNC_END(check_events)
 
 .pushsection .noinstr.text, "ax"
+/*
+ * (xen_)save_fl is used to get the current interrupt enable status.
+ * Callers expect the status to be in X86_EFLAGS_IF, and other bits
+ * may be set in the return value.  We take advantage of this by
+ * making sure that X86_EFLAGS_IF has the right value (and other bits
+ * in that byte are 0), but other bits in the return value are
+ * undefined.  We need to toggle the state of the bit, because Xen and
+ * x86 use opposite senses (mask vs enable).
+ */
+SYM_FUNC_START(xen_save_fl_direct)
+       testb $0xff, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_mask
+       setz %ah
+       addb %ah, %ah
+       ret
+SYM_FUNC_END(xen_save_fl_direct)
+
 SYM_FUNC_START(xen_read_cr2)
        FRAME_BEGIN
        _ASM_MOV PER_CPU_VAR(xen_vcpu), %_ASM_AX