Re: [PATCH v2 11/25] KVM: TDX: Add placeholders for TDX VM/vCPU structures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2024-10-30 at 19:00, Rick Edgecombe wrote:
> diff --git a/arch/x86/kvm/vmx/tdx.h b/arch/x86/kvm/vmx/tdx.h
> index 766a6121f670..e6a232d58e6a 100644
> --- a/arch/x86/kvm/vmx/tdx.h
> +++ b/arch/x86/kvm/vmx/tdx.h
> @@ -4,9 +4,58 @@
>  #ifdef CONFIG_INTEL_TDX_HOST
>  void tdx_bringup(void);
>  void tdx_cleanup(void);
> +
> +extern bool enable_tdx;
> +
> +struct kvm_tdx {
> +	struct kvm kvm;
> +	/* TDX specific members follow. */
> +};
> +
> +struct vcpu_tdx {
> +	struct kvm_vcpu	vcpu;
> +	/* TDX specific members follow. */
> +};
> +
> +static inline bool is_td(struct kvm *kvm)
> +{
> +	return kvm->arch.vm_type == KVM_X86_TDX_VM;
> +}
> +
> +static inline bool is_td_vcpu(struct kvm_vcpu *vcpu)
> +{
> +	return is_td(vcpu->kvm);
> +}
> +
> +static __always_inline struct kvm_tdx *to_kvm_tdx(struct kvm *kvm)
> +{
> +	return container_of(kvm, struct kvm_tdx, kvm);
> +}
> +
> +static __always_inline struct vcpu_tdx *to_tdx(struct kvm_vcpu
> *vcpu)
> +{
> +	return container_of(vcpu, struct vcpu_tdx, vcpu);
> +}
> +
>  #else
>  static inline void tdx_bringup(void) {}
>  static inline void tdx_cleanup(void) {}
> +
> +#define enable_tdx	0
> +
> +struct kvm_tdx {
> +	struct kvm kvm;
> +};
> +
> +struct vcpu_tdx {
> +	struct kvm_vcpu	vcpu;
> +};
> +
> +static inline bool is_td(struct kvm *kvm) { return false; }
> +static inline bool is_td_vcpu(struct kvm_vcpu *vcpu) { return false;
> }
> +static inline struct kvm_tdx *to_kvm_tdx(struct kvm *kvm) { return
> NULL; }
> +static inline struct vcpu_tdx *to_tdx(struct kvm_vcpu *vcpu) {
> return NULL; }

IMO the definitions of to_kvm_tdx() and to_tdx() shouldn't be there
when CONFIG_INTEL_TDX_HOST is not defined: they are (and should be)
only used in CONFIG_INTEL_TDX_HOST code.





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux