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: 117725 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp870862edm; Wed, 1 Nov 2017 07:52:32 -0700 (PDT) X-Google-Smtp-Source: ABhQp+R1wLTgUcLkMcx3wim4BBg7WtwoyefwYcVKSH0mMIjkLPb1o83HtY3sfk1HA4P64NHj2whM X-Received: by 10.36.93.72 with SMTP id w69mr789633ita.103.1509547951914; Wed, 01 Nov 2017 07:52:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509547951; cv=none; d=google.com; s=arc-20160816; b=mKypr9UepEEywDFaX7R5omlutRsHRZkCbGGz6mZpMa/2l7O2smKSFQlS395yC1ZDLW 9HCrQz10QGmWp6uAja5608rpO5XP5Uv6b+euh7PJxOdORAhr3TVjm3Spw5g1OUzB6CMX s7tO8BQNw4yhQNeIsAy70CFE00pO/XjwkaiqC3ra0Q3HWAX5wDSuxhjmSL6j3gpjC0KO CwZrYHtYsKlqq86zQCZty4wvgywcR4eLbI0kWcEAofHU4pgbvpX5LYa951K4dfaDuh+C durIDIM8fPfzClwSFNwLGtdNV6UAYrKjoAWaCkeSvXLTjfuRdDZ4xjSpKe0dG4CQO3SR gKKw== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:message-id:date:to:from:dkim-signature :arc-authentication-results; bh=R122G376dISQwlw2kRWxreS7NseuggJ2tvD9cqITa/8=; b=RZIpSmhZyf6XwReeR8qwTudWnJjdzltWr4U1QTxicz4M1wc19yzI31nRUjje3dapHK 6Gurl4+gRW3UKHkzcepGhFKWN93xKj2y66NlmGFZUPNv+DfkQQuA4EN3BoT5DZr8R/qZ cq/R01hXwnxmM8zpAmz0N7l/c1kIwbVy9IKxrsQ2/ZnamP72/GM5jXB4B1Rr8TyBn+xo 6oR0S/ummqLD7yE8VKHs/Ip3gcOI6JhDnYS7I2+55byonU8P5pMwA88sgwAzE3Zafi3j wWAwwa//lmalDI3PBUxnT6zLCK5xplCVF9yUrvPKfbTJTn7Y/oOykQETJw86RAwA9vub mR6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ux3hcg6j; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id s14si1139293ite.108.2017.11.01.07.52.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Nov 2017 07:52:31 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Ux3hcg6j; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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-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" 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. */