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

[Minios-devel] [UNIKRAFT PATCH v2 9/9] plat/common: Add a notice regarding trap handling



Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
---
 plat/common/x86/traps.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/plat/common/x86/traps.c b/plat/common/x86/traps.c
index c4c520b4..cfb120f6 100644
--- a/plat/common/x86/traps.c
+++ b/plat/common/x86/traps.c
@@ -40,6 +40,18 @@
 #include <uk/print.h>
 #include <uk/assert.h>
 
+/* A general word of caution when writing trap handlers. The platform trap
+ * entry code is set up to properly save general-purpose registers (e.g., rsi,
+ * rdi, rax, r8, ...), but it does NOT save any floating-point or SSE/AVX
+ * registers. (This would require figuring out in the trap handler code whether
+ * these are available to not risk a #UD trap inside the trap handler itself.)
+ * Hence, you need to be extra careful not to do anything that clobbers these
+ * registers if you intend to return from the handler. This includes calling
+ * other functions, which may clobber those registers.
+ * Of course, if you end your trap handler with a UK_CRASH, knock yourself out,
+ * it's not like the function you came from will ever have the chance to 
notice.
+ */
+
 /* Traps handled on both Xen and KVM */
 
 DECLARE_TRAP_EC(divide_error,      "divide error")
-- 
2.19.2


_______________________________________________
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®.