Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 85767
b: refs/heads/master
c: 31eedd8
h: refs/heads/master
i:
  85765: a9dfd3c
  85763: a3a63da
  85759: 71053cf
v: v3
  • Loading branch information
Thomas Gleixner committed Feb 18, 2008
1 parent b9a9dd0 commit 202e156
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 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: c31c7d4844ea4817692ae16bf70f9c96c05a50eb
refs/heads/master: 31eedd823c1bf3650c450346a0d0c39431034eb9
3 changes: 3 additions & 0 deletions trunk/arch/x86/kernel/head64.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ void __init x86_64_start_kernel(char * real_mode_data)
/* Make NULL pointers segfault */
zap_identity_mappings();

/* Cleanup the over mapped high alias */
cleanup_highmap();

for (i = 0; i < IDT_ENTRIES; i++) {
#ifdef CONFIG_EARLY_PRINTK
set_intr_gate(i, &early_idt_handlers[i]);
Expand Down
7 changes: 6 additions & 1 deletion trunk/arch/x86/kernel/head_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,13 @@ startup_64:
movq %rdx, 0(%rbx, %rax, 8)
ident_complete:

/* Fixup the kernel text+data virtual addresses
/*
* Fixup the kernel text+data virtual addresses. Note that
* we might write invalid pmds, when the kernel is relocated
* cleanup_highmap() fixes this up along with the mappings
* beyond _end.
*/

leaq level2_kernel_pgt(%rip), %rdi
leaq 4096(%rdi), %r8
/* See if it is a valid page table entry */
Expand Down
27 changes: 27 additions & 0 deletions trunk/arch/x86/mm/init_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,33 @@ set_pte_phys(unsigned long vaddr, unsigned long phys, pgprot_t prot)
__flush_tlb_one(vaddr);
}

/*
* The head.S code sets up the kernel high mapping from:
* __START_KERNEL_map to __START_KERNEL_map + KERNEL_TEXT_SIZE
*
* phys_addr holds the negative offset to the kernel, which is added
* to the compile time generated pmds. This results in invalid pmds up
* to the point where we hit the physaddr 0 mapping.
*
* We limit the mappings to the region from _text to _end. _end is
* rounded up to the 2MB boundary. This catches the invalid pmds as
* well, as they are located before _text:
*/
void __init cleanup_highmap(void)
{
unsigned long vaddr = __START_KERNEL_map;
unsigned long end = round_up((unsigned long)_end, PMD_SIZE) - 1;
pmd_t *pmd = level2_kernel_pgt;
pmd_t *last_pmd = pmd + PTRS_PER_PMD;

for (; pmd < last_pmd; pmd++, vaddr += PMD_SIZE) {
if (!pmd_present(*pmd))
continue;
if (vaddr < (unsigned long) _text || vaddr > end)
set_pmd(pmd, __pmd(0));
}
}

/* NOTE: this is meant to be run only at boot */
void __init
__set_fixmap(enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
Expand Down
1 change: 1 addition & 0 deletions trunk/include/asm-x86/pgtable_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ static inline int pud_large(pud_t pte)
#define __swp_entry_to_pte(x) ((pte_t) { .pte = (x).val })

extern int kern_addr_valid(unsigned long addr);
extern void cleanup_highmap(void);

#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
remap_pfn_range(vma, vaddr, pfn, size, prot)
Expand Down

0 comments on commit 202e156

Please sign in to comment.