[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 10/23] cpu: Directly use get_memory_mapping() fallback handler
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v7 10/23] cpu: Directly use get_memory_mapping() fallback handlers in place |
Date: |
Mon, 17 May 2021 12:51:27 +0200 |
No code uses CPUClass::get_memory_mapping() outside of hw/core/cpu.c:
$ git grep -F -- '->get_memory_mapping'
hw/core/cpu.c:87: cc->get_memory_mapping(cpu, list, errp);
hw/core/cpu.c:439: k->get_memory_mapping = cpu_common_get_memory_mapping;
target/i386/cpu.c:7422: cc->get_memory_mapping =
x86_cpu_get_memory_mapping;
Check the handler presence in place and remove the common fallback code.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/core/cpu-common.c | 16 ----------------
hw/core/cpu-sysemu.c | 13 +++++++++++++
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index 2aa6b8cffca..9530e266ecb 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -66,21 +66,6 @@ CPUState *cpu_create(const char *typename)
return cpu;
}
-void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
- Error **errp)
-{
- CPUClass *cc = CPU_GET_CLASS(cpu);
-
- cc->get_memory_mapping(cpu, list, errp);
-}
-
-static void cpu_common_get_memory_mapping(CPUState *cpu,
- MemoryMappingList *list,
- Error **errp)
-{
- error_setg(errp, "Obtaining memory mappings is unsupported on this CPU.");
-}
-
/* Resetting the IRQ comes from across the code base so we take the
* BQL here if we need to. cpu_interrupt assumes it is held.*/
void cpu_reset_interrupt(CPUState *cpu, int mask)
@@ -304,7 +289,6 @@ static void cpu_class_init(ObjectClass *klass, void *data)
k->parse_features = cpu_common_parse_features;
k->get_arch_id = cpu_common_get_arch_id;
k->has_work = cpu_common_has_work;
- k->get_memory_mapping = cpu_common_get_memory_mapping;
k->gdb_read_register = cpu_common_gdb_read_register;
k->gdb_write_register = cpu_common_gdb_write_register;
set_bit(DEVICE_CATEGORY_CPU, dc->categories);
diff --git a/hw/core/cpu-sysemu.c b/hw/core/cpu-sysemu.c
index 931ba46354d..aa68ca281e8 100644
--- a/hw/core/cpu-sysemu.c
+++ b/hw/core/cpu-sysemu.c
@@ -33,6 +33,19 @@ bool cpu_paging_enabled(const CPUState *cpu)
return false;
}
+void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
+ Error **errp)
+{
+ CPUClass *cc = CPU_GET_CLASS(cpu);
+
+ if (cc->get_memory_mapping) {
+ cc->get_memory_mapping(cpu, list, errp);
+ return;
+ }
+
+ error_setg(errp, "Obtaining memory mappings is unsupported on this CPU.");
+}
+
hwaddr cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
MemTxAttrs *attrs)
{
--
2.26.3
- Re: [PATCH v7 02/23] cpu: Restrict target cpu_do_transaction_failed() handlers to sysemu, (continued)
- [PATCH v7 03/23] cpu: Restrict target cpu_do_unaligned_access() handlers to sysemu, Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 04/23] cpu: Remove duplicated 'sysemu/hw_accel.h' header, Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 05/23] cpu: Split as cpu-common / cpu-sysemu, Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 06/23] cpu: Un-inline cpu_get_phys_page_debug and cpu_asidx_from_attrs, Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 07/23] cpu: Introduce cpu_virtio_is_big_endian(), Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 08/23] cpu: Directly use cpu_write_elf*() fallback handlers in place, Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 09/23] cpu: Directly use get_paging_enabled() fallback handlers in place, Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 10/23] cpu: Directly use get_memory_mapping() fallback handlers in place,
Philippe Mathieu-Daudé <=
- [PATCH v7 11/23] cpu: Assert DeviceClass::vmsd is NULL on user emulation, Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 12/23] cpu: Rename CPUClass vmsd -> legacy_vmsd, Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 13/23] cpu: Move AVR target vmsd field from CPUClass to DeviceClass, Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 14/23] cpu: Introduce SysemuCPUOps structure, Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 15/23] cpu: Move CPUClass::vmsd to SysemuCPUOps, Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 16/23] cpu: Move CPUClass::virtio_is_big_endian to SysemuCPUOps, Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 17/23] cpu: Move CPUClass::get_crash_info to SysemuCPUOps, Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 18/23] cpu: Move CPUClass::write_elf* to SysemuCPUOps, Philippe Mathieu-Daudé, 2021/05/17
- [PATCH v7 19/23] cpu: Move CPUClass::asidx_from_attrs to SysemuCPUOps, Philippe Mathieu-Daudé, 2021/05/17