qemu-s390x
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 09/11] target/cpu: Restrict handlers using hwaddr type to sys


From: Paolo Bonzini
Subject: Re: [PATCH 09/11] target/cpu: Restrict handlers using hwaddr type to system-mode
Date: Sat, 9 May 2020 23:03:24 +0200



Il sab 9 mag 2020, 22:01 Philippe Mathieu-Daudé <address@hidden> ha scritto:
> I forgot once Peter Maydell told me we can't do that for some reason I
> don't remember.
>
> At least this changes the sizeof(CPUClass), so we get:
>
> qom/object.c:315:type_initialize: assertion failed: (parent->class_size
> <= ti->class_size)
>
> So we can't poison the hwaddr type? (final patch of this series).

Well, this works...:

-- >8 --
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -167,6 +167,7 @@ typedef struct CPUClass {
     int reset_dump_flags;
     bool (*has_work)(CPUState *cpu);
     void (*do_interrupt)(CPUState *cpu);
+#ifndef CONFIG_USER_ONLY
     void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
                                 MMUAccessType access_type,
                                 int mmu_idx, uintptr_t retaddr);
@@ -174,6 +175,12 @@ typedef struct CPUClass {
                                   unsigned size, MMUAccessType access_type,
                                   int mmu_idx, MemTxAttrs attrs,
                                   MemTxResult response, uintptr_t retaddr);
+    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
+    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
+                                        MemTxAttrs *attrs);
+#else
+    void (*reserved[4])(CPUState *cpu, ...);
+#endif /* CONFIG_USER_ONLY */
     bool (*virtio_is_big_endian)(CPUState *cpu);
     int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
                            uint8_t *buf, int len, bool is_write);
@@ -189,9 +196,6 @@ typedef struct CPUClass {
     bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
                      MMUAccessType access_type, int mmu_idx,
                      bool probe, uintptr_t retaddr);
-    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
-    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
-                                        MemTxAttrs *attrs);
     int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
     int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
     int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
---

Ugly?

More. :-) And hwaddr is only a small part, there are several other methods that only make sense for system emulation. Let me review the rest of the series, it may not be good enough to stop here while we figure out a way.

Paolo


>
> >       void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
> >                                   MMUAccessType access_type,
> >                                   int mmu_idx, uintptr_t retaddr);
> > @@ -174,6 +175,10 @@ typedef struct CPUClass {
> >                                     unsigned size, MMUAccessType access_type,
> >                                     int mmu_idx, MemTxAttrs attrs,
> >                                     MemTxResult response, uintptr_t retaddr);
> > +    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> > +    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> > +                                        MemTxAttrs *attrs);
> > +#endif /* CONFIG_USER_ONLY */
> >       bool (*virtio_is_big_endian)(CPUState *cpu);
> >       int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
> >                              uint8_t *buf, int len, bool is_write);
> > @@ -189,9 +194,6 @@ typedef struct CPUClass {
> >       bool (*tlb_fill)(CPUState *cpu, vaddr address, int size,
> >                        MMUAccessType access_type, int mmu_idx,
> >                        bool probe, uintptr_t retaddr);
> > -    hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
> > -    hwaddr (*get_phys_page_attrs_debug)(CPUState *cpu, vaddr addr,
> > -                                        MemTxAttrs *attrs);
> >       int (*asidx_from_attrs)(CPUState *cpu, MemTxAttrs attrs);
> >       int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
> >       int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
> [...]


reply via email to

[Prev in Thread] Current Thread [Next in Thread]