git: 1a9f14cfa5c5 - stable/13 - Use vmspace->vm_stacktop in place of sv_usrstack in more places.

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 16 Feb 2022 17:59:17 UTC
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=1a9f14cfa5c56402d816914a1510d8db2c4d5623

commit 1a9f14cfa5c56402d816914a1510d8db2c4d5623
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-02-14 18:57:30 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-02-16 16:55:37 +0000

    Use vmspace->vm_stacktop in place of sv_usrstack in more places.
    
    Reviewed by:    markj
    Obtained from:  CheriBSD
    
    (cherry picked from commit becaf6433be4a7c86e8053d42f399176c24d76b6)
---
 sys/compat/linux/linux_mmap.c | 2 +-
 sys/kern/kern_resource.c      | 4 ++--
 sys/vm/vm_map.c               | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/compat/linux/linux_mmap.c b/sys/compat/linux/linux_mmap.c
index 1b4b0b78280c..f4655adcbb52 100644
--- a/sys/compat/linux/linux_mmap.c
+++ b/sys/compat/linux/linux_mmap.c
@@ -178,7 +178,7 @@ linux_mmap_common(struct thread *td, uintptr_t addr, size_t len, int prot,
 			 * mmap's return value.
 			 */
 			PROC_LOCK(p);
-			vms->vm_maxsaddr = (char *)p->p_sysent->sv_usrstack -
+			vms->vm_maxsaddr = (char *)round_page(vms->vm_stacktop) -
 			    lim_cur_proc(p, RLIMIT_STACK);
 			PROC_UNLOCK(p);
 		}
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index 0ea863917727..3dd243199088 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -760,12 +760,12 @@ kern_proc_setrlimit(struct thread *td, struct proc *p, u_int which,
 			if (limp->rlim_cur > oldssiz.rlim_cur) {
 				prot = p->p_sysent->sv_stackprot;
 				size = limp->rlim_cur - oldssiz.rlim_cur;
-				addr = p->p_sysent->sv_usrstack -
+				addr = round_page(p->p_vmspace->vm_stacktop) -
 				    limp->rlim_cur;
 			} else {
 				prot = VM_PROT_NONE;
 				size = oldssiz.rlim_cur - limp->rlim_cur;
-				addr = p->p_sysent->sv_usrstack -
+				addr = round_page(p->p_vmspace->vm_stacktop) -
 				    oldssiz.rlim_cur;
 			}
 			addr = trunc_page(addr);
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index 4c3448c358da..fb59c2351a5d 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -4666,7 +4666,7 @@ retry:
 	 * limit.
 	 */
 	is_procstack = addr >= (vm_offset_t)vm->vm_maxsaddr &&
-	    addr < (vm_offset_t)p->p_sysent->sv_usrstack;
+	    addr < (vm_offset_t)vm->vm_stacktop;
 	if (is_procstack && (ctob(vm->vm_ssize) + grow_amount > stacklim))
 		return (KERN_NO_SPACE);