cpuidle, intel_idle: Fix CPUIDLE_FLAG_INIT_XSTATE
authorPeter Zijlstra <peterz@infradead.org>
Thu, 12 Jan 2023 19:43:33 +0000 (20:43 +0100)
committerIngo Molnar <mingo@kernel.org>
Fri, 13 Jan 2023 10:48:15 +0000 (11:48 +0100)
Fix instrumentation bugs objtool found:

  vmlinux.o: warning: objtool: intel_idle_s2idle+0xd5: call to fpu_idle_fpregs() leaves .noinstr.text section
  vmlinux.o: warning: objtool: intel_idle_xstate+0x11: call to fpu_idle_fpregs() leaves .noinstr.text section
  vmlinux.o: warning: objtool: fpu_idle_fpregs+0x9: call to xfeatures_in_use() leaves .noinstr.text section

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Tony Lindgren <tony@atomide.com>
Tested-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20230112195540.494977795@infradead.org
arch/x86/include/asm/fpu/xcr.h
arch/x86/include/asm/special_insns.h
arch/x86/kernel/fpu/core.c

index 9656a5bc6feae4b096c93fcdf1e26e806fa7b5d2..9a710c0604457a3d42926aa1bb5150e099782336 100644 (file)
@@ -5,7 +5,7 @@
 #define XCR_XFEATURE_ENABLED_MASK      0x00000000
 #define XCR_XFEATURE_IN_USE_MASK       0x00000001
 
-static inline u64 xgetbv(u32 index)
+static __always_inline u64 xgetbv(u32 index)
 {
        u32 eax, edx;
 
@@ -27,7 +27,7 @@ static inline void xsetbv(u32 index, u64 value)
  *
  * Callers should check X86_FEATURE_XGETBV1.
  */
-static inline u64 xfeatures_in_use(void)
+static __always_inline u64 xfeatures_in_use(void)
 {
        return xgetbv(XCR_XFEATURE_IN_USE_MASK);
 }
index 35f709f619fb4fc2278ddbe09c3ef72f20e1cfcb..c2e322189f853305482658d29c4c06c5fea55a25 100644 (file)
@@ -295,7 +295,7 @@ static inline int enqcmds(void __iomem *dst, const void *src)
        return 0;
 }
 
-static inline void tile_release(void)
+static __always_inline void tile_release(void)
 {
        /*
         * Instruction opcode for TILERELEASE; supported in binutils
index 9baa89a8877d01c3e9f6b883426131bbdb343aa6..dccce58201b7cf12e160818ed94bf6c163129963 100644 (file)
@@ -853,12 +853,12 @@ int fpu__exception_code(struct fpu *fpu, int trap_nr)
  * Initialize register state that may prevent from entering low-power idle.
  * This function will be invoked from the cpuidle driver only when needed.
  */
-void fpu_idle_fpregs(void)
+noinstr void fpu_idle_fpregs(void)
 {
        /* Note: AMX_TILE being enabled implies XGETBV1 support */
        if (cpu_feature_enabled(X86_FEATURE_AMX_TILE) &&
            (xfeatures_in_use() & XFEATURE_MASK_XTILE)) {
                tile_release();
-               fpregs_deactivate(&current->thread.fpu);
+               __this_cpu_write(fpu_fpregs_owner_ctx, NULL);
        }
 }