]> xenbits.xensource.com Git - unikraft/libs/libunwind.git/commitdiff
patches: Re-add `UnwindRegistersSave.S` RIP patch RELEASE-0.14.0
authorAndrei Tatar <andrei@unikraft.io>
Wed, 10 May 2023 12:48:22 +0000 (15:48 +0300)
committerUnikraft <monkey@unikraft.io>
Thu, 1 Jun 2023 19:29:55 +0000 (19:29 +0000)
The previous patch (removed in 7b56f9b17de72d0e237e4af2bf72635c48389f3c)
was erroneous in its implementation but its intent was valid: when
saving registers in unikraft libunwind should take the return address of
the previous stack frame as the IP of the throwing function.
This patch implements this functionality correctly.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #7

patches/0001-Save-RIP-from-previous-stack-frame.patch [new file with mode: 0644]

diff --git a/patches/0001-Save-RIP-from-previous-stack-frame.patch b/patches/0001-Save-RIP-from-previous-stack-frame.patch
new file mode 100644 (file)
index 0000000..2011e3f
--- /dev/null
@@ -0,0 +1,32 @@
+From 6d79ff97d634cf5317492f7e80ede5b8e07bf51a Mon Sep 17 00:00:00 2001
+From: Andrei Tatar <andrei@unikraft.io>
+Date: Wed, 10 May 2023 15:21:30 +0300
+Subject: [PATCH] Save RIP from previous stack frame
+
+__unw_getcontext assumes the throwing function's return address is at
+the top of the stack; however, this does not hold in unikraft, instead
+we must go one stack frame earlier to get the right address.
+
+Co-authored-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
+Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
+Signed-off-by: Andrei Tatar <andrei@unikraft.io>
+---
+ libunwind/src/UnwindRegistersSave.S | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libunwind/src/UnwindRegistersSave.S b/libunwind/src/UnwindRegistersSave.S
+index b39489235..49067c021 100644
+--- a/src/UnwindRegistersSave.S
++++ b/src/UnwindRegistersSave.S
+@@ -90,7 +90,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
+   movq  %r13,104(PTR)
+   movq  %r14,112(PTR)
+   movq  %r15,120(PTR)
+-  movq  (%rsp),TMP
++  movq  8(%rbp),TMP
+   movq  TMP,128(PTR) # store return address as rip
+   # skip rflags
+   # skip cs
+-- 
+2.40.1
+