From nobody Wed Dec 29 10:39:52 2021 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 B8E021927C55; Wed, 29 Dec 2021 10:39:52 +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 4JP7Fh2DJZz4ply; Wed, 29 Dec 2021 10:39:52 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2E07E2369B; Wed, 29 Dec 2021 10:39:52 +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 1BTAdqiO087532; Wed, 29 Dec 2021 10:39:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BTAdqeJ087531; Wed, 29 Dec 2021 10:39:52 GMT (envelope-from git) Date: Wed, 29 Dec 2021 10:39:52 GMT Message-Id: <202112291039.1BTAdqeJ087531@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: 886190fa267e - stable/13 - Handle table attributes in the arm64 kernel map 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: 886190fa267ecae634481982efd4a85688b7e6fe Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640774392; 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=tTK63Kr3FIwKD95iDuLYrXZyNlI41EoJ58goEltoVpk=; b=iYSnfQooYOerVDPJqyqolzCzKdbq5YO6wMmCoyavumwzVyNEAMMdNVfxJQwKolfRGgMYfD hslgulz1PZoAp0Da8rZGeG/mw7+CYFiEZQsotPyjo+OmiUH0iTcsqTSJFg2p6YN/OMNmYD X6OCzcuUzgANpRHbz+mS2T+ziHxEnATTCsAKV6sHxIQSJQW1WCrvdiuJnr3A9HVWNtu82r 4HqevYHYA62NFzxo0qXho0dYt0cs6ZeR5q9B9pq4eZUnTlf0X4Wc94YpY6bQ6cFiZIOc+p NojaKtnTGzRsTHT/4YcOFedEnQlwb2TDvNkV/WJNydAkGNTs7Ox6D4YfjcM9Ew== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640774392; a=rsa-sha256; cv=none; b=tFEk85nm/xmvOhsrwfCeEq31gQBHFsikX73kpvLwaVHXl0j5+w6VvvmHikhCWdPbbXN7yL IxLzm1RX7mGlFPlXVAHC7JCQxw5Vs8yqwy6jZAnCusjJgVoWQsNVsvmG+UjNABotATsKGy 1AulLh3Qbvm1GrcMiKQa/EieQ36iQzOKp9NSdEZGaVR96Ktul5cdVVTKpofrN+mYeuelK/ GlvOE+R7I+yEv7FUdeYGs5+3tvnlrelbbY6WftC1gTXRRnpF6J4Vbc2rISdMCk5N0xfGd3 u0m0yC7sEoa4R5sTTV0DAmwDoFDBiM6WjRbmKnZfPxjKmMSQAN4HMyJPJyOaYA== 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=886190fa267ecae634481982efd4a85688b7e6fe commit 886190fa267ecae634481982efd4a85688b7e6fe Author: Andrew Turner AuthorDate: 2021-12-07 14:23:13 +0000 Commit: Andrew Turner CommitDate: 2021-12-29 10:05:59 +0000 Handle table attributes in the arm64 kernel map When getting the arm64 kernel maps sysctl we should look at the table attributes as well as the block/page attributes. These attributes are different to the last level attributes so need to be translated. The previous code assumed the table and block/page attributes are identical, however this is not the case. Handle the difference by extracting the code into new helper functions & calling them as needed based on the entry type being checked. Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33321 (cherry picked from commit 8d0b41b058795dcb0270ca0abcbf92289563c3ed) --- sys/arm64/arm64/pmap.c | 47 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index 17e76c0d5a41..d4cebf6a8956 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -7215,6 +7215,30 @@ sysctl_kmaps_reinit(struct pmap_kernel_map_range *range, vm_offset_t va, range->attrs = attrs; } +/* Get the block/page attributes that correspond to the table attributes */ +static pt_entry_t +sysctl_kmaps_table_attrs(pd_entry_t table) +{ + pt_entry_t attrs; + + attrs = 0; + if ((table & TATTR_UXN_TABLE) != 0) + attrs |= ATTR_S1_UXN; + if ((table & TATTR_PXN_TABLE) != 0) + attrs |= ATTR_S1_PXN; + if ((table & TATTR_AP_TABLE_RO) != 0) + attrs |= ATTR_S1_AP(ATTR_S1_AP_RO); + + return (attrs); +} + +/* Read the block/page attributes we care about */ +static pt_entry_t +sysctl_kmaps_block_attrs(pt_entry_t block) +{ + return (block & (ATTR_S1_AP_MASK | ATTR_S1_XN | ATTR_S1_IDX_MASK)); +} + /* * Given a leaf PTE, derive the mapping's attributes. If they do not match * those of the current run, dump the address range and its attributes, and @@ -7227,15 +7251,22 @@ sysctl_kmaps_check(struct sbuf *sb, struct pmap_kernel_map_range *range, { pt_entry_t attrs; - attrs = l0e & (ATTR_S1_AP_MASK | ATTR_S1_XN); - attrs |= l1e & (ATTR_S1_AP_MASK | ATTR_S1_XN); - if ((l1e & ATTR_DESCR_MASK) == L1_BLOCK) - attrs |= l1e & ATTR_S1_IDX_MASK; - attrs |= l2e & (ATTR_S1_AP_MASK | ATTR_S1_XN); - if ((l2e & ATTR_DESCR_MASK) == L2_BLOCK) - attrs |= l2e & ATTR_S1_IDX_MASK; - attrs |= l3e & (ATTR_S1_AP_MASK | ATTR_S1_XN | ATTR_S1_IDX_MASK); + attrs = sysctl_kmaps_table_attrs(l0e); + + if ((l1e & ATTR_DESCR_TYPE_MASK) == ATTR_DESCR_TYPE_BLOCK) { + attrs |= sysctl_kmaps_block_attrs(l1e); + goto done; + } + attrs |= sysctl_kmaps_table_attrs(l1e); + + if ((l2e & ATTR_DESCR_TYPE_MASK) == ATTR_DESCR_TYPE_BLOCK) { + attrs |= sysctl_kmaps_block_attrs(l2e); + goto done; + } + attrs |= sysctl_kmaps_table_attrs(l2e); + attrs |= sysctl_kmaps_block_attrs(l3e); +done: if (range->sva > va || !sysctl_kmaps_match(range, attrs)) { sysctl_kmaps_dump(sb, range, va); sysctl_kmaps_reinit(range, va, attrs);