From: Luke Kenneth Casson Leighton Date: Sun, 26 Jun 2022 11:56:59 +0000 (+0100) Subject: add test case for kaivb to jump to 0x2700 X-Git-Tag: sv_maxu_works-initial~331 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=58a7e851cc2b288fe99a125f6d929e3402328e06;p=openpower-isa.git add test case for kaivb to jump to 0x2700 --- diff --git a/src/openpower/decoder/isa/caller.py b/src/openpower/decoder/isa/caller.py index 941a89f0..16fbaa1b 100644 --- a/src/openpower/decoder/isa/caller.py +++ b/src/openpower/decoder/isa/caller.py @@ -741,15 +741,18 @@ class ISACaller(ISACallerHelper, ISAFPHelpers): hence the default arguments. when calling from inside ISACaller it is best to use call_trap() """ - log("TRAP:", hex(trap_addr), hex(self.namespace['MSR'].value)) + # https://bugs.libre-soc.org/show_bug.cgi?id=859 + kaivb = self.spr['KAIVB'].value + msr = self.namespace['MSR'].value + log("TRAP:", hex(trap_addr), hex(msr), "kaivb", hex(kaivb)) # store CIA(+4?) in SRR0, set NIA to 0x700 # store MSR in SRR1, set MSR to um errr something, have to check spec # store SVSTATE (if enabled) in SVSRR0 self.spr['SRR0'].value = self.pc.CIA.value - self.spr['SRR1'].value = self.namespace['MSR'].value + self.spr['SRR1'].value = msr if self.is_svp64_mode: self.spr['SVSRR0'] = self.namespace['SVSTATE'].value - self.trap_nia = SelectableInt(trap_addr, 64) + self.trap_nia = SelectableInt(trap_addr | (kaivb&~0x1fff), 64) self.spr['SRR1'][trap_bit] = 1 # change *copy* of MSR in SRR1 # set exception bits. TODO: this should, based on the address diff --git a/src/openpower/test/trap/trap_cases.py b/src/openpower/test/trap/trap_cases.py index 41d34348..1501b8ab 100644 --- a/src/openpower/test/trap/trap_cases.py +++ b/src/openpower/test/trap/trap_cases.py @@ -10,6 +10,7 @@ import random class TrapTestCase(TestAccumulatorBase): def case_1_kaivb(self): + # https://bugs.libre-soc.org/show_bug.cgi?id=859 lst = ["mtspr 850, 1", # KAIVB "mfspr 2, 850", ] @@ -22,6 +23,26 @@ class TrapTestCase(TestAccumulatorBase): initial_regs, initial_sprs, initial_msr=msr) + def case_2_kaivb_test(self): + # https://bugs.libre-soc.org/show_bug.cgi?id=859 + # sets KAIVB to 1<<13 then deliberately causes exception. + # PC expected to jump to (1<<13)|0x700 *NOT* 0x700 as usual + lst = ["mtspr 850, 1", # KAIVB + "tbegin.", # deliberately use illegal instruction + ] + initial_regs = [0] * 32 + initial_regs[1] = 1<<13 + initial_sprs = {'KAIVB': 0x12345678, + } + msr = 0xa000000000000003 + e = ExpectedState(pc=0x2700) + e.intregs[1] = 1<<13 + e.msr = 0xa000000000000003 # TODO, not actually checked + self.add_case(Program(lst, bigendian), + initial_regs, initial_sprs, + initial_msr=msr, + expected=e) + def case_0_hrfid(self): lst = ["hrfid"] initial_regs = [0] * 32