From nobody Mon Mar 28 09:11:02 2022 X-Original-To: dev-commits-src-main@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 D2A211A3F8B2; Mon, 28 Mar 2022 09:11:02 +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 4KRn465bZNz4rTc; Mon, 28 Mar 2022 09:11:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648458662; 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=h04+pCKhDlagX5p9J9MK9D3UFMOHzEkwf6JXYT/3bJk=; b=jQpKU/tHQEh9M9hQ00Ytqkg+IIhERQWDb3XL/Iy3PKqRcojpEtVpDv42Dx2I6EYnTlPPPw Zbj9mA4oHxr+l/rpCM7jdG/TC1eq2PwYh0hK8i2pldvj4L47Qy/rsclQzmaZeIA9okg2yQ YhF1MM0L/WrfVpM9KcLCYgpz5MhI+P8ZPobA1tCB4O3HXUEcOQZmYKYel2tltyMuzZ3UZP 4Lx8hhtUcGTkGJfG9Hhs3JH6/BJoPDrGF1rNrbjZy3xVY0vMtYXz3BbrA6lptEhbRHB63U EdBDwH2HU/zmeL4IbbbrmN7TrnY7odXqYl7HIZbJ9quqtUrJl5oqmxfyJv2ZSg== 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 9FAE426B46; Mon, 28 Mar 2022 09:11:02 +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 22S9B2N1083969; Mon, 28 Mar 2022 09:11:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22S9B29Y083968; Mon, 28 Mar 2022 09:11:02 GMT (envelope-from git) Date: Mon, 28 Mar 2022 09:11:02 GMT Message-Id: <202203280911.22S9B29Y083968@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 029c1c4828aa - main - Treat cache write as a read in arm64 data faults List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 029c1c4828aab451ba262cd4e2e1d9362cf18b76 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648458662; 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=h04+pCKhDlagX5p9J9MK9D3UFMOHzEkwf6JXYT/3bJk=; b=EC9Ho4sAlA5FSRyIIjAI7kzmLeGi+cOOtND/4wQG+FAjcCzVIFjF80hxlRcNDKfQ7MdzvS RvCDCr/VIxNC5ePzicuXayF0axPzegtUEh2wMG3aVZbM5Md6W8pwnu5YPpqN4mbzzJN6qA XbfCAvyDiCbf4fHlXUWbxnQDGehz/1CLb+rjw59z65jnkt9tYGBebhrqtRafoH74nk2cOp +yfKoLyOuHR1ucPu7NKSMhH6o+UtNJ4MPlTh5H+B8WUhtql2NaOdGxyVuFyZvdWp6Mi+tu hB8dIpu7pwSR4AnKcHugDNaIzYwTr3N4KfFiMGZ8pWryUVquMxmPV1ISmKYfzQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648458662; a=rsa-sha256; cv=none; b=nHGDDzQnz+FgH1TnwsDSvTx8P2+uRA9lTcNjYzM8cISwuyRbVbtjZ72InpC6JsxwyRLAoe vR99jL7JlR7a5Oq1QJQM7VafQbVJgP1ncPeD+d4hKBYAIBLud2MGQJXtd8I1B/8HKu1Uzb fu7/CGazRabpnz0z1VdsRNFW7MvJnITbow0YuykOSu80Gy5BYxGPW4uEb0cPhWIQzbEe+8 H2sJDUmoXRtBBRgGTDPslp8iYgTwJWm+A3Rwg1DWQSoV8a7jvADMeR1dtyt7VeeeT3AfsU fze0ETv20yb9H0vD7X0xX0Hqu7ycQXqDpW2O0GolIo667ThSBDjDRgZGym5FVA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=029c1c4828aab451ba262cd4e2e1d9362cf18b76 commit 029c1c4828aab451ba262cd4e2e1d9362cf18b76 Author: Andrew Turner AuthorDate: 2022-03-26 15:59:34 +0000 Commit: Andrew Turner CommitDate: 2022-03-28 09:10:15 +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 --- 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 fa921e39b844..226f69592952 100644 --- a/sys/arm64/arm64/trap.c +++ b/sys/arm64/arm64/trap.c @@ -318,8 +318,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; }