public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Mads Ynddal <mads@ynddal.dk>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"open list:Overall KVM CPUs" <kvm@vger.kernel.org>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>
Subject: Re: [PATCH] gdbstub: move update guest debug to accel ops
Date: Wed, 14 Dec 2022 14:16:47 +0000	[thread overview]
Message-ID: <87h6xyjcdh.fsf@linaro.org> (raw)
In-Reply-To: <C8BC6E24-F98D-428D-80F8-98BDA40C7B15@ynddal.dk>


Mads Ynddal <mads@ynddal.dk> writes:

>> Isn't this '0' flag here accelerator-specific? ...
>
>> ... if so the prototype should be:
>> 
>>       int (*update_guest_debug)(CPUState *cpu);
>> 
>> and the '0' value set within kvm-accel-ops.c handler implementation.
>> 
>
> You're right, we can avoid the additional variable. We'll then have to wrap
> `kvm_update_guest_debug`. Would the following be ok?
>
> diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
> index 6ebf9a644f..5e0fb42408 100644
> --- a/accel/kvm/kvm-accel-ops.c
> +++ b/accel/kvm/kvm-accel-ops.c
> @@ -86,6 +86,10 @@ static bool kvm_cpus_are_resettable(void)
>      return !kvm_enabled() || kvm_cpu_check_are_resettable();
>  }
>  
> +static int kvm_update_guest_debug_ops(CPUState *cpu) {
> +    return kvm_update_guest_debug(cpu, 0);
> +}
> +
>  static void kvm_accel_ops_class_init(ObjectClass *oc, void *data)
>  {
>      AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
> @@ -99,7 +103,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, void *data)
>      ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm;
>  
>  #ifdef KVM_CAP_SET_GUEST_DEBUG
> -    ops->update_guest_debug = kvm_update_guest_debug;
> +    ops->update_guest_debug = kvm_update_guest_debug_ops;
>      ops->supports_guest_debug = kvm_supports_guest_debug;
>      ops->insert_breakpoint = kvm_insert_breakpoint;
>      ops->remove_breakpoint = kvm_remove_breakpoint;
> diff --git a/cpu.c b/cpu.c
> index ef433a79e3..b2ade96caa 100644
> --- a/cpu.c
> +++ b/cpu.c
> @@ -383,7 +383,7 @@ void cpu_single_step(CPUState *cpu, int enabled)
>          cpu->singlestep_enabled = enabled;
>  
>          if (ops->update_guest_debug) {
> -            ops->update_guest_debug(cpu, 0);
> +            ops->update_guest_debug(cpu);
>          }
>  
>          trace_breakpoint_singlestep(cpu->cpu_index, enabled);
> diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h
> index 0a47a2f00c..cd6a4ef7a5 100644
> --- a/include/sysemu/accel-ops.h
> +++ b/include/sysemu/accel-ops.h
> @@ -48,7 +48,7 @@ struct AccelOpsClass {
>  
>      /* gdbstub hooks */
>      bool (*supports_guest_debug)(void);
> -    int (*update_guest_debug)(CPUState *cpu, unsigned long flags);
> +    int (*update_guest_debug)(CPUState *cpu);
>      int (*insert_breakpoint)(CPUState *cpu, int type, hwaddr addr, hwaddr len);
>      int (*remove_breakpoint)(CPUState *cpu, int type, hwaddr addr, hwaddr len);
>      void (*remove_all_breakpoints)(CPUState *cpu);
>
>
> If you have a better name for `kvm_update_guest_debug_ops`, I'm open for
> suggestions.

It will do. You could just call it update_guest_debug as it is an
internal static function although I guess that makes grepping a bit of a
pain.

> On a side note. When compiling for an arch that isn't the same as the system
> (i.e. aarch64 on x86_64), I'm getting a linker-error for cpu.c that
> `cpus_get_accel` isn't defined. Do I need to move `cpus_get_accel` or somehow
> #ifdef its use?

Is something being accidentally linked with linux-user and softmmu?

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro

  reply	other threads:[~2022-12-14 14:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23 12:17 [PATCH] gdbstub: move update guest debug to accel ops Mads Ynddal
2022-11-23 12:25 ` Mads Ynddal
2022-11-23 14:05 ` Alex Bennée
2022-11-23 14:41   ` Mads Ynddal
2022-11-23 18:20 ` Philippe Mathieu-Daudé
2022-11-24 13:59   ` Mads Ynddal
2022-12-14 14:16     ` Alex Bennée [this message]
2022-12-20 10:45       ` Mads Ynddal
2023-02-06 13:52         ` Alex Bennée
2023-02-07 11:58           ` Mads Ynddal

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=87h6xyjcdh.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=eduardo@habkost.net \
    --cc=kvm@vger.kernel.org \
    --cc=mads@ynddal.dk \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=wangyanan55@huawei.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox