From nobody Wed Dec 8 11:27:27 2021 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 045A818DCA23; Wed, 8 Dec 2021 11:27:28 +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 4J8FJH5DPlz3HLs; Wed, 8 Dec 2021 11:27:27 +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 93F7D1282C; Wed, 8 Dec 2021 11:27:27 +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 1B8BRRnn025077; Wed, 8 Dec 2021 11:27:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B8BRRbC025076; Wed, 8 Dec 2021 11:27:27 GMT (envelope-from git) Date: Wed, 8 Dec 2021 11:27:27 GMT Message-Id: <202112081127.1B8BRRbC025076@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: 8d0b41b05879 - main - Handle table attributes in the arm64 kernel map 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: 8d0b41b058795dcb0270ca0abcbf92289563c3ed Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638962847; 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=tFd+H9LlWwwpZpPOw3Rb4zI18JA8AS2GxIyavstnC0Y=; b=MCII1d6amhuPOGYkQScoGkUGMGe0f/1V4+8p2gTsHY2wjNF1cJQMs+MgqUkZaBJhRWx9As 56dqW0UEf+//IZpxAuzGN4awlUNQg+yMbSpkUjQn6LUuGadCkzl2CB8nkGfxXCBeoS6T/f l1WnUcZYN3VrawS0IkMgi7JTcadJhducpLlZUsxb4w7mfMyaOPrE5Z8+l+0KTAY1U44No5 I4C6Hg5LsryNdFUagITbzEqdF9+HZzod9LcH3eSuGhTuB1JtwAy34lP4sioHgvpZ2nOC9B OdyKlwEICZ7v6o3Sh1tjJMTslWNBWfnL/cf+PkyEbuIRpJKkNeYAlul8LTWzVA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638962847; a=rsa-sha256; cv=none; b=usp3qemH0kpx57R0nW8ga6lhorg92/SKA/VwpnN0n8L6O49mdZloq0fM2VK7KGzDyolymN /kkl4c2rUyVsC7X7K7SzwxEeLzuzAJLE9xuD6XQq9nnxm8aCCgjkTQnMhu6IgBNX2W/gXn zV/PsPi59KWJF+mnHLYLqZjOffqF0ESg6mNM+PftGJzcBXO7ECRFxMbZdzgYZaSiTki7xW FxqgkVK6B+7gKgHbV1lm5Egm8pYQooKuwTVU+jFGHCGBDYxm0ornojGJvQHCFLKGuhFiV3 aIel8cC6owJ/nxZMZ0+atu92vE9d1fIPkuSZjlAPXFFKqkmjwtsNZ/I36mwEpA== 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=8d0b41b058795dcb0270ca0abcbf92289563c3ed commit 8d0b41b058795dcb0270ca0abcbf92289563c3ed Author: Andrew Turner AuthorDate: 2021-12-07 14:23:13 +0000 Commit: Andrew Turner CommitDate: 2021-12-08 11:22:17 +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 --- 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 a877c0c033f5..e732afc7e350 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -7034,6 +7034,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 @@ -7046,15 +7070,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);