$NetBSD: patch-zz-bouyer,v 1.3 2019/03/25 15:28:13 bouyer Exp $
Dirty hack to avoid assert failure. This has been discussed on xen-devel
but no solution has been found so far.
The box producing http://www-soc.lip6.fr/~bouyer/NetBSD-tests/xen/
is running with this patch; the printk has fired but the
hypervisor keeps running.

--- xen/arch/x86/mm.c.orig	2018-07-19 10:32:07.000000000 +0200
+++ xen/arch/x86/mm.c	2018-07-21 20:47:47.000000000 +0200
@@ -674,7 +674,12 @@
     typeof(pg->linear_pt_count) oc;
 
     oc = arch_fetch_and_add(&pg->linear_pt_count, -1);
-    ASSERT(oc > 0);
+    if (oc <= 0) {
+            gdprintk(XENLOG_WARNING,
+                 "mm.c:dec_linear_entries(): oc %d would fail assert\n", oc);
+	    pg->linear_pt_count = 0;
+    }
+    /* ASSERT(oc > 0); */
 }
 
 static bool inc_linear_uses(struct page_info *pg)
