Skip to content

Commit

Permalink
vmm: don't vmap non-canonical addresses
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Wikner <[email protected]>
  • Loading branch information
sktt committed Nov 9, 2023
1 parent 4b44717 commit 68dc913
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion arch/x86/pagetables.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ static inline void dump_pte(void *entry, mfn_t table, int level, int index) {
level, index, paddr, flags);
}

#if defined(__x86_64__)
static inline int canonical_va(void *va) {
int sign = _ul(va) >> 47 & 1;
return sign * 0xfffful == _ul(va) >> 48;
}
#else
static inline int canonical_va(void *va) {
return 1;
}
#endif

static void dump_pagetable(mfn_t table, int level) {
pte_t *pt;

Expand Down Expand Up @@ -262,7 +273,7 @@ static void *_vmap(cr3_t *cr3_ptr, void *va, mfn_t mfn, unsigned int order,
mfn_t l1t_mfn, l2t_mfn, l3t_mfn;
pgentry_t *tab, *entry;

if (!va || (_ul(va) & ~PAGE_ORDER_TO_MASK(order)))
if (!va || (_ul(va) & ~PAGE_ORDER_TO_MASK(order)) || !canonical_va(va))
return NULL;

dprintk("%s: va: 0x%p mfn: 0x%lx (order: %u)\n", __func__, va, mfn, order);
Expand Down

0 comments on commit 68dc913

Please sign in to comment.