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
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9f857e72-7992-4c37-af51-bea059092c2a@amd.com>
Date: Wed, 12 Mar 2025 18:37:53 +0530
From: "Nikunj A. Dadhania" <nikunj@....com>
To: Paolo Bonzini <pbonzini@...hat.com>,
 Isaku Yamahata <isaku.yamahata@...el.com>, kvm@...r.kernel.org
Cc: 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,
 Marcelo Tosatti <mtosatti@...hat.com>
Subject: Re: [PATCH 0/2] KVM: kvm-coco-queue: Support protected TSC



On 3/12/2025 5:52 PM, Paolo Bonzini wrote:
> On 10/12/24 09:55, Isaku Yamahata wrote:
>> The current x86 KVM implementation conflicts with protected TSC because the
>> VMM can't change the TSC offset/multiplier.  Disable or ignore the KVM
>> logic to change/adjust the TSC offset/multiplier somehow.
>>
>> Because KVM emulates the TSC timer or the TSC deadline timer with the TSC
>> offset/multiplier, the TSC timer interrupts are injected to the guest at the
>> wrong time if the KVM TSC offset is different from what the TDX module
>> determined.
>>
>> Originally the issue was found by cyclic test of rt-test [1] as the latency in
>> TDX case is worse than VMX value + TDX SEAMCALL overhead.  It turned out that
>> the KVM TSC offset is different from what the TDX module determines.
>>
>> The solution is to keep the KVM TSC offset/multiplier the same as the value of
>> the TDX module somehow. [...] Ignore (or don't call related functions) the
>> request to change the TSC offset/multiplier.
>>
>> [...]  With this patch series, SEV-SNP secure TSC can be supported.
> 
> Thanks, I've squashed these changes (apart from setting
> vcpu->arch.guest_tsc_protected) into the corresponding patches in
> kvm-coco-queue.  Just one small change is needed in patch 2, to
> which I will reply.
> 
> For SEV-SNP, all that's necessary on top should be
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index d92e97baea0f..beddeed90ff0 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -2481,6 +2481,9 @@ static int snp_launch_update_vmsa(struct kvm *kvm, struct kvm_sev_cmd *argp)
>          }
>  
>          svm->vcpu.arch.guest_state_protected = true;
> +        if (snp_secure_tsc_enabled(kvm))
> +            svm->vcpu.arch.guest_tsc_protected = true;
> +
>          /*
>           * SEV-ES (and thus SNP) guest mandates LBR Virtualization to
>           * be _always_ ON. Enable it only after setting
> 
> For the sake of testing, I applied the latest SEV-SNP host patches
> from https://github.com/AMDESE/linux-kvm/commits/sectsc-host-latest
> to kvm-coco-queue as well, plus the above hunk; Nikunj can integrate
> it in the next revision of
> https://lore.kernel.org/kvm/20250310064347.13986-1-nikunj@amd.com/T/.

Sure Paolo, I will add the above changes in my next revision. 
Should I rebase the Secure TSC host patches on top of kvm-coco-queue ?

Regards
Nikunj

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ