* [PATCH] target/arm: kvm64: remove a redundant KVM_CAP_SET_GUEST_DEBUG probe
@ 2023-10-25 7:07 Chao Du
2023-11-22 8:15 ` Chao Du
0 siblings, 1 reply; 4+ messages in thread
From: Chao Du @ 2023-10-25 7:07 UTC (permalink / raw)
To: qemu-devel, qemu-arm
The KVM_CAP_SET_GUEST_DEBUG is probed during kvm_init().
gdbserver will fail to start if the CAP is not supported.
So no need to make another probe here, like other targets.
Signed-off-by: Chao Du <duchao@eswincomputing.com>
---
target/arm/kvm64.c | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
index 4bb68646e4..b0bf59b5a1 100644
--- a/target/arm/kvm64.c
+++ b/target/arm/kvm64.c
@@ -31,13 +31,9 @@
#include "hw/acpi/acpi.h"
#include "hw/acpi/ghes.h"
-static bool have_guest_debug;
void kvm_arm_init_debug(KVMState *s)
{
- have_guest_debug = kvm_check_extension(s,
- KVM_CAP_SET_GUEST_DEBUG);
-
max_hw_wps = kvm_check_extension(s, KVM_CAP_GUEST_DEBUG_HW_WPS);
hw_watchpoints = g_array_sized_new(true, true,
sizeof(HWWatchpoint), max_hw_wps);
@@ -1140,33 +1136,23 @@ static const uint32_t brk_insn = 0xd4200000;
int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
{
- if (have_guest_debug) {
- if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 0) ||
- cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk_insn, 4, 1)) {
- return -EINVAL;
- }
- return 0;
- } else {
- error_report("guest debug not supported on this kernel");
+ if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 0) ||
+ cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk_insn, 4, 1)) {
return -EINVAL;
}
+ return 0;
}
int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
{
static uint32_t brk;
- if (have_guest_debug) {
- if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk, 4, 0) ||
- brk != brk_insn ||
- cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 1)) {
- return -EINVAL;
- }
- return 0;
- } else {
- error_report("guest debug not supported on this kernel");
+ if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk, 4, 0) ||
+ brk != brk_insn ||
+ cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 1)) {
return -EINVAL;
}
+ return 0;
}
/* See v8 ARM ARM D7.2.27 ESR_ELx, Exception Syndrome Register
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] target/arm: kvm64: remove a redundant KVM_CAP_SET_GUEST_DEBUG probe
@ 2023-10-25 8:37 Chao Du
0 siblings, 0 replies; 4+ messages in thread
From: Chao Du @ 2023-10-25 8:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-arm
The KVM_CAP_SET_GUEST_DEBUG is probed during kvm_init().
gdbserver will fail to start if the CAP is not supported.
So no need to make another probe here, like other targets.
Signed-off-by: Chao Du <duchao@eswincomputing.com>
---
target/arm/kvm64.c | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
index 4bb68646e4..b0bf59b5a1 100644
--- a/target/arm/kvm64.c
+++ b/target/arm/kvm64.c
@@ -31,13 +31,9 @@
#include "hw/acpi/acpi.h"
#include "hw/acpi/ghes.h"
-static bool have_guest_debug;
void kvm_arm_init_debug(KVMState *s)
{
- have_guest_debug = kvm_check_extension(s,
- KVM_CAP_SET_GUEST_DEBUG);
-
max_hw_wps = kvm_check_extension(s, KVM_CAP_GUEST_DEBUG_HW_WPS);
hw_watchpoints = g_array_sized_new(true, true,
sizeof(HWWatchpoint), max_hw_wps);
@@ -1140,33 +1136,23 @@ static const uint32_t brk_insn = 0xd4200000;
int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
{
- if (have_guest_debug) {
- if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 0) ||
- cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk_insn, 4, 1)) {
- return -EINVAL;
- }
- return 0;
- } else {
- error_report("guest debug not supported on this kernel");
+ if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 0) ||
+ cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk_insn, 4, 1)) {
return -EINVAL;
}
+ return 0;
}
int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
{
static uint32_t brk;
- if (have_guest_debug) {
- if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk, 4, 0) ||
- brk != brk_insn ||
- cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 1)) {
- return -EINVAL;
- }
- return 0;
- } else {
- error_report("guest debug not supported on this kernel");
+ if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk, 4, 0) ||
+ brk != brk_insn ||
+ cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 1)) {
return -EINVAL;
}
+ return 0;
}
/* See v8 ARM ARM D7.2.27 ESR_ELx, Exception Syndrome Register
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] target/arm: kvm64: remove a redundant KVM_CAP_SET_GUEST_DEBUG probe
2023-10-25 7:07 [PATCH] target/arm: kvm64: remove a redundant KVM_CAP_SET_GUEST_DEBUG probe Chao Du
@ 2023-11-22 8:15 ` Chao Du
2023-11-22 16:38 ` Richard Henderson
0 siblings, 1 reply; 4+ messages in thread
From: Chao Du @ 2023-11-22 8:15 UTC (permalink / raw)
To: qemu-devel, qemu-arm; +Cc: peter.maydell, pbonzini
Hi,
Kindly ping. :)
Thanks,
Chao
> -----Original Messages-----From:"Chao Du" <duchao@eswincomputing.com>Sent Time:2023-10-25 15:07:26 (Wednesday)To:qemu-devel@nongnu.org, qemu-arm@nongnu.orgCc:Subject:[PATCH] target/arm: kvm64: remove a redundant KVM_CAP_SET_GUEST_DEBUG probe
>
> The KVM_CAP_SET_GUEST_DEBUG is probed during kvm_init().
> gdbserver will fail to start if the CAP is not supported.
> So no need to make another probe here, like other targets.
>
> Signed-off-by: Chao Du <duchao@eswincomputing.com>
> ---
> target/arm/kvm64.c | 28 +++++++---------------------
> 1 file changed, 7 insertions(+), 21 deletions(-)
>
> diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
> index 4bb68646e4..b0bf59b5a1 100644
> --- a/target/arm/kvm64.c
> +++ b/target/arm/kvm64.c
> @@ -31,13 +31,9 @@
> #include "hw/acpi/acpi.h"
> #include "hw/acpi/ghes.h"
>
> -static bool have_guest_debug;
>
> void kvm_arm_init_debug(KVMState *s)
> {
> - have_guest_debug = kvm_check_extension(s,
> - KVM_CAP_SET_GUEST_DEBUG);
> -
> max_hw_wps = kvm_check_extension(s, KVM_CAP_GUEST_DEBUG_HW_WPS);
> hw_watchpoints = g_array_sized_new(true, true,
> sizeof(HWWatchpoint), max_hw_wps);
> @@ -1140,33 +1136,23 @@ static const uint32_t brk_insn = 0xd4200000;
>
> int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
> {
> - if (have_guest_debug) {
> - if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 0) ||
> - cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk_insn, 4, 1)) {
> - return -EINVAL;
> - }
> - return 0;
> - } else {
> - error_report("guest debug not supported on this kernel");
> + if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 0) ||
> + cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk_insn, 4, 1)) {
> return -EINVAL;
> }
> + return 0;
> }
>
> int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
> {
> static uint32_t brk;
>
> - if (have_guest_debug) {
> - if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk, 4, 0) ||
> - brk != brk_insn ||
> - cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 1)) {
> - return -EINVAL;
> - }
> - return 0;
> - } else {
> - error_report("guest debug not supported on this kernel");
> + if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk, 4, 0) ||
> + brk != brk_insn ||
> + cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 1)) {
> return -EINVAL;
> }
> + return 0;
> }
>
> /* See v8 ARM ARM D7.2.27 ESR_ELx, Exception Syndrome Register
> --
> 2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] target/arm: kvm64: remove a redundant KVM_CAP_SET_GUEST_DEBUG probe
2023-11-22 8:15 ` Chao Du
@ 2023-11-22 16:38 ` Richard Henderson
0 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2023-11-22 16:38 UTC (permalink / raw)
To: Chao Du, qemu-devel, qemu-arm; +Cc: peter.maydell, pbonzini
On 11/22/23 02:15, Chao Du wrote:
> Hi,
>
> Kindly ping. :)
>
> Thanks,
> Chao
>
>
>> -----Original Messages-----From:"Chao Du" <duchao@eswincomputing.com>Sent Time:2023-10-25 15:07:26 (Wednesday)To:qemu-devel@nongnu.org, qemu-arm@nongnu.orgCc:Subject:[PATCH] target/arm: kvm64: remove a redundant KVM_CAP_SET_GUEST_DEBUG probe
>>
>> The KVM_CAP_SET_GUEST_DEBUG is probed during kvm_init().
>> gdbserver will fail to start if the CAP is not supported.
>> So no need to make another probe here, like other targets.
>>
>> Signed-off-by: Chao Du <duchao@eswincomputing.com>
Correct: all handled by kvm_supports_guest_debug.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
>> ---
>> target/arm/kvm64.c | 28 +++++++---------------------
>> 1 file changed, 7 insertions(+), 21 deletions(-)
>>
>> diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
>> index 4bb68646e4..b0bf59b5a1 100644
>> --- a/target/arm/kvm64.c
>> +++ b/target/arm/kvm64.c
>> @@ -31,13 +31,9 @@
>> #include "hw/acpi/acpi.h"
>> #include "hw/acpi/ghes.h"
>>
>> -static bool have_guest_debug;
>>
>> void kvm_arm_init_debug(KVMState *s)
>> {
>> - have_guest_debug = kvm_check_extension(s,
>> - KVM_CAP_SET_GUEST_DEBUG);
>> -
>> max_hw_wps = kvm_check_extension(s, KVM_CAP_GUEST_DEBUG_HW_WPS);
>> hw_watchpoints = g_array_sized_new(true, true,
>> sizeof(HWWatchpoint), max_hw_wps);
>> @@ -1140,33 +1136,23 @@ static const uint32_t brk_insn = 0xd4200000;
>>
>> int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
>> {
>> - if (have_guest_debug) {
>> - if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 0) ||
>> - cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk_insn, 4, 1)) {
>> - return -EINVAL;
>> - }
>> - return 0;
>> - } else {
>> - error_report("guest debug not supported on this kernel");
>> + if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 0) ||
>> + cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk_insn, 4, 1)) {
>> return -EINVAL;
>> }
>> + return 0;
>> }
>>
>> int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
>> {
>> static uint32_t brk;
>>
>> - if (have_guest_debug) {
>> - if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk, 4, 0) ||
>> - brk != brk_insn ||
>> - cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 1)) {
>> - return -EINVAL;
>> - }
>> - return 0;
>> - } else {
>> - error_report("guest debug not supported on this kernel");
>> + if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk, 4, 0) ||
>> + brk != brk_insn ||
>> + cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 1)) {
>> return -EINVAL;
>> }
>> + return 0;
>> }
>>
>> /* See v8 ARM ARM D7.2.27 ESR_ELx, Exception Syndrome Register
>> --
>> 2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-22 16:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-25 7:07 [PATCH] target/arm: kvm64: remove a redundant KVM_CAP_SET_GUEST_DEBUG probe Chao Du
2023-11-22 8:15 ` Chao Du
2023-11-22 16:38 ` Richard Henderson
-- strict thread matches above, loose matches on Subject: below --
2023-10-25 8:37 Chao Du
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).