fix compilation issues in aarch64 ports
authorLunaixsky <lunaixsky@qq.com>
Sun, 6 Oct 2024 17:09:32 +0000 (18:09 +0100)
committerLunaixsky <lunaixsky@qq.com>
Sun, 6 Oct 2024 17:09:32 +0000 (18:09 +0100)
* fix: corrected syntax of sys with encoding space.
* fix: corrected syntax of inline asm constrain list.
* fix: corrected the #include name error
* fix: corrected the use of asm directive to load symbol to reg
* fix: replace the invalid ldr into sp by using add to deduce the value
* ref: remove the sp_el1_saved from exec_param as no longer needed
* fix: add couple missing headers
* fix: other general fixes with type conversions

19 files changed:
lunaix-os/arch/aarch64/LBuild
lunaix-os/arch/aarch64/boot/init.c
lunaix-os/arch/aarch64/boot/kremap.c
lunaix-os/arch/aarch64/boot/start.S
lunaix-os/arch/aarch64/exception/context.S
lunaix-os/arch/aarch64/exception/entries.S
lunaix-os/arch/aarch64/exception/hart_fields.inc
lunaix-os/arch/aarch64/includes/asm/aa64_asm.h
lunaix-os/arch/aarch64/includes/asm/aa64_msrs.h
lunaix-os/arch/aarch64/includes/asm/aa64_sysinst.h
lunaix-os/arch/aarch64/includes/asm/abi.h
lunaix-os/arch/aarch64/includes/asm/bits.h
lunaix-os/arch/aarch64/includes/asm/hart.h
lunaix-os/arch/aarch64/includes/asm/tlb.h
lunaix-os/arch/aarch64/includes/linking/base_defs.ld.inc
lunaix-os/arch/aarch64/includes/sys/elf.h [new file with mode: 0644]
lunaix-os/arch/aarch64/includes/sys/failsafe.h [new file with mode: 0644]
lunaix-os/arch/aarch64/includes/sys/syscall_utils.h [new file with mode: 0644]
lunaix-os/arch/aarch64/trace.c

index 52b347958737924c9024662c08589a3d8ee48f0b..6dae92410e9cd8e2644409b789410267dfc67d72 100644 (file)
@@ -11,11 +11,19 @@ sources([
     "exception/handler.c"
 ])
 
     "exception/handler.c"
 ])
 
+sources([
+    "soc/gic.c",
+])
+
 sources([
     "fault.c",
     "trace.c"
 ])
 
 sources([
     "fault.c",
     "trace.c"
 ])
 
+headers([
+    "includes"
+])
+
 compile_opts([
     "-mlittle-endian",
     "-mgeneral-regs-only",
 compile_opts([
     "-mlittle-endian",
     "-mgeneral-regs-only",
index b4256a76323aad1a2b64d45958cd7005997e90d1..d10675e60ea616ebd49241e3807c447c3419b19e 100644 (file)
@@ -32,7 +32,7 @@ extern void aa64_vbase();
 static inline void
 setup_evbar()
 {
 static inline void
 setup_evbar()
 {
-    set_sysreg(VBAR_EL1, aa64_vbase);
+    set_sysreg(VBAR_EL1, __ptr(aa64_vbase));
 }
 
 static inline void
 }
 
 static inline void
index a230ece8afba00051b7001d0d49faa677c5c3405..b91d1d5f5ee86fe4d05b5f716292725ddf1e1b3f 100644 (file)
@@ -1,4 +1,6 @@
 #include <lunaix/sections.h>
 #include <lunaix/sections.h>
+
+#include <asm/mm_defs.h>
 #include <asm-generic/init_pagetable.h>
 #include <asm/boot_stage.h>
 
 #include <asm-generic/init_pagetable.h>
 #include <asm/boot_stage.h>
 
@@ -17,10 +19,10 @@ kremap()
     init_pt_alloc(&alloc, to_kphysical(&kpt), sizeof(kpt));
     init_ptw_state(&ptw, &alloc, kpt_alloc_table(&alloc));
 
     init_pt_alloc(&alloc, to_kphysical(&kpt), sizeof(kpt));
     init_ptw_state(&ptw, &alloc, kpt_alloc_table(&alloc));
 
-    pte = mkpte(boot_start, KERNEL_DATA);
+    pte = mkpte(bootsec_start, KERNEL_DATA);
     pte = pte_mkexec(pte);
     pte = pte_mkexec(pte);
-    nr  = leaf_count(boot_end - boot_start);
-    kpt_set_ptes(&ptw, boot_start, pte, LFT_SIZE, nr);
+    nr  = leaf_count(bootsec_end - bootsec_start);
+    kpt_set_ptes(&ptw, bootsec_start, pte, LFT_SIZE, nr);
 
     kpt_mktable_at(&ptw, VMAP, L0T_SIZE);
     kpt_mktable_at(&ptw, PMAP, L2T_SIZE);
 
     kpt_mktable_at(&ptw, VMAP, L0T_SIZE);
     kpt_mktable_at(&ptw, PMAP, L2T_SIZE);
index f2aa88a11335e76da587fda4ddcdc99cb9db1dad..13878da38ac93e7c88e40df94efdbd48c06f1d2c 100644 (file)
@@ -1,5 +1,5 @@
 .section .boot.data
 .section .boot.data
-    .align 16
+    .align 4
     stack_end:
         .skip 512
     stack_top:
     stack_end:
         .skip 512
     stack_top:
             mov x3, xzr
      */
     start_:
             mov x3, xzr
      */
     start_:
-        ldr sp, =stack_top
+        adr x4, stack_top
+        mov sp, x4
         mov fp, xzr
 
         mov fp, xzr
 
-        ldr x4, =aarch64_init
+        adr x4, aarch64_init
         bl x4
          
         // x0: ptr to boot_handoff
         bl x4
          
         // x0: ptr to boot_handoff
-        ldr x4, =kernel_bootstrap
+        adr x4, kernel_bootstrap
         bl x4
\ No newline at end of file
         bl x4
\ No newline at end of file
index fd8584991b6ce274f50e8c2832ef1098c06b5bf6..e30f72d8e574453c926d964f01f3bef0ee327ace 100644 (file)
@@ -1,6 +1,6 @@
 #define __ASM__
 #include <asm/aa64_msrs.h>
 #define __ASM__
 #include <asm/aa64_msrs.h>
-#include "hart_field.inc"
+#include "hart_fields.inc"
 
 .section .text
     
 
 .section .text
     
@@ -8,12 +8,12 @@
     .globl _aa64_switch_task
 
     _aa64_evec_prehandle:
     .globl _aa64_switch_task
 
     _aa64_evec_prehandle:
-        # reservation for struct exec_param
-        sub   sp,  sp,  #8         # push  sp_el1
-        sub   sp,  sp,  #16        # push {sp_el0, link}
-        sub   sp,  sp,  #16        # push {spsr,   parent_hart}
+        // reservation for struct exec_param
+        sub   sp,  sp,  #8         // push  xzr
+        sub   sp,  sp,  #16        // push {sp_el0, link}
+        sub   sp,  sp,  #16        // push {spsr,   parent_hart}
 
 
-        stp   lr,  fp, [sp, #-16]!  # push {x31-x1}
+        stp   lr,  fp, [sp, #-16]! //push {x31-x1}
         stp  x28, x27, [sp, #-16]!
         stp  x26, x25, [sp, #-16]!
         stp  x24, x23, [sp, #-16]!
         stp  x28, x27, [sp, #-16]!
         stp  x26, x25, [sp, #-16]!
         stp  x24, x23, [sp, #-16]!
@@ -28,7 +28,7 @@
         stp   x6,  x5, [sp, #-16]!
         stp   x4,  x3, [sp, #-16]!
         stp   x2,  x1, [sp, #-16]!
         stp   x6,  x5, [sp, #-16]!
         stp   x4,  x3, [sp, #-16]!
         stp   x2,  x1, [sp, #-16]!
-        stp   x0, xzr, [sp, #-16]!  # push {x0, xzr}
+        stp   x0, xzr, [sp, #-16]!  // push {x0, xzr}
 
         add   x1, sp,  #hart_execp
 
 
         add   x1, sp,  #hart_execp
 
         mrs   x0, SPSR_EL1
         str   x0, [x1, #execp_spsr]
         
         mrs   x0, SPSR_EL1
         str   x0, [x1, #execp_spsr]
         
-        sub   x0, sp,  #hart_end
-        str   x0, [x1, #execp_spel1_saved]
-        
         mov   x0, sp
         bl    handle_exception
         
     do_eret:
         mov   x0, sp
         bl    handle_exception
         
     do_eret:
-        mov   sp,   x0
+        add   sp, x0,   xzr
 
         add   x1,   x0, #hart_execp
 
 
         add   x1,   x0, #hart_execp
 
         ldp  x27, x28, [sp, #16]!
         ldp   fp,  lr, [sp, #16]!
         
         ldp  x27, x28, [sp, #16]!
         ldp   fp,  lr, [sp, #16]!
         
-        # sp now point to the start of exec_param
+        // sp now point to the start of exec_param
 
 
-        ldr   sp,  [sp, #execp_spel1_saved]
+        sub   sp,  sp, #execp_end
 
         eret
 
     _aa64_switch_task:
 
         eret
 
     _aa64_switch_task:
-        # TODO
+        // TODO
         b     do_eret
\ No newline at end of file
         b     do_eret
\ No newline at end of file
index ec96927b3e5aae10bb8b36914ed0e4be2fed2ffb..b7cbef8e051b7e8e3c5617b70e831fd053e67cd2 100644 (file)
@@ -3,17 +3,17 @@
 #include <asm/aa64_msrs.h>
 
 .macro aa64_exception_entry type
 #include <asm/aa64_msrs.h>
 
 .macro aa64_exception_entry type
-    .align 128
+    .align 7
     .type  _exception_entry_t\type, @function
 
     .type  _exception_entry_t\type, @function
 
-    # each handler has at most 128 bytes (32 insts)
+    // each handler has at most 128 bytes (32 insts)
     _exception_entry_t\type:
         stp x1,  x0,  [sp, #-16]
 
     _exception_entry_t\type:
         stp x1,  x0,  [sp, #-16]
 
-        # re-purpose the [63, 56] of ESR to exception
-        #  type identifier
+        // re-purpose the [63, 56] of ESR to exception
+        //  type identifier
 
 
-        mov x0,  =\type
+        mov x0,  #\type
         lsl x0,  x0, #56
         mrs x1,  ESR_EL1
         orr x0,  x0, x1
         lsl x0,  x0, #56
         mrs x1,  ESR_EL1
         orr x0,  x0, x1
@@ -28,7 +28,7 @@
 .section .text
 
     .globl aa64_vbase
 .section .text
 
     .globl aa64_vbase
-    .align 128
+    .align 7
 
     aa64_vbase:
     aa64_exception_entry EXCEPTION_SYNC
 
     aa64_vbase:
     aa64_exception_entry EXCEPTION_SYNC
index 62629bc00fe4f58bf733042d14e6fa06767874d3..5e9d63b4181c4c34a2d31a1e746c9f7116e6e7c2 100644 (file)
@@ -16,8 +16,8 @@ execp_link:
     .struct execp_link + 8
 execp_spel0_saved:
     .struct execp_spel0_saved + 8
     .struct execp_link + 8
 execp_spel0_saved:
     .struct execp_spel0_saved + 8
-execp_spel1_saved:
-    .struct execp_spel1_saved + 8
+execp_rsvd:
+    .struct execp_rsvd + 8
 execp_syndrome:
     .struct execp_syndrome + 8
 execp_end:
 execp_syndrome:
     .struct execp_syndrome + 8
 execp_end:
index 51dcf5e4f7712de423573e4a74d95d62806de3b5..f617cfc23ab764d912eed198d7e40a6b6eda9f87 100644 (file)
@@ -1,8 +1,14 @@
 #ifndef __LUNAIX_AA64_ASM_H
 #define __LUNAIX_AA64_ASM_H
 
 #ifndef __LUNAIX_AA64_ASM_H
 #define __LUNAIX_AA64_ASM_H
 
+#define __const_expr_sign #
+#define __comma() ,
+#define __const_expr()    __const_expr_sign
+
 #define __sr_encode(op0, op1, crn, crm, op2)    \
             s##op0##_##op1##_c##crn##_c##crm##_##op2
 #define __sr_encode(op0, op1, crn, crm, op2)    \
             s##op0##_##op1##_c##crn##_c##crm##_##op2
+#define __sysop_encode(op1, crn, crm, op2)      \
+            "#" #op1 ",C" #crn ",C" #crm ",#" #op2
 
 #ifndef __ASM__
 
 
 #ifndef __ASM__
 
index b49d1022cde9a2ebd0c62df3c156a4afbf0eaea6..f1da5f2fa3ac650e7bc971a5208f816884e596bb 100644 (file)
 #define SCTRL_A             (1UL << 1)
 #define SCTRL_M             (1UL << 0)
 
 #define SCTRL_A             (1UL << 1)
 #define SCTRL_M             (1UL << 0)
 
+#define sysreg_flagging(reg, set, unset)                    \
+        ({                                                  \
+            unsigned long _x;                               \
+            _x = read_sysreg(reg);                          \
+            _x = (_x & ~(unset)) | (set);                   \
+            set_sysreg(reg, _x);                            \
+            _x;                                             \
+        })
+
 #endif
 #endif /* __LUNAIX_AA64_MSRS_H */
 #endif
 #endif /* __LUNAIX_AA64_MSRS_H */
index eaea5416cb0043e88043a4eb1326d9af95d033b0..230c4559e1ae1bad920a3137778b8ace548c35b2 100644 (file)
@@ -3,22 +3,22 @@
 
 #include "aa64_asm.h"
 
 
 #include "aa64_asm.h"
 
-#define tlbi_alle1      __sr_encode(1, 4, 8, 7, 4)
-#define tlbi_aside1     __sr_encode(1, 0, 8, 7, 2)
-#define tlbi_rvaae1     __sr_encode(1, 0, 8, 6, 3)
-#define tlbi_rvae1      __sr_encode(1, 0, 8, 6, 1)
-#define tlbi_vaae1      __sr_encode(1, 0, 8, 7, 3)
-#define tlbi_vae1       __sr_encode(1, 0, 8, 7, 1)
+#define tlbi_alle1      __sysop_encode(4, 8, 7, 4)
+#define tlbi_aside1     __sysop_encode(0, 8, 7, 2)
+#define tlbi_rvaae1     __sysop_encode(0, 8, 6, 3)
+#define tlbi_rvae1      __sysop_encode(0, 8, 6, 1)
+#define tlbi_vaae1      __sysop_encode(0, 8, 7, 3)
+#define tlbi_vae1       __sysop_encode(0, 8, 7, 1)
 
 #define sys_a0(op)    \
 
 #define sys_a0(op)    \
-    ({  asm ("sys " stringify(op)); })
+    ({  asm ("sys " op); })
 
 #define sys_a1(op, xt)    \
 
 #define sys_a1(op, xt)    \
-    ({  asm ("sys " stringify(op) ", %0" :: "r"(xt)); })
+    ({  asm ("sys " op ", %0" :: "r"(xt)); })
 
 #define sysl(op)    \
     ({  unsigned long _x;                               \
 
 #define sysl(op)    \
     ({  unsigned long _x;                               \
-        asm ("sysl %0, " stringify(op):"=r"(_x));       \
+        asm ("sysl %0, " op :"=r"(_x));       \
         _x;                                             \
     })
 
         _x;                                             \
     })
 
index 7f8d83d545563075799cacee0f7a52b65b92324c..cc18bba28d47d3cef59165ba4d8e719063680d7d 100644 (file)
@@ -4,8 +4,13 @@
 #include <lunaix/types.h>
 
 #ifndef __ASM__
 #include <lunaix/types.h>
 
 #ifndef __ASM__
+
 #define align_stack(ptr) ((ptr) & ~15)
 
 #define align_stack(ptr) ((ptr) & ~15)
 
+#define store_retval(retval) current_thread->hstate->registers.x[0] = (retval)
+#define store_retval_to(th, retval) (th)->hstate->registers.x[0] = (retval)
+
+
 static inline void must_inline noret
 switch_context() {
     // TODO
 static inline void must_inline noret
 switch_context() {
     // TODO
@@ -29,6 +34,20 @@ abi_get_retaddrat(ptr_t fp)
     return ((ptr_t*)fp)[1];
 }
 
     return ((ptr_t*)fp)[1];
 }
 
+static inline ptr_t must_inline
+abi_get_callframe()
+{
+    ptr_t val;
+    asm volatile("mov %0, fp" : "=r"(val));
+    return val;
+}
+
+static inline void must_inline 
+j_usr(ptr_t sp, ptr_t pc) 
+{
+    // TODO
+}
+
 #endif
 
 #endif /* __LUNAIX_AA64_ABI_H */
 #endif
 
 #endif /* __LUNAIX_AA64_ABI_H */
index a30f254bf0a9a267ee0b13fd150a333459919b70..29ed7bf552975ace889653de0990e0e5cab943c2 100644 (file)
@@ -11,8 +11,8 @@
             unsigned long _r;           \
             asm ("ubfm %0, %1, %2, %3"  \
                  : "=r"(_r)             \
             unsigned long _r;           \
             asm ("ubfm %0, %1, %2, %3"  \
                  : "=r"(_r)             \
-                 : "r"(from)            \
-                   "i"(l) "i"(h));      \
+                 : "r"(from),           \
+                   "i"(l),"i"(h));      \
             _r;                         \
         })
 
             _r;                         \
         })
 
@@ -21,8 +21,8 @@
             unsigned long _r = to;      \
             asm ("bfi %0, %1, %2, %3"   \
                  : "=r"(_r)             \
             unsigned long _r = to;      \
             asm ("bfi %0, %1, %2, %3"   \
                  : "=r"(_r)             \
-                 : "r"(from)            \
-                   "i"(l)               \
+                 : "r"(from),           \
+                   "i"(l),              \
                    "i"(h - l + 1));     \
             _r;                         \
         })
                    "i"(h - l + 1));     \
             _r;                         \
         })
index ae84ddd13c70c373f7bda587d324f626ff522784..fa1f4bfd165f7b30322d84bc398c9b98e27ff13c 100644 (file)
@@ -15,7 +15,7 @@ struct regcontext
     union {
         reg_t x[31];
         struct {
     union {
         reg_t x[31];
         struct {
-            reg_t x[29];
+            reg_t x_[29];
             reg_t fp;
             reg_t lr;
         };
             reg_t fp;
             reg_t lr;
         };
@@ -29,7 +29,7 @@ struct exec_param
     reg_t link;
     struct {
         reg_t sp_el0;
     reg_t link;
     struct {
         reg_t sp_el0;
-        reg_t sp_el1;
+        reg_t rsvd;
     };
     
     reg_t syndrome;
     };
     
     reg_t syndrome;
@@ -73,10 +73,7 @@ hart_pc(struct hart_state* hstate)
 static inline ptr_t
 hart_sp(struct hart_state* hstate)
 {
 static inline ptr_t
 hart_sp(struct hart_state* hstate)
 {
-    if (spsr_from_el0(hstate->execp.spsr)) {
-        return hstate->execp.sp_el0;
-    }
-    return hstate->execp.sp_el1;
+    return __ptr(&hstate[-1]);
 }
 
 static inline bool
 }
 
 static inline bool
index 11690d39d4f6153fe1f3104ce4b15b6ea7150c37..d59f846df4c058a3f1f1e1686046f80bea5aa1de 100644 (file)
@@ -7,17 +7,17 @@
 #include <asm/aa64_sysinst.h>
 
 #define pack_va(asid, ttl, va)                \
 #include <asm/aa64_sysinst.h>
 
 #define pack_va(asid, ttl, va)                \
-        (((asid & 0xffff) << 48)            | \
-         ((ttl  & 0b1111) << 44)            | \
-         (pfn(va) & ((1 << 44) - 1)))
+        (((asid & 0xffffUL) << 48)            | \
+         ((ttl  & 0b1111UL) << 44)            | \
+         (pfn(va) & ((1UL << 44) - 1)))
 
 #define pack_rva(asid, ttl, base, n, scale)   \
 
 #define pack_rva(asid, ttl, base, n, scale)   \
-        (((asid    & 0xffff) << 48)         | \
-         ((_MMU_TG & 0b11) << 46)           | \
-         ((n       & 0x1f) << 39)           | \
-         ((scale   & 0b11) << 37)           | \
-         ((ttl     & 0b1111) << 44)         | \
-         (pfn(base)& ((1 << 37) - 1)))
+        (((asid    & 0xffffUL) << 48)         | \
+         ((_MMU_TG & 0b11UL) << 46)           | \
+         ((n       & 0x1fUL) << 39)           | \
+         ((scale   & 0b11UL) << 37)           | \
+         ((ttl     & 0b1111UL) << 44)         | \
+         (pfn(base)& ((1UL << 37) - 1)))
 
 /**
  * @brief Invalidate an entry of all address space
 
 /**
  * @brief Invalidate an entry of all address space
index 827c6b3a334617cc893728013e288cbfc3e00490..5a7f42af4cae934c14d848821afc26529570c0b2 100644 (file)
@@ -2,7 +2,7 @@
 #define __LUNAIX_BASE_DEFS_LD_INC
 
 #define __LD__
 #define __LUNAIX_BASE_DEFS_LD_INC
 
 #define __LD__
-#include <sys/mm/mempart.h>
+#include <asm/mempart.h>
 
 #define KEXEC_BASE      KERNEL_IMG
 #define PAGE_GRAN       4K
 
 #define KEXEC_BASE      KERNEL_IMG
 #define PAGE_GRAN       4K
diff --git a/lunaix-os/arch/aarch64/includes/sys/elf.h b/lunaix-os/arch/aarch64/includes/sys/elf.h
new file mode 100644 (file)
index 0000000..1d945f9
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __LUNAIX_ARCH_ELF_H
+#define __LUNAIX_ARCH_ELF_H
+
+#include <sys-generic/elf.h>
+
+#endif /* __LUNAIX_ARCH_ELF_H */
diff --git a/lunaix-os/arch/aarch64/includes/sys/failsafe.h b/lunaix-os/arch/aarch64/includes/sys/failsafe.h
new file mode 100644 (file)
index 0000000..8bc3570
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef __LUNAIX_ARCH_FAILSAFE_H
+#define __LUNAIX_ARCH_FAILSAFE_H
+
+#define STACK_SANITY            0xbeefc0de
+
+#ifndef __ASM__
+
+#include <lunaix/types.h>
+
+static inline bool
+check_bootstack_sanity()
+{
+    extern unsigned int __kinit_stack_end[];
+
+    return ( __kinit_stack_end[0] 
+           | __kinit_stack_end[1]
+           | __kinit_stack_end[2]
+           | __kinit_stack_end[3]) == STACK_SANITY;
+}
+
+static inline void must_inline noret
+failsafe_diagnostic() {
+    // TODO
+    unreachable;
+}
+
+#endif
+
+#endif /* __LUNAIX_FAILSAFE_H */
diff --git a/lunaix-os/arch/aarch64/includes/sys/syscall_utils.h b/lunaix-os/arch/aarch64/includes/sys/syscall_utils.h
new file mode 100644 (file)
index 0000000..4a43eb8
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef __LUNAIX_ARCH_SYSCALL_UTILS_H
+#define __LUNAIX_ARCH_SYSCALL_UTILS_H
+
+#include <klibc/string.h>
+
+static inline void
+convert_valist(va_list* ap_ref, sc_va_list syscall_ap)
+{
+    memcpy(ap_ref, syscall_ap, sizeof(*ap_ref));
+}
+
+#endif /* __LUNAIX_SYSCALL_UTILS_H */
index 19300039552c577a96ad5ce7fd6890d8ccb6eb7a..7370a37fd7ef4af7c0f0786f6994dbc871ad9435 100644 (file)
@@ -5,16 +5,16 @@
 static inline char*
 __type_name(reg_t syndrome)
 {
 static inline char*
 __type_name(reg_t syndrome)
 {
-    switch (hart_vector_stamp(syndrome))
+    switch (BITS_GET(syndrome, SYNDROME_ETYPE))
     {
     {
-    case EXCEPTION_SYNC:
-        return "sync";
-    case EXCEPTION_IRQ:
-        return "async (irq)";
-    case EXCEPTION_FIQ:
-        return "async (fiq)";
-    case EXCEPTION_SERR:
-        return "async (serr)";
+        case EXCEPTION_SYNC:
+            return "sync";
+        case EXCEPTION_IRQ:
+            return "async (irq)";
+        case EXCEPTION_FIQ:
+            return "async (fiq)";
+        case EXCEPTION_SERR:
+            return "async (serr)";
     }
 
     return "unknwon";
     }
 
     return "unknwon";
@@ -50,7 +50,7 @@ trace_print_transition_full(struct hart_state* hstate)
     trace_log("  esr=0x%016lx,  spsr=0x%016lx",
                 syndrome, execp->spsr);
     trace_log("  sp_el0=0x%016lx,  sp_el1=0x%016lx",
     trace_log("  esr=0x%016lx,  spsr=0x%016lx",
                 syndrome, execp->spsr);
     trace_log("  sp_el0=0x%016lx,  sp_el1=0x%016lx",
-                execp->sp_el0, execp->sp_el1);
+                execp->sp_el0, hart_sp(hstate));
     trace_log("  pc=0x%016lx", execp->link);
 }
 
     trace_log("  pc=0x%016lx", execp->link);
 }