I made some changes to the code in qemu :
https://github.com/qemu/qemu/blob/stable-6.0/target/arm/cpu.c#L339 . I have
commented out the variable vecbase and directly given the address of my
vector address(not zero) or where they are located in our binary file. Is
that a problem?

BR.
Abhijeet.

On Thu, Dec 16, 2021 at 7:47 PM Peter Maydell <peter.mayd...@linaro.org>
wrote:

> On Thu, 16 Dec 2021 at 17:44, Philippe Mathieu-Daudé <f4...@amsat.org>
> wrote:
> >
> > Cc'ing qemu-arm developers.
> >
> > On 12/16/21 18:31, abhijeet inamdar wrote:
> > > Hi,
> > >
> > > I was running my .elf file on my custom machine(CM3) and was hit with
> > > this error when debugging and had the required -d flags and single
> stepping.
> > >
> > > IN: Hal_MemFault
> > > 0x7004e794:  4770       bx       lr
> > >
> > > Trace 0: 0x7f4faa471100 [00000000/7004e794/0x312000c1]  Hal_MemFault
> > > R00=7004938d R01=00000000 R02=7004938c R03=ffffffff
> > > R04=7005e410 R05=10020000 R06=e000eda0 R07=00000000
> > > R08=00000010 R09=1003f8e0 R10=e000ed94 R11=00000000
> > > R12=ffffffff R13=1003dbe0 R14=fffffff9 R15=7004e794
> > > XPSR=01000003 ---- T handler
> > > Taking exception 8 [QEMU v7M exception exit]
> > > Exception return: magic PC fffffff9 previous exception 3
> > > M profile return from interrupt with misaligned PC is UNPREDICTABLE on
> v7M
> > > ...successful exception return
> > > DRBAR[6]: 0xa0000000 misaligned to DRSR region size, mask = 0x3fffffff
> > > Taking exception 3 [Prefetch Abort]
> > > ...with CFSR.IACCVIOL
> > > ...taking pending nonsecure exception 3
>
> The logging here tells you what happened:
>
>  * we are in an exception handler
>  * we do the bx lr to magic value which is M-profile's exception-return
>  * ...but there's something wrong with the return address we pull
>    off the stack, because it's not an aligned value (its least
>    significant bit is set)
>  * moreover, it's an address that corresponds to an MPU region
>    that has been misprogrammed (the DRBAR value isn't right);
>    the MPU treats such regions as not matching
>  * and so we take an instruction access fault
>
> So you have two problems:
>  (1) the PC value on the stack that you're trying to return to is wrong
>  (2) you're programming the MPU wrong
>
> You need to investigate and fix both.
>
> -- PMM
>

Reply via email to