[PATCH 4/4] include: sbi: scratch: Add per-hart FP and vector context pointers in scratch
dave.patel at riscstar.com
dave.patel at riscstar.com
Fri Mar 20 07:23:49 PDT 2026
From: Dave Patel <dave.patel at riscstar.com>
Extend the per-hart sbi_scratch structure to include pointers to floating-point
and vector context storage.
This enables tracking of the currently active FP and vector context on a per-hart
basis, which is required for eager context switching during trap handling.
The scratch structure serves as the central per-hart storage area, making these
pointers readily accessible in low-level trap and context switch paths.
The FP and vector context pointers are used by the corresponding save/restore
routines to preserve architectural state across traps, ensuring correct isolation
between privilege levels.
This change lays the foundation for eager FP and vector context management in OpenSBI.
Signed-off-by: Dave Patel <dave.patel at riscstar.com>
---
include/sbi/sbi_scratch.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h
index 58d54628..13e4a294 100644
--- a/include/sbi/sbi_scratch.h
+++ b/include/sbi/sbi_scratch.h
@@ -54,6 +54,8 @@
#ifndef __ASSEMBLER__
#include <sbi/sbi_types.h>
+#include <sbi/sbi_fp.h>
+#include <sbi/sbi_vector.h>
/** Representation of per-HART scratch space */
struct sbi_scratch {
@@ -87,6 +89,9 @@ struct sbi_scratch {
unsigned long options;
/** Index of the hart */
unsigned long hartindex;
+ /* Current FP/Vector context owner per hart */
+ struct sbi_fp_context *fp_ctx;
+ struct sbi_vector_context *vec_ctx;
};
/**
--
2.43.0
More information about the opensbi
mailing list