From 0b663e0cee89dedf5b070ff4e839d5ad95061535 Mon Sep 17 00:00:00 2001 From: Justin Hibbits Date: Wed, 19 Mar 2025 18:22:32 -0400 Subject: [PATCH] powerpc: Add Hypervisor Facility Unavailable handling Treat Hypervisor Facility Unavailable as an illegal instruction in user space. This way programs that use facilities like transactional memory, which will never be supported as it has been removed from the ISA, will not crash the kernel. Tested by: pkubaj MFC after: 1 week --- sys/powerpc/aim/aim_machdep.c | 1 + sys/powerpc/powerpc/trap.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/sys/powerpc/aim/aim_machdep.c b/sys/powerpc/aim/aim_machdep.c index b439905441d..814c679ff47 100644 --- a/sys/powerpc/aim/aim_machdep.c +++ b/sys/powerpc/aim/aim_machdep.c @@ -417,6 +417,7 @@ aim_cpu_init(vm_offset_t toc) bcopy(&hypertrapcode, (void *)(EXC_HEA + trap_offset), trapsize); bcopy(&hypertrapcode, (void *)(EXC_HMI + trap_offset), trapsize); bcopy(&hypertrapcode, (void *)(EXC_HVI + trap_offset), trapsize); + bcopy(&hypertrapcode, (void *)(EXC_HFAC + trap_offset), trapsize); bcopy(&hypertrapcode, (void *)(EXC_SOFT_PATCH + trap_offset), trapsize); #endif diff --git a/sys/powerpc/powerpc/trap.c b/sys/powerpc/powerpc/trap.c index ab3e5687516..d919b771566 100644 --- a/sys/powerpc/powerpc/trap.c +++ b/sys/powerpc/powerpc/trap.c @@ -138,6 +138,7 @@ static struct powerpc_exception powerpc_exceptions[] = { { EXC_VEC, "altivec unavailable" }, { EXC_VSX, "vsx unavailable" }, { EXC_FAC, "facility unavailable" }, + { EXC_HFAC, "hypervisor facility unavailable" }, { EXC_ITMISS, "instruction tlb miss" }, { EXC_DLMISS, "data load tlb miss" }, { EXC_DSMISS, "data store tlb miss" }, @@ -147,6 +148,7 @@ static struct powerpc_exception powerpc_exceptions[] = { { EXC_THRM, "thermal management" }, { EXC_RUNMODETRC, "run mode/trace" }, { EXC_SOFT_PATCH, "soft patch exception" }, + { EXC_HVI, "hypervisor virtualization" }, { EXC_LAST, NULL } }; @@ -351,6 +353,7 @@ trap(struct trapframe *frame) mtspr(SPR_FSCR, fscr & ~FSCR_IC_MASK); break; case EXC_HEA: + case EXC_HFAC: sig = SIGILL; ucode = ILL_ILLOPC; break;