]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/common: Add `auxsp` field to `struct lcpu`
authorSergiu Moga <sergiu@unikraft.io>
Wed, 1 Nov 2023 06:44:07 +0000 (08:44 +0200)
committerSergiu Moga <sergiu@unikraft.io>
Sat, 25 Nov 2023 11:06:50 +0000 (13:06 +0200)
`struct uk_thread` contains a field called `auxsp` which is meant to
represent an auxiliary stack that may be used when switching stacks
during syscall entries or when simply wanting to have a scratch space
to use during a very fragile state of the system, such as when handling
an exception.

Give access to this field through `struct lcpu` as well. This field
shall represent the auxiliary stack pointer of the thread currently
executing on this LCPU.

If uksched/ukthread is disabled, this can come in handy as simply a
pointer to a scratch space that we can contaminate with whatever we
may want during a more fragile execution context.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
plat/common/include/uk/plat/common/lcpu.h

index 27963d60656ceab202cdffd7219dde546416c402..7a18ebc868d504af761b25bd5425345f28a87b8f 100644 (file)
@@ -97,7 +97,8 @@ UK_CTASSERT(sizeof(struct lcpu_sargs) == LCPU_SARGS_SIZE);
 #define LCPU_ENTRY_OFFSET              (LCPU_ID_OFFSET    + 0x08)
 #define LCPU_STACKP_OFFSET             (LCPU_ENTRY_OFFSET + 0x08)
 #define LCPU_ERR_OFFSET                        (LCPU_ENTRY_OFFSET + 0x00)
-#define LCPU_ARCH_OFFSET               (LCPU_ENTRY_OFFSET + 0x10)
+#define LCPU_AUXSP_OFFSET              (LCPU_ENTRY_OFFSET + 0x10)
+#define LCPU_ARCH_OFFSET               (LCPU_ENTRY_OFFSET + 0x18)
 
 #ifdef CONFIG_HAVE_SMP
 #define LCPU_FUNC_SIZE                 0x10
@@ -136,6 +137,9 @@ struct __align(CACHE_LINE_SIZE) lcpu {
                int error_code;
        };
 
+       /* Auxiliary stack pointer of the thread currently executing on LCPU */
+       __uptr auxsp;
+
        /* Architecture-dependent part */
        struct lcpu_arch arch;
 };
@@ -150,6 +154,7 @@ UK_CTASSERT(__offsetof(struct lcpu, id)            == LCPU_ID_OFFSET);
 UK_CTASSERT(__offsetof(struct lcpu, s_args.entry)  == LCPU_ENTRY_OFFSET);
 UK_CTASSERT(__offsetof(struct lcpu, s_args.stackp) == LCPU_STACKP_OFFSET);
 UK_CTASSERT(__offsetof(struct lcpu, error_code)    == LCPU_ERR_OFFSET);
+UK_CTASSERT(__offsetof(struct lcpu, auxsp)         == LCPU_AUXSP_OFFSET);
 UK_CTASSERT(__offsetof(struct lcpu, arch)          == LCPU_ARCH_OFFSET);
 
 UK_CTASSERT(sizeof(struct lcpu) == LCPU_SIZE);