aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-09-17 10:51:59 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2015-09-17 10:51:59 -0400
commitefe4d36a75d4dfd1a9c161b2bbf9b90beb4d9648 (patch)
treee7261ab57ded208c8425797e052ae562343ee618
parent9bf9fde2c98ba8362ea1d41d8bd8b32a23776e67 (diff)
parentef748917b529847277f07c98c55e1c0ce416449f (diff)
Merge tag 'kvm-arm-for-4.3-rc2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into kvm-master
Second set of KVM/ARM changes for 4.3-rc2 - Workaround for a Cortex-A57 erratum - Bug fix for the debugging infrastructure - Fix for 32bit guests with more than 4GB of address space on a 32bit host - A number of fixes for the (unusual) case when we don't use the in-kernel GIC emulation - Removal of ThumbEE handling on arm64, since these have been dropped from the architecture before anyone actually ever built a CPU - Remove the KVM_ARM_MAX_VCPUS limitation which has become fairly pointless
-rw-r--r--arch/arm/include/asm/kvm_host.h8
-rw-r--r--arch/arm/kvm/Kconfig11
-rw-r--r--arch/arm/kvm/arm.c2
-rw-r--r--arch/arm/kvm/interrupts_head.S6
-rw-r--r--arch/arm/kvm/mmu.c6
-rw-r--r--arch/arm64/include/asm/kvm_arm.h1
-rw-r--r--arch/arm64/include/asm/kvm_asm.h4
-rw-r--r--arch/arm64/include/asm/kvm_host.h8
-rw-r--r--arch/arm64/kvm/Kconfig11
-rw-r--r--arch/arm64/kvm/hyp.S31
-rw-r--r--arch/arm64/kvm/sys_regs.c15
-rw-r--r--include/kvm/arm_vgic.h6
-rw-r--r--virt/kvm/arm/vgic-v3.c2
13 files changed, 30 insertions, 81 deletions
diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h
index 687ddeba3611..3df1e975f72a 100644
--- a/arch/arm/include/asm/kvm_host.h
+++ b/arch/arm/include/asm/kvm_host.h
@@ -29,12 +29,6 @@
29 29
30#define __KVM_HAVE_ARCH_INTC_INITIALIZED 30#define __KVM_HAVE_ARCH_INTC_INITIALIZED
31 31
32#if defined(CONFIG_KVM_ARM_MAX_VCPUS)
33#define KVM_MAX_VCPUS CONFIG_KVM_ARM_MAX_VCPUS
34#else
35#define KVM_MAX_VCPUS 0
36#endif
37
38#define KVM_USER_MEM_SLOTS 32 32#define KVM_USER_MEM_SLOTS 32
39#define KVM_PRIVATE_MEM_SLOTS 4 33#define KVM_PRIVATE_MEM_SLOTS 4
40#define KVM_COALESCED_MMIO_PAGE_OFFSET 1 34#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
@@ -44,6 +38,8 @@
44 38
45#include <kvm/arm_vgic.h> 39#include <kvm/arm_vgic.h>
46 40
41#define KVM_MAX_VCPUS VGIC_V2_MAX_CPUS
42
47u32 *kvm_vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num, u32 mode); 43u32 *kvm_vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num, u32 mode);
48int __attribute_const__ kvm_target_cpu(void); 44int __attribute_const__ kvm_target_cpu(void);
49int kvm_reset_vcpu(struct kvm_vcpu *vcpu); 45int kvm_reset_vcpu(struct kvm_vcpu *vcpu);
diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
index bfb915d05665..210eccadb69a 100644
--- a/arch/arm/kvm/Kconfig
+++ b/arch/arm/kvm/Kconfig
@@ -45,15 +45,4 @@ config KVM_ARM_HOST
45 ---help--- 45 ---help---
46 Provides host support for ARM processors. 46 Provides host support for ARM processors.
47 47
48config KVM_ARM_MAX_VCPUS
49 int "Number maximum supported virtual CPUs per VM"
50 depends on KVM_ARM_HOST
51 default 4
52 help
53 Static number of max supported virtual CPUs per VM.
54
55 If you choose a high number, the vcpu structures will be quite
56 large, so only choose a reasonable number that you expect to
57 actually use.
58
59endif # VIRTUALIZATION 48endif # VIRTUALIZATION
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index ce404a5c3062..dc017adfddc8 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -446,7 +446,7 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu)
446 * Map the VGIC hardware resources before running a vcpu the first 446 * Map the VGIC hardware resources before running a vcpu the first
447 * time on this VM. 447 * time on this VM.
448 */ 448 */
449 if (unlikely(!vgic_ready(kvm))) { 449 if (unlikely(irqchip_in_kernel(kvm) && !vgic_ready(kvm))) {
450 ret = kvm_vgic_map_resources(kvm); 450 ret = kvm_vgic_map_resources(kvm);
451 if (ret) 451 if (ret)
452 return ret; 452 return ret;
diff --git a/arch/arm/kvm/interrupts_head.S b/arch/arm/kvm/interrupts_head.S
index 702740d37465..51a59504bef4 100644
--- a/arch/arm/kvm/interrupts_head.S
+++ b/arch/arm/kvm/interrupts_head.S
@@ -515,8 +515,7 @@ ARM_BE8(rev r6, r6 )
515 515
516 mrc p15, 0, r2, c14, c3, 1 @ CNTV_CTL 516 mrc p15, 0, r2, c14, c3, 1 @ CNTV_CTL
517 str r2, [vcpu, #VCPU_TIMER_CNTV_CTL] 517 str r2, [vcpu, #VCPU_TIMER_CNTV_CTL]
518 bic r2, #1 @ Clear ENABLE 518
519 mcr p15, 0, r2, c14, c3, 1 @ CNTV_CTL
520 isb 519 isb
521 520
522 mrrc p15, 3, rr_lo_hi(r2, r3), c14 @ CNTV_CVAL 521 mrrc p15, 3, rr_lo_hi(r2, r3), c14 @ CNTV_CVAL
@@ -529,6 +528,9 @@ ARM_BE8(rev r6, r6 )
529 mcrr p15, 4, r2, r2, c14 @ CNTVOFF 528 mcrr p15, 4, r2, r2, c14 @ CNTVOFF
530 529
5311: 5301:
531 mov r2, #0 @ Clear ENABLE
532 mcr p15, 0, r2, c14, c3, 1 @ CNTV_CTL
533
532 @ Allow physical timer/counter access for the host 534 @ Allow physical timer/counter access for the host
533 mrc p15, 4, r2, c14, c1, 0 @ CNTHCTL 535 mrc p15, 4, r2, c14, c1, 0 @ CNTHCTL
534 orr r2, r2, #(CNTHCTL_PL1PCEN | CNTHCTL_PL1PCTEN) 536 orr r2, r2, #(CNTHCTL_PL1PCEN | CNTHCTL_PL1PCTEN)
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 7b4201294187..6984342da13d 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -1792,8 +1792,10 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
1792 if (vma->vm_flags & VM_PFNMAP) { 1792 if (vma->vm_flags & VM_PFNMAP) {
1793 gpa_t gpa = mem->guest_phys_addr + 1793 gpa_t gpa = mem->guest_phys_addr +
1794 (vm_start - mem->userspace_addr); 1794 (vm_start - mem->userspace_addr);
1795 phys_addr_t pa = (vma->vm_pgoff << PAGE_SHIFT) + 1795 phys_addr_t pa;
1796 vm_start - vma->vm_start; 1796
1797 pa = (phys_addr_t)vma->vm_pgoff << PAGE_SHIFT;
1798 pa += vm_start - vma->vm_start;
1797 1799
1798 /* IO region dirty page logging not allowed */ 1800 /* IO region dirty page logging not allowed */
1799 if (memslot->flags & KVM_MEM_LOG_DIRTY_PAGES) 1801 if (memslot->flags & KVM_MEM_LOG_DIRTY_PAGES)
diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h
index cbc5e1a0ea8f..9694f2654593 100644
--- a/arch/arm64/include/asm/kvm_arm.h
+++ b/arch/arm64/include/asm/kvm_arm.h
@@ -172,7 +172,6 @@
172#define VTTBR_VMID_MASK (UL(0xFF) << VTTBR_VMID_SHIFT) 172#define VTTBR_VMID_MASK (UL(0xFF) << VTTBR_VMID_SHIFT)
173 173
174/* Hyp System Trap Register */ 174/* Hyp System Trap Register */
175#define HSTR_EL2_TTEE (1 << 16)
176#define HSTR_EL2_T(x) (1 << x) 175#define HSTR_EL2_T(x) (1 << x)
177 176
178/* Hyp Coproccessor Trap Register Shifts */ 177/* Hyp Coproccessor Trap Register Shifts */
diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h
index 67fa0de3d483..5e377101f919 100644
--- a/arch/arm64/include/asm/kvm_asm.h
+++ b/arch/arm64/include/asm/kvm_asm.h
@@ -53,9 +53,7 @@
53#define IFSR32_EL2 25 /* Instruction Fault Status Register */ 53#define IFSR32_EL2 25 /* Instruction Fault Status Register */
54#define FPEXC32_EL2 26 /* Floating-Point Exception Control Register */ 54#define FPEXC32_EL2 26 /* Floating-Point Exception Control Register */
55#define DBGVCR32_EL2 27 /* Debug Vector Catch Register */ 55#define DBGVCR32_EL2 27 /* Debug Vector Catch Register */
56#define TEECR32_EL1 28 /* ThumbEE Configuration Register */ 56#define NR_SYS_REGS 28
57#define TEEHBR32_EL1 29 /* ThumbEE Handler Base Register */
58#define NR_SYS_REGS 30
59 57
60/* 32bit mapping */ 58/* 32bit mapping */
61#define c0_MPIDR (MPIDR_EL1 * 2) /* MultiProcessor ID Register */ 59#define c0_MPIDR (MPIDR_EL1 * 2) /* MultiProcessor ID Register */
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 486594583cc6..4562459456a6 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -30,12 +30,6 @@
30 30
31#define __KVM_HAVE_ARCH_INTC_INITIALIZED 31#define __KVM_HAVE_ARCH_INTC_INITIALIZED
32 32
33#if defined(CONFIG_KVM_ARM_MAX_VCPUS)
34#define KVM_MAX_VCPUS CONFIG_KVM_ARM_MAX_VCPUS
35#else
36#define KVM_MAX_VCPUS 0
37#endif
38
39#define KVM_USER_MEM_SLOTS 32 33#define KVM_USER_MEM_SLOTS 32
40#define KVM_PRIVATE_MEM_SLOTS 4 34#define KVM_PRIVATE_MEM_SLOTS 4
41#define KVM_COALESCED_MMIO_PAGE_OFFSET 1 35#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
@@ -43,6 +37,8 @@
43#include <kvm/arm_vgic.h> 37#include <kvm/arm_vgic.h>
44#include <kvm/arm_arch_timer.h> 38#include <kvm/arm_arch_timer.h>
45 39
40#define KVM_MAX_VCPUS VGIC_V3_MAX_CPUS
41
46#define KVM_VCPU_MAX_FEATURES 3 42#define KVM_VCPU_MAX_FEATURES 3
47 43
48int __attribute_const__ kvm_target_cpu(void); 44int __attribute_const__ kvm_target_cpu(void);
diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
index bfffe8f4bd53..5c7e920e4861 100644
--- a/arch/arm64/kvm/Kconfig
+++ b/arch/arm64/kvm/Kconfig
@@ -41,15 +41,4 @@ config KVM_ARM_HOST
41 ---help--- 41 ---help---
42 Provides host support for ARM processors. 42 Provides host support for ARM processors.
43 43
44config KVM_ARM_MAX_VCPUS
45 int "Number maximum supported virtual CPUs per VM"
46 depends on KVM_ARM_HOST
47 default 4
48 help
49 Static number of max supported virtual CPUs per VM.
50
51 If you choose a high number, the vcpu structures will be quite
52 large, so only choose a reasonable number that you expect to
53 actually use.
54
55endif # VIRTUALIZATION 44endif # VIRTUALIZATION
diff --git a/arch/arm64/kvm/hyp.S b/arch/arm64/kvm/hyp.S
index 37c89ea2c572..e5836138ec42 100644
--- a/arch/arm64/kvm/hyp.S
+++ b/arch/arm64/kvm/hyp.S
@@ -433,20 +433,13 @@
433 mrs x5, ifsr32_el2 433 mrs x5, ifsr32_el2
434 stp x4, x5, [x3] 434 stp x4, x5, [x3]
435 435
436 skip_fpsimd_state x8, 3f 436 skip_fpsimd_state x8, 2f
437 mrs x6, fpexc32_el2 437 mrs x6, fpexc32_el2
438 str x6, [x3, #16] 438 str x6, [x3, #16]
4393: 4392:
440 skip_debug_state x8, 2f 440 skip_debug_state x8, 1f
441 mrs x7, dbgvcr32_el2 441 mrs x7, dbgvcr32_el2
442 str x7, [x3, #24] 442 str x7, [x3, #24]
4432:
444 skip_tee_state x8, 1f
445
446 add x3, x2, #CPU_SYSREG_OFFSET(TEECR32_EL1)
447 mrs x4, teecr32_el1
448 mrs x5, teehbr32_el1
449 stp x4, x5, [x3]
4501: 4431:
451.endm 444.endm
452 445
@@ -466,16 +459,9 @@
466 msr dacr32_el2, x4 459 msr dacr32_el2, x4
467 msr ifsr32_el2, x5 460 msr ifsr32_el2, x5
468 461
469 skip_debug_state x8, 2f 462 skip_debug_state x8, 1f
470 ldr x7, [x3, #24] 463 ldr x7, [x3, #24]
471 msr dbgvcr32_el2, x7 464 msr dbgvcr32_el2, x7
4722:
473 skip_tee_state x8, 1f
474
475 add x3, x2, #CPU_SYSREG_OFFSET(TEECR32_EL1)
476 ldp x4, x5, [x3]
477 msr teecr32_el1, x4
478 msr teehbr32_el1, x5
4791: 4651:
480.endm 466.endm
481 467
@@ -570,8 +556,6 @@ alternative_endif
570 mrs x3, cntv_ctl_el0 556 mrs x3, cntv_ctl_el0
571 and x3, x3, #3 557 and x3, x3, #3
572 str w3, [x0, #VCPU_TIMER_CNTV_CTL] 558 str w3, [x0, #VCPU_TIMER_CNTV_CTL]
573 bic x3, x3, #1 // Clear Enable
574 msr cntv_ctl_el0, x3
575 559
576 isb 560 isb
577 561
@@ -579,6 +563,9 @@ alternative_endif
579 str x3, [x0, #VCPU_TIMER_CNTV_CVAL] 563 str x3, [x0, #VCPU_TIMER_CNTV_CVAL]
580 564
5811: 5651:
566 // Disable the virtual timer
567 msr cntv_ctl_el0, xzr
568
582 // Allow physical timer/counter access for the host 569 // Allow physical timer/counter access for the host
583 mrs x2, cnthctl_el2 570 mrs x2, cnthctl_el2
584 orr x2, x2, #3 571 orr x2, x2, #3
@@ -753,6 +740,9 @@ ENTRY(__kvm_vcpu_run)
753 // Guest context 740 // Guest context
754 add x2, x0, #VCPU_CONTEXT 741 add x2, x0, #VCPU_CONTEXT
755 742
743 // We must restore the 32-bit state before the sysregs, thanks
744 // to Cortex-A57 erratum #852523.
745 restore_guest_32bit_state
756 bl __restore_sysregs 746 bl __restore_sysregs
757 747
758 skip_debug_state x3, 1f 748 skip_debug_state x3, 1f
@@ -760,7 +750,6 @@ ENTRY(__kvm_vcpu_run)
760 kern_hyp_va x3 750 kern_hyp_va x3
761 bl __restore_debug 751 bl __restore_debug
7621: 7521:
763 restore_guest_32bit_state
764 restore_guest_regs 753 restore_guest_regs
765 754
766 // That's it, no more messing around. 755 // That's it, no more messing around.
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index b41607d270ac..d03d3af17e7e 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -272,7 +272,7 @@ static int set_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
272{ 272{
273 __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg]; 273 __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg];
274 274
275 if (copy_from_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0) 275 if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
276 return -EFAULT; 276 return -EFAULT;
277 return 0; 277 return 0;
278} 278}
@@ -314,7 +314,7 @@ static int set_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
314{ 314{
315 __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg]; 315 __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg];
316 316
317 if (copy_from_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0) 317 if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
318 return -EFAULT; 318 return -EFAULT;
319 319
320 return 0; 320 return 0;
@@ -358,7 +358,7 @@ static int set_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
358{ 358{
359 __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg]; 359 __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg];
360 360
361 if (copy_from_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0) 361 if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
362 return -EFAULT; 362 return -EFAULT;
363 return 0; 363 return 0;
364} 364}
@@ -400,7 +400,7 @@ static int set_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
400{ 400{
401 __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg]; 401 __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg];
402 402
403 if (copy_from_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0) 403 if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
404 return -EFAULT; 404 return -EFAULT;
405 return 0; 405 return 0;
406} 406}
@@ -539,13 +539,6 @@ static const struct sys_reg_desc sys_reg_descs[] = {
539 { Op0(0b10), Op1(0b000), CRn(0b0111), CRm(0b1110), Op2(0b110), 539 { Op0(0b10), Op1(0b000), CRn(0b0111), CRm(0b1110), Op2(0b110),
540 trap_dbgauthstatus_el1 }, 540 trap_dbgauthstatus_el1 },
541 541
542 /* TEECR32_EL1 */
543 { Op0(0b10), Op1(0b010), CRn(0b0000), CRm(0b0000), Op2(0b000),
544 NULL, reset_val, TEECR32_EL1, 0 },
545 /* TEEHBR32_EL1 */
546 { Op0(0b10), Op1(0b010), CRn(0b0001), CRm(0b0000), Op2(0b000),
547 NULL, reset_val, TEEHBR32_EL1, 0 },
548
549 /* MDCCSR_EL1 */ 542 /* MDCCSR_EL1 */
550 { Op0(0b10), Op1(0b011), CRn(0b0000), CRm(0b0001), Op2(0b000), 543 { Op0(0b10), Op1(0b011), CRn(0b0000), CRm(0b0001), Op2(0b000),
551 trap_raz_wi }, 544 trap_raz_wi },
diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
index d901f1a47be6..4e14dac282bb 100644
--- a/include/kvm/arm_vgic.h
+++ b/include/kvm/arm_vgic.h
@@ -35,11 +35,7 @@
35#define VGIC_V3_MAX_LRS 16 35#define VGIC_V3_MAX_LRS 16
36#define VGIC_MAX_IRQS 1024 36#define VGIC_MAX_IRQS 1024
37#define VGIC_V2_MAX_CPUS 8 37#define VGIC_V2_MAX_CPUS 8
38 38#define VGIC_V3_MAX_CPUS 255
39/* Sanity checks... */
40#if (KVM_MAX_VCPUS > 255)
41#error Too many KVM VCPUs, the VGIC only supports up to 255 VCPUs for now
42#endif
43 39
44#if (VGIC_NR_IRQS_LEGACY & 31) 40#if (VGIC_NR_IRQS_LEGACY & 31)
45#error "VGIC_NR_IRQS must be a multiple of 32" 41#error "VGIC_NR_IRQS must be a multiple of 32"
diff --git a/virt/kvm/arm/vgic-v3.c b/virt/kvm/arm/vgic-v3.c
index afbf925b00f4..7dd5d62f10a1 100644
--- a/virt/kvm/arm/vgic-v3.c
+++ b/virt/kvm/arm/vgic-v3.c
@@ -288,7 +288,7 @@ int vgic_v3_probe(struct device_node *vgic_node,
288 288
289 vgic->vctrl_base = NULL; 289 vgic->vctrl_base = NULL;
290 vgic->type = VGIC_V3; 290 vgic->type = VGIC_V3;
291 vgic->max_gic_vcpus = KVM_MAX_VCPUS; 291 vgic->max_gic_vcpus = VGIC_V3_MAX_CPUS;
292 292
293 kvm_info("%s@%llx IRQ%d\n", vgic_node->name, 293 kvm_info("%s@%llx IRQ%d\n", vgic_node->name,
294 vcpu_res.start, vgic->maint_irq); 294 vcpu_res.start, vgic->maint_irq);