Changeset View
Standalone View
sys/powerpc/powerpc/trap.c
Show First 20 Lines • Show All 391 Lines • ▼ Show 20 Lines | #endif | ||||
ucode = TRAP_BRKPT; | ucode = TRAP_BRKPT; | ||||
} else { | } else { | ||||
sig = ppc_instr_emulate(frame, td); | sig = ppc_instr_emulate(frame, td); | ||||
if (sig == SIGILL) { | if (sig == SIGILL) { | ||||
if (frame->srr1 & EXC_PGM_PRIV) | if (frame->srr1 & EXC_PGM_PRIV) | ||||
ucode = ILL_PRVOPC; | ucode = ILL_PRVOPC; | ||||
else if (frame->srr1 & EXC_PGM_ILLEGAL) | else if (frame->srr1 & EXC_PGM_ILLEGAL) | ||||
ucode = ILL_ILLOPC; | ucode = ILL_ILLOPC; | ||||
} else if (sig == SIGFPE) | } else if (sig == SIGFPE) { | ||||
ucode = FPE_FLTINV; /* Punt for now, invalid operation. */ | int msr; | ||||
union { | |||||
double d; | |||||
struct { | |||||
#if _BYTE_ORDER == _LITTLE_ENDIAN | |||||
uint32_t reg; | |||||
luporl: Variable declarations should be all in the beginning of a block, separated of other statements… | |||||
uint32_t junk; | |||||
#else | |||||
Done Inline ActionsThis will panic with an illegal instruction on cores with no FPU. Isn't the FPSCR already available? I think this should also probably go into a FPU-specific header (machine/fpu.h, maybe even powerpc/fpu.c for implementation), so that it's easy to also use other FPU interfaces, such as the SPE for powerpcspe arch. jhibbits: This will panic with an illegal instruction on cores with no FPU. Isn't the FPSCR already… | |||||
uint32_t junk; | |||||
uint32_t reg; | |||||
#endif | |||||
} bits; | |||||
} u; | |||||
luporlUnsubmitted Done Inline ActionsI think this whole union could be replaced by an uint64_t. luporl: I think this whole union could be replaced by an uint64_t.
The only part where you use it as a… | |||||
Done Inline ActionsThis block won't work as you think. FPE_FLTDIV, et al, are integers, not bitfields. Only one reason is allowed. jhibbits: This block won't work as you think. FPE_FLTDIV, et al, are integers, not bitfields. Only one… | |||||
msr = mfmsr(); | |||||
mtmsr(msr | PSL_FP); | |||||
__asm __volatile ("mffs 0; stfd 0,0(%0)" | |||||
:: "b"(&u.d)); | |||||
mtmsr(msr); | |||||
ucode = 0; | |||||
if (u.bits.reg & FPSCR_ZX) | |||||
Done Inline ActionsIs there a paired save_fpu() anywhere? Otherwise we're overwriting the FPRs with whatever was last saved, which could be nothing. jhibbits: Is there a paired save_fpu() anywhere? Otherwise we're overwriting the FPRs with whatever was… | |||||
ucode |= FPE_FLTDIV; | |||||
if (u.bits.reg & FPSCR_OX) | |||||
Done Inline ActionsI may be missing something, but why is enable_fpu() needed here? luporl: I may be missing something, but why is `enable_fpu()` needed here? | |||||
Done Inline Actionsenable_fpu() loads the floating point registers from the PCB. Without it the application can't capture the SIGFPE. renato.riolino_eldorado.org.br: enable_fpu() loads the floating point registers from the PCB. Without it the application can't… | |||||
ucode |= FPE_FLTOVF; | |||||
if (u.bits.reg & FPSCR_UX) | |||||
ucode |= FPE_FLTUND; | |||||
if (u.bits.reg & FPSCR_XX) | |||||
ucode |= FPE_FLTRES; | |||||
if (u.bits.reg & FPSCR_VX) | |||||
ucode |= FPE_FLTINV; | |||||
enable_fpu(td); | |||||
} | |||||
Done Inline ActionsThis brace should be in the line above. luporl: This brace should be in the line above.
See style(9). | |||||
Done Inline ActionsI don't think this is quite right. We need to be able to pass up SIGFPE on emulated FPU as well. jhibbits: I don't think this is quite right. We need to be able to pass up SIGFPE on emulated FPU as… | |||||
} | } | ||||
break; | break; | ||||
case EXC_MCHK: | case EXC_MCHK: | ||||
/* | /* | ||||
* Note that this may not be recoverable for the user | * Note that this may not be recoverable for the user | ||||
* process, depending on the type of machine check, | * process, depending on the type of machine check, | ||||
* but it at least prevents the kernel from dying. | * but it at least prevents the kernel from dying. | ||||
▲ Show 20 Lines • Show All 536 Lines • Show Last 20 Lines |
Variable declarations should be all in the beginning of a block, separated of other statements by a new line, and function call initializers should not be used (e.g. mfmsr()).
See style(9).