[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 15/20] hw/i386: update vapic_write to use MemTxAttrs
From: |
Alex Bennée |
Subject: |
[PATCH v5 15/20] hw/i386: update vapic_write to use MemTxAttrs |
Date: |
Fri, 11 Nov 2022 18:25:30 +0000 |
This allows us to drop the current_cpu hack and properly model an
invalid access to the vapic.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
hw/i386/kvmvapic.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c
index 43f8a8f679..a76ed07199 100644
--- a/hw/i386/kvmvapic.c
+++ b/hw/i386/kvmvapic.c
@@ -635,20 +635,21 @@ static int vapic_prepare(VAPICROMState *s)
return 0;
}
-static void vapic_write(void *opaque, hwaddr addr, uint64_t data,
- unsigned int size)
+static MemTxResult vapic_write(void *opaque, hwaddr addr, uint64_t data,
+ unsigned int size, MemTxAttrs attrs)
{
VAPICROMState *s = opaque;
+ CPUState *cs;
X86CPU *cpu;
CPUX86State *env;
hwaddr rom_paddr;
- if (!current_cpu) {
- return;
+ if (attrs.requester_type != MTRT_CPU) {
+ return MEMTX_ACCESS_ERROR;
}
-
- cpu_synchronize_state(current_cpu);
- cpu = X86_CPU(current_cpu);
+ cs = qemu_get_cpu(attrs.requester_id);
+ cpu_synchronize_state(cs);
+ cpu = X86_CPU(cs);
env = &cpu->env;
/*
@@ -708,6 +709,8 @@ static void vapic_write(void *opaque, hwaddr addr, uint64_t
data,
}
break;
}
+
+ return MEMTX_OK;
}
static uint64_t vapic_read(void *opaque, hwaddr addr, unsigned size)
@@ -716,7 +719,7 @@ static uint64_t vapic_read(void *opaque, hwaddr addr,
unsigned size)
}
static const MemoryRegionOps vapic_ops = {
- .write = vapic_write,
+ .write_with_attrs = vapic_write,
.read = vapic_read,
.endianness = DEVICE_NATIVE_ENDIAN,
};
--
2.34.1
- [PATCH v5 08/20] hw/timer: convert mptimer access to attrs to derive cpu index, (continued)
- [PATCH v5 08/20] hw/timer: convert mptimer access to attrs to derive cpu index, Alex Bennée, 2022/11/11
- [PATCH v5 07/20] hw/intc/gic: use MxTxAttrs to divine accessing CPU, Alex Bennée, 2022/11/11
- [PATCH v5 17/20] hw/intc: properly model IOAPIC MSI messages, Alex Bennée, 2022/11/11
- [PATCH v5 02/20] target/arm: ensure TCG IO accesses set appropriate MemTxAttrs, Alex Bennée, 2022/11/11
- [PATCH v5 01/20] hw: encode accessing CPU index in MemTxAttrs, Alex Bennée, 2022/11/11
- [PATCH v5 15/20] hw/i386: update vapic_write to use MemTxAttrs,
Alex Bennée <=
- [PATCH v5 19/20] hw/isa: derive CPUState from MemTxAttrs in apm_ioport_writeb, Alex Bennée, 2022/11/11
- [PATCH v5 06/20] qtest: make read/write operation appear to be from CPU, Alex Bennée, 2022/11/11
- [PATCH v5 09/20] hw/arm: remove current_cpu hack from pxa2xx access, Alex Bennée, 2022/11/11
- [PATCH v5 10/20] target/microblaze: initialise MemTxAttrs for CPU access, Alex Bennée, 2022/11/11