From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Thomas Huth" <thuth@redhat.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Laurent Vivier" <laurent@vivier.eu>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
qemu-s390x@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
"Claudio Fontana" <cfontana@suse.de>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: [PATCH v4 21/28] target/arm: Refactor some function bodies
Date: Wed, 3 Mar 2021 22:47:01 +0100 [thread overview]
Message-ID: <20210303214708.1727801-22-f4bug@amsat.org> (raw)
In-Reply-To: <20210303214708.1727801-1-f4bug@amsat.org>
Refactor few fonctions body to ease #ifdef'ry review
in the next commit. No logical change intented.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
Patch easier to review using:
'git-diff --color-moved-ws=allow-indentation-change'
---
target/arm/debug_helper.c | 72 +++++++++++++++++++--------------------
target/arm/helper.c | 5 ++-
2 files changed, 38 insertions(+), 39 deletions(-)
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
index c01d8524443..980110e1328 100644
--- a/target/arm/debug_helper.c
+++ b/target/arm/debug_helper.c
@@ -230,7 +230,6 @@ bool arm_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp)
static bool check_breakpoints(ARMCPU *cpu)
{
CPUARMState *env = &cpu->env;
- int n;
/*
* If breakpoints are disabled globally or we can't take debug
@@ -241,7 +240,7 @@ static bool check_breakpoints(ARMCPU *cpu)
return false;
}
- for (n = 0; n < ARRAY_SIZE(env->cpu_breakpoint); n++) {
+ for (int n = 0; n < ARRAY_SIZE(env->cpu_breakpoint); n++) {
if (bp_wp_matches(cpu, n, false)) {
return true;
}
@@ -266,47 +265,48 @@ void arm_debug_excp_handler(CPUState *cs)
*/
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
+ uint64_t pc;
+ bool same_el;
CPUWatchpoint *wp_hit = cs->watchpoint_hit;
- if (wp_hit) {
- if (wp_hit->flags & BP_CPU) {
- bool wnr = (wp_hit->flags & BP_WATCHPOINT_HIT_WRITE) != 0;
- bool same_el = arm_debug_target_el(env) == arm_current_el(env);
+ if (wp_hit && (wp_hit->flags & BP_CPU)) {
+ bool wnr = (wp_hit->flags & BP_WATCHPOINT_HIT_WRITE) != 0;
+ bool same_el = arm_debug_target_el(env) == arm_current_el(env);
- cs->watchpoint_hit = NULL;
-
- env->exception.fsr = arm_debug_exception_fsr(env);
- env->exception.vaddress = wp_hit->hitaddr;
- raise_exception(env, EXCP_DATA_ABORT,
- syn_watchpoint(same_el, 0, wnr),
- arm_debug_target_el(env));
- }
- } else {
- uint64_t pc = is_a64(env) ? env->pc : env->regs[15];
- bool same_el = (arm_debug_target_el(env) == arm_current_el(env));
-
- /*
- * (1) GDB breakpoints should be handled first.
- * (2) Do not raise a CPU exception if no CPU breakpoint has fired,
- * since singlestep is also done by generating a debug internal
- * exception.
- */
- if (cpu_breakpoint_test(cs, pc, BP_GDB)
- || !cpu_breakpoint_test(cs, pc, BP_CPU)) {
- return;
- }
+ cs->watchpoint_hit = NULL;
env->exception.fsr = arm_debug_exception_fsr(env);
- /*
- * FAR is UNKNOWN: clear vaddress to avoid potentially exposing
- * values to the guest that it shouldn't be able to see at its
- * exception/security level.
- */
- env->exception.vaddress = 0;
- raise_exception(env, EXCP_PREFETCH_ABORT,
- syn_breakpoint(same_el),
+ env->exception.vaddress = wp_hit->hitaddr;
+ raise_exception(env, EXCP_DATA_ABORT,
+ syn_watchpoint(same_el, 0, wnr),
arm_debug_target_el(env));
+ return;
}
+
+ pc = is_a64(env) ? env->pc : env->regs[15];
+ same_el = (arm_debug_target_el(env) == arm_current_el(env));
+
+ /*
+ * (1) GDB breakpoints should be handled first.
+ * (2) Do not raise a CPU exception if no CPU breakpoint has fired,
+ * since singlestep is also done by generating a debug internal
+ * exception.
+ */
+ if (cpu_breakpoint_test(cs, pc, BP_GDB)
+ || !cpu_breakpoint_test(cs, pc, BP_CPU)) {
+ return;
+ }
+
+ env->exception.fsr = arm_debug_exception_fsr(env);
+ /*
+ * FAR is UNKNOWN: clear vaddress to avoid potentially exposing
+ * values to the guest that it shouldn't be able to see at its
+ * exception/security level.
+ */
+ env->exception.vaddress = 0;
+ raise_exception(env, EXCP_PREFETCH_ABORT,
+ syn_breakpoint(same_el),
+ arm_debug_target_el(env));
}
#if !defined(CONFIG_USER_ONLY)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 0e1a3b94211..54648c7fbb6 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -6595,7 +6595,7 @@ static void define_debug_regs(ARMCPU *cpu)
* These are just dummy implementations for now.
*/
int i;
- int wrps, brps, ctx_cmps;
+ int brps, ctx_cmps;
/*
* The Arm ARM says DBGDIDR is optional and deprecated if EL1 cannot
@@ -6614,7 +6614,6 @@ static void define_debug_regs(ARMCPU *cpu)
/* Note that all these register fields hold "number of Xs minus 1". */
brps = arm_num_brps(cpu);
- wrps = arm_num_wrps(cpu);
ctx_cmps = arm_num_ctx_cmps(cpu);
assert(ctx_cmps <= brps);
@@ -6644,7 +6643,7 @@ static void define_debug_regs(ARMCPU *cpu)
define_arm_cp_regs(cpu, dbgregs);
}
- for (i = 0; i < wrps; i++) {
+ for (i = 0; i < arm_num_wrps(cpu); i++) {
ARMCPRegInfo dbgregs[] = {
{ .name = "DBGWVR", .state = ARM_CP_STATE_BOTH,
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 6,
--
2.26.2
next prev parent reply other threads:[~2021-03-03 21:59 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-03 21:46 [PATCH v4 00/28] cpu: Introduce SysemuCPUOps structure, remove watchpoints from usermode Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 01/28] target: Set CPUClass::vmsd instead of DeviceClass::vmsd Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 02/28] cpu: Un-inline cpu_get_phys_page_debug and cpu_asidx_from_attrs Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 03/28] cpu: Introduce cpu_virtio_is_big_endian() Philippe Mathieu-Daudé
2021-03-03 22:08 ` Michael S. Tsirkin
2021-03-03 22:15 ` Michael S. Tsirkin
2021-03-03 22:18 ` Richard Henderson
2021-03-03 22:24 ` Richard Henderson
2021-03-04 7:51 ` Greg Kurz
2021-04-22 10:33 ` Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 04/28] cpu: Directly use cpu_write_elf*() fallback handlers in place Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 05/28] cpu: Directly use get_paging_enabled() " Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 06/28] cpu: Directly use get_memory_mapping() " Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 07/28] cpu: Introduce SysemuCPUOps structure Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 08/28] cpu: Move CPUClass::vmsd to SysemuCPUOps Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 09/28] cpu: Move CPUClass::virtio_is_big_endian " Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 10/28] cpu: Move CPUClass::get_crash_info " Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 11/28] cpu: Move CPUClass::write_elf* " Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 12/28] cpu: Move CPUClass::asidx_from_attrs " Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 13/28] cpu: Move CPUClass::get_phys_page_debug " Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 14/28] cpu: Move CPUClass::get_memory_mapping " Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 15/28] cpu: Move CPUClass::get_paging_enabled " Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 16/28] cpu: Restrict "hw/core/sysemu-cpu-ops.h" to target/cpu.c Philippe Mathieu-Daudé
2021-03-03 22:27 ` Taylor Simpson
2021-03-03 21:46 ` [PATCH v4 17/28] linux-user: Remove dead code Philippe Mathieu-Daudé
2021-05-15 19:25 ` Laurent Vivier
2021-03-03 21:46 ` [PATCH v4 18/28] gdbstub: Remove watchpoint dead code in gdbserver_fork() Philippe Mathieu-Daudé
2021-03-03 21:46 ` [PATCH v4 19/28] target/arm/internals: Fix code style for checkpatch.pl Philippe Mathieu-Daudé
2021-03-03 21:47 ` [PATCH v4 20/28] target/arm: Move code blocks around Philippe Mathieu-Daudé
2021-03-03 21:47 ` Philippe Mathieu-Daudé [this message]
2021-03-03 21:47 ` [PATCH v4 22/28] target/arm: Restrict watchpoint code to system emulation Philippe Mathieu-Daudé
2021-03-03 22:40 ` Richard Henderson
2021-03-03 21:47 ` [PATCH v4 23/28] target/i386: " Philippe Mathieu-Daudé
2021-03-03 21:47 ` [PATCH v4 24/28] target/xtensa: " Philippe Mathieu-Daudé
2021-03-03 21:47 ` [PATCH v4 25/28] accel/tcg/cpu-exec: " Philippe Mathieu-Daudé
2021-03-03 21:47 ` [PATCH v4 26/28] cpu: Remove watchpoint stubs for user emulation Philippe Mathieu-Daudé
2021-03-03 23:28 ` Richard Henderson
2021-03-03 21:47 ` [PATCH v4 27/28] cpu: Fix code style for checkpatch.pl Philippe Mathieu-Daudé
2021-03-03 21:47 ` [PATCH v4 28/28] cpu: Move sysemu specific declarations to 'sysemu-cpu-ops.h' Philippe Mathieu-Daudé
2021-03-04 1:52 ` [PATCH v4 00/28] cpu: Introduce SysemuCPUOps structure, remove watchpoints from usermode Richard Henderson
2021-04-22 10:39 ` 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=20210303214708.1727801-22-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=alex.bennee@linaro.org \
--cc=cfontana@suse.de \
--cc=cohuck@redhat.com \
--cc=laurent@vivier.eu \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.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;
as well as URLs for NNTP newsgroup(s).