diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-08 05:27:39 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-08 05:27:39 -0400 |
| commit | e4e65676f272adb63655a2ca95207e8212d282f1 (patch) | |
| tree | 3679a3e6897d698ee949642660281e7f74e2852b /virt | |
| parent | f89f4a06a59f30dec64b2afc4111426fc01e9e12 (diff) | |
| parent | f439ed27f8b8b90d243ae15acb193d37f96eebe0 (diff) | |
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM updates from Paolo Bonzini:
"Fixes and features for 3.18.
Apart from the usual cleanups, here is the summary of new features:
- s390 moves closer towards host large page support
- PowerPC has improved support for debugging (both inside the guest
and via gdbstub) and support for e6500 processors
- ARM/ARM64 support read-only memory (which is necessary to put
firmware in emulated NOR flash)
- x86 has the usual emulator fixes and nested virtualization
improvements (including improved Windows support on Intel and
Jailhouse hypervisor support on AMD), adaptive PLE which helps
overcommitting of huge guests. Also included are some patches that
make KVM more friendly to memory hot-unplug, and fixes for rare
caching bugs.
Two patches have trivial mm/ parts that were acked by Rik and Andrew.
Note: I will soon switch to a subkey for signing purposes"
* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (157 commits)
kvm: do not handle APIC access page if in-kernel irqchip is not in use
KVM: s390: count vcpu wakeups in stat.halt_wakeup
KVM: s390/facilities: allow TOD-CLOCK steering facility bit
KVM: PPC: BOOK3S: HV: CMA: Reserve cma region only in hypervisor mode
arm/arm64: KVM: Report correct FSC for unsupported fault types
arm/arm64: KVM: Fix VTTBR_BADDR_MASK and pgd alloc
kvm: Fix kvm_get_page_retry_io __gup retval check
arm/arm64: KVM: Fix set_clear_sgi_pend_reg offset
kvm: x86: Unpin and remove kvm_arch->apic_access_page
kvm: vmx: Implement set_apic_access_page_addr
kvm: x86: Add request bit to reload APIC access page address
kvm: Add arch specific mmu notifier for page invalidation
kvm: Rename make_all_cpus_request() to kvm_make_all_cpus_request() and make it non-static
kvm: Fix page ageing bugs
kvm/x86/mmu: Pass gfn and level to rmapp callback.
x86: kvm: use alternatives for VMCALL vs. VMMCALL if kernel text is read-only
kvm: x86: use macros to compute bank MSRs
KVM: x86: Remove debug assertion of non-PAE reserved bits
kvm: don't take vcpu mutex for obviously invalid vcpu ioctls
kvm: Faults which trigger IO release the mmap_sem
...
Diffstat (limited to 'virt')
| -rw-r--r-- | virt/kvm/arm/vgic.c | 744 | ||||
| -rw-r--r-- | virt/kvm/async_pf.c | 4 | ||||
| -rw-r--r-- | virt/kvm/eventfd.c | 4 | ||||
| -rw-r--r-- | virt/kvm/ioapic.c | 46 | ||||
| -rw-r--r-- | virt/kvm/ioapic.h | 2 | ||||
| -rw-r--r-- | virt/kvm/kvm_main.c | 192 | ||||
| -rw-r--r-- | virt/kvm/vfio.c | 22 | ||||
| -rw-r--r-- | virt/kvm/vfio.h | 13 |
8 files changed, 779 insertions, 248 deletions
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 73eba793b17f..862967852d5a 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c | |||
| @@ -36,21 +36,22 @@ | |||
| 36 | * How the whole thing works (courtesy of Christoffer Dall): | 36 | * How the whole thing works (courtesy of Christoffer Dall): |
| 37 | * | 37 | * |
| 38 | * - At any time, the dist->irq_pending_on_cpu is the oracle that knows if | 38 | * - At any time, the dist->irq_pending_on_cpu is the oracle that knows if |
| 39 | * something is pending | 39 | * something is pending on the CPU interface. |
| 40 | * - VGIC pending interrupts are stored on the vgic.irq_state vgic | 40 | * - Interrupts that are pending on the distributor are stored on the |
| 41 | * bitmap (this bitmap is updated by both user land ioctls and guest | 41 | * vgic.irq_pending vgic bitmap (this bitmap is updated by both user land |
| 42 | * mmio ops, and other in-kernel peripherals such as the | 42 | * ioctls and guest mmio ops, and other in-kernel peripherals such as the |
| 43 | * arch. timers) and indicate the 'wire' state. | 43 | * arch. timers). |
| 44 | * - Every time the bitmap changes, the irq_pending_on_cpu oracle is | 44 | * - Every time the bitmap changes, the irq_pending_on_cpu oracle is |
| 45 | * recalculated | 45 | * recalculated |
| 46 | * - To calculate the oracle, we need info for each cpu from | 46 | * - To calculate the oracle, we need info for each cpu from |
| 47 | * compute_pending_for_cpu, which considers: | 47 | * compute_pending_for_cpu, which considers: |
| 48 | * - PPI: dist->irq_state & dist->irq_enable | 48 | * - PPI: dist->irq_pending & dist->irq_enable |
| 49 | * - SPI: dist->irq_state & dist->irq_enable & dist->irq_spi_target | 49 | * - SPI: dist->irq_pending & dist->irq_enable & dist->irq_spi_target |
| 50 | * - irq_spi_target is a 'formatted' version of the GICD_ICFGR | 50 | * - irq_spi_target is a 'formatted' version of the GICD_ITARGETSRn |
| 51 | * registers, stored on each vcpu. We only keep one bit of | 51 | * registers, stored on each vcpu. We only keep one bit of |
| 52 | * information per interrupt, making sure that only one vcpu can | 52 | * information per interrupt, making sure that only one vcpu can |
| 53 | * accept the interrupt. | 53 | * accept the interrupt. |
| 54 | * - If any of the above state changes, we must recalculate the oracle. | ||
| 54 | * - The same is true when injecting an interrupt, except that we only | 55 | * - The same is true when injecting an interrupt, except that we only |
| 55 | * consider a single interrupt at a time. The irq_spi_cpu array | 56 | * consider a single interrupt at a time. The irq_spi_cpu array |
| 56 | * contains the target CPU for each SPI. | 57 | * contains the target CPU for each SPI. |
| @@ -60,13 +61,18 @@ | |||
| 60 | * the 'line' again. This is achieved as such: | 61 | * the 'line' again. This is achieved as such: |
| 61 | * | 62 | * |
| 62 | * - When a level interrupt is moved onto a vcpu, the corresponding | 63 | * - When a level interrupt is moved onto a vcpu, the corresponding |
| 63 | * bit in irq_active is set. As long as this bit is set, the line | 64 | * bit in irq_queued is set. As long as this bit is set, the line |
| 64 | * will be ignored for further interrupts. The interrupt is injected | 65 | * will be ignored for further interrupts. The interrupt is injected |
| 65 | * into the vcpu with the GICH_LR_EOI bit set (generate a | 66 | * into the vcpu with the GICH_LR_EOI bit set (generate a |
| 66 | * maintenance interrupt on EOI). | 67 | * maintenance interrupt on EOI). |
| 67 | * - When the interrupt is EOIed, the maintenance interrupt fires, | 68 | * - When the interrupt is EOIed, the maintenance interrupt fires, |
| 68 | * and clears the corresponding bit in irq_active. This allow the | 69 | * and clears the corresponding bit in irq_queued. This allows the |
| 69 | * interrupt line to be sampled again. | 70 | * interrupt line to be sampled again. |
| 71 | * - Note that level-triggered interrupts can also be set to pending from | ||
| 72 | * writes to GICD_ISPENDRn and lowering the external input line does not | ||
| 73 | * cause the interrupt to become inactive in such a situation. | ||
| 74 | * Conversely, writes to GICD_ICPENDRn do not cause the interrupt to become | ||
| 75 | * inactive as long as the external input line is held high. | ||
| 70 | */ | 76 | */ |
| 71 | 77 | ||
| 72 | #define VGIC_ADDR_UNDEF (-1) | 78 | #define VGIC_ADDR_UNDEF (-1) |
| @@ -89,6 +95,7 @@ static void vgic_retire_disabled_irqs(struct kvm_vcpu *vcpu); | |||
| 89 | static void vgic_retire_lr(int lr_nr, int irq, struct kvm_vcpu *vcpu); | 95 | static void vgic_retire_lr(int lr_nr, int irq, struct kvm_vcpu *vcpu); |
| 90 | static void vgic_update_state(struct kvm *kvm); | 96 | static void vgic_update_state(struct kvm *kvm); |
| 91 | static void vgic_kick_vcpus(struct kvm *kvm); | 97 | static void vgic_kick_vcpus(struct kvm *kvm); |
| 98 | static u8 *vgic_get_sgi_sources(struct vgic_dist *dist, int vcpu_id, int sgi); | ||
| 92 | static void vgic_dispatch_sgi(struct kvm_vcpu *vcpu, u32 reg); | 99 | static void vgic_dispatch_sgi(struct kvm_vcpu *vcpu, u32 reg); |
| 93 | static struct vgic_lr vgic_get_lr(const struct kvm_vcpu *vcpu, int lr); | 100 | static struct vgic_lr vgic_get_lr(const struct kvm_vcpu *vcpu, int lr); |
| 94 | static void vgic_set_lr(struct kvm_vcpu *vcpu, int lr, struct vgic_lr lr_desc); | 101 | static void vgic_set_lr(struct kvm_vcpu *vcpu, int lr, struct vgic_lr lr_desc); |
| @@ -99,10 +106,8 @@ static const struct vgic_ops *vgic_ops; | |||
| 99 | static const struct vgic_params *vgic; | 106 | static const struct vgic_params *vgic; |
| 100 | 107 | ||
| 101 | /* | 108 | /* |
| 102 | * struct vgic_bitmap contains unions that provide two views of | 109 | * struct vgic_bitmap contains a bitmap made of unsigned longs, but |
| 103 | * the same data. In one case it is an array of registers of | 110 | * extracts u32s out of them. |
| 104 | * u32's, and in the other case it is a bitmap of unsigned | ||
| 105 | * longs. | ||
| 106 | * | 111 | * |
| 107 | * This does not work on 64-bit BE systems, because the bitmap access | 112 | * This does not work on 64-bit BE systems, because the bitmap access |
| 108 | * will store two consecutive 32-bit words with the higher-addressed | 113 | * will store two consecutive 32-bit words with the higher-addressed |
| @@ -118,23 +123,45 @@ static const struct vgic_params *vgic; | |||
| 118 | #define REG_OFFSET_SWIZZLE 0 | 123 | #define REG_OFFSET_SWIZZLE 0 |
| 119 | #endif | 124 | #endif |
| 120 | 125 | ||
| 126 | static int vgic_init_bitmap(struct vgic_bitmap *b, int nr_cpus, int nr_irqs) | ||
| 127 | { | ||
| 128 | int nr_longs; | ||
| 129 | |||
| 130 | nr_longs = nr_cpus + BITS_TO_LONGS(nr_irqs - VGIC_NR_PRIVATE_IRQS); | ||
| 131 | |||
| 132 | b->private = kzalloc(sizeof(unsigned long) * nr_longs, GFP_KERNEL); | ||
| 133 | if (!b->private) | ||
| 134 | return -ENOMEM; | ||
| 135 | |||
| 136 | b->shared = b->private + nr_cpus; | ||
| 137 | |||
| 138 | return 0; | ||
| 139 | } | ||
| 140 | |||
| 141 | static void vgic_free_bitmap(struct vgic_bitmap *b) | ||
| 142 | { | ||
| 143 | kfree(b->private); | ||
| 144 | b->private = NULL; | ||
| 145 | b->shared = NULL; | ||
| 146 | } | ||
| 147 | |||
| 121 | static u32 *vgic_bitmap_get_reg(struct vgic_bitmap *x, | 148 | static u32 *vgic_bitmap_get_reg(struct vgic_bitmap *x, |
| 122 | int cpuid, u32 offset) | 149 | int cpuid, u32 offset) |
| 123 | { | 150 | { |
| 124 | offset >>= 2; | 151 | offset >>= 2; |
| 125 | if (!offset) | 152 | if (!offset) |
| 126 | return x->percpu[cpuid].reg + (offset ^ REG_OFFSET_SWIZZLE); | 153 | return (u32 *)(x->private + cpuid) + REG_OFFSET_SWIZZLE; |
| 127 | else | 154 | else |
| 128 | return x->shared.reg + ((offset - 1) ^ REG_OFFSET_SWIZZLE); | 155 | return (u32 *)(x->shared) + ((offset - 1) ^ REG_OFFSET_SWIZZLE); |
| 129 | } | 156 | } |
| 130 | 157 | ||
| 131 | static int vgic_bitmap_get_irq_val(struct vgic_bitmap *x, | 158 | static int vgic_bitmap_get_irq_val(struct vgic_bitmap *x, |
| 132 | int cpuid, int irq) | 159 | int cpuid, int irq) |
| 133 | { | 160 | { |
| 134 | if (irq < VGIC_NR_PRIVATE_IRQS) | 161 | if (irq < VGIC_NR_PRIVATE_IRQS) |
| 135 | return test_bit(irq, x->percpu[cpuid].reg_ul); | 162 | return test_bit(irq, x->private + cpuid); |
| 136 | 163 | ||
| 137 | return test_bit(irq - VGIC_NR_PRIVATE_IRQS, x->shared.reg_ul); | 164 | return test_bit(irq - VGIC_NR_PRIVATE_IRQS, x->shared); |
| 138 | } | 165 | } |
| 139 | 166 | ||
| 140 | static void vgic_bitmap_set_irq_val(struct vgic_bitmap *x, int cpuid, | 167 | static void vgic_bitmap_set_irq_val(struct vgic_bitmap *x, int cpuid, |
| @@ -143,9 +170,9 @@ static void vgic_bitmap_set_irq_val(struct vgic_bitmap *x, int cpuid, | |||
| 143 | unsigned long *reg; | 170 | unsigned long *reg; |
| 144 | 171 | ||
| 145 | if (irq < VGIC_NR_PRIVATE_IRQS) { | 172 | if (irq < VGIC_NR_PRIVATE_IRQS) { |
| 146 | reg = x->percpu[cpuid].reg_ul; | 173 | reg = x->private + cpuid; |
| 147 | } else { | 174 | } else { |
| 148 | reg = x->shared.reg_ul; | 175 | reg = x->shared; |
| 149 | irq -= VGIC_NR_PRIVATE_IRQS; | 176 | irq -= VGIC_NR_PRIVATE_IRQS; |
| 150 | } | 177 | } |
| 151 | 178 | ||
| @@ -157,24 +184,49 @@ static void vgic_bitmap_set_irq_val(struct vgic_bitmap *x, int cpuid, | |||
| 157 | 184 | ||
| 158 | static unsigned long *vgic_bitmap_get_cpu_map(struct vgic_bitmap *x, int cpuid) | 185 | static unsigned long *vgic_bitmap_get_cpu_map(struct vgic_bitmap *x, int cpuid) |
| 159 | { | 186 | { |
| 160 | if (unlikely(cpuid >= VGIC_MAX_CPUS)) | 187 | return x->private + cpuid; |
| 161 | return NULL; | ||
| 162 | return x->percpu[cpuid].reg_ul; | ||
| 163 | } | 188 | } |
| 164 | |||
