Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <tiwei.btw@antgroup.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Tiwei Bie and committed by
Johannes Berg
e047f9af b765d69a

+5 -6
+2 -1
arch/um/include/shared/as-layout.h
··· 24 24 #define STUB_CODE STUB_START 25 25 #define STUB_DATA (STUB_CODE + UM_KERN_PAGE_SIZE) 26 26 #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) 28 29 29 30 #ifndef __ASSEMBLER__ 30 31
+1 -3
arch/um/kernel/um_arch.c
··· 331 331 332 332 host_task_size = get_top_address(envp); 333 333 /* 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; 337 335 host_task_size = stub_start; 338 336 339 337 /* Limit TASK_SIZE to what is addressable by the page table */
+1 -1
arch/x86/um/shared/sysdep/stub_32.h
··· 129 129 "subl %0,%%esp ;" \ 130 130 "movl %1, %%eax ; " \ 131 131 "call *%%eax ;" \ 132 - :: "i" ((1 + STUB_DATA_PAGES) * UM_KERN_PAGE_SIZE), \ 132 + :: "i" (STUB_SIZE), \ 133 133 "i" (&fn)) 134 134 135 135 static __always_inline void
+1 -1
arch/x86/um/shared/sysdep/stub_64.h
··· 133 133 "subq %0,%%rsp ;" \ 134 134 "movq %1,%%rax ;" \ 135 135 "call *%%rax ;" \ 136 - :: "i" ((1 + STUB_DATA_PAGES) * UM_KERN_PAGE_SIZE), \ 136 + :: "i" (STUB_SIZE), \ 137 137 "i" (&fn)) 138 138 139 139 static __always_inline void