Skip to content

Commit 8155469

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM fixes from Paolo Bonzini: "s390: - SRCU fix PPC: - host crash fixes x86: - bugfixes, including making nested posted interrupts really work Generic: - tweaks to kvm_stat and to uevents" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: LAPIC: Fix reentrancy issues with preempt notifiers tools/kvm_stat: add '-f help' to get the available event list tools/kvm_stat: use variables instead of hard paths in help output KVM: nVMX: Fix loss of L2's NMI blocking state KVM: nVMX: Fix posted intr delivery when vcpu is in guest mode x86: irq: Define a global vector for nested posted interrupts KVM: x86: do mask out upper bits of PAE CR3 KVM: make pid available for uevents without debugfs KVM: s390: take srcu lock when getting/setting storage keys KVM: VMX: remove unused field KVM: PPC: Book3S HV: Fix host crash on changing HPT size KVM: PPC: Book3S HV: Enable TM before accessing TM registers
2 parents 8562e89 + 7b5e0a4 commit 8155469

File tree

16 files changed

+99
-49
lines changed

16 files changed

+99
-49
lines changed

arch/powerpc/kvm/book3s_64_mmu_hv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,10 @@ long kvmppc_alloc_reset_hpt(struct kvm *kvm, int order)
164164
goto out;
165165
}
166166

167-
if (kvm->arch.hpt.virt)
167+
if (kvm->arch.hpt.virt) {
168168
kvmppc_free_hpt(&kvm->arch.hpt);
169+
kvmppc_rmap_reset(kvm);
170+
}
169171

170172
err = kvmppc_allocate_hpt(&info, order);
171173
if (err < 0)

arch/powerpc/kvm/book3s_hv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3211,6 +3211,8 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
32113211
run->fail_entry.hardware_entry_failure_reason = 0;
32123212
return -EINVAL;
32133213
}
3214+
/* Enable TM so we can read the TM SPRs */
3215+
mtmsr(mfmsr() | MSR_TM);
32143216
current->thread.tm_tfhar = mfspr(SPRN_TFHAR);
32153217
current->thread.tm_tfiar = mfspr(SPRN_TFIAR);
32163218
current->thread.tm_texasr = mfspr(SPRN_TEXASR);

arch/s390/kvm/kvm-s390.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ static long kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
13241324
{
13251325
uint8_t *keys;
13261326
uint64_t hva;
1327-
int i, r = 0;
1327+
int srcu_idx, i, r = 0;
13281328

13291329
if (args->flags != 0)
13301330
return -EINVAL;
@@ -1342,6 +1342,7 @@ static long kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
13421342
return -ENOMEM;
13431343

13441344
down_read(&current->mm->mmap_sem);
1345+
srcu_idx = srcu_read_lock(&kvm->srcu);
13451346
for (i = 0; i < args->count; i++) {
13461347
hva = gfn_to_hva(kvm, args->start_gfn + i);
13471348
if (kvm_is_error_hva(hva)) {
@@ -1353,6 +1354,7 @@ static long kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
13531354
if (r)
13541355
break;
13551356
}
1357+
srcu_read_unlock(&kvm->srcu, srcu_idx);
13561358
up_read(&current->mm->mmap_sem);
13571359

13581360
if (!r) {
@@ -1370,7 +1372,7 @@ static long kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
13701372
{
13711373
uint8_t *keys;
13721374
uint64_t hva;
1373-
int i, r = 0;
1375+
int srcu_idx, i, r = 0;
13741376

13751377
if (args->flags != 0)
13761378
return -EINVAL;
@@ -1396,6 +1398,7 @@ static long kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
13961398
goto out;
13971399

13981400
down_read(&current->mm->mmap_sem);
1401+
srcu_idx = srcu_read_lock(&kvm->srcu);
13991402
for (i = 0; i < args->count; i++) {
14001403
hva = gfn_to_hva(kvm, args->start_gfn + i);
14011404
if (kvm_is_error_hva(hva)) {
@@ -1413,6 +1416,7 @@ static long kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
14131416
if (r)
14141417
break;
14151418
}
1419+
srcu_read_unlock(&kvm->srcu, srcu_idx);
14161420
up_read(&current->mm->mmap_sem);
14171421
out:
14181422
kvfree(keys);

arch/x86/entry/entry_64.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ apicinterrupt X86_PLATFORM_IPI_VECTOR x86_platform_ipi smp_x86_platform_ipi
705705
#ifdef CONFIG_HAVE_KVM
706706
apicinterrupt3 POSTED_INTR_VECTOR kvm_posted_intr_ipi smp_kvm_posted_intr_ipi
707707
apicinterrupt3 POSTED_INTR_WAKEUP_VECTOR kvm_posted_intr_wakeup_ipi smp_kvm_posted_intr_wakeup_ipi
708+
apicinterrupt3 POSTED_INTR_NESTED_VECTOR kvm_posted_intr_nested_ipi smp_kvm_posted_intr_nested_ipi
708709
#endif
709710

710711
#ifdef CONFIG_X86_MCE_THRESHOLD

arch/x86/include/asm/entry_arch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ BUILD_INTERRUPT3(kvm_posted_intr_ipi, POSTED_INTR_VECTOR,
2525
smp_kvm_posted_intr_ipi)
2626
BUILD_INTERRUPT3(kvm_posted_intr_wakeup_ipi, POSTED_INTR_WAKEUP_VECTOR,
2727
smp_kvm_posted_intr_wakeup_ipi)
28+
BUILD_INTERRUPT3(kvm_posted_intr_nested_ipi, POSTED_INTR_NESTED_VECTOR,
29+
smp_kvm_posted_intr_nested_ipi)
2830
#endif
2931

3032
/*

arch/x86/include/asm/hardirq.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ typedef struct {
1515
#ifdef CONFIG_HAVE_KVM
1616
unsigned int kvm_posted_intr_ipis;
1717
unsigned int kvm_posted_intr_wakeup_ipis;
18+
unsigned int kvm_posted_intr_nested_ipis;
1819
#endif
1920
unsigned int x86_platform_ipis; /* arch dependent */
2021
unsigned int apic_perf_irqs;

arch/x86/include/asm/hw_irq.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extern asmlinkage void apic_timer_interrupt(void);
3030
extern asmlinkage void x86_platform_ipi(void);
3131
extern asmlinkage void kvm_posted_intr_ipi(void);
3232
extern asmlinkage void kvm_posted_intr_wakeup_ipi(void);
33+
extern asmlinkage void kvm_posted_intr_nested_ipi(void);
3334
extern asmlinkage void error_interrupt(void);
3435
extern asmlinkage void irq_work_interrupt(void);
3536

@@ -62,6 +63,7 @@ extern void trace_call_function_single_interrupt(void);
6263
#define trace_reboot_interrupt reboot_interrupt
6364
#define trace_kvm_posted_intr_ipi kvm_posted_intr_ipi
6465
#define trace_kvm_posted_intr_wakeup_ipi kvm_posted_intr_wakeup_ipi
66+
#define trace_kvm_posted_intr_nested_ipi kvm_posted_intr_nested_ipi
6567
#endif /* CONFIG_TRACING */
6668

6769
#ifdef CONFIG_X86_LOCAL_APIC

arch/x86/include/asm/irq_vectors.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
*/
8484
#define X86_PLATFORM_IPI_VECTOR 0xf7
8585

86-
#define POSTED_INTR_WAKEUP_VECTOR 0xf1
8786
/*
8887
* IRQ work vector:
8988
*/
@@ -98,6 +97,8 @@
9897
/* Vector for KVM to deliver posted interrupt IPI */
9998
#ifdef CONFIG_HAVE_KVM
10099
#define POSTED_INTR_VECTOR 0xf2
100+
#define POSTED_INTR_WAKEUP_VECTOR 0xf1
101+
#define POSTED_INTR_NESTED_VECTOR 0xf0
101102
#endif
102103

103104
/*

arch/x86/kernel/irq.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ int arch_show_interrupts(struct seq_file *p, int prec)
155155
seq_printf(p, "%10u ", irq_stats(j)->kvm_posted_intr_ipis);
156156
seq_puts(p, " Posted-interrupt notification event\n");
157157

158+
seq_printf(p, "%*s: ", prec, "NPI");
159+
for_each_online_cpu(j)
160+
seq_printf(p, "%10u ",
161+
irq_stats(j)->kvm_posted_intr_nested_ipis);
162+
seq_puts(p, " Nested posted-interrupt event\n");
163+
158164
seq_printf(p, "%*s: ", prec, "PIW");
159165
for_each_online_cpu(j)
160166
seq_printf(p, "%10u ",
@@ -313,6 +319,19 @@ __visible void smp_kvm_posted_intr_wakeup_ipi(struct pt_regs *regs)
313319
exiting_irq();
314320
set_irq_regs(old_regs);
315321
}
322+
323+
/*
324+
* Handler for POSTED_INTERRUPT_NESTED_VECTOR.
325+
*/
326+
__visible void smp_kvm_posted_intr_nested_ipi(struct pt_regs *regs)
327+
{
328+
struct pt_regs *old_regs = set_irq_regs(regs);
329+
330+
entering_ack_irq();
331+
inc_irq_stat(kvm_posted_intr_nested_ipis);
332+
exiting_irq();
333+
set_irq_regs(old_regs);
334+
}
316335
#endif
317336

318337
__visible void __irq_entry smp_trace_x86_platform_ipi(struct pt_regs *regs)

arch/x86/kernel/irqinit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ static void __init apic_intr_init(void)
150150
alloc_intr_gate(POSTED_INTR_VECTOR, kvm_posted_intr_ipi);
151151
/* IPI for KVM to deliver interrupt to wake up tasks */
152152
alloc_intr_gate(POSTED_INTR_WAKEUP_VECTOR, kvm_posted_intr_wakeup_ipi);
153+
/* IPI for KVM to deliver nested posted interrupt */
154+
alloc_intr_gate(POSTED_INTR_NESTED_VECTOR, kvm_posted_intr_nested_ipi);
153155
#endif
154156

155157
/* IPI vectors for APIC spurious and error interrupts */

0 commit comments

Comments
 (0)