m1n1.hv,proxyutils: Refactor how faults are printed re: context

Instead of directly taking a proxy entry code to determine what to
decode, just take an is_fault argument and only show and decode ESR/FAR
if true.

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2022-05-30 22:36:37 +09:00
parent 7c5d47ff85
commit 984b22cd51
2 changed files with 14 additions and 8 deletions

View file

@ -849,7 +849,7 @@ class HV(Reloadable):
handled = self.handle_sync(ctx) handled = self.handle_sync(ctx)
elif code == EXC.FIQ: elif code == EXC.FIQ:
self.u.msr(CNTV_CTL_EL0, 0) self.u.msr(CNTV_CTL_EL0, 0)
self.u.print_exception(code, ctx) self.u.print_context(ctx, False)
handled = True handled = True
elif reason == START.HV: elif reason == START.HV:
code = HV_EVENT(code) code = HV_EVENT(code)
@ -870,7 +870,7 @@ class HV(Reloadable):
else: else:
self.log(f"Guest exception: {reason.name}/{code.name}") self.log(f"Guest exception: {reason.name}/{code.name}")
self.update_pac_mask() self.update_pac_mask()
self.u.print_exception(code, ctx) self.u.print_context(ctx, self.is_fault)
if self._sigint_pending or not handled or user_interrupt: if self._sigint_pending or not handled or user_interrupt:
self._sigint_pending = False self._sigint_pending = False
@ -1022,6 +1022,12 @@ class HV(Reloadable):
def decode_panic_call(self): def decode_panic_call(self):
xnutools.decode_panic_call(self.u, self.ctx) xnutools.decode_panic_call(self.u, self.ctx)
def context(self):
f = f" (orig: #{self.exc_orig_cpu})" if self.ctx.cpu_id != self.exc_orig_cpu else ""
print(f" == On CPU #{self.ctx.cpu_id}{f} ==")
print(f" Reason: {self.exc_reason.name}/{self.exc_code.name}")
self.u.print_context(self.ctx, self.is_fault)
def bt(self, frame=None, lr=None): def bt(self, frame=None, lr=None):
if frame is None: if frame is None:
frame = self.ctx.regs[29] frame = self.ctx.regs[29]

View file

@ -223,14 +223,15 @@ class ProxyUtils(Reloadable):
self.msr(L2C_ERR_STS_EL1, l2c_err_sts) # Clear the flag bits self.msr(L2C_ERR_STS_EL1, l2c_err_sts) # Clear the flag bits
self.msr(DAIF, self.mrs(DAIF) | 0x100) # Re-enable SError exceptions self.msr(DAIF, self.mrs(DAIF) | 0x100) # Re-enable SError exceptions
def print_exception(self, code, ctx, addr=lambda a: f"0x{a:x}"): def print_context(self, ctx, is_fault=True, addr=lambda a: f"0x{a:x}"):
print(f" == Exception taken from {ctx.spsr.M.name} ==") print(f" == Exception taken from {ctx.spsr.M.name} ==")
el = ctx.spsr.M >> 2 el = ctx.spsr.M >> 2
print(f" SPSR = {ctx.spsr}") print(f" SPSR = {ctx.spsr}")
print(f" ELR = {addr(ctx.elr)}" + (f" (0x{ctx.elr_phys:x})" if ctx.elr_phys else "")) print(f" ELR = {addr(ctx.elr)}" + (f" (0x{ctx.elr_phys:x})" if ctx.elr_phys else ""))
print(f" ESR = {ctx.esr}")
print(f" FAR = {addr(ctx.far)}" + (f" (0x{ctx.far_phys:x})" if ctx.far_phys else ""))
print(f" SP_EL{el} = 0x{ctx.sp[el]:x}" + (f" (0x{ctx.sp_phys:x})" if ctx.sp_phys else "")) print(f" SP_EL{el} = 0x{ctx.sp[el]:x}" + (f" (0x{ctx.sp_phys:x})" if ctx.sp_phys else ""))
if is_fault:
print(f" ESR = {ctx.esr}")
print(f" FAR = {addr(ctx.far)}" + (f" (0x{ctx.far_phys:x})" if ctx.far_phys else ""))
for i in range(0, 31, 4): for i in range(0, 31, 4):
j = min(30, i + 3) j = min(30, i + 3)
@ -238,11 +239,11 @@ class ProxyUtils(Reloadable):
if ctx.elr_phys: if ctx.elr_phys:
print() print()
print(" == Faulting code ==") print(" == Code context ==")
self.disassemble_at(ctx.elr_phys - 4 * 4, 9 * 4, ctx.elr_phys) self.disassemble_at(ctx.elr_phys - 4 * 4, 9 * 4, ctx.elr_phys)
if code == EXC.SYNC: if is_fault:
if ctx.esr.EC == ESR_EC.MSR or ctx.esr.EC == ESR_EC.IMPDEF and ctx.esr.ISS == 0x20: if ctx.esr.EC == ESR_EC.MSR or ctx.esr.EC == ESR_EC.IMPDEF and ctx.esr.ISS == 0x20:
print() print()
print(" == MRS/MSR fault decoding ==") print(" == MRS/MSR fault decoding ==")
@ -272,7 +273,6 @@ class ProxyUtils(Reloadable):
if iss.DFSC == DABORT_DFSC.ECC_ERROR: if iss.DFSC == DABORT_DFSC.ECC_ERROR:
self.print_l2c_regs() self.print_l2c_regs()
elif code == EXC.SERROR:
if ctx.esr.EC == ESR_EC.SERROR and ctx.esr.ISS == 0: if ctx.esr.EC == ESR_EC.SERROR and ctx.esr.ISS == 0:
self.print_l2c_regs() self.print_l2c_regs()