From nobody Mon May 09 18:17:11 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 D13371ADF99B; Mon, 9 May 2022 18:17:12 +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 4KxqBv474rz3J9B; Mon, 9 May 2022 18:17:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652120231; 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=PldOOADwntrvIx9FVOoorZGrAgyix2h9TJJuxB8KiE0=; b=J+/xQtM8JPSTDmZ2qYVG9d5FpEsccnHKOjrnkePvYmWMK33XEPRwArecwNmU5GAQ8bpsik fspMwgxM4nD7wgZpADRWmcZDqqcbNPEUE0AywZA2oHkRG0pJp9+s8c8/ffqcK3tZzmsCJb ZYJokivSKdn3Za7LhwvBDvBfSCTYSFu5P2uUmeqYOYxu7bBmqeSJcr2OUTj8s5SmL9A1cP lxPpk9BBonKa+pVkG8qq+oOqFKS/BlEoeKPAfIHp9UG0xIT/hN5aiuunZDkC0j7O/9Px7e BkVDNS+rh8rU6ZkprNmvGboWqirEjBfn6m3BpxA43dSQ4W+z3IJBhKZaDidijA== 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 49AEC16088; Mon, 9 May 2022 18:17:11 +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 249IHBtH090545; Mon, 9 May 2022 18:17:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 249IHBQF090544; Mon, 9 May 2022 18:17:11 GMT (envelope-from git) Date: Mon, 9 May 2022 18:17:11 GMT Message-Id: <202205091817.249IHBQF090544@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 07d108932ab5 - main - linux(4): Return native error from futex_atomic_op to avoid conversion by the caller. 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: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 07d108932ab5b5bc25221be4916ebf8874cd256f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652120231; 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=PldOOADwntrvIx9FVOoorZGrAgyix2h9TJJuxB8KiE0=; b=aqHy85+hZkENYuqXB4Taz+ye3aaXyxqgQAKxWSXUwUI6cdNK6UCYOdKNSfPZs6D4rY9zI1 HkG7HEN4eudX2IljTrEBRj2ueCIfiTryTYp7Omsch2Ftv39kQkhxoZVulu8EIRGdFofPzo NMr6g+wifI6h4nMjL0/M/cj8DRTennkjj5PTN+QEGLna4+9m3J+Han2Up31gjsplV/Ij8l RvbE80/0ENbzcnBapHWe2xV7rV9+uQ2P+m7HSyRv4pazQ/EJ3qjsLRkCamqE3G0u0j5RKp x9JSpT40T5sRXvbObG7VZP6BPBQpWPvpNS3K4ggP9wfrZl2rzCxUWBvSepf4Ig== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652120231; a=rsa-sha256; cv=none; b=ADjbB2LfXvUaOSaaXXyUv966g9lRByr9JFHiycq2Ay42krzjcrorNaxULFqoTzW8jLLES5 L9GjaIjS3gPzy6SAuwMcmwTO7xe1phe4Ik4l8MWttIo2+WT8NnWhdHYzqIXEHXafvU3/4G 5LAsxaCH7NqgmyJhgALSpnRv5V/j4UCDI5tuq0VZutyI/5d+36cMazX1pxKXE8rvkSgudg Ghp/vATpItkpSpcDiCdRMLyhtq5HC13xoIWmc15OXxu+ZDJ5EjFfTHrpuNXBJhMsAd2JbE 0nGNDgMErA4Zi0m9zeVY6w5u1tkruoG8wVt8AR16xr+myv9CR6Zi+tc7xiKpYQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=07d108932ab5b5bc25221be4916ebf8874cd256f commit 07d108932ab5b5bc25221be4916ebf8874cd256f Author: Dmitry Chagin AuthorDate: 2022-05-09 18:16:31 +0000 Commit: Dmitry Chagin CommitDate: 2022-05-09 18:16:31 +0000 linux(4): Return native error from futex_atomic_op to avoid conversion by the caller. MFC after: 2 weeks --- sys/amd64/linux/linux_support.s | 2 +- sys/amd64/linux32/linux32_support.s | 2 +- sys/compat/linux/linux_futex.c | 31 +++++++++++++------------------ sys/i386/linux/linux_copyout.c | 10 +++++----- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/sys/amd64/linux/linux_support.s b/sys/amd64/linux/linux_support.s index 79e361867f1d..1e9ad45b9623 100644 --- a/sys/amd64/linux/linux_support.s +++ b/sys/amd64/linux/linux_support.s @@ -39,7 +39,7 @@ futex_fault: je 1f clac 1: movq $0,PCB_ONFAULT(%r8) - movl $-EFAULT,%eax + movl $EFAULT,%eax ret ENTRY(futex_xchgl_nosmap) diff --git a/sys/amd64/linux32/linux32_support.s b/sys/amd64/linux32/linux32_support.s index 2e2dbca4e24b..c92cb48e2d1a 100644 --- a/sys/amd64/linux32/linux32_support.s +++ b/sys/amd64/linux32/linux32_support.s @@ -39,7 +39,7 @@ futex_fault: je 1f clac 1: movq $0,PCB_ONFAULT(%r8) - movl $-EFAULT,%eax + movl $EFAULT,%eax ret ENTRY(futex_xchgl_nosmap) diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c index 1b4ef9e8efe8..2bcaabf2d972 100644 --- a/sys/compat/linux/linux_futex.c +++ b/sys/compat/linux/linux_futex.c @@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$"); #define GET_SHARED(a) (a->flags & FUTEX_SHARED) ? AUTO_SHARE : THREAD_SHARE -static int futex_atomic_op(struct thread *, int, uint32_t *); +static int futex_atomic_op(struct thread *, int, uint32_t *, int *); static int handle_futex_death(struct thread *td, struct linux_emuldata *, uint32_t *, unsigned int, bool); static int fetch_robust_entry(struct linux_robust_list **, @@ -130,7 +130,8 @@ futex_wake_pi(struct thread *td, uint32_t *uaddr, bool shared) } static int -futex_atomic_op(struct thread *td, int encoded_op, uint32_t *uaddr) +futex_atomic_op(struct thread *td, int encoded_op, uint32_t *uaddr, + int *res) { int op = (encoded_op >> 28) & 7; int cmp = (encoded_op >> 24) & 15; @@ -158,34 +159,34 @@ futex_atomic_op(struct thread *td, int encoded_op, uint32_t *uaddr) ret = futex_xorl(oparg, uaddr, &oldval); break; default: - ret = -ENOSYS; + ret = ENOSYS; break; } - if (ret) + if (ret != 0) return (ret); switch (cmp) { case FUTEX_OP_CMP_EQ: - ret = (oldval == cmparg); + *res = (oldval == cmparg); break; case FUTEX_OP_CMP_NE: - ret = (oldval != cmparg); + *res = (oldval != cmparg); break; case FUTEX_OP_CMP_LT: - ret = (oldval < cmparg); + *res = (oldval < cmparg); break; case FUTEX_OP_CMP_GE: - ret = (oldval >= cmparg); + *res = (oldval >= cmparg); break; case FUTEX_OP_CMP_LE: - ret = (oldval <= cmparg); + *res = (oldval <= cmparg); break; case FUTEX_OP_CMP_GT: - ret = (oldval > cmparg); + *res = (oldval > cmparg); break; default: - ret = -ENOSYS; + ret = ENOSYS; } return (ret); @@ -635,13 +636,7 @@ linux_futex_wakeop(struct thread *td, struct linux_futex_args *args) umtxq_lock(&key); umtxq_busy(&key); umtxq_unlock(&key); - op_ret = futex_atomic_op(td, args->val3, args->uaddr2); - if (op_ret < 0) { - if (op_ret == -ENOSYS) - error = ENOSYS; - else - error = EFAULT; - } + error = futex_atomic_op(td, args->val3, args->uaddr2, &op_ret); umtxq_lock(&key); umtxq_unbusy(&key); if (error != 0) diff --git a/sys/i386/linux/linux_copyout.c b/sys/i386/linux/linux_copyout.c index bf4c874c3cf2..6dc98bc8bf5d 100644 --- a/sys/i386/linux/linux_copyout.c +++ b/sys/i386/linux/linux_copyout.c @@ -72,7 +72,7 @@ futex_xchgl(int oparg, uint32_t *uaddr, int *oldval) st.oldval = oldval; if (cp_slow0((vm_offset_t)uaddr, sizeof(uint32_t), true, futex_xchgl_slow0, &st) != 0) - return (-EFAULT); + return (EFAULT); return (0); } @@ -94,7 +94,7 @@ futex_addl(int oparg, uint32_t *uaddr, int *oldval) st.oldval = oldval; if (cp_slow0((vm_offset_t)uaddr, sizeof(uint32_t), true, futex_addl_slow0, &st) != 0) - return (-EFAULT); + return (EFAULT); return (0); } @@ -120,7 +120,7 @@ futex_orl(int oparg, uint32_t *uaddr, int *oldval) st.oldval = oldval; if (cp_slow0((vm_offset_t)uaddr, sizeof(uint32_t), true, futex_orl_slow0, &st) != 0) - return (-EFAULT); + return (EFAULT); return (0); } @@ -146,7 +146,7 @@ futex_andl(int oparg, uint32_t *uaddr, int *oldval) st.oldval = oldval; if (cp_slow0((vm_offset_t)uaddr, sizeof(uint32_t), true, futex_andl_slow0, &st) != 0) - return (-EFAULT); + return (EFAULT); return (0); } @@ -172,6 +172,6 @@ futex_xorl(int oparg, uint32_t *uaddr, int *oldval) st.oldval = oldval; if (cp_slow0((vm_offset_t)uaddr, sizeof(uint32_t), true, futex_xorl_slow0, &st) != 0) - return (-EFAULT); + return (EFAULT); return (0); }