Il sab 9 mag 2020, 22:01 Philippe Mathieu-Daudé <f4...@amsat.org> 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