From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D5B02572 for ; Mon, 13 Feb 2023 10:18:30 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D6F211E8D; Mon, 13 Feb 2023 02:19:12 -0800 (PST) Received: from godel.lab.cambridge.arm.com (godel.lab.cambridge.arm.com [10.7.66.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4853F3F703; Mon, 13 Feb 2023 02:18:29 -0800 (PST) From: Nikos Nikoleris To: kvm@vger.kernel.org, kvmarm@lists.linux.dev, andrew.jones@linux.dev Cc: Andrew Jones , pbonzini@redhat.com, alexandru.elisei@arm.com, ricarkol@google.com Subject: [PATCH v4 22/30] arm64: Add a new type of memory type flag MR_F_RESERVED Date: Mon, 13 Feb 2023 10:17:51 +0000 Message-Id: <20230213101759.2577077-23-nikos.nikoleris@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230213101759.2577077-1-nikos.nikoleris@arm.com> References: <20230213101759.2577077-1-nikos.nikoleris@arm.com> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ARM-No-Footer: FoSSMail Content-Transfer-Encoding: 8bit From: Andrew Jones This will be used by future change to add PTE entries for special EFI memory regions. Signed-off-by: Nikos Nikoleris Reviewed-by: Ricardo Koller --- lib/arm/asm/setup.h | 1 + lib/arm/mmu.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/arm/asm/setup.h b/lib/arm/asm/setup.h index f0e70b11..64cd379b 100644 --- a/lib/arm/asm/setup.h +++ b/lib/arm/asm/setup.h @@ -15,6 +15,7 @@ extern int nr_cpus; #define MR_F_IO (1U << 0) #define MR_F_CODE (1U << 1) +#define MR_F_RESERVED (1U << 2) #define MR_F_UNKNOWN (1U << 31) struct mem_region { diff --git a/lib/arm/mmu.c b/lib/arm/mmu.c index e1a72fe4..931be985 100644 --- a/lib/arm/mmu.c +++ b/lib/arm/mmu.c @@ -174,6 +174,10 @@ void *setup_mmu(phys_addr_t phys_end, void *unused) for (r = mem_regions; r->end; ++r) { if (r->flags & MR_F_IO) { continue; + } else if (r->flags & MR_F_RESERVED) { + /* Reserved pages need to be writable for whatever reserved them */ + mmu_set_range_ptes(mmu_idmap, r->start, r->start, r->end, + __pgprot(PTE_WBWA)); } else if (r->flags & MR_F_CODE) { /* armv8 requires code shared between EL1 and EL0 to be read-only */ mmu_set_range_ptes(mmu_idmap, r->start, r->start, r->end, -- 2.25.1