[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z9N6xWQV6e5Tufy4@ls.amr.corp.intel.com>
Date: Thu, 13 Mar 2025 17:39:33 -0700
From: Isaku Yamahata <isaku.yamahata@...el.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: Isaku Yamahata <isaku.yamahata@...el.com>, kvm@...r.kernel.org,
Sean Christopherson <seanjc@...gle.com>, chao.gao@...el.com,
rick.p.edgecombe@...el.com, yan.y.zhao@...el.com,
linux-kernel@...r.kernel.org, isaku.yamahata@...il.com,
Nikunj A Dadhania <nikunj@....com>,
Marcelo Tosatti <mtosatti@...hat.com>,
isaku.yamahata@...ux.intel.com
Subject: Re: [PATCH 2/2] KVM: x86: Don't allow tsc_offset, tsc_scaling_ratio
to change
On Wed, Mar 12, 2025 at 01:24:32PM +0100,
Paolo Bonzini <pbonzini@...hat.com> wrote:
> On 10/12/24 09:55, Isaku Yamahata wrote:
> > Add guest_tsc_protected member to struct kvm_arch_vcpu and prohibit
> > changing TSC offset/multiplier when guest_tsc_protected is true.
>
> Thanks Isaku! To match the behavior of the SEV-SNP patches, this is
> also needed, which I have added to kvm-coco-queue:
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index dc2f14a6d8a1..ccde7c2b2248 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3919,7 +3925,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
> case MSR_IA32_TSC:
> if (msr_info->host_initiated) {
> kvm_synchronize_tsc(vcpu, &data);
> - } else {
> + } else if (!vcpu->arch.guest_tsc_protected) {
> u64 adj = kvm_compute_l1_tsc_offset(vcpu, data) - vcpu->arch.l1_tsc_offset;
> adjust_tsc_offset_guest(vcpu, adj);
> vcpu->arch.ia32_tsc_adjust_msr += adj;
Thank you for catching this. This looks good.
--
Isaku Yamahata <isaku.yamahata@...el.com>
Powered by blists - more mailing lists