Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 41379
b: refs/heads/master
c: 656be92
h: refs/heads/master
i:
  41377: 7979055
  41375: bbe5985
v: v3
  • Loading branch information
Atsushi Nemoto authored and Ralf Baechle committed Nov 30, 2006
1 parent e0a256b commit 67de2b6
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 56ae58333031bb0564c141f955d1e42276cade55
refs/heads/master: 656be92f9ae194ed62bc81310a4589a7cd765f13
4 changes: 1 addition & 3 deletions trunk/arch/mips/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ cflags-y += -mabi=64
ifdef CONFIG_BUILD_ELF64
cflags-y += $(call cc-option,-mno-explicit-relocs)
else
# -msym32 can not be used for modules since they are loaded into XKSEG
CFLAGS_MODULE += $(call cc-option,-mno-explicit-relocs)
CFLAGS_KERNEL += $(call cc-option,-msym32)
cflags-y += $(call cc-option,-msym32)
endif
endif

Expand Down
3 changes: 3 additions & 0 deletions trunk/arch/mips/kernel/head.S
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ NESTED(smp_bootstrap, 16, sp)
*/
page swapper_pg_dir, _PGD_ORDER
#ifdef CONFIG_64BIT
#if defined(CONFIG_MODULES) && !defined(CONFIG_BUILD_ELF64)
page module_pg_dir, _PGD_ORDER
#endif
page invalid_pmd_table, _PMD_ORDER
#endif
page invalid_pte_table, _PTE_ORDER
15 changes: 15 additions & 0 deletions trunk/arch/mips/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <asm/pgtable.h> /* MODULE_START */

struct mips_hi16 {
struct mips_hi16 *next;
Expand All @@ -43,9 +44,23 @@ static DEFINE_SPINLOCK(dbe_lock);

void *module_alloc(unsigned long size)
{
#ifdef MODULE_START
struct vm_struct *area;

size = PAGE_ALIGN(size);
if (!size)
return NULL;

area = __get_vm_area(size, VM_ALLOC, MODULE_START, MODULE_END);
if (!area)
return NULL;

return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL);
#else
if (size == 0)
return NULL;
return vmalloc(size);
#endif
}

/* Free memory returned from module_alloc */
Expand Down
4 changes: 4 additions & 0 deletions trunk/arch/mips/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
*/
if (unlikely(address >= VMALLOC_START && address <= VMALLOC_END))
goto vmalloc_fault;
#ifdef MODULE_START
if (unlikely(address >= MODULE_START && address < MODULE_END))
goto vmalloc_fault;
#endif

/*
* If we're in an interrupt or have no user
Expand Down
3 changes: 3 additions & 0 deletions trunk/arch/mips/mm/pgtable-64.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ void __init pagetable_init(void)

/* Initialize the entire pgd. */
pgd_init((unsigned long)swapper_pg_dir);
#ifdef MODULE_START
pgd_init((unsigned long)module_pg_dir);
#endif
pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table);

pgd_base = swapper_pg_dir;
Expand Down
55 changes: 55 additions & 0 deletions trunk/arch/mips/mm/tlbex.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ enum label_id {
label_invalid,
label_second_part,
label_leave,
#ifdef MODULE_START
label_module_alloc,
#endif
label_vmalloc,
label_vmalloc_done,
label_tlbw_hazard,
Expand Down Expand Up @@ -455,6 +458,9 @@ static __init void build_label(struct label **lab, u32 *addr,

L_LA(_second_part)
L_LA(_leave)
#ifdef MODULE_START
L_LA(_module_alloc)
#endif
L_LA(_vmalloc)
L_LA(_vmalloc_done)
L_LA(_tlbw_hazard)
Expand Down Expand Up @@ -686,6 +692,13 @@ static void __init il_bgezl(u32 **p, struct reloc **r, unsigned int reg,
i_bgezl(p, reg, 0);
}

static void __init __attribute__((unused))
il_bgez(u32 **p, struct reloc **r, unsigned int reg, enum label_id l)
{
r_mips_pc16(r, *p, l);
i_bgez(p, reg, 0);
}

/* The only general purpose registers allowed in TLB handlers. */
#define K0 26
#define K1 27
Expand Down Expand Up @@ -970,7 +983,11 @@ build_get_pmde64(u32 **p, struct label **l, struct reloc **r,
* The vmalloc handling is not in the hotpath.
*/
i_dmfc0(p, tmp, C0_BADVADDR);
#ifdef MODULE_START
il_bltz(p, r, tmp, label_module_alloc);
#else
il_bltz(p, r, tmp, label_vmalloc);
#endif
/* No i_nop needed here, since the next insn doesn't touch TMP. */

#ifdef CONFIG_SMP
Expand Down Expand Up @@ -1023,8 +1040,46 @@ build_get_pgd_vmalloc64(u32 **p, struct label **l, struct reloc **r,
{
long swpd = (long)swapper_pg_dir;

#ifdef MODULE_START
long modd = (long)module_pg_dir;

l_module_alloc(l, *p);
/*
* Assumption:
* VMALLOC_START >= 0xc000000000000000UL
* MODULE_START >= 0xe000000000000000UL
*/
i_SLL(p, ptr, bvaddr, 2);
il_bgez(p, r, ptr, label_vmalloc);

if (in_compat_space_p(MODULE_START) && !rel_lo(MODULE_START)) {
i_lui(p, ptr, rel_hi(MODULE_START)); /* delay slot */
} else {
/* unlikely configuration */
i_nop(p); /* delay slot */
i_LA(p, ptr, MODULE_START);
}
i_dsubu(p, bvaddr, bvaddr, ptr);

if (in_compat_space_p(modd) && !rel_lo(modd)) {
il_b(p, r, label_vmalloc_done);
i_lui(p, ptr, rel_hi(modd));
} else {
i_LA_mostly(p, ptr, modd);
il_b(p, r, label_vmalloc_done);
i_daddiu(p, ptr, ptr, rel_lo(modd));
}

l_vmalloc(l, *p);
if (in_compat_space_p(MODULE_START) && !rel_lo(MODULE_START) &&
MODULE_START << 32 == VMALLOC_START)
i_dsll32(p, ptr, ptr, 0); /* typical case */
else
i_LA(p, ptr, VMALLOC_START);
#else
l_vmalloc(l, *p);
i_LA(p, ptr, VMALLOC_START);
#endif
i_dsubu(p, bvaddr, bvaddr, ptr);

if (in_compat_space_p(swpd) && !rel_lo(swpd)) {
Expand Down
13 changes: 13 additions & 0 deletions trunk/include/asm-mips/pgtable-64.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <asm/addrspace.h>
#include <asm/page.h>
#include <asm/cachectl.h>
#include <asm/fixmap.h>

#include <asm-generic/pgtable-nopud.h>

Expand Down Expand Up @@ -103,6 +104,13 @@
#define VMALLOC_START MAP_BASE
#define VMALLOC_END \
(VMALLOC_START + PTRS_PER_PGD * PTRS_PER_PMD * PTRS_PER_PTE * PAGE_SIZE)
#if defined(CONFIG_MODULES) && !defined(CONFIG_BUILD_ELF64) && \
VMALLOC_START != CKSSEG
/* Load modules into 32bit-compatible segment. */
#define MODULE_START CKSSEG
#define MODULE_END (FIXADDR_START-2*PAGE_SIZE)
extern pgd_t module_pg_dir[PTRS_PER_PGD];
#endif

#define pte_ERROR(e) \
printk("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e))
Expand Down Expand Up @@ -174,7 +182,12 @@ static inline void pud_clear(pud_t *pudp)
#define __pmd_offset(address) pmd_index(address)

/* to find an entry in a kernel page-table-directory */
#ifdef MODULE_START
#define pgd_offset_k(address) \
((address) >= MODULE_START ? module_pg_dir : pgd_offset(&init_mm, 0UL))
#else
#define pgd_offset_k(address) pgd_offset(&init_mm, 0UL)
#endif

#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
Expand Down

0 comments on commit 67de2b6

Please sign in to comment.