From patchwork Mon Oct 10 00:32:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9368769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7B796608A6 for ; Mon, 10 Oct 2016 00:35:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DDB527F89 for ; Mon, 10 Oct 2016 00:35:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F025284A5; Mon, 10 Oct 2016 00:35:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9138028B1B for ; Mon, 10 Oct 2016 00:35:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btOX5-0004Zx-IJ; Mon, 10 Oct 2016 00:33:31 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btOX4-0004ZY-3B for xen-devel@lists.xen.org; Mon, 10 Oct 2016 00:33:30 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id CB/7A-12967-9D1EAF75; Mon, 10 Oct 2016 00:33:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRWlGSWpSXmKPExsXS1tYhr3vj4a9 wgy23FSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oz1F88xFlwRreifsoelgfGQQBcjB4eQQKVE 03OrLkZODgkBXokjy2awQtj+El8u3mfvYuQCKulllNiy5gkLSIJNQF9ixeODYEUiAtIS1z5fZ gQpYha4xyhx5f8rsCJhgQSJ13efs4PYLAKqEnPOLQVr4BWwkeg5MIsJYoO8xIWrp8DqOQVsJb btXAlmCwHV3JzRxzqBkXcBI8MqRo3i1KKy1CJdQwO9pKLM9IyS3MTMHCDPWC83tbg4MT01JzG pWC85P3cTIzAc6hkYGHcwbutyPsQoycGkJMqbeOJHuBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ XucHv8KFBItS01Mr0jJzgIEJk5bg4FES4V0HkuYtLkjMLc5Mh0idYlSUEufNAUkIgCQySvPg2 mDRcIlRVkqYl5GBgUGIpyC1KDezBFX+FaM4B6OSMG83yBSezLwSuOmvgBYzAS1mWfwDZHFJIk JKqoHRwP9spHn9KwfGTP4DoSFBFRNWnmtOOWeasTMser3A/PWpizyXXqnfPNHX8hI3k5qEq8J bqZpM6er5Sat/OG7LafrF1a0TW5u0cmm5kvunXpunBfdLzt3xOXW38Idqe8E0lqa6PoWSr297 pE8b3Xh2X4fj0/lToU2bfqSwmE74uraofO3B7oNKLMUZiYZazEXFiQBKLWQCgQIAAA== X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1476059606!9755180!1 X-Originating-IP: [134.134.136.31] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1609 invoked from network); 10 Oct 2016 00:33:28 -0000 Received: from mga06.intel.com (HELO mga06.intel.com) (134.134.136.31) by server-9.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 10 Oct 2016 00:33:28 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP; 09 Oct 2016 17:33:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,469,1473145200"; d="scan'208";a="178161116" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.148]) by fmsmga004.fm.intel.com with ESMTP; 09 Oct 2016 17:33:24 -0700 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Mon, 10 Oct 2016 08:32:21 +0800 Message-Id: <20161010003235.4213-3-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161010003235.4213-1-haozhong.zhang@intel.com> References: <20161010003235.4213-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Andrew Cooper , Xiao Guangrong , Jan Beulich Subject: [Xen-devel] [RFC XEN PATCH 02/16] x86_64/mm: explicitly specify the location to place the M2P table X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP A reserved area on each pmem region is used to place the M2P table. However, it's not at the beginning of the pmem region, so we need to specify the location explicitly when creating the M2P table. Signed-off-by: Haozhong Zhang --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/x86_64/mm.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 33f226a..5c0f527 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -317,7 +317,8 @@ void destroy_m2p_mapping(struct mem_hotadd_info *info) * spfn/epfn: the pfn ranges to be setup * free_s/free_e: the pfn ranges that is free still */ -static int setup_compat_m2p_table(struct mem_hotadd_info *info) +static int setup_compat_m2p_table(struct mem_hotadd_info *info, + struct mem_hotadd_info *alloc_info) { unsigned long i, va, smap, emap, rwva, epfn = info->epfn, mfn; unsigned int n; @@ -371,7 +372,7 @@ static int setup_compat_m2p_table(struct mem_hotadd_info *info) if ( n == CNT ) continue; - mfn = alloc_hotadd_mfn(info); + mfn = alloc_hotadd_mfn(alloc_info); err = map_pages_to_xen(rwva, mfn, 1UL << PAGETABLE_ORDER, PAGE_HYPERVISOR); if ( err ) @@ -391,7 +392,8 @@ static int setup_compat_m2p_table(struct mem_hotadd_info *info) * Allocate and map the machine-to-phys table. * The L3 for RO/RWRW MPT and the L2 for compatible MPT should be setup already */ -static int setup_m2p_table(struct mem_hotadd_info *info) +static int setup_m2p_table(struct mem_hotadd_info *info, + struct mem_hotadd_info *alloc_info) { unsigned long i, va, smap, emap; unsigned int n; @@ -440,7 +442,7 @@ static int setup_m2p_table(struct mem_hotadd_info *info) break; if ( n < CNT ) { - unsigned long mfn = alloc_hotadd_mfn(info); + unsigned long mfn = alloc_hotadd_mfn(alloc_info); ret = map_pages_to_xen( RDWR_MPT_VIRT_START + i * sizeof(unsigned long), @@ -485,7 +487,7 @@ static int setup_m2p_table(struct mem_hotadd_info *info) #undef CNT #undef MFN - ret = setup_compat_m2p_table(info); + ret = setup_compat_m2p_table(info, alloc_info); error: return ret; } @@ -1427,7 +1429,7 @@ int memory_add(unsigned long spfn, unsigned long epfn, unsigned int pxm) total_pages += epfn - spfn; set_pdx_range(spfn, epfn); - ret = setup_m2p_table(&info); + ret = setup_m2p_table(&info, &info); if ( ret ) goto destroy_m2p;