diff options
| author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-05-05 06:33:10 -0400 |
|---|---|---|
| committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-05-05 06:57:12 -0400 |
| commit | f6869e7fe657bd977e72954cd78c5871a6a4f71d (patch) | |
| tree | 1e34a4bb36cde4b541d7344599e65b541bb4bee7 | |
| parent | 5a4e58bc693f04aa650219784e5e339e0db6b902 (diff) | |
| parent | cec4b7eaf09d330e94e8e94133d360e6f1855974 (diff) | |
Merge remote-tracking branch 'anton/abiv2' into next
This series adds support for building the powerpc 64-bit
LE kernel using the new ABI v2. We already supported
running ABI v2 userspace programs but this adds support
for building the kernel itself using the new ABI.
55 files changed, 902 insertions, 680 deletions
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 31b96942c0a7..68cde2f8a12c 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile | |||
| @@ -113,8 +113,13 @@ else | |||
| 113 | endif | 113 | endif |
| 114 | endif | 114 | endif |
| 115 | 115 | ||
| 116 | CFLAGS-$(CONFIG_PPC64) := -mtraceback=no -mcall-aixdesc | 116 | CFLAGS-$(CONFIG_PPC64) := -mtraceback=no |
| 117 | CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1) | 117 | ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) |
| 118 | CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,-mcall-aixdesc) | ||
| 119 | AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2) | ||
| 120 | else | ||
| 121 | CFLAGS-$(CONFIG_PPC64) += -mcall-aixdesc | ||
| 122 | endif | ||
| 118 | CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,-mminimal-toc) | 123 | CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,-mminimal-toc) |
| 119 | CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions) | 124 | CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions) |
| 120 | CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD) | 125 | CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD) |
| @@ -151,7 +156,7 @@ endif | |||
| 151 | CFLAGS-$(CONFIG_TUNE_CELL) += $(call cc-option,-mtune=cell) | 156 | CFLAGS-$(CONFIG_TUNE_CELL) += $(call cc-option,-mtune=cell) |
| 152 | 157 | ||
| 153 | KBUILD_CPPFLAGS += -Iarch/$(ARCH) | 158 | KBUILD_CPPFLAGS += -Iarch/$(ARCH) |
| 154 | KBUILD_AFLAGS += -Iarch/$(ARCH) | 159 | KBUILD_AFLAGS += -Iarch/$(ARCH) $(AFLAGS-y) |
| 155 | KBUILD_CFLAGS += -msoft-float -pipe -Iarch/$(ARCH) $(CFLAGS-y) | 160 | KBUILD_CFLAGS += -msoft-float -pipe -Iarch/$(ARCH) $(CFLAGS-y) |
| 156 | CPP = $(CC) -E $(KBUILD_CFLAGS) | 161 | CPP = $(CC) -E $(KBUILD_CFLAGS) |
| 157 | 162 | ||
diff --git a/arch/powerpc/boot/util.S b/arch/powerpc/boot/util.S index 6636b1d7821b..243b8497d58b 100644 --- a/arch/powerpc/boot/util.S +++ b/arch/powerpc/boot/util.S | |||
| @@ -45,7 +45,7 @@ udelay: | |||
| 45 | mfspr r4,SPRN_PVR | 45 | mfspr r4,SPRN_PVR |
| 46 | srwi r4,r4,16 | 46 | srwi r4,r4,16 |
| 47 | cmpwi 0,r4,1 /* 601 ? */ | 47 | cmpwi 0,r4,1 /* 601 ? */ |
| 48 | bne .udelay_not_601 | 48 | bne .Ludelay_not_601 |
| 49 | 00: li r0,86 /* Instructions / microsecond? */ | 49 | 00: li r0,86 /* Instructions / microsecond? */ |
| 50 | mtctr r0 | 50 | mtctr r0 |
| 51 | 10: addi r0,r0,0 /* NOP */ | 51 | 10: addi r0,r0,0 /* NOP */ |
| @@ -54,7 +54,7 @@ udelay: | |||
| 54 | bne 00b | 54 | bne 00b |
| 55 | blr | 55 | blr |
| 56 | 56 | ||
| 57 | .udelay_not_601: | 57 | .Ludelay_not_601: |
| 58 | mulli r4,r3,1000 /* nanoseconds */ | 58 | mulli r4,r3,1000 /* nanoseconds */ |
| 59 | /* Change r4 to be the number of ticks using: | 59 | /* Change r4 to be the number of ticks using: |
| 60 | * (nanoseconds + (timebase_period_ns - 1 )) / timebase_period_ns | 60 | * (nanoseconds + (timebase_period_ns - 1 )) / timebase_period_ns |
diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h index 97e02f985df8..37991e154ef8 100644 --- a/arch/powerpc/include/asm/code-patching.h +++ b/arch/powerpc/include/asm/code-patching.h | |||
| @@ -42,15 +42,47 @@ void __patch_exception(int exc, unsigned long addr); | |||
| 42 | } while (0) | 42 | } while (0) |
| 43 | #endif | 43 | #endif |
| 44 | 44 | ||
| 45 | #define OP_RT_RA_MASK 0xffff0000UL | ||
| 46 | #define LIS_R2 0x3c020000UL | ||
| 47 | #define ADDIS_R2_R12 0x3c4c0000UL | ||
| 48 | #define ADDI_R2_R2 0x38420000UL | ||
| 49 | |||
| 45 | static inline unsigned long ppc_function_entry(void *func) | 50 | static inline unsigned long ppc_function_entry(void *func) |
| 46 | { | 51 | { |
| 47 | #ifdef CONFIG_PPC64 | 52 | #if defined(CONFIG_PPC64) |
| 53 | #if defined(_CALL_ELF) && _CALL_ELF == 2 | ||
| 54 | u32 *insn = func; | ||
| 55 | |||
| 56 | /* | ||
| 57 | * A PPC64 ABIv2 function may have a local and a global entry | ||
| 58 | * point. We need to use the local entry point when patching | ||
| 59 | * functions, so identify and step over the global entry point | ||
| 60 | * sequence. | ||
| 61 | * | ||
| 62 | * The global entry point sequence is always of the form: | ||
| 63 | * | ||
| 64 | * addis r2,r12,XXXX | ||
| 65 | * addi r2,r2,XXXX | ||
| 66 | * | ||
| 67 | * A linker optimisation may convert the addis to lis: | ||
| 68 | * | ||
| 69 | * lis r2,XXXX | ||
| 70 | * addi r2,r2,XXXX | ||
| 71 | */ | ||
| 72 | if ((((*insn & OP_RT_RA_MASK) == ADDIS_R2_R12) || | ||
| 73 | ((*insn & OP_RT_RA_MASK) == LIS_R2)) && | ||
| 74 | ((*(insn+1) & OP_RT_RA_MASK) == ADDI_R2_R2)) | ||
| 75 | return (unsigned long)(insn + 2); | ||
| 76 | else | ||
| 77 | return (unsigned long)func; | ||
| 78 | #else | ||
| 48 | /* | 79 | /* |
| 49 | * On PPC64 the function pointer actually points to the function's | 80 | * On PPC64 ABIv1 the function pointer actually points to the |
| 50 | * descriptor. The first entry in the descriptor is the address | 81 | * function's descriptor. The first entry in the descriptor is the |
