diff mbox

[01/23] target-arm: Log AArch64 exception returns

Message ID 1481625384-15077-2-git-send-email-peter.maydell@linaro.org
State Superseded
Headers show

Commit Message

Peter Maydell Dec. 13, 2016, 10:36 a.m. UTC
We already log exception entry; add logging of the AArch64 exception
return path as well.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>

---
 target-arm/op_helper.c | 9 +++++++++
 1 file changed, 9 insertions(+)

-- 
2.7.4

Comments

Alistair Francis Dec. 19, 2016, 9:51 p.m. UTC | #1
On Tue, Dec 13, 2016 at 2:36 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> We already log exception entry; add logging of the AArch64 exception

> return path as well.

>

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

> Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>


Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>


Thanks,

Alistair

> ---

>  target-arm/op_helper.c | 9 +++++++++

>  1 file changed, 9 insertions(+)

>

> diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c

> index cd94216..ba796d8 100644

> --- a/target-arm/op_helper.c

> +++ b/target-arm/op_helper.c

> @@ -17,6 +17,7 @@

>   * License along with this library; if not, see <http://www.gnu.org/licenses/>.

>   */

>  #include "qemu/osdep.h"

> +#include "qemu/log.h"

>  #include "cpu.h"

>  #include "exec/helper-proto.h"

>  #include "internals.h"

> @@ -972,6 +973,9 @@ void HELPER(exception_return)(CPUARMState *env)

>          } else {

>              env->regs[15] = env->elr_el[cur_el] & ~0x3;

>          }

> +        qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to "

> +                      "AArch32 EL%d PC 0x%" PRIx32 "\n",

> +                      cur_el, new_el, env->regs[15]);

>      } else {

>          env->aarch64 = 1;

>          pstate_write(env, spsr);

> @@ -980,6 +984,9 @@ void HELPER(exception_return)(CPUARMState *env)

>          }

>          aarch64_restore_sp(env, new_el);

>          env->pc = env->elr_el[cur_el];

> +        qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to "

> +                      "AArch64 EL%d PC 0x%" PRIx64 "\n",

> +                      cur_el, new_el, env->pc);

>      }

>

>      arm_call_el_change_hook(arm_env_get_cpu(env));

> @@ -1002,6 +1009,8 @@ illegal_return:

>      if (!arm_singlestep_active(env)) {

>          env->pstate &= ~PSTATE_SS;

>      }

> +    qemu_log_mask(LOG_GUEST_ERROR, "Illegal exception return at EL%d: "

> +                  "resuming execution at 0x%" PRIx64 "\n", cur_el, env->pc);

>  }

>

>  /* Return true if the linked breakpoint entry lbn passes its checks */

> --

> 2.7.4

>

>
Andrew Jones Dec. 20, 2016, 3:31 p.m. UTC | #2
On Tue, Dec 13, 2016 at 10:36:02AM +0000, Peter Maydell wrote:
> We already log exception entry; add logging of the AArch64 exception

> return path as well.

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

> Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>

> ---

>  target-arm/op_helper.c | 9 +++++++++

>  1 file changed, 9 insertions(+)

> 

> diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c

> index cd94216..ba796d8 100644

> --- a/target-arm/op_helper.c

> +++ b/target-arm/op_helper.c

> @@ -17,6 +17,7 @@

>   * License along with this library; if not, see <http://www.gnu.org/licenses/>.

>   */

>  #include "qemu/osdep.h"

> +#include "qemu/log.h"

>  #include "cpu.h"

>  #include "exec/helper-proto.h"

>  #include "internals.h"

> @@ -972,6 +973,9 @@ void HELPER(exception_return)(CPUARMState *env)

>          } else {

>              env->regs[15] = env->elr_el[cur_el] & ~0x3;

>          }

> +        qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to "

> +                      "AArch32 EL%d PC 0x%" PRIx32 "\n",

> +                      cur_el, new_el, env->regs[15]);

>      } else {

>          env->aarch64 = 1;

>          pstate_write(env, spsr);

> @@ -980,6 +984,9 @@ void HELPER(exception_return)(CPUARMState *env)

>          }

>          aarch64_restore_sp(env, new_el);

>          env->pc = env->elr_el[cur_el];

> +        qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to "

> +                      "AArch64 EL%d PC 0x%" PRIx64 "\n",

> +                      cur_el, new_el, env->pc);

>      }

>  

>      arm_call_el_change_hook(arm_env_get_cpu(env));

> @@ -1002,6 +1009,8 @@ illegal_return:

>      if (!arm_singlestep_active(env)) {

>          env->pstate &= ~PSTATE_SS;

>      }

> +    qemu_log_mask(LOG_GUEST_ERROR, "Illegal exception return at EL%d: "

> +                  "resuming execution at 0x%" PRIx64 "\n", cur_el, env->pc);

>  }

>  

>  /* Return true if the linked breakpoint entry lbn passes its checks */

> -- 

> 2.7.4

> 

>


Should we output both the destination PC (ELR) and the source PC (where
the eret was)? Otherwise if there are many erets to the same entry point,
then the logs won't fully enlighten us.

Thanks,
drew
Peter Maydell Dec. 27, 2016, 3:13 p.m. UTC | #3
On 20 December 2016 at 15:31, Andrew Jones <drjones@redhat.com> wrote:
> Should we output both the destination PC (ELR) and the source PC (where

> the eret was)? Otherwise if there are many erets to the same entry point,

> then the logs won't fully enlighten us.


We don't really conveniently have the source PC, because it isn't
written out to env->pc at the point when this helper function
is called (the calling code in translate-a64.c doesn't call
gen_a64_set_pc(), because it knows the helper doesn't need to
care about the PC value).

thanks
-- PMM
diff mbox

Patch

diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
index cd94216..ba796d8 100644
--- a/target-arm/op_helper.c
+++ b/target-arm/op_helper.c
@@ -17,6 +17,7 @@ 
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 #include "qemu/osdep.h"
+#include "qemu/log.h"
 #include "cpu.h"
 #include "exec/helper-proto.h"
 #include "internals.h"
@@ -972,6 +973,9 @@  void HELPER(exception_return)(CPUARMState *env)
         } else {
             env->regs[15] = env->elr_el[cur_el] & ~0x3;
         }
+        qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to "
+                      "AArch32 EL%d PC 0x%" PRIx32 "\n",
+                      cur_el, new_el, env->regs[15]);
     } else {
         env->aarch64 = 1;
         pstate_write(env, spsr);
@@ -980,6 +984,9 @@  void HELPER(exception_return)(CPUARMState *env)
         }
         aarch64_restore_sp(env, new_el);
         env->pc = env->elr_el[cur_el];
+        qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to "
+                      "AArch64 EL%d PC 0x%" PRIx64 "\n",
+                      cur_el, new_el, env->pc);
     }
 
     arm_call_el_change_hook(arm_env_get_cpu(env));
@@ -1002,6 +1009,8 @@  illegal_return:
     if (!arm_singlestep_active(env)) {
         env->pstate &= ~PSTATE_SS;
     }
+    qemu_log_mask(LOG_GUEST_ERROR, "Illegal exception return at EL%d: "
+                  "resuming execution at 0x%" PRIx64 "\n", cur_el, env->pc);
 }
 
 /* Return true if the linked breakpoint entry lbn passes its checks */