Skip to content

Commit 9db5959

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull more KVM updates from Paolo Bonzini: - PPC bugfixes - RCU splat fix - swait races fix - pointless userspace-triggerable BUG() fix - misc fixes for KVM_RUN corner cases - nested virt correctness fixes + one host DoS - some cleanups - clang build fix - fix AMD AVIC with default QEMU command line options - x86 bugfixes * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (28 commits) kvm: nVMX: Handle deferred early VMLAUNCH/VMRESUME failure properly kvm: vmx: Handle VMLAUNCH/VMRESUME failure properly kvm: nVMX: Remove nested_vmx_succeed after successful VM-entry kvm,mips: Fix potential swait_active() races kvm,powerpc: Serialize wq active checks in ops->vcpu_kick kvm: Serialize wq active checks in kvm_vcpu_wake_up() kvm,x86: Fix apf_task_wake_one() wq serialization kvm,lapic: Justify use of swait_active() kvm,async_pf: Use swq_has_sleeper() sched/wait: Add swq_has_sleeper() KVM: VMX: Do not BUG() on out-of-bounds guest IRQ KVM: Don't accept obviously wrong gsi values via KVM_IRQFD kvm: nVMX: Don't allow L2 to access the hardware CR8 KVM: trace events: update list of exit reasons KVM: async_pf: Fix #DF due to inject "Page not Present" and "Page Ready" exceptions simultaneously KVM: X86: Don't block vCPU if there is pending exception KVM: SVM: Add irqchip_split() checks before enabling AVIC KVM: Add struct kvm_vcpu pointer parameter to get_enable_apicv() KVM: SVM: Refactor AVIC vcpu initialization into avic_init_vcpu() KVM: x86: fix clang build ...
2 parents b38923a + 4f350c6 commit 9db5959

18 files changed

Lines changed: 257 additions & 111 deletions

File tree

arch/mips/kvm/mips.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
514514

515515
dvcpu->arch.wait = 0;
516516

517-
if (swait_active(&dvcpu->wq))
517+
if (swq_has_sleeper(&dvcpu->wq))
518518
swake_up(&dvcpu->wq);
519519

520520
return 0;
@@ -1179,7 +1179,7 @@ static void kvm_mips_comparecount_func(unsigned long data)
11791179
kvm_mips_callbacks->queue_timer_int(vcpu);
11801180

11811181
vcpu->arch.wait = 0;
1182-
if (swait_active(&vcpu->wq))
1182+
if (swq_has_sleeper(&vcpu->wq))
11831183
swake_up(&vcpu->wq);
11841184
}
11851185

arch/powerpc/kvm/book3s_hv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static void kvmppc_fast_vcpu_kick_hv(struct kvm_vcpu *vcpu)
181181
struct swait_queue_head *wqp;
182182

183183
wqp = kvm_arch_vcpu_wq(vcpu);
184-
if (swait_active(wqp)) {
184+
if (swq_has_sleeper(wqp)) {
185185
swake_up(wqp);
186186
++vcpu->stat.halt_wakeup;
187187
}
@@ -4212,11 +4212,13 @@ static int kvmhv_configure_mmu(struct kvm *kvm, struct kvm_ppc_mmuv3_cfg *cfg)
42124212
if ((cfg->process_table & PRTS_MASK) > 24)
42134213
return -EINVAL;
42144214

4215+
mutex_lock(&kvm->lock);
42154216
kvm->arch.process_table = cfg->process_table;
42164217
kvmppc_setup_partition_table(kvm);
42174218

42184219
lpcr = (cfg->flags & KVM_PPC_MMUV3_GTSE) ? LPCR_GTSE : 0;
42194220
kvmppc_update_lpcr(kvm, lpcr, LPCR_GTSE);
4221+
mutex_unlock(&kvm->lock);
42204222

42214223
return 0;
42224224
}

arch/powerpc/kvm/book3s_hv_rm_xive.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ static inline void __iomem *get_tima_phys(void)
3838
#define __x_tima get_tima_phys()
3939
#define __x_eoi_page(xd) ((void __iomem *)((xd)->eoi_page))
4040
#define __x_trig_page(xd) ((void __iomem *)((xd)->trig_page))
41-
#define __x_readb __raw_rm_readb
4241
#define __x_writeb __raw_rm_writeb
4342
#define __x_readw __raw_rm_readw
4443
#define __x_readq __raw_rm_readq

arch/powerpc/kvm/book3s_hv_rmhandlers.S

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,9 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
771771

772772
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
773773
BEGIN_FTR_SECTION
774+
/*
775+
* NOTE THAT THIS TRASHES ALL NON-VOLATILE REGISTERS INCLUDING CR
776+
*/
774777
bl kvmppc_restore_tm
775778
END_FTR_SECTION_IFSET(CPU_FTR_TM)
776779
#endif
@@ -1630,6 +1633,9 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_300)
16301633

16311634
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
16321635
BEGIN_FTR_SECTION
1636+
/*
1637+
* NOTE THAT THIS TRASHES ALL NON-VOLATILE REGISTERS INCLUDING CR
1638+
*/
16331639
bl kvmppc_save_tm
16341640
END_FTR_SECTION_IFSET(CPU_FTR_TM)
16351641
#endif
@@ -1749,7 +1755,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
17491755
/*
17501756
* Are we running hash or radix ?
17511757
*/
1752-
beq cr2,3f
1758+
ld r5, VCPU_KVM(r9)
1759+
lbz r0, KVM_RADIX(r5)
1760+
cmpwi cr2, r0, 0
1761+
beq cr2, 3f
17531762

17541763
/* Radix: Handle the case where the guest used an illegal PID */
17551764
LOAD_REG_ADDR(r4, mmu_base_pid)
@@ -2466,6 +2475,9 @@ _GLOBAL(kvmppc_h_cede) /* r3 = vcpu pointer, r11 = msr, r13 = paca */
24662475

24672476
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
24682477
BEGIN_FTR_SECTION
2478+
/*
2479+
* NOTE THAT THIS TRASHES ALL NON-VOLATILE REGISTERS INCLUDING CR
2480+
*/
24692481
ld r9, HSTATE_KVM_VCPU(r13)
24702482
bl kvmppc_save_tm
24712483
END_FTR_SECTION_IFSET(CPU_FTR_TM)
@@ -2578,6 +2590,9 @@ kvm_end_cede:
25782590

25792591
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
25802592
BEGIN_FTR_SECTION
2593+
/*
2594+
* NOTE THAT THIS TRASHES ALL NON-VOLATILE REGISTERS INCLUDING CR
2595+
*/
25812596
bl kvmppc_restore_tm
25822597
END_FTR_SECTION_IFSET(CPU_FTR_TM)
25832598
#endif

arch/powerpc/kvm/book3s_xive.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#define __x_tima xive_tima
4949
#define __x_eoi_page(xd) ((void __iomem *)((xd)->eoi_mmio))
5050
#define __x_trig_page(xd) ((void __iomem *)((xd)->trig_mmio))
51-
#define __x_readb __raw_readb
5251
#define __x_writeb __raw_writeb
5352
#define __x_readw __raw_readw
5453
#define __x_readq __raw_readq

arch/powerpc/kvm/book3s_xive_template.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ static void GLUE(X_PFX,ack_pending)(struct kvmppc_xive_vcpu *xc)
2828
* bit.
2929
*/
3030
if (cpu_has_feature(CPU_FTR_POWER9_DD1)) {
31-
u8 pipr = __x_readb(__x_tima + TM_QW1_OS + TM_PIPR);
31+
__be64 qw1 = __x_readq(__x_tima + TM_QW1_OS);
32+
u8 pipr = be64_to_cpu(qw1) & 0xff;
3233
if (pipr >= xc->hw_cppr)
3334
return;
3435
}
@@ -336,7 +337,6 @@ X_STATIC unsigned long GLUE(X_PFX,h_ipoll)(struct kvm_vcpu *vcpu, unsigned long
336337
struct kvmppc_xive_vcpu *xc = vcpu->arch.xive_vcpu;
337338
u8 pending = xc->pending;
338339
u32 hirq;
339-
u8 pipr;
340340

341341
pr_devel("H_IPOLL(server=%ld)\n", server);
342342

@@ -353,7 +353,8 @@ X_STATIC unsigned long GLUE(X_PFX,h_ipoll)(struct kvm_vcpu *vcpu, unsigned long
353353
pending = 0xff;
354354
} else {
355355
/* Grab pending interrupt if any */
356-
pipr = __x_readb(__x_tima + TM_QW1_OS + TM_PIPR);
356+
__be64 qw1 = __x_readq(__x_tima + TM_QW1_OS);
357+
u8 pipr = be64_to_cpu(qw1) & 0xff;
357358
if (pipr < 8)
358359
pending |= 1 << pipr;
359360
}

arch/x86/include/asm/kvm_host.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,6 @@ struct kvm_x86_ops {
951951
void (*cache_reg)(struct kvm_vcpu *vcpu, enum kvm_reg reg);
952952
unsigned long (*get_rflags)(struct kvm_vcpu *vcpu);
953953
void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags);
954-
u32 (*get_pkru)(struct kvm_vcpu *vcpu);
955954

956955
void (*tlb_flush)(struct kvm_vcpu *vcpu);
957956

@@ -973,7 +972,7 @@ struct kvm_x86_ops {
973972
void (*enable_nmi_window)(struct kvm_vcpu *vcpu);
974973
void (*enable_irq_window)(struct kvm_vcpu *vcpu);
975974
void (*update_cr8_intercept)(struct kvm_vcpu *vcpu, int tpr, int irr);
976-
bool (*get_enable_apicv)(void);
975+
bool (*get_enable_apicv)(struct kvm_vcpu *vcpu);
977976
void (*refresh_apicv_exec_ctrl)(struct kvm_vcpu *vcpu);
978977
void (*hwapic_irr_update)(struct kvm_vcpu *vcpu, int max_irr);
979978
void (*hwapic_isr_update)(struct kvm_vcpu *vcpu, int isr);

arch/x86/kernel/kvm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static void apf_task_wake_one(struct kvm_task_sleep_node *n)
180180
hlist_del_init(&n->link);
181181
if (n->halted)
182182
smp_send_reschedule(n->cpu);
183-
else if (swait_active(&n->wq))
183+
else if (swq_has_sleeper(&n->wq))
184184
swake_up(&n->wq);
185185
}
186186

arch/x86/kvm/cpuid.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ static __always_inline struct cpuid_reg x86_feature_cpuid(unsigned x86_feature)
5959
{
6060
unsigned x86_leaf = x86_feature / 32;
6161

62-
BUILD_BUG_ON(!__builtin_constant_p(x86_leaf));
6362
BUILD_BUG_ON(x86_leaf >= ARRAY_SIZE(reverse_cpuid));
6463
BUILD_BUG_ON(reverse_cpuid[x86_leaf].function == 0);
6564

arch/x86/kvm/lapic.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,10 @@ static void apic_timer_expired(struct kvm_lapic *apic)
13241324
atomic_inc(&apic->lapic_timer.pending);
13251325
kvm_set_pending_timer(vcpu);
13261326

1327+
/*
1328+
* For x86, the atomic_inc() is serialized, thus
1329+
* using swait_active() is safe.
1330+
*/
13271331
if (swait_active(q))
13281332
swake_up(q);
13291333

0 commit comments

Comments
 (0)