Bug 224350 - [PATCH] powerpc64: Add handler for Facility Unavailable
Summary: [PATCH] powerpc64: Add handler for Facility Unavailable
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: powerpc Any
: --- Affects Some People
Assignee: Justin Hibbits
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-12-14 22:29 UTC by Gustavo Romero
Modified: 2019-01-21 21:46 UTC (History)
3 users (show)

See Also:


Attachments
Patch for this bug (2.53 KB, patch)
2017-12-14 22:29 UTC, Gustavo Romero
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gustavo Romero 2017-12-14 22:29:28 UTC
Created attachment 188843 [details]
Patch for this bug

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:

#include <stdio.h>

int main() { asm volatile ("tbegin.;"); }

which will use TM (Hardware Transactional Memory) feature
which is not supported by the kernel and so I'll trigger
the following 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:
#0 0x59d1c8 at ??+0
#1 0x59d264 at ??+0
#2 0x959490 at ??+0
#3 0x95a94c at ??+0
#4 0x94ea4c at ??+0
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

This commit fixes that state by adding a handler for
Facility Unavailable exception (0xF60), treating
the instruction that trigged the exception as an
illegal instruction.
Comment 1 commit-hook freebsd_committer freebsd_triage 2017-12-15 04:12:14 UTC
A commit references this bug:

Author: jhibbits
Date: Fri Dec 15 04:11:20 UTC 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 <gromero_AT_ibm_DOT_com>
  MFC after:	2 weeks

Changes:
  head/sys/powerpc/include/trap.h
  head/sys/powerpc/powerpc/trap.c
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2018-05-23 10:27:00 UTC
batch change of PRs untouched in 2018 marked "in progress" back to open.
Comment 3 Justin Hibbits freebsd_committer freebsd_triage 2019-01-21 21:46:05 UTC
Closing bug I no longer intend to MFC.  Recommend people use 12.0 or later for PowerPC.