From patchwork Mon Feb 18 11:35:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 158595 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2384481jaa; Mon, 18 Feb 2019 03:38:08 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ9b5z1DtpcjoO9B9QO7BLvtCbb3Dz8KbmSf3/7O49i+HLMbNYmYTD1t1whnY4omxEeUAKA X-Received: by 2002:a25:b9c1:: with SMTP id y1mr18270451ybj.57.1550489888481; Mon, 18 Feb 2019 03:38:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550489888; cv=none; d=google.com; s=arc-20160816; b=WG7KW0a+CmJHVQRlSFaPt0UkYwUZ4XX+MDq7d1yFm3rQA2m6L/EDYFR4E4y6WfEBLT H64g6/azV2AEh/BA8TuQXzZOgHIZjbHCHq/iUaJMwvikq5u/qs3tu7pRqpRy/WvPcXEz Nvtf314fjf9mU7tbgGGa+M8cNEs5l5zanjDIfrbaeLTW7+Hsj3zT4Ve+9tAx+HapUXl0 XXx6RS9zxYqy+CtR7mpbnEtarYhRIBskqaCpxOu5FNPxiqRh794l3g7K+LPem7QQxU86 9dMakOHtH3IqvAPJdPtnrTJQWjDPCis5AQXjYs1p/e3JvDkZkrAAAFbiRoYS09m9sMNz uXnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from; bh=R+k87lOV4Bu5m4XN2CM1ClsI2Mh1Jfh22kJT58FMd20=; b=g72Z+ijkVHDcQFcvnni47Wi9RCZrlrYJSIBAlK5YzCsNezr4XV6/z3cN4ekXhmgzkG iICguldHMKsVlMCOjiDaeMgfoj+b2Q8w5wosizlyNpol17ZXvTuBRcDse5sMECwsmGdW fDJmA9SKIxwvJx0/9p0DQaTXCAq3Xvd4u7AibaIhFy6U+g0oyckOK3DlTBs9iWAwxJtY ZsWlrDq4e0AEq0pug4Z54lXtBugv/aLSEkA2sqRzSXv0Ox8TmHqTwKiY6v4I5iviqZ0D OnlmpicWwbxtokIpKuGhwKvLW0nxXBhyKR2BWgBKBeNxYo2ghbxvBqOBI4zEVnamh2Ee xOoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@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.google.com with ESMTPS id u5si7457711ywd.303.2019.02.18.03.38.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Feb 2019 03:38:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gvhDj-00024b-Q7; Mon, 18 Feb 2019 11:36:23 +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 1gvhDi-00023l-MJ for xen-devel@lists.xenproject.org; Mon, 18 Feb 2019 11:36:22 +0000 X-Inumbo-ID: 6a321c94-3371-11e9-a898-0760cb0a41f5 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 6a321c94-3371-11e9-a898-0760cb0a41f5; Mon, 18 Feb 2019 11:36: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 94AEA1684; Mon, 18 Feb 2019 03:36:21 -0800 (PST) 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 801EF3F720; Mon, 18 Feb 2019 03:36:14 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 18 Feb 2019 11:35:56 +0000 Message-Id: <20190218113600.9540-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190218113600.9540-1-julien.grall@arm.com> References: <20190218113600.9540-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-next 5/9] 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: sstabellini@kernel.org, Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Convert online_page, offline_page and query_page_offline to use typesafe MFN. No functional changes. Signed-off-by: Julien Grall Acked-by: Jan Beulich --- 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/mcaction.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 @@ 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; @@ -22,7 +22,7 @@ mci_action_add_pageoffline(int bank, struct mc_info *mi, rec->mc_bank = bank; rec->action_types = MC_ACTION_PAGE_OFFLINE; - rec->action_info.page_retire.mfn = mfn; + rec->action_info.page_retire.mfn = mfn_x(mfn); rec->action_info.page_retire.status = status; return rec; } @@ -42,7 +42,8 @@ mc_memerr_dhandler(struct mca_binfo *binfo, struct mcinfo_bank *bank = binfo->mib; struct mcinfo_global *global = 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; } - mfn = bank->mc_addr >> PAGE_SHIFT; + mfn = 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; } @@ -89,10 +91,10 @@ mc_memerr_dhandler(struct mca_binfo *binfo, ASSERT(d); gfn = get_gpfn_from_mfn((bank->mc_addr) >> PAGE_SHIFT); - 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 failed\n", + mfn_x(mfn), d->domain_id); goto vmce_failed; } diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index f71d3bb7a1..5684a13557 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) } -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 = 0; struct domain *owner; struct page_info *pg; - 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 page out of range %"PRI_mfn"\n", mfn_x(mfn)); return -EINVAL; } *status = 0; - pg = mfn_to_page(_mfn(mfn)); + pg = mfn_to_page(mfn); - if ( is_xen_fixed_mfn(mfn) ) + if ( is_xen_fixed_mfn(mfn_x(mfn)) ) { *status = PG_OFFLINE_XENPAGE | PG_OFFLINE_FAILED | (DOMID_XEN << PG_OFFLINE_OWNER_SHIFT); @@ -1595,7 +1595,7 @@ int offline_page(unsigned long mfn, int broken, uint32_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 = PG_OFFLINE_FAILED | PG_OFFLINE_NOT_CONV_RAM; return -EINVAL; @@ -1677,19 +1677,19 @@ int offline_page(unsigned long mfn, int broken, uint32_t *status) * The caller should make sure end_pfn <= 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; - if ( !mfn_valid(_mfn(mfn)) ) + if ( !mfn_valid(mfn) ) { dprintk(XENLOG_WARNING, "call expand_pages() first\n"); return -EINVAL; } - pg = mfn_to_page(_mfn(mfn)); + pg = mfn_to_page(mfn); spin_lock(&heap_lock); @@ -1730,11 +1730,11 @@ unsigned int online_page(unsigned long mfn, uint32_t *status) return ret; } -int query_page_offline(unsigned long mfn, uint32_t *status) +int query_page_offline(mfn_t mfn, uint32_t *status) { struct page_info *pg; - if ( !mfn_valid(_mfn(mfn)) || !page_is_ram_type(mfn, RAM_TYPE_CONVENTIONAL) ) + if ( !mfn_valid(mfn) || !page_is_ram_type(mfn_x(mfn), RAM_TYPE_CONVENTIONAL) ) { dprintk(XENLOG_WARNING, "call expand_pages() first\n"); return -EINVAL; @@ -1743,7 +1743,7 @@ int query_page_offline(unsigned long mfn, uint32_t *status) *status = 0; spin_lock(&heap_lock); - pg = mfn_to_page(_mfn(mfn)); + pg = mfn_to_page(mfn); if ( page_state_is(pg, offlining) ) *status |= 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_sysctl) case XEN_SYSCTL_page_offline_op: { uint32_t *status, *ptr; - unsigned long pfn; + mfn_t mfn; ret = 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)); - for ( pfn = op->u.page_offline.start; - pfn <= op->u.page_offline.end; - pfn ++ ) + for ( mfn = _mfn(op->u.page_offline.start); + mfn_x(mfn) <= op->u.page_offline.end; + mfn = 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 = offline_page(pfn, 0, ptr++); + ret = offline_page(mfn, 0, ptr++); break; case sysctl_page_online: - ret = online_page(pfn, ptr++); + ret = online_page(mfn, ptr++); break; case sysctl_query_page_offline: - ret = query_page_offline(pfn, ptr++); + ret = query_page_offline(mfn, ptr++); break; default: ret = -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); void heap_init_late(void);