[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCHv5 29/46] plat/kvm: Add trap handler to dump registers


  • To: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>, "minios-devel@xxxxxxxxxxxxxxxxxxxx" <minios-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Wei Chen (Arm Technology China)" <Wei.Chen@xxxxxxx>
  • Date: Wed, 12 Sep 2018 03:12:46 +0000
  • Accept-language: en-US
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wei.Chen@xxxxxxx;
  • Cc: "Kaly Xin \(Arm Technology China\)" <Kaly.Xin@xxxxxxx>, nd <nd@xxxxxxx>
  • Delivery-date: Wed, 12 Sep 2018 03:12:57 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Nodisclaimer: True
  • Spamdiagnosticmetadata: NSPM
  • Spamdiagnosticoutput: 1:99
  • Thread-index: AQHUMHk4ArHw8VtYtEitDP3PrIhelaTrUDAAgADZ4zA=
  • Thread-topic: [Minios-devel] [UNIKRAFT PATCHv5 29/46] plat/kvm: Add trap handler to dump registers


> -----Original Message-----
> From: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
> Sent: 2018年9月11日 22:06
> To: Wei Chen (Arm Technology China) <Wei.Chen@xxxxxxx>; minios-
> devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Kaly Xin (Arm Technology China) <Kaly.Xin@xxxxxxx>; nd <nd@xxxxxxx>
> Subject: Re: [Minios-devel] [UNIKRAFT PATCHv5 29/46] plat/kvm: Add trap
> handler to dump registers
> 
> On 10.08.2018 09:08, Wei Chen wrote:
> > From: Wei Chen <Wei.Chen@xxxxxxx>
> >
> > Sometimes, for debug purpose, we would like to dump the
> > registers' value while exception happened. This patch add
> > a function to dump registers. Currently, we haven't enable
> > the interrupt controller, so any exception is not expected.
> > So any exception will cause registers dump.
> >
> > Signed-off-by: Wei Chen <Wei.Chen@xxxxxxx>
> > ---
> >   plat/common/arm/traps.c | 72 +++++++++++++++++++++++++++++++++++++++++
> >   plat/kvm/Makefile.uk    |  1 +
> >   2 files changed, 73 insertions(+)
> >   create mode 100644 plat/common/arm/traps.c
> >
> > diff --git a/plat/common/arm/traps.c b/plat/common/arm/traps.c
> > new file mode 100644
> > index 0000000..14e3011
> > --- /dev/null
> > +++ b/plat/common/arm/traps.c
> > @@ -0,0 +1,72 @@
> > +/* SPDX-License-Identifier: ISC */
> > +/*
> > + * Authors: Wei Chen <Wei.Chen@xxxxxxx>
> > + *
> > + * Copyright (c) 2018 Arm Ltd.
> > + *
> > + * Permission to use, copy, modify, and/or distribute this software
> > + * for any purpose with or without fee is hereby granted, provided
> > + * that the above copyright notice and this permission notice appear
> > + * in all copies.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
> > + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
> > + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
> > + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
> > + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
> > + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
> > + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
> > + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> > + */
> > +
> > +#include <stdint.h>
> > +#include <string.h>
> > +#include <uk/print.h>
> > +#include <uk/assert.h>
> > +
> > +static const char *exception_modes[]= {
> > +   "Synchronous Abort",
> > +   "IRQ",
> > +   "FIQ",
> > +   "Error"
> > +};
> > +
> > +static void dump_registers(struct __regs *regs, uint64_t far)
> > +{
> 
> Does this function works for both Arm and Arm64 (since you placed it as
> common Arm code)?
> 

Emm, my goal is to make this function works for both Arm ans Arm64.
Although, it only works for Arm64 now : )

> > +   unsigned char idx;
> > +
> > +   uk_printd(DLVL_ERR, "Unikraft: Dump registers:\n");
> > +   uk_printd(DLVL_ERR, "\t SP       : 0x%016lx\n", regs->sp);
> > +   uk_printd(DLVL_ERR, "\t ESR_EL1  : 0x%016lx\n", regs->esr_el1);
> > +   uk_printd(DLVL_ERR, "\t ELR_EL1  : 0x%016lx\n", regs->elr_el1);
> > +   uk_printd(DLVL_ERR, "\t LR (x30) : 0x%016lx\n", regs->lr);
> > +   uk_printd(DLVL_ERR, "\t PSTATE   : 0x%016lx\n", regs->spsr_el1);
> > +   uk_printd(DLVL_ERR, "\t FAR_EL1  : 0x%016lx\n", far);
> > +
> > +   for (idx = 0; idx < 28; idx += 4)
> > +           uk_printd(DLVL_ERR,
> > +                   "\t x%02d ~ x%02d: 0x%016lx 0x%016lx 0x%016lx 
> > 0x%016lx\n",
> > +                   idx, idx + 3, regs->x[idx], regs->x[idx + 1],
> > +                   regs->x[idx + 2], regs->x[idx + 3]);
> > +
> > +   uk_printd(DLVL_ERR, "\t x28 ~ x29: 0x%016lx 0x%016lx\n",
> > +                           regs->x[28], regs->x[29]);
> > +}
> > +
> > +void invalid_trap_handler(struct __regs *regs, uint32_t el,
> > +                           uint32_t reason, uint64_t far)
> > +{
> > +   uk_printd(DLVL_ERR,  "Unikraft: EL%d invalid %s trap caught\n",
> > +                           el, exception_modes[reason]);
> 
> UK_CRASH() is actually printining with DLVL_CRIT. I suggest that you use
> DLVL_CRIT also for this message.
> 

Ok

> > +   dump_registers(regs, far);
> > +   UK_CRASH("PANIC\n");
> 
> Probably you should use ukplat_crash() from /inlucde/uk/plat/bootstrap.h
> directly. I think the message us not giving you more details as you know
> already with the previous printd.
> 

Yes, that's right.

> > +}
> > +
> > +void trap_el1_sync(struct __regs *regs, uint64_t far)
> > +{
> > +   uk_printd(DLVL_ERR,  "Unikraft: EL1 sync trap caught\n");
> > +
> 
> DLVL_CRIT

Got it

> 
> > +   dump_registers(regs, far);
> > +
> > +   UK_CRASH("EXIT\n");
> 
> ukplat_crash()
> 


Got it

> > +}
> > diff --git a/plat/kvm/Makefile.uk b/plat/kvm/Makefile.uk
> > index a61b126..53e6b90 100644
> > --- a/plat/kvm/Makefile.uk
> > +++ b/plat/kvm/Makefile.uk
> > @@ -55,6 +55,7 @@ LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) +=
> $(UK_PLAT_COMMON_BASE)/arm/console.c|co
> >   endif
> >   LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) +=
> $(UK_PLAT_COMMON_BASE)/arm/cache64.S|common
> >   LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) +=
> $(UK_PLAT_COMMON_BASE)/arm/time.c|common
> > +LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) +=
> $(UK_PLAT_COMMON_BASE)/arm/traps.c|common
> >   LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += $(LIBKVMPLAT_BASE)/arm/entry64.S
> >   LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += $(LIBKVMPLAT_BASE)/arm/setup.c
> >   LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += $(LIBKVMPLAT_BASE)/arm/lcpu.c
> >
> 
> Thanks,
> 
> Simon
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.