From nobody Tue Feb 10 05:46:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1584893766; cv=none; d=zohomail.com; s=zohoarc; b=AIg+htIswFQ+XFlBuL47fqMMWLSmV3Qod8NjExdjW1+gR4UMx4CrWZDqIArvRmP1tfuVsLNhtNpLuYrcY+MEzHRP1chcpK+IPeWCjJjYcvHRNr0LMNOqDJxKXGb+gOfEfyEib99ZGJxCUCJ8cswxKaQdD9RW2EnHF+ZIqrbN8ZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584893766; 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; bh=/aKfBCE3TkrNyM4hCY8xb4iTlJ+7uc0oNLJEEaCRRhk=; b=M1yX9QkP4qFARorvHMtEOGz0yoa8Ai9ertPpsDZxupv49VdoRBlc/5mRioQej/FzFvdC6aI//JfBbY3zvBCwkyG2CS67DojtuOi5S9PErDfDO2208SJQWps/UBpWMgnoKklStlYzphLc0wUoo0PI53AvbMNtGAS5MBxPRdpRufg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 15848937663301023.5495709476914; Sun, 22 Mar 2020 09:16:06 -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 1jG3FV-0004my-VG; Sun, 22 Mar 2020 16:14:53 +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 1jG3FU-0004lW-7p for xen-devel@lists.xenproject.org; Sun, 22 Mar 2020 16:14:52 +0000 Received: from mail-ed1-f66.google.com (unknown [209.85.208.66]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 3839efde-6c58-11ea-8134-12813bfff9fa; Sun, 22 Mar 2020 16:14:34 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id n25so12545557eds.10 for ; Sun, 22 Mar 2020 09:14:34 -0700 (PDT) Received: from ufe34d9ed68d054.ant.amazon.com (54-240-197-235.amazon.com. [54.240.197.235]) by smtp.gmail.com with ESMTPSA id v13sm106693edj.62.2020.03.22.09.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Mar 2020 09:14:33 -0700 (PDT) X-Inumbo-ID: 3839efde-6c58-11ea-8134-12813bfff9fa X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hRWWcaYfaNesHVQvECGOs6y6OntZoli0r5yhjgk5SFw=; b=cdtW2AHGb85Bgd2vCKI0EXe0EMTVJX4xWXoaiSl6Vuc2EcA+FX4McGjfn2Dj9tqx3T pm6XnH0NfG1l3Ra15j9WGcC4P6KP6vQS6tJ4A+ydtBmZI4sKjPQgXC1VQU9qBHdPTnsG RB/jZaKoPzwKrMs3lD2Xmc2/UweG5Zo61+ifs8WmdIhWTCihdWEjtzan84IaETwf0b6f jzQKZC/saecW5U7ZIxkcs5j+5MYmn16xF+Hnmpk3oXkBTgCRz8mt/qU97ixbnxZDL4qE o/EWIyz8UU84PfXjrzxmW1iN+02RLeieqTmNpmJiBK0wESemqxlXIk2Z8OPCJO2WFDix hO5A== X-Gm-Message-State: ANhLgQ2JCNVjGmsTUm1fmON7sWyPHWeyw82EjBeGXyFK4ooCfPL9NJdM Jbr6E+TP8wAXV29HlLLHaKu7MgA9TkNHyQ== X-Google-Smtp-Source: ADFU+vuig2Dh/4OhjxdWgKHpoUm3uk6qpNguyjyBCWRQ6EXvc0WoB+oz7RkrCNYZUJF2f8nx+dx+Sw== X-Received: by 2002:a17:906:7fd9:: with SMTP id r25mr4979523ejs.138.1584893673666; Sun, 22 Mar 2020 09:14:33 -0700 (PDT) From: julien@xen.org To: xen-devel@lists.xenproject.org Date: Sun, 22 Mar 2020 16:14:10 +0000 Message-Id: <20200322161418.31606-10-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200322161418.31606-1-julien@xen.org> References: <20200322161418.31606-1-julien@xen.org> Subject: [Xen-devel] [PATCH 09/17] xen/x86: Reduce the number of use of l*e_{from, get}_pfn() 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: julien@xen.org, Wei Liu , Andrew Cooper , Julien Grall , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= 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" From: Julien Grall It is preferable to use the typesafe l*e_{from, get}_mfn(). Sadly, this can't be used everywhere easily, so for now only replace the simple ones. No functional changes intended. Signed-off-by: Julien Grall Reviewed-by: Jan Beulich --- xen/arch/x86/machine_kexec.c | 2 +- xen/arch/x86/mm.c | 30 +++++++++++++++--------------- xen/arch/x86/setup.c | 2 +- xen/include/asm-x86/page.h | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/machine_kexec.c b/xen/arch/x86/machine_kexec.c index b70d5a6a86..b69c2e5fad 100644 --- a/xen/arch/x86/machine_kexec.c +++ b/xen/arch/x86/machine_kexec.c @@ -86,7 +86,7 @@ int machine_kexec_add_page(struct kexec_image *image, uns= igned long vaddr, =20 l1 =3D __map_domain_page(l1_page); l1 +=3D l1_table_offset(vaddr); - l1e_write(l1, l1e_from_pfn(maddr >> PAGE_SHIFT, __PAGE_HYPERVISOR)); + l1e_write(l1, l1e_from_mfn(maddr_to_mfn(maddr), __PAGE_HYPERVISOR)); =20 ret =3D 0; out: diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 65bc03984d..2516548e49 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1138,7 +1138,7 @@ static int get_page_from_l2e( l2_pgentry_t l2e, mfn_t l2mfn, struct domain *d, unsigned int flags) { - unsigned long mfn =3D l2e_get_pfn(l2e); + mfn_t mfn =3D l2e_get_mfn(l2e); int rc; =20 if ( unlikely((l2e_get_flags(l2e) & L2_DISALLOW_MASK)) ) @@ -1150,7 +1150,7 @@ get_page_from_l2e( =20 ASSERT(!(flags & PTF_preemptible)); =20 - rc =3D get_page_and_type_from_mfn(_mfn(mfn), PGT_l1_page_table, d, fla= gs); + rc =3D get_page_and_type_from_mfn(mfn, PGT_l1_page_table, d, flags); if ( unlikely(rc =3D=3D -EINVAL) && get_l2_linear_pagetable(l2e, l2mfn= , d) ) rc =3D 0; =20 @@ -1209,14 +1209,14 @@ static int _put_page_type(struct page_info *page, u= nsigned int flags, =20 void put_page_from_l1e(l1_pgentry_t l1e, struct domain *l1e_owner) { - unsigned long pfn =3D l1e_get_pfn(l1e); + mfn_t mfn =3D l1e_get_mfn(l1e); struct page_info *page; struct domain *pg_owner; =20 - if ( !(l1e_get_flags(l1e) & _PAGE_PRESENT) || is_iomem_page(_mfn(pfn))= ) + if ( !(l1e_get_flags(l1e) & _PAGE_PRESENT) || is_iomem_page(mfn) ) return; =20 - page =3D mfn_to_page(_mfn(pfn)); + page =3D mfn_to_page(mfn); pg_owner =3D page_get_owner(page); =20 /* @@ -5219,8 +5219,8 @@ int map_pages_to_xen( =20 for ( i =3D 0; i < L2_PAGETABLE_ENTRIES; i++ ) l2e_write(l2t + i, - l2e_from_pfn(l3e_get_pfn(ol3e) + - (i << PAGETABLE_ORDER), + l2e_from_mfn(mfn_add(l3e_get_mfn(ol3e), + (i << PAGETABLE_ORDER)), l3e_get_flags(ol3e))); =20 if ( l3e_get_flags(ol3e) & _PAGE_GLOBAL ) @@ -5320,7 +5320,7 @@ int map_pages_to_xen( =20 for ( i =3D 0; i < L1_PAGETABLE_ENTRIES; i++ ) l1e_write(&l1t[i], - l1e_from_pfn(l2e_get_pfn(*pl2e) + i, + l1e_from_mfn(mfn_add(l2e_get_mfn(*pl2e), i), lNf_to_l1f(l2e_get_flags(*pl2e)= ))); =20 if ( l2e_get_flags(*pl2e) & _PAGE_GLOBAL ) @@ -5391,7 +5391,7 @@ int map_pages_to_xen( l1t =3D l2e_to_l1e(ol2e); base_mfn =3D l1e_get_pfn(l1t[0]) & ~(L1_PAGETABLE_ENTRIES = - 1); for ( i =3D 0; i < L1_PAGETABLE_ENTRIES; i++ ) - if ( (l1e_get_pfn(l1t[i]) !=3D (base_mfn + i)) || + if ( !mfn_eq(l1e_get_mfn(l1t[i]), _mfn(base_mfn + i)) = || (l1e_get_flags(l1t[i]) !=3D flags) ) break; if ( i =3D=3D L1_PAGETABLE_ENTRIES ) @@ -5521,7 +5521,7 @@ int modify_xen_mappings(unsigned long s, unsigned lon= g e, unsigned int nf) { /* PAGE1GB: whole superpage is modified. */ l3_pgentry_t nl3e =3D !(nf & _PAGE_PRESENT) ? l3e_empty() - : l3e_from_pfn(l3e_get_pfn(*pl3e), + : l3e_from_mfn(l3e_get_mfn(*pl3e), (l3e_get_flags(*pl3e) & ~FLAGS_MASK) | = nf); =20 l3e_write_atomic(pl3e, nl3e); @@ -5535,8 +5535,8 @@ int modify_xen_mappings(unsigned long s, unsigned lon= g e, unsigned int nf) return -ENOMEM; for ( i =3D 0; i < L2_PAGETABLE_ENTRIES; i++ ) l2e_write(l2t + i, - l2e_from_pfn(l3e_get_pfn(*pl3e) + - (i << PAGETABLE_ORDER), + l2e_from_mfn(mfn_add(l3e_get_mfn(*pl3e), + (i << PAGETABLE_ORDER)), l3e_get_flags(*pl3e))); if ( locking ) spin_lock(&map_pgdir_lock); @@ -5576,7 +5576,7 @@ int modify_xen_mappings(unsigned long s, unsigned lon= g e, unsigned int nf) { /* PSE: whole superpage is modified. */ l2_pgentry_t nl2e =3D !(nf & _PAGE_PRESENT) ? l2e_empty() - : l2e_from_pfn(l2e_get_pfn(*pl2e), + : l2e_from_mfn(l2e_get_mfn(*pl2e), (l2e_get_flags(*pl2e) & ~FLAGS_MASK) | = nf); =20 l2e_write_atomic(pl2e, nl2e); @@ -5592,7 +5592,7 @@ int modify_xen_mappings(unsigned long s, unsigned lon= g e, unsigned int nf) return -ENOMEM; for ( i =3D 0; i < L1_PAGETABLE_ENTRIES; i++ ) l1e_write(&l1t[i], - l1e_from_pfn(l2e_get_pfn(*pl2e) + i, + l1e_from_mfn(mfn_add(l2e_get_mfn(*pl2e), i), l2e_get_flags(*pl2e) & ~_PAGE_P= SE)); if ( locking ) spin_lock(&map_pgdir_lock); @@ -5625,7 +5625,7 @@ int modify_xen_mappings(unsigned long s, unsigned lon= g e, unsigned int nf) ASSERT(!(nf & _PAGE_PRESENT)); =20 nl1e =3D !(nf & _PAGE_PRESENT) ? l1e_empty() - : l1e_from_pfn(l1e_get_pfn(*pl1e), + : l1e_from_mfn(l1e_get_mfn(*pl1e), (l1e_get_flags(*pl1e) & ~FLAGS_MASK) | nf); =20 l1e_write_atomic(pl1e, nl1e); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index cfe95c5dac..4d1d38dae3 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1147,7 +1147,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) BUG_ON(using_2M_mapping() && l2_table_offset((unsigned long)_erodata) =3D=3D l2_table_offset((unsigned long)_stext)); - *pl2e++ =3D l2e_from_pfn(xen_phys_start >> PAGE_SHIFT, + *pl2e++ =3D l2e_from_mfn(maddr_to_mfn(xen_phys_start), PAGE_HYPERVISOR_RX | _PAGE_PSE); for ( i =3D 1; i < L2_PAGETABLE_ENTRIES; i++, pl2e++ ) { diff --git a/xen/include/asm-x86/page.h b/xen/include/asm-x86/page.h index 377ba14f6e..8d581cd1e7 100644 --- a/xen/include/asm-x86/page.h +++ b/xen/include/asm-x86/page.h @@ -270,7 +270,7 @@ void copy_page_sse2(void *, const void *); #define pfn_to_paddr(pfn) __pfn_to_paddr(pfn) #define paddr_to_pfn(pa) __paddr_to_pfn(pa) #define paddr_to_pdx(pa) pfn_to_pdx(paddr_to_pfn(pa)) -#define vmap_to_mfn(va) _mfn(l1e_get_pfn(*virt_to_xen_l1e((unsigned lo= ng)(va)))) +#define vmap_to_mfn(va) l1e_get_mfn(*virt_to_xen_l1e((unsigned long)(v= a))) #define vmap_to_page(va) mfn_to_page(vmap_to_mfn(va)) =20 #endif /* !defined(__ASSEMBLY__) */ --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel