Skip to content

Commit 862f0a3

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM fixes from Paolo Bonzini: "The usual smattering of fixes and tunings that came in too late for the merge window, but should not wait four months before they appear in a release. I also travelled a bit more than usual in the first part of May, which didn't help with picking up patches and reports promptly" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (33 commits) KVM: x86: fix return value for reserved EFER tools/kvm_stat: fix fields filter for child events KVM: selftests: Wrap vcpu_nested_state_get/set functions with x86 guard kvm: selftests: aarch64: compile with warnings on kvm: selftests: aarch64: fix default vm mode kvm: selftests: aarch64: dirty_log_test: fix unaligned memslot size KVM: s390: fix memory slot handling for KVM_SET_USER_MEMORY_REGION KVM: x86/pmu: do not mask the value that is written to fixed PMUs KVM: x86/pmu: mask the result of rdpmc according to the width of the counters x86/kvm/pmu: Set AMD's virt PMU version to 1 KVM: x86: do not spam dmesg with VMCS/VMCB dumps kvm: Check irqchip mode before assign irqfd kvm: svm/avic: fix off-by-one in checking host APIC ID KVM: selftests: do not blindly clobber registers in guest asm KVM: selftests: Remove duplicated TEST_ASSERT in hyperv_cpuid.c KVM: LAPIC: Expose per-vCPU timer_advance_ns to userspace KVM: LAPIC: Fix lapic_timer_advance_ns parameter overflow kvm: vmx: Fix -Wmissing-prototypes warnings KVM: nVMX: Fix using __this_cpu_read() in preemptible context kvm: fix compilation on s390 ...
2 parents 128f2bf + 66f61c9 commit 862f0a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+399
-303
lines changed

MAINTAINERS

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8611,14 +8611,12 @@ F: arch/x86/include/asm/svm.h
86118611
F: arch/x86/kvm/svm.c
86128612

86138613
KERNEL VIRTUAL MACHINE FOR ARM/ARM64 (KVM/arm, KVM/arm64)
8614-
M: Christoffer Dall <[email protected]>
86158614
M: Marc Zyngier <[email protected]>
86168615
R: James Morse <[email protected]>
86178616
R: Julien Thierry <[email protected]>
86188617
R: Suzuki K Pouloze <[email protected]>
86198618
L: [email protected] (moderated for non-subscribers)
86208619
8621-
W: http://systems.cs.columbia.edu/projects/kvm-arm
86228620
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git
86238621
S: Maintained
86248622
F: arch/arm/include/uapi/asm/kvm*

arch/arm/kvm/hyp/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CFLAGS_ARMV7VE :=$(call cc-option, -march=armv7ve)
1111

1212
obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/vgic-v3-sr.o
1313
obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/timer-sr.o
14+
obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/aarch32.o
1415

1516
obj-$(CONFIG_KVM_ARM_HOST) += tlb.o
1617
obj-$(CONFIG_KVM_ARM_HOST) += cp15-sr.o

arch/arm64/include/asm/kvm_host.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,9 +592,6 @@ static inline int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu)
592592
void kvm_set_pmu_events(u32 set, struct perf_event_attr *attr);
593593
void kvm_clr_pmu_events(u32 clr);
594594

595-
void __pmu_switch_to_host(struct kvm_cpu_context *host_ctxt);
596-
bool __pmu_switch_to_guest(struct kvm_cpu_context *host_ctxt);
597-
598595
void kvm_vcpu_pmu_restore_guest(struct kvm_vcpu *vcpu);
599596
void kvm_vcpu_pmu_restore_host(struct kvm_vcpu *vcpu);
600597
#else

arch/arm64/kvm/hyp/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ KVM=../../../../virt/kvm
1010

1111
obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/vgic-v3-sr.o
1212
obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/timer-sr.o
13+
obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/aarch32.o
1314

1415
obj-$(CONFIG_KVM_ARM_HOST) += vgic-v2-cpuif-proxy.o
1516
obj-$(CONFIG_KVM_ARM_HOST) += sysreg-sr.o

arch/arm64/kvm/hyp/switch.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
#include <linux/arm-smccc.h>
19+
#include <linux/kvm_host.h>
1920
#include <linux/types.h>
2021
#include <linux/jump_label.h>
2122
#include <uapi/linux/psci.h>
@@ -505,6 +506,44 @@ static void __hyp_text __set_host_arch_workaround_state(struct kvm_vcpu *vcpu)
505506
#endif
506507
}
507508

509+
/**
510+
* Disable host events, enable guest events
511+
*/
512+
static bool __hyp_text __pmu_switch_to_guest(struct kvm_cpu_context *host_ctxt)
513+
{
514+
struct kvm_host_data *host;
515+
struct kvm_pmu_events *pmu;
516+
517+
host = container_of(host_ctxt, struct kvm_host_data, host_ctxt);
518+
pmu = &host->pmu_events;
519+
520+
if (pmu->events_host)
521+
write_sysreg(pmu->events_host, pmcntenclr_el0);
522+
523+
if (pmu->events_guest)
524+
write_sysreg(pmu->events_guest, pmcntenset_el0);
525+
526+
return (pmu->events_host || pmu->events_guest);
527+
}
528+
529+
/**
530+
* Disable guest events, enable host events
531+
*/
532+
static void __hyp_text __pmu_switch_to_host(struct kvm_cpu_context *host_ctxt)
533+
{
534+
struct kvm_host_data *host;
535+
struct kvm_pmu_events *pmu;
536+
537+
host = container_of(host_ctxt, struct kvm_host_data, host_ctxt);
538+
pmu = &host->pmu_events;
539+
540+
if (pmu->events_guest)
541+
write_sysreg(pmu->events_guest, pmcntenclr_el0);
542+
543+
if (pmu->events_host)
544+
write_sysreg(pmu->events_host, pmcntenset_el0);
545+
}
546+
508547
/* Switch to the guest for VHE systems running in EL2 */
509548
int kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu)
510549
{

arch/arm64/kvm/pmu.c

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -53,44 +53,6 @@ void kvm_clr_pmu_events(u32 clr)
5353
ctx->pmu_events.events_guest &= ~clr;
5454
}
5555

56-
/**
57-
* Disable host events, enable guest events
58-
*/
59-
bool __hyp_text __pmu_switch_to_guest(struct kvm_cpu_context *host_ctxt)
60-
{
61-
struct kvm_host_data *host;
62-
struct kvm_pmu_events *pmu;
63-
64-
host = container_of(host_ctxt, struct kvm_host_data, host_ctxt);
65-
pmu = &host->pmu_events;
66-
67-
if (pmu->events_host)
68-
write_sysreg(pmu->events_host, pmcntenclr_el0);
69-
70-
if (pmu->events_guest)
71-
write_sysreg(pmu->events_guest, pmcntenset_el0);
72-
73-
return (pmu->events_host || pmu->events_guest);
74-
}
75-
76-
/**
77-
* Disable guest events, enable host events
78-
*/
79-
void __hyp_text __pmu_switch_to_host(struct kvm_cpu_context *host_ctxt)
80-
{
81-
struct kvm_host_data *host;
82-
struct kvm_pmu_events *pmu;
83-
84-
host = container_of(host_ctxt, struct kvm_host_data, host_ctxt);
85-
pmu = &host->pmu_events;
86-
87-
if (pmu->events_guest)
88-
write_sysreg(pmu->events_guest, pmcntenclr_el0);
89-
90-
if (pmu->events_host)
91-
write_sysreg(pmu->events_host, pmcntenset_el0);
92-
}
93-
9456
#define PMEVTYPER_READ_CASE(idx) \
9557
case idx: \
9658
return read_sysreg(pmevtyper##idx##_el0)

arch/s390/include/asm/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*/
3737
#define KVM_NR_IRQCHIPS 1
3838
#define KVM_IRQCHIP_NUM_PINS 4096
39-
#define KVM_HALT_POLL_NS_DEFAULT 80000
39+
#define KVM_HALT_POLL_NS_DEFAULT 50000
4040

4141
/* s390-specific vcpu->requests bit members */
4242
#define KVM_REQ_ENABLE_IBS KVM_ARCH_REQ(0)

arch/s390/kvm/kvm-s390.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ MODULE_PARM_DESC(hpage, "1m huge page backing support");
181181
/* maximum percentage of steal time for polling. >100 is treated like 100 */
182182
static u8 halt_poll_max_steal = 10;
183183
module_param(halt_poll_max_steal, byte, 0644);
184-
MODULE_PARM_DESC(hpage, "Maximum percentage of steal time to allow polling");
184+
MODULE_PARM_DESC(halt_poll_max_steal, "Maximum percentage of steal time to allow polling");
185185

186186
/*
187187
* For now we handle at most 16 double words as this is what the s390 base
@@ -4524,21 +4524,28 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
45244524
const struct kvm_memory_slot *new,
45254525
enum kvm_mr_change change)
45264526
{
4527-
int rc;
4528-
4529-
/* If the basics of the memslot do not change, we do not want
4530-
* to update the gmap. Every update causes several unnecessary
4531-
* segment translation exceptions. This is usually handled just
4532-
* fine by the normal fault handler + gmap, but it will also
4533-
* cause faults on the prefix page of running guest CPUs.
4534-
*/
4535-
if (old->userspace_addr == mem->userspace_addr &&
4536-
old->base_gfn * PAGE_SIZE == mem->guest_phys_addr &&
4537-
old->npages * PAGE_SIZE == mem->memory_size)
4538-
return;
4527+
int rc = 0;
45394528

4540-
rc = gmap_map_segment(kvm->arch.gmap, mem->userspace_addr,
4541-
mem->guest_phys_addr, mem->memory_size);
4529+
switch (change) {
4530+
case KVM_MR_DELETE:
4531+
rc = gmap_unmap_segment(kvm->arch.gmap, old->base_gfn * PAGE_SIZE,
4532+
old->npages * PAGE_SIZE);
4533+
break;
4534+
case KVM_MR_MOVE:
4535+
rc = gmap_unmap_segment(kvm->arch.gmap, old->base_gfn * PAGE_SIZE,
4536+
old->npages * PAGE_SIZE);
4537+
if (rc)
4538+
break;
4539+
/* FALLTHROUGH */
4540+
case KVM_MR_CREATE:
4541+
rc = gmap_map_segment(kvm->arch.gmap, mem->userspace_addr,
4542+
mem->guest_phys_addr, mem->memory_size);
4543+
break;
4544+
case KVM_MR_FLAGS_ONLY:
4545+
break;
4546+
default:
4547+
WARN(1, "Unknown KVM MR CHANGE: %d\n", change);
4548+
}
45424549
if (rc)
45434550
pr_warn("failed to commit memory region\n");
45444551
return;

arch/x86/kvm/cpuid.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,9 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
456456
}
457457
break;
458458
}
459-
/* function 4 has additional index. */
460-
case 4: {
459+
/* functions 4 and 0x8000001d have additional index. */
460+
case 4:
461+
case 0x8000001d: {
461462
int i, cache_type;
462463

463464
entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
@@ -701,8 +702,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
701702
entry->ecx = entry->edx = 0;
702703
break;
703704
case 0x8000001a:
704-
break;
705-
case 0x8000001d:
705+
case 0x8000001e:
706706
break;
707707
/*Add support for Centaur's CPUID instruction*/
708708
case 0xC0000000:

arch/x86/kvm/debugfs.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,22 @@
99
*/
1010
#include <linux/kvm_host.h>
1111
#include <linux/debugfs.h>
12+
#include "lapic.h"
1213

1314
bool kvm_arch_has_vcpu_debugfs(void)
1415
{
1516
return true;
1617
}
1718

19+
static int vcpu_get_timer_advance_ns(void *data, u64 *val)
20+
{
21+
struct kvm_vcpu *vcpu = (struct kvm_vcpu *) data;
22+
*val = vcpu->arch.apic->lapic_timer.timer_advance_ns;
23+
return 0;
24+
}
25+
26+
DEFINE_SIMPLE_ATTRIBUTE(vcpu_timer_advance_ns_fops, vcpu_get_timer_advance_ns, NULL, "%llu\n");
27+
1828
static int vcpu_get_tsc_offset(void *data, u64 *val)
1929
{
2030
struct kvm_vcpu *vcpu = (struct kvm_vcpu *) data;
@@ -51,6 +61,14 @@ int kvm_arch_create_vcpu_debugfs(struct kvm_vcpu *vcpu)
5161
if (!ret)
5262
return -ENOMEM;
5363

64+
if (lapic_in_kernel(vcpu)) {
65+
ret = debugfs_create_file("lapic_timer_advance_ns", 0444,
66+
vcpu->debugfs_dentry,
67+
vcpu, &vcpu_timer_advance_ns_fops);
68+
if (!ret)
69+
return -ENOMEM;
70+
}
71+
5472
if (kvm_has_tsc_control) {
5573
ret = debugfs_create_file("tsc-scaling-ratio", 0444,
5674
vcpu->debugfs_dentry,

0 commit comments

Comments
 (0)