From nobody Mon Feb 9 23:04:01 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1556125302; cv=none; d=zoho.com; s=zohoarc; b=iapQR35idooWDsD4ELOeiDBOzPdO2z4vwAFiodzTtzLxdJw3iwGrV2OClOdrni9aruTcb42qC0KwPo8/DBwHoKn8fxf18B+mMMwmGnHo6yVAZQS2qXGmf4Kryq4IqpSNoCHF+tBWRKTUwuQUMF/1blp4NCpT3FuUUv+pIPb9eto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556125302; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=NlbK9HPyMEbbgtBdlomy8/Y3Jhvfacl6cJjNdD5yKCw=; b=hRvsQCnHZ4xi133SzgwMqVwW23HnsayaTYjvQbkIoZyF2VUEp7atBdeoMEt54ufn5xb8lKHWO+pV8QcZZ/F+1NV9JLR97vpCg0sU+s3FfDZZQwVJq4L049ZC+fblx9O1sjJ3DY6DkcwLzSvvokaDdkrGFkajwvyIJwm6ew9IGLI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556125302570642.7635508890686; Wed, 24 Apr 2019 10:01:42 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hJLFu-0007qw-Ma; Wed, 24 Apr 2019 17:00:22 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hJLFu-0007qV-22 for xen-devel@lists.xenproject.org; Wed, 24 Apr 2019 17:00:22 +0000 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 71db77c8-66b2-11e9-9fa8-dfc6e70f8e3d; Wed, 24 Apr 2019 17:00:21 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F1477374; Wed, 24 Apr 2019 10:00:20 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D6D073F557; Wed, 24 Apr 2019 10:00:19 -0700 (PDT) X-Inumbo-ID: 71db77c8-66b2-11e9-9fa8-dfc6e70f8e3d From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 24 Apr 2019 17:59:55 +0100 Message-Id: <20190424165955.23718-13-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190424165955.23718-1-julien.grall@arm.com> References: <20190424165955.23718-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 12/12] xen/arm: mm: Remove set_pte_flags_on_range() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Oleksandr_Tyshchenko@epam.com, Julien Grall , sstabellini@kernel.org, Andrii_Anisov@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" set_pte_flags_on_range() is yet another function that will open-code update to a specific range in the Xen page-tables. It can be completely dropped by using either modify_xen_mappings() or destroy_xen_mappings(). Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov --- xen/arch/arm/mm.c | 58 ++++++++++-----------------------------------------= ---- 1 file changed, 10 insertions(+), 48 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 7e6df9f877..5810d569ee 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1272,52 +1272,6 @@ int modify_xen_mappings(unsigned long s, unsigned lo= ng e, unsigned int flags) return xen_pt_update(s, INVALID_MFN, (e - s) >> PAGE_SHIFT, flags); } =20 -enum mg { mg_clear, mg_ro, mg_rw, mg_rx }; -static void set_pte_flags_on_range(const char *p, unsigned long l, enum mg= mg) -{ - lpae_t pte; - int i; - - ASSERT(is_kernel(p) && is_kernel(p + l)); - - /* Can only guard in page granularity */ - ASSERT(!((unsigned long) p & ~PAGE_MASK)); - ASSERT(!(l & ~PAGE_MASK)); - - for ( i =3D (p - _start) / PAGE_SIZE;=20 - i < (p + l - _start) / PAGE_SIZE;=20 - i++ ) - { - pte =3D xen_xenmap[i]; - switch ( mg ) - { - case mg_clear: - pte.pt.valid =3D 0; - break; - case mg_ro: - pte.pt.valid =3D 1; - pte.pt.pxn =3D 1; - pte.pt.xn =3D 1; - pte.pt.ro =3D 1; - break; - case mg_rw: - pte.pt.valid =3D 1; - pte.pt.pxn =3D 1; - pte.pt.xn =3D 1; - pte.pt.ro =3D 0; - break; - case mg_rx: - pte.pt.valid =3D 1; - pte.pt.pxn =3D 0; - pte.pt.xn =3D 0; - pte.pt.ro =3D 1; - break; - } - write_pte(xen_xenmap + i, pte); - } - flush_xen_tlb_local(); -} - /* Release all __init and __initdata ranges to be reused */ void free_init_memory(void) { @@ -1326,8 +1280,12 @@ void free_init_memory(void) uint32_t insn; unsigned int i, nr =3D len / sizeof(insn); uint32_t *p; + int rc; =20 - set_pte_flags_on_range(__init_begin, len, mg_rw); + rc =3D modify_xen_mappings((unsigned long)__init_begin, + (unsigned long)__init_end, PAGE_HYPERVISOR_RW= ); + if ( rc ) + panic("Unable to map RW the init section (rc =3D %d)", rc); =20 /* * From now on, init will not be used for execution anymore, @@ -1345,7 +1303,11 @@ void free_init_memory(void) for ( i =3D 0; i < nr; i++ ) *(p + i) =3D insn; =20 - set_pte_flags_on_range(__init_begin, len, mg_clear); + rc =3D destroy_xen_mappings((unsigned long)__init_begin, + (unsigned long)__init_end); + if ( rc ) + panic("Unable to remove the init section (rc =3D %d)", rc); + init_domheap_pages(pa, pa + len); printk("Freed %ldkB init memory.\n", (long)(__init_end-__init_begin)>>= 10); } --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel