[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 1/3] xen/mm: enforce SCRUB_DEBUG checks for MEMF_no_scrub allocations


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Thu, 15 Jan 2026 12:18:02 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DGFKVF0i2wWigbiwR7BNTdhzq53D/kNouGUmcPEvNic=; b=JdiHKVg/Q04yRKCBDGAg34F6fzWLdPryQoeNztm9IsEqstxHWHzxiKQAUJBzycHu59aOsxsB8Y55S+w3YoXZMKXz278f3RQDjRGp/DRg42kmGMn2tVng8cQ8YMn4DsF4J4cojPTKfvBVHlQilluLTSP7Elihwc9KZbWRlb7uFvdWDILmbfDFl35YoML/w+oRqduyTB7R3gJh3mmRKfUgOniDZHg6GHeoQrGG7Lbao1W1zdkLmw146kwfJ4kkxqvOYdfctMpQKY8I64wPcOn6IsL/PYg3y95ATCa9AR+8hoC+9CYCH9+wdWSgaT1sdNOjRF65oUnLG7r8fjfMmDuLPg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HOUt15YJB2aXEzpXq0D3dExLXpxTS0dWGWptTiLjTOzULkpBRXQYJ3nD5hdv4mg9vZtUDAEIszkcEwV3Ck8c3wcchArhow1Kv8LYAoE7zyM+mntVJswv1JRs9F6hvW9Nz9icnM1hvTRCztVb32MaAR+HzIhBvV9z62nzj3QEPBRgnEb/r+aBZVEtruPulHNWX4aIFXHLF/IAt3oSw6WPLoXsXhfMscFvWVZve+Ey2PVkh4pVeC04oKHqlsMnmJ/UyCgIoWzjdZ83hUF8b5AzyYhU5eOhZMqsw65FOXFbzc6LBdEBTNYCH2OrA6TSXg/sb4H4+mAgjLZqKW3mYFi1kw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Thu, 15 Jan 2026 11:19:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The logic in alloc_heap_pages() only checks for scrubbing pattern
correctness when the caller doesn't pass MEMF_no_scrub in memflags.
However already scrubbed pages can be checked for correctness, regardless
of the caller having requested MEMF_no_scrub.

Relax the checking around the check_one_page() call, to allow for calls
with MEMF_no_scrub to also check the correctness of pages marked as already
scrubbed when allocated.  This widens the checking of scrubbing
correctness, so it would also check the scrubbing correctness of
MEMF_no_scrub allocations.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
After discussing with Jan I've deliberately omitted the tag:

Fixes: 0c5f2f9cefac ("mm: Make sure pages are scrubbed")

The intended approach might have been to ensure the caller of
alloc_heap_pages() gets properly scrubbed pages, rather than asserting the
internal state of free pages is as expected.
---
 xen/common/page_alloc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index 2efc11ce095f..de1480316f05 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -1105,8 +1105,7 @@ static struct page_info *alloc_heap_pages(
 
     spin_unlock(&heap_lock);
 
-    if ( first_dirty != INVALID_DIRTY_IDX ||
-         (scrub_debug && !(memflags & MEMF_no_scrub)) )
+    if ( first_dirty != INVALID_DIRTY_IDX || scrub_debug )
     {
         bool cold = d && d != current->domain;
 
@@ -1119,7 +1118,7 @@ static struct page_info *alloc_heap_pages(
 
                 dirty_cnt++;
             }
-            else if ( !(memflags & MEMF_no_scrub) )
+            else
                 check_one_page(&pg[i]);
         }
 
-- 
2.51.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.