Commit b2f31717 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull kvm fixes from Paolo Bonzini:
 "ARM64:

   - Pass the correct address to mte_clear_page_tags() on initialising a
     tagged page

   - Plug a race against a GICv4.1 doorbell interrupt while saving the
     vgic-v3 pending state.

  x86:

   - A command line parsing fix and a clang compilation fix for
     selftests

   - A fix for a longstanding VMX issue, that surprisingly was only
     found now to affect real world guests"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
  KVM: selftests: Make reclaim_period_ms input always be positive
  KVM: x86/vmx: Do not skip segment attributes if unusable bit is set
  selftests: kvm: move declaration at the beginning of main()
  KVM: arm64: GICv4.1: Fix race with doorbell on VPE activation/deactivation
  KVM: arm64: Pass the actual page address to mte_clear_page_tags()
parents 02db81a7 c2c46b10
...@@ -1079,7 +1079,7 @@ long kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm, ...@@ -1079,7 +1079,7 @@ long kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm,
/* uaccess failed, don't leave stale tags */ /* uaccess failed, don't leave stale tags */
if (num_tags != MTE_GRANULES_PER_PAGE) if (num_tags != MTE_GRANULES_PER_PAGE)
mte_clear_page_tags(page); mte_clear_page_tags(maddr);
set_page_mte_tagged(page); set_page_mte_tagged(page);
kvm_release_pfn_dirty(pfn); kvm_release_pfn_dirty(pfn);
......
...@@ -350,26 +350,23 @@ int vgic_v3_lpi_sync_pending_status(struct kvm *kvm, struct vgic_irq *irq) ...@@ -350,26 +350,23 @@ int vgic_v3_lpi_sync_pending_status(struct kvm *kvm, struct vgic_irq *irq)
* The deactivation of the doorbell interrupt will trigger the * The deactivation of the doorbell interrupt will trigger the
* unmapping of the associated vPE. * unmapping of the associated vPE.
*/ */
static void unmap_all_vpes(struct vgic_dist *dist) static void unmap_all_vpes(struct kvm *kvm)
{ {
struct irq_desc *desc; struct vgic_dist *dist = &kvm->arch.vgic;
int i; int i;
for (i = 0; i < dist->its_vm.nr_vpes; i++) { for (i = 0; i < dist->its_vm.nr_vpes; i++)
desc = irq_to_desc(dist->its_vm.vpes[i]->irq); free_irq(dist->its_vm.vpes[i]->irq, kvm_get_vcpu(kvm, i));
irq_domain_deactivate_irq(irq_desc_get_irq_data(desc));
}
} }
static void map_all_vpes(struct vgic_dist *dist) static void map_all_vpes(struct kvm *kvm)
{ {
struct irq_desc *desc; struct vgic_dist *dist = &kvm->arch.vgic;
int i; int i;
for (i = 0; i < dist->its_vm.nr_vpes; i++) { for (i = 0; i < dist->its_vm.nr_vpes; i++)
desc = irq_to_desc(dist->its_vm.vpes[i]->irq); WARN_ON(vgic_v4_request_vpe_irq(kvm_get_vcpu(kvm, i),
irq_domain_activate_irq(irq_desc_get_irq_data(desc), false); dist->its_vm.vpes[i]->irq));
}
} }
/** /**
...@@ -394,7 +391,7 @@ int vgic_v3_save_pending_tables(struct kvm *kvm) ...@@ -394,7 +391,7 @@ int vgic_v3_save_pending_tables(struct kvm *kvm)
* and enabling of the doorbells have already been done. * and enabling of the doorbells have already been done.
*/ */
if (kvm_vgic_global_state.has_gicv4_1) { if (kvm_vgic_global_state.has_gicv4_1) {
unmap_all_vpes(dist); unmap_all_vpes(kvm);
vlpi_avail = true; vlpi_avail = true;
} }
...@@ -444,7 +441,7 @@ int vgic_v3_save_pending_tables(struct kvm *kvm) ...@@ -444,7 +441,7 @@ int vgic_v3_save_pending_tables(struct kvm *kvm)
out: out:
if (vlpi_avail) if (vlpi_avail)
map_all_vpes(dist); map_all_vpes(kvm);
return ret; return ret;
} }
......
...@@ -222,6 +222,11 @@ void vgic_v4_get_vlpi_state(struct vgic_irq *irq, bool *val) ...@@ -222,6 +222,11 @@ void vgic_v4_get_vlpi_state(struct vgic_irq *irq, bool *val)
*val = !!(*ptr & mask); *val = !!(*ptr & mask);
} }
int vgic_v4_request_vpe_irq(struct kvm_vcpu *vcpu, int irq)
{
return request_irq(irq, vgic_v4_doorbell_handler, 0, "vcpu", vcpu);
}
/** /**
* vgic_v4_init - Initialize the GICv4 data structures * vgic_v4_init - Initialize the GICv4 data structures
* @kvm: Pointer to the VM being initialized * @kvm: Pointer to the VM being initialized
...@@ -283,8 +288,7 @@ int vgic_v4_init(struct kvm *kvm) ...@@ -283,8 +288,7 @@ int vgic_v4_init(struct kvm *kvm)
irq_flags &= ~IRQ_NOAUTOEN; irq_flags &= ~IRQ_NOAUTOEN;
irq_set_status_flags(irq, irq_flags); irq_set_status_flags(irq, irq_flags);
ret = request_irq(irq, vgic_v4_doorbell_handler, ret = vgic_v4_request_vpe_irq(vcpu, irq);
0, "vcpu", vcpu);
if (ret) { if (ret) {
kvm_err("failed to allocate vcpu IRQ%d\n", irq); kvm_err("failed to allocate vcpu IRQ%d\n", irq);
/* /*
......
...@@ -331,5 +331,6 @@ int vgic_v4_init(struct kvm *kvm); ...@@ -331,5 +331,6 @@ int vgic_v4_init(struct kvm *kvm);
void vgic_v4_teardown(struct kvm *kvm); void vgic_v4_teardown(struct kvm *kvm);
void vgic_v4_configure_vsgis(struct kvm *kvm); void vgic_v4_configure_vsgis(struct kvm *kvm);
void vgic_v4_get_vlpi_state(struct vgic_irq *irq, bool *val); void vgic_v4_get_vlpi_state(struct vgic_irq *irq, bool *val);
int vgic_v4_request_vpe_irq(struct kvm_vcpu *vcpu, int irq);
#endif #endif
...@@ -3440,18 +3440,15 @@ static u32 vmx_segment_access_rights(struct kvm_segment *var) ...@@ -3440,18 +3440,15 @@ static u32 vmx_segment_access_rights(struct kvm_segment *var)
{ {
u32 ar; u32 ar;
if (var->unusable || !var->present) ar = var->type & 15;
ar = 1 << 16; ar |= (var->s & 1) << 4;
else { ar |= (var->dpl & 3) << 5;
ar = var->type & 15; ar |= (var->present & 1) << 7;
ar |= (var->s & 1) << 4; ar |= (var->avl & 1) << 12;
ar |= (var->dpl & 3) << 5; ar |= (var->l & 1) << 13;
ar |= (var->present & 1) << 7; ar |= (var->db & 1) << 14;
ar |= (var->avl & 1) << 12; ar |= (var->g & 1) << 15;
ar |= (var->l & 1) << 13; ar |= (var->unusable || !var->present) << 16;
ar |= (var->db & 1) << 14;
ar |= (var->g & 1) << 15;
}
return ar; return ar;
} }
......
...@@ -241,7 +241,7 @@ int main(int argc, char **argv) ...@@ -241,7 +241,7 @@ int main(int argc, char **argv)
while ((opt = getopt(argc, argv, "hp:t:r")) != -1) { while ((opt = getopt(argc, argv, "hp:t:r")) != -1) {
switch (opt) { switch (opt) {
case 'p': case 'p':
reclaim_period_ms = atoi_non_negative("Reclaim period", optarg); reclaim_period_ms = atoi_positive("Reclaim period", optarg);
break; break;
case 't': case 't':
token = atoi_paranoid(optarg); token = atoi_paranoid(optarg);
......
...@@ -434,6 +434,7 @@ static void *juggle_shinfo_state(void *arg) ...@@ -434,6 +434,7 @@ static void *juggle_shinfo_state(void *arg)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct timespec min_ts, max_ts, vm_ts; struct timespec min_ts, max_ts, vm_ts;
struct kvm_xen_hvm_attr evt_reset;
struct kvm_vm *vm; struct kvm_vm *vm;
pthread_t thread; pthread_t thread;
bool verbose; bool verbose;
...@@ -962,10 +963,8 @@ int main(int argc, char *argv[]) ...@@ -962,10 +963,8 @@ int main(int argc, char *argv[])
} }
done: done:
struct kvm_xen_hvm_attr evt_reset = { evt_reset.type = KVM_XEN_ATTR_TYPE_EVTCHN;
.type = KVM_XEN_ATTR_TYPE_EVTCHN, evt_reset.u.evtchn.flags = KVM_XEN_EVTCHN_RESET;
.u.evtchn.flags = KVM_XEN_EVTCHN_RESET,
};
vm_ioctl(vm, KVM_XEN_HVM_SET_ATTR, &evt_reset); vm_ioctl(vm, KVM_XEN_HVM_SET_ATTR, &evt_reset);
alarm(0); alarm(0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment