Re: [patch 2/2] x86_64: align RODATA kernel section to 2MB withCONFIG_DEBUG_RODATA

From: Sam Ravnborg
Date: Wed Oct 14 2009 - 23:25:35 EST


> Index: tree/arch/x86/include/asm/sections.h
> ===================================================================
> --- tree.orig/arch/x86/include/asm/sections.h
> +++ tree/arch/x86/include/asm/sections.h
> @@ -2,7 +2,13 @@
> #define _ASM_X86_SECTIONS_H
>
> #include <asm-generic/sections.h>
> +#include <asm/uaccess.h>
>
> extern char __brk_base[], __brk_limit[];
> +extern struct exception_table_entry __stop___ex_table[];
> +
> +#if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
> +extern char __end_rodata_hpage_align[];
> +#endif
>
> #endif /* _ASM_X86_SECTIONS_H */
> Index: tree/arch/x86/kernel/vmlinux.lds.S
> ===================================================================
> --- tree.orig/arch/x86/kernel/vmlinux.lds.S
> +++ tree/arch/x86/kernel/vmlinux.lds.S
> @@ -41,6 +41,21 @@ ENTRY(phys_startup_64)
> jiffies_64 = jiffies;
> #endif
>
> +#if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
> +
> +#define X64_ALIGN_DEBUG_RODATA_BEGIN . = ALIGN(HPAGE_SIZE);
> +
> +#define X64_ALIGN_DEBUG_RODATA_END \
> + . = ALIGN(HPAGE_SIZE); \
> + __end_rodata_hpage_align = .;
This symbol is only defined if CONFIG_DEBUG_RODATA is defined, but (see below).

> +
> +#else
> +
> +#define X64_ALIGN_DEBUG_RODATA_BEGIN
> +#define X64_ALIGN_DEBUG_RODATA_END
> +
> +#endif

A coment describing the purpose of
this would be nice.

> +
> PHDRS {
> text PT_LOAD FLAGS(5); /* R_E */
> data PT_LOAD FLAGS(7); /* RWE */
> @@ -90,7 +105,9 @@ SECTIONS
>
> EXCEPTION_TABLE(16) :text = 0x9090
>
> + X64_ALIGN_DEBUG_RODATA_BEGIN
> RO_DATA(PAGE_SIZE)
> + X64_ALIGN_DEBUG_RODATA_END
>
> /* Data */
> .data : AT(ADDR(.data) - LOAD_OFFSET) {
> Index: tree/arch/x86/mm/init_64.c
> ===================================================================
> --- tree.orig/arch/x86/mm/init_64.c
> +++ tree/arch/x86/mm/init_64.c
> @@ -726,9 +726,13 @@ void set_kernel_text_ro(void)
>
> void mark_rodata_ro(void)
> {
> - unsigned long start = PFN_ALIGN(_text), end = PFN_ALIGN(__end_rodata);
> + unsigned long start = PFN_ALIGN(_text);
> unsigned long rodata_start =
> ((unsigned long)__start_rodata + PAGE_SIZE - 1) & PAGE_MASK;
> + unsigned long end = (unsigned long) &__end_rodata_hpage_align;
Here the symbol seems to be referenced unconditionally.

Sam
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/