From nobody Fri Apr 01 12:34:25 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 8C4371A3B170; Fri, 1 Apr 2022 12:34:25 +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 4KVKNx2brPz4Ygv; Fri, 1 Apr 2022 12:34:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648816465; 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=yGEdvEMSLpXDLKbH+eosgms5axSE//2y50walUWVfdg=; b=MZCK1AVsom5ILNqNbsqh38nk+C3ef+Mqr5Hp1zeZSTuDUFjaH1b47aDu0QqCeDcEumyIWh FcjCghUSU7c5CRv2LEhJcL0dQQ4e31foGXiLjKLQ+HN0x940o+e8cggQxUIaC7TcBaYXLU 4lWiG2rfNo3VVzxn6IgycANs1Y4+gRXsweUu5VJsFAYSXXaE/C35grqdvuV7KZY67Vyas0 MpepDwVfTz9qjlgxRFJu95UTuO7nUVUgtUcbcgZzE82Mz2VVJLEPw0E8UtCD3JlYgOm1XR Ti0nHShmFt8pBkHWFZHunFxDChN1U6ASiAbDJZya2zopErBH4DoH/orZaqLRvA== 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 39DC014255; Fri, 1 Apr 2022 12:34:25 +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 231CYPfX060375; Fri, 1 Apr 2022 12:34:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 231CYPF7060374; Fri, 1 Apr 2022 12:34:25 GMT (envelope-from git) Date: Fri, 1 Apr 2022 12:34:25 GMT Message-Id: <202204011234.231CYPF7060374@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: b57e32117576 - releng/13.1 - 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/releng/13.1 X-Git-Reftype: branch X-Git-Commit: b57e321175768358fcae767e2828e04e3ce7fa3d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648816465; 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=yGEdvEMSLpXDLKbH+eosgms5axSE//2y50walUWVfdg=; b=VYxv9o/UTk1/dmSt49VE1fiFOTNUDV77AZA9pV5hHhCfsKYFBCy47V+5wUjn6iAAQvAxNF tqgKHm2Oxu/4igXtAPtItFiGf0sm1yvfAZSs7fiRiY/24ZroqPAh62oh+K1HBpeTiJWuXQ nSujmfbH89VcCm2IaE7dw5uPRnJ9MIN+wso/alt1yeE9Bq3EXct24S4+k0aDUf87W/SzBs EW7sGxnfUTCnMNnMhl6Unb6eUicOBbZ1FblFBsnMEDNjYEzWiZ79eJlOv0JZJBxANVuieh Hf9KlgcrG+uIZwXyHMh2OuvXlxxmJCAzjLDgR5IXKefx5EiyIjNzKAcr3fAVhA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648816465; a=rsa-sha256; cv=none; b=hdGQIflMvwr+OTb9TCPqNT8ui3owaoUSVToCohKV0GEpCYA+tkodyORj69lVdynMCmXxIZ Dl3nz3nnvDKwudq9oFWJKdKR8bJ/Z7BDi2Pn3i/uVuUybqqrAyF6lWNt7bsnxmcTwiKRUI iJvL5+kpQ+RaeUDg8V7SvzRXirEdyTXX+ZdS5Y8KoT3dvt2KGb8mKmPF+GnSXOzpr1tAyH mh3UWaLPqFylelz6cFmJVEZYLIUI/qQX8OzJwMqqoZKJqs3std1/x40J3NJ0qhOmavL6HF VLfCUDZJEB7hTFMFcwBn2lKzxtHL9YvkZUnOp6/akk5uFbkP1tE7bQbxT+DFTg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch releng/13.1 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=b57e321175768358fcae767e2828e04e3ce7fa3d commit b57e321175768358fcae767e2828e04e3ce7fa3d Author: Andrew Turner AuthorDate: 2022-03-26 15:59:34 +0000 Commit: Andrew Turner CommitDate: 2022-04-01 11:15:08 +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 Approved by: re (gjb) Sponsored by: The FreeBSD Foundation (cherry picked from commit 029c1c4828aab451ba262cd4e2e1d9362cf18b76) (cherry picked from commit 004da2d51f8427745c0d1287781d5ba546b19000) --- 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; }