From: Sergey Fedorov <serge.fdrv@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
qemu-arm@nongnu.org, patches@linaro.org
Subject: Re: [Qemu-arm] [PATCH 3/8] target-arm: Use a single entry point for AArch64 and AArch32 exceptions
Date: Fri, 29 Jan 2016 19:46:19 +0300 [thread overview]
Message-ID: <56AB975B.50001@gmail.com> (raw)
In-Reply-To: <1452796451-2946-4-git-send-email-peter.maydell@linaro.org>
On 14.01.2016 21:34, Peter Maydell wrote:
> If EL2 or EL3 is present on an AArch64 CPU, then exceptions can be
> taken to an exception level which is running AArch32 (if only EL0
> and EL1 are present then EL1 must be AArch64 and all exceptions are
> taken to AArch64). To support this we need to have a single
> implementation of the CPU do_interrupt() method which can handle both
> 32 and 64 bit exception entry.
>
> Pull the common parts of aarch64_cpu_do_interrupt() and
> arm_cpu_do_interrupt() out into a new function which calls
> either the AArch32 or AArch64 specific entry code once it has
> worked out which one is needed.
>
> We temporarily special-case the handling of EXCP_SEMIHOST to
> avoid an assertion in arm_el_is_aa64(); the next patch will
> pull all the semihosting handling out to the arm_cpu_do_interrupt()
> level (since semihosting semantics depend on the register width
> of the calling code, not on that of any higher EL).
Reviewed-by: Sergey Fedorov <serge.fdrv@gmail.com>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> target-arm/cpu-qom.h | 2 --
> target-arm/cpu64.c | 3 ---
> target-arm/helper.c | 75 ++++++++++++++++++++++++++++++----------------------
> 3 files changed, 44 insertions(+), 36 deletions(-)
>
> diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h
> index bda2af8..eae6cd1 100644
> --- a/target-arm/cpu-qom.h
> +++ b/target-arm/cpu-qom.h
> @@ -249,6 +249,4 @@ int aarch64_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);
> int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
> #endif
>
> -void aarch64_cpu_do_interrupt(CPUState *cs);
> -
> #endif
> diff --git a/target-arm/cpu64.c b/target-arm/cpu64.c
> index 63c8b1c..edb41f7 100644
> --- a/target-arm/cpu64.c
> +++ b/target-arm/cpu64.c
> @@ -290,9 +290,6 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data)
> {
> CPUClass *cc = CPU_CLASS(oc);
>
> -#if !defined(CONFIG_USER_ONLY)
> - cc->do_interrupt = aarch64_cpu_do_interrupt;
> -#endif
> cc->cpu_exec_interrupt = arm_cpu_exec_interrupt;
> cc->set_pc = aarch64_cpu_set_pc;
> cc->gdb_read_register = aarch64_cpu_gdb_read_register;
> diff --git a/target-arm/helper.c b/target-arm/helper.c
> index 519f066..962bb3c 100644
> --- a/target-arm/helper.c
> +++ b/target-arm/helper.c
> @@ -5707,8 +5707,7 @@ void aarch64_sync_64_to_32(CPUARMState *env)
> env->regs[15] = env->pc;
> }
>
> -/* Handle a CPU exception. */
> -void arm_cpu_do_interrupt(CPUState *cs)
> +static void arm_cpu_do_interrupt_aarch32(CPUState *cs)
> {
> ARMCPU *cpu = ARM_CPU(cs);
> CPUARMState *env = &cpu->env;
> @@ -5718,16 +5717,6 @@ void arm_cpu_do_interrupt(CPUState *cs)
> uint32_t offset;
> uint32_t moe;
>
> - assert(!IS_M(env));
> -
> - arm_log_exception(cs->exception_index);
> -
> - if (arm_is_psci_call(cpu, cs->exception_index)) {
> - arm_handle_psci_call(cpu);
> - qemu_log_mask(CPU_LOG_INT, "...handled as PSCI call\n");
> - return;
> - }
> -
> /* If this is a debug exception we must update the DBGDSCR.MOE bits */
> switch (env->exception.syndrome >> ARM_EL_EC_SHIFT) {
> case EC_BREAKPOINT:
> @@ -5899,11 +5888,10 @@ void arm_cpu_do_interrupt(CPUState *cs)
> }
> env->regs[14] = env->regs[15] + offset;
> env->regs[15] = addr;
> - cs->interrupt_request |= CPU_INTERRUPT_EXITTB;
> }
>
> -/* Handle a CPU exception. */
> -void aarch64_cpu_do_interrupt(CPUState *cs)
> +/* Handle exception entry to a target EL which is using AArch64 */
> +static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
> {
> ARMCPU *cpu = ARM_CPU(cs);
> CPUARMState *env = &cpu->env;
> @@ -5921,22 +5909,6 @@ void aarch64_cpu_do_interrupt(CPUState *cs)
> addr += 0x200;
> }
>
> - arm_log_exception(cs->exception_index);
> - qemu_log_mask(CPU_LOG_INT, "...from EL%d to EL%d\n", arm_current_el(env),
> - new_el);
> - if (qemu_loglevel_mask(CPU_LOG_INT)
> - && !excp_is_internal(cs->exception_index)) {
> - qemu_log_mask(CPU_LOG_INT, "...with ESR %x/0x%" PRIx32 "\n",
> - env->exception.syndrome >> ARM_EL_EC_SHIFT,
> - env->exception.syndrome);
> - }
> -
> - if (arm_is_psci_call(cpu, cs->exception_index)) {
> - arm_handle_psci_call(cpu);
> - qemu_log_mask(CPU_LOG_INT, "...handled as PSCI call\n");
> - return;
> - }
> -
> switch (cs->exception_index) {
> case EXCP_PREFETCH_ABORT:
> case EXCP_DATA_ABORT:
> @@ -5996,6 +5968,47 @@ void aarch64_cpu_do_interrupt(CPUState *cs)
>
> qemu_log_mask(CPU_LOG_INT, "...to EL%d PC 0x%" PRIx64 " PSTATE 0x%x\n",
> new_el, env->pc, pstate_read(env));
> +}
> +
> +/* Handle a CPU exception for A and R profile CPUs.
> + * Do any appropriate logging, handle PSCI calls, and then hand off
> + * to the AArch64-entry or AArch32-entry function depending on the
> + * target exception level's register width.
> + */
> +void arm_cpu_do_interrupt(CPUState *cs)
> +{
> + ARMCPU *cpu = ARM_CPU(cs);
> + CPUARMState *env = &cpu->env;
> + unsigned int new_el = env->exception.target_el;
> +
> + assert(!IS_M(env));
> +
> + arm_log_exception(cs->exception_index);
> + qemu_log_mask(CPU_LOG_INT, "...from EL%d to EL%d\n", arm_current_el(env),
> + new_el);
> + if (qemu_loglevel_mask(CPU_LOG_INT)
> + && !excp_is_internal(cs->exception_index)) {
> + qemu_log_mask(CPU_LOG_INT, "...with ESR %x/0x%" PRIx32 "\n",
> + env->exception.syndrome >> ARM_EL_EC_SHIFT,
> + env->exception.syndrome);
> + }
> +
> + if (arm_is_psci_call(cpu, cs->exception_index)) {
> + arm_handle_psci_call(cpu);
> + qemu_log_mask(CPU_LOG_INT, "...handled as PSCI call\n");
> + return;
> + }
> +
> + /* Temporary special case for EXCP_SEMIHOST, which is used only
> + * for 64-bit semihosting calls -- as this is an internal exception
> + * it has no specified target level and arm_el_is_aa64() would
> + * assert because new_el could be 0.
> + */
> + if (cs->exception_index == EXCP_SEMIHOST || arm_el_is_aa64(env, new_el)) {
> + arm_cpu_do_interrupt_aarch64(cs);
> + } else {
> + arm_cpu_do_interrupt_aarch32(cs);
> + }
>
> if (!kvm_enabled()) {
> cs->interrupt_request |= CPU_INTERRUPT_EXITTB;
next prev parent reply other threads:[~2016-01-29 16:46 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-14 18:34 [PATCH 0/8] target-arm: support mixed 32/64 bit execution beyond EL0 Peter Maydell
2016-01-14 18:34 ` [PATCH 1/8] target-arm: Properly support EL2 and EL3 in arm_el_is_aa64() Peter Maydell
2016-01-15 14:38 ` Edgar E. Iglesias
2016-01-15 14:50 ` Peter Maydell
2016-01-15 15:37 ` Edgar E. Iglesias
2016-01-15 15:47 ` Peter Maydell
2016-01-15 20:37 ` Edgar E. Iglesias
2016-01-29 16:45 ` [Qemu-devel] " Sergey Fedorov
2016-01-29 16:50 ` Sergey Fedorov
2016-01-29 17:05 ` Peter Maydell
2016-01-29 17:08 ` Sergey Fedorov
2016-01-14 18:34 ` [PATCH 2/8] target-arm: Move aarch64_cpu_do_interrupt() to helper.c Peter Maydell
2016-01-15 14:39 ` Edgar E. Iglesias
2016-01-29 16:46 ` [Qemu-devel] " Sergey Fedorov
2016-01-14 18:34 ` [PATCH 3/8] target-arm: Use a single entry point for AArch64 and AArch32 exceptions Peter Maydell
2016-01-15 14:54 ` Edgar E. Iglesias
2016-01-29 16:46 ` Sergey Fedorov [this message]
2016-01-14 18:34 ` [PATCH 4/8] target-arm: Pull semihosting handling out to arm_cpu_do_interrupt() Peter Maydell
2016-01-29 16:46 ` [Qemu-devel] " Sergey Fedorov
2016-01-14 18:34 ` [PATCH 5/8] target-arm: Fix wrong AArch64 entry offset for EL2/EL3 target Peter Maydell
2016-01-19 16:40 ` Edgar E. Iglesias
2016-01-29 16:47 ` [Qemu-devel] " Sergey Fedorov
2016-01-14 18:34 ` [PATCH 6/8] target-arm: Handle exception return from AArch64 to non-EL0 AArch32 Peter Maydell
2016-01-19 16:47 ` Edgar E. Iglesias
2016-01-29 16:47 ` [Qemu-arm] " Sergey Fedorov
2016-01-14 18:34 ` [PATCH 7/8] target-arm: Implement remaining illegal return event checks Peter Maydell
2016-01-19 16:53 ` Edgar E. Iglesias
2016-01-19 16:58 ` Peter Maydell
2016-01-29 16:47 ` [Qemu-devel] " Sergey Fedorov
2016-01-14 18:34 ` [PATCH 8/8] target-arm: ignore ELR_ELx[1] for exception return to 32-bit ARM mode Peter Maydell
2016-01-19 16:56 ` Edgar E. Iglesias
2016-01-29 16:48 ` [Qemu-devel] [Qemu-arm] " Sergey Fedorov
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=56AB975B.50001@gmail.com \
--to=serge.fdrv@gmail.com \
--cc=patches@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).