From nobody Thu Mar 31 11:19:05 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 C6D871A3AB01; Thu, 31 Mar 2022 11:19: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 4KTgmT50mQz5593; Thu, 31 Mar 2022 11:19:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648725545; 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=FhsL5GgU7ZlDrxsVPtKX8EE3NoaOwJBkk+G3piBorig=; b=mjOsYYsG6lgez3SfK/ff8Oma0ARsyHhW0BoRxmQO2Rl2n4CFWC+d2hW+IlGkLcrRkgIoig zp9hNYo/UDcGfVeJsc5Id+qnrCn2z+LBBCI91IsiCsus0BPpHfYJXpo8TMHoTlero/oZbb D8+5y9VAmQybzhTVz0H5VGiH0AcTRyMJKrHHJnKxc5BtsZMupqW2UiO57iOQ3PIL14XYXA cGxdQkbrOXRffsDe67kuPqoJatrnTMFQi/KG+PZidSrz8i8q67v6sZRyXhUtqP3+UKlgVE f6B1B0iJEaYj73D8DzgfszShKF78Z3WfpAL2+Afok5pBqOEzwSoQbm/D9wBtlQ== 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 876402681E; Thu, 31 Mar 2022 11:19: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 22VBJ5Z5004310; Thu, 31 Mar 2022 11:19:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22VBJ5Ip004309; Thu, 31 Mar 2022 11:19:05 GMT (envelope-from git) Date: Thu, 31 Mar 2022 11:19:05 GMT Message-Id: <202203311119.22VBJ5Ip004309@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: 004da2d51f84 - stable/13 - Treat cache write as a read in arm64 data faults 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: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 004da2d51f8427745c0d1287781d5ba546b19000 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648725545; 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=FhsL5GgU7ZlDrxsVPtKX8EE3NoaOwJBkk+G3piBorig=; b=Qzu4MlshSR/YX6f57j7Llu1dCrVphHfarFbDoOn11tAQloHhrsZTPuqz7Jy+bEowwyt0U9 UWxpga01BHu/sXpsaaHuNtL6yGpmHBVV+I7QxktKBCFVNmYTtDTnICotIJ0ekpa1r4F2bt IAFAvw+vGxHIcNLxJYNFPB3EoNemtds6chGHJxbzaD9QivqGA9k4mheRr89eDbVufK3DVr o3ldLJ2b6bM5A3j0IsN5OeLi95OhmKWPzlgbQXOOx/POtXArn7s46b1Xf/pLq7SkCVpyzd OHbu9eCw0NNK2Ba1v85kegCdKTpcbrAliqm5Vnn2QhyKzYsFT+QpJzt+PvQU8A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648725545; a=rsa-sha256; cv=none; b=RxUw6aJq+MzmAoqvwQ9YOBWmXFBFl9yZVb0ZMji6P38BoYwkSwhtyyNx/L4AtAxAsvughw XqE0moBupVfSAGlFyNW8iXHHN7Imb3D2T64lLsAb3owlHGmMfLtX/ZtfOx8YUhyeVSgA55 3c8jGbbpCF28y3wD4/svaz9sb7aYd5FI+ucv0/rsYYTnoIQxU5MQLaNTNiMZTInkI7bkX/ XLWWHJCUxLAU3n15zM+d8P8MnJW7ERj9opH8yre9++ANPQm/Ruo++mWwfBNSYqFwMb/rAu Z1YCIOaRwgrYcOBd4p0zq02Caa/ikii0kPHht1owp79LObbKaJDECwDKyAwgCA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=004da2d51f8427745c0d1287781d5ba546b19000 commit 004da2d51f8427745c0d1287781d5ba546b19000 Author: Andrew Turner AuthorDate: 2022-03-26 15:59:34 +0000 Commit: Andrew Turner CommitDate: 2022-03-31 11:09:07 +0000 Treat cache write as a read in arm64 data faults On arm64 we can ask the hardware to perform cache operations from userspace. These require read permission however when the memory is unmapped the kernel will receive a write exception. Add a check to see if the cause of the exception is from the cache and pass a memory read fault type to the vm subsystem. PR: 262836 Reported by: dch Sponsored by: The FreeBSD Foundation (cherry picked from commit 029c1c4828aab451ba262cd4e2e1d9362cf18b76) --- sys/arm64/arm64/trap.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c index a8d29ffaa9a7..849f26ee8220 100644 --- a/sys/arm64/arm64/trap.c +++ b/sys/arm64/arm64/trap.c @@ -317,8 +317,16 @@ data_abort(struct thread *td, struct trapframe *frame, uint64_t esr, ftype = VM_PROT_EXECUTE; break; default: - ftype = (esr & ISS_DATA_WnR) == 0 ? VM_PROT_READ : - VM_PROT_WRITE; + /* + * If the exception was because of a read or cache operation + * pass a read fault type into the vm code. Cache operations + * need read permission but will set the WnR flag when the + * memory is unmapped. + */ + if ((esr & ISS_DATA_WnR) == 0 || (esr & ISS_DATA_CM) != 0) + ftype = VM_PROT_READ; + else + ftype = VM_PROT_WRITE; break; }