On Fri, May 17, 2024 at 05:00:19PM +0200, Jürgen Groß wrote: > On 17.05.24 16:53, Kirill A. Shutemov wrote: > > On Fri, May 17, 2024 at 04:37:16PM +0200, Juergen Gross wrote: > > > On 17.05.24 16:32, Kirill A. Shutemov wrote: > > > > On Mon, Feb 26, 2024 at 12:25:41AM -0800, isaku.yamahata@xxxxxxxxx wrote: > > > > > @@ -725,6 +967,17 @@ static int __init tdx_module_setup(void) > > > > > tdx_info->nr_tdcs_pages = tdcs_base_size / PAGE_SIZE; > > > > > + /* > > > > > + * Make TDH.VP.ENTER preserve RBP so that the stack unwinder > > > > > + * always work around it. Query the feature. > > > > > + */ > > > > > + if (!(tdx_info->features0 & MD_FIELD_ID_FEATURES0_NO_RBP_MOD) && > > > > > + !IS_ENABLED(CONFIG_FRAME_POINTER)) { > > > > > > > > I think it supposed to be IS_ENABLED(CONFIG_FRAME_POINTER). "!" shouldn't > > > > be here. > > > > > > No, I don't think so. > > > > > > With CONFIG_FRAME_POINTER %rbp is being saved and restored, so there is no > > > problem in case the seamcall is clobbering it. > > > > Could you check setup_tdparams() in your tree? > > > > Commit > > > > [SEAM-WORKAROUND] KVM: TDX: Don't use NO_RBP_MOD for backward compatibility > > > > in my tree comments out the setting TDX_CONTROL_FLAG_NO_RBP_MOD. > > > > I now remember there was problem in EDK2 using RBP. So the patch is > > temporary until EDK2 is fixed. > > > > I have the following line in setup_tdparams() (not commented out): > > td_params->exec_controls = TDX_CONTROL_FLAG_NO_RBP_MOD; Could you check if it is visible from the guest side? It is zero for me. diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index c1cb90369915..f65993a6066d 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -822,13 +822,33 @@ static bool tdx_enc_status_change_finish(unsigned long vaddr, int numpages, return true; } +#define TDG_VM_RD 7 + +#define TDCS_CONFIG_FLAGS 0x1110000300000016 + +#define TDCS_CONFIG_NO_RBP_MOD BIT_ULL(2) + +/* Read TD-scoped metadata */ +static inline u64 tdg_vm_rd(u64 field, u64 *value) +{ + struct tdx_module_args args = { + .rdx = field, + }; + u64 ret; + + ret = __tdcall_ret(TDG_VM_RD, &args); + *value = args.r8; + + return ret; +} + void __init tdx_early_init(void) { struct tdx_module_args args = { .rdx = TDCS_NOTIFY_ENABLES, .r9 = -1ULL, }; - u64 cc_mask; + u64 cc_mask, config; u32 eax, sig[3]; cpuid_count(TDX_CPUID_LEAF_ID, 0, &eax, &sig[0], &sig[2], &sig[1]); @@ -893,4 +913,7 @@ void __init tdx_early_init(void) x86_cpuinit.parallel_bringup = false; pr_info("Guest detected\n"); + + tdg_vm_rd(TDCS_CONFIG_FLAGS, &config); + printk("NO_RBP_MOD: %#llx\n", config & TDCS_CONFIG_NO_RBP_MOD); } -- Kiryl Shutsemau / Kirill A. Shutemov