mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-24 07:31:41 +00:00
x86/kvm: Unify kvm_pv_guest_cpu_reboot() with kvm_guest_cpu_offline()
Simplify the code by making PV features shutdown happen in one place. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Message-Id: <20210414123544.1060604-6-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
3d6b84132d
commit
384fc672f5
1 changed files with 17 additions and 25 deletions
|
@ -384,31 +384,6 @@ static void kvm_disable_steal_time(void)
|
||||||
wrmsr(MSR_KVM_STEAL_TIME, 0, 0);
|
wrmsr(MSR_KVM_STEAL_TIME, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void kvm_pv_guest_cpu_reboot(void *unused)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* We disable PV EOI before we load a new kernel by kexec,
|
|
||||||
* since MSR_KVM_PV_EOI_EN stores a pointer into old kernel's memory.
|
|
||||||
* New kernel can re-enable when it boots.
|
|
||||||
*/
|
|
||||||
if (kvm_para_has_feature(KVM_FEATURE_PV_EOI))
|
|
||||||
wrmsrl(MSR_KVM_PV_EOI_EN, 0);
|
|
||||||
kvm_pv_disable_apf();
|
|
||||||
kvm_disable_steal_time();
|
|
||||||
}
|
|
||||||
|
|
||||||
static int kvm_pv_reboot_notify(struct notifier_block *nb,
|
|
||||||
unsigned long code, void *unused)
|
|
||||||
{
|
|
||||||
if (code == SYS_RESTART)
|
|
||||||
on_each_cpu(kvm_pv_guest_cpu_reboot, NULL, 1);
|
|
||||||
return NOTIFY_DONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct notifier_block kvm_pv_reboot_nb = {
|
|
||||||
.notifier_call = kvm_pv_reboot_notify,
|
|
||||||
};
|
|
||||||
|
|
||||||
static u64 kvm_steal_clock(int cpu)
|
static u64 kvm_steal_clock(int cpu)
|
||||||
{
|
{
|
||||||
u64 steal;
|
u64 steal;
|
||||||
|
@ -687,6 +662,23 @@ static struct syscore_ops kvm_syscore_ops = {
|
||||||
.resume = kvm_resume,
|
.resume = kvm_resume,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void kvm_pv_guest_cpu_reboot(void *unused)
|
||||||
|
{
|
||||||
|
kvm_guest_cpu_offline(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int kvm_pv_reboot_notify(struct notifier_block *nb,
|
||||||
|
unsigned long code, void *unused)
|
||||||
|
{
|
||||||
|
if (code == SYS_RESTART)
|
||||||
|
on_each_cpu(kvm_pv_guest_cpu_reboot, NULL, 1);
|
||||||
|
return NOTIFY_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct notifier_block kvm_pv_reboot_nb = {
|
||||||
|
.notifier_call = kvm_pv_reboot_notify,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* After a PV feature is registered, the host will keep writing to the
|
* After a PV feature is registered, the host will keep writing to the
|
||||||
* registered memory location. If the guest happens to shutdown, this memory
|
* registered memory location. If the guest happens to shutdown, this memory
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue