Skip to contentSkip to conversation

x86: tdx: hide unused tdx_dump_mce_info()

PATCH In review Arnd Bergmann 5 participants 9 messages Dec 12, 2023 – Dec 13, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: tdx: hide unused tdx_dump_mce_info()

From: Arnd Bergmann <[email protected]>

When TDX is enabled but MCE is not, the tdx_dump_mce_info() function fails to link:

ld.lld: error: undefined symbol: mce_is_memory_error ld.lld: error: undefined symbol: mce_usable_address

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by usercopy_64.c
vmlinux.o:(tdx_dump_mce_info)

In this configuration, there is also no caller for the function, so avoid the problem by enclosing it in an #ifdef block.

Fixes 45f31973967d ("x86/mce: Differentiate real hardware #MCs from TDX erratum ones")
---
 arch/x86/virt/vmx/tdx/tdx.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/virt/vmx/tdx/tdx.c +2 -0
index 13df68ef40b5..3af7a7e2d8d0 100644
@@ -1245,6 +1245,7 @@ int tdx_enable(void)
 }
 EXPORT_SYMBOL_GPL(tdx_enable);
 
+#ifdef CONFIG_X86_MCE
 static bool is_pamt_page(unsigned long phys)
 {
 	struct tdmr_info_list *tdmr_list = &tdx_tdmr_list;
@@ -1344,6 +1345,7 @@ const char *tdx_dump_mce_info(struct mce *m)
 
 	return "TDX private memory error. Possible kernel bug.";
 }
+#endif
 
 static __init int record_keyid_partitioning(u32 *tdx_keyid_start,
 					    u32 *nr_tdx_keyids)
Signature · 1 line
2.39.2
#1 lore raw
Quoted 4 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When TDX is enabled but MCE is not, the tdx_dump_mce_info() function fails to link:

Thanks for the report, Arnd.

The only way that TDX has to report integrity errors is an MCE. I'm not sure it even makes sense to have TDX support but not MCE support. Maybe we should just make TDX host support depend on MCE.

maintainer
#2 lore raw
Quoted 11 lines · Dave Hansen
Quoted 4 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When TDX is enabled but MCE is not, the tdx_dump_mce_info() function fails to link:

Thanks for the report, Arnd.

The only way that TDX has to report integrity errors is an MCE. I'm not sure it even makes sense to have TDX support but not MCE support. Maybe we should just make TDX host support depend on MCE.

... or provide an empty stub of tdx_dump_mce_info() for the !CONFIG_X86_MCE case.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#3 lore raw
In reply to Dave Hansen
Quoted 11 lines · Dave Hansen
Quoted 4 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When TDX is enabled but MCE is not, the tdx_dump_mce_info() function fails to link:

Thanks for the report, Arnd.

The only way that TDX has to report integrity errors is an MCE. I'm not sure it even makes sense to have TDX support but not MCE support. Maybe we should just make TDX host support depend on MCE.

I agree. Silently ignore integrity errors is not good idea.

TDX module spec also supports it:

"The machine-check exception handler is expected to be implemented in the VMM."

Signature · 1 line
  Kiryl Shutsemau / Kirill A. Shutemov
#4 lore raw
Quoted 13 lines · Kirill A. Shutemov
Quoted 11 lines · Dave Hansen
Quoted 4 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When TDX is enabled but MCE is not, the tdx_dump_mce_info() function fails to link:

Thanks for the report, Arnd.

The only way that TDX has to report integrity errors is an MCE. I'm not sure it even makes sense to have TDX support but not MCE support. Maybe we should just make TDX host support depend on MCE.

Quoted 6 lines

I agree. Silently ignore integrity errors is not good idea.

TDX module spec also supports it:

"The machine-check exception handler is expected to be implemented in the VMM."

I also agree. Thanks.

#5 lore raw
Quoted 3 lines · Kai
Quoted 2 lines

"The machine-check exception handler is expected to be implemented in the VMM."

I also agree. Thanks.

Kai, could you please send a patch to fix this build problem that Arnd reported?

#6 lore raw
Quoted 7 lines · Dave Hansen
Quoted 3 lines · Kai
Quoted 2 lines

"The machine-check exception handler is expected to be implemented in the VMM."

I also agree. Thanks.

Kai, could you please send a patch to fix this build problem that Arnd reported?

Yeah will do asap.

#7 lore raw
In reply to Dave Hansen
Quoted 7 lines · Dave Hansen
Quoted 3 lines · Kai
Quoted 2 lines

"The machine-check exception handler is expected to be implemented in the VMM."

I also agree. Thanks.

Kai, could you please send a patch to fix this build problem that Arnd reported?

Turns out INTEL_TDX_GUEST selects X86_MCE, I think we can also just select X86_MCE for TDX host?

config INTEL_TDX_GUEST

        bool "Intel TDX (Trust Domain Extensions) - Guest Support"
        depends on X86_64 && CPU_SUP_INTEL
	...
        select X86_MCE
#8 lore raw
Quoted 9 lines · Kai
Quoted 7 lines · Dave Hansen
Quoted 3 lines · Kai
Quoted 2 lines

"The machine-check exception handler is expected to be implemented in the VMM."

I also agree. Thanks.

Kai, could you please send a patch to fix this build problem that Arnd reported?

Quoted 9 lines

Turns out INTEL_TDX_GUEST selects X86_MCE, I think we can also just select X86_MCE for TDX host?

config INTEL_TDX_GUEST

        bool "Intel TDX (Trust Domain Extensions) - Guest Support"
        depends on X86_64 && CPU_SUP_INTEL
	...
        select X86_MCE

Turns out we have to use 'depend on' but not 'select' because with the latter I got "mm/Kconfig:772:error: recursive dependency detected!".

I just sent out the fixing patch. I did kernel built of multiple combinations of TDX_GUEST/TDX_HOST/X86_MCE in the Kconfig, and they all passed.