From nobody Mon Mar 14 14:46:10 2022 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 7414D1A26E4D; Mon, 14 Mar 2022 14:46:11 +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 4KHK9G6yH9z3hPl; Mon, 14 Mar 2022 14:46:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647269171; 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=/TinbVvA3/BsBnn9MYQSsEEbJtBD3/2F9U1zh/m8mRg=; b=F0OnrelJ1cw8grXrmHmAAlXbHYsaU/zU4Gtf8LciYng/TpY4LZ5Rn2BYgV5Sdtg7vhF+I3 +yHyoixaBT4TzGH3dqkP+DlaWnncq24gsqBBPDE1JCeZblQ2XwNIO0xvnk/Uaaxg+pxuBD Olm/Uup8BpTYHB6/Vf4n71fkkae+SzmkPWLZDhmQGufv8sQJNva2KY3vFqkHZ1ABun1qqH xioMOZoZJc/W9o3O2/sNw203XfJfYqgJfLUy6UNoH8MhWq47hyzwEGiDAz76UX9GN2BQnG MIqL1M5KyqMhS8rQGCHOiiUaGAkhCr4x/xrbT5Y+Mvk47yQy60Hy6JJTwjIo1Q== 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 95D796F72; Mon, 14 Mar 2022 14:46:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22EEkA60051976; Mon, 14 Mar 2022 14:46:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22EEkAsE051975; Mon, 14 Mar 2022 14:46:10 GMT (envelope-from git) Date: Mon, 14 Mar 2022 14:46:10 GMT Message-Id: <202203141446.22EEkAsE051975@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 4bf624d7cfac - stable/13 - riscv: Conditionally modify the ELF64 sysentvec for SV48 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4bf624d7cfacb9500924d84675abec5af97cc862 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647269171; 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=/TinbVvA3/BsBnn9MYQSsEEbJtBD3/2F9U1zh/m8mRg=; b=cCmYp6XHg23wzYpfwr13SqY9avkkdX3CI4vuzOEwUw6l4hOzE9RvQW+08e17d91t6fXM35 Y0/uy0LrkJUg3ldTafoJaud+UAL8zlYqK6y0pn22o3KjVPjJC9F2oXLWpZuqlWQYSmGC9/ A66YNnrSYc2HWahLDo3TJn0JD4usQxUZqpXUoF3Rop6AgpTvBqkjRrkn6T0o1RjeqcLZSH 5PJLNem4BMh4hJWZwEXX9GgaJwHA3nSsbsJGampxS8Saje5SrCG8qCOZhEAp+9NHSTn/jI IT4EGqvrYR3kTHsow8lqihaxVtVk/5n/CzhHfn27shLQGiUZOywDZG9iUq2sFg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647269171; a=rsa-sha256; cv=none; b=LQuci3oWwA4ySODKjuX/sMqMc5PNvsrsArJHstTp65V2ve/BSNqc2NNcSMNiQ1e5N6M6rp NvMuHXjy7hnn+etVaMjhb+5HzCwqZSp4wBfmanI63qm4CGXjBcpclyBVuxJWR64EYPJYQd gdUP4wkugoOEIyq+eMcSrYmLN6DsmS4Qh2WrTM4Vji0/i0YcIHtgH945jEp8UI11IBvoPt uQfxrS+vmbCPBuhmGNm92nLdY0j8Zdi9TgPB4VWdwwa7GNMs994/9Z833b8MzyzilA+8MM wszVNeOL80GgWlOayXsH5Eej1zjwQpHlZgJT8IQpGKnHUvc8YG4uOpzHDF6gNA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4bf624d7cfacb9500924d84675abec5af97cc862 commit 4bf624d7cfacb9500924d84675abec5af97cc862 Author: Mark Johnston AuthorDate: 2022-03-01 14:05:02 +0000 Commit: Mark Johnston CommitDate: 2022-03-14 14:45:36 +0000 riscv: Conditionally modify the ELF64 sysentvec for SV48 A sysinit determines whether the pmap has enabled SV48 mode and modifies the corresponding fields which describe the user memory map. Reviewed by: kib, jhb Sponsored by: The FreeBSD Foundation (cherry picked from commit ecaf115434cf5b427339d27860bcbee3e9f48e39) --- sys/riscv/riscv/elf_machdep.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/sys/riscv/riscv/elf_machdep.c b/sys/riscv/riscv/elf_machdep.c index 1e24cbf51004..f9b4098c4fca 100644 --- a/sys/riscv/riscv/elf_machdep.c +++ b/sys/riscv/riscv/elf_machdep.c @@ -62,7 +62,7 @@ static const char *riscv_machine_arch(struct proc *p); u_long elf_hwcap; -struct sysentvec elf64_freebsd_sysvec = { +static struct sysentvec elf64_freebsd_sysvec = { .sv_size = SYS_MAXSYSCALL, .sv_table = sysent, .sv_transtrap = NULL, @@ -75,9 +75,9 @@ struct sysentvec elf64_freebsd_sysvec = { .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, .sv_minuser = VM_MIN_ADDRESS, - .sv_maxuser = VM_MAXUSER_ADDRESS, - .sv_usrstack = USRSTACK, - .sv_psstrings = PS_STRINGS, + .sv_maxuser = 0, /* Filled in during boot. */ + .sv_usrstack = 0, /* Filled in during boot. */ + .sv_psstrings = 0, /* Filled in during boot. */ .sv_psstringssz = sizeof(struct ps_strings), .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, .sv_copyout_auxargs = __elfN(freebsd_copyout_auxargs), @@ -90,7 +90,7 @@ struct sysentvec elf64_freebsd_sysvec = { .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, - .sv_shared_page_base = SHAREDPAGE, + .sv_shared_page_base = 0, /* Filled in during boot. */ .sv_shared_page_len = PAGE_SIZE, .sv_schedtail = NULL, .sv_thread_detach = NULL, @@ -123,10 +123,33 @@ static Elf64_Brandinfo freebsd_brand_info = { .brand_note = &elf64_freebsd_brandnote, .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE }; - SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_FIRST, (sysinit_cfunc_t)elf64_insert_brand_entry, &freebsd_brand_info); +static void +elf64_register_sysvec(void *arg) +{ + struct sysentvec *sv; + + sv = arg; + switch (pmap_mode) { + case PMAP_MODE_SV48: + sv->sv_maxuser = VM_MAX_USER_ADDRESS_SV48; + sv->sv_usrstack = USRSTACK_SV48; + sv->sv_psstrings = PS_STRINGS_SV48; + sv->sv_shared_page_base = SHAREDPAGE_SV48; + break; + case PMAP_MODE_SV39: + sv->sv_maxuser = VM_MAX_USER_ADDRESS_SV39; + sv->sv_usrstack = USRSTACK_SV39; + sv->sv_psstrings = PS_STRINGS_SV39; + sv->sv_shared_page_base = SHAREDPAGE_SV39; + break; + } +} +SYSINIT(elf64_register_sysvec, SI_SUB_VM, SI_ORDER_ANY, elf64_register_sysvec, + &elf64_freebsd_sysvec); + static bool debug_kld; SYSCTL_BOOL(_debug, OID_AUTO, kld_reloc, CTLFLAG_RW, &debug_kld, 0, "Activate debug prints in elf_reloc_internal()");