Skip to content

Commit b86206e

Browse files
powerpc: Fix branch patching code for ABIv2
The MMU hashtable and SLB branch patching code uses function pointers for the update sites. This creates a difference between ABIv1 and ABIv2 because we don't have function descriptors on ABIv2. Get rid of the function pointer and just point at the update sites directly. This works on both ABIs. Signed-off-by: Anton Blanchard <anton@samba.org>
1 parent 26f9206 commit b86206e

4 files changed

Lines changed: 47 additions & 33 deletions

File tree

‎arch/powerpc/mm/hash_low_64.S‎

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ htab_insert_pte:
201201
li r8,MMU_PAGE_4K /* page size */
202202
li r9,MMU_PAGE_4K /* actual page size */
203203
ld r10,STK_PARAM(R9)(r1) /* segment size */
204-
_GLOBAL(htab_call_hpte_insert1)
204+
.globl htab_call_hpte_insert1
205+
htab_call_hpte_insert1:
205206
bl . /* Patched by htab_finish_init() */
206207
cmpdi 0,r3,0
207208
bge htab_pte_insert_ok /* Insertion successful */
@@ -225,7 +226,8 @@ _GLOBAL(htab_call_hpte_insert1)
225226
li r8,MMU_PAGE_4K /* page size */
226227
li r9,MMU_PAGE_4K /* actual page size */
227228
ld r10,STK_PARAM(R9)(r1) /* segment size */
228-
_GLOBAL(htab_call_hpte_insert2)
229+
.globl htab_call_hpte_insert2
230+
htab_call_hpte_insert2:
229231
bl . /* Patched by htab_finish_init() */
230232
cmpdi 0,r3,0
231233
bge+ htab_pte_insert_ok /* Insertion successful */
@@ -242,7 +244,8 @@ _GLOBAL(htab_call_hpte_insert2)
242244
2: and r0,r5,r27
243245
rldicr r3,r0,3,63-3 /* r0 = (hash & mask) << 3 */
244246
/* Call ppc_md.hpte_remove */
245-
_GLOBAL(htab_call_hpte_remove)
247+
.globl htab_call_hpte_remove
248+
htab_call_hpte_remove:
246249
bl . /* Patched by htab_finish_init() */
247250

248251
/* Try all again */
@@ -296,7 +299,8 @@ htab_modify_pte:
296299
li r7,MMU_PAGE_4K /* actual page size */
297300
ld r8,STK_PARAM(R9)(r1) /* segment size */
298301
ld r9,STK_PARAM(R8)(r1) /* get "local" param */
299-
_GLOBAL(htab_call_hpte_updatepp)
302+
.globl htab_call_hpte_updatepp
303+
htab_call_hpte_updatepp:
300304
bl . /* Patched by htab_finish_init() */
301305

302306
/* if we failed because typically the HPTE wasn't really here
@@ -526,7 +530,8 @@ htab_special_pfn:
526530
li r8,MMU_PAGE_4K /* page size */
527531
li r9,MMU_PAGE_4K /* actual page size */
528532
ld r10,STK_PARAM(R9)(r1) /* segment size */
529-
_GLOBAL(htab_call_hpte_insert1)
533+
.globl htab_call_hpte_insert1
534+
htab_call_hpte_insert1:
530535
bl . /* patched by htab_finish_init() */
531536
cmpdi 0,r3,0
532537
bge htab_pte_insert_ok /* Insertion successful */
@@ -554,7 +559,8 @@ _GLOBAL(htab_call_hpte_insert1)
554559
li r8,MMU_PAGE_4K /* page size */
555560
li r9,MMU_PAGE_4K /* actual page size */
556561
ld r10,STK_PARAM(R9)(r1) /* segment size */
557-
_GLOBAL(htab_call_hpte_insert2)
562+
.globl htab_call_hpte_insert2
563+
htab_call_hpte_insert2:
558564
bl . /* patched by htab_finish_init() */
559565
cmpdi 0,r3,0
560566
bge+ htab_pte_insert_ok /* Insertion successful */
@@ -571,7 +577,8 @@ _GLOBAL(htab_call_hpte_insert2)
571577
2: and r0,r5,r27
572578
rldicr r3,r0,3,63-3 /* r0 = (hash & mask) << 3 */
573579
/* Call ppc_md.hpte_remove */
574-
_GLOBAL(htab_call_hpte_remove)
580+
.globl htab_call_hpte_remove
581+
htab_call_hpte_remove:
575582
bl . /* patched by htab_finish_init() */
576583

577584
/* Try all again */
@@ -660,7 +667,8 @@ htab_modify_pte:
660667
li r7,MMU_PAGE_4K /* actual page size */
661668
ld r8,STK_PARAM(R9)(r1) /* segment size */
662669
ld r9,STK_PARAM(R8)(r1) /* get "local" param */
663-
_GLOBAL(htab_call_hpte_updatepp)
670+
.globl htab_call_hpte_updatepp
671+
htab_call_hpte_updatepp:
664672
bl . /* patched by htab_finish_init() */
665673

666674
/* if we failed because typically the HPTE wasn't really here
@@ -857,7 +865,8 @@ ht64_insert_pte:
857865
li r8,MMU_PAGE_64K
858866
li r9,MMU_PAGE_64K /* actual page size */
859867
ld r10,STK_PARAM(R9)(r1) /* segment size */
860-
_GLOBAL(ht64_call_hpte_insert1)
868+
.globl ht64_call_hpte_insert1
869+
ht64_call_hpte_insert1:
861870
bl . /* patched by htab_finish_init() */
862871
cmpdi 0,r3,0
863872
bge ht64_pte_insert_ok /* Insertion successful */
@@ -881,7 +890,8 @@ _GLOBAL(ht64_call_hpte_insert1)
881890
li r8,MMU_PAGE_64K
882891
li r9,MMU_PAGE_64K /* actual page size */
883892
ld r10,STK_PARAM(R9)(r1) /* segment size */
884-
_GLOBAL(ht64_call_hpte_insert2)
893+
.globl ht64_call_hpte_insert2
894+
ht64_call_hpte_insert2:
885895
bl . /* patched by htab_finish_init() */
886896
cmpdi 0,r3,0
887897
bge+ ht64_pte_insert_ok /* Insertion successful */
@@ -898,7 +908,8 @@ _GLOBAL(ht64_call_hpte_insert2)
898908
2: and r0,r5,r27
899909
rldicr r3,r0,3,63-3 /* r0 = (hash & mask) << 3 */
900910
/* Call ppc_md.hpte_remove */
901-
_GLOBAL(ht64_call_hpte_remove)
911+
.globl ht64_call_hpte_remove
912+
ht64_call_hpte_remove:
902913
bl . /* patched by htab_finish_init() */
903914

904915
/* Try all again */
@@ -952,7 +963,8 @@ ht64_modify_pte:
952963
li r7,MMU_PAGE_64K /* actual page size */
953964
ld r8,STK_PARAM(R9)(r1) /* segment size */
954965
ld r9,STK_PARAM(R8)(r1) /* get "local" param */
955-
_GLOBAL(ht64_call_hpte_updatepp)
966+
.globl ht64_call_hpte_updatepp
967+
ht64_call_hpte_updatepp:
956968
bl . /* patched by htab_finish_init() */
957969

958970
/* if we failed because typically the HPTE wasn't really here

‎arch/powerpc/mm/hash_utils_64.c‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -603,19 +603,18 @@ int remove_section_mapping(unsigned long start, unsigned long end)
603603
}
604604
#endif /* CONFIG_MEMORY_HOTPLUG */
605605

606+
extern u32 htab_call_hpte_insert1[];
607+
extern u32 htab_call_hpte_insert2[];
608+
extern u32 htab_call_hpte_remove[];
609+
extern u32 htab_call_hpte_updatepp[];
610+
extern u32 ht64_call_hpte_insert1[];
611+
extern u32 ht64_call_hpte_insert2[];
612+
extern u32 ht64_call_hpte_remove[];
613+
extern u32 ht64_call_hpte_updatepp[];
614+
606615
static void __init htab_finish_init(void)
607616
{
608-
extern unsigned int *htab_call_hpte_insert1;
609-
extern unsigned int *htab_call_hpte_insert2;
610-
extern unsigned int *htab_call_hpte_remove;
611-
extern unsigned int *htab_call_hpte_updatepp;
612-
613617
#ifdef CONFIG_PPC_HAS_HASH_64K
614-
extern unsigned int *ht64_call_hpte_insert1;
615-
extern unsigned int *ht64_call_hpte_insert2;
616-
extern unsigned int *ht64_call_hpte_remove;
617-
extern unsigned int *ht64_call_hpte_updatepp;
618-
619618
patch_branch(ht64_call_hpte_insert1,
620619
ppc_function_entry(ppc_md.hpte_insert),
621620
BRANCH_SET_LINK);
@@ -628,7 +627,6 @@ static void __init htab_finish_init(void)
628627
patch_branch(ht64_call_hpte_updatepp,
629628
ppc_function_entry(ppc_md.hpte_updatepp),
630629
BRANCH_SET_LINK);
631-
632630
#endif /* CONFIG_PPC_HAS_HASH_64K */
633631

634632
patch_branch(htab_call_hpte_insert1,

‎arch/powerpc/mm/slb.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,14 @@ static inline void patch_slb_encoding(unsigned int *insn_addr,
256256
patch_instruction(insn_addr, insn);
257257
}
258258

259+
extern u32 slb_compare_rr_to_size[];
260+
extern u32 slb_miss_kernel_load_linear[];
261+
extern u32 slb_miss_kernel_load_io[];
262+
extern u32 slb_compare_rr_to_size[];
263+
extern u32 slb_miss_kernel_load_vmemmap[];
264+
259265
void slb_set_size(u16 size)
260266
{
261-
extern unsigned int *slb_compare_rr_to_size;
262-
263267
if (mmu_slb_size == size)
264268
return;
265269

@@ -272,11 +276,7 @@ void slb_initialize(void)
272276
unsigned long linear_llp, vmalloc_llp, io_llp;
273277
unsigned long lflags, vflags;
274278
static int slb_encoding_inited;
275-
extern unsigned int *slb_miss_kernel_load_linear;
276-
extern unsigned int *slb_miss_kernel_load_io;
277-
extern unsigned int *slb_compare_rr_to_size;
278279
#ifdef CONFIG_SPARSEMEM_VMEMMAP
279-
extern unsigned int *slb_miss_kernel_load_vmemmap;
280280
unsigned long vmemmap_llp;
281281
#endif
282282

‎arch/powerpc/mm/slb_low.S‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ _GLOBAL(slb_allocate_realmode)
5959
/* Linear mapping encoding bits, the "li" instruction below will
6060
* be patched by the kernel at boot
6161
*/
62-
_GLOBAL(slb_miss_kernel_load_linear)
62+
.globl slb_miss_kernel_load_linear
63+
slb_miss_kernel_load_linear:
6364
li r11,0
6465
/*
6566
* context = (MAX_USER_CONTEXT) + ((ea >> 60) - 0xc) + 1
@@ -79,7 +80,8 @@ END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT)
7980
/* Check virtual memmap region. To be patches at kernel boot */
8081
cmpldi cr0,r9,0xf
8182
bne 1f
82-
_GLOBAL(slb_miss_kernel_load_vmemmap)
83+
.globl slb_miss_kernel_load_vmemmap
84+
slb_miss_kernel_load_vmemmap:
8385
li r11,0
8486
b 6f
8587
1:
@@ -95,7 +97,8 @@ _GLOBAL(slb_miss_kernel_load_vmemmap)
9597
b 6f
9698
5:
9799
/* IO mapping */
98-
_GLOBAL(slb_miss_kernel_load_io)
100+
.globl slb_miss_kernel_load_io
101+
slb_miss_kernel_load_io:
99102
li r11,0
100103
6:
101104
/*
@@ -250,7 +253,8 @@ slb_finish_load:
250253
7: ld r10,PACASTABRR(r13)
251254
addi r10,r10,1
252255
/* This gets soft patched on boot. */
253-
_GLOBAL(slb_compare_rr_to_size)
256+
.globl slb_compare_rr_to_size
257+
slb_compare_rr_to_size:
254258
cmpldi r10,0
255259

256260
blt+ 4f

0 commit comments

Comments
 (0)