tests/misc: Add a store/dcbz test
authorAnton Blanchard <anton@linux.ibm.com>
Thu, 23 Sep 2021 05:47:52 +0000 (15:47 +1000)
committerAnton Blanchard <anton@ozlabs.org>
Mon, 27 Sep 2021 05:30:41 +0000 (15:30 +1000)
We have a bug where an store near a dcbz can cause the dcbz to only zero
8 bytes. Add a test case for this.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
tests/misc/head.S
tests/misc/misc.c
tests/test_misc.bin
tests/test_misc.console_out

index 025f2266f5dbe2ef50f569180a45fea27111253a..ec48c26089586bdc9c0bc7bb1f872de591295e1f 100644 (file)
@@ -215,3 +215,45 @@ test_icbi:
        nop
        addi    %r3,%r3,1
        blr
+
+       .global test_dcbz_near_store
+test_dcbz_near_store:
+       li      %r0,-1
+       addi    %r10,%r1,-64
+       # cacheline align stack pointer
+       srdi    %r10,%r10,6
+       sldi    %r10,%r10,6
+
+       std     %r0,0(%r10)
+       std     %r0,8(%r10)
+       std     %r0,16(%r10)
+       std     %r0,24(%r10)
+       std     %r0,32(%r10)
+       std     %r0,40(%r10)
+       std     %r0,48(%r10)
+       std     %r0,56(%r10)
+
+       li      %r3,0xa5
+       # Store to same cacheline as dcbz, although it doesn't seem
+       # necessary to hit the issue.
+       std     %r3,0(%r10)
+       dcbz    0,%r10
+
+       ld      %r0,0(%r10)
+       ld      %r3,8(%r10)
+       ld      %r4,16(%r10)
+       ld      %r5,24(%r10)
+       ld      %r6,32(%r10)
+       ld      %r7,40(%r10)
+       ld      %r8,48(%r10)
+       ld      %r9,56(%r10)
+
+       or      %r3,%r3,%r0
+       or      %r3,%r3,%r4
+       or      %r3,%r3,%r5
+       or      %r3,%r3,%r6
+       or      %r3,%r3,%r7
+       or      %r3,%r3,%r8
+       or      %r3,%r3,%r9
+
+       blr
index d5eb12e77a00ba4aef7e22e8a26d16098b9140c2..4773f83b72d040e2033689ddd482c16bb6fa0824 100644 (file)
@@ -17,6 +17,7 @@ extern long test_mtpvr(void);
 extern long test_bdnzl(void);
 extern long test_loadhitstore(void);
 extern long test_icbi(void);
+extern long test_dcbz_near_store(void);
 
 // i < 100
 void print_test_number(int i)
@@ -82,5 +83,12 @@ int main(void)
        } else
                puts(PASS);
 
+       print_test_number(8);
+       if (test_dcbz_near_store() != 0) {
+               fail = 1;
+               puts(FAIL);
+       } else
+               puts(PASS);
+
        return fail;
 }
index 0897d85a4404b8e19b81011c15c2d1870f58a218..5350aa3677bbe55379646e900a30b6e573e14d26 100755 (executable)
Binary files a/tests/test_misc.bin and b/tests/test_misc.bin differ
index 041accfdeae74ad0196d16948bdf57af25be6392..06625dad643f1f8d65014c88f5c96040158dfe3f 100644 (file)
@@ -5,3 +5,4 @@ Test 04:PASS
 Test 05:PASS\r
 Test 06:PASS\r
 Test 07:PASS\r
+Test 08:PASS\r