Now that the sframe infrastructure is fully in place, make it work by
hooking it up to the unwind_user interface.

Signed-off-by: Josh Poimboeuf <jpoim...@kernel.org>
---
 arch/Kconfig                      |  1 +
 include/linux/unwind_user_types.h |  1 +
 kernel/unwind/user.c              | 22 +++++++++++++++++++---
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 23edd0e4e16a..12a3b73cbe66 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -448,6 +448,7 @@ config HAVE_UNWIND_USER_COMPAT_FP
 
 config HAVE_UNWIND_USER_SFRAME
        bool
+       select UNWIND_USER
 
 config AS_SFRAME
        def_bool $(as-instr,.cfi_sections .sframe\n.cfi_startproc\n.cfi_endproc)
diff --git a/include/linux/unwind_user_types.h 
b/include/linux/unwind_user_types.h
index 3ec4a097a3dd..5558558948b7 100644
--- a/include/linux/unwind_user_types.h
+++ b/include/linux/unwind_user_types.h
@@ -9,6 +9,7 @@ enum unwind_user_type {
        UNWIND_USER_TYPE_NONE,
        UNWIND_USER_TYPE_FP,
        UNWIND_USER_TYPE_COMPAT_FP,
+       UNWIND_USER_TYPE_SFRAME,
 };
 
 struct unwind_stacktrace {
diff --git a/kernel/unwind/user.c b/kernel/unwind/user.c
index 92963f129c6a..fc0c75da81f6 100644
--- a/kernel/unwind/user.c
+++ b/kernel/unwind/user.c
@@ -6,6 +6,7 @@
 #include <linux/sched.h>
 #include <linux/sched/task_stack.h>
 #include <linux/unwind_user.h>
+#include <linux/sframe.h>
 #include <linux/uaccess.h>
 #include <asm/unwind_user.h>
 
@@ -29,6 +30,12 @@ static inline bool compat_state(struct unwind_user_state 
*state)
               state->type == UNWIND_USER_TYPE_COMPAT_FP;
 }
 
+static inline bool sframe_state(struct unwind_user_state *state)
+{
+       return IS_ENABLED(CONFIG_HAVE_UNWIND_USER_SFRAME) &&
+              state->type == UNWIND_USER_TYPE_SFRAME;
+}
+
 #define UNWIND_GET_USER_LONG(to, from, state)                          \
 ({                                                                     \
        int __ret;                                                      \
@@ -48,12 +55,19 @@ int unwind_user_next(struct unwind_user_state *state)
        if (state->done)
                return -EINVAL;
 
-       if (compat_state(state))
+       if (compat_state(state)) {
                frame = &compat_fp_frame;
-       else if (fp_state(state))
+       } else if (sframe_state(state)) {
+               if (sframe_find(state->ip, frame)) {
+                       if (!IS_ENABLED(CONFIG_HAVE_UNWIND_USER_FP))
+                               goto the_end;
+                       frame = &fp_frame;
+               }
+       } else if (fp_state(state)) {
                frame = &fp_frame;
-       else
+       } else {
                goto the_end;
+       }
 
        cfa = (frame->use_fp ? state->fp : state->sp) + frame->cfa_off;
 
@@ -94,6 +108,8 @@ int unwind_user_start(struct unwind_user_state *state)
 
        if (IS_ENABLED(CONFIG_HAVE_UNWIND_USER_COMPAT_FP) && 
in_compat_mode(regs))
                state->type = UNWIND_USER_TYPE_COMPAT_FP;
+       else if (current_has_sframe())
+               state->type = UNWIND_USER_TYPE_SFRAME;
        else if (IS_ENABLED(CONFIG_HAVE_UNWIND_USER_FP))
                state->type = UNWIND_USER_TYPE_FP;
        else
-- 
2.48.1


Reply via email to