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
534/* Xen HVM per vcpu emulation context */534/* Xen HVM per vcpu emulation context */
535struct kvm_vcpu_xen {535struct kvm_vcpu_xen {
536 u64 hypercall_rip;536 u64 hypercall_rip;
537 bool vcpu_info_set;
538 struct gfn_to_hva_cache vcpu_info_cache;
537};539};
538 540
539struct kvm_vcpu_arch {541struct 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
120 120
121int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)121int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
122{122{
123 int r = -ENOENT;123 int idx, r = -ENOENT;
124 124
125 mutex_lock(&vcpu->kvm->lock);125 mutex_lock(&vcpu->kvm->lock);
126 idx = srcu_read_lock(&vcpu->kvm->srcu);
126 127
127 switch (data->type) {128 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
128 default:143 default:
129 break;144 break;
130 }145 }
131 146
147 srcu_read_unlock(&vcpu->kvm->srcu, idx);
132 mutex_unlock(&vcpu->kvm->lock);148 mutex_unlock(&vcpu->kvm->lock);
133 return r;149 return r;
134}150}
@@ -140,6 +156,13 @@ int kvm_xen_vcpu_get_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data) · 5 unmodified lines
140 mutex_lock(&vcpu->kvm->lock);156 mutex_lock(&vcpu->kvm->lock);
141 157
142 switch (data->type) {158 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
143 default:166 default:
144 break;167 break;
145 }168 }
include/uapi/linux/kvm.h+3−0
@@ -1614,10 +1614,13 @@ struct kvm_xen_vcpu_attr { · 1613 unmodified lines
1614 __u16 type;1614 __u16 type;
1615 __u16 pad[3];1615 __u16 pad[3];
1616 union {1616 union {
1617 __u64 gpa;
1617 __u64 pad[8];1618 __u64 pad[8];
1618 } u;1619 } u;
1619};1620};
1620 1621
1622#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO 0x0
1623
1621/* Secure Encrypted Virtualization command */1624/* Secure Encrypted Virtualization command */
1622enum sev_cmd_id {1625enum sev_cmd_id {
1623 /* Guest initialization commands */1626 /* Guest initialization commands */