All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Peter Maydell" <peter.maydell@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PATCH 08/10] hw/core/cpu: Pass CPUArchState to set/get_pc() handlers
Date: Fri, 15 Nov 2024 17:21:07 +0100	[thread overview]
Message-ID: <483152fa-78a1-4e65-bec3-e7fb31b96929@redhat.com> (raw)
In-Reply-To: <CAFEAcA8X8zp7oXKjiVOL_uCGdM8r00jW6S1efkm-M6f4fEuGdg@mail.gmail.com>

On 11/15/24 16:54, Peter Maydell wrote:
> On Fri, 15 Nov 2024 at 15:22, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> CPUClass set_pc() and get_pc() handlers are target specific.
>> Rather than passing a generic CPUState and forcing QOM casts,
>> we can directly pass the target CPUArchState, simplifying.
> 
>> diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
>> index db8a6fbc6e..70f5f8c3bf 100644
>> --- a/include/hw/core/cpu.h
>> +++ b/include/hw/core/cpu.h
>> @@ -160,8 +160,8 @@ struct CPUClass {
>>       int64_t (*get_arch_id)(CPUState *cpu);
>>       bool (*cpu_persistent_status)(CPUState *cpu);
>>       bool (*cpu_enabled_status)(CPUState *cpu);
>> -    void (*set_pc)(CPUState *cpu, vaddr value);
>> -    vaddr (*get_pc)(CPUState *cpu);
>> +    void (*set_pc)(CPUArchState *env, vaddr value);
>> +    vaddr (*get_pc)(CPUArchState *env);
>>       int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
>>       int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
>>       vaddr (*gdb_adjust_breakpoint)(CPUState *cpu, vaddr addr);
> 
> This is effectively the table of methods for the CPUClass
> class. I think that methods on class A should take a pointer to the
> object of that type, not to something else.

Yeah, the diffstat is enticing but I agree.  It's particularly confusing 
because there isn't a single type called CPUArchState*, it's different 
depending on which target/ subdirectory you're compiling. In a 
multi-target binary it'd have to be void*, and then you get back the casts.


Paolo



  reply	other threads:[~2024-11-15 16:21 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-15 15:20 [PATCH 00/10] accel/tcg: API prototype cleanups Philippe Mathieu-Daudé
2024-11-15 15:20 ` [PATCH 01/10] target/mips: Drop left-over comment about Jazz machine Philippe Mathieu-Daudé
2024-11-15 15:39   ` Peter Maydell
2024-11-15 17:14   ` Richard Henderson
2024-11-15 15:20 ` [PATCH 02/10] target/loongarch: Declare loongarch_cpu_dump_state() locally Philippe Mathieu-Daudé
2024-11-15 15:40   ` Peter Maydell
2024-11-15 17:15   ` Richard Henderson
2024-11-15 15:20 ` [PATCH 03/10] target/sparc: Move sparc_restore_state_to_opc() to cpu.c Philippe Mathieu-Daudé
2024-11-15 15:42   ` Peter Maydell
2024-11-15 17:17   ` Richard Henderson
2024-11-15 15:20 ` [PATCH 04/10] accel/tcg: Ensure frontends define restore_state_to_opc handler Philippe Mathieu-Daudé
2024-11-15 15:20 ` [PATCH 05/10] accel/tcg: Move cpu_unwind_state_data() declaration Philippe Mathieu-Daudé
2024-11-15 15:48   ` Peter Maydell
2024-11-15 16:04     ` Philippe Mathieu-Daudé
2024-11-15 15:20 ` [PATCH 06/10] accel/tcg: Remove cpu_unwind_state_data() unused CPUState argument Philippe Mathieu-Daudé
2024-11-15 15:50   ` Peter Maydell
2024-11-15 17:23   ` Richard Henderson
2024-11-15 17:33     ` Peter Maydell
2025-03-19  7:53       ` Philippe Mathieu-Daudé
2024-11-15 15:20 ` [PATCH 07/10] accel/tcg: Reduce log_pc() declaration scope Philippe Mathieu-Daudé
2024-11-15 15:51   ` Peter Maydell
2024-11-15 17:26   ` Richard Henderson
2024-11-15 15:20 ` [PATCH 08/10] hw/core/cpu: Pass CPUArchState to set/get_pc() handlers Philippe Mathieu-Daudé
2024-11-15 15:54   ` Peter Maydell
2024-11-15 16:21     ` Paolo Bonzini [this message]
2024-11-15 17:51       ` Richard Henderson
2024-11-15 15:20 ` [PATCH 09/10] hw/core/cpu: Pass CPUArchState to restore_state_to_opc() handler Philippe Mathieu-Daudé
2024-11-15 15:20 ` [PATCH 10/10] hw/core/cpu: Pass CPUArchState to cpu_dump_state() handler Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=483152fa-78a1-4e65-bec3-e7fb31b96929@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.