Skip to content

Commit 41b85a1

Browse files
committed
parisc: Map kernel text and data on huge pages
Adjust the linker script and map_pages() to map kernel text and data on physical 1MB huge/large pages. Signed-off-by: Helge Deller <[email protected]>
1 parent 736d216 commit 41b85a1

File tree

3 files changed

+31
-26
lines changed

3 files changed

+31
-26
lines changed

arch/parisc/kernel/asm-offsets.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,14 @@ int main(void)
289289
DEFINE(ASM_PTE_ENTRY_SIZE, PTE_ENTRY_SIZE);
290290
DEFINE(ASM_PFN_PTE_SHIFT, PFN_PTE_SHIFT);
291291
DEFINE(ASM_PT_INITIAL, PT_INITIAL);
292+
BLANK();
293+
/* HUGEPAGE_SIZE is only used in vmlinux.lds.S to align kernel text
294+
* and kernel data on physical huge pages */
295+
#ifdef CONFIG_HUGETLB_PAGE
296+
DEFINE(HUGEPAGE_SIZE, 1UL << REAL_HPAGE_SHIFT);
297+
#else
298+
DEFINE(HUGEPAGE_SIZE, PAGE_SIZE);
299+
#endif
292300
BLANK();
293301
DEFINE(EXCDATA_IP, offsetof(struct exception_data, fault_ip));
294302
DEFINE(EXCDATA_SPACE, offsetof(struct exception_data, fault_space));

arch/parisc/kernel/vmlinux.lds.S

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ SECTIONS
6060
EXIT_DATA
6161
}
6262
PERCPU_SECTION(8)
63-
. = ALIGN(PAGE_SIZE);
63+
. = ALIGN(HUGEPAGE_SIZE);
6464
__init_end = .;
6565
/* freed after init ends here */
6666

@@ -116,7 +116,7 @@ SECTIONS
116116
* that we can properly leave these
117117
* as writable
118118
*/
119-
. = ALIGN(PAGE_SIZE);
119+
. = ALIGN(HUGEPAGE_SIZE);
120120
data_start = .;
121121

122122
EXCEPTION_TABLE(8)
@@ -135,8 +135,11 @@ SECTIONS
135135
_edata = .;
136136

137137
/* BSS */
138-
BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 8)
138+
BSS_SECTION(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE)
139+
140+
/* bootmap is allocated in setup_bootmem() directly behind bss. */
139141

142+
. = ALIGN(HUGEPAGE_SIZE);
140143
_end = . ;
141144

142145
STABS_DEBUG

arch/parisc/mm/init.c

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -407,15 +407,11 @@ static void __init map_pages(unsigned long start_vaddr,
407407
unsigned long vaddr;
408408
unsigned long ro_start;
409409
unsigned long ro_end;
410-
unsigned long fv_addr;
411-
unsigned long gw_addr;
412-
extern const unsigned long fault_vector_20;
413-
extern void * const linux_gateway_page;
410+
unsigned long kernel_end;
414411

415412
ro_start = __pa((unsigned long)_text);
416413
ro_end = __pa((unsigned long)&data_start);
417-
fv_addr = __pa((unsigned long)&fault_vector_20) & PAGE_MASK;
418-
gw_addr = __pa((unsigned long)&linux_gateway_page) & PAGE_MASK;
414+
kernel_end = __pa((unsigned long)&_end);
419415

420416
end_paddr = start_paddr + size;
421417

@@ -473,24 +469,25 @@ static void __init map_pages(unsigned long start_vaddr,
473469
for (tmp2 = start_pte; tmp2 < PTRS_PER_PTE; tmp2++, pg_table++) {
474470
pte_t pte;
475471

476-
/*
477-
* Map the fault vector writable so we can
478-
* write the HPMC checksum.
479-
*/
480472
if (force)
481473
pte = __mk_pte(address, pgprot);
482-
else if (parisc_text_address(vaddr) &&
483-
address != fv_addr)
474+
else if (parisc_text_address(vaddr)) {
484475
pte = __mk_pte(address, PAGE_KERNEL_EXEC);
476+
if (address >= ro_start && address < kernel_end)
477+
pte = pte_mkhuge(pte);
478+
}
485479
else
486480
#if defined(CONFIG_PARISC_PAGE_SIZE_4KB)
487-
if (address >= ro_start && address < ro_end
488-
&& address != fv_addr
489-
&& address != gw_addr)
490-
pte = __mk_pte(address, PAGE_KERNEL_RO);
491-
else
481+
if (address >= ro_start && address < ro_end) {
482+
pte = __mk_pte(address, PAGE_KERNEL_EXEC);
483+
pte = pte_mkhuge(pte);
484+
} else
492485
#endif
486+
{
493487
pte = __mk_pte(address, pgprot);
488+
if (address >= ro_start && address < kernel_end)
489+
pte = pte_mkhuge(pte);
490+
}
494491

495492
if (address >= end_paddr) {
496493
if (force)
@@ -534,15 +531,12 @@ void free_initmem(void)
534531

535532
/* force the kernel to see the new TLB entries */
536533
__flush_tlb_range(0, init_begin, init_end);
537-
/* Attempt to catch anyone trying to execute code here
538-
* by filling the page with BRK insns.
539-
*/
540-
memset((void *)init_begin, 0x00, init_end - init_begin);
534+
541535
/* finally dump all the instructions which were cached, since the
542536
* pages are no-longer executable */
543537
flush_icache_range(init_begin, init_end);
544538

545-
free_initmem_default(-1);
539+
free_initmem_default(POISON_FREE_INITMEM);
546540

547541
/* set up a new led state on systems shipped LED State panel */
548542
pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BCOMPLETE);
@@ -712,8 +706,8 @@ static void __init pagetable_init(void)
712706
unsigned long size;
713707

714708
start_paddr = pmem_ranges[range].start_pfn << PAGE_SHIFT;
715-
end_paddr = start_paddr + (pmem_ranges[range].pages << PAGE_SHIFT);
716709
size = pmem_ranges[range].pages << PAGE_SHIFT;
710+
end_paddr = start_paddr + size;
717711

718712
map_pages((unsigned long)__va(start_paddr), start_paddr,
719713
size, PAGE_KERNEL, 0);

0 commit comments

Comments
 (0)