Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 53810
b: refs/heads/master
c: 6fb1475
h: refs/heads/master
v: v3
  • Loading branch information
Jan Beulich authored and Andi Kleen committed May 2, 2007
1 parent a56a748 commit 3033cf9
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 24 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: d01ad8dd56527be72947b4b9997bb2c05783c3ed
refs/heads/master: 6fb14755a676282a4e6caa05a08c92db8e45cfff
4 changes: 2 additions & 2 deletions trunk/arch/i386/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ SECTIONS
__stop___ex_table = .;
}

RODATA

BUG_TABLE

. = ALIGN(4);
Expand All @@ -72,6 +70,8 @@ SECTIONS
__tracedata_end = .;
}

RODATA

/* writeable */
. = ALIGN(4096);
.data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */
Expand Down
25 changes: 19 additions & 6 deletions trunk/arch/i386/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/init.h>
#include <linux/highmem.h>
#include <linux/pagemap.h>
#include <linux/pfn.h>
#include <linux/poison.h>
#include <linux/bootmem.h>
#include <linux/slab.h>
Expand Down Expand Up @@ -751,13 +752,25 @@ static int noinline do_test_wp_bit(void)

void mark_rodata_ro(void)
{
unsigned long addr = (unsigned long)__start_rodata;
unsigned long start = PFN_ALIGN(_text);
unsigned long size = PFN_ALIGN(_etext) - start;

for (; addr < (unsigned long)__end_rodata; addr += PAGE_SIZE)
change_page_attr(virt_to_page(addr), 1, PAGE_KERNEL_RO);
#ifdef CONFIG_HOTPLUG_CPU
/* It must still be possible to apply SMP alternatives. */
if (num_possible_cpus() <= 1)
#endif
{
change_page_attr(virt_to_page(start),
size >> PAGE_SHIFT, PAGE_KERNEL_RX);
printk("Write protecting the kernel text: %luk\n", size >> 10);
}

printk("Write protecting the kernel read-only data: %uk\n",
(__end_rodata - __start_rodata) >> 10);
start += size;
size = (unsigned long)__end_rodata - start;
change_page_attr(virt_to_page(start),
size >> PAGE_SHIFT, PAGE_KERNEL_RO);
printk("Write protecting the kernel read-only data: %luk\n",
size >> 10);

/*
* change_page_attr() requires a global_flush_tlb() call after it.
Expand All @@ -781,7 +794,7 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
__free_page(page);
totalram_pages++;
}
printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
}

void free_initmem(void)
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/x86_64/kernel/head.S
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ early_idt_ripmsg:

.balign PAGE_SIZE
ENTRY(stext)
ENTRY(_stext)

#define NEXT_PAGE(name) \
.balign PAGE_SIZE; \
Expand Down
5 changes: 3 additions & 2 deletions trunk/arch/x86_64/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ SECTIONS
.text : AT(ADDR(.text) - LOAD_OFFSET) {
/* First the code that has to be first for bootstrapping */
*(.bootstrap.text)
_stext = .;
/* Then all the functions that are "hot" in profiles, to group them
onto the same hugetlb entry */
#include "functionlist"
Expand All @@ -50,10 +51,10 @@ SECTIONS
__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
__stop___ex_table = .;

RODATA

BUG_TABLE

RODATA

. = ALIGN(PAGE_SIZE); /* Align data segment to page size boundary */
/* Data */
.data : AT(ADDR(.data) - LOAD_OFFSET) {
Expand Down
25 changes: 16 additions & 9 deletions trunk/arch/x86_64/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/bootmem.h>
#include <linux/proc_fs.h>
#include <linux/pci.h>
#include <linux/pfn.h>
#include <linux/poison.h>
#include <linux/dma-mapping.h>
#include <linux/module.h>
Expand Down Expand Up @@ -563,21 +564,23 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
if (begin >= end)
return;

printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
for (addr = begin; addr < end; addr += PAGE_SIZE) {
struct page *page = pfn_to_page(addr >> PAGE_SHIFT);
ClearPageReserved(page);
init_page_count(page);
memset(page_address(page), POISON_FREE_INITMEM, PAGE_SIZE);
if (addr >= __START_KERNEL_map)
change_page_attr_addr(addr, 1, __pgprot(0));
__free_page(page);
totalram_pages++;
}
if (addr > __START_KERNEL_map)
global_flush_tlb();
}

void free_initmem(void)
{
memset(__initdata_begin, POISON_FREE_INITDATA,
__initdata_end - __initdata_begin);
free_init_pages("unused kernel memory",
__pa_symbol(&__init_begin),
__pa_symbol(&__init_end));
Expand All @@ -587,14 +590,18 @@ void free_initmem(void)

void mark_rodata_ro(void)
{
unsigned long addr = (unsigned long)__va(__pa_symbol(&__start_rodata));
unsigned long end = (unsigned long)__va(__pa_symbol(&__end_rodata));
unsigned long start = PFN_ALIGN(__va(__pa_symbol(&_stext))), size;

for (; addr < end; addr += PAGE_SIZE)
change_page_attr_addr(addr, 1, PAGE_KERNEL_RO);
#ifdef CONFIG_HOTPLUG_CPU
/* It must still be possible to apply SMP alternatives. */
if (num_possible_cpus() > 1)
start = PFN_ALIGN(__va(__pa_symbol(&_etext)));
#endif
size = (unsigned long)__va(__pa_symbol(&__end_rodata)) - start;
change_page_attr_addr(start, size >> PAGE_SHIFT, PAGE_KERNEL_RO);

printk ("Write protecting the kernel read-only data: %luk\n",
(__end_rodata - __start_rodata) >> 10);
printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n",
size >> 10);

/*
* change_page_attr_addr() requires a global_flush_tlb() call after it.
Expand Down
3 changes: 0 additions & 3 deletions trunk/include/linux/poison.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
/********** arch/$ARCH/mm/init.c **********/
#define POISON_FREE_INITMEM 0xcc

/********** arch/x86_64/mm/init.c **********/
#define POISON_FREE_INITDATA 0xba

/********** arch/ia64/hp/common/sba_iommu.c **********/
/*
* arch/ia64/hp/common/sba_iommu.c uses a 16-byte poison string with a
Expand Down

0 comments on commit 3033cf9

Please sign in to comment.