From nobody Tue Mar 01 14:40:02 2022 X-Original-To: dev-commits-src-main@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 C3F3819DB358; Tue, 1 Mar 2022 14:40:05 +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 4K7KfC1H9yz3Fyc; Tue, 1 Mar 2022 14:40:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646145605; 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=wYb+jZZ8A7O0gHFdpMlImy3niaOaPnKJvdXGbrvkz/Q=; b=tD+MybQo5rsd6YA6og0COPnw+GSgUoDDrCh2Tk5uYTfnFn6MsdJfLy2cKhsT2o2uFzzPut 5d8pDOAUygd0eJ5ws3WzzexBO+Fyv4WfSkVJlSYU2eut1fhJuQF0InSdgntciCYeC2zyhj YS2qTVwkekhyhH+cooQR/gQ0y8NrWRPWoNE6YTh5hRZW32EzCHcnX/u2b8r1HXspa4L6ct AIqeIc06WVhAkv4ZiHk4HmKCRKDAMiKW8aQ5hSA+auyNP/aYnXL9jd5ZhcDulkslX4SWcz UB2NzUTBOfGKMN2j0ablPiu/eB6bAQc6BJ9dxGqPYu2yAsmb4wqLexeoB8VsZQ== 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 A194B117A3; Tue, 1 Mar 2022 14:40:02 +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 221Ee2hO040518; Tue, 1 Mar 2022 14:40:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 221Ee2v4040515; Tue, 1 Mar 2022 14:40:02 GMT (envelope-from git) Date: Tue, 1 Mar 2022 14:40:02 GMT Message-Id: <202203011440.221Ee2v4040515@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: ecaf115434cf - main - riscv: Conditionally modify the ELF64 sysentvec for SV48 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: ecaf115434cf5b427339d27860bcbee3e9f48e39 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646145605; 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=wYb+jZZ8A7O0gHFdpMlImy3niaOaPnKJvdXGbrvkz/Q=; b=YAKx3PHEU5TnA1PoXsJBzHGPtCZgYw01p6FV4P8kjtbjXeT1FCufYK59Tm2ziTi5lrSFrD CIcqiOyFoc72yJOn07VIYKytvH9b3XU8txpDPjWv7MJ9RzPqpGmuVcopjshQiCWKY+9qVI YCQTaRTJzNbRX+TKSpBny89Fv6+0Gl5Y0mRkWXiJCNxp2KClvFWz8kv3+AwP5U/IX8luAn 0T6z8sqI5mQ78RsDyBBhp4vvnXif3Rhiw9fm3wpBrnT/8k/XPUrCOWMEI5YB9qPyRrKYl7 s2Ngjj+FwnVHgloVeQepmFcKCKgGKnrwRvNgr0/QD6YrszNv9CksumE9IpIJiw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646145605; a=rsa-sha256; cv=none; b=H8d8buql6qpGsoEdvArOAQ4ZEYRnRHWTATLrZAQDS8Sf+CJbnociLkF3Fpp0aXPfwvuruH VCpm3c+pAxFaZNDsBEcUi3UvGml/Hgz+lXB9vDNqmzKJjikSFYylvKnuhJKFghrYOEZPuW +l8av/P9pszegsCErhl6lmVVDNrCQYk67oln+BZxRERPpSLpaGTRSrVCyNvwYAHV+zTjsH ZBanvizQyFNLriWFIr5ngb3B3cjuVx7hboLTGaAkWQdR48kbKaVaEt9Xzwl2y8QNhtG/+K v5Q6Jnmf3q2lHFnFlpE2ByhBfDSrYbbCme2Yw5uZ63ZsUOFNxDb6K6kDzbxaqw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ecaf115434cf5b427339d27860bcbee3e9f48e39 commit ecaf115434cf5b427339d27860bcbee3e9f48e39 Author: Mark Johnston AuthorDate: 2022-03-01 14:05:02 +0000 Commit: Mark Johnston CommitDate: 2022-03-01 14:39:43 +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 MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34274 --- 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 117f28c941d3..c218fc76af5e 100644 --- a/sys/riscv/riscv/elf_machdep.c +++ b/sys/riscv/riscv/elf_machdep.c @@ -63,7 +63,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, @@ -79,9 +79,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), @@ -94,7 +94,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, @@ -129,10 +129,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()");