The vcpu info supersedes the per vcpu area of the shared info page and the guest vcpus will use this instead.
Unified · Split
| @@ -534,6 +534,8 @@ struct kvm_vcpu_hv { · 533 unmodified lines | ||
| 534 | 534 | /* Xen HVM per vcpu emulation context */ |
| 535 | 535 | struct kvm_vcpu_xen { |
| 536 | 536 | u64 hypercall_rip; |
| 537 | + bool vcpu_info_set; | |
| 538 | + struct gfn_to_hva_cache vcpu_info_cache; | |
| 537 | 539 | }; |
| 538 | 540 | |
| 539 | 541 | struct kvm_vcpu_arch { |
| @@ -120,15 +120,31 @@ int kvm_xen_hvm_get_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data) · 119 unmodified lines | ||
| 120 | 120 | |
| 121 | 121 | int 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 | 125 | mutex_lock(&vcpu->kvm->lock); |
| 126 | + idx = srcu_read_lock(&vcpu->kvm->srcu); | |
| 126 | 127 | |
| 127 | 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 | 143 | default: |
| 129 | 144 | break; |
| 130 | 145 | } |
| 131 | 146 | |
| 147 | + srcu_read_unlock(&vcpu->kvm->srcu, idx); | |
| 132 | 148 | mutex_unlock(&vcpu->kvm->lock); |
| 133 | 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 | 156 | mutex_lock(&vcpu->kvm->lock); |
| 141 | 157 | |
| 142 | 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 | 166 | default: |
| 144 | 167 | break; |
| 145 | 168 | } |
| @@ -1614,10 +1614,13 @@ struct kvm_xen_vcpu_attr { · 1613 unmodified lines | ||
| 1614 | 1614 | __u16 type; |
| 1615 | 1615 | __u16 pad[3]; |
| 1616 | 1616 | union { |
| 1617 | + __u64 gpa; | |
| 1617 | 1618 | __u64 pad[8]; |
| 1618 | 1619 | } u; |
| 1619 | 1620 | }; |
| 1620 | 1621 | |
| 1622 | +#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO 0x0 | |
| 1623 | + | |
| 1621 | 1624 | /* Secure Encrypted Virtualization command */ |
| 1622 | 1625 | enum sev_cmd_id { |
| 1623 | 1626 | /* Guest initialization commands */ |