Ralf Ramsauer <[email protected]> writes:

> Hi,
>
> I need spinlocks in inmates on ARM, so I simply included asm/spinlock.h.
> Taking locks in inmates on ARM somehow doesn't work at all, but that's
> not the main issue. As soon as I try to take locks, cells can not be
> destroyed any longer, the whole system freezes on cell destroy.
>
> I was able to trace this down to the 'ldrex' instruction. This minimal
> example triggers this behavior (tested on a TK1, can not test it on
> other boards):
>
> #include <inmate.h>
>
> void inmate_main(void)
> {
>       unsigned int foo = 0, bar = 0;
>
>       printk("Foo!\n");
>       asm volatile("ldrex %0, [%1]\n\t"
>               : "=&r" (foo) : "r" (bar));
>
>       printk("Bar!\n");
>       while(1);
>               asm volatile("wfi");
> }
>
> The example code successfully finishes, I can read Foo and Bar on my
> serial console. But I am not able to destroy the cell afterwards. My
> system completely hangs on "jailhouse cell destroy".
>
> Curiously the cell can be re-loaded and started over again. Leaving out
> the ldrex instruction does not trigger the bug.
>
>   - How can ldrex prevent my cell from being destroyed?
>
>     Does it change some 'internal state' where jailhouse is not aware
>     about?
>
>   - Why do spinlocks not work at all in inmates?
>
>     spin_lock(&lock) never returns in inmates on a fresh spin lock.
>     Does the ARM implementation of spinlocks require some special
>     global initialisation that I don't know of?

Spinlocks use ldrex/strex pairs, so if ldrex is broken, I wouldn't
expect spinlocks to work either.

-- 
Måns Rullgård

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to