diff mbox series

[03/13] accel: Elide kvm_update_guest_debug by checking kvm_supports_guest_debug

Message ID 20220208152243.16452-4-f4bug@amsat.org (mailing list archive)
State New, archived
Headers show
Series exec: Move translation declarations to 'translate-all.h' | expand

Commit Message

Philippe Mathieu-Daudé Feb. 8, 2022, 3:22 p.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 accel/stubs/kvm-stub.c | 5 -----
 cpu.c                  | 2 +-
 2 files changed, 1 insertion(+), 6 deletions(-)

Comments

Richard Henderson Feb. 8, 2022, 10:16 p.m. UTC | #1
On 2/9/22 02:22, Philippe Mathieu-Daudé wrote:
> -int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)
> -{
> -    return -ENOSYS;
> -}
> -
>   int kvm_insert_breakpoint(CPUState *cpu, target_ulong addr,
>                             target_ulong len, int type)
>   {
> diff --git a/cpu.c b/cpu.c
> index 97d42b6b2a..834e2b4cdb 100644
> --- a/cpu.c
> +++ b/cpu.c
> @@ -350,7 +350,7 @@ void cpu_single_step(CPUState *cpu, int enabled)
>   {
>       if (cpu->singlestep_enabled != enabled) {
>           cpu->singlestep_enabled = enabled;
> -        if (kvm_enabled()) {
> +        if (kvm_enabled() && kvm_supports_guest_debug()) {
>               kvm_update_guest_debug(cpu, 0);

Why is this second hunk required?

I would think the stub would be removable on its own, since it is protected by 
kvm_enabled, which will expand to false exactly like kvm_supports_guest_debug expands to 
false.

As an aside, I wonder about the non-checking of the update return value...


r~
diff mbox series

Patch

diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c
index 7e0fb884b9..924ffbde85 100644
--- a/accel/stubs/kvm-stub.c
+++ b/accel/stubs/kvm-stub.c
@@ -46,11 +46,6 @@  int kvm_has_many_ioeventfds(void)
     return 0;
 }
 
-int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)
-{
-    return -ENOSYS;
-}
-
 int kvm_insert_breakpoint(CPUState *cpu, target_ulong addr,
                           target_ulong len, int type)
 {
diff --git a/cpu.c b/cpu.c
index 97d42b6b2a..834e2b4cdb 100644
--- a/cpu.c
+++ b/cpu.c
@@ -350,7 +350,7 @@  void cpu_single_step(CPUState *cpu, int enabled)
 {
     if (cpu->singlestep_enabled != enabled) {
         cpu->singlestep_enabled = enabled;
-        if (kvm_enabled()) {
+        if (kvm_enabled() && kvm_supports_guest_debug()) {
             kvm_update_guest_debug(cpu, 0);
         }
         trace_breakpoint_singlestep(cpu->cpu_index, enabled);