[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 42/53] hw/core: introduce a 'format_tlb' callback
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH v2 42/53] hw/core: introduce a 'format_tlb' callback |
Date: |
Tue, 14 Sep 2021 19:02:19 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
On 9/14/21 6:34 PM, Daniel P. Berrangé wrote:
> On Tue, Sep 14, 2021 at 05:56:09PM +0200, Philippe Mathieu-Daudé wrote:
>> On 9/14/21 4:20 PM, Daniel P. Berrangé wrote:
>>> This will allow us to reduce duplication between the different targets
>>> implementing the 'info tlb' command.
>>>
>>> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
>>> ---
>>> hw/core/cpu-common.c | 9 +++++++++
>>> include/hw/core/cpu.h | 11 +++++++++++
>>> 2 files changed, 20 insertions(+)
>>
>>> diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
>>> index 4c47e1df18..64fc57c8d9 100644
>>> --- a/include/hw/core/cpu.h
>>> +++ b/include/hw/core/cpu.h
>>> * @has_work: Callback for checking if there is work to do.
>>> * @memory_rw_debug: Callback for GDB memory access.
>>> * @format_state: Callback for formatting state.
>>> + * @format_tlb: Callback for formatting memory mappings
"... for formatting translations of virtual to physical memory mappings"
>>> * @get_arch_id: Callback for getting architecture-dependent CPU ID.
>>> * @set_pc: Callback for setting the Program Counter register. This
>>> * should have the semantics used by the target architecture when
>>> @@ -136,6 +137,7 @@ struct CPUClass {
>>> int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
>>> uint8_t *buf, int len, bool is_write);
>>> void (*format_state)(CPUState *cpu, GString *buf, int flags);
>>> + void (*format_tlb)(CPUState *cpu, GString *buf);
>>
>> Doesn't this belong to SysemuCPUOps?
>
> I can't really answer, since my knowledge of this area of QEMU code is
> fairly mimimal. I put it here because it is basically serving the same
> purpose as the "format_state" callback immediately above it, which was
> a rename of the existing "dump_state" callback. I assumed whatever was
> there already was a good practice to follow[1]...
Since it involves physical memory, I'm pretty sure this is sysemu
specific. Beside in the following patches you guard the handlers
with '#ifndef CONFIG_USER_ONLY'.
Good news, there is very few changes needed in your patches, for
example the next patch:
-- >8 --
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index ab86224ee23..9d2bd2e2ef4 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6732,6 +6732,7 @@ static Property x86_cpu_properties[] = {
#include "hw/core/sysemu-cpu-ops.h"
static const struct SysemuCPUOps i386_sysemu_ops = {
+ .format_tlb = x86_cpu_format_tlb,
.get_memory_mapping = x86_cpu_get_memory_mapping,
.get_paging_enabled = x86_cpu_get_paging_enabled,
.get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug,
@@ -6765,9 +6766,6 @@ static void x86_cpu_common_class_init(ObjectClass
*oc, void *data)
cc->parse_features = x86_cpu_parse_featurestr;
cc->has_work = x86_cpu_has_work;
cc->format_state = x86_cpu_format_state;
-#ifndef CONFIG_USER_ONLY
- cc->format_tlb = x86_cpu_format_tlb;
-#endif
cc->set_pc = x86_cpu_set_pc;
cc->gdb_read_register = x86_cpu_gdb_read_register;
cc->gdb_write_register = x86_cpu_gdb_write_register;
---
>
> Regards,
> Daniel
>
> [1] yes assuming these things is often foolish in QEMU :-)
>
- [PATCH v2 37/53] qapi: introduce x-query-cmma QMP command, (continued)
- [PATCH v2 37/53] qapi: introduce x-query-cmma QMP command, Daniel P . Berrangé, 2021/09/14
- [PATCH v2 38/53] qapi: introduce x-query-lapic QMP command, Daniel P . Berrangé, 2021/09/14
- [PATCH v2 39/53] qapi: introduce x-query-irq QMP command, Daniel P . Berrangé, 2021/09/14
- [PATCH v2 40/53] hw/core: drop "dump_state" callback from CPU targets, Daniel P . Berrangé, 2021/09/14
- [PATCH v2 41/53] hw/core: drop support for NULL pointer for FILE * in cpu_dump_state, Daniel P . Berrangé, 2021/09/14
- [PATCH v2 42/53] hw/core: introduce a 'format_tlb' callback, Daniel P . Berrangé, 2021/09/14
[PATCH v2 43/53] target/i386: convert to use format_tlb callback, Daniel P . Berrangé, 2021/09/14
[PATCH v2 44/53] target/m68k: convert to use format_tlb callback, Daniel P . Berrangé, 2021/09/14
[PATCH v2 45/53] target/nios2: convert to use format_tlb callback, Daniel P . Berrangé, 2021/09/14
[PATCH v2 46/53] target/ppc: convert to use format_tlb callback, Daniel P . Berrangé, 2021/09/14
[PATCH v2 47/53] target/sh4: convert to use format_tlb callback, Daniel P . Berrangé, 2021/09/14
[PATCH v2 48/53] target/sparc: convert to use format_tlb callback, Daniel P . Berrangé, 2021/09/14