From nobody Wed Feb 15 16:43:05 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 4PH3m94bvlz3qXhn; Wed, 15 Feb 2023 16:43: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 4PH3m93y6jz3pGM; Wed, 15 Feb 2023 16:43:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676479385; 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=pof/scvlqavbP92QTgCBoLgpM6pu4jPkTLZq/eJk1+g=; b=ObaekqAKxHP7WgCJ0phIhwlSkMPqi0tyn00ejzYlWIVAXui6Kw60UMlodGCgJEARPt+LJU jE0Q842yar7U9UcCOiS9ivUtIA+L5o8H3TVCixJEfsuQWTezfIt5qWNoLqyvS4HSmYLFXy dCaBkb0xg8MgWpqJKX784bxXriERJ130ZM2i7O5xTUgynxjQ4XnfIfnRcIutbmLichSIvk 2kfJMgyhiTG1FrJpISNptr/57qtz8RXfNUsPx8LEj+/xPJeDzlolC7XdFjownnN6MQR2c6 cmyE/x8TuvyDRP/YoTQe5i8J/NDZmZnEYLxPjMKysS9PqWZaSL2wKGQm7FJhyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676479385; 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=pof/scvlqavbP92QTgCBoLgpM6pu4jPkTLZq/eJk1+g=; b=mxtQh0AlXxmRx5SsI5JhijWZmKonZXqgr8s7v9YPiv+yvRjVC6I2W34rUGXW0xclbHdqMH /Gd7XhCKILlbBzfCz/P1Y0nO7xAjKT8gS/GvKHOCbSSLFAN5GfhQHp2LZ8XBBDTlJXbTMl sEThhIqwb6rvJuCVEEDZ8vFDoDodgpdVut/oJBLVT+jmA6Rby/x2q2i6pxtH2cFIy/cAjH hcynYKnnsItfcG7MiVOCpfDo1eG2qAwu3rHxZclDjW/5cgFKvNNjTFvgyFtnG1dFuM54ZT a1ObWiJA16Tiqs0uoYdt98Hz3/B1dY89+MzWX5sdAvb5mCtT7YE4/S59YD4h7w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676479385; a=rsa-sha256; cv=none; b=TdKbT/Sf5ezhYZifXi5/LPtQwMp45vL78genhM1gkUFboXpNXKBNGQXw5txiW40I0Wm8Tg /Eb2dIy1e3ZTMPsZGZz/D7Oa07qjp/c8lMkMUI3cOrpW0I7BSUfkiaenbzyH+ZUYrjwFFe HpDuziyGbEfMkqVdbn83mUG25G0iRQx7ZHJxDzs031jJ/jQbFAIB0aFcqMhMv26szJ5ueu W8Uf52rMj695nG7dqSV8437L4Y6VjqXUS8Mk6hoVYVQigFLVbzbEu45f93eNQE6cWv9DI6 KeHc8wAC1H5ldzKfK5bIB4aC6M2BOCZeWPp0nuwi7QP4T0xK8E680t9fto8Lcg== 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 4PH3m932R1zWTF; Wed, 15 Feb 2023 16:43:05 +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 31FGh5gA002107; Wed, 15 Feb 2023 16:43:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31FGh54B002106; Wed, 15 Feb 2023 16:43:05 GMT (envelope-from git) Date: Wed, 15 Feb 2023 16:43:05 GMT Message-Id: <202302151643.31FGh54B002106@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 698af78e7809 - stable/13 - dtrace_asm.S: properly enter/exit user access 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: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 698af78e78093aed0b84f1e5d396e127ae13f52c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=698af78e78093aed0b84f1e5d396e127ae13f52c commit 698af78e78093aed0b84f1e5d396e127ae13f52c Author: Mitchell Horne AuthorDate: 2023-02-06 18:04:21 +0000 Commit: Mitchell Horne CommitDate: 2023-02-15 16:41:39 +0000 dtrace_asm.S: properly enter/exit user access In order to read or write userspace memory without generating an access fault, we must first enable the SUM bit in the sstatus CSR. Reviewed by: markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38298 (cherry picked from commit 0e563bde48b1af6bd472e940f04a8d76315749ab) --- sys/cddl/dev/dtrace/riscv/dtrace_asm.S | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sys/cddl/dev/dtrace/riscv/dtrace_asm.S b/sys/cddl/dev/dtrace/riscv/dtrace_asm.S index eeaf64061675..98c22a2aedfd 100644 --- a/sys/cddl/dev/dtrace/riscv/dtrace_asm.S +++ b/sys/cddl/dev/dtrace/riscv/dtrace_asm.S @@ -74,7 +74,9 @@ uint8_t dtrace_fuword8_nocheck(void *addr) */ ENTRY(dtrace_fuword8_nocheck) + ENTER_USER_ACCESS(t0) lb a0, 0(a0) + EXIT_USER_ACCESS(t0) RET END(dtrace_fuword8_nocheck) @@ -83,7 +85,9 @@ uint16_t dtrace_fuword16_nocheck(void *addr) */ ENTRY(dtrace_fuword16_nocheck) + ENTER_USER_ACCESS(t0) lh a0, 0(a0) + EXIT_USER_ACCESS(t0) RET END(dtrace_fuword16_nocheck) @@ -92,7 +96,9 @@ uint32_t dtrace_fuword32_nocheck(void *addr) */ ENTRY(dtrace_fuword32_nocheck) + ENTER_USER_ACCESS(t0) lw a0, 0(a0) + EXIT_USER_ACCESS(t0) RET END(dtrace_fuword32_nocheck) @@ -101,7 +107,9 @@ uint64_t dtrace_fuword64_nocheck(void *addr) */ ENTRY(dtrace_fuword64_nocheck) + ENTER_USER_ACCESS(t0) ld a0, 0(a0) + EXIT_USER_ACCESS(t0) RET END(dtrace_fuword64_nocheck) @@ -111,6 +119,7 @@ dtrace_copy(uintptr_t uaddr, uintptr_t kaddr, size_t size) */ ENTRY(dtrace_copy) beqz a2, 2f /* If len == 0 then skip loop */ + ENTER_USER_ACCESS(t0) 1: lb a4, 0(a0) /* Load from uaddr */ addi a0, a0, 1 @@ -118,6 +127,7 @@ ENTRY(dtrace_copy) addi a1, a1, 1 addi a2, a2, -1 /* len-- */ bnez a2, 1b + EXIT_USER_ACCESS(t0) 2: RET END(dtrace_copy) @@ -129,7 +139,9 @@ dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size, XXX: Check for flags? */ ENTRY(dtrace_copystr) - beqz a2, 2f /* If len == 0 then skip loop */ + beqz a2, 3f /* If len == 0 then skip loop */ + ENTER_USER_ACCESS(t0) +1: lb a4, 0(a0) /* Load from uaddr */ addi a0, a0, 1 sb a4, 0(a1) /* Store in kaddr */ @@ -138,6 +150,8 @@ ENTRY(dtrace_copystr) addi a2, a2, -1 /* len-- */ bnez a2, 1b 2: + EXIT_USER_ACCESS(t0) +3: RET END(dtrace_copystr)