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

[PATCH v2 4/6] x86/PV: properly set shadow allocation for Dom0


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 2 Sep 2021 10:34:15 +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=MFNiMXoiKa06wTzVJFs8SMvmLCcjsyrCF6I15nLpdgY=; b=Nd3+D0GZyx9wHfGziRufm/aqTed9mhjaXx5K/e1jT0P4o5R6Qi8Zkm3fu17mQ1D75l3mRx7Xu0nAPcUI3TqCF06j/rXkWEO8r9nBSiCcb8s+EqoUrMPuaR0KO2BZRL+QjgtQzE8GmFZseEwmYe4b1FdJC99PWhMCKUA4E0hrnD5frM/k8mWG3U6EDtuvXv6RpdP2M9oxsTbADTru0ndZBj5ZHKhVhH4q7GUpbIU9NQPTQIeFm6kGae63oNDMSE9nO+hW0q4y3LE2Ta+VRwmdKDEbwkJTOUBKqWCOzTmEF3M2TOU3Cg03N2MpwWaVY31OFXNJ3Cs5j7wpk7vXS/L9pw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BRlP2XFEfmByhwI/5Jf+T8woCrmkt8PDBZQUnFGG1RT+wj9ZnW2niRp5wFisVcrdH6rOdX9pGqJNIjCvztOFUEQtiqCyIJ2crF9k9Iu6s0o90FfXVDwJDY2IjewBuS05SMGeHPOTRATkC0cTINUxHkY7LfUM5NuRel1AU8mboDs+FgMn+xLmzJJOTMSrbw3vrYYkznPQfQ6Zy2RGPeQb5fzk7prlGyZA2KKT77uaTojfquY0joDihX8NA189LHmBcEGdufjUqKgymI+IPrhGjrAhfHU3NdbETz0UemsKUVkS0KPTCTHOaW97xbRTy9LJJ3WTWs6P6U1PdQjGUzn24w==
  • Authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Tim Deegan <tim@xxxxxxx>
  • Delivery-date: Thu, 02 Sep 2021 08:34:24 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Leaving shadow setup just to the L1TF tasklet means running Dom0 on a
minimally acceptable shadow memory pool, rather than what normally
would be used (also, for example, for PVH). Populate the pool before
triggering the tasklet, on a best effort basis (again like done for
PVH).

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Tim Deegan <tim@xxxxxxx>
---
v2: Latch dom0_paging_pages() result.

--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -1298,7 +1298,7 @@ int shadow_set_allocation(struct domain
 {
     struct page_info *sp;
 
-    ASSERT(paging_locked_by_me(d));
+    ASSERT(paging_locked_by_me(d) || system_state < SYS_STATE_active);
 
     if ( pages > 0 )
     {
--- a/xen/arch/x86/pv/dom0_build.c
+++ b/xen/arch/x86/pv/dom0_build.c
@@ -21,6 +21,7 @@
 #include <asm/page.h>
 #include <asm/pv/mm.h>
 #include <asm/setup.h>
+#include <asm/shadow.h>
 
 /* Allow ring-3 access in long mode as guest cannot use ring 1 ... */
 #define BASE_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER)
@@ -933,7 +934,18 @@ int __init dom0_construct_pv(struct doma
 #ifdef CONFIG_SHADOW_PAGING
     if ( opt_dom0_shadow )
     {
+        bool preempted;
+
         printk("Switching dom0 to using shadow paging\n");
+
+        nr_pt_pages = dom0_paging_pages(d, nr_pages);
+
+        do {
+            preempted = false;
+            shadow_set_allocation(d, nr_pt_pages, &preempted);
+            process_pending_softirqs();
+        } while ( preempted );
+
         tasklet_schedule(&d->arch.paging.shadow.pv_l1tf_tasklet);
     }
 #endif




 


Rackspace

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