[PATCH] x86/mce: don't call an unregistered address check

Stefano Stabellini posted 1 patch 3 weeks, 6 days ago
xen/arch/x86/cpu/mcheck/mcaction.c | 3 ++-
xen/arch/x86/cpu/mcheck/mce.c      | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
[PATCH] x86/mce: don't call an unregistered address check
Posted by Stefano Stabellini 3 weeks, 6 days ago
Family 0Fh registers no check_addr callback, yet mca_init_bank() and
mc_memerr_dhandler() call it unconditionally.  With altcall the NULL
pointer is patched to ud2, so on such a CPU the first bank reporting a
valid address traps inside the machine check path.

Treat a missing callback as the address not being physical.  The
recoverable_scan callback, also not registered on family 0Fh, is
already guarded through "recover".

Fixes: 9595ef77ab11 ("Implement page offline recovery action for AMD")
Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
---
 xen/arch/x86/cpu/mcheck/mcaction.c | 3 ++-
 xen/arch/x86/cpu/mcheck/mce.c      | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu/mcheck/mcaction.c b/xen/arch/x86/cpu/mcheck/mcaction.c
index bf7a0de965..96febefd0c 100644
--- a/xen/arch/x86/cpu/mcheck/mcaction.c
+++ b/xen/arch/x86/cpu/mcheck/mcaction.c
@@ -41,7 +41,8 @@ mc_memerr_dhandler(struct mca_binfo *binfo,
     int vmce_vcpuid;
     unsigned int mc_vcpuid;
 
-    if ( !alternative_call(mce_callbacks.check_addr, bank->mc_status,
+    if ( !mce_callbacks.check_addr ||
+         !alternative_call(mce_callbacks.check_addr, bank->mc_status,
                            bank->mc_misc, MC_ADDR_PHYSICAL) )
     {
         dprintk(XENLOG_WARNING,
diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c
index 1888f22d15..8c984c61d2 100644
--- a/xen/arch/x86/cpu/mcheck/mce.c
+++ b/xen/arch/x86/cpu/mcheck/mce.c
@@ -192,6 +192,7 @@ static void mca_init_bank(enum mca_source who, struct mc_info *mi, int bank)
 
     if ( (mib->mc_status & MCi_STATUS_MISCV) &&
          (mib->mc_status & MCi_STATUS_ADDRV) &&
+         mce_callbacks.check_addr &&
          alternative_call(mce_callbacks.check_addr, mib->mc_status,
                           mib->mc_misc, MC_ADDR_PHYSICAL) &&
          (who == MCA_POLLER || who == MCA_CMCI_HANDLER) &&
-- 
2.47.3
Re: [PATCH] x86/mce: don't call an unregistered address check
Posted by Jan Beulich 3 weeks, 6 days ago
On 27.10.2026 01:48, Stefano Stabellini wrote:
> Family 0Fh registers no check_addr callback, yet mca_init_bank() and
> mc_memerr_dhandler() call it unconditionally.  With altcall the NULL
> pointer is patched to ud2, so on such a CPU the first bank reporting a
> valid address traps inside the machine check path.
> 
> Treat a missing callback as the address not being physical.  The
> recoverable_scan callback, also not registered on family 0Fh, is
> already guarded through "recover".

With this mentioned, perhaps also mention .info_collect?

> Fixes: 9595ef77ab11 ("Implement page offline recovery action for AMD")
> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan