From patchwork Fri Sep 8 17:11:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 9944697 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 952AA6035D for ; Fri, 8 Sep 2017 17:15:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7ABBB2885D for ; Fri, 8 Sep 2017 17:15:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CBA82885F; Fri, 8 Sep 2017 17:15:04 +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 9D88A2885D for ; Fri, 8 Sep 2017 17:15:03 +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 1dqMoc-0003h4-B2; Fri, 08 Sep 2017 17:11:38 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqMoa-0003gy-GG for xen-devel@lists.xen.org; Fri, 08 Sep 2017 17:11:36 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id F0/A2-03093-74FC2B95; Fri, 08 Sep 2017 17:11:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHIsWRWlGSWpSXmKPExsWyU9JRQtf9/KZ Igx0T+SyWfFzM4sDocXT3b6YAxijWzLyk/IoE1ox/e5vZCuZxVfy42cHewLiUo4uRk0NCwE/i 5YylTCA2i4CKxMkF3exdjBwcbAL2EtO/VoCERQQMJN5fn8QGYjMLlEi83b+UEcQWFlCSmHtnF lgrr4CnxOpZ+8FqhARsJea8XwoVF5Q4OfMJC0SvjsSC3Z/YQMYzC0hLLP8HdgGngJ3E8g0fWU FsUZALVq5hghijKNE/7wEbxJXpEhOf9bBMYOSfhWTqLCRTZyFMXcDIvIpRozi1qCy1SNfIVC+ pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTIzD8GIBgB+OqBYGHGCU5mJREeWV6NkUK 8SXlp1RmJBZnxBeV5qQWH2LU4OAQ2Lx29QVGKZa8/LxUJQlennNAdYJFqempFWmZOcAIgSmV4 OBREuHdchYozVtckJhbnJkOkTrFqMvxY9KVP0xCYDOkxHn9QGYIgBRllObBjYBF6yVGWSlhXk agA4V4ClKLcjNLUOVfMYpzMCoJ8waCTOHJzCuB2/QK6AgmoCNKnm8AOaIkESEl1cAYsWWCSPU 094AjD/aGb+O5O/POp93qxcscXwfvtVWr+bSyQl0o8bSzykvBL9nTLBcYF9V+fVuV0h3D+0Ag Oermb2W5sjVbpOZGp957tiP8R7+MXeXBjEhHnp6LDKevGN3v0yk8m1h9ntHiZCrnUhvLFatq+ me13fjyTXLNtcVWy2btfv1xafMZJZbijERDLeai4kQAxJM6TdECAAA= X-Env-Sender: prvs=417750147=roger.pau@citrix.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1504890694!75252597!1 X-Originating-IP: [185.25.65.24] X-SpamReason: No, hits=0.0 required=7.0 tests=received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 750 invoked from network); 8 Sep 2017 17:11:35 -0000 Received: from smtp.ctxuk.citrix.com (HELO SMTP.EU.CITRIX.COM) (185.25.65.24) by server-14.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 8 Sep 2017 17:11:35 -0000 X-IronPort-AV: E=Sophos;i="5.42,362,1500940800"; d="scan'208";a="52516474" Date: Fri, 8 Sep 2017 18:11:00 +0100 From: Roger Pau =?iso-8859-1?Q?Monn=E9?= To: Boris Ostrovsky Message-ID: <20170908171100.mvoa5zrw24csbbbb@dhcp-3-128.uk.xensource.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170714 (1.8.3) X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) Cc: Andrew Cooper , Jan Beulich , xen-devel Subject: Re: [Xen-devel] PVH dom0 memory setup 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Sep 08, 2017 at 10:56:33AM -0400, Boris Ostrovsky wrote: > I am slightly confused by the use of 'need_paging' variable in > dom0_compute_nr_pages(). > > Because paging_mode_hap() and iommu_hap_pt_share are (almost?) always > true, we are not reducing available memory for PVH dom0 by page tables > size. But then in pvh_setup_p2m() we do use this memory by > paging_set_allocation(). And from what I've seen we then may run our of > heap pages when populating memory map (in the 'for' loop below). > > Am I not reading this correctly? Yes, I think you are reading this correctly. dom0_compute_nr_pages should set need_paging if the domain type is hvm AFAICT, because hap also consumes memory for it's page tables. Do you have a reliable way to trigger this? I was thinking of a fix along the lines of: ---8<--- diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index f616b99ddc..424192a7c4 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -263,8 +263,7 @@ unsigned long __init dom0_compute_nr_pages( avail -= max_pdx >> s; } - need_paging = is_hvm_domain(d) && - (!iommu_hap_pt_share || !paging_mode_hap(d)); + need_paging = is_hvm_domain(d); for ( ; ; need_paging = false ) { nr_pages = dom0_nrpages;