Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp3943403imc; Thu, 14 Mar 2019 08:41:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKY1AN6469NTL0qjdO2UW7K0ecyk+HCMqsGUhRFWVN0yxIqGOBXLLQ8zOPXhylQF/YpKum X-Received: by 2002:a17:902:9306:: with SMTP id bc6mr51065563plb.59.1552578082026; Thu, 14 Mar 2019 08:41:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552578082; cv=none; d=google.com; s=arc-20160816; b=jooxHjNkUxl+8ZIKWNPg5YatKu6e+m4BRLD6vNE3juvTKP0bnZiZg1g/yer1NCV9JF MMnKiYLG311289soeWkNvStofOUyf6KA0fbc8cozGvackNCcn5Wvr5QGqffKDeIcHSJL v4Boa2l94dqkElHpudWpNmBDfS7fov6CdOoC0q09+ZgtiVvgRccLy3zKwQzuRU79CU48 8uojI/ahxXrMJDQwkfkPRLNUmJ6VbpdaR3Rm3Ppp7/1mCzgyymrzTO34fSjZriFaOdDJ 3ayJYFIwal0QM53tEIl5Mhzqt7FUX3z1LeugHgrbBVczHiI9N5xhOHEtnDwrjCfJPNaK W1iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=6k8y5owJlIgtXJ/xW4k/7iaMZhqHe82u6BLdUz4Kcic=; b=xLVlb6IeYV0orBeN6k7l5hr48vPQ/aFnaR/KiPdUetaQhPL6GNBFZjm7Dv+hkd+Vzl cFwBFDyrBwDvXHbleVuO/l5YujIJ/Pk82MviUVhUG3y8O/YBAPJAYdIqVerZ66auHyhI SlbdZAFjXPVeaSLLgrkbNQme2rAladRG+3dot9mrZHHAr6pIEPKqL7nDe2NrbxF/+Iza G623dgSNjmRACjBEjV8XTG+DCFLp/rylqejXkPbLFB6IYb/N2ooVcJQO6q5FwMYUqt2q wC9VOOroniLASySa8/Cnx08Q0T6ugfTt/egZygobvobl7C5WQry3rMZ+EwiUD1SgdFuM Fvsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m4si2527220pls.216.2019.03.14.08.41.06; Thu, 14 Mar 2019 08:41:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726585AbfCNPkb (ORCPT + 99 others); Thu, 14 Mar 2019 11:40:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47848 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbfCNPkb (ORCPT ); Thu, 14 Mar 2019 11:40:31 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5BD0880F6B; Thu, 14 Mar 2019 15:40:30 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-188.ams2.redhat.com [10.36.117.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id D93A15D75C; Thu, 14 Mar 2019 15:40:25 +0000 (UTC) From: David Hildenbrand To: xen-devel@lists.xenproject.org Cc: linux-kernel@vger.kernel.org, Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Julien Grall , Matthew Wilcox , Nadav Amit , Andrew Cooper , akpm@linux-foundation.org, linux-mm@kvack.org, David Hildenbrand Subject: [PATCH v1] xen/balloon: Fix mapping PG_offline pages to user space Date: Thu, 14 Mar 2019 16:40:25 +0100 Message-Id: <20190314154025.21128-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 14 Mar 2019 15:40:30 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The XEN balloon driver - in contrast to other balloon drivers - allows to map some inflated pages to user space. Such pages are allocated via alloc_xenballooned_pages() and freed via free_xenballooned_pages(). The pfn space of these allocated pages is used to map other things by the hypervisor using hypercalls. Pages marked with PG_offline must never be mapped to user space (as this page type uses the mapcount field of struct pages). So what we can do is, clear/set PG_offline when allocating/freeing an inflated pages. This way, most inflated pages can be excluded by dumping tools and the "reused for other purpose" balloon pages are correctly not marked as PG_offline. Fixes: 77c4adf6a6df (xen/balloon: mark inflated pages PG_offline) Reported-by: Julien Grall Tested-by: Julien Grall Signed-off-by: David Hildenbrand --- drivers/xen/balloon.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 39b229f9e256..751d32f41f26 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -604,6 +604,7 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages) while (pgno < nr_pages) { page = balloon_retrieve(true); if (page) { + __ClearPageOffline(page); pages[pgno++] = page; #ifdef CONFIG_XEN_HAVE_PVMMU /* @@ -646,6 +647,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages) for (i = 0; i < nr_pages; i++) { if (pages[i]) + __SetPageOffline(pages[i]); balloon_append(pages[i]); } -- 2.17.2