From: Isaku Yamahata <isaku.yamahata@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Isaku Yamahata <isaku.yamahata@intel.com>,
kvm@vger.kernel.org, Sean Christopherson <seanjc@google.com>,
chao.gao@intel.com, rick.p.edgecombe@intel.com,
yan.y.zhao@intel.com, linux-kernel@vger.kernel.org,
isaku.yamahata@gmail.com, Nikunj A Dadhania <nikunj@amd.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
isaku.yamahata@linux.intel.com
Subject: Re: [PATCH 2/2] KVM: x86: Don't allow tsc_offset, tsc_scaling_ratio to change
Date: Thu, 13 Mar 2025 17:39:33 -0700 [thread overview]
Message-ID: <Z9N6xWQV6e5Tufy4@ls.amr.corp.intel.com> (raw)
In-Reply-To: <510e0391-410b-40be-b556-f91554b8d3a1@redhat.com>
On Wed, Mar 12, 2025 at 01:24:32PM +0100,
Paolo Bonzini <pbonzini@redhat.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@intel.com>
next prev parent reply other threads:[~2025-03-14 14:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-12 7:55 [PATCH 0/2] KVM: kvm-coco-queue: Support protected TSC Isaku Yamahata
2024-10-12 7:55 ` [PATCH 1/2] KVM: x86: Push down setting vcpu.arch.user_set_tsc Isaku Yamahata
2024-10-12 7:55 ` [PATCH 2/2] KVM: x86: Don't allow tsc_offset, tsc_scaling_ratio to change Isaku Yamahata
2024-10-14 15:48 ` Edgecombe, Rick P
2024-11-21 23:50 ` Isaku Yamahata
2025-03-12 12:24 ` Paolo Bonzini
2025-03-14 0:39 ` Isaku Yamahata [this message]
2024-10-14 14:47 ` [PATCH 0/2] KVM: kvm-coco-queue: Support protected TSC Nikunj A. Dadhania
2024-10-25 16:24 ` Marcelo Tosatti
2024-10-27 14:06 ` Xiaoyao Li
2024-10-28 16:42 ` Marcelo Tosatti
2024-10-29 4:04 ` Nikunj A. Dadhania
2024-10-29 13:44 ` Marcelo Tosatti
2024-10-28 12:48 ` Nikunj A. Dadhania
2024-11-21 23:32 ` Isaku Yamahata
2025-03-12 1:13 ` Marcelo Tosatti
2025-03-14 0:43 ` Isaku Yamahata
2025-03-12 12:22 ` Paolo Bonzini
2025-03-12 13:07 ` Nikunj A. Dadhania
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z9N6xWQV6e5Tufy4@ls.amr.corp.intel.com \
--to=isaku.yamahata@intel.com \
--cc=chao.gao@intel.com \
--cc=isaku.yamahata@gmail.com \
--cc=isaku.yamahata@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=nikunj@amd.com \
--cc=pbonzini@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=yan.y.zhao@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®