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

[PATCH][4.17] x86/shadow: drop (replace) bogus assertions


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 14 Oct 2022 10:49:55 +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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=poZy3Fj+sfjLDpJyyPbFWFcXUIdvNScSz2arcNdyaZo=; b=NEq89zTdHMsue53lv6fMlwfMg2pJqtbXe1rFvelhQ1CheBtnMW6mxFVnQiML1tuUPQeJkyNgjuKduYGP1JhmZLS4crgmD6GmILuIFlHk/VC/vVPRauz0snbmCEkTjXpQk0rwX3zhSipjV9WX3ZdbTEY3LVSsrnyfFEEMeX/osBdyHQNBZhhi9nMRDa/artapubWJbhuaeNWaBCHi39HwOEZG+PuyM9q4zo3dnLTO4pBRW1fIl0gdYAmpaxOe5oNgVj4nAF7BvRVeC1MtSOkVGycaDHfCl5mSuOrqfXOPqd3yd5WWa8WffFhYKczWDXFS/P71V1AKgKvhXmrzdqCaow==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j9pzo7zwr1xe4G/8wybFUI+TjMlpyH/9uQHgK7gWPT3iDube8YrO8mgTd78I5V1wyKMiKDJHatiYLXqsRw3iEVztxldcX3TbovB25O30sIlpa4apI5t3i/56KpZ6XK1og4pY3QoVhZtkx6K6JD+Q4G9ax2b8tRXK9YfKAy4LoDtGFWrzayRjs3WNiN3cuWw6eRTiYV/WBAHa15MTrAHsmGyAA46lz88J/9EUrxo402v7pcNXPa2sDXgPZCLhnyhEUHo1I7AujbdnltBj16W7EAmJVfB6RAYafM13ld8y369JmP/8XfJ+72iqCMkpyvgpznqTyHT/TDszlsTLNMo7aQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;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>, Henry Wang <Henry.Wang@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>
  • Delivery-date: Fri, 14 Oct 2022 08:50:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The addition of a call to shadow_blow_tables() from shadow_teardown()
has resulted in the "no vcpus" related assertion becoming triggerable:
If domain_create() fails with at least one page successfully allocated
in the course of shadow_enable(), or if domain_create() succeeds and
the domain is then killed without ever invoking XEN_DOMCTL_max_vcpus.

The assertion's comment was bogus anyway: Shadow mode has been getting
enabled before allocation of vCPU-s for quite some time. Convert the
assertion to a conditional: As long as there are no vCPU-s, there's
nothing to blow away.

Fixes: e7aa55c0aab3 ("x86/p2m: free the paging memory pool preemptively")
Reported-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

A similar assertion/comment pair exists in _shadow_prealloc(); the
comment is similarly bogus, and the assertion could in principle trigger
e.g. when shadow_alloc_p2m_page() is called early enough. Replace those
at the same time by a similar early return, here indicating failure to
the caller (which will generally lead to the domain being crashed in
shadow_prealloc()).

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
While in shadow_blow_tables() the option exists to simply remove the
assertion without adding a new conditional (the two loops simply will
do nothing), the same isn't true for _shadow_prealloc(): There we
would then trigger the ASSERT_UNREACHABLE() near the end of the
function.

--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -943,8 +943,9 @@ static bool __must_check _shadow_preallo
         /* No reclaim when the domain is dying, teardown will take care of it. 
*/
         return false;
 
-    /* Shouldn't have enabled shadows if we've no vcpus. */
-    ASSERT(d->vcpu && d->vcpu[0]);
+    /* Nothing to reclaim when there are no vcpus yet. */
+    if ( !d->vcpu[0] )
+        return false;
 
     /* Stage one: walk the list of pinned pages, unpinning them */
     perfc_incr(shadow_prealloc_1);
@@ -1034,8 +1035,9 @@ void shadow_blow_tables(struct domain *d
     mfn_t smfn;
     int i;
 
-    /* Shouldn't have enabled shadows if we've no vcpus. */
-    ASSERT(d->vcpu && d->vcpu[0]);
+    /* Nothing to do when there are no vcpus yet. */
+    if ( !d->vcpu[0] )
+        return;
 
     /* Pass one: unpin all pinned pages */
     foreach_pinned_shadow(d, sp, t)



 


Rackspace

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