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

[PATCH v2] x86/PV: assert page state in mark_pv_pt_pages_rdonly()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 17 Aug 2021 16:29:20 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RMC/WPWQmSMgom0Dy/h+kiqrFEVC1Yp73t9dr6QPkDs=; b=dwO32HatWJzVB5UYsOF9HnTGwI4OaZRGNPo+ZYhZeNeogwgNuVKAus19FSgXAdjLP5gp59GBeffvAPTR8pCDXJ2o7XqZhEQnBCO2yU3Vl58UzBaDw+iu4v3//L8zpT1+sx8Ea/2Lc8GrMYrn/rA485ooKgi0bgFXYexEmhvu04oztqXeKdgxh1Dh5oFuj48I/BdnvZiGdNqnp53Oj7SG3XPOx+24oZ0XR+X7AXsRt0iU2hgwVg/hhuT+kPQbr/0s7EJdQmFN/7PHu/ByzN3oKFEZ1ipdiZjrZjlvOI+w8o7P5Jo0oFk0//x/Fn0V00BPLyXfkuZSx5/pfR075Lwaug==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jrjk8Wl8zMsu7yd4KmqlZsxaekF4f72kS5hTY7GbjfFCpZEkb3GQa7o5t/ViffvSlqU58s3i2EutSMC6gfB8iPIgXP7GPWxH0Z2ogtbVMeQKLRaQrEr7RyJq9Cx1xpHfcyNz3qzGfUmXPpcrU95SLdJLj/I7BLR/MZ94zG8FnQc77RzFkM7wjJTQYkODUk7CTSnL0JYowCeb8U39alybsEsXkXTTjn7LwGSQA7AVeaCoXenPylHAkcGjYPf46qr6uHjSKDYAVNMIZvBYkb7W5JJQDePy023IB7b/Q3dL5k20JZ6LxZNDd2L4woPL3rHYdC84RIKHezYCkMzBpb/9VA==
  • Authentication-results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 17 Aug 2021 14:29:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

About every time I look at dom0_construct_pv()'s "calculation" of
nr_pt_pages I question (myself) whether the result is precise or merely
an upper bound. I think it is meant to be precise, but I think we would
be better off having some checking in place. Hence add ASSERT()s to
verify that
- all pages have a valid L1...Ln (currently L4) page table type and
- no other bits are set, in particular the type refcount is still zero.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: Refine an expression. Add comment.
---
There are (at least) two factors supporting my uncertainty about the
"calculation" being precise: The loop starting from 2 (which clearly is
too small for a possible result) and an apparently wrong comment stating
that not only v_end but also v_start would be superpage aligned (in fact
v_end is 4MiB aligned, which is the superpage size only on long
abandoned [by us] non-PAE x86-32).

--- a/xen/arch/x86/pv/dom0_build.c
+++ b/xen/arch/x86/pv/dom0_build.c
@@ -59,6 +59,16 @@ static __init void mark_pv_pt_pages_rdon
         l1e_remove_flags(*pl1e, _PAGE_RW);
         page = mfn_to_page(l1e_get_mfn(*pl1e));
 
+        /*
+         * Verify that
+         * - all pages have a valid L1...Ln page table type and
+         * - no other bits are set, in particular the type refcount is still
+         *   zero.
+         */
+        ASSERT((page->u.inuse.type_info & PGT_type_mask) >= PGT_l1_page_table);
+        ASSERT((page->u.inuse.type_info & PGT_type_mask) <= 
PGT_root_page_table);
+        ASSERT(!(page->u.inuse.type_info & ~PGT_type_mask));
+
         /* Read-only mapping + PGC_allocated + page-table page. */
         page->count_info         = PGC_allocated | 3;
         page->u.inuse.type_info |= PGT_validated | 1;




 


Rackspace

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