pvh: call pit_init for pvh also
PATCH 1/1 pvh: call pit_init for pvh also
Hi,
New in V1:
- move pit_init to arch_domain_create since it's called for all 3 guests..
- move pit_deinit also to appropriately.
This should be backported to 4.4 IMO.
thanks,
Mukesh
Quoted 1 line
From V0:
I just upgraded by domU and ran into this pit related hang again for pvh. During shutdown, the guest does:
[ 24.617014] pcspkr pcspkr: shutdown
this results in call to handle_pio() --> .. --> handle_pvh_io() -> ..
handle_speaker_io() causing xen to hang on :
spin_lock(&vpit->lock);
because pit_init has not be called and the spin lock didn't get initialized.
At least I see in my earlier patches I had call to pit_init, but it seems to have fallen thru the cracks in final checkins. Anyways, here's my first cut at the proposed fix. Other alternative would be to just register handle_speaker_io handler in pit_reset, since we don't seem to be emulating pit for pvh. LMK suggestions if this fix is not very congenial.
George, I think this should be a candidate for next 4.4 RC. Fix is simple and it avoids hang in xen from pvh guest shutdown.
PATCH 1/1 pvh: call pit_init for pvh also
During halt of a pvh guest, the guest may do speaker shutdown. This results in call to handle_speaker_io in xen. It will hang on the vpit spin lock because it has not been initialized.
Since, pit_init is also called for both pv and hvm, the call is moved to a more generic place.
--- xen/arch/x86/domain.c | 9 +++++---- xen/arch/x86/hvm/hvm.c | 2 -- xen/arch/x86/hvm/i8254.c | 3 +-- xen/include/asm-x86/hvm/vpt.h | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-)
xen/arch/x86/domain.c +5 -4
@@ -422,10 +422,6 @@ int vcpu_initialise(struct vcpu *v)/* PV guests by default have a 100Hz ticker. */ v->periodic_period =MILLISECS (10 ); - -/* PV guests get an emulated PIT too for video BIOSes to use. */ -if ( v->vcpu_id ==0 ) -pit_init (v, cpu_khz); } v->arch.schedule_tail = continue_nonidle_domain;
@@ -579,6 +575,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags)tsc_set_info (d,TSC_MODE_DEFAULT ,0UL ,0 ,0 );spin_lock_init (&d->arch.vtsc_lock); +/* PV/PVH guests get an emulated PIT for video BIOSes. */ +pit_init (d, cpu_khz); +return 0 ; fail:
@@ -1978,6 +1977,8 @@ int domain_relinquish_resources(struct domain *d)BUG (); } +pit_deinit (d); +if (has_hvm_container_domain (d) )hvm_domain_relinquish_resources (d);
xen/arch/x86/hvm/hvm.c +0 -2
@@ -643,7 +643,6 @@ void hvm_domain_relinquish_resources(struct domain *d)rtc_deinit (d);if ( d->vcpu !=NULL && d->vcpu[0 ] !=NULL ) { -pit_deinit (d);pmtimer_deinit (d);hpet_deinit (d); }
@@ -1337,7 +1336,6 @@ int hvm_vcpu_initialise(struct vcpu *v)if ( v->vcpu_id ==0 ) {/* NB. All these really belong in hvm_domain_initialise(). */ -pit_init (v, cpu_khz);pmtimer_init (v);hpet_init (v);
xen/arch/x86/hvm/i8254.c +1 -2
@@ -447,9 +447,8 @@ void pit_reset(struct domain *d)spin_unlock (&pit->lock); } -void pit_init (struct vcpu *v,unsigned long cpu_khz) +void pit_init (struct domain *d,unsigned long cpu_khz) { -struct domain *d = v->domain;PITState *pit =domain_vpit (d);spin_lock_init (&pit->lock);
xen/include/asm-x86/hvm/vpt.h +1 -1
@@ -176,7 +176,7 @@ void destroy_periodic_time(struct periodic_time *pt);int pv_pit_handler (int port,int data,int write);void pit_reset (struct domain *d); -void pit_init (struct vcpu *v,unsigned long cpu_khz); +void pit_init (struct domain *d,unsigned long cpu_khz);void pit_stop_channel0_irq (PITState * pit);void pit_deinit (struct domain *d);void rtc_init (struct domain *d);
Signature · 1 line
1.8.3.1