lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Fri, 1 Apr 2022 01:10:04 -0700 From: Wanpeng Li <kernellwp@...il.com> To: linux-kernel@...r.kernel.org, kvm@...r.kernel.org Cc: Paolo Bonzini <pbonzini@...hat.com>, Sean Christopherson <seanjc@...gle.com>, Vitaly Kuznetsov <vkuznets@...hat.com>, Wanpeng Li <wanpengli@...cent.com>, Jim Mattson <jmattson@...gle.com>, Joerg Roedel <joro@...tes.org> Subject: [PATCH v2 4/5] x86/kvm: Add MSR_KVM_PREEMPT_COUNT guest support From: Wanpeng Li <wanpengli@...cent.com> The x86 guest passes the per-cpu preempt_count value to the hypervisor, so the hypervisor knows whether the guest is running in the critical section. Signed-off-by: Wanpeng Li <wanpengli@...cent.com> --- arch/x86/kernel/kvm.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 79e0b8d63ffa..5b900334de6e 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -366,6 +366,14 @@ static void kvm_guest_cpu_init(void) if (has_steal_clock) kvm_register_steal_time(); + + if (kvm_para_has_feature(KVM_FEATURE_PREEMPT_COUNT)) { + u64 pa = slow_virt_to_phys(this_cpu_ptr(&__preempt_count)) + | KVM_MSR_ENABLED; + wrmsrl(MSR_KVM_PREEMPT_COUNT, pa); + + pr_debug("setup pv preempt_count: cpu %d\n", smp_processor_id()); + } } static void kvm_pv_disable_apf(void) @@ -442,6 +450,8 @@ static void kvm_guest_cpu_offline(bool shutdown) if (!shutdown) apf_task_wake_all(); kvmclock_disable(); + if (kvm_para_has_feature(KVM_FEATURE_PREEMPT_COUNT)) + wrmsrl(MSR_KVM_PREEMPT_COUNT, 0); } static int kvm_cpu_online(unsigned int cpu) -- 2.25.1
Powered by blists - more mailing lists