From nobody Wed Apr 24 08:27:55 2024 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=1557242205; cv=none; d=zoho.com; s=zohoarc; b=lKVOn9qeYsAfB9aZV6zC98yODJ13JvNeC04DGwljr1yRlDMDlT+0BBqQLetSXkNPQE7t79SNb1y3oRze4Rut5ONtUF8Eq9G0Cp5PwF2WdwxxZ+dkkBB2Q9oTwypnH3xTC/dD1M+i7LEHGpcK0a90qVgRexxEggaNIjIRSty03dY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557242205; 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=J0821RA/OnovgfPlzifASdxHCjoXlyuWc2dO2uxdjQQ=; b=Y8hY5MQtv5CHvgKG6s1pEZLCjxqdqg38MefCMdTWX0V9c9MJsB23fbpyY0/MPMKPqNuNP5RGG8PCBwKgZHpwe+p2e/vC5kLeJ8gfVr+/HyLNAtxK05zPHtHcBCWnyCf3OZgFHqPf7+XJTkQHTz8h1W9qZwWlIg4sGI49mMU7Wno= 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 1557242205140321.1012612742908; Tue, 7 May 2019 08:16:45 -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 1hO1oS-0007NQ-Ku; Tue, 07 May 2019 15:15:24 +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 1hO1oR-0007Mn-5r for xen-devel@lists.xenproject.org; Tue, 07 May 2019 15:15:23 +0000 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id ee0e99ec-70da-11e9-9df6-03527982748a; Tue, 07 May 2019 15:15: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 E073A1682; Tue, 7 May 2019 08:15: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 CC56B3F5AF; Tue, 7 May 2019 08:15:18 -0700 (PDT) X-Inumbo-ID: ee0e99ec-70da-11e9-9df6-03527982748a From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 7 May 2019 16:14:50 +0100 Message-Id: <20190507151458.29350-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190507151458.29350-1-julien.grall@arm.com> References: <20190507151458.29350-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 06/14] xen: Convert hotplug page function to use typesafe MFN 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: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , 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" Convert online_page, offline_page and query_page_offline to use typesafe MFN. Note, for clarity, the words have been re-ordered in the error message updated by this patch. No functional changes. Signed-off-by: Julien Grall Acked-by: Jan Beulich --- Changes: - Update error message - Add Jan's acked-by --- xen/arch/x86/cpu/mcheck/mcaction.c | 18 ++++++++++-------- xen/common/page_alloc.c | 24 ++++++++++++------------ xen/common/sysctl.c | 14 +++++++------- xen/include/xen/mm.h | 6 +++--- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/xen/arch/x86/cpu/mcheck/mcaction.c b/xen/arch/x86/cpu/mcheck/m= caction.c index e42267414e..69332fb84d 100644 --- a/xen/arch/x86/cpu/mcheck/mcaction.c +++ b/xen/arch/x86/cpu/mcheck/mcaction.c @@ -6,7 +6,7 @@ =20 static struct mcinfo_recovery * mci_action_add_pageoffline(int bank, struct mc_info *mi, - uint64_t mfn, uint32_t status) + mfn_t mfn, uint32_t status) { struct mcinfo_recovery *rec; =20 @@ -22,7 +22,7 @@ mci_action_add_pageoffline(int bank, struct mc_info *mi, =20 rec->mc_bank =3D bank; rec->action_types =3D MC_ACTION_PAGE_OFFLINE; - rec->action_info.page_retire.mfn =3D mfn; + rec->action_info.page_retire.mfn =3D mfn_x(mfn); rec->action_info.page_retire.status =3D status; return rec; } @@ -42,7 +42,8 @@ mc_memerr_dhandler(struct mca_binfo *binfo, struct mcinfo_bank *bank =3D binfo->mib; struct mcinfo_global *global =3D binfo->mig; struct domain *d; - unsigned long mfn, gfn; + mfn_t mfn; + unsigned long gfn; uint32_t status; int vmce_vcpuid; unsigned int mc_vcpuid; @@ -54,11 +55,12 @@ mc_memerr_dhandler(struct mca_binfo *binfo, return; } =20 - mfn =3D bank->mc_addr >> PAGE_SHIFT; + mfn =3D maddr_to_mfn(bank->mc_addr); if ( offline_page(mfn, 1, &status) ) { dprintk(XENLOG_WARNING, - "Failed to offline page %lx for MCE error\n", mfn); + "Failed to offline page %"PRI_mfn" for MCE error\n", + mfn_x(mfn)); return; } =20 @@ -89,10 +91,10 @@ mc_memerr_dhandler(struct mca_binfo *binfo, ASSERT(d); gfn =3D get_gpfn_from_mfn((bank->mc_addr) >> PAGE_SHIFT); =20 - if ( unmmap_broken_page(d, _mfn(mfn), gfn) ) + if ( unmmap_broken_page(d, mfn, gfn) ) { - printk("Unmap broken memory %lx for DOM%d failed\n", - mfn, d->domain_id); + printk("Unmap broken memory %"PRI_mfn" for DOM%d faile= d\n", + mfn_x(mfn), d->domain_id); goto vmce_failed; } =20 diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index be44158033..f445f7daec 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1568,23 +1568,23 @@ static int reserve_heap_page(struct page_info *pg) =20 } =20 -int offline_page(unsigned long mfn, int broken, uint32_t *status) +int offline_page(mfn_t mfn, int broken, uint32_t *status) { unsigned long old_info =3D 0; struct domain *owner; struct page_info *pg; =20 - if ( !mfn_valid(_mfn(mfn)) ) + if ( !mfn_valid(mfn) ) { dprintk(XENLOG_WARNING, - "try to offline page out of range %lx\n", mfn); + "try to offline out of range page %"PRI_mfn"\n", mfn_x(mfn= )); return -EINVAL; } =20 *status =3D 0; - pg =3D mfn_to_page(_mfn(mfn)); + pg =3D mfn_to_page(mfn); =20 - if ( is_xen_fixed_mfn(mfn) ) + if ( is_xen_fixed_mfn(mfn_x(mfn)) ) { *status =3D PG_OFFLINE_XENPAGE | PG_OFFLINE_FAILED | (DOMID_XEN << PG_OFFLINE_OWNER_SHIFT); @@ -1595,7 +1595,7 @@ int offline_page(unsigned long mfn, int broken, uint3= 2_t *status) * N.B. xen's txt in x86_64 is marked reserved and handled already. * Also kexec range is reserved. */ - if ( !page_is_ram_type(mfn, RAM_TYPE_CONVENTIONAL) ) + if ( !page_is_ram_type(mfn_x(mfn), RAM_TYPE_CONVENTIONAL) ) { *status =3D PG_OFFLINE_FAILED | PG_OFFLINE_NOT_CONV_RAM; return -EINVAL; @@ -1677,19 +1677,19 @@ int offline_page(unsigned long mfn, int broken, uin= t32_t *status) * The caller should make sure end_pfn <=3D max_page, * if not, expand_pages() should be called prior to online_page(). */ -unsigned int online_page(unsigned long mfn, uint32_t *status) +unsigned int online_page(mfn_t mfn, uint32_t *status) { unsigned long x, nx, y; struct page_info *pg; int ret; =20 - if ( !mfn_valid(_mfn(mfn)) ) + if ( !mfn_valid(mfn) ) { dprintk(XENLOG_WARNING, "call expand_pages() first\n"); return -EINVAL; } =20 - pg =3D mfn_to_page(_mfn(mfn)); + pg =3D mfn_to_page(mfn); =20 spin_lock(&heap_lock); =20 @@ -1730,11 +1730,11 @@ unsigned int online_page(unsigned long mfn, uint32_= t *status) return ret; } =20 -int query_page_offline(unsigned long mfn, uint32_t *status) +int query_page_offline(mfn_t mfn, uint32_t *status) { struct page_info *pg; =20 - if ( !mfn_valid(_mfn(mfn)) || !page_is_ram_type(mfn, RAM_TYPE_CONVENTI= ONAL) ) + if ( !mfn_valid(mfn) || !page_is_ram_type(mfn_x(mfn), RAM_TYPE_CONVENT= IONAL) ) { dprintk(XENLOG_WARNING, "call expand_pages() first\n"); return -EINVAL; @@ -1743,7 +1743,7 @@ int query_page_offline(unsigned long mfn, uint32_t *s= tatus) *status =3D 0; spin_lock(&heap_lock); =20 - pg =3D mfn_to_page(_mfn(mfn)); + pg =3D mfn_to_page(mfn); =20 if ( page_state_is(pg, offlining) ) *status |=3D PG_OFFLINE_STATUS_OFFLINE_PENDING; diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index c0aa6bde4e..ab161793e5 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -186,7 +186,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_s= ysctl) case XEN_SYSCTL_page_offline_op: { uint32_t *status, *ptr; - unsigned long pfn; + mfn_t mfn; =20 ret =3D xsm_page_offline(XSM_HOOK, op->u.page_offline.cmd); if ( ret ) @@ -205,21 +205,21 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u= _sysctl) memset(status, PG_OFFLINE_INVALID, sizeof(uint32_t) * (op->u.page_offline.end - op->u.page_offline.start += 1)); =20 - for ( pfn =3D op->u.page_offline.start; - pfn <=3D op->u.page_offline.end; - pfn ++ ) + for ( mfn =3D _mfn(op->u.page_offline.start); + mfn_x(mfn) <=3D op->u.page_offline.end; + mfn =3D mfn_add(mfn, 1) ) { switch ( op->u.page_offline.cmd ) { /* Shall revert her if failed, or leave caller do it? */ case sysctl_page_offline: - ret =3D offline_page(pfn, 0, ptr++); + ret =3D offline_page(mfn, 0, ptr++); break; case sysctl_page_online: - ret =3D online_page(pfn, ptr++); + ret =3D online_page(mfn, ptr++); break; case sysctl_query_page_offline: - ret =3D query_page_offline(pfn, ptr++); + ret =3D query_page_offline(mfn, ptr++); break; default: ret =3D -EINVAL; diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index e971147234..3ba7168cc9 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -206,9 +206,9 @@ unsigned long avail_domheap_pages(void); unsigned long avail_node_heap_pages(unsigned int); #define alloc_domheap_page(d,f) (alloc_domheap_pages(d,0,f)) #define free_domheap_page(p) (free_domheap_pages(p,0)) -unsigned int online_page(unsigned long mfn, uint32_t *status); -int offline_page(unsigned long mfn, int broken, uint32_t *status); -int query_page_offline(unsigned long mfn, uint32_t *status); +unsigned int online_page(mfn_t mfn, uint32_t *status); +int offline_page(mfn_t mfn, int broken, uint32_t *status); +int query_page_offline(mfn_t mfn, uint32_t *status); unsigned long total_free_pages(void); =20 void heap_init_late(void); --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel