Skip to content

Commit c398df3

Browse files
Amerigo Wangrustyrussell
authored andcommitted
module: merge module_alloc() finally
As Christoph Hellwig suggested, module_alloc() actually can be unified for i386 and x86_64 (of course, also UML). Signed-off-by: WANG Cong <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: 'Ingo Molnar' <[email protected]> Signed-off-by: Rusty Russell <[email protected]>
1 parent c0e5e10 commit c398df3

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

arch/um/include/asm/pgtable.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,21 @@ extern unsigned long end_iomem;
5353
#else
5454
# define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
5555
#endif
56+
#define MODULES_VADDR VMALLOC_START
57+
#define MODULES_END VMALLOC_END
58+
#define MODULES_LEN (MODULES_VADDR - MODULES_END)
5659

5760
#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
5861
#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
5962
#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
60-
63+
#define __PAGE_KERNEL_EXEC \
64+
(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
6165
#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
6266
#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED)
6367
#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
6468
#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
6569
#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
70+
#define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC)
6671

6772
/*
6873
* The i386 can't do page protection for execute, and considers that the same

arch/x86/include/asm/pgtable_32_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
4646
# define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
4747
#endif
4848

49+
#define MODULES_VADDR VMALLOC_START
50+
#define MODULES_END VMALLOC_END
51+
#define MODULES_LEN (MODULES_VADDR - MODULES_END)
52+
4953
#define MAXMEM (VMALLOC_END - PAGE_OFFSET - __VMALLOC_RESERVE)
5054

5155
#endif /* _ASM_X86_PGTABLE_32_DEFS_H */

arch/x86/kernel/module.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@
3434
#define DEBUGP(fmt...)
3535
#endif
3636

37-
#if defined(CONFIG_UML) || defined(CONFIG_X86_32)
38-
void *module_alloc(unsigned long size)
39-
{
40-
if (size == 0)
41-
return NULL;
42-
return vmalloc_exec(size);
43-
}
44-
#else /*X86_64*/
4537
void *module_alloc(unsigned long size)
4638
{
4739
struct vm_struct *area;
@@ -56,9 +48,9 @@ void *module_alloc(unsigned long size)
5648
if (!area)
5749
return NULL;
5850

59-
return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL_EXEC);
51+
return __vmalloc_area(area, GFP_KERNEL | __GFP_HIGHMEM,
52+
PAGE_KERNEL_EXEC);
6053
}
61-
#endif
6254

6355
/* Free memory returned from module_alloc */
6456
void module_free(struct module *mod, void *module_region)

0 commit comments

Comments
 (0)