From: Jan Kiszka <[email protected]> PAGE_SIZE, PAGE_MASK and PAGE_OFFS_MASK can all be derived from arch-specific PAGE_SHIFT. So move those three into the generic header. We just need to replace a few asm/paging.h includes with the generic one, and we need move the asm include down in jailhouse/paging.h because ARM needs PAGE_MASK in a static inline function.
Signed-off-by: Jan Kiszka <[email protected]> --- hypervisor/arch/arm/include/asm/paging.h | 3 --- hypervisor/arch/arm64/entry.S | 2 +- hypervisor/arch/arm64/include/asm/paging.h | 3 --- hypervisor/arch/x86/include/asm/paging.h | 3 --- hypervisor/arch/x86/include/asm/vmx.h | 2 +- hypervisor/hypervisor.lds.S | 2 +- hypervisor/include/jailhouse/paging.h | 17 +++++++++++++++-- 7 files changed, 18 insertions(+), 14 deletions(-) diff --git a/hypervisor/arch/arm/include/asm/paging.h b/hypervisor/arch/arm/include/asm/paging.h index 8e82d7c2..08bed5cf 100644 --- a/hypervisor/arch/arm/include/asm/paging.h +++ b/hypervisor/arch/arm/include/asm/paging.h @@ -20,9 +20,6 @@ #include <asm/sysregs.h> #define PAGE_SHIFT 12 -#define PAGE_SIZE (1 << PAGE_SHIFT) -#define PAGE_MASK ~(PAGE_SIZE - 1) -#define PAGE_OFFS_MASK (PAGE_SIZE - 1) #define MAX_PAGE_TABLE_LEVELS 3 diff --git a/hypervisor/arch/arm64/entry.S b/hypervisor/arch/arm64/entry.S index 167e29d2..27e148c6 100644 --- a/hypervisor/arch/arm64/entry.S +++ b/hypervisor/arch/arm64/entry.S @@ -13,8 +13,8 @@ * the COPYING file in the top-level directory. */ +#include <jailhouse/paging.h> #include <asm/asm-defines.h> -#include <asm/paging.h> #include <asm/smccc.h> #include <asm/jailhouse_hypercall.h> #include <jailhouse/header.h> diff --git a/hypervisor/arch/arm64/include/asm/paging.h b/hypervisor/arch/arm64/include/asm/paging.h index 9398ecb2..5713379c 100644 --- a/hypervisor/arch/arm64/include/asm/paging.h +++ b/hypervisor/arch/arm64/include/asm/paging.h @@ -31,9 +31,6 @@ */ #define PAGE_SHIFT 12 -#define PAGE_SIZE (1 << PAGE_SHIFT) -#define PAGE_MASK ~(PAGE_SIZE - 1) -#define PAGE_OFFS_MASK (PAGE_SIZE - 1) #define MAX_PAGE_TABLE_LEVELS 4 diff --git a/hypervisor/arch/x86/include/asm/paging.h b/hypervisor/arch/x86/include/asm/paging.h index ef614b02..065bac9b 100644 --- a/hypervisor/arch/x86/include/asm/paging.h +++ b/hypervisor/arch/x86/include/asm/paging.h @@ -18,9 +18,6 @@ #include <asm/processor.h> #define PAGE_SHIFT 12 -#define PAGE_SIZE (1 << PAGE_SHIFT) -#define PAGE_MASK ~(PAGE_SIZE - 1) -#define PAGE_OFFS_MASK (PAGE_SIZE - 1) #define MAX_PAGE_TABLE_LEVELS 4 diff --git a/hypervisor/arch/x86/include/asm/vmx.h b/hypervisor/arch/x86/include/asm/vmx.h index 53490e10..c03ffc55 100644 --- a/hypervisor/arch/x86/include/asm/vmx.h +++ b/hypervisor/arch/x86/include/asm/vmx.h @@ -31,7 +31,7 @@ #ifndef _JAILHOUSE_ASM_VMX_H #define _JAILHOUSE_ASM_VMX_H -#include <asm/paging.h> +#include <jailhouse/paging.h> struct per_cpu; diff --git a/hypervisor/hypervisor.lds.S b/hypervisor/hypervisor.lds.S index 62c39114..ca06ab20 100644 --- a/hypervisor/hypervisor.lds.S +++ b/hypervisor/hypervisor.lds.S @@ -12,7 +12,7 @@ #include <jailhouse/header.h> -#include <asm/paging.h> +#include <jailhouse/paging.h> #include <asm/sections.h> SECTIONS diff --git a/hypervisor/include/jailhouse/paging.h b/hypervisor/include/jailhouse/paging.h index bdaf8b58..5513c4ec 100644 --- a/hypervisor/include/jailhouse/paging.h +++ b/hypervisor/include/jailhouse/paging.h @@ -13,8 +13,6 @@ #ifndef _JAILHOUSE_PAGING_H #define _JAILHOUSE_PAGING_H -#include <asm/paging.h> - /** * @defgroup Paging Page Management Subsystem * @@ -26,6 +24,13 @@ * @{ */ +/** Size of smallest page. */ +#define PAGE_SIZE (1 << PAGE_SHIFT) +/** Mask of bits selecting a page. */ +#define PAGE_MASK ~(PAGE_SIZE - 1) +/** Mask of bits selecting an offset in a page. */ +#define PAGE_OFFS_MASK (PAGE_SIZE - 1) + /** Align address to page boundary (round up). */ #define PAGE_ALIGN(s) (((s) + PAGE_SIZE-1) & PAGE_MASK) /** Count number of pages for given size (round up). */ @@ -34,12 +39,20 @@ /** Location of per-CPU data structure in hypervisor address space. */ #define LOCAL_CPU_BASE (TEMPORARY_MAPPING_BASE + \ NUM_TEMPORARY_PAGES * PAGE_SIZE) +/** @} */ + +#include <asm/paging.h> #ifndef __ASSEMBLY__ #include <jailhouse/entry.h> #include <jailhouse/types.h> +/** + * @ingroup Paging + * @{ + */ + /** Page pool state. */ struct page_pool { /** Base address of the pool. */ -- 2.16.4 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/b5d8439116e8615e5b0498391f3ecb27407a1505.1581770164.git.jan.kiszka%40web.de.
