We will enter this function if we hit unrecoverable state.

Signed-off-by: Ralf Ramsauer <[email protected]>
---
 inmates/lib/arm-common/include/inmate.h | 6 ++++++
 inmates/lib/x86/inmate.h                | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/inmates/lib/arm-common/include/inmate.h 
b/inmates/lib/arm-common/include/inmate.h
index 921fde96..1dfbdfbb 100644
--- a/inmates/lib/arm-common/include/inmate.h
+++ b/inmates/lib/arm-common/include/inmate.h
@@ -88,6 +88,12 @@ static inline void cpu_relax(void)
        asm volatile("" : : : "memory");
 }
 
+static inline void __attribute__((noreturn)) spin_forever(void)
+{
+       for (;;)
+               asm volatile("wfi" : : : "memory");
+}
+
 typedef void (*irq_handler_t)(unsigned int);
 void gic_setup(irq_handler_t handler);
 void gic_enable_irq(unsigned int irq);
diff --git a/inmates/lib/x86/inmate.h b/inmates/lib/x86/inmate.h
index 964a5435..f3c57d33 100644
--- a/inmates/lib/x86/inmate.h
+++ b/inmates/lib/x86/inmate.h
@@ -106,6 +106,12 @@ static inline void cpu_relax(void)
        asm volatile("rep; nop" : : : "memory");
 }
 
+static inline void __attribute__((noreturn)) spin_forever(void)
+{
+       for (;;)
+               asm volatile ("hlt" : : : "memory");
+}
+
 static inline void outb(u8 v, u16 port)
 {
        asm volatile("outb %0,%1" : : "a" (v), "dN" (port));
-- 
2.17.0

-- 
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