mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-25 05:34:00 +08:00
x86/hyperv: Properly suspend/resume reenlightenment notifications
Errors during hibernation with reenlightenment notifications enabled were reported: [ 51.730435] PM: hibernation entry [ 51.737435] PM: Syncing filesystems ... ... [ 54.102216] Disabling non-boot CPUs ... [ 54.106633] smpboot: CPU 1 is now offline [ 54.110006] unchecked MSR access error: WRMSR to 0x40000106 (tried to write 0x47c72780000100ee) at rIP: 0xffffffff90062f24 native_write_msr+0x4/0x20) [ 54.110006] Call Trace: [ 54.110006] hv_cpu_die+0xd9/0xf0 ... Normally, hv_cpu_die() just reassigns reenlightenment notifications to some other CPU when the CPU receiving them goes offline. Upon hibernation, there is no other CPU which is still online so cpumask_any_but(cpu_online_mask) returns >= nr_cpu_ids and using it as hv_vp_index index is incorrect. Disable the feature when cpumask_any_but() fails. Also, as we now disable reenlightenment notifications upon hibernation we need to restore them on resume. Check if hv_reenlightenment_cb was previously set and restore from hv_resume(). Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Reviewed-by: Dexuan Cui <decui@microsoft.com> Reviewed-by: Tianyu Lan <Tianyu.Lan@microsoft.com> Link: https://lore.kernel.org/r/20200512160153.134467-1-vkuznets@redhat.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
This commit is contained in:
parent
f081bbb3fd
commit
38dce4195f
@ -226,10 +226,18 @@ static int hv_cpu_die(unsigned int cpu)
|
||||
|
||||
rdmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *((u64 *)&re_ctrl));
|
||||
if (re_ctrl.target_vp == hv_vp_index[cpu]) {
|
||||
/* Reassign to some other online CPU */
|
||||
/*
|
||||
* Reassign reenlightenment notifications to some other online
|
||||
* CPU or just disable the feature if there are no online CPUs
|
||||
* left (happens on hibernation).
|
||||
*/
|
||||
new_cpu = cpumask_any_but(cpu_online_mask, cpu);
|
||||
|
||||
re_ctrl.target_vp = hv_vp_index[new_cpu];
|
||||
if (new_cpu < nr_cpu_ids)
|
||||
re_ctrl.target_vp = hv_vp_index[new_cpu];
|
||||
else
|
||||
re_ctrl.enabled = 0;
|
||||
|
||||
wrmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *((u64 *)&re_ctrl));
|
||||
}
|
||||
|
||||
@ -293,6 +301,13 @@ static void hv_resume(void)
|
||||
|
||||
hv_hypercall_pg = hv_hypercall_pg_saved;
|
||||
hv_hypercall_pg_saved = NULL;
|
||||
|
||||
/*
|
||||
* Reenlightenment notifications are disabled by hv_cpu_die(0),
|
||||
* reenable them here if hv_reenlightenment_cb was previously set.
|
||||
*/
|
||||
if (hv_reenlightenment_cb)
|
||||
set_hv_tscchange_cb(hv_reenlightenment_cb);
|
||||
}
|
||||
|
||||
/* Note: when the ops are called, only CPU0 is online and IRQs are disabled. */
|
||||
|
Loading…
Reference in New Issue
Block a user