From f64ab6569d4c5dd94a3be86a0e56ad932c178d84 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Mon, 13 Jan 2025 22:00:00 +1100 Subject: [PATCH] tests/trace: Add a couple of tests of CIABR function Signed-off-by: Paul Mackerras --- tests/test_trace.bin | Bin 11948 -> 12348 bytes tests/test_trace.console_out | 1 + tests/trace/head.S | 13 ++++++++++++ tests/trace/trace.c | 38 ++++++++++++++++++++++++++++++++++- 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/tests/test_trace.bin b/tests/test_trace.bin index 3c7c7bc962f6acf707f6b04ec268e4dd73c3453e..9ad843bdfd2582c39f0f03c773e4481590844869 100755 GIT binary patch literal 12348 zcmeHNe{2)?6@Pa&_T?vGLs~kza>mh=WS*2sXg!kz&IwQxTIvEDo5r*Y30i16X%$p+ zCcD05mIhL!!PGxmse&=J7DLs9Pr7`+@B7}p_xZeg-|t<%XCl3usIPz0+c$#tAnASmLj-`6oRt?Oo9@Fh{OIiI>&A=nc zfQz)F{}nqQiSH#iH4$G~#`xq0|GUe`AMurCj8Ch;KfiqZmrx>)*2Dw;b1Rs?7yM^e zFnikha-3Yt5dQPYa%Hp319B(MDanAP7KlM*`Lz+*(goTnk3B~CEwg}3eCMr{d2#e z(YZ5pdhQ&ZpL?68<|atWUm#!pGKKQ*Q-A(CjpnE6bbf};=W{fbKiZ@RQ?774)jJbQ z^?nQIZv2051XI0-<0;plV=33wSPRk9sUGNipzmQlX@xz5ALkVMWiHioI0js!>aEpr zU`qpA8ragnmI1a5uw{TP18f;!%K%#j*fPMD1-2}(Wq~aVY*}E-0$Uc?vLyL5aGy@O zl$c89E{O&;VAHryG&n6pv47m@2fj)%r+@RY`93fkeAZ(hL$-ZL#nyyhcR-;r-MN;? zb%Enx>tkyn_JAf+QghRQrl2L&AFGEw`{Z-}I!M){nt^Htsu`$epqhbd2C5mTW}upZ zY6hwqsAiy=fd|ZhM0yuZ^k}>fkP}mR-U~R7y?_)=;Q!ozY^i@vbgDF^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3J lT}6)>lUo{^PUnPR4>v}q(1+j)fu9@uSjPyi{sDHN{SV}mszU$( diff --git a/tests/test_trace.console_out b/tests/test_trace.console_out index 2fe36d2..3e84260 100644 --- a/tests/test_trace.console_out +++ b/tests/test_trace.console_out @@ -7,3 +7,4 @@ test 06:PASS test 07:PASS test 08:PASS test 09:PASS +test 10:PASS diff --git a/tests/trace/head.S b/tests/trace/head.S index cd57e3a..14026e4 100644 --- a/tests/trace/head.S +++ b/tests/trace/head.S @@ -224,3 +224,16 @@ test8: test9: sc blr + + .global test10 +test10: + addi %r3,%r3,1 + addi %r4,%r4,2 + addi %r3,%r3,4 + addi %r4,%r4,8 + cmpd %r3,%r4 + bne 1f + nop + nop +1: li %r3,-1 + blr diff --git a/tests/trace/trace.c b/tests/trace/trace.c index 908d299..764b3dd 100644 --- a/tests/trace/trace.c +++ b/tests/trace/trace.c @@ -7,7 +7,6 @@ extern unsigned long callit(unsigned long arg1, unsigned long arg2, unsigned long (*fn)(unsigned long, unsigned long), unsigned long msr, unsigned long *regs); - #define MSR_FP 0x2000 #define MSR_SE 0x400 #define MSR_BE 0x200 @@ -16,6 +15,7 @@ extern unsigned long callit(unsigned long arg1, unsigned long arg2, #define SRR1 27 #define SPRG0 272 #define SPRG1 273 +#define CIABR 187 static inline unsigned long mfmsr(void) { @@ -218,6 +218,41 @@ int trace_test_9(void) return 0; } +extern unsigned long test10(unsigned long, unsigned long); + +int trace_test_10(void) +{ + unsigned long ret; + unsigned long regs[2]; + + mtspr(CIABR, (unsigned long)&test10 + 4 + 3); + ret = callit(1, 1, test10, mfmsr(), regs); + if (ret != 0xd00 || mfspr(SRR0) != (unsigned long)&test10 + 8) + return ret + 1; + if ((mfspr(SRR1) & 0x781f0000) != 0x40100000) + return ret + 2; + if (regs[0] != 2 || regs[1] != 3) + return 3; + + /* test CIABR on a taken branch */ + mtspr(CIABR, (unsigned long)&test10 + 20 + 3); + ret = callit(1, 1, test10, mfmsr(), regs); + if (ret != 0xd00 || mfspr(SRR0) != (unsigned long)&test10 + 32) + return ret + 4; + if ((mfspr(SRR1) & 0x781f0000) != 0x40100000) + return ret + 5; + if (regs[0] != 6 || regs[1] != 11) + return 6; + + /* test CIABR with PRIV = problem state */ + mtspr(CIABR, (unsigned long)&test10 + 1); + ret = callit(1, 1, test10, mfmsr(), regs); + if (ret != 0) + return ret + 7; + /* don't have page tables so can't actually run in problem state */ + return 0; +} + int fail = 0; void do_test(int num, int (*test)(void)) @@ -249,6 +284,7 @@ int main(void) do_test(7, trace_test_7); do_test(8, trace_test_8); do_test(9, trace_test_9); + do_test(10, trace_test_10); return fail; }