From nobody Thu Feb 08 16:36:36 2024 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 4TW2gT0477z5B0jr; Thu, 8 Feb 2024 16:36:37 +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 4TW2gS3l9gz4N2F; Thu, 8 Feb 2024 16:36:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707410196; 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=0bKEGp1M+Ggyv6omUDxcw4T6rSEIEBdDjUTO/ydpnGM=; b=LEaVe2jg6TurqesrhOlRrfI4zO+iLjO5mWxHskDDRqYfLJhLpj5HnJkTmpuYDJKCBJTj9K 5vhOfELRp74+lZ5C3F+C33GewPBH0/ywBKEHreTxX9OMPeNYEcctYsq9sCqCLQp8kRihBk WG+PYCT4I70m+3imbd2DP4YtM+ovWViI9or4jyun41ztdGejERFOt1+in3LCwS/I4Ixt44 O3A7ZL1ut7cs1qA7AUkoUfZv03UEHPUq414DiJs+MNEApRRHjmPKrNB88Dej4kfE41Tq6t KMi0ceXtPS0VlrZufhB01zFmM56X1Y86iznxAGDxSFYBxdWPTLYdjoqcPSgnaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707410196; 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=0bKEGp1M+Ggyv6omUDxcw4T6rSEIEBdDjUTO/ydpnGM=; b=iw4PuQ/j1S2jrigLas40L9mOPibu8EtogcnmvrEZLOztaqOETXKaY7GBKIGHhSCW2007nJ B9o+TGFUvaad7OgH3f6LfA8OUyvDHc64eLqBDZTBHHXAJYtPOebw2tyVhhx5Ik8oFo1txC /oA2iU+BF/kvofYgy/eN5EAp5SwdIpjwAkTDb6CU1ba6aQbYkcaF8lLX/wHmulAFv1D0u/ Ccucu303qdhP2qhcwT6D+x/a3zSWk+18XHPhS5Xx3KALLn0v98e11tq+ZRxh8Wn9hfCL1a Cn+3vlcjdhUa+fY5zNK7urTcXAO9NMD1twgcbvtCeYyaKTVNCPJrAoSO+c9MDQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707410196; a=rsa-sha256; cv=none; b=C4FkIW9k76fOOKAMYnXfat80lZ2H3S4m5P61kHfBQrX0DRdZtkH/C367/LZGdMa4O4T4el fXgzq1g0plcX+fKbTf8qdBFDgeu5cG1JdKUFP5eokeAPnnhkQvi5hJgUwvAGk/6d1sQnrG +dlpYaIFzO2TUsLr4M6loVnqan/AKGo07BtIyidduAAX2BiugdthRr8arMGrvXjJ91wco0 JXgLdYSOjMhAhUjGDzHwgPosNwMiUqtewZk/XcCJkty9yM7usynlSjWQGVlZ9OReat8Yh6 DXdshI4aP+HI0yRyZw5And5USubLpkGBxdKiUp/yHUImQxczSn3/FMRGdbQ59g== 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 4TW2gS2sHJzwtT; Thu, 8 Feb 2024 16:36:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 418GaaJ8020876; Thu, 8 Feb 2024 16:36:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 418GaaV4020873; Thu, 8 Feb 2024 16:36:36 GMT (envelope-from git) Date: Thu, 8 Feb 2024 16:36:36 GMT Message-Id: <202402081636.418GaaV4020873@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 01bb9a2a3557 - main - arm64: Disable kernel superpage promotion when KMSAN is configured 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 01bb9a2a3557bc9389f628d301cd691e08266f1d Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=01bb9a2a3557bc9389f628d301cd691e08266f1d commit 01bb9a2a3557bc9389f628d301cd691e08266f1d Author: Mark Johnston AuthorDate: 2024-02-08 16:02:48 +0000 Commit: Mark Johnston CommitDate: 2024-02-08 16:35:11 +0000 arm64: Disable kernel superpage promotion when KMSAN is configured The break-before-make operation required to promote or demote a superpage leaves a window where the KMSAN runtime can trigger a fatal data abort. More specifically, the code in pmap_update_entry() which executes after ATTR_DESCR_VALID is cleared may implicitly attempt to access KMSAN context via curthread, but we may be promoting or demoting a 2MB page containing the curthread structure. Reviewed by: imp Sponsored by: Klara, Inc. Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D43158 --- sys/arm64/arm64/pmap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index 7c7a9a08fd30..6a84b6bb80f8 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -728,6 +728,18 @@ pmap_ps_enabled(pmap_t pmap) if (pmap->pm_stage != PM_STAGE1) return (false); +#ifdef KMSAN + /* + * The break-before-make in pmap_update_entry() results in a situation + * where a CPU may call into the KMSAN runtime while the entry is + * invalid. If the entry is used to map the current thread structure, + * then the runtime will attempt to access unmapped memory. Avoid this + * by simply disabling superpage promotion for the kernel map. + */ + if (pmap == kernel_pmap) + return (false); +#endif + return (superpages_enabled != 0); }