From: Greg Kroah-Hartman Date: Tue, 5 Apr 2022 05:31:10 +0000 (+0200) Subject: 4.9-stable patches X-Git-Tag: v5.17.2~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6b4b4083f99f282dbe8f0f07b41662f3289e35da;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: kvm-x86-forbid-vmm-to-set-synic-stimer-msrs-when-synic-wasn-t-activated.patch --- diff --git a/queue-4.9/kvm-x86-forbid-vmm-to-set-synic-stimer-msrs-when-synic-wasn-t-activated.patch b/queue-4.9/kvm-x86-forbid-vmm-to-set-synic-stimer-msrs-when-synic-wasn-t-activated.patch new file mode 100644 index 00000000000..b16d796527d --- /dev/null +++ b/queue-4.9/kvm-x86-forbid-vmm-to-set-synic-stimer-msrs-when-synic-wasn-t-activated.patch @@ -0,0 +1,65 @@ +From b1e34d325397a33d97d845e312d7cf2a8b646b44 Mon Sep 17 00:00:00 2001 +From: Vitaly Kuznetsov +Date: Fri, 25 Mar 2022 14:21:40 +0100 +Subject: KVM: x86: Forbid VMM to set SYNIC/STIMER MSRs when SynIC wasn't activated + +From: Vitaly Kuznetsov + +commit b1e34d325397a33d97d845e312d7cf2a8b646b44 upstream. + +Setting non-zero values to SYNIC/STIMER MSRs activates certain features, +this should not happen when KVM_CAP_HYPERV_SYNIC{,2} was not activated. + +Note, it would've been better to forbid writing anything to SYNIC/STIMER +MSRs, including zeroes, however, at least QEMU tries clearing +HV_X64_MSR_STIMER0_CONFIG without SynIC. HV_X64_MSR_EOM MSR is somewhat +'special' as writing zero there triggers an action, this also should not +happen when SynIC wasn't activated. + +Signed-off-by: Vitaly Kuznetsov +Message-Id: <20220325132140.25650-4-vkuznets@redhat.com> +Cc: stable@vger.kernel.org +Signed-off-by: Paolo Bonzini +Signed-off-by: Greg Kroah-Hartman +--- + arch/x86/kvm/hyperv.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +--- a/arch/x86/kvm/hyperv.c ++++ b/arch/x86/kvm/hyperv.c +@@ -244,6 +244,9 @@ static int synic_set_msr(struct kvm_vcpu + case HV_X64_MSR_EOM: { + int i; + ++ if (!synic->active) ++ break; ++ + for (i = 0; i < ARRAY_SIZE(synic->sint); i++) + kvm_hv_notify_acked_sint(vcpu, i); + break; +@@ -504,6 +507,12 @@ static int stimer_start(struct kvm_vcpu_ + static int stimer_set_config(struct kvm_vcpu_hv_stimer *stimer, u64 config, + bool host) + { ++ struct kvm_vcpu *vcpu = stimer_to_vcpu(stimer); ++ struct kvm_vcpu_hv_synic *synic = vcpu_to_synic(vcpu); ++ ++ if (!synic->active && (!host || config)) ++ return 1; ++ + trace_kvm_hv_stimer_set_config(stimer_to_vcpu(stimer)->vcpu_id, + stimer->index, config, host); + +@@ -518,6 +527,12 @@ static int stimer_set_config(struct kvm_ + static int stimer_set_count(struct kvm_vcpu_hv_stimer *stimer, u64 count, + bool host) + { ++ struct kvm_vcpu *vcpu = stimer_to_vcpu(stimer); ++ struct kvm_vcpu_hv_synic *synic = vcpu_to_synic(vcpu); ++ ++ if (!synic->active && (!host || count)) ++ return 1; ++ + trace_kvm_hv_stimer_set_count(stimer_to_vcpu(stimer)->vcpu_id, + stimer->index, count, host); + diff --git a/queue-4.9/series b/queue-4.9/series index 01575459ef8..0b3a45c058e 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -160,3 +160,4 @@ asoc-topology-allow-tlv-control-to-be-either-read-or-write.patch arm-dts-spear1340-update-serial-node-properties.patch arm-dts-spear13xx-update-spi-dma-properties.patch openvswitch-fixed-nd-target-mask-field-in-the-flow-dump.patch +kvm-x86-forbid-vmm-to-set-synic-stimer-msrs-when-synic-wasn-t-activated.patch