powerpc/64s: Set assembler machine type to POWER4
authorNicholas Piggin <npiggin@gmail.com>
Tue, 20 Feb 2018 19:08:26 +0000 (05:08 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 31 Mar 2018 13:47:49 +0000 (00:47 +1100)
Rather than override the machine type in .S code (which can hide wrong
or ambiguous code generation for the target), set the type to power4
for all assembly.

This also means we need to be careful not to build power4-only code
when we're not building for Book3S, such as the "power7" versions of
copyuser/page/memcpy.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
[mpe: Fix Book3E build, don't build the "power7" variants for non-Book3S]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/Makefile
arch/powerpc/include/asm/ppc_asm.h
arch/powerpc/kernel/entry_64.S
arch/powerpc/kernel/exceptions-64s.S
arch/powerpc/lib/Makefile
arch/powerpc/lib/copypage_64.S
arch/powerpc/lib/copypage_power7.S
arch/powerpc/lib/copyuser_64.S
arch/powerpc/lib/copyuser_power7.S
arch/powerpc/lib/memcpy_64.S
arch/powerpc/lib/memcpy_power7.S

index c7628e973084289bf53dff4a3271ac663439260d..af46d22fa6608768e9da1ce2b7e546bbc172fc64 100644 (file)
@@ -245,6 +245,7 @@ endif
 cpu-as-$(CONFIG_4xx)           += -Wa,-m405
 cpu-as-$(CONFIG_ALTIVEC)       += $(call as-option,-Wa$(comma)-maltivec)
 cpu-as-$(CONFIG_E200)          += -Wa,-me200
+cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4
 
 KBUILD_AFLAGS += $(cpu-as-y)
 KBUILD_CFLAGS += $(cpu-as-y)
index ae94b3626b6cd8790f03d60d1f58cbcc5db1b4d2..13f7f4c0e1eae8f57abf5ef075c7e8b06f06b3ae 100644 (file)
@@ -439,14 +439,11 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
 
 /* The following stops all load and store data streams associated with stream
  * ID (ie. streams created explicitly).  The embedded and server mnemonics for
- * dcbt are different so we use machine "power4" here explicitly.
+ * dcbt are different so this must only be used for server.
  */
-#define DCBT_STOP_ALL_STREAM_IDS(scratch)      \
-.machine push ;                                        \
-.machine "power4" ;                            \
-       lis     scratch,0x60000000@h;           \
-       dcbt    0,scratch,0b01010;              \
-.machine pop
+#define DCBT_BOOK3S_STOP_ALL_STREAM_IDS(scratch)       \
+       lis     scratch,0x60000000@h;                   \
+       dcbt    0,scratch,0b01010
 
 /*
  * toreal/fromreal/tophys/tovirt macros. 32-bit BookE makes them
index 2cb5109a7ea3d3d4959fa0d9360248218b56d688..51695608c68b3cd59141a084d632f4291265b398 100644 (file)
@@ -545,7 +545,7 @@ _GLOBAL(_switch)
 /* Cancel all explict user streams as they will have no use after context
  * switch and will stop the HW from creating streams itself
  */
-       DCBT_STOP_ALL_STREAM_IDS(r6)
+       DCBT_BOOK3S_STOP_ALL_STREAM_IDS(r6)
 #endif
 
        addi    r6,r4,-THREAD   /* Convert THREAD to 'current' */
index bc5d927da37a8f36c1f24f5c89c3d12248c5d890..ae6a849db60b1ae8440abcc776b8a5b59e57a641 100644 (file)
@@ -687,14 +687,11 @@ END_MMU_FTR_SECTION_IFCLR(MMU_FTR_TYPE_RADIX)
 
        bne     cr4,1f          /* returning to kernel */
 
-.machine       push
-.machine       "power4"
        mtcrf   0x80,r9
        mtcrf   0x08,r9         /* MSR[PR] indication is in cr4 */
        mtcrf   0x04,r9         /* MSR[RI] indication is in cr5 */
        mtcrf   0x02,r9         /* I/D indication is in cr6 */
        mtcrf   0x01,r9         /* slb_allocate uses cr0 and cr7 */
-.machine       pop
 
        RESTORE_CTR(r9, PACA_EXSLB)
        RESTORE_PPR_PACA(PACA_EXSLB, r9)
@@ -707,14 +704,11 @@ END_MMU_FTR_SECTION_IFCLR(MMU_FTR_TYPE_RADIX)
        RFI_TO_USER
        b       .       /* prevent speculative execution */
 1:
-.machine       push
-.machine       "power4"
        mtcrf   0x80,r9
        mtcrf   0x08,r9         /* MSR[PR] indication is in cr4 */
        mtcrf   0x04,r9         /* MSR[RI] indication is in cr5 */
        mtcrf   0x02,r9         /* I/D indication is in cr6 */
        mtcrf   0x01,r9         /* slb_allocate uses cr0 and cr7 */
-.machine       pop
 
        RESTORE_CTR(r9, PACA_EXSLB)
        RESTORE_PPR_PACA(PACA_EXSLB, r9)
@@ -1524,7 +1518,7 @@ TRAMP_REAL_BEGIN(rfi_flush_fallback)
        ld      r11,PACA_L1D_FLUSH_SIZE(r13)
        srdi    r11,r11,(7 + 3) /* 128 byte lines, unrolled 8x */
        mtctr   r11
-       DCBT_STOP_ALL_STREAM_IDS(r11) /* Stop prefetch streams */
+       DCBT_BOOK3S_STOP_ALL_STREAM_IDS(r11) /* Stop prefetch streams */
 
        /* order ld/st prior to dcbt stop all streams with flushing */
        sync
@@ -1564,7 +1558,7 @@ TRAMP_REAL_BEGIN(hrfi_flush_fallback)
        ld      r11,PACA_L1D_FLUSH_SIZE(r13)
        srdi    r11,r11,(7 + 3) /* 128 byte lines, unrolled 8x */
        mtctr   r11
-       DCBT_STOP_ALL_STREAM_IDS(r11) /* Stop prefetch streams */
+       DCBT_BOOK3S_STOP_ALL_STREAM_IDS(r11) /* Stop prefetch streams */
 
        /* order ld/st prior to dcbt stop all streams with flushing */
        sync
index 3c29c9009bbf2c0a830d32a4fdf353ecb8a34b60..653901042ad7d094c18495f3e71d6c2aacf84e0a 100644 (file)
@@ -22,9 +22,11 @@ ifeq ($(call ld-ifversion, -lt, 225000000, y),y)
 extra-$(CONFIG_PPC64)  += crtsavres.o
 endif
 
+obj-$(CONFIG_PPC_BOOK3S_64) += copyuser_power7.o copypage_power7.o \
+                              memcpy_power7.o
+
 obj64-y        += copypage_64.o copyuser_64.o mem_64.o hweight_64.o \
-          copyuser_power7.o string_64.o copypage_power7.o memcpy_power7.o \
-          memcpy_64.o memcmp_64.o pmem.o
+          string_64.o memcpy_64.o memcmp_64.o pmem.o
 
 obj64-$(CONFIG_SMP)    += locks.o
 obj64-$(CONFIG_ALTIVEC)        += vmx-helper.o
index 4bcc9e76fb55658d78bdb803b2806371e0ad3c7d..8d5034f645f3ff599942e44a8740708c70dcf40b 100644 (file)
@@ -21,7 +21,9 @@ _GLOBAL_TOC(copy_page)
 BEGIN_FTR_SECTION
        lis     r5,PAGE_SIZE@h
 FTR_SECTION_ELSE
+#ifdef CONFIG_PPC_BOOK3S_64
        b       copypage_power7
+#endif
 ALT_FTR_SECTION_END_IFCLR(CPU_FTR_VMX_COPY)
        ori     r5,r5,PAGE_SIZE@l
 BEGIN_FTR_SECTION
index ca5fc8fa7efc9207372da8d36c517a349432fa4f..8fa73b7ab20ee8a3b028e6a7ea13bfa556903a48 100644 (file)
@@ -42,8 +42,6 @@ _GLOBAL(copypage_power7)
        lis     r8,0x8000       /* GO=1 */
        clrldi  r8,r8,32
 
-.machine push
-.machine "power4"
        /* setup read stream 0  */
        dcbt    0,r4,0b01000    /* addr from */
        dcbt    0,r7,0b01010   /* length and depth from */
@@ -52,7 +50,6 @@ _GLOBAL(copypage_power7)
        dcbtst  0,r10,0b01010  /* length and depth to */
        eieio
        dcbt    0,r8,0b01010    /* all streams GO */
-.machine pop
 
 #ifdef CONFIG_ALTIVEC
        mflr    r0
index 08da06e1bd729c3374493cf570ce053fb5137e79..506677395681a9a25d304378b1602c75bb980cbc 100644 (file)
 
        .align  7
 _GLOBAL_TOC(__copy_tofrom_user)
+#ifdef CONFIG_PPC_BOOK3S_64
 BEGIN_FTR_SECTION
        nop
 FTR_SECTION_ELSE
        b       __copy_tofrom_user_power7
 ALT_FTR_SECTION_END_IFCLR(CPU_FTR_VMX_COPY)
+#endif
 _GLOBAL(__copy_tofrom_user_base)
        /* first check for a whole page copy on a page boundary */
        cmpldi  cr1,r5,16
index d416a4a6657858809a9e54d0fea77cb49d8976a3..215e4760c09fff491cdfa80e0258a428aaf91b81 100644 (file)
@@ -312,8 +312,6 @@ err1;       stb     r0,0(r3)
        lis     r8,0x8000       /* GO=1 */
        clrldi  r8,r8,32
 
-.machine push
-.machine "power4"
        /* setup read stream 0 */
        dcbt    0,r6,0b01000   /* addr from */
        dcbt    0,r7,0b01010   /* length and depth from */
@@ -322,7 +320,6 @@ err1;       stb     r0,0(r3)
        dcbtst  0,r10,0b01010  /* length and depth to */
        eieio
        dcbt    0,r8,0b01010    /* all streams GO */
-.machine pop
 
        beq     cr1,.Lunwind_stack_nonvmx_copy
 
index f4d6088e2d5390b937f60e35819496dfeab17858..8d8265be1a5941745eedd80edc26c01826eccba9 100644 (file)
@@ -19,9 +19,11 @@ BEGIN_FTR_SECTION
        std     r3,-STACKFRAMESIZE+STK_REG(R31)(r1)     /* save destination pointer for return value */
 #endif
 FTR_SECTION_ELSE
+#ifdef CONFIG_PPC_BOOK3S_64
 #ifndef SELFTEST
        b       memcpy_power7
 #endif
+#endif
 ALT_FTR_SECTION_END_IFCLR(CPU_FTR_VMX_COPY)
 #ifdef __LITTLE_ENDIAN__
        /* dumb little-endian memcpy that will get replaced at runtime */
index 193909abd18b3edea2170601081753f70cc39577..df7de9d3da087fc987e712bf40de3c557027c94e 100644 (file)
@@ -259,15 +259,12 @@ _GLOBAL(memcpy_power7)
        lis     r8,0x8000       /* GO=1 */
        clrldi  r8,r8,32
 
-.machine push
-.machine "power4"
        dcbt    0,r6,0b01000
        dcbt    0,r7,0b01010
        dcbtst  0,r9,0b01000
        dcbtst  0,r10,0b01010
        eieio
        dcbt    0,r8,0b01010    /* GO */
-.machine pop
 
        beq     cr1,.Lunwind_stack_nonvmx_copy