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

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



While traps.c itself is compiled with NO_X86_EXTREGS_FLAGS, it still
doesn't hurt to remind potential editors of the file that calling any
other function from your trap handler is potentially dangerous.

Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
Reviewed-by: Yuri Volchkov <yuri.volchkov@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.20.1


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