linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] misc: pvpanic: add crash loaded event
@ 2019-12-12 12:32 zhenwei pi
  2019-12-12 13:01 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: zhenwei pi @ 2019-12-12 12:32 UTC (permalink / raw)
  To: arnd, gregkh, peng.hao2; +Cc: linux-kernel, pizhenwei

Some users prefer kdump tools to generate guest kernel dumpfile,
at the same time, need a out-of-band kernel panic event.

Currently if booting guest kernel with 'crash_kexec_post_notifiers',
QEMU will recieve PVPANIC_PANICKED event and stop VM. If booting
guest kernel without 'crash_kexec_post_notifiers', guest will not
call notifier chain.

Add PVPANIC_CRASH_LOADED bit for pvpanic event, it means that guest
actually hit a kernel panic, but kernel wants to handle by itself.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
---
 drivers/misc/pvpanic.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c
index 95ff7c5a1dfb..a8cc96c90550 100644
--- a/drivers/misc/pvpanic.c
+++ b/drivers/misc/pvpanic.c
@@ -10,6 +10,7 @@
 
 #include <linux/acpi.h>
 #include <linux/kernel.h>
+#include <linux/kexec.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
@@ -19,6 +20,7 @@
 static void __iomem *base;
 
 #define PVPANIC_PANICKED        (1 << 0)
+#define PVPANIC_CRASH_LOADED    (1 << 1)
 
 MODULE_AUTHOR("Hu Tao <hutao@cn.fujitsu.com>");
 MODULE_DESCRIPTION("pvpanic device driver");
@@ -34,7 +36,13 @@ static int
 pvpanic_panic_notify(struct notifier_block *nb, unsigned long code,
 		     void *unused)
 {
-	pvpanic_send_event(PVPANIC_PANICKED);
+	unsigned int event = PVPANIC_PANICKED;
+
+	if (kexec_crash_loaded())
+		event = PVPANIC_CRASH_LOADED;
+
+	pvpanic_send_event(event);
+
 	return NOTIFY_DONE;
 }
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] misc: pvpanic: add crash loaded event
  2019-12-12 12:32 [PATCH] misc: pvpanic: add crash loaded event zhenwei pi
@ 2019-12-12 13:01 ` Greg KH
       [not found]   ` <0364f87c-7ad0-0208-fb03-d5f17d45ab73@bytedance.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2019-12-12 13:01 UTC (permalink / raw)
  To: zhenwei pi; +Cc: arnd, peng.hao2, linux-kernel

On Thu, Dec 12, 2019 at 08:32:26PM +0800, zhenwei pi wrote:
> Some users prefer kdump tools to generate guest kernel dumpfile,
> at the same time, need a out-of-band kernel panic event.
> 
> Currently if booting guest kernel with 'crash_kexec_post_notifiers',
> QEMU will recieve PVPANIC_PANICKED event and stop VM. If booting
> guest kernel without 'crash_kexec_post_notifiers', guest will not
> call notifier chain.
> 
> Add PVPANIC_CRASH_LOADED bit for pvpanic event, it means that guest
> actually hit a kernel panic, but kernel wants to handle by itself.
> 
> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
> ---
>  drivers/misc/pvpanic.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c
> index 95ff7c5a1dfb..a8cc96c90550 100644
> --- a/drivers/misc/pvpanic.c
> +++ b/drivers/misc/pvpanic.c
> @@ -10,6 +10,7 @@
>  
>  #include <linux/acpi.h>
>  #include <linux/kernel.h>
> +#include <linux/kexec.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/of_address.h>
> @@ -19,6 +20,7 @@
>  static void __iomem *base;
>  
>  #define PVPANIC_PANICKED        (1 << 0)
> +#define PVPANIC_CRASH_LOADED    (1 << 1)

BIT(1)?

>  MODULE_AUTHOR("Hu Tao <hutao@cn.fujitsu.com>");
>  MODULE_DESCRIPTION("pvpanic device driver");
> @@ -34,7 +36,13 @@ static int
>  pvpanic_panic_notify(struct notifier_block *nb, unsigned long code,
>  		     void *unused)
>  {
> -	pvpanic_send_event(PVPANIC_PANICKED);
> +	unsigned int event = PVPANIC_PANICKED;
> +
> +	if (kexec_crash_loaded())
> +		event = PVPANIC_CRASH_LOADED;
> +
> +	pvpanic_send_event(event);

Who gets this event to know that the above new bit is set or not?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [External] Re: [PATCH] misc: pvpanic: add crash loaded event
       [not found]   ` <0364f87c-7ad0-0208-fb03-d5f17d45ab73@bytedance.com>
@ 2019-12-12 13:35     ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2019-12-12 13:35 UTC (permalink / raw)
  To: zhenwei pi; +Cc: arnd, peng.hao2, linux-kernel

On Thu, Dec 12, 2019 at 09:26:22PM +0800, zhenwei pi wrote:
> On 12/12/19 9:01 PM, Greg KH wrote:
> 
> > On Thu, Dec 12, 2019 at 08:32:26PM +0800, zhenwei pi wrote:
> > > Some users prefer kdump tools to generate guest kernel dumpfile,
> > > at the same time, need a out-of-band kernel panic event.
> > > 
> > > Currently if booting guest kernel with 'crash_kexec_post_notifiers',
> > > QEMU will recieve PVPANIC_PANICKED event and stop VM. If booting
> > > guest kernel without 'crash_kexec_post_notifiers', guest will not
> > > call notifier chain.
> > > 
> > > Add PVPANIC_CRASH_LOADED bit for pvpanic event, it means that guest
> > > actually hit a kernel panic, but kernel wants to handle by itself.
> > > 
> > > Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
> > > ---
> > >   drivers/misc/pvpanic.c | 10 +++++++++-
> > >   1 file changed, 9 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c
> > > index 95ff7c5a1dfb..a8cc96c90550 100644
> > > --- a/drivers/misc/pvpanic.c
> > > +++ b/drivers/misc/pvpanic.c
> > > @@ -10,6 +10,7 @@
> > >   #include <linux/acpi.h>
> > >   #include <linux/kernel.h>
> > > +#include <linux/kexec.h>
> > >   #include <linux/module.h>
> > >   #include <linux/of.h>
> > >   #include <linux/of_address.h>
> > > @@ -19,6 +20,7 @@
> > >   static void __iomem *base;
> > >   #define PVPANIC_PANICKED        (1 << 0)
> > > +#define PVPANIC_CRASH_LOADED    (1 << 1)
> > BIT(1)?
> 
> zhenwei: yes, define PVPANIC_CRASH_LOADED as BIT(1)?
> 
> > 
> > >   MODULE_AUTHOR("Hu Tao <hutao@cn.fujitsu.com>");
> > >   MODULE_DESCRIPTION("pvpanic device driver");
> > > @@ -34,7 +36,13 @@ static int
> > >   pvpanic_panic_notify(struct notifier_block *nb, unsigned long code,
> > >   		     void *unused)
> > >   {
> > > -	pvpanic_send_event(PVPANIC_PANICKED);
> > > +	unsigned int event = PVPANIC_PANICKED;
> > > +
> > > +	if (kexec_crash_loaded())
> > > +		event = PVPANIC_CRASH_LOADED;
> > > +
> > > +	pvpanic_send_event(event);
> > Who gets this event to know that the above new bit is set or not?
> 
> Hypervisor will catch this event. A typical case maybe like this: guest os triggers
> pvpanic PVPANIC_CRASH_LOADED event, QEMU gets this event by handling vm-exit reason,
> then QEMU posts event to libvirt. Monotor agent gets domain lifecycle event from
> libvirt. Bingo, we can know that the guest has crashed but it handle error by
> kexec crash loaded image.

But as you have burried this user api value in a random .c file, how
does anything outside of the kernel know what the value really is for?

Shouldn't the #define be in a uapi file?

thanks,

greg k-h-

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-12 13:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-12 12:32 [PATCH] misc: pvpanic: add crash loaded event zhenwei pi
2019-12-12 13:01 ` Greg KH
     [not found]   ` <0364f87c-7ad0-0208-fb03-d5f17d45ab73@bytedance.com>
2019-12-12 13:35     ` [External] " Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).