[PATCH] x86: tdx: hide unused tdx_dump_mce_info()

From: Arnd Bergmann
Date: Tue Dec 12 2023 - 16:37:14 EST


From: Arnd Bergmann <arnd@xxxxxxxx>

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
>>> 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")
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
arch/x86/virt/vmx/tdx/tdx.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
index 13df68ef40b5..3af7a7e2d8d0 100644
--- a/arch/x86/virt/vmx/tdx/tdx.c
+++ b/arch/x86/virt/vmx/tdx/tdx.c
@@ -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)
--
2.39.2