From e84bc1de1ac3420ac5edae0541ce7b150eb3cf0b Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Thu, 19 Dec 2024 18:32:40 +0000 Subject: [PATCH] libvmmapi: Map the guest physical address space with PROT_CAP This lets the gdb stub see capability tag bits; otherwise, they're cleared on load and the debugger sees all capabilities as invalid. Note that this enables the writing of capabilities to the GPA space as well. --- lib/libvmmapi/vmmapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c index d8c49665faed..7a017c7405ca 100644 --- a/lib/libvmmapi/vmmapi.c +++ b/lib/libvmmapi/vmmapi.c @@ -415,7 +415,7 @@ setup_memory_segment(struct vmctx *ctx, vm_paddr_t gpa, size_t len, char *base) flags |= MAP_NOCORE; /* mmap into the process address space on the host */ - ptr = mmap(base + gpa, len, PROT_RW, flags, ctx->fd, gpa); + ptr = mmap(base + gpa, len, PROT_RW | PROT_CAP, flags, ctx->fd, gpa); if (ptr == MAP_FAILED) return (-1); @@ -455,7 +455,7 @@ vm_setup_memory(struct vmctx *ctx, size_t memsize, enum vm_mmap_style vms) * and the adjoining guard regions. */ len = VM_MMAP_GUARD_SIZE + objsize + VM_MMAP_GUARD_SIZE; - ptr = mmap(NULL, len, PROT_NONE | PROT_MAX(PROT_RW), + ptr = mmap(NULL, len, PROT_NONE | PROT_MAX(PROT_RW | PROT_CAP), MAP_GUARD | MAP_ALIGNED_SUPER, -1, 0); if (ptr == MAP_FAILED) return (-1);