From 56b54a66413aa7d3e379ee1ca53d759178f22a5d Mon Sep 17 00:00:00 2001 From: Hector Martin Date: Wed, 15 Sep 2021 23:22:42 +0900 Subject: [PATCH] hv_vm/hv_exc: Add cpu_id to exception & mmiotrace structs Signed-off-by: Hector Martin --- proxyclient/m1n1/hv.py | 1 + proxyclient/m1n1/proxy.py | 1 + src/hv.h | 5 +++-- src/hv_exc.c | 2 ++ src/hv_vm.c | 3 ++- src/uartproxy.h | 1 + 6 files changed, 10 insertions(+), 3 deletions(-) diff --git a/proxyclient/m1n1/hv.py b/proxyclient/m1n1/hv.py index 63d10fd2..b5f8f7fe 100644 --- a/proxyclient/m1n1/hv.py +++ b/proxyclient/m1n1/hv.py @@ -15,6 +15,7 @@ from . import xnutools, shell __all__ = ["HV"] class MMIOTraceFlags(Register32): + CPU = 23, 16 WIDTH = 4, 0 WRITE = 5 MULTI = 6 diff --git a/proxyclient/m1n1/proxy.py b/proxyclient/m1n1/proxy.py index 7937feca..3cabc3be 100644 --- a/proxyclient/m1n1/proxy.py +++ b/proxyclient/m1n1/proxy.py @@ -67,6 +67,7 @@ class EXC_RET(IntEnum): STEP = 4 ExcInfo = Struct( + "cpu_id" / Int64ul, "spsr" / RegAdapter(SPSR), "elr" / Int64ul, "esr" / RegAdapter(ESR), diff --git a/src/hv.h b/src/hv.h index 346697e5..63510224 100644 --- a/src/hv.h +++ b/src/hv.h @@ -9,9 +9,10 @@ typedef bool(hv_hook_t)(u64 addr, u64 *val, bool write, int width); -#define MMIO_EVT_WIDTH GENMASK(4, 0) -#define MMIO_EVT_WRITE BIT(5) +#define MMIO_EVT_CPU GENMASK(23, 16) #define MMIO_EVT_MULTI BIT(6) +#define MMIO_EVT_WRITE BIT(5) +#define MMIO_EVT_WIDTH GENMASK(4, 0) struct hv_evt_mmiotrace { u32 flags; diff --git a/src/hv_exc.c b/src/hv_exc.c index 35646e12..344188aa 100644 --- a/src/hv_exc.c +++ b/src/hv_exc.c @@ -4,6 +4,7 @@ #include "assert.h" #include "cpu_regs.h" #include "exception.h" +#include "smp.h" #include "string.h" #include "uart.h" #include "uartproxy.h" @@ -33,6 +34,7 @@ void hv_exc_proxy(u64 *regs, uartproxy_boot_reason_t reason, uartproxy_exc_code_ hv_wdt_breadcrumb('P'); struct uartproxy_exc_info exc_info = { + .cpu_id = smp_id(), .spsr = hv_get_spsr(), .elr = hv_get_elr(), .esr = hv_get_esr(), diff --git a/src/hv_vm.c b/src/hv_vm.c index 178b8481..78dd7060 100644 --- a/src/hv_vm.c +++ b/src/hv_vm.c @@ -7,6 +7,7 @@ #include "cpu_regs.h" #include "iodev.h" #include "malloc.h" +#include "smp.h" #include "string.h" #include "types.h" #include "uartproxy.h" @@ -616,7 +617,7 @@ static bool emulate_store(u64 *regs, u32 insn, u64 *val, u64 *width) static void emit_mmiotrace(u64 pc, u64 addr, u64 *data, u64 width, u64 flags, bool sync) { struct hv_evt_mmiotrace evt = { - .flags = flags, + .flags = flags | FIELD_PREP(MMIO_EVT_CPU, smp_id()), .pc = pc, .addr = addr, }; diff --git a/src/uartproxy.h b/src/uartproxy.h index adb4d5e4..e68a380d 100644 --- a/src/uartproxy.h +++ b/src/uartproxy.h @@ -33,6 +33,7 @@ typedef enum _uartproxy_event_type_t { } uartproxy_event_type_t; struct uartproxy_exc_info { + u64 cpu_id; u64 spsr; u64 elr; u64 esr;