mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 15:03:52 +08:00
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>
This commit is contained in:
@@ -24,7 +24,8 @@
|
||||
#define STUB_CODE STUB_START
|
||||
#define STUB_DATA (STUB_CODE + UM_KERN_PAGE_SIZE)
|
||||
#define STUB_DATA_PAGES 2
|
||||
#define STUB_END (STUB_DATA + STUB_DATA_PAGES * UM_KERN_PAGE_SIZE)
|
||||
#define STUB_SIZE ((1 + STUB_DATA_PAGES) * UM_KERN_PAGE_SIZE)
|
||||
#define STUB_END (STUB_START + STUB_SIZE)
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
|
||||
@@ -331,9 +331,7 @@ int __init linux_main(int argc, char **argv, char **envp)
|
||||
|
||||
host_task_size = get_top_address(envp);
|
||||
/* reserve a few pages for the stubs */
|
||||
stub_start = host_task_size - STUB_DATA_PAGES * PAGE_SIZE;
|
||||
/* another page for the code portion */
|
||||
stub_start -= PAGE_SIZE;
|
||||
stub_start = host_task_size - STUB_SIZE;
|
||||
host_task_size = stub_start;
|
||||
|
||||
/* Limit TASK_SIZE to what is addressable by the page table */
|
||||
|
||||
@@ -129,7 +129,7 @@ static __always_inline void *get_stub_data(void)
|
||||
"subl %0,%%esp ;" \
|
||||
"movl %1, %%eax ; " \
|
||||
"call *%%eax ;" \
|
||||
:: "i" ((1 + STUB_DATA_PAGES) * UM_KERN_PAGE_SIZE), \
|
||||
:: "i" (STUB_SIZE), \
|
||||
"i" (&fn))
|
||||
|
||||
static __always_inline void
|
||||
|
||||
@@ -133,7 +133,7 @@ static __always_inline void *get_stub_data(void)
|
||||
"subq %0,%%rsp ;" \
|
||||
"movq %1,%%rax ;" \
|
||||
"call *%%rax ;" \
|
||||
:: "i" ((1 + STUB_DATA_PAGES) * UM_KERN_PAGE_SIZE), \
|
||||
:: "i" (STUB_SIZE), \
|
||||
"i" (&fn))
|
||||
|
||||
static __always_inline void
|
||||
|
||||
Reference in New Issue
Block a user