Date: Sun, 17 Nov 2019 01:01:03 +0000 (UTC) From: Justin Hibbits <jhibbits@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r354783 - head/sys/powerpc/powerpc Message-ID: <201911170101.xAH113ih072380@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhibbits Date: Sun Nov 17 01:01:02 2019 New Revision: 354783 URL: https://svnweb.freebsd.org/changeset/base/354783 Log: powerpc: Return SIGILL if DSCR does not exist in m{f,t}spr emulation Guard against programs written for one powerpc target running on another, and panicking the system due to not having the DSCR register. Modified: head/sys/powerpc/powerpc/exec_machdep.c Modified: head/sys/powerpc/powerpc/exec_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/exec_machdep.c Sun Nov 17 00:52:58 2019 (r354782) +++ head/sys/powerpc/powerpc/exec_machdep.c Sun Nov 17 01:01:02 2019 (r354783) @@ -1086,15 +1086,17 @@ emulate_mfspr(int spr, int reg, struct trapframe *fram td = curthread; if (spr == SPR_DSCR || spr == SPR_DSCRP) { + if (!(cpu_features2 & PPC_FEATURE2_DSCR)) + return (SIGILL); // If DSCR was never set, get the default DSCR if ((td->td_pcb->pcb_flags & PCB_CDSCR) == 0) td->td_pcb->pcb_dscr = mfspr(SPR_DSCRP); frame->fixreg[reg] = td->td_pcb->pcb_dscr; frame->srr0 += 4; - return 0; + return (0); } else - return SIGILL; + return (SIGILL); } static int @@ -1104,13 +1106,15 @@ emulate_mtspr(int spr, int reg, struct trapframe *fram td = curthread; if (spr == SPR_DSCR || spr == SPR_DSCRP) { + if (!(cpu_features2 & PPC_FEATURE2_DSCR)) + return (SIGILL); td->td_pcb->pcb_flags |= PCB_CDSCR; td->td_pcb->pcb_dscr = frame->fixreg[reg]; mtspr(SPR_DSCRP, frame->fixreg[reg]); frame->srr0 += 4; - return 0; + return (0); } else - return SIGILL; + return (SIGILL); } #define XFX 0xFC0007FF
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911170101.xAH113ih072380>