From nobody Sat Nov 11 00:40:16 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SRxg46JT0z501RW; Sat, 11 Nov 2023 00:40:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SRxg45sQDz4Gf2; Sat, 11 Nov 2023 00:40:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699663216; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jXqPTET/dZ7HEpjJW4M1Ke7tZVcwCMLRPJ6b+eu//Z0=; b=UnJ9sWDeSaHKBkT/BZ3ZJjcvN/jsZBB5XaE3aNVK4XF3YAI+3+NFZn58OeQ9nvGopdOJNA bWkxbrlPGleIzsXvJ7BUR0VXwVRjV/fYs+YoT3M0QfBQCS4PI43t8sjqVBfZ7zfQwz5cYy 6zZfo24XVYuHdKePEmw9cca4YZNTigCDPR6SkgyECDmt4fQ88IxN0hMCoSZvQ4qvTayaG6 xYACKIgBkj0SDvoz6scaiNpqKvXvqZ0J0YqK6l+nwtvgSvTb5GU/F2oPB/3q2my8gmdFFD heGqHYzak/RaPdTu/F4LxUJzSuBYe5SAWTEeay+aQMMGD35YYW4h9DFGA6ZSdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699663216; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jXqPTET/dZ7HEpjJW4M1Ke7tZVcwCMLRPJ6b+eu//Z0=; b=aCERZCYfQ+hKb5GC7bl+s13LY4ZdkVqGeWMTvmrCftv0FHL4H3gyIbYNO9uIKOYfrAGHxq UZMVqhQWDaMUADDdgobRcPOYXMaS4+OrLTY+N/XTIiGr0BstWmt3z3kwdUwMlmEyaFjCzb SxEbs3/Yx2XcypFCxYd62/2GmBBmz9OPRluP5pbHiYcMHPFPdiHh02Fu02ldEURgdOb5bQ cwezvQq7iA1dogelk88n+6gLPdB42spYTP4/SXizDkqlAiFCM4QcZ56r1z7SocZBUaQbjq kaxNRUfp4E/U+FL/ghHm01lJ9oLOGs1PTTY5g8N+JHbCkcd+OyS5HcxMluEiKA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699663216; a=rsa-sha256; cv=none; b=TCdKvJiMbuPefRKR76Gpt/xkQ7sUqyLP23dZt4KXdkPZ3PpOxSPNxzFurAJDMdFdrptvAS ODLkfYJU4gIIhbO4FFXUmRtb7AzMoKolwCQhPy/qeClt+yiPeMIrxHSo+EhKhn2IuW/h1m kehC6jAdty820j+vf9NWqiq/rhT2UK3t508zVwggWZLZd20T14q8PylGRu8O6dX013pNPw QbFSiQQMhHwtzQf4ADP3EEj0SoGV4Y1kU5O0KU//87nb9GIwVaftJeFTqN242VOKYV3cAM Kai79Wf9lgau+4VV/W+x1ZxSzZp9frct8DnjbYkcab21DZCUJfMs/pTU6K4W0w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SRxg44p7Nz4Tx; Sat, 11 Nov 2023 00:40:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AB0eG40076865; Sat, 11 Nov 2023 00:40:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AB0eGQo076857; Sat, 11 Nov 2023 00:40:16 GMT (envelope-from git) Date: Sat, 11 Nov 2023 00:40:16 GMT Message-Id: <202311110040.3AB0eGQo076857@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 0dc8af9dae2c - stable/14 - arm64: improve UVA layout for 32bit processes List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 0dc8af9dae2ca5419a0d3313d0dcb42c6b5d6d38 Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0dc8af9dae2ca5419a0d3313d0dcb42c6b5d6d38 commit 0dc8af9dae2ca5419a0d3313d0dcb42c6b5d6d38 Author: Konstantin Belousov AuthorDate: 2023-10-25 01:03:09 +0000 Commit: Konstantin Belousov CommitDate: 2023-11-10 12:15:46 +0000 arm64: improve UVA layout for 32bit processes PR: 274705 (cherry picked from commit 967022aa5aa60a18764a668ae0fb78e39e16fa8e) --- sys/arm64/arm64/elf32_machdep.c | 54 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/sys/arm64/arm64/elf32_machdep.c b/sys/arm64/arm64/elf32_machdep.c index 4161f9d44ae7..733aaf40541a 100644 --- a/sys/arm64/arm64/elf32_machdep.c +++ b/sys/arm64/arm64/elf32_machdep.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,9 @@ #define FREEBSD32_MAXUSER ((1ul << 32) - PAGE_SIZE) #define FREEBSD32_SHAREDPAGE (FREEBSD32_MAXUSER - PAGE_SIZE) #define FREEBSD32_USRSTACK FREEBSD32_SHAREDPAGE +#define AARCH32_MAXDSIZ (512 * 1024 *n1024) +#define AARCH32_MAXSSIZ (64 * 1024 * 1024) +#define AARCH32_MAXVMEM 0 extern const char *freebsd32_syscallnames[]; @@ -74,12 +78,26 @@ static void freebsd32_set_syscall_retval(struct thread *, int); static bool elf32_arm_abi_supported(struct image_params *, int32_t *, uint32_t *); +static void elf32_fixlimit(struct rlimit *rl, int which); extern void freebsd32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask); u_long __read_frequently elf32_hwcap; u_long __read_frequently elf32_hwcap2; +static SYSCTL_NODE(_compat, OID_AUTO, aarch32, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, + "aarch32 mode"); + +static u_long aarch32_maxdsiz = AARCH32_MAXDSIZ; +SYSCTL_ULONG(_compat_aarch32, OID_AUTO, maxdsiz, CTLFLAG_RWTUN, + &aarch32_maxdsiz, 0, ""); +u_long aarch32_maxssiz = AARCH32_MAXSSIZ; +SYSCTL_ULONG(_compat_aarch32, OID_AUTO, maxssiz, CTLFLAG_RWTUN, + &aarch32_maxssiz, 0, ""); +static u_long aarch32_maxvmem = AARCH32_MAXVMEM; +SYSCTL_ULONG(_compat_aarch32, OID_AUTO, maxvmem, CTLFLAG_RWTUN, + &aarch32_maxvmem, 0, ""); + static struct sysentvec elf32_freebsd_sysvec = { .sv_size = SYS_MAXSYSCALL, .sv_table = freebsd32_sysent, @@ -102,8 +120,8 @@ static struct sysentvec elf32_freebsd_sysvec = { .sv_copyout_auxargs = elf32_freebsd_copyout_auxargs, .sv_copyout_strings = freebsd32_copyout_strings, .sv_setregs = freebsd32_setregs, - .sv_fixlimit = NULL, // XXX - .sv_maxssiz = NULL, + .sv_fixlimit = elf32_fixlimit, + .sv_maxssiz = &aarch32_maxssiz, .sv_flags = SV_ABI_FREEBSD | SV_ILP32 | SV_SHP | SV_TIMEKEEP | SV_RNG_SEED_VER | SV_SIGSYS, .sv_set_syscall_retval = freebsd32_set_syscall_retval, @@ -284,3 +302,35 @@ void elf32_dump_thread(struct thread *td, void *dst, size_t *off) { } + +static void +elf32_fixlimit(struct rlimit *rl, int which) +{ + + switch (which) { + case RLIMIT_DATA: + if (aarch32_maxdsiz != 0) { + if (rl->rlim_cur > aarch32_maxdsiz) + rl->rlim_cur = aarch32_maxdsiz; + if (rl->rlim_max > aarch32_maxdsiz) + rl->rlim_max = aarch32_maxdsiz; + } + break; + case RLIMIT_STACK: + if (aarch32_maxssiz != 0) { + if (rl->rlim_cur > aarch32_maxssiz) + rl->rlim_cur = aarch32_maxssiz; + if (rl->rlim_max > aarch32_maxssiz) + rl->rlim_max = aarch32_maxssiz; + } + break; + case RLIMIT_VMEM: + if (aarch32_maxvmem != 0) { + if (rl->rlim_cur > aarch32_maxvmem) + rl->rlim_cur = aarch32_maxvmem; + if (rl->rlim_max > aarch32_maxvmem) + rl->rlim_max = aarch32_maxvmem; + } + break; + } +}