Re: [PATCH 6.6.y] x86/tdx: Fix arch_safe_halt() execution for TDX VMs

Sasha Levin
2025-04-10T15:55:06Z

[ Sasha's backport helper bot ]

Hi,

Summary of potential issues:
⚠️ Found matching upstream commit but patch is missing proper reference to it

Found matching upstream commit: 9f98a4f4e7216dbe366010b4cdcab6b220f229c4

Status in newer kernel trees:
6.14.y | Present (different SHA1: 8defd0d8678b)
6.13.y | Present (different SHA1: f88759f8f742)
6.12.y | Present (different SHA1: 7aff5ffe2c87)

Note: The patch differs from the upstream commit:
---
1: 9f98a4f4e7216 ! 1: 882c95e29bbba x86/tdx: Fix arch_safe_halt() execution for TDX VMs
@@ Commit message
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250228014416.3925664-3-vannapurve@google.com
+ (cherry picked from commit 9f98a4f4e7216dbe366010b4cdcab6b220f229c4)

## arch/x86/Kconfig ##
@@ arch/x86/Kconfig: config INTEL_TDX_GUEST
@@ arch/x86/coco/tdx/tdx.c
#include <asm/insn-eval.h>
+#include <asm/paravirt_types.h>
#include <asm/pgtable.h>
- #include <asm/set_memory.h>
#include <asm/traps.h>
+
@@ arch/x86/coco/tdx/tdx.c: static int handle_halt(struct ve_info *ve)
return ve_instr_len(ve);
}
@@ arch/x86/coco/tdx/tdx.c: void __cpuidle tdx_safe_halt(void)
+
static int read_msr(struct pt_regs *regs, struct ve_info *ve)
{
- struct tdx_module_args args = {
+ struct tdx_hypercall_args args = {
@@ arch/x86/coco/tdx/tdx.c: void __init tdx_early_init(void)
- x86_platform.guest.enc_kexec_begin = tdx_kexec_begin;
- x86_platform.guest.enc_kexec_finish = tdx_kexec_finish;
+ x86_platform.guest.enc_cache_flush_required = tdx_cache_flush_required;
+ x86_platform.guest.enc_tlb_flush_required = tdx_tlb_flush_required;

+ /*
+ * Avoid "sti;hlt" execution in TDX guests as HLT induces a #VE that
@@ arch/x86/include/asm/tdx.h: void tdx_get_ve_info(struct ve_info *ve);

bool tdx_early_handle_ve(struct pt_regs *regs);

-@@ arch/x86/include/asm/tdx.h: void __init tdx_dump_td_ctls(u64 td_ctls);
+@@ arch/x86/include/asm/tdx.h: int tdx_mcall_get_report0(u8 *reportdata, u8 *tdreport);
#else

static inline void tdx_early_init(void) { };
@@ arch/x86/include/asm/tdx.h: void __init tdx_dump_td_ctls(u64 td_ctls);

## arch/x86/kernel/process.c ##
-@@ arch/x86/kernel/process.c: void __init select_idle_routine(void)
+@@ arch/x86/kernel/process.c: void select_idle_routine(const struct cpuinfo_x86 *c)
static_call_update(x86_idle, mwait_idle);
} else if (cpu_feature_enabled(X86_FEATURE_TDX_GUEST)) {
pr_info("using TDX aware idle routine\n");
- static_call_update(x86_idle, tdx_safe_halt);
+ static_call_update(x86_idle, tdx_halt);
- } else {
+ } else
static_call_update(x86_idle, default_idle);
- }
+ }
---

Results of testing on various branches:

| Branch | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.6.y | Success | Success |