arm64: Direct access to Mckernel memory from Linux.

Change-Id: I1a096aa5232c56382ae19d8c4e4f41d4e3e9f660
This commit is contained in:
Shiratori, Takehiro
2019-02-26 17:17:46 +09:00
committed by Dominique Martinet
parent 20d5900c35
commit aa3c5e91db
9 changed files with 32 additions and 28 deletions

View File

@ -34,7 +34,7 @@ void panic(const char *);
*/ */
/* early alloc area address */ /* early alloc area address */
/* START:_end, SIZE:512 pages */ /* START:_end, SIZE:512 pages */
#define MAP_EARLY_ALLOC_SHIFT 9 #define MAP_EARLY_ALLOC_SHIFT 5
#define MAP_EARLY_ALLOC_SIZE (UL(1) << (PAGE_SHIFT + MAP_EARLY_ALLOC_SHIFT)) #define MAP_EARLY_ALLOC_SIZE (UL(1) << (PAGE_SHIFT + MAP_EARLY_ALLOC_SHIFT))
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
@ -55,7 +55,10 @@ extern char _end[];
# define MAP_BOOT_PARAM_END (MAP_BOOT_PARAM + MAP_BOOT_PARAM_SIZE) # define MAP_BOOT_PARAM_END (MAP_BOOT_PARAM + MAP_BOOT_PARAM_SIZE)
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */
#if (VA_BITS == 39 && GRANULE_SIZE == _SZ4KB) /*
* MAP_KERNEL_START is HOST MODULES_END - 8MiB
*/
#if (VA_BITS == 39 && GRANULE_SIZE == _SZ4KB) /* ARM64_MEMORY_LAYOUT=1 */
# #
# define LD_TASK_UNMAPPED_BASE UL(0x0000000400000000) # define LD_TASK_UNMAPPED_BASE UL(0x0000000400000000)
# define TASK_UNMAPPED_BASE UL(0x0000000800000000) # define TASK_UNMAPPED_BASE UL(0x0000000800000000)
@ -64,9 +67,9 @@ extern char _end[];
# define MAP_VMAP_SIZE UL(0x0000000100000000) # define MAP_VMAP_SIZE UL(0x0000000100000000)
# define MAP_FIXED_START UL(0xffffffbffbdfd000) # define MAP_FIXED_START UL(0xffffffbffbdfd000)
# define MAP_ST_START UL(0xffffffc000000000) # define MAP_ST_START UL(0xffffffc000000000)
# define MAP_KERNEL_START UL(0xffffffffff800000) # define MAP_KERNEL_START UL(0xffffff8007800000)
# #
#elif (VA_BITS == 42 && GRANULE_SIZE == _SZ64KB) #elif (VA_BITS == 42 && GRANULE_SIZE == _SZ64KB) /* ARM64_MEMORY_LAYOUT=3 */
# #
# define LD_TASK_UNMAPPED_BASE UL(0x0000002000000000) # define LD_TASK_UNMAPPED_BASE UL(0x0000002000000000)
# define TASK_UNMAPPED_BASE UL(0x0000004000000000) # define TASK_UNMAPPED_BASE UL(0x0000004000000000)
@ -75,9 +78,9 @@ extern char _end[];
# define MAP_VMAP_SIZE UL(0x0000000100000000) # define MAP_VMAP_SIZE UL(0x0000000100000000)
# define MAP_FIXED_START UL(0xfffffdfffbdd0000) # define MAP_FIXED_START UL(0xfffffdfffbdd0000)
# define MAP_ST_START UL(0xfffffe0000000000) # define MAP_ST_START UL(0xfffffe0000000000)
# define MAP_KERNEL_START UL(0xffffffffe0000000) # define MAP_KERNEL_START UL(0xfffffc0007800000)
# #
#elif (VA_BITS == 48 && GRANULE_SIZE == _SZ4KB) #elif (VA_BITS == 48 && GRANULE_SIZE == _SZ4KB) /* ARM64_MEMORY_LAYOUT=2 */
# #
# define LD_TASK_UNMAPPED_BASE UL(0x0000080000000000) # define LD_TASK_UNMAPPED_BASE UL(0x0000080000000000)
# define TASK_UNMAPPED_BASE UL(0x0000100000000000) # define TASK_UNMAPPED_BASE UL(0x0000100000000000)
@ -86,9 +89,9 @@ extern char _end[];
# define MAP_VMAP_SIZE UL(0x0000000100000000) # define MAP_VMAP_SIZE UL(0x0000000100000000)
# define MAP_FIXED_START UL(0xffff7ffffbdfd000) # define MAP_FIXED_START UL(0xffff7ffffbdfd000)
# define MAP_ST_START UL(0xffff800000000000) # define MAP_ST_START UL(0xffff800000000000)
# define MAP_KERNEL_START UL(0xffffffffff800000) # define MAP_KERNEL_START UL(0xffff000007800000)
# #
#elif (VA_BITS == 48 && GRANULE_SIZE == _SZ64KB) #elif (VA_BITS == 48 && GRANULE_SIZE == _SZ64KB) /* ARM64_MEMORY_LAYOUT=4 */
# #
# define LD_TASK_UNMAPPED_BASE UL(0x0000080000000000) # define LD_TASK_UNMAPPED_BASE UL(0x0000080000000000)
# define TASK_UNMAPPED_BASE UL(0x0000100000000000) # define TASK_UNMAPPED_BASE UL(0x0000100000000000)
@ -97,7 +100,7 @@ extern char _end[];
# define MAP_VMAP_SIZE UL(0x0000000100000000) # define MAP_VMAP_SIZE UL(0x0000000100000000)
# define MAP_FIXED_START UL(0xffff7ffffbdd0000) # define MAP_FIXED_START UL(0xffff7ffffbdd0000)
# define MAP_ST_START UL(0xffff800000000000) # define MAP_ST_START UL(0xffff800000000000)
# define MAP_KERNEL_START UL(0xffffffffe0000000) # define MAP_KERNEL_START UL(0xffff000007800000)
# #
#else #else
# error address space is not defined. # error address space is not defined.

View File

@ -3334,10 +3334,10 @@ unsigned long virt_to_phys(void *v)
{ {
unsigned long va = (unsigned long)v; unsigned long va = (unsigned long)v;
if (MAP_KERNEL_START <= va) { if (va >= MAP_ST_START) {
return va - MAP_KERNEL_START + arm64_kernel_phys_base; return va - MAP_ST_START;
} }
return va - MAP_ST_START; return va - MAP_KERNEL_START + arm64_kernel_phys_base;
} }
void *phys_to_virt(unsigned long p) void *phys_to_virt(unsigned long p)

View File

@ -55,13 +55,14 @@ uintptr_t virt_to_phys(uintptr_t va)
{ {
extern uintptr_t kernel_base; extern uintptr_t kernel_base;
if (va >= MAP_ST) {
return (va - MAP_ST);
}
if (va >= MAP_KERNEL) { if (va >= MAP_KERNEL) {
return (va - MAP_KERNEL + kernel_base); return (va - MAP_KERNEL + kernel_base);
} }
if (va >= MAP_ST) {
return (va - MAP_ST);
}
return NOPHYS; return NOPHYS;
} /* virt_to_phys() */ } /* virt_to_phys() */
#endif /* POSTK_DEBUG_ARCH_DEP_34 */ #endif /* POSTK_DEBUG_ARCH_DEP_34 */

View File

@ -6,15 +6,15 @@
# #
# if (CONFIG_ARM64_VA_BITS == 42) # if (CONFIG_ARM64_VA_BITS == 42)
# /* VA_BITS=42, 64K_PAGE address */ # /* VA_BITS=42, 64K_PAGE address */
# define MAP_KERNEL 0xffffffffe0000000 # define MAP_KERNEL 0xfffffc0007800000
# define MAP_ST 0xfffffe0000000000 # define MAP_ST 0xfffffe0000000000
# define MAP_KERNEL_TEXT "0xffffffffe0000000" # define MAP_KERNEL_TEXT "0xfffffc0007800000"
# #
# elif (CONFIG_ARM64_VA_BITS == 48) # elif (CONFIG_ARM64_VA_BITS == 48)
# /* VA_BITS=48, 64K_PAGE address */ # /* VA_BITS=48, 64K_PAGE address */
# define MAP_KERNEL 0xffffffffe0000000 # define MAP_KERNEL 0xffff000007800000
# define MAP_ST 0xffff800000000000 # define MAP_ST 0xffff800000000000
# define MAP_KERNEL_TEXT "0xffffffffe0000000" # define MAP_KERNEL_TEXT "0xffff000007800000"
# #
# else # else
# #
@ -26,15 +26,15 @@
# #
# if (CONFIG_ARM64_VA_BITS == 39) # if (CONFIG_ARM64_VA_BITS == 39)
# /* VA_BITS=39, 4K_PAGE address */ # /* VA_BITS=39, 4K_PAGE address */
# define MAP_KERNEL 0xffffffffff800000 # define MAP_KERNEL 0xffffff8007800000
# define MAP_ST 0xffffffc000000000 # define MAP_ST 0xffffffc000000000
# define MAP_KERNEL_TEXT "0xffffffffff800000" # define MAP_KERNEL_TEXT "0xffffff8007800000"
# #
# elif (CONFIG_ARM64_VA_BITS == 48) # elif (CONFIG_ARM64_VA_BITS == 48)
# /* VA_BITS=48, 4K_PAGE address */ # /* VA_BITS=48, 4K_PAGE address */
# define MAP_KERNEL 0xffffffffff800000 # define MAP_KERNEL 0xffff000007800000
# define MAP_ST 0xffff800000000000 # define MAP_ST 0xffff800000000000
# define MAP_KERNEL_TEXT "0xffffffffff800000" # define MAP_KERNEL_TEXT "0xffff000007800000"
# #
# else # else
# #

2
ihk

Submodule ihk updated: 283b10e18f...6da480a535

View File

@ -6,7 +6,7 @@ PHDRS
} }
SECTIONS SECTIONS
{ {
. = 0xffffffffff800000; /* KERNEL_START */ . = 0xffffff8007800000; /* KERNEL_START */
_head = .; _head = .;
.text : { .text : {

View File

@ -6,7 +6,7 @@ PHDRS
} }
SECTIONS SECTIONS
{ {
. = 0xffffffffff800000; /* KERNEL_START */ . = 0xffff000007800000; /* KERNEL_START */
_head = .; _head = .;
.text : { .text : {

View File

@ -6,7 +6,7 @@ PHDRS
} }
SECTIONS SECTIONS
{ {
. = 0xffffffffe0000000; /* KERNEL_START */ . = 0xfffffc0007800000; /* KERNEL_START */
_head = .; _head = .;
.text : { .text : {

View File

@ -6,7 +6,7 @@ PHDRS
} }
SECTIONS SECTIONS
{ {
. = 0xffffffffe0000000; /* KERNEL_START */ . = 0xffff000007800000; /* KERNEL_START */
_head = .; _head = .;
.text : { .text : {