From patchwork Wed Nov 1 14:50:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 10036451 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 0AFF76032D for ; Wed, 1 Nov 2017 14:52:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D845B28BB0 for ; Wed, 1 Nov 2017 14:52:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC6D028BFE; Wed, 1 Nov 2017 14:52:57 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID 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 6151828BB0 for ; Wed, 1 Nov 2017 14:52:56 +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 1e9uLa-00040S-Hu; Wed, 01 Nov 2017 14:50:26 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e9uLZ-00040M-LG for xen-devel@lists.xen.org; Wed, 01 Nov 2017 14:50:25 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id CD/0D-13910-03FD9F95; Wed, 01 Nov 2017 14:50:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMIsWRWlGSWpSXmKPExsVyMbThkK7B/Z+ RBrcXiVks+biYxYHR4+ju30wBjFGsmXlJ+RUJrBkfPhxhLjjLV3Hpyi7WBsYF3F2MXBxCAhMZ JSb8XsbWxcjJwSLQzixx830iSEJC4B2LxJZ195lAEhICeRLfF65jg7DTJH7/PsEMYZdJXL96l KWLkQNokprEmjdREEN7mSQ6b5wGi7MJ6Eism1ELUi4iIC1x7fNlRpAws0CFxOo9WSBhYYFoic 6Hd5kgTlCV2Pn5OAuIzStgLfGrvxnqAnmJXW0XWScw8i9gZFjFqFGcWlSWWqRrbKSXVJSZnlG Sm5iZo2toYKaXm1pcnJiempOYVKyXnJ+7iREYPAxAsIPx9LrAQ4ySHExKorw7Hb9HCvEl5adU ZiQWZ8QXleakFh9ilOHgUJLgPXTvZ6SQYFFqempFWmYOMIxh0hIcPEoivBkgad7igsTc4sx0i NQpRnuOC3cu/WHiOLDnFpDsuHkXSD6b+bqBWYglLz8vVUqctxekTQCkLaM0D24oLO4uMcpKCf MyAp0pxFOQWpSbWYIq/4pRnINRSZh3H8gUnsy8Erjdr4DOYgI6y0viB8hZJYkIKakGxq0G4tE cmZfv1+ToruncL17estSNpfXcVEvP13s3ayb/E7zQ/O2nxLotrilPO1fVyb+Iv171OMl4qrm0 2e+Nzqdr5RxXPZ365RX/9IhTJmyfuKQ1b209zXh5QZxU7D7viKJvW4/rZcr/3nT92KffqZZG9 /pNdV5MLzF3mrxeK/yuUKqxPEPveyWW4oxEQy3mouJEABb/zgS2AgAA X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-13.tower-27.messagelabs.com!1509547824!104925594!1 X-Originating-IP: [209.85.128.194] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7626 invoked from network); 1 Nov 2017 14:50:24 -0000 Received: from mail-wr0-f194.google.com (HELO mail-wr0-f194.google.com) (209.85.128.194) by server-13.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Nov 2017 14:50:24 -0000 Received: by mail-wr0-f194.google.com with SMTP id k62so2144809wrc.9 for ; Wed, 01 Nov 2017 07:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=JYewdK6MuOW3pjkkl6dpMLTuPnBuIdBRExWGt2sW05Q=; b=Ux3hcg6jx+1L9affQJL1gJZCKSZjWjhZQ44Zj6YboL/F4Q1OoTjCRG2CXFrjc4aJ9h r2hseYX8dK16ytoheMbnpe8b7DtVtVoo9kETT+FeuEiifhGN1aGk823pS6K+N20BZ65M 3U9TsVns9z2EgMcyrRKFejdUaCIPYyWtnVwTE= 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; bh=JYewdK6MuOW3pjkkl6dpMLTuPnBuIdBRExWGt2sW05Q=; b=gD/VJvbZpWz5b6cF8rR5+k3rtB5kgG/2fdvsVKGhQyNke7t6CZ2WSaD3DoWnDNlTi2 DsSSl32hNICV71rfv3k/xNhSR8i/ee58XPoxva3S7rk6gkMLsnviV1atDXoC3RPo94TJ i8rtX5ZmbVUW40wiER648hJxt0w3vBvUfOWL/WcpDhq5CC3tdvbYU1qzwHKlw/YmIcsc wWky4v0klgFzwQh1997Jkp2UYvyfQPnSZEJwIk6ZX0b1aH0E95pBkSND77o7IO5nHgWo /Alo+Mp0X8aV8rLutUEj90t55ZbspoMSl2dr+9W8LBJmzqAbA0kOMDgkJAlM8CRN7h0P wB5w== X-Gm-Message-State: AMCzsaUQiBDbToDI4h4hKVwzXWl7b4PA2ifj4CXfDniJggmZh3ogVJh1 zv9gh0V3cXudibdIqW3boj977SJmCjI= X-Google-Smtp-Source: ABhQp+Tfq09xwwbmyhyxA/QHgnzNh4szpdwzpQn3WbqcesF3n9nYQd5uVCsdRSJMdvAg7MBTaXq+uA== X-Received: by 10.223.146.37 with SMTP id 34mr62528wrj.79.1509547823689; Wed, 01 Nov 2017 07:50:23 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id d195sm471128wmd.30.2017.11.01.07.50.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Nov 2017 07:50:23 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 1 Nov 2017 14:50:20 +0000 Message-Id: <20171101145020.6881-1-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 Cc: George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, Julien Grall , jbeulich@suse.com Subject: [Xen-devel] [PATCH for-4.10] xen/x86: p2m-pod: Prevent infinite loop when shattering 1GB pages 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 The PoD subsystem only have pool of 4KB and 2MB pages. When it comes accross a 1GB mapping, it will be splitted in 2MB one using p2m_set_entry and request the caller to retry (see ept_get_entry for instance). p2m_set_entry may fail to shatter if it is not possible to allocate memory for the new page table. However, the error is not progated resulting to the callers to retry infinitely the PoD. Prevent the infinite loop by return false when it is not possible to shatter the 1GB mapping. Signed-off-by: Julien Grall --- This is a potential candidate to backport and for Xen 4.10. Without it, there a potential for infinite loop if the memory is exhausted. --- xen/arch/x86/mm/p2m-pod.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 0a811ccf28..69269a0bd1 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -1103,6 +1103,8 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, */ if ( order == PAGE_ORDER_1G ) { + int rc; + pod_unlock(p2m); /* * Note that we are supposed to call p2m_set_entry() 512 times to @@ -1113,9 +1115,9 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, * NOTE: In a fine-grained p2m locking scenario this operation * may need to promote its locking from gfn->1g superpage */ - p2m_set_entry(p2m, gfn_aligned, INVALID_MFN, PAGE_ORDER_2M, - p2m_populate_on_demand, p2m->default_access); - return true; + rc = p2m_set_entry(p2m, gfn_aligned, INVALID_MFN, PAGE_ORDER_2M, + p2m_populate_on_demand, p2m->default_access); + return !rc; } /* Only reclaim if we're in actual need of more cache. */