cpuidle, tdx: Make TDX code noinstr clean
authorPeter Zijlstra <peterz@infradead.org>
Thu, 12 Jan 2023 19:43:43 +0000 (20:43 +0100)
committerIngo Molnar <mingo@kernel.org>
Fri, 13 Jan 2023 10:48:16 +0000 (11:48 +0100)
objtool found a few cases where this code called out into instrumented
code:

  vmlinux.o: warning: objtool: __halt+0x2c: call to hcall_func.constprop.0() leaves .noinstr.text section
  vmlinux.o: warning: objtool: __halt+0x3f: call to __tdx_hypercall() leaves .noinstr.text section
  vmlinux.o: warning: objtool: __tdx_hypercall+0x66: call to __tdx_hypercall_failed() leaves .noinstr.text section

Fix it by:

  - moving TDX tdcall assembly methods into .noinstr.text (they are already noistr-clean)
  - marking __tdx_hypercall_failed() as 'noinstr'
  - annotating hcall_func() as __always_inline

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/20230112195541.111485720@infradead.org
arch/x86/boot/compressed/vmlinux.lds.S
arch/x86/coco/tdx/tdcall.S
arch/x86/coco/tdx/tdx.c

index 112b2375d021bb190fb6491bf05a41f52c2ea4fe..b22f34b8684a725b92c2b044f1a4efbbff959773 100644 (file)
@@ -34,6 +34,7 @@ SECTIONS
                _text = .;      /* Text */
                *(.text)
                *(.text.*)
+               *(.noinstr.text)
                _etext = . ;
        }
        .rodata : {
index 508c17332e2ecb4323321f7fb40bcc4e37a61777..ad0d51f03cb408eb407deef9db665cda0662550a 100644 (file)
@@ -31,6 +31,8 @@
                                          TDX_R12 | TDX_R13 | \
                                          TDX_R14 | TDX_R15 )
 
+.section .noinstr.text, "ax"
+
 /*
  * __tdx_module_call()  - Used by TDX guests to request services from
  * the TDX module (does not include VMM services) using TDCALL instruction.
index 8804174aef1a22f9101daeae267c6f907d1ddeaf..70e80157926a2b93b5a70669269515d53f496af3 100644 (file)
@@ -64,8 +64,9 @@ static inline u64 _tdx_hypercall(u64 fn, u64 r12, u64 r13, u64 r14, u64 r15)
 }
 
 /* Called from __tdx_hypercall() for unrecoverable failure */
-void __tdx_hypercall_failed(void)
+noinstr void __tdx_hypercall_failed(void)
 {
+       instrumentation_begin();
        panic("TDVMCALL failed. TDX module bug?");
 }
 
@@ -75,7 +76,7 @@ void __tdx_hypercall_failed(void)
  * Reusing the KVM EXIT_REASON macros makes it easier to connect the host and
  * guest sides of these calls.
  */
-static u64 hcall_func(u64 exit_reason)
+static __always_inline u64 hcall_func(u64 exit_reason)
 {
        return exit_reason;
 }