From owner-svn-src-head@freebsd.org Fri Dec 15 04:11:21 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D5F12E99A25; Fri, 15 Dec 2017 04:11:21 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AE99365BB1; Fri, 15 Dec 2017 04:11:21 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBF4BKIq065171; Fri, 15 Dec 2017 04:11:20 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBF4BK7Y065169; Fri, 15 Dec 2017 04:11:20 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201712150411.vBF4BK7Y065169@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Fri, 15 Dec 2017 04:11:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326870 - in head/sys/powerpc: include powerpc X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: in head/sys/powerpc: include powerpc X-SVN-Commit-Revision: 326870 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Dec 2017 04:11:21 -0000 Author: jhibbits Date: Fri Dec 15 04:11:20 2017 New Revision: 326870 URL: https://svnweb.freebsd.org/changeset/base/326870 Log: Handle the Facility Unavailable exception as a SIGILL Currently Facility Unavailable is absent and once an application tries to use or access a register from a feature disabled in the CPU it causes a kernel panic. A simple test-case is: int main() { asm volatile ("tbegin.;"); } which will use TM (Hardware Transactional Memory) feature which is not supported by the kernel and so will trigger the following kernel panic: ---- fatal user trap: exception = 0xf60 (unknown) srr0 = 0x10000890 srr1 = 0x800000000000f032 lr = 0x100004e4 curthread = 0x5f93000 pid = 1021, comm = htm panic: unknown trap cpuid = 40 KDB: stack backtrace: Uptime: 3m18s Dumping 10 MB (3 chunks) chunk 0: 11MB (2648 pages) ... ok chunk 1: 1MB (24 pages) ... ok chunk 2: 1MB (2 pages)panic: IOMMU mapping error: -4 cpuid = 40 Uptime: 3m18s ---- Since Hardware Transactional Memory is not yet supported by FreeBSD, treat this as an illegal instruction. PR: 224350 Submitted by: Gustavo Romero MFC after: 2 weeks Modified: head/sys/powerpc/include/trap.h head/sys/powerpc/powerpc/trap.c Modified: head/sys/powerpc/include/trap.h ============================================================================== --- head/sys/powerpc/include/trap.h Fri Dec 15 03:46:52 2017 (r326869) +++ head/sys/powerpc/include/trap.h Fri Dec 15 04:11:20 2017 (r326870) @@ -80,6 +80,9 @@ #define EXC_HEA 0x0e40 /* Hypervisor Emulation Assistance */ #define EXC_VSX 0x0f40 /* VSX Unavailable */ +/* Power ISA 2.07+: */ +#define EXC_FAC 0x0f60 /* Facility Unavailable */ + /* The following are available on 4xx and 85xx */ #define EXC_CRIT 0x0100 /* Critical Input Interrupt */ #define EXC_PIT 0x1000 /* Programmable Interval Timer */ Modified: head/sys/powerpc/powerpc/trap.c ============================================================================== --- head/sys/powerpc/powerpc/trap.c Fri Dec 15 03:46:52 2017 (r326869) +++ head/sys/powerpc/powerpc/trap.c Fri Dec 15 04:11:20 2017 (r326870) @@ -135,6 +135,7 @@ static struct powerpc_exception powerpc_exceptions[] = { EXC_PERF, "performance monitoring" }, { EXC_VEC, "altivec unavailable" }, { EXC_VSX, "vsx unavailable" }, + { EXC_FAC, "facility unavailable" }, { EXC_ITMISS, "instruction tlb miss" }, { EXC_DLMISS, "data load tlb miss" }, { EXC_DSMISS, "data store tlb miss" }, @@ -277,6 +278,11 @@ trap(struct trapframe *frame) save_fpu(td); td->td_pcb->pcb_flags |= PCB_VSX; enable_fpu(td); + break; + + case EXC_FAC: + sig = SIGILL; + ucode = ILL_ILLOPC; break; case EXC_VECAST_E: