From nobody Mon Nov 22 22:37:51 2021 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 3C24B1892CF4; Mon, 22 Nov 2021 22:37:53 +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 4HyhxD07qgz4YQ5; Mon, 22 Nov 2021 22:37:51 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 6830A2F85; Mon, 22 Nov 2021 22:37:51 +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 1AMMbppM047322; Mon, 22 Nov 2021 22:37:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AMMbpwX047321; Mon, 22 Nov 2021 22:37:51 GMT (envelope-from git) Date: Mon, 22 Nov 2021 22:37:51 GMT Message-Id: <202111222237.1AMMbpwX047321@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brooks Davis Subject: git: 0a4e16446b02 - main - makesyscalls: handle longs in ABI compat 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: brooks X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0a4e16446b02f2aa0701ee0977366678987fba43 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=0a4e16446b02f2aa0701ee0977366678987fba43 commit 0a4e16446b02f2aa0701ee0977366678987fba43 Author: Brooks Davis AuthorDate: 2021-11-22 22:36:57 +0000 Commit: Brooks Davis CommitDate: 2021-11-22 22:36:57 +0000 makesyscalls: handle longs in ABI compat Replace long-derived types with their abi equivalent where required by the target ABI. There are two cases: - All pointers to types that go from 64-bit to 32-bit between the default ABI and the target ABI. - Signed arguments that go from 64-bit to 32-bit (these require sign-extension before passing to general kernel ABIs). This adds four new config variables: abi_long, semid_t, abi_size_t, and abi_u_long which default to long, size_t, and u_long respectively. Reviewed by: kevans --- sys/tools/makesyscalls.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sys/tools/makesyscalls.lua b/sys/tools/makesyscalls.lua index 1023e2faa0e6..a4250e072277 100644 --- a/sys/tools/makesyscalls.lua +++ b/sys/tools/makesyscalls.lua @@ -62,6 +62,10 @@ local config = { abi_flags_mask = 0, abi_headers = "", abi_intptr_t = "intptr_t", + abi_size_t = "size_t", + abi_u_long = "u_long", + abi_long = "long", + abi_semid_t = "semid_t", ptr_intptr_t_cast = "intptr_t", } @@ -134,6 +138,16 @@ local known_abi_flags = { value = 0x00000001, exprs = { "_Contains[a-z_]*_long_", + "^long [a-z0-9_]+$", + "long [*]", + "size_t [*]", + -- semid_t is not included because it is only used + -- as an argument or written out individually and + -- said writes are handled by the ksem framework. + -- Technically a sign-extension issue exists for + -- arguments, but because semid_t is actually a file + -- descriptor negative 32-bit values are invalid + -- regardless of sign-extension. }, }, time_t_size = { @@ -603,6 +617,15 @@ local function process_args(args) end argtype = argtype:gsub("intptr_t", config["abi_intptr_t"]) + argtype = argtype:gsub("semid_t", config["abi_semid_t"]) + if isptrtype(argtype) then + argtype = argtype:gsub("size_t", config["abi_size_t"]) + argtype = argtype:gsub("^long", config["abi_long"]); + argtype = argtype:gsub("^u_long", config["abi_u_long"]); + argtype = argtype:gsub("^const u_long", "const " .. config["abi_u_long"]); + elseif argtype:find("^long$") then + argtype = config["abi_long"] + end -- XX TODO: Forward declarations? See: sysstubfwd in CheriBSD if abi_change then