aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2024-11-18 11:23:01 +0100
committerAlexander Potapenko <glider@google.com>2024-11-26 11:12:47 +0000
commit3bbc60604366c324295d54a7d93dd7d258a0e2aa (patch)
tree7f2598945acc42bd3f2b3a901decc9260307fc5a
parent26cf63663eb59ad18dd3d635de7698a91ba24f2a (diff)
executor: arm64: allocate memory for ITS tables on the host side
-rw-r--r--executor/common_kvm_arm64.h6
-rw-r--r--executor/common_kvm_arm64_syzos.h1
-rw-r--r--executor/kvm.h3
3 files changed, 9 insertions, 1 deletions
diff --git a/executor/common_kvm_arm64.h b/executor/common_kvm_arm64.h
index bb47c88f4..bc809a152 100644
--- a/executor/common_kvm_arm64.h
+++ b/executor/common_kvm_arm64.h
@@ -104,6 +104,12 @@ static void setup_vm(int vmfd, void* host_mem, void** text_slot)
// Map the remaining pages at address 0.
next = alloc_guest_mem(&allocator, allocator.size);
vm_set_user_memory_region(vmfd, slot++, 0, 0, next.size, (uintptr_t)next.addr);
+
+ // Allocate memory for the ITS tables.
+ // TODO(glider): leak this memory for now, this shouldn't be a problem for the short-living executor process.
+ int its_size = SZ_64K * (4 + /*num_cpus*/ 4 + /*num_devices*/ 16);
+ void* its = mmap(NULL, its_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
+ vm_set_user_memory_region(vmfd, slot++, 0, ARM64_ADDR_ITS_TABLES, its_size, (uintptr_t)its);
}
#endif
diff --git a/executor/common_kvm_arm64_syzos.h b/executor/common_kvm_arm64_syzos.h
index f2a517c81..a2e3404ae 100644
--- a/executor/common_kvm_arm64_syzos.h
+++ b/executor/common_kvm_arm64_syzos.h
@@ -356,7 +356,6 @@ GUEST_CODE static void gicd_wait_for_rwp()
spin_while_readl(ARM64_ADDR_GICD_BASE + GICD_CTLR, GICD_CTLR_RWP);
}
-#define SZ_64K 0x00010000
GUEST_CODE static uint64 gicr_base_cpu(uint32 cpu)
{
return ARM64_ADDR_GICR_BASE + cpu * SZ_64K * 2;
diff --git a/executor/kvm.h b/executor/kvm.h
index f69322bfd..b90da9362 100644
--- a/executor/kvm.h
+++ b/executor/kvm.h
@@ -76,12 +76,15 @@
#define NEXT_INSN $0xbadc0de
#define PREFIX_SIZE 0xba1d
+#define SZ_64K 0x00010000
+
// GICv3 distributor address.
#define ARM64_ADDR_GICD_BASE 0x08000000
// GICv3 ITS address.
#define ARM64_ADDR_GICI_BASE 0x08080000
// GICv3 redistributor address.
#define ARM64_ADDR_GICR_BASE 0x080a0000
+#define ARM64_ADDR_ITS_TABLES 0xc0000000
// Write to this page to trigger a page fault and stop KVM_RUN.
#define ARM64_ADDR_EXIT 0xdddd0000
// Dedicated address within the exit page for the uexit command.