From 80bc9d5098f924b911e645f3970c5339b5ca3148 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Thu, 16 Jan 2025 22:37:58 +1100 Subject: [PATCH] tests/trace: Add a few tests of DAWR (data watchpoint) functionality Signed-off-by: Paul Mackerras --- tests/test_trace.bin | Bin 12492 -> 13352 bytes tests/test_trace.console_out | 1 + tests/trace/head.S | 14 ++++++ tests/trace/trace.c | 93 ++++++++++++++++++++++++++++++++++- 4 files changed, 107 insertions(+), 1 deletion(-) diff --git a/tests/test_trace.bin b/tests/test_trace.bin index 8139a81460205a9dffaca390cc4aa1569758e21e..44538d83668af16e48d936f4008d8da975306bc7 100755 GIT binary patch delta 1506 zcmZvbUrbw79LIk>v;|7(O0xI|y5;s#p)FmhN|wT4YuTJt76L9R4 ze7?W)JLk^4HPSPbV8em2_xF|s{O&HzO5H;Nm9$ZXw0mxR&7=`^XAnJy)Y{ZVGK|biY z$QDarE}647it#Hx7xz@9nbXFXs#f)dB8q(^+*yUD_oZrP^+Tl8r)nDeQZ%Ir@$-S} z?P6bq7Q%^#X`SeJIFY-f|9V%n5F9F~^zNjAsENA5adL-m6n1GN;H6kYAH@!64C^yu zAd+Gi^axX$DAuUW<^30t->=Px0X^cSs}R1SOF=1+7lVit?B60}hfo28hJ|R60%kf^ zZ^n9x`L)43^o2f}_i2fL1)8)|(#D}YTMqT4hMv}UZ4)8-=^TEHaog`nqh-mpaWiX;ZMnz*KX?j3w^H_Q*ppW z{gF4xSFcdz*{}H-@5^i?&cE^Q4z)9ifpENSMb|=5m(RP&h&4dvdBaA3!$pAdnQHu6 zz7V?}=WqC`*hHM4^Oaks;$7iMKBiP~rOIqsz`u5ePy4Qw3Ng@F0?gdogW=D|Pxz0S zOyTkGYVMladQZIDt3bIedh}?ijYv5hedP!O(w-Onxs14)TM^T_tXRl7$%KD5*^2lw z>vK z*dGXy=BD7&Hd#d$bMyhf9aNi-JQU&*TsrKClts^7Hg!6v`6p}Cg;1l3=zHXQWd0>b z2>DhA9kfQ_dNDhZcmBbfYt@DT-1BfFe+qGr!8uqQrRXK|rv;y}%O-4$I^yj%iN5{g z57uaj2TLZfe(f)Qx>mK!!*ubFYpX4GZ0_OHwUyR7Sd&@4RIBdngcLG_Jfb_d*Azh{{Qt%YwB?c zmM^S4xEQH#M$Yy=sX0|X4TUfcoHKBqFT>Lw{9zcFi>*TA1fDX!LR+Wg16VpP#os~s zI8`%PNi0GmM0QJUb+e#q_9IU=q1}aB$pie7;^CIYg2*uzFvcd^xWePeO|F#CHwTqB zc+0#FwIVK=QQL?ArLmun$~Mb;@4NHm^ig(+O?t5-Z?l-!R9S$np?>VKhM`f!t5y;| z7V(ZXpf!tmZV9eUbk*smj zBKvG#hz*)z*Lr!xe|Q(m*+eQh5TYVOLLbp0HYl4Tl{inlLQEXuS~fMDI}}1j60$x= UEKp|AQVE$Y5-Wd&n2`bDAL`Gg{Qv*} diff --git a/tests/test_trace.console_out b/tests/test_trace.console_out index 3e84260..3a5a601 100644 --- a/tests/test_trace.console_out +++ b/tests/test_trace.console_out @@ -8,3 +8,4 @@ test 07:PASS test 08:PASS test 09:PASS test 10:PASS +test 11:PASS diff --git a/tests/trace/head.S b/tests/trace/head.S index 14026e4..fd444b6 100644 --- a/tests/trace/head.S +++ b/tests/trace/head.S @@ -237,3 +237,17 @@ test10: nop 1: li %r3,-1 blr + + .global test11 +test11: + stdx %r3,%r3,%r4 + stw %r3,6(%r4) + dcbt 0,%r4 + dcbf 0,%r4 + dcbtst 0,%r4 + sync + ld %r3,0(%r4) + lwz %r3,6(%r4) + lwz %r3,27(%r4) + stb %r3,26(%r4) + blr diff --git a/tests/trace/trace.c b/tests/trace/trace.c index e7d58ba..a88c751 100644 --- a/tests/trace/trace.c +++ b/tests/trace/trace.c @@ -11,11 +11,17 @@ extern unsigned long callit(unsigned long arg1, unsigned long arg2, #define MSR_SE 0x400 #define MSR_BE 0x200 +#define DSISR 18 +#define DAR 19 #define SRR0 26 #define SRR1 27 #define SPRG0 272 #define SPRG1 273 #define CIABR 187 +#define DAWR0 180 +#define DAWR1 181 +#define DAWRX0 188 +#define DAWRX1 189 #define SIAR 780 #define SDAR 781 @@ -232,6 +238,7 @@ int trace_test_9(void) extern unsigned long test10(unsigned long, unsigned long); +/* test CIABR */ int trace_test_10(void) { unsigned long ret; @@ -265,6 +272,89 @@ int trace_test_10(void) return 0; } +/* test DAWR[X]{0,1} */ +#define MRD_SHIFT 10 +#define HRAMMC 0x80 +#define DW 0x40 +#define DR 0x20 +#define WT 0x10 +#define WTI 0x08 +#define PRIVM_HYP 0x04 +#define PRIVM_PNH 0x02 +#define PRIVM_PRO 0x01 + +extern unsigned long test11(unsigned long, unsigned long); + +int trace_test_11(void) +{ + unsigned long ret; + unsigned long regs[2]; + unsigned long x[4]; + + mtspr(DAWR0, (unsigned long)&x[0]); + mtspr(DAWRX0, (0 << MRD_SHIFT) + DW + PRIVM_HYP); + ret = callit(0, (unsigned long) &x, test11, mfmsr(), regs); + if (ret != 0x300) + return ret + 1; + if (mfspr(SRR0) != (unsigned long) &test11 || mfspr(DSISR) != 0x02400000 || + mfspr(DAR) != (unsigned long)&x[0]) + return 2; + + mtspr(DAWR0, (unsigned long)&x[1]); + ret = callit(0, (unsigned long) &x, test11, mfmsr(), regs); + if (ret != 0x300) + return ret + 3; + if (mfspr(SRR0) != (unsigned long) &test11 + 4 || mfspr(DSISR) != 0x02400000 || + mfspr(DAR) != (unsigned long)&x[1]) + return 4; + + mtspr(DAWR0, (unsigned long)&x[0]); + mtspr(DAWRX0, (0 << MRD_SHIFT) + DR + PRIVM_HYP); + ret = callit(0, (unsigned long) &x, test11, mfmsr(), regs); + if (ret != 0x300) + return ret + 5; + if (mfspr(SRR0) != (unsigned long) &test11 + 24 || mfspr(DSISR) != 0x00400000) + return 6; + + mtspr(DAWR0, (unsigned long)&x[1]); + ret = callit(0, (unsigned long) &x, test11, mfmsr(), regs); + if (ret != 0x300) + return ret + 7; + if (mfspr(SRR0) != (unsigned long) &test11 + 28 || mfspr(DSISR) != 0x00400000) + return 8; + + mtspr(DAWR0, (unsigned long)&x[3]); + ret = callit(0, (unsigned long) &x, test11, mfmsr(), regs); + if (ret != 0x300) + return ret + 9; + if (mfspr(SRR0) != (unsigned long) &test11 + 32 || mfspr(DSISR) != 0x00400000) + return 10; + + mtspr(DAWR0, (unsigned long)&x[2]); + mtspr(DAWRX0, (1 << MRD_SHIFT) + DW + PRIVM_HYP); + ret = callit(0, (unsigned long) &x, test11, mfmsr(), regs); + if (ret != 0x300) + return ret + 11; + if (mfspr(SRR0) != (unsigned long) &test11 + 36 || mfspr(DSISR) != 0x02400000) + return 12; + + mtspr(DAWR0, (unsigned long)&x[0]); + mtspr(DAWRX0, (3 << MRD_SHIFT) + DR + DW + WT + PRIVM_HYP); + ret = callit(0, (unsigned long) &x, test11, mfmsr(), regs); + if (ret != 0) + return ret + 13; + + mtspr(DAWR0, (unsigned long)&x[0]); + mtspr(DAWRX0, (3 << MRD_SHIFT) + DR + DW + WT + WTI + PRIVM_HYP); + ret = callit(0, (unsigned long) &x, test11, mfmsr(), regs); + if (ret != 0x300) + return ret + 14; + if (mfspr(SRR0) != (unsigned long) &test11 || mfspr(DSISR) != 0x02400000) + return 15; + + return 0; +} + int fail = 0; void do_test(int num, int (*test)(void)) @@ -277,7 +367,7 @@ void do_test(int num, int (*test)(void)) print_string("PASS\r\n"); } else { fail = 1; - print_string("FAIL "); + print_string(" FAIL "); print_hex(ret, 4); print_string("\r\n"); } @@ -297,6 +387,7 @@ int main(void) do_test(8, trace_test_8); do_test(9, trace_test_9); do_test(10, trace_test_10); + do_test(11, trace_test_11); return fail; }