Commit e047f9af authored by Tiwei Bie's avatar Tiwei Bie Committed by Johannes Berg
Browse files

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: default avatarTiwei Bie <tiwei.btw@antgroup.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent b765d69a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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__

+1 −3
Original line number Diff line number Diff line
@@ -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 */
+1 −1
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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