From patchwork Fri May 6 20:55:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikos Nikoleris X-Patchwork-Id: 12841608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E682C433EF for ; Fri, 6 May 2022 20:57:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444292AbiEFVBD (ORCPT ); Fri, 6 May 2022 17:01:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444282AbiEFVAy (ORCPT ); Fri, 6 May 2022 17:00:54 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BDCB46A068 for ; Fri, 6 May 2022 13:57:09 -0700 (PDT) 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 91BA1152B; Fri, 6 May 2022 13:57:09 -0700 (PDT) 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 BC40F3F800; Fri, 6 May 2022 13:57:08 -0700 (PDT) From: Nikos Nikoleris To: kvm@vger.kernel.org Cc: drjones@redhat.com, pbonzini@redhat.com, jade.alglave@arm.com, alexandru.elisei@arm.com Subject: [kvm-unit-tests PATCH v2 15/23] arm64: Add a new type of memory type flag MR_F_RESERVED Date: Fri, 6 May 2022 21:55:57 +0100 Message-Id: <20220506205605.359830-16-nikos.nikoleris@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220506205605.359830-1-nikos.nikoleris@arm.com> References: <20220506205605.359830-1-nikos.nikoleris@arm.com> MIME-Version: 1.0 X-ARM-No-Footer: FoSSMail Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 f0e70b1..64cd379 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 e1a72fe..931be98 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,