Skip to contentSkip to conversation

x86/hvm/viridian: set shutdown_code in response to CrashNotify

PATCH In review Paul Durrant 2 participants 8 messages Aug 10, 2018 – Sep 6, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/hvm/viridian: set shutdown_code in response to CrashNotify

When Windows writes the CrashNotify bit in the CRASH_CTL MSR then we know it is crashing, so set the domain shutdown code appropriately.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>

---
 xen/arch/x86/hvm/viridian.c | 4 ++++
 1 file changed, 4 insertions(+)
xen/arch/x86/hvm/viridian.c +4 -0
index 486065182c..294cf486cc 100644
@@ -645,6 +645,10 @@ int wrmsr_viridian_regs(uint32_t idx, uint64_t val)
         if ( !ctl.u.CrashNotify )
             break;
 
+        spin_lock(&d->shutdown_lock);
+        d->shutdown_code = SHUTDOWN_crash;
+        spin_unlock(&d->shutdown_lock);
+
         gprintk(XENLOG_WARNING, "VIRIDIAN CRASH: %lx %lx %lx %lx %lx\n",
                 v->arch.hvm_vcpu.viridian.crash_param[0],
                 v->arch.hvm_vcpu.viridian.crash_param[1],
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 16 lines · Paul Durrant

When Windows writes the CrashNotify bit in the CRASH_CTL MSR then we know it is crashing, so set the domain shutdown code appropriately.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>

---
 xen/arch/x86/hvm/viridian.c | 4 ++++
 1 file changed, 4 insertions(+)
xen/arch/x86/hvm/viridian.c +0 -0
index 486065182c..294cf486cc 100644

xen/arch/x86/hvm/viridian.c int wrmsr_viridian_regs(uint32_t idx, uint64_t val) · line 650

Quoted 6 lines
xen/arch/x86/hvm/viridian.c +3 -0
@@ -645,6 +645,10 @@ int wrmsr_viridian_regs(uint32_t idx, uint64_t val)
         if ( !ctl.u.CrashNotify )
             break;
 
+        spin_lock(&d->shutdown_lock);
+        d->shutdown_code = SHUTDOWN_crash;
+        spin_unlock(&d->shutdown_lock);

How does the domain eventually shut down?  It feels slightly odd to have a shutdown code before the domain has finished executing code.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 29 lines

-----Original Message-----
From: Andrew Cooper
Sent: 10 August 2018 16:57
To: Paul Durrant <[email protected]>; [email protected]
Cc: Jan Beulich <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: set shutdown_code in response to CrashNotify

Quoted 1 line · Paul Durrant

When Windows writes the CrashNotify bit in the CRASH_CTL MSR then we

know

Quoted 18 lines

it is crashing, so set the domain shutdown code appropriately.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>

---
 xen/arch/x86/hvm/viridian.c | 4 ++++
 1 file changed, 4 insertions(+)
xen/arch/x86/hvm/viridian.c +0 -0
index 486065182c..294cf486cc 100644
@@ -645,6 +645,10 @@ int wrmsr_viridian_regs(uint32_t idx, uint64_t val)
         if ( !ctl.u.CrashNotify )
             break;
 
Quoted 5 lines

xen/arch/x86/hvm/viridian.c int wrmsr_viridian_regs(uint32_t idx, uint64_t val) · line 650

Quoted 3 lines
xen/arch/x86/hvm/viridian.c +3 -0
+        spin_lock(&d->shutdown_lock);
+        d->shutdown_code = SHUTDOWN_crash;
+        spin_unlock(&d->shutdown_lock);

How does the domain eventually shut down?

I assume it shuts down when the guest writes to the PIIX.

Quoted 3 lines

  It feels slightly odd to have
a shutdown code before the domain has finished executing code.

That's the norm. The PV drivers (if they are installed) set it via a schedop. This just makes sure it is set even if the PV drivers aren't there.

Paul

Quoted 1 line

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 33 lines · Paul Durrant
Quoted 29 lines

-----Original Message-----
From: Andrew Cooper
Sent: 10 August 2018 16:57
To: Paul Durrant <[email protected]>; [email protected]
Cc: Jan Beulich <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: set shutdown_code in response to CrashNotify

Quoted 1 line · Paul Durrant

When Windows writes the CrashNotify bit in the CRASH_CTL MSR then we

know

Quoted 18 lines

it is crashing, so set the domain shutdown code appropriately.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>

---
 xen/arch/x86/hvm/viridian.c | 4 ++++
 1 file changed, 4 insertions(+)
xen/arch/x86/hvm/viridian.c +0 -0
index 486065182c..294cf486cc 100644
@@ -645,6 +645,10 @@ int wrmsr_viridian_regs(uint32_t idx, uint64_t val)
         if ( !ctl.u.CrashNotify )
             break;
 
Quoted 4 lines

xen/arch/x86/hvm/viridian.c int wrmsr_viridian_regs(uint32_t idx, uint64_t val) · line 650

Quoted 3 lines
xen/arch/x86/hvm/viridian.c +3 -0
+        spin_lock(&d->shutdown_lock);
+        d->shutdown_code = SHUTDOWN_crash;
+        spin_unlock(&d->shutdown_lock);

How does the domain eventually shut down?

Quoted 6 lines

I assume it shuts down when the guest writes to the PIIX.

Quoted 3 lines

  It feels slightly odd to have
a shutdown code before the domain has finished executing code.

That's the norm. The PV drivers (if they are installed) set it via a schedop. This just makes sure it is set even if the PV drivers aren't there.

What happens if the user has configured windows to reboot after a crash?

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 48 lines

-----Original Message-----
From: Andrew Cooper
Sent: 16 August 2018 10:40
To: Paul Durrant <[email protected]>; [email protected]
Cc: Jan Beulich <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: set shutdown_code in response to CrashNotify

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Andrew Cooper
Sent: 10 August 2018 16:57
To: Paul Durrant <[email protected]>; xen-

[email protected]

Quoted 2 lines
Quoted 2 lines

Cc: Jan Beulich <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: set shutdown_code in response

to

Quoted 4 lines
Quoted 4 lines

CrashNotify

Quoted 1 line · Paul Durrant

When Windows writes the CrashNotify bit in the CRASH_CTL MSR then

we

Quoted 11 lines
Quoted 11 lines

know

Quoted 10 lines

it is crashing, so set the domain shutdown code appropriately.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>

---
 xen/arch/x86/hvm/viridian.c | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 5 lines
Quoted 5 lines

xen/arch/x86/hvm/viridian.c int wrmsr_viridian_regs(uint32_t idx, uint64_t

Quoted 5 lines
xen/arch/x86/hvm/viridian.c +0 -0
index 486065182c..294cf486cc 100644
@@ -645,6 +645,10 @@ int wrmsr_viridian_regs(uint32_t idx, uint64_t

val)

Quoted 9 lines
Quoted 7 lines

xen/arch/x86/hvm/viridian.c int wrmsr_viridian_regs(uint32_t idx, uint64_t val) · line 650

Quoted 6 lines
xen/arch/x86/hvm/viridian.c +3 -0
         if ( !ctl.u.CrashNotify )
             break;
 
+        spin_lock(&d->shutdown_lock);
+        d->shutdown_code = SHUTDOWN_crash;
+        spin_unlock(&d->shutdown_lock);

How does the domain eventually shut down?

I assume it shuts down when the guest writes to the PIIX.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

  It feels slightly odd to have
a shutdown code before the domain has finished executing code.

That's the norm. The PV drivers (if they are installed) set it via a schedop.

This just makes sure it is set even if the PV drivers aren't there.

What happens if the user has configured windows to reboot after a crash?

That's exactly what this is trying to fix. Without the patch a VM without PV drivers will appear to just shut down (because nothing will set the shutdown code to anything else) so the actions-after-crash will not take effect.

Paul

Quoted 1 line

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
Quoted 63 lines

-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Paul Durrant
Sent: 23 August 2018 09:38
To: Andrew Cooper <[email protected]>; xen- [email protected]
Cc: Jan Beulich <[email protected]>
Subject: Re: [Xen-devel] [PATCH] x86/hvm/viridian: set shutdown_code in response to CrashNotify

Quoted 4 lines

-----Original Message-----
From: Andrew Cooper
Sent: 16 August 2018 10:40
To: Paul Durrant <[email protected]>; xen-

[email protected]

Quoted 48 lines

Cc: Jan Beulich <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: set shutdown_code in response to CrashNotify

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Andrew Cooper
Sent: 10 August 2018 16:57
To: Paul Durrant <[email protected]>; xen-

[email protected]

Quoted 2 lines
Quoted 2 lines

Cc: Jan Beulich <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: set shutdown_code in response

to

Quoted 4 lines
Quoted 4 lines

CrashNotify

Quoted 1 line · Paul Durrant

When Windows writes the CrashNotify bit in the CRASH_CTL MSR then

we

Quoted 11 lines
Quoted 11 lines

know

Quoted 10 lines

it is crashing, so set the domain shutdown code appropriately.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>

---
 xen/arch/x86/hvm/viridian.c | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 5 lines
Quoted 5 lines

xen/arch/x86/hvm/viridian.c int wrmsr_viridian_regs(uint32_t idx, uint64_t

Quoted 5 lines
xen/arch/x86/hvm/viridian.c +0 -0
index 486065182c..294cf486cc 100644
@@ -645,6 +645,10 @@ int wrmsr_viridian_regs(uint32_t idx, uint64_t

val)

Quoted 13 lines
Quoted 7 lines

xen/arch/x86/hvm/viridian.c int wrmsr_viridian_regs(uint32_t idx, uint64_t val) · line 650

Quoted 6 lines
xen/arch/x86/hvm/viridian.c +3 -0
         if ( !ctl.u.CrashNotify )
             break;
 
+        spin_lock(&d->shutdown_lock);
+        d->shutdown_code = SHUTDOWN_crash;
+        spin_unlock(&d->shutdown_lock);

How does the domain eventually shut down?

I assume it shuts down when the guest writes to the PIIX.

Quoted 3 lines

  It feels slightly odd to have
a shutdown code before the domain has finished executing code.

That's the norm. The PV drivers (if they are installed) set it via a schedop.

Quoted 9 lines
Quoted 4 lines

This just makes sure it is set even if the PV drivers aren't there.

What happens if the user has configured windows to reboot after a crash?

That's exactly what this is trying to fix. Without the patch a VM without PV drivers will appear to just shut down (because nothing will set the shutdown code to anything else) so the actions-after-crash will not take effect.

Ping? Are you ok with the patch now?

Paul

Quoted 7 lines

Paul

Quoted 1 line

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw
Quoted 65 lines · Paul Durrant
Quoted 65 lines

-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Paul Durrant
Sent: 23 August 2018 09:38
To: Andrew Cooper <[email protected]>; xen- [email protected]
Cc: Jan Beulich <[email protected]>
Subject: Re: [Xen-devel] [PATCH] x86/hvm/viridian: set shutdown_code in response to CrashNotify

Quoted 4 lines

-----Original Message-----
From: Andrew Cooper
Sent: 16 August 2018 10:40
To: Paul Durrant <[email protected]>; xen-

[email protected]

Quoted 50 lines

Cc: Jan Beulich <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: set shutdown_code in response to CrashNotify

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Andrew Cooper
Sent: 10 August 2018 16:57
To: Paul Durrant <[email protected]>; xen-

[email protected]

Quoted 2 lines
Quoted 2 lines

Cc: Jan Beulich <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: set shutdown_code in response

to

Quoted 4 lines
Quoted 4 lines

CrashNotify

Quoted 1 line · Paul Durrant

When Windows writes the CrashNotify bit in the CRASH_CTL MSR then

we

Quoted 11 lines
Quoted 11 lines

know

Quoted 10 lines

it is crashing, so set the domain shutdown code appropriately.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>

---
 xen/arch/x86/hvm/viridian.c | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 5 lines
Quoted 5 lines

xen/arch/x86/hvm/viridian.c int wrmsr_viridian_regs(uint32_t idx, uint64_t

Quoted 5 lines
xen/arch/x86/hvm/viridian.c +0 -0
index 486065182c..294cf486cc 100644
@@ -645,6 +645,10 @@ int wrmsr_viridian_regs(uint32_t idx, uint64_t

val)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
xen/arch/x86/hvm/viridian.c +3 -0
         if ( !ctl.u.CrashNotify )
             break;
 
+        spin_lock(&d->shutdown_lock);
+        d->shutdown_code = SHUTDOWN_crash;
+        spin_unlock(&d->shutdown_lock);
Quoted 7 lines
Quoted 1 line

How does the domain eventually shut down?

I assume it shuts down when the guest writes to the PIIX.

Quoted 3 lines

  It feels slightly odd to have
a shutdown code before the domain has finished executing code.

That's the norm. The PV drivers (if they are installed) set it via a schedop.

This just makes sure it is set even if the PV drivers aren't there.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

What happens if the user has configured windows to reboot after a crash?

That's exactly what this is trying to fix. Without the patch a VM without PV drivers will appear to just shut down (because nothing will set the shutdown code to anything else) so the actions-after-crash will not take effect.

Ping? Are you ok with the patch now?

Lol - I was literally just trying to find it.  I'll commit it in a moment.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#7 lore raw
Quoted 85 lines

-----Original Message-----
From: Andrew Cooper
Sent: 06 September 2018 16:33
To: Paul Durrant <[email protected]>; [email protected]
Cc: Jan Beulich <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: set shutdown_code in response to CrashNotify

Quoted 2 lines · Paul Durrant
Quoted 2 lines

-----Original Message-----
From: Xen-devel [mailto:[email protected]] On

Behalf

Quoted 6 lines
Quoted 6 lines

Of Paul Durrant
Sent: 23 August 2018 09:38
To: Andrew Cooper <[email protected]>; xen- [email protected]
Cc: Jan Beulich <[email protected]>
Subject: Re: [Xen-devel] [PATCH] x86/hvm/viridian: set shutdown_code

in

Quoted 9 lines
Quoted 9 lines

response to CrashNotify

Quoted 4 lines

-----Original Message-----
From: Andrew Cooper
Sent: 16 August 2018 10:40
To: Paul Durrant <[email protected]>; xen-

[email protected]

Quoted 2 lines

Cc: Jan Beulich <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: set shutdown_code in response

to

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

CrashNotify

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Andrew Cooper
Sent: 10 August 2018 16:57
To: Paul Durrant <[email protected]>; xen-

[email protected]

Quoted 2 lines
Quoted 2 lines

Cc: Jan Beulich <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: set shutdown_code in

response

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

to

Quoted 4 lines
Quoted 4 lines

CrashNotify

Quoted 1 line · Paul Durrant

When Windows writes the CrashNotify bit in the CRASH_CTL MSR

then

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

we

Quoted 11 lines
Quoted 11 lines

know

Quoted 10 lines

it is crashing, so set the domain shutdown code appropriately.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>

---
 xen/arch/x86/hvm/viridian.c | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/xen/arch/x86/hvm/viridian.c

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

xen/arch/x86/hvm/viridian.c int wrmsr_viridian_regs(uint32_t idx,

Quoted 4 lines

index 486065182c..294cf486cc 100644

xen/arch/x86/hvm/viridian.c +0 -0
@@ -645,6 +645,10 @@ int wrmsr_viridian_regs(uint32_t idx,

uint64_t

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

val)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
xen/arch/x86/hvm/viridian.c +3 -0
         if ( !ctl.u.CrashNotify )
             break;
 
+        spin_lock(&d->shutdown_lock);
+        d->shutdown_code = SHUTDOWN_crash;
+        spin_unlock(&d->shutdown_lock);
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line

How does the domain eventually shut down?

I assume it shuts down when the guest writes to the PIIX.

Quoted 3 lines

  It feels slightly odd to have
a shutdown code before the domain has finished executing code.

That's the norm. The PV drivers (if they are installed) set it via a

schedop.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

This just makes sure it is set even if the PV drivers aren't there.

What happens if the user has configured windows to reboot after a

crash?

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines

That's exactly what this is trying to fix. Without the patch a VM without PV drivers will appear to just shut down (because nothing will set the

shutdown

Quoted 3 lines
Quoted 2 lines

code to anything else) so the actions-after-crash will not take effect.

Ping? Are you ok with the patch now?

Lol - I was literally just trying to find it.  I'll commit it in a moment.

:-)

Quoted 1 line

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel