History

KVM: x86/xen: register vcpu info

The vcpu info supersedes the per vcpu area of the shared info page and the guest vcpus will use this instead.

Joao Martins committed 8 years ago

Commit 73e69a81 parent 3e324613 files · +29 −1Browse files

Unified · Split

3 files
  1. arch/x86/include/asm/kvm_host.h +2 −0
  2. arch/x86/kvm/xen.c +24 −1
  3. include/uapi/linux/kvm.h +3 −0
arch/x86/include/asm/kvm_host.h+2−0
@@ -534,6 +534,8 @@ struct kvm_vcpu_hv { · 533 unmodified lines
534534 /* Xen HVM per vcpu emulation context */
535535 struct kvm_vcpu_xen {
536536 u64 hypercall_rip;
537+ bool vcpu_info_set;
538+ struct gfn_to_hva_cache vcpu_info_cache;
537539 };
538540
539541 struct kvm_vcpu_arch {
arch/x86/kvm/xen.c+24−1
@@ -120,15 +120,31 @@ int kvm_xen_hvm_get_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data) · 119 unmodified lines
120120
121121 int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
122122 {
123− int r = -ENOENT;
123+ int idx, r = -ENOENT;
124124
125125 mutex_lock(&vcpu->kvm->lock);
126+ idx = srcu_read_lock(&vcpu->kvm->srcu);
126127
127128 switch (data->type) {
129+ case KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO:
130+ /* No compat necessary here. */
131+ BUILD_BUG_ON(sizeof(struct vcpu_info) !=
132+ sizeof(struct compat_vcpu_info));
133+
134+ r = kvm_gfn_to_hva_cache_init(vcpu->kvm,
135+ &vcpu->arch.xen.vcpu_info_cache,
136+ data->u.gpa,
137+ sizeof(struct vcpu_info));
138+ if (!r)
139+ vcpu->arch.xen.vcpu_info_set = true;
140+ break;
141+
142+
128143 default:
129144 break;
130145 }
131146
147+ srcu_read_unlock(&vcpu->kvm->srcu, idx);
132148 mutex_unlock(&vcpu->kvm->lock);
133149 return r;
134150 }
@@ -140,6 +156,13 @@ int kvm_xen_vcpu_get_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data) · 5 unmodified lines
140156 mutex_lock(&vcpu->kvm->lock);
141157
142158 switch (data->type) {
159+ case KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO:
160+ if (vcpu->arch.xen.vcpu_info_set) {
161+ data->u.gpa = vcpu->arch.xen.vcpu_info_cache.gpa;
162+ r = 0;
163+ }
164+ break;
165+
143166 default:
144167 break;
145168 }
include/uapi/linux/kvm.h+3−0
@@ -1614,10 +1614,13 @@ struct kvm_xen_vcpu_attr { · 1613 unmodified lines
16141614 __u16 type;
16151615 __u16 pad[3];
16161616 union {
1617+ __u64 gpa;
16171618 __u64 pad[8];
16181619 } u;
16191620 };
16201621
1622+#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO 0x0
1623+
16211624 /* Secure Encrypted Virtualization command */
16221625 enum sev_cmd_id {
16231626 /* Guest initialization commands */