Skip to content

Commit e047f9a

Browse files
btw616jmberg-intel
authored andcommitted
um: Centralize stub size calculations
Currently, the stub size is calculated in multiple places. Define a macro that performs the calculation so that the code is easier to read and maintain. Signed-off-by: Tiwei Bie <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent b765d69 commit e047f9a

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

arch/um/include/shared/as-layout.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
#define STUB_CODE STUB_START
2525
#define STUB_DATA (STUB_CODE + UM_KERN_PAGE_SIZE)
2626
#define STUB_DATA_PAGES 2
27-
#define STUB_END (STUB_DATA + STUB_DATA_PAGES * UM_KERN_PAGE_SIZE)
27+
#define STUB_SIZE ((1 + STUB_DATA_PAGES) * UM_KERN_PAGE_SIZE)
28+
#define STUB_END (STUB_START + STUB_SIZE)
2829

2930
#ifndef __ASSEMBLER__
3031

arch/um/kernel/um_arch.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,7 @@ int __init linux_main(int argc, char **argv, char **envp)
331331

332332
host_task_size = get_top_address(envp);
333333
/* reserve a few pages for the stubs */
334-
stub_start = host_task_size - STUB_DATA_PAGES * PAGE_SIZE;
335-
/* another page for the code portion */
336-
stub_start -= PAGE_SIZE;
334+
stub_start = host_task_size - STUB_SIZE;
337335
host_task_size = stub_start;
338336

339337
/* Limit TASK_SIZE to what is addressable by the page table */

arch/x86/um/shared/sysdep/stub_32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static __always_inline void *get_stub_data(void)
129129
"subl %0,%%esp ;" \
130130
"movl %1, %%eax ; " \
131131
"call *%%eax ;" \
132-
:: "i" ((1 + STUB_DATA_PAGES) * UM_KERN_PAGE_SIZE), \
132+
:: "i" (STUB_SIZE), \
133133
"i" (&fn))
134134

135135
static __always_inline void

arch/x86/um/shared/sysdep/stub_64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static __always_inline void *get_stub_data(void)
133133
"subq %0,%%rsp ;" \
134134
"movq %1,%%rax ;" \
135135
"call *%%rax ;" \
136-
:: "i" ((1 + STUB_DATA_PAGES) * UM_KERN_PAGE_SIZE), \
136+
:: "i" (STUB_SIZE), \
137137
"i" (&fn))
138138

139139
static __always_inline void

0 commit comments

Comments
 (0)