Re: [PATCH v3 14/17] KVM: x86/xen: register runstate info

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

 




On 12/14/20 8:39 AM, David Woodhouse wrote:

[...]

> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index b7dfcb4de92a..4b345a8945ea 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -523,10 +523,15 @@ struct kvm_vcpu_hv {
>  /* Xen HVM per vcpu emulation context */
>  struct kvm_vcpu_xen {
>  	u64 hypercall_rip;
> +	u32 current_runstate;
>  	bool vcpu_info_set;
>  	bool vcpu_time_info_set;
> +	bool runstate_set;
>  	struct gfn_to_hva_cache vcpu_info_cache;
>  	struct gfn_to_hva_cache vcpu_time_info_cache;
> +	struct gfn_to_hva_cache runstate_cache;
> +	u64 last_steal;
> +	u64 last_state_ns;
>  };
>  
>  struct kvm_vcpu_arch {

[...]

> @@ -78,7 +198,6 @@ int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
>  		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));
> @@ -110,6 +229,22 @@ int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
>  		kvm_make_request(KVM_REQ_CLOCK_UPDATE, v);
>  		break;
>  
> +	case KVM_XEN_ATTR_TYPE_VCPU_RUNSTATE:
> +		v = kvm_get_vcpu_by_id(kvm, data->u.vcpu_attr.vcpu_id);
> +		if (!v)
> +			return -EINVAL;
> +
> +		r = kvm_gfn_to_hva_cache_init(kvm, &v->arch.xen.runstate_cache,
> +					      data->u.vcpu_attr.gpa,
> +					      sizeof(struct vcpu_runstate_info));
> +		if (r)
> +			return r;
> +
> +		v->arch.xen.runstate_set = true;

Same as shared_info comment.

But maybe {shared_info,vcpu_info,runstate}_set could be instead turned into helpers
if it helps the cosmetics.

> +		v->arch.xen.current_runstate = RUNSTATE_blocked;
> +		v->arch.xen.last_state_ns = ktime_get_ns();
> +		break;
> +
>  	default:
>  		break;
>  	}
> @@ -157,6 +292,17 @@ int kvm_xen_hvm_get_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
>  		}
>  		break;
>  
> +	case KVM_XEN_ATTR_TYPE_VCPU_RUNSTATE:
> +		v = kvm_get_vcpu_by_id(kvm, data->u.vcpu_attr.vcpu_id);
> +		if (!v)
> +			return -EINVAL;
> +
> +		if (v->arch.xen.runstate_set) {
> +			data->u.vcpu_attr.gpa = v->arch.xen.runstate_cache.gpa;
> +			r = 0;
> +		}
> +		break;
> +
>  	default:
>  		break;
>  	}
> diff --git a/arch/x86/kvm/xen.h b/arch/x86/kvm/xen.h
> index 120b7450252a..407e717476d6 100644
> --- a/arch/x86/kvm/xen.h
> +++ b/arch/x86/kvm/xen.h
> @@ -9,6 +9,8 @@
>  #ifndef __ARCH_X86_KVM_XEN_H__
>  #define __ARCH_X86_KVM_XEN_H__
>  
> +void kvm_xen_setup_runstate_page(struct kvm_vcpu *vcpu);
> +void kvm_xen_runstate_set_preempted(struct kvm_vcpu *vcpu);
>  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 kvm_xen_hypercall(struct kvm_vcpu *vcpu);
> @@ -54,7 +56,12 @@ struct compat_shared_info {
>  	uint32_t evtchn_mask[32];
>  	struct pvclock_wall_clock wc;
>  	struct compat_arch_shared_info arch;
> -
>  };
>  

This change belos in the seventh patch I believe.



[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