Pull KVM fixes from Paolo Bonzini: "KVM/ARM fixes: - Fix per-vcpu vgic bitmap allocation - Do not give copy random memory on MMIO read - Fix GICv3 APR register restore order KVM/x86 fixes: - Fix ubsan warning - Fix hardware breakpoints in a guest vs. preempt notifiers - Fix Hurd Generic: - use __GFP_NOWARN together with GFP_NOWAIT" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: x86: MMU: fix ubsan index-out-of-range warning arm64: KVM: vgic-v3: Restore ICH_APR0Rn_EL2 before ICH_APR1Rn_EL2 KVM: async_pf: do not warn on page allocation failures KVM: x86: fix conversion of addresses to linear in 32-bit protected mode KVM: x86: fix missed hardware breakpoints arm/arm64: KVM: Feed initialized memory to MMIO accesses KVM: arm/arm64: vgic: Ensure bitmaps are long enough
Unified · Split
| @@ -206,7 +206,8 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run, · 205 unmodified lines | ||
| 206 | 206 | run->mmio.is_write = is_write; |
| 207 | 207 | run->mmio.phys_addr = fault_ipa; |
| 208 | 208 | run->mmio.len = len; |
| 209 | − memcpy(run->mmio.data, data_buf, len); | |
| 209 | + if (is_write) | |
| 210 | + memcpy(run->mmio.data, data_buf, len); | |
| 210 | 211 | |
| 211 | 212 | if (!ret) { |
| 212 | 213 | /* We handled the access successfully in the kernel. */ |
| @@ -147,16 +147,6 @@ void __hyp_text __vgic_v3_restore_state(struct kvm_vcpu *vcpu) · 146 unmodified lines | ||
| 147 | 147 | max_lr_idx = vtr_to_max_lr_idx(val); |
| 148 | 148 | nr_pri_bits = vtr_to_nr_pri_bits(val); |
| 149 | 149 | |
| 150 | − switch (nr_pri_bits) { | |
| 151 | − case 7: | |
| 152 | − write_gicreg(cpu_if->vgic_ap1r[3], ICH_AP1R3_EL2); | |
| 153 | − write_gicreg(cpu_if->vgic_ap1r[2], ICH_AP1R2_EL2); | |
| 154 | − case 6: | |
| 155 | − write_gicreg(cpu_if->vgic_ap1r[1], ICH_AP1R1_EL2); | |
| 156 | − default: | |
| 157 | − write_gicreg(cpu_if->vgic_ap1r[0], ICH_AP1R0_EL2); | |
| 158 | − } | |
| 159 | − | |
| 160 | 150 | switch (nr_pri_bits) { |
| 161 | 151 | case 7: |
| 162 | 152 | write_gicreg(cpu_if->vgic_ap0r[3], ICH_AP0R3_EL2); |
| @@ -167,6 +157,16 @@ void __hyp_text __vgic_v3_restore_state(struct kvm_vcpu *vcpu) · 4 unmodified lines | ||
| 167 | 157 | write_gicreg(cpu_if->vgic_ap0r[0], ICH_AP0R0_EL2); |
| 168 | 158 | } |
| 169 | 159 | |
| 160 | + switch (nr_pri_bits) { | |
| 161 | + case 7: | |
| 162 | + write_gicreg(cpu_if->vgic_ap1r[3], ICH_AP1R3_EL2); | |
| 163 | + write_gicreg(cpu_if->vgic_ap1r[2], ICH_AP1R2_EL2); | |
| 164 | + case 6: | |
| 165 | + write_gicreg(cpu_if->vgic_ap1r[1], ICH_AP1R1_EL2); | |
| 166 | + default: | |
| 167 | + write_gicreg(cpu_if->vgic_ap1r[0], ICH_AP1R0_EL2); | |
| 168 | + } | |
| 169 | + | |
| 170 | 170 | switch (max_lr_idx) { |
| 171 | 171 | case 15: |
| 172 | 172 | write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(15)], ICH_LR15_EL2); |
| @@ -650,10 +650,10 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt, · 649 unmodified lines | ||
| 650 | 650 | u16 sel; |
| 651 | 651 | |
| 652 | 652 | la = seg_base(ctxt, addr.seg) + addr.ea; |
| 653 | − *linear = la; | |
| 654 | 653 | *max_size = 0; |
| 655 | 654 | switch (mode) { |
| 656 | 655 | case X86EMUL_MODE_PROT64: |
| 656 | + *linear = la; | |
| 657 | 657 | if (is_noncanonical_address(la)) |
| 658 | 658 | goto bad; |
| 659 | 659 | |
| @@ -662,6 +662,7 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt, · 2 unmodified lines | ||
| 662 | 662 | goto bad; |
| 663 | 663 | break; |
| 664 | 664 | default: |
| 665 | + *linear = la = (u32)la; | |
| 665 | 666 | usable = ctxt->ops->get_segment(ctxt, &sel, &desc, NULL, |
| 666 | 667 | addr.seg); |
| 667 | 668 | if (!usable) |
| @@ -689,7 +690,6 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt, · 21 unmodified lines | ||
| 689 | 690 | if (size > *max_size) |
| 690 | 691 | goto bad; |
| 691 | 692 | } |
| 692 | − la &= (u32)-1; | |
| 693 | 693 | break; |
| 694 | 694 | } |
| 695 | 695 | if (insn_aligned(ctxt, size) && ((la & (size - 1)) != 0)) |
| @@ -249,7 +249,7 @@ static int FNAME(update_accessed_dirty_bits)(struct kvm_vcpu *vcpu, · 248 unmodified lines | ||
| 249 | 249 | return ret; |
| 250 | 250 | |
| 251 | 251 | kvm_vcpu_mark_page_dirty(vcpu, table_gfn); |
| 252 | − walker->ptes[level] = pte; | |
| 252 | + walker->ptes[level - 1] = pte; | |
| 253 | 253 | } |
| 254 | 254 | return 0; |
| 255 | 255 | } |
| @@ -2752,6 +2752,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) · 2751 unmodified lines | ||
| 2752 | 2752 | } |
| 2753 | 2753 | |
| 2754 | 2754 | kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu); |
| 2755 | + vcpu->arch.switch_db_regs |= KVM_DEBUGREG_RELOAD; | |
| 2755 | 2756 | } |
| 2756 | 2757 | |
| 2757 | 2758 | void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) |
| @@ -1875,8 +1875,8 @@ void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu) · 1874 unmodified lines | ||
| 1875 | 1875 | static int vgic_vcpu_init_maps(struct kvm_vcpu *vcpu, int nr_irqs) |
| 1876 | 1876 | { |
| 1877 | 1877 | struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; |
| 1878 | − | |
| 1879 | − int sz = (nr_irqs - VGIC_NR_PRIVATE_IRQS) / 8; | |
| 1878 | + int nr_longs = BITS_TO_LONGS(nr_irqs - VGIC_NR_PRIVATE_IRQS); | |
| 1879 | + int sz = nr_longs * sizeof(unsigned long); | |
| 1880 | 1880 | vgic_cpu->pending_shared = kzalloc(sz, GFP_KERNEL); |
| 1881 | 1881 | vgic_cpu->active_shared = kzalloc(sz, GFP_KERNEL); |
| 1882 | 1882 | vgic_cpu->pend_act_shared = kzalloc(sz, GFP_KERNEL); |
| @@ -172,7 +172,7 @@ int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, unsigned long hva, · 171 unmodified lines | ||
| 172 | 172 | * do alloc nowait since if we are going to sleep anyway we |
| 173 | 173 | * may as well sleep faulting in page |
| 174 | 174 | */ |
| 175 | − work = kmem_cache_zalloc(async_pf_cache, GFP_NOWAIT); | |
| 175 | + work = kmem_cache_zalloc(async_pf_cache, GFP_NOWAIT | __GFP_NOWARN); | |
| 176 | 176 | if (!work) |
| 177 | 177 | return 0; |
| 178 | 178 | |