We'll need them in assembly, so move them over to regs.h and align the naming with the hypervisor. And introduce the shorthand PAGE_DEFAULT_FLAGS.
No functional change. Signed-off-by: Ralf Ramsauer <[email protected]> --- inmates/lib/x86/include/asm/regs.h | 7 +++++++ inmates/lib/x86/mem.c | 17 ++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/inmates/lib/x86/include/asm/regs.h b/inmates/lib/x86/include/asm/regs.h index 1ae13591..16a0665e 100644 --- a/inmates/lib/x86/include/asm/regs.h +++ b/inmates/lib/x86/include/asm/regs.h @@ -49,6 +49,13 @@ #define X86_XCR0_SSE (1 << 1) #define X86_XCR0_AVX (1 << 2) +#define PAGE_FLAG_PRESENT 0x01 +#define PAGE_FLAG_RW 0x02 +#define PAGE_FLAG_PS 0x80 +#define PAGE_FLAG_PCD 0x10 + +#define PAGE_DEFAULT_FLAGS (PAGE_FLAG_PRESENT | PAGE_FLAG_RW) + #define MSR_EFER 0xc0000080 #define EFER_LME 0x00000100 diff --git a/inmates/lib/x86/mem.c b/inmates/lib/x86/mem.c index e391f2b0..7e1c8b83 100644 --- a/inmates/lib/x86/mem.c +++ b/inmates/lib/x86/mem.c @@ -39,11 +39,6 @@ #include <inmate.h> #include <asm/regs.h> -#define PG_PRESENT 0x01 -#define PG_RW 0x02 -#define PG_PS 0x80 -#define PG_PCD 0x10 - void map_range(void *start, unsigned long size, enum map_type map_type) { unsigned long pt_addr, *pt_entry, *pt; @@ -59,25 +54,25 @@ void map_range(void *start, unsigned long size, enum map_type map_type) pt = (unsigned long *)pt_addr; pt_entry = &pt[(vaddr >> 39) & 0x1ff]; - if (*pt_entry & PG_PRESENT) { + if (*pt_entry & PAGE_FLAG_PRESENT) { pt = (unsigned long *)(*pt_entry & PAGE_MASK); } else { pt = alloc(PAGE_SIZE, PAGE_SIZE); - *pt_entry = (unsigned long)pt | PG_RW | PG_PRESENT; + *pt_entry = (unsigned long)pt | PAGE_DEFAULT_FLAGS; } pt_entry = &pt[(vaddr >> 30) & 0x1ff]; - if (*pt_entry & PG_PRESENT) { + if (*pt_entry & PAGE_FLAG_PRESENT) { pt = (unsigned long *)(*pt_entry & PAGE_MASK); } else { pt = alloc(PAGE_SIZE, PAGE_SIZE); - *pt_entry = (unsigned long)pt | PG_RW | PG_PRESENT; + *pt_entry = (unsigned long)pt | PAGE_DEFAULT_FLAGS; } pt_entry = &pt[(vaddr >> 21) & 0x1ff]; *pt_entry = (vaddr & HUGE_PAGE_MASK) | - (map_type == MAP_UNCACHED ? PG_PCD : 0) | - PG_PS | PG_RW | PG_PRESENT; + (map_type == MAP_UNCACHED ? PAGE_FLAG_PCD : 0) | + PAGE_FLAG_PS | PAGE_DEFAULT_FLAGS; #else #error not yet implemented #endif -- 2.28.0 -- 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/20200923160745.580421-1-ralf.ramsauer%40oth-regensburg.de.
