Skip to content

Commit

Permalink
{stop,start}_vmspace_proc: take a proc argument
Browse files Browse the repository at this point in the history
While the process will currently be curproc it's more consistant with
other code in the revoker to take struct proc *.
  • Loading branch information
brooksdavis committed Feb 3, 2023
1 parent 3373954 commit 9551da8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
6 changes: 2 additions & 4 deletions sys/kern/kern_cheri_revoke.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,7 @@ kern_cheri_revoke(struct thread *td, int flags,
return ERESTART;
}
}
KASSERT(td->td_proc == curproc,
("stop_vmspace_proc only works with curproc"));
stop_vmspace_proc();
stop_vmspace_proc(td->td_proc);

/*
* Drop the process lock *then* iterate the threads in this
Expand Down Expand Up @@ -537,7 +535,7 @@ kern_cheri_revoke(struct thread *td, int flags,

PROC_LOCK(td->td_proc);
_PRELE(td->td_proc);
resume_vmspace_proc();
resume_vmspace_proc(td->td_proc);
if ((td->td_proc->p_flag & P_HADTHREADS) != 0) {
thread_single_end(td->td_proc, SINGLE_BOUNDARY);
}
Expand Down
10 changes: 4 additions & 6 deletions sys/kern/kern_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3859,9 +3859,9 @@ resume_all_proc(void)
* curproc. It should be run after curproc has entered thread_single.
*/
void
stop_vmspace_proc(void)
stop_vmspace_proc(struct proc* cp)
{
struct proc *cp, *p;
struct proc *p;
struct vmspace *vm;
int r, gen;
bool restart, seen_stopped, seen_exiting, stopped_some;
Expand All @@ -3871,7 +3871,6 @@ stop_vmspace_proc(void)
* Maybe atomic CAS on a field in vmspace?
*/

cp = curproc;
vm = cp->p_vmspace;
vmspace_loop:
VMSPACE_LOCK(vm);
Expand Down Expand Up @@ -3932,12 +3931,11 @@ stop_vmspace_proc(void)
}

void
resume_vmspace_proc(void)
resume_vmspace_proc(struct proc *cp)
{
struct proc *cp, *p;
struct proc *p;
struct vmspace *vm;

cp = curproc;
vm = cp->p_vmspace;

VMSPACE_LOCK(vm);
Expand Down
4 changes: 2 additions & 2 deletions sys/sys/proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1300,8 +1300,8 @@ void stop_all_proc_unblock(void);

void stop_all_proc(void);
void resume_all_proc(void);
void stop_vmspace_proc(void);
void resume_vmspace_proc(void);
void stop_vmspace_proc(struct proc *cp);
void resume_vmspace_proc(struct proc *cp);

static __inline int
curthread_pflags_set(int flags)
Expand Down

0 comments on commit 9551da8

Please sign in to comment.