Re: [PATCH v3 11/17] KVM: x86/xen: register vcpu info

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

 



On 12/14/20 8:38 AM, David Woodhouse wrote:
> diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
> index e5117a611737..4bc72e0b9928 100644
> --- a/arch/x86/kvm/xen.c
> +++ b/arch/x86/kvm/xen.c
> @@ -58,6 +58,7 @@ static int kvm_xen_shared_info_init(struct kvm *kvm, gfn_t gfn)
>  
>  int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
>  {
> +	struct kvm_vcpu *v;
>  	int r = -ENOENT;
>  
>  	switch (data->type) {
> @@ -73,6 +74,23 @@ int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
>  		r = kvm_xen_shared_info_init(kvm, data->u.shared_info.gfn);
>  		break;
>  
> +	case KVM_XEN_ATTR_TYPE_VCPU_INFO:
> +		v = kvm_get_vcpu_by_id(kvm, data->u.vcpu_attr.vcpu_id);
> +		if (!v)
> +			return -EINVAL;
> +
> +		/* No compat necessary here. */
> +		BUILD_BUG_ON(sizeof(struct vcpu_info) !=
> +			     sizeof(struct compat_vcpu_info));
> +		r = kvm_gfn_to_hva_cache_init(kvm, &v->arch.xen.vcpu_info_cache,
> +					      data->u.vcpu_attr.gpa,
> +					      sizeof(struct vcpu_info));
> +		if (r)
> +			return r;
> +
> +		v->arch.xen.vcpu_info_set = true;

Same comment as the shared_info page.

> +		break;
> +
>  	default:
>  		break;
>  	}
> @@ -83,6 +101,7 @@ int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
>  int kvm_xen_hvm_get_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
>  {
>  	int r = -ENOENT;
> +	struct kvm_vcpu *v;
>  
>  	switch (data->type) {
>  	case KVM_XEN_ATTR_TYPE_LONG_MODE:
> @@ -97,6 +116,17 @@ int kvm_xen_hvm_get_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
>  		}
>  		break;
>  
> +	case KVM_XEN_ATTR_TYPE_VCPU_INFO:
> +		v = kvm_get_vcpu_by_id(kvm, data->u.vcpu_attr.vcpu_id);
> +		if (!v)
> +			return -EINVAL;
> +
> +		if (v->arch.xen.vcpu_info_set) {
> +			data->u.vcpu_attr.gpa = v->arch.xen.vcpu_info_cache.gpa;
> +			r = 0;
> +		}
> +		break;
> +
>  	default:
>  		break;
>  	}
> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> index caa9faf3c5ad..87d150992f48 100644
> --- a/include/uapi/linux/kvm.h
> +++ b/include/uapi/linux/kvm.h
> @@ -1588,12 +1588,17 @@ struct kvm_xen_hvm_attr {
>  		struct {
>  			__u64 gfn;
>  		} shared_info;
> +		struct {
> +			__u32 vcpu_id;
> +			__u64 gpa;
> +		} vcpu_attr;
>  		__u64 pad[4];
>  	} u;
>  };
>  
>  #define KVM_XEN_ATTR_TYPE_LONG_MODE		0x0
>  #define KVM_XEN_ATTR_TYPE_SHARED_INFO		0x1
> +#define KVM_XEN_ATTR_TYPE_VCPU_INFO		0x2
>  
>  /* Secure Encrypted Virtualization command */
>  enum sev_cmd_id {
> 



[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