From nobody Tue Sep 27 12:56:12 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 4McKPV6XYMz4cwRD; Tue, 27 Sep 2022 12:56:14 +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 4McKPS6n1Cz3P3J; Tue, 27 Sep 2022 12:56:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664283372; 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=bLWDI6+7zLQYjqZggblM+h/XuQBb0JtRJpddsROp/WY=; b=t6xjzy4LGA0Y2pSTq5OgIRC/SZTt0CCTZ4yTmpKMT0aRWKfGKlfEotCxxUY7urccQe1hW+ +KkhkMN6kyMgOnfD4KCkpcgxQd/iuGx/TlNedxb9IshlYaV9NeecR9o8uA0EKprIIFS2q9 SxVWtdfjRrqL68eA/aQVT/WQgh0LLTYKDY/UDZYV/Nx33ZalK5uRSV7zlBpH5s5sWMkRQX sahIQLYidWAlkU1yB/5OGwAy4cNgyT64FxS20FrsO2AIQWn2O6AyT1/LWkSOzcbdQfSSBa ep+Xgo9asGFC7rbH+8VCXkaAXXkX4h4tVXKClDMBMgK2HbV8H3YydrinEj8oXw== 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 4McKPS5lH6z17DD; Tue, 27 Sep 2022 12:56:12 +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 28RCuC7e041365; Tue, 27 Sep 2022 12:56:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28RCuCDr041364; Tue, 27 Sep 2022 12:56:12 GMT (envelope-from git) Date: Tue, 27 Sep 2022 12:56:12 GMT Message-Id: <202209271256.28RCuCDr041364@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: 9404d22f0563 - main - Make the arm64 pmap bootstrap state global 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/main X-Git-Reftype: branch X-Git-Commit: 9404d22f0563f4c769a958b7ceccea0e28363a50 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664283372; 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=bLWDI6+7zLQYjqZggblM+h/XuQBb0JtRJpddsROp/WY=; b=BvUTKuePrkGU2WoukW6qvKGgY4tdu30+zx5as4jBKV5YFCSFQD9WhiNldX7TBei56m6aBE +gZ2zgPPlDiaSaE3knIRtM8aeCTF7mfR0x8ZjLYLGoqn+81PSGmgsTJRkKUduVegqYhoWC 4kLOw6zu81P2pjaPxORUdwfs/Ie9CkD8XbbTxSF8V5SqG2eHmsocTBLlMSAzKzvNpkx6TL v33KBsSxUo8pI4P1ugBjFIaDqqDukz5fb4reJqnMwO+VVeJt68xCndFHP7xBmGsad3q5YD 6ZtG+HLzK8BOowIH8xU5YUUvKSebGd8VUT9sm4SFvepckyWlws5Z28irP4ZotA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664283372; a=rsa-sha256; cv=none; b=Hpo4V797iEBTw7Iu/3E36bEa8VLrQuWuhUDyUz/dmu5fszGYX9qEY07BK/Cu9F0rogFuIa rrPm/i3eJU8bNU+ukE9+E2qJxgqX+8iiIg1ax0oyihwgVaHUksSNSzthE38jI2oxFqcRcN 75IAyBE913Mu1KFKvQ6dYBeT6qy3QOojWAIZ16m490mGe/n5ZxVqxbSRNxzZi5xXtNu6cW V+D9Z62IDgtUgbUeeFqBGBHhC/21X+8DdNuvMQ6x3Fbpm3bEl4ibCDElpIzZh+VzNfvcDl IqkAEFDWlmjvKLnmxlp4/5Xa4XF+ZEsy2OvOgp+ki3mOkqoQH74J+NvQXnfBxA== 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=9404d22f0563f4c769a958b7ceccea0e28363a50 commit 9404d22f0563f4c769a958b7ceccea0e28363a50 Author: Andrew Turner AuthorDate: 2022-09-26 12:24:50 +0000 Commit: Andrew Turner CommitDate: 2022-09-27 12:26:29 +0000 Make the arm64 pmap bootstrap state global So it can be reused by KASAN Sponsored by: The FreeBSD Foundation --- sys/arm64/arm64/pmap.c | 72 +++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index bcb6e24cf4b3..80d6caf33424 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -829,6 +829,16 @@ struct pmap_bootstrap_state { vm_offset_t freemempos; }; +/* The bootstrap state */ +static struct pmap_bootstrap_state bs_state = { + .l1 = NULL, + .l2 = NULL, + .l3 = NULL, + .l0_slot = L0_ENTRIES, + .l1_slot = Ln_ENTRIES, + .l2_slot = Ln_ENTRIES, +}; + static void pmap_bootstrap_l0_table(struct pmap_bootstrap_state *state) { @@ -1000,71 +1010,67 @@ static vm_offset_t pmap_bootstrap_dmap(vm_offset_t kern_l1, vm_paddr_t min_pa, vm_offset_t freemempos) { - struct pmap_bootstrap_state state; int i; dmap_phys_base = min_pa & ~L1_OFFSET; dmap_phys_max = 0; dmap_max_addr = 0; - state.l1 = state.l2 = state.l3 = NULL; - state.l0_slot = L0_ENTRIES; - state.l1_slot = Ln_ENTRIES; - state.l2_slot = Ln_ENTRIES; - state.freemempos = freemempos; + bs_state.freemempos = freemempos; for (i = 0; i < (physmap_idx * 2); i += 2) { - state.pa = physmap[i] & ~L3_OFFSET; - state.va = state.pa - dmap_phys_base + DMAP_MIN_ADDRESS; + bs_state.pa = physmap[i] & ~L3_OFFSET; + bs_state.va = bs_state.pa - dmap_phys_base + DMAP_MIN_ADDRESS; /* Create L3 mappings at the start of the region */ - if ((state.pa & L2_OFFSET) != 0) - pmap_bootstrap_l3_page(&state, i); - MPASS(state.pa <= physmap[i + 1]); + if ((bs_state.pa & L2_OFFSET) != 0) + pmap_bootstrap_l3_page(&bs_state, i); + MPASS(bs_state.pa <= physmap[i + 1]); if (L1_BLOCKS_SUPPORTED) { /* Create L2 mappings at the start of the region */ - if ((state.pa & L1_OFFSET) != 0) - pmap_bootstrap_l2_block(&state, i); - MPASS(state.pa <= physmap[i + 1]); + if ((bs_state.pa & L1_OFFSET) != 0) + pmap_bootstrap_l2_block(&bs_state, i); + MPASS(bs_state.pa <= physmap[i + 1]); /* Create the main L1 block mappings */ - for (; state.va < DMAP_MAX_ADDRESS && - (physmap[i + 1] - state.pa) >= L1_SIZE; - state.va += L1_SIZE, state.pa += L1_SIZE) { + for (; bs_state.va < DMAP_MAX_ADDRESS && + (physmap[i + 1] - bs_state.pa) >= L1_SIZE; + bs_state.va += L1_SIZE, bs_state.pa += L1_SIZE) { /* Make sure there is a valid L1 table */ - pmap_bootstrap_l0_table(&state); - MPASS((state.pa & L1_OFFSET) == 0); - pmap_store(&state.l1[pmap_l1_index(state.va)], - state.pa | ATTR_DEFAULT | ATTR_S1_XN | + pmap_bootstrap_l0_table(&bs_state); + MPASS((bs_state.pa & L1_OFFSET) == 0); + pmap_store( + &bs_state.l1[pmap_l1_index(bs_state.va)], + bs_state.pa | ATTR_DEFAULT | ATTR_S1_XN | ATTR_S1_IDX(VM_MEMATTR_WRITE_BACK) | L1_BLOCK); } - MPASS(state.pa <= physmap[i + 1]); + MPASS(bs_state.pa <= physmap[i + 1]); /* Create L2 mappings at the end of the region */ - pmap_bootstrap_l2_block(&state, i); + pmap_bootstrap_l2_block(&bs_state, i); } else { - while (state.va < DMAP_MAX_ADDRESS && - (physmap[i + 1] - state.pa) >= L2_SIZE) { - pmap_bootstrap_l2_block(&state, i); + while (bs_state.va < DMAP_MAX_ADDRESS && + (physmap[i + 1] - bs_state.pa) >= L2_SIZE) { + pmap_bootstrap_l2_block(&bs_state, i); } } - MPASS(state.pa <= physmap[i + 1]); + MPASS(bs_state.pa <= physmap[i + 1]); /* Create L3 mappings at the end of the region */ - pmap_bootstrap_l3_page(&state, i); - MPASS(state.pa == physmap[i + 1]); + pmap_bootstrap_l3_page(&bs_state, i); + MPASS(bs_state.pa == physmap[i + 1]); - if (state.pa > dmap_phys_max) { - dmap_phys_max = state.pa; - dmap_max_addr = state.va; + if (bs_state.pa > dmap_phys_max) { + dmap_phys_max = bs_state.pa; + dmap_max_addr = bs_state.va; } } cpu_tlb_flushID(); - return (state.freemempos); + return (bs_state.freemempos); } static vm_offset_t