KVM: i8254: change PIT discard tick policy
Quoted 16 lines · Radim Krčmář
From: Radim Krčmář <[email protected]>
commit
7dd0fdff145c5be7146d0ac06732ae3613412ac1upstream.Discard policy uses
ack_notifiersto prevent injection of PIT interrupts before EOI from the last one.This patch changes the policy to always try to deliver the interrupt, which makes a difference when its vector is in ISR.
Old implementation would drop the interrupt, but proposed one injects to IRR, like real hardware would.The old policy breaks legacy NMI watchdogs, where PIT is used through virtual wire (LVT0): PIT never sends an interrupt before receiving EOI, thus a guest deadlock with disabled interrupts will stop NMIs.
Quoted 6 lines
Note that NMI doesn't do EOI, so PIT also had to send a normal interrupt through IOAPIC. (KVM's PIT is deeply rotten and luckily not used much in modern systems.)
Even though there is a chance of regressions, I think we can fix the LVT0 NMI bug without introducing a new tick policy.
[...]
Given the 'chance of regressions', should we let this sit in mainline longer before including it in stable updates?
Ben.
Signature · 2 lines
Ben Hutchings This sentence contradicts itself - no actually it doesn't.
Greg Kroah-Hartman
maintainerQuoted 21 lines · Ben Hutchings
Quoted 20 lines · Radim Krčmář
From: Radim Krčmář <[email protected]>
commit
7dd0fdff145c5be7146d0ac06732ae3613412ac1upstream.Discard policy uses
ack_notifiersto prevent injection of PIT interrupts before EOI from the last one.This patch changes the policy to always try to deliver the interrupt, which makes a difference when its vector is in ISR.
Old implementation would drop the interrupt, but proposed one injects to IRR, like real hardware would.The old policy breaks legacy NMI watchdogs, where PIT is used through virtual wire (LVT0): PIT never sends an interrupt before receiving EOI, thus a guest deadlock with disabled interrupts will stop NMIs.
Note that NMI doesn't do EOI, so PIT also had to send a normal interrupt through IOAPIC. (KVM's PIT is deeply rotten and luckily not used much in modern systems.)
Quoted 6 lines
Quoted 2 lines
Even though there is a chance of regressions, I think we can fix the LVT0 NMI bug without introducing a new tick policy.
[...]
Given the 'chance of regressions', should we let this sit in mainline longer before including it in stable updates?
Hm, good point, Radim, what do you think, is this good to go to stable now? This has been in since 4.6-rc1, so it's been a few weeks with people running it already...
thanks,
greg k-h
2016-04-11 18:21-0700, Greg Kroah-Hartman:
Quoted 12 lines · Ben Hutchings
Quoted 7 lines · Radim Krčmář
Quoted 2 lines
Even though there is a chance of regressions, I think we can fix the LVT0 NMI bug without introducing a new tick policy.
[...]
Given the 'chance of regressions', should we let this sit in mainline longer before including it in stable updates?
Hm, good point, Radim, what do you think, is this good to go to stable now? This has been in since 4.6-rc1, so it's been a few weeks with people running it already...
I think it is good to go. No reasonable workload should regress and the fixed use-case is common on old linux guest.
This patch makes a difference if the guest doesn't EOI in PIT interrupts before the next one arrives. PIT would have been unreliable in that situation, so all worloads that that could regress have likely been avoided. Changes to NMI injection would need even crazier guest to regress.
(This patch always injects NMI from PIT and shrinks a window where a
maskable PIT interrupt is discarded. Previously, next interrupt would have been discarded as long as the last one is in IRR or ISR. Only IRR is considered after this patch, so PIT interrupts are more likely to chain.)
Greg Kroah-Hartman
maintainerQuoted 14 lines · Radim Krčmář
2016-04-11 18:21-0700, Greg Kroah-Hartman:
Quoted 12 lines · Ben Hutchings
Quoted 7 lines · Radim Krčmář
Quoted 2 lines
Even though there is a chance of regressions, I think we can fix the LVT0 NMI bug without introducing a new tick policy.
[...]
Given the 'chance of regressions', should we let this sit in mainline longer before including it in stable updates?
Hm, good point, Radim, what do you think, is this good to go to stable now? This has been in since 4.6-rc1, so it's been a few weeks with people running it already...
Quoted 8 lines
I think it is good to go. No reasonable workload should regress and the fixed use-case is common on old linux guest.
This patch makes a difference if the guest doesn't EOI in PIT interrupts before the next one arrives. PIT would have been unreliable in that situation, so all worloads that that could regress have likely been avoided. Changes to NMI injection would need even crazier guest to regress.
Ok, thanks, leaving it in.
greg k-h
Quoted 18 lines · Greg Kroah-Hartman
Quoted 17 lines · Radim Krčmář
2016-04-11 18:21-0700, Greg Kroah-Hartman:
Quoted 12 lines · Ben Hutchings
Quoted 7 lines · Radim Krčmář
Quoted 2 lines
Even though there is a chance of regressions, I think we can fix the LVT0 NMI bug without introducing a new tick policy.
[...]
Given the 'chance of regressions', should we let this sit in mainline longer before including it in stable updates?
Hm, good point, Radim, what do you think, is this good to go to stable now? This has been in since 4.6-rc1, so it's been a few weeks with people running it already...
I think it is good to go. No reasonable workload should regress and the fixed use-case is common on old linux guest.
Quoted 7 lines
Quoted 5 lines
This patch makes a difference if the guest doesn't EOI in PIT interrupts before the next one arrives. PIT would have been unreliable in that situation, so all worloads that that could regress have likely been avoided. Changes to NMI injection would need even crazier guest to regress.
Ok, thanks, leaving it in.
I agree.
FWIW the behavior after the patch is consistent with what actual hardware does. The old behavior was _documented_ to be consistent with actual hardware, but instead it was crazy.
Paolo