From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olaf Hering Subject: [PATCH 08/11] xen/hvm kexec: unregister the watch of the "backend" node during reboot Date: Thu, 28 Jul 2011 15:23:08 +0200 Message-ID: <20110728132302.745855909@aepfle.de> References: <20110728132300.248098023@aepfle.de> Return-path: Content-Disposition: inline; filename=xen.syscore_ops.unregister_watch.xenbus_backend.patch List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org The watch of the xenstore "backend" node has to be unregistered during a kexec reboot. Otherwise the kexec kernel will crash due to a memory corruption because more than one watch is registered on that node. v2: use kexec_is_loaded() function Signed-off-by: Olaf Hering --- drivers/xen/xenbus/xenbus_probe_backend.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) Index: linux-3.0/drivers/xen/xenbus/xenbus_probe_backend.c =================================================================== --- linux-3.0.orig/drivers/xen/xenbus/xenbus_probe_backend.c +++ linux-3.0/drivers/xen/xenbus/xenbus_probe_backend.c @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include #include @@ -255,6 +257,18 @@ static int backend_probe_and_watch(struc return NOTIFY_DONE; } +static void xenbus_backend_shutdown_watcher(void) +{ + if (!kexec_is_loaded()) + return; + + unregister_xenbus_watch(&be_watch); +} + +static struct syscore_ops xenbus_backend_watcher_syscore_ops = { + .shutdown = xenbus_backend_shutdown_watcher, +}; + static int __init xenbus_probe_backend_init(void) { static struct notifier_block xenstore_notifier = { @@ -270,6 +284,7 @@ static int __init xenbus_probe_backend_i return err; register_xenstore_notifier(&xenstore_notifier); + register_syscore_ops(&xenbus_backend_watcher_syscore_ops); return 0; }