Jailhouse runs with GIF cleared on AMD, and simple 'sti' and 'cli'
aren't enough to enable and disable interrupts. This affects apic_clear()
which fails to reset IRR on AMD. To overcome this, former enable_irq()
and disable_irq() are now defined in svm.c/vmx.c in vendor-specific way.
Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
[Jan: convert documentation into doxygen format]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
#ifndef __ASSEMBLY__
+/**
+ * @ingroup X86
+ * @defgroup Processor Processor
+ *
+ * Low-level support for x86 processor configuration and status retrieval.
+ *
+ * @{
+ */
+
struct registers {
unsigned long r15;
unsigned long r14;
asm volatile("lidtq %0" : : "m" (*val));
}
-static inline void enable_irq(void)
-{
- asm volatile("sti");
-}
+/**
+ * Enable or disable interrupts delivery to the local CPU when in host mode.
+ *
+ * In some cases (AMD) changing IF isn't enough, so these are implemented on
+ * per-vendor basis.
+ * @{
+ */
+void enable_irq(void);
-static inline void disable_irq(void)
-{
- asm volatile("cli");
-}
+void disable_irq(void);
+/** @} */
+/** @} */
#endif /* !__ASSEMBLY__ */
#endif /* !_JAILHOUSE_ASM_PROCESSOR_H */
x_state->cs = cpu_data->vmcb.cs.selector;
x_state->rip = cpu_data->vmcb.rip;
}
+
+/* GIF must be set for interrupts to be delivered (APMv2, Sect. 15.17) */
+void enable_irq(void)
+{
+ asm volatile("stgi; sti" : : : "memory");
+}
+
+/* Jailhouse runs with GIF cleared, so we need to restore this state */
+void disable_irq(void)
+{
+ asm volatile("cli; clgi" : : : "memory");
+}
x_state->cs = vmcs_read16(GUEST_CS_SELECTOR);
x_state->rip = vmcs_read64(GUEST_RIP);
}
+
+void enable_irq(void)
+{
+ asm volatile("sti" : : : "memory");
+}
+
+void disable_irq(void)
+{
+ asm volatile("cli" : : : "memory");
+}