[PATCH 1/7] whpx: re-enable guest debug support on x86

Mohamed Mediouni posted 7 patches 1 month, 4 weeks ago
There is a newer version of this series
[PATCH 1/7] whpx: re-enable guest debug support on x86
Posted by Mohamed Mediouni 1 month, 4 weeks ago
Fix what got broken several years ago by adding ops->supports_guest_debug
support as an architecture-specific function.

arm64 WHP doesn't currently provide support needed for this.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
 accel/whpx/whpx-accel-ops.c | 8 ++++++++
 include/system/whpx-all.h   | 4 ++++
 target/arm/whpx/whpx-all.c  | 5 +++++
 target/i386/whpx/whpx-all.c | 5 +++++
 4 files changed, 22 insertions(+)

diff --git a/accel/whpx/whpx-accel-ops.c b/accel/whpx/whpx-accel-ops.c
index 50fadea0fd..b8f41544cb 100644
--- a/accel/whpx/whpx-accel-ops.c
+++ b/accel/whpx/whpx-accel-ops.c
@@ -17,6 +17,7 @@
 
 #include "system/whpx.h"
 #include "system/whpx-internal.h"
+#include "system/whpx-all.h"
 #include "system/whpx-accel-ops.h"
 
 static void *whpx_cpu_thread_fn(void *arg)
@@ -81,6 +82,12 @@ static bool whpx_vcpu_thread_is_idle(CPUState *cpu)
     return !whpx_irqchip_in_kernel();
 }
 
+static bool whpx_supports_guest_debug(void)
+{
+    return whpx_arch_supports_guest_debug();
+}
+
+
 static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
 {
     AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
@@ -89,6 +96,7 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
     ops->kick_vcpu_thread = whpx_kick_vcpu_thread;
     ops->cpu_thread_is_idle = whpx_vcpu_thread_is_idle;
     ops->handle_interrupt = generic_handle_interrupt;
+    ops->supports_guest_debug = whpx_supports_guest_debug;
 
     ops->synchronize_post_reset = whpx_cpu_synchronize_post_reset;
     ops->synchronize_post_init = whpx_cpu_synchronize_post_init;
diff --git a/include/system/whpx-all.h b/include/system/whpx-all.h
index f13cdf7f66..3db074c38c 100644
--- a/include/system/whpx-all.h
+++ b/include/system/whpx-all.h
@@ -17,4 +17,8 @@ void whpx_translate_cpu_breakpoints(
     struct whpx_breakpoints *breakpoints,
     CPUState *cpu,
     int cpu_breakpoint_count);
+
+/* called by whpx-accel-ops */
+bool whpx_arch_supports_guest_debug(void);
+
 #endif
diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c
index 36c5e30a03..8d0ca794af 100644
--- a/target/arm/whpx/whpx-all.c
+++ b/target/arm/whpx/whpx-all.c
@@ -304,6 +304,11 @@ void whpx_translate_cpu_breakpoints(
     /* Breakpoints aren’t supported on this platform */
 }
 
+bool whpx_arch_supports_guest_debug(void) 
+{
+    return false;
+}
+
 static void whpx_get_reg(CPUState *cpu, WHV_REGISTER_NAME reg, WHV_REGISTER_VALUE* val)
 {
     struct whpx_state *whpx = &whpx_global;
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 8210250dc3..e1f0fa5e77 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -1272,6 +1272,11 @@ void whpx_apply_breakpoints(
     }
 }
 
+bool whpx_arch_supports_guest_debug(void) 
+{
+    return true;
+}
+
 /* Returns the address of the next instruction that is about to be executed. */
 static vaddr whpx_vcpu_get_pc(CPUState *cpu, bool exit_context_valid)
 {
-- 
2.50.1 (Apple Git-155)


Re: [PATCH 1/7] whpx: re-enable guest debug support on x86
Posted by Alex Bennée 1 month, 4 weeks ago
Mohamed Mediouni <mohamed@unpredictable.fr> writes:

> Fix what got broken several years ago by adding ops->supports_guest_debug
> support as an architecture-specific function.

I was going to say does this need a:

Fixes: a48e7d9e52f (gdbstub: move guest debug support check to ops)

But I can't see how whpx debug would have worked before that anyway.

>
> arm64 WHP doesn't currently provide support needed for this.
>
> Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
> ---
>  accel/whpx/whpx-accel-ops.c | 8 ++++++++
>  include/system/whpx-all.h   | 4 ++++
>  target/arm/whpx/whpx-all.c  | 5 +++++
>  target/i386/whpx/whpx-all.c | 5 +++++
>  4 files changed, 22 insertions(+)
>
> diff --git a/accel/whpx/whpx-accel-ops.c b/accel/whpx/whpx-accel-ops.c
> index 50fadea0fd..b8f41544cb 100644
> --- a/accel/whpx/whpx-accel-ops.c
> +++ b/accel/whpx/whpx-accel-ops.c
> @@ -17,6 +17,7 @@
>  
>  #include "system/whpx.h"
>  #include "system/whpx-internal.h"
> +#include "system/whpx-all.h"
>  #include "system/whpx-accel-ops.h"
>  
>  static void *whpx_cpu_thread_fn(void *arg)
> @@ -81,6 +82,12 @@ static bool whpx_vcpu_thread_is_idle(CPUState *cpu)
>      return !whpx_irqchip_in_kernel();
>  }
>  
> +static bool whpx_supports_guest_debug(void)
> +{
> +    return whpx_arch_supports_guest_debug();
> +}
> +
> +
>  static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
>  {
>      AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
> @@ -89,6 +96,7 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
>      ops->kick_vcpu_thread = whpx_kick_vcpu_thread;
>      ops->cpu_thread_is_idle = whpx_vcpu_thread_is_idle;
>      ops->handle_interrupt = generic_handle_interrupt;
> +    ops->supports_guest_debug = whpx_supports_guest_debug;
>  
>      ops->synchronize_post_reset = whpx_cpu_synchronize_post_reset;
>      ops->synchronize_post_init = whpx_cpu_synchronize_post_init;
> diff --git a/include/system/whpx-all.h b/include/system/whpx-all.h
> index f13cdf7f66..3db074c38c 100644
> --- a/include/system/whpx-all.h
> +++ b/include/system/whpx-all.h
> @@ -17,4 +17,8 @@ void whpx_translate_cpu_breakpoints(
>      struct whpx_breakpoints *breakpoints,
>      CPUState *cpu,
>      int cpu_breakpoint_count);
> +
> +/* called by whpx-accel-ops */
> +bool whpx_arch_supports_guest_debug(void);
> +
>  #endif
> diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c
> index 36c5e30a03..8d0ca794af 100644
> --- a/target/arm/whpx/whpx-all.c
> +++ b/target/arm/whpx/whpx-all.c
> @@ -304,6 +304,11 @@ void whpx_translate_cpu_breakpoints(
>      /* Breakpoints aren’t supported on this platform */
>  }
>  
> +bool whpx_arch_supports_guest_debug(void) 
> +{
> +    return false;
> +}
> +
>  static void whpx_get_reg(CPUState *cpu, WHV_REGISTER_NAME reg, WHV_REGISTER_VALUE* val)
>  {
>      struct whpx_state *whpx = &whpx_global;
> diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
> index 8210250dc3..e1f0fa5e77 100644
> --- a/target/i386/whpx/whpx-all.c
> +++ b/target/i386/whpx/whpx-all.c
> @@ -1272,6 +1272,11 @@ void whpx_apply_breakpoints(
>      }
>  }
>  
> +bool whpx_arch_supports_guest_debug(void) 
> +{
> +    return true;
> +}
> +
>  /* Returns the address of the next instruction that is about to be executed. */
>  static vaddr whpx_vcpu_get_pc(CPUState *cpu, bool exit_context_valid)
>  {

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro