]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
powerpc: Add .machine directives for scv, copy, paste, cpabort instructions
authorTulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Fri, 20 Aug 2021 22:07:09 +0000 (19:07 -0300)
committerCarl Love <cel@us.ibm.com>
Thu, 30 Sep 2021 22:30:01 +0000 (17:30 -0500)
GCC is no longer passing the "-many" flag to the assembler.  So, the
inline assembly instructions statements need to use the .machine directives
for the specific platform.

(gcc commit e154242724b084380e3221df7c08fcdbd8460674 ; "[RS6000] Don't
pass -many to the assembler".

Hardware sync instruction (hwsync) added after the copy, paste and cpabort
instructions to improve the reliability of the test.

Makefile.all.am
VEX/priv/guest_ppc_helpers.c
coregrind/m_syscall.c
none/tests/ppc64/Makefile.am
none/tests/ppc64/test_copy_paste.c

index 1b66f82ea46ab10c1f89d5188966cdd0f35b9b00..06b23c99e03110be84084c799817d6ca9708d42e 100644 (file)
@@ -126,9 +126,9 @@ AM_CFLAGS_BASE = \
 # Power ISA flag for use by guest_ppc_helpers.c
 if HAS_XSCVHPDP
 if HAS_DARN
-ISA_3_0_BUILD_FLAG = -DHAS_XSCVHPDP -DHAS_DARN
+ISA_3_0_BUILD_FLAG = -DHAS_XSCVHPDP -DHAS_DARN -DHAS_ISA_3_00
 else
-ISA_3_0_BUILD_FLAG = -DHAS_XSCVHPDP
+ISA_3_0_BUILD_FLAG = -DHAS_XSCVHPDP  -DHAS_ISA_3_00
 endif
 else
 ISA_3_0_BUILD_FLAG =
index 87f094c6703d58351300a86b173277905b0177f6..689aa8f34eb7fad7f3ae40bdbe864add3c1efab7 100644 (file)
@@ -3170,13 +3170,22 @@ UInt copy_paste_abort_dirty_helper(UInt addr, UInt op) {
    UInt cr;
 
    if (op == COPY_INST)
-      __asm__ __volatile__ ("copy 0,%0" :: "r" (addr));
+      __asm__ __volatile__ (".machine push;\n"
+                            ".machine power9;\n"
+                            "copy 0,%0;\n"
+                            ".machine pop" :: "r" (addr));
 
    else if (op == PASTE_INST)
-      __asm__ __volatile__ ("paste. 0,%0" :: "r" (addr));
+      __asm__ __volatile__ (".machine push;\n"
+                            ".machine power9;\n"
+                            "paste. 0,%0\n"
+                            ".machine pop" :: "r" (addr));
 
    else if (op == CPABORT_INST)
-      __asm__ __volatile__ ("cpabort");
+      __asm__ __volatile__ (".machine push;\n"
+                            ".machine power9;\n"
+                            "cpabort\n"
+                            ".machine pop");
 
    else
       /* Unknown operation */
index 80e2af439714472e43f9e2b4c81e6075794c8214..c12632d366572fae239c023453abde783cdbaa3a 100644 (file)
@@ -599,7 +599,11 @@ asm(
 "        ld   4, 16(3)\n"  /* sc arg 2 */
 "        ld   0,  0(3)\n"  /* sc number */
 "        ld   3,  8(3)\n"  /* sc arg 1 */
+
+"        .machine push\n"
+"        .machine \"power9\"\n"
 "        scv  0\n"
+"        .machine pop\n"
 "        ld   5,-16(1)\n"  /* reacquire argblock ptr (r5 is caller-save) */
 "        std  3,0(5)\n"    /* argblock[0] = r3 */
 
index 9527cdf1e8f63a6cff0afbf810f5acb18430b7ba..15e90ebfdba9b44e25fe854a813e8b9d50ff4c96 100644 (file)
@@ -218,8 +218,8 @@ test_isa_3_1_AT_CFLAGS = $(test_isa_3_1_CFLAGS)
 subnormal_test_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(VSX_FLAG) $(ISA_2_06_FLAG) \
                        @FLAG_M64@ $(ALTIVEC_FLAG) $(BUILD_FLAG_VSX) $(BUILD_FLAGS_ISA_2_06)
 
-test_copy_paste_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(HTM_FLAG) $(ISA_3_00_FLAG) \
-                       @FLAG_M64@ $(BUILD_FLAGS_ISA_3_00)
+test_copy_paste_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(HTM_FLAG) $(ISA_3_1_FLAG) \
+                       @FLAG_M64@ $(BUILD_FLAGS_ISA_3_1)
 
 test_isa_2_06_part3_LDADD = -lm
 test_dfp1_LDADD = -lm
index dc5f42c1a08dc835cf69e6b6f72fa26d4c78879c..339ff8b6f7a564e1f5b297a366c7262a6e346dd5 100644 (file)
@@ -1,5 +1,9 @@
 /* The copy, paste, cpabort are ISA 3.0 instructions.  However, the memory
-   to memory copy is only supported on ISA 3.1 era machines.  */
+   to memory copy is only supported on ISA 3.1 era machines.
+
+   The following test does a memory to memory copy test, an out of order
+   paste test, and a copy paste abort test.  This test is only supported
+   ISA 3.1 systems.  */
 
 #include <stdio.h>
 #include <stdint.h>
@@ -7,7 +11,7 @@
 #include <string.h>
 #include <malloc.h>
 
-#ifdef HAS_ISA_3_00
+#ifdef HAS_ISA_3_1
 #include <altivec.h>
 
 /* return CR0 in least significant bits */
 
 void test_copy (uint8_t *reg)
 {
-  __asm__ __volatile__ ("copy 0,%0" : : "r" (reg));
+  __asm__ __volatile__ (".machine push; .machine power9; " \
+                        "copy 0,%0; hwsync; .machine pop;" : : "r" (reg));
 }
 
 void test_paste (uint8_t *reg)
 {
-  __asm__ __volatile__ ("paste. 0,%0" : : "r" (reg));
+  __asm__ __volatile__ (".machine push; .machine power9; " \
+                        "paste. 0,%0; hwsync; .machine pop;" : : "r" (reg));
 }
 
 void test_cpabort (void)
 {
-  __asm__ __volatile__ ("cpabort");
+  __asm__ __volatile__ (".machine push; .machine power9; " \
+                        "cpabort; hwsync; .machine pop;");
 }
 
 #define NUM_ELEMENTS 128
@@ -39,7 +46,7 @@ void test_cpabort (void)
 
 int main()
 {
-#ifdef HAS_ISA_3_00
+#ifdef HAS_ISA_3_1
    int i;
    unsigned int cc_value;
    int result = SUCCESS;
@@ -66,6 +73,10 @@ int main()
    test_paste (dst_buffer);
    GET_CR0(cc_value);
 
+#if DEBUG
+   printf("CR0 = 0x%x\n", cc_value);
+#endif
+
 #if DEBUG
    printf("AFTER COPY/PASTE Contents of src/dst buffer\n");
    for (i=0; i<NUM_ELEMENTS; i++) {
@@ -111,7 +122,7 @@ int main()
       printf("FAILURE.\n");
 
 #else
-  printf("HAS_ISA_3_00 not detected.\n");
+  printf("HAS_ISA_3_1 not detected.\n");
 #endif
    return 0;
 }