tests/misc: Add a test for a load that hits two preceding stores
authorPaul Mackerras <paulus@ozlabs.org>
Tue, 31 Aug 2021 01:45:57 +0000 (11:45 +1000)
committerPaul Mackerras <paulus@ozlabs.org>
Thu, 2 Sep 2021 23:09:44 +0000 (09:09 +1000)
This checks that the store forwarding machinery in the dcache
correctly combines forwarded stores when they are partial stores
(i.e. only writing part of the doubleword, as for a byte store).

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
tests/misc/head.S
tests/misc/misc.c
tests/test_misc.bin
tests/test_misc.console_out

index d490a6187fc73a8c10530110603c64abedb76d46..9044c519dfbb71df3ad86030be5f47c48cb56d63 100644 (file)
@@ -162,3 +162,26 @@ test_bdnzl:
        li      %r3,0
 9:     mtlr    %r10
        blr
+
+/* Test that a load that hits stores gets the correct data */
+       .global test_loadhitstore
+test_loadhitstore:
+       addi    %r5,%r1,-16
+       ld      %r0,0(%r5)
+       li      %r0,0
+       std     %r0,0(%r5)
+       li      %r6,0x66
+       li      %r7,0x77
+       .balign 64
+       nop
+       nop
+       nop
+       nop
+       stb     %r6,2(%r5)
+       stb     %r7,3(%r5)
+       ld      %r0,0(%r5)
+       sldi    %r6,%r6,16
+       sldi    %r7,%r7,24
+       or      %r7,%r6,%r7
+       subf    %r3,%r0,%r7
+       blr
index 73745d94a510863e99cc049d6b7ad388ded025fb..3cc030070b569c6c59b6aa3ce58b01de71b4249b 100644 (file)
@@ -15,6 +15,7 @@ extern long test_addpcis_2(void);
 extern long test_mfpvr(void);
 extern long test_mtpvr(void);
 extern long test_bdnzl(void);
+extern long test_loadhitstore(void);
 
 // i < 100
 void print_test_number(int i)
@@ -66,5 +67,12 @@ int main(void)
        } else
                puts(PASS);
 
+       print_test_number(6);
+       if (test_loadhitstore() != 0) {
+               fail = 1;
+               puts(FAIL);
+       } else
+               puts(PASS);
+
        return fail;
 }
index 2264686c06a630733a71d56de90ea1a1f3925baf..648ab184ab362a9a3c1ba0c554df4f1ceb96bb3e 100755 (executable)
Binary files a/tests/test_misc.bin and b/tests/test_misc.bin differ
index e59c03fe1e46b3a5496cc4949fdbfac9ae10ab77..5296101d5c1830bf45bd3ea3ea08d8f8176038c1 100644 (file)
@@ -3,3 +3,4 @@ Test 02:PASS
 Test 03:PASS\r
 Test 04:PASS\r
 Test 05:PASS\r
+Test 06:PASS\r