mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 18:43:33 +02:00
KVM: TDX: Add methods to ignore accesses to TSC
TDX protects TDX guest TSC state from VMM. Implement access methods to ignore guest TSC. Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com> Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com> Message-ID: <20250227012021.1778144-16-binbin.wu@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
a946c71cf8
commit
cf5f3668c5
|
|
@ -786,6 +786,42 @@ static int vt_set_identity_map_addr(struct kvm *kvm, u64 ident_addr)
|
|||
return vmx_set_identity_map_addr(kvm, ident_addr);
|
||||
}
|
||||
|
||||
static u64 vt_get_l2_tsc_offset(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
/* TDX doesn't support L2 guest at the moment. */
|
||||
if (is_td_vcpu(vcpu))
|
||||
return 0;
|
||||
|
||||
return vmx_get_l2_tsc_offset(vcpu);
|
||||
}
|
||||
|
||||
static u64 vt_get_l2_tsc_multiplier(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
/* TDX doesn't support L2 guest at the moment. */
|
||||
if (is_td_vcpu(vcpu))
|
||||
return 0;
|
||||
|
||||
return vmx_get_l2_tsc_multiplier(vcpu);
|
||||
}
|
||||
|
||||
static void vt_write_tsc_offset(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
/* In TDX, tsc offset can't be changed. */
|
||||
if (is_td_vcpu(vcpu))
|
||||
return;
|
||||
|
||||
vmx_write_tsc_offset(vcpu);
|
||||
}
|
||||
|
||||
static void vt_write_tsc_multiplier(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
/* In TDX, tsc multiplier can't be changed. */
|
||||
if (is_td_vcpu(vcpu))
|
||||
return;
|
||||
|
||||
vmx_write_tsc_multiplier(vcpu);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
static int vt_set_hv_timer(struct kvm_vcpu *vcpu, u64 guest_deadline_tsc,
|
||||
bool *expired)
|
||||
|
|
@ -944,10 +980,10 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
|
|||
|
||||
.has_wbinvd_exit = cpu_has_vmx_wbinvd_exit,
|
||||
|
||||
.get_l2_tsc_offset = vmx_get_l2_tsc_offset,
|
||||
.get_l2_tsc_multiplier = vmx_get_l2_tsc_multiplier,
|
||||
.write_tsc_offset = vmx_write_tsc_offset,
|
||||
.write_tsc_multiplier = vmx_write_tsc_multiplier,
|
||||
.get_l2_tsc_offset = vt_get_l2_tsc_offset,
|
||||
.get_l2_tsc_multiplier = vt_get_l2_tsc_multiplier,
|
||||
.write_tsc_offset = vt_write_tsc_offset,
|
||||
.write_tsc_multiplier = vt_write_tsc_multiplier,
|
||||
|
||||
.load_mmu_pgd = vt_load_mmu_pgd,
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user