summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-26 15:14:17 -0400
committerIan Moffett <ian@osmora.org>2025-07-26 15:14:17 -0400
commit6b3c37f5bc9dbd3656ee08b925f2df2d233084fe (patch)
treed7d6666eb4e9e9cb6e99c0737d4278c64024fd62 /sys
parent15c4ee1321be918d8fcbc8d858ea90a4dabe54a5 (diff)
kernel: vsr: Add 'td' argument for most funcsexpt
Allow specification of which process should be targeted for specific operations. Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/include/sys/vsr.h12
-rw-r--r--sys/kern/kern_vsr.c50
2 files changed, 24 insertions, 38 deletions
diff --git a/sys/include/sys/vsr.h b/sys/include/sys/vsr.h
index 88cb659..e63cce1 100644
--- a/sys/include/sys/vsr.h
+++ b/sys/include/sys/vsr.h
@@ -39,6 +39,8 @@
#include <sys/mutex.h>
#endif /* _KERNEL */
+struct proc;
+
#define VSR_FILE 0x00000000 /* Represented by file */
/*
@@ -152,12 +154,12 @@ struct vsr_domain {
struct vsr_table table;
};
-void vsr_init_domains(void);
-void vsr_destroy_domains(void);
+void vsr_init_domains(struct proc *td);
+void vsr_destroy_domains(struct proc *td);
-struct vsr_domain *vsr_new_domain(vsr_domain_t type);
-struct vsr_capsule *vsr_new_capsule(vsr_domain_t type, const char *name);
-struct vsr_capsule *vsr_lookup_capsule(vsr_domain_t type, const char *name);
+struct vsr_domain *vsr_new_domain(struct proc *td, vsr_domain_t type);
+struct vsr_capsule *vsr_new_capsule(struct proc *td, vsr_domain_t type, const char *name);
+struct vsr_capsule *vsr_lookup_capsule(struct proc *td, vsr_domain_t type, const char *name);
#endif /* _KERNEL */
#endif /* !_SYS_VSR_H_ */
diff --git a/sys/kern/kern_vsr.c b/sys/kern/kern_vsr.c
index 8fb7fc7..c59be1e 100644
--- a/sys/kern/kern_vsr.c
+++ b/sys/kern/kern_vsr.c
@@ -208,20 +208,19 @@ vsr_destroy_table(struct vsr_table *tab)
/*
* Allocate a new VSR capsule and add it to
* VSR domain.
+ *
+ * @type: Domain type (e.g., VSR_FILE)
+ * @name: Capsule name (e.g., "mod0.data")
+ * @sz: Length of capsulized data
*/
struct vsr_capsule *
-vsr_new_capsule(vsr_domain_t type, const char *name)
+vsr_new_capsule(struct proc *td, vsr_domain_t type, const char *name)
{
struct vsr_capsule *capsule;
struct vsr_domain *domain;
- struct proc *td = this_td();
- /* Valid type? */
- if (type >= VSR_MAX_DOMAIN) {
- return NULL;
- }
-
- if (__unlikely(td == NULL)) {
+ /* Valid args? */
+ if (type >= VSR_MAX_DOMAIN || td == NULL) {
return NULL;
}
@@ -250,27 +249,17 @@ vsr_new_capsule(vsr_domain_t type, const char *name)
/*
* Allocate a new VSR domain and add it to
- * the current process.
+ * a specific process.
*
* @type: VSR type (e.g., VSR_FILE)
*/
struct vsr_domain *
-vsr_new_domain(vsr_domain_t type)
+vsr_new_domain(struct proc *td, vsr_domain_t type)
{
struct vsr_domain *domain;
- struct vsr_table *tablep;
- struct proc *td = this_td();
- /* Valid type? */
- if (type >= VSR_MAX_DOMAIN) {
- return NULL;
- }
-
- /*
- * The scheduler should be set up before any
- * calls to vsr_new_vec() should be made.
- */
- if (__unlikely(td == NULL)) {
+ /* Valid args? */
+ if (type >= VSR_MAX_DOMAIN || td == NULL) {
return NULL;
}
@@ -293,8 +282,6 @@ vsr_new_domain(vsr_domain_t type)
memset(domain, 0, sizeof(*domain));
domain->type = type;
- /* Initialize the domain's table */
- tablep = &domain->table;
td->vsr_tab[type] = domain;
return domain;
}
@@ -304,13 +291,11 @@ vsr_new_domain(vsr_domain_t type)
* process.
*/
struct vsr_capsule *
-vsr_lookup_capsule(vsr_domain_t type, const char *name)
+vsr_lookup_capsule(struct proc *td, vsr_domain_t type, const char *name)
{
struct vsr_domain *domain;
- struct proc *td = this_td();
- /* Must be on a process */
- if (__unlikely(td == NULL)) {
+ if (td == NULL) {
return NULL;
}
@@ -330,9 +315,9 @@ vsr_lookup_capsule(vsr_domain_t type, const char *name)
* Initialize per-process domains
*/
void
-vsr_init_domains(void)
+vsr_init_domains(struct proc *td)
{
- if (vsr_new_domain(VSR_FILE) == NULL) {
+ if (vsr_new_domain(td, VSR_FILE) == NULL) {
pr_error("failed to initialize VSR file domain\n");
}
}
@@ -341,12 +326,11 @@ vsr_init_domains(void)
* Destroy per-process domains
*/
void
-vsr_destroy_domains(void)
+vsr_destroy_domains(struct proc *td)
{
- struct proc *td = this_td();
struct vsr_domain *domain;
- if (__unlikely(td == NULL)) {
+ if (td == NULL) {
return;
}