From nobody Thu Jun 12 09:49:36 2025 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 4bHyRj1kkSz5yVl7; Thu, 12 Jun 2025 09:49: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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bHyRh603dz3cdg; Thu, 12 Jun 2025 09:49:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1749721776; 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=2EBfwyZyd8vd0yKfO4q8e+X+ApMpBqZjMJ897hb3AAc=; b=RjTVcV2I1mGbmdWehRUJyhwe0h67CK5E68XzqCqcRfK7T1NOI5onBp3OQlwP+7TsG4O7zs uqUb0gjhoRsD6KYUXNMb0dye4GbqIdLueYDmcEMKReMk0SycS3MRHALuQwkHzMkSDDQyh+ Qb8XvHZFP6g3U3IF/1lmMFXObvPCmM94Wx1zpJqBQqwBTZicuvCBZwS4UT9bEeoShN3Luw HNvqHqeZwTZL8mB67AVxcggAU2NoMiS+NtyBiNJ71ZnJF8LzgYHcNJSlk7sgUOoKnvZK8D dHHH8L3mLnNics+inV+UPP84f9A6NUbtKOB8AVIioc2Bi+rlvuiszOSIwFcXFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1749721776; 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=2EBfwyZyd8vd0yKfO4q8e+X+ApMpBqZjMJ897hb3AAc=; b=kO1dP+vZKarlvlL3AOyAPiHGyhkgcGVCsfHBgWVKyPQJr/L0G1zCDYbnfJJrg74ld/aTNf Td9S7+9Dw9hFMyqN29Se79uYtlZhHOFyQWCjIaI2tMj2ES4pqIcEgG/nFp13siWJQBTrwo h5dre8c1hVWxGJYpkY15bG9Q07D945i2eHX74k+NID3TShVc3f/kpMADkdoWfNlT61LLpm eqGcNbxfse2xCxjPWugR16yBx4cBQ2oX4qYgnybtxbPSF3btxqI8428LW85YqfOnWqFMvW HoOaUACGvWz7CDhmSn6co+Zm4vNLqLn3QeqZJ0TiZVuqteI7KU6jpoIXfA6CSA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1749721776; a=rsa-sha256; cv=none; b=EbTtkuwLCBBVsD00RTZfvtt/o/Vv9UIBX6Z32UBT8UNPlA4kjqmyS1nqPdWAmtkUXBrEWn MfOhphNeLY7hbNf0eVi/BDlTnj7fpa+9oo+4MImXbhYIpOmCaBcLhuCA5/79zKPSzPGaM9 9CyilL3beIm8dM1q1rv4t1GdSr4oc4+gHze9c6w8n6EJgG9AEwvtwWXlnj40/fAWS2Ojv7 gbtgWk4NT68g1jRhh68cbDH/aj6zr6j+fhs+a7NJXeBTZJBXTY23pOKm2crgQ9Gui9V/2i RIVw2ZkHi7h9KX9ibrlZ/l+sPnTQWqvKf/HbC3Odl0L+f7KV2CtJFp0b0AVtoA== 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 4bHyRh5Hsyz15YR; Thu, 12 Jun 2025 09:49:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 55C9naWo029593; Thu, 12 Jun 2025 09:49:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 55C9naJ9029590; Thu, 12 Jun 2025 09:49:36 GMT (envelope-from git) Date: Thu, 12 Jun 2025 09:49:36 GMT Message-Id: <202506120949.55C9naJ9029590@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: e6928c33f60c - main - arm64: Reduce the kernel executable pages 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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: e6928c33f60c0a29a5e280840b038dfcbbbbce72 Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=e6928c33f60c0a29a5e280840b038dfcbbbbce72 commit e6928c33f60c0a29a5e280840b038dfcbbbbce72 Author: Andrew Turner AuthorDate: 2025-06-12 09:37:27 +0000 Commit: Andrew Turner CommitDate: 2025-06-12 09:48:57 +0000 arm64: Reduce the kernel executable pages When creating the kernel page tables we create them all executable to allow the kernel to boot. We can reduce the number of l2 blocks or l3 pages created as executable by looking where the end of the .text section is and only marking memory up to this as executable (rounded up to the block/page size). Memory after the .text is marked as execute never as it will be data. Reviewed by: alc Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D45063 --- sys/arm64/arm64/locore.S | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S index 1268d0d79193..fcc3f948f00c 100644 --- a/sys/arm64/arm64/locore.S +++ b/sys/arm64/arm64/locore.S @@ -598,7 +598,14 @@ common: #endif /* Get the number of blocks/pages to allocate, rounded down */ - lsr x10, x8, #(PTE_SHIFT) + lsr x14, x8, #(PTE_SHIFT) + + ldr x25, =etext + ldr x8, =((1 << PTE_SHIFT) - 1) + add x25, x25, x8 + mov x8, #(KERNBASE) + sub x25, x25, x8 + lsr x25, x25, #(PTE_SHIFT) /* Create the kernel space PTE table */ adrp x6, LL_PAGE_TABLE @@ -606,6 +613,16 @@ common: mov x7, #(ATTR_S1_IDX(VM_MEMATTR_WRITE_BACK)) mov x8, #(KERNBASE) mov x9, x28 + mov x10, x25 + bl BUILD_PTE_FUNC + + /* Create the kernel space XN PTE table */ + lsl x10, x25, #(PTE_SHIFT) + ldr x7, =(ATTR_S1_IDX(VM_MEMATTR_WRITE_BACK) | ATTR_S1_XN) + ldr x8, =(KERNBASE) + add x8, x8, x10 + add x9, x28, x10 + sub x10, x14, x25 bl BUILD_PTE_FUNC #undef PTE_SHIFT