diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-18 17:32:31 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-18 17:32:31 -0400 |
commit | 8a5de18239e418fe7b1f36504834689f754d8ccc (patch) | |
tree | 8d05ae77da1d4a8512b6052e2ba23571543666c7 /virt | |
parent | 857b50f5d0eed113428c864e927289d8f5f2b864 (diff) | |
parent | 2df36a5dd6792870bef48f63bfca42055ea5b79c (diff) |
Merge tag 'kvm-arm-for-3.18-take-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm
Pull second batch of changes for KVM/{arm,arm64} from Marc Zyngier:
"The most obvious thing is the sizeable MMU changes to support 48bit
VAs on arm64.
Summary:
- support for 48bit IPA and VA (EL2)
- a number of fixes for devices mapped into guests
- yet another VGIC fix for BE
- a fix for CPU hotplug
- a few compile fixes (disabled VGIC, strict mm checks)"
[ I'm pulling directly from Marc at the request of Paolo Bonzini, whose
backpack was stolen at Düsseldorf airport and will do new keys and
rebuild his web of trust. - Linus ]
* tag 'kvm-arm-for-3.18-take-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm:
arm/arm64: KVM: Fix BE accesses to GICv2 EISR and ELRSR regs
arm: kvm: STRICT_MM_TYPECHECKS fix for user_mem_abort
arm/arm64: KVM: Ensure memslots are within KVM_PHYS_SIZE
arm64: KVM: Implement 48 VA support for KVM EL2 and Stage-2
arm/arm64: KVM: map MMIO regions at creation time
arm64: kvm: define PAGE_S2_DEVICE as read-only by default
ARM: kvm: define PAGE_S2_DEVICE as read-only by default
arm/arm64: KVM: add 'writable' parameter to kvm_phys_addr_ioremap
arm/arm64: KVM: fix potential NULL dereference in user_mem_abort()
arm/arm64: KVM: use __GFP_ZERO not memset() to get zeroed pages
ARM: KVM: fix vgic-disabled build
arm: kvm: fix CPU hotplug
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/arm/vgic-v2.c | 24 | ||||
-rw-r--r-- | virt/kvm/arm/vgic.c | 21 |
2 files changed, 21 insertions, 24 deletions
diff --git a/virt/kvm/arm/vgic-v2.c b/virt/kvm/arm/vgic-v2.c index 416baedfc89f..2935405ad22f 100644 --- a/virt/kvm/arm/vgic-v2.c +++ b/virt/kvm/arm/vgic-v2.c | |||
@@ -71,35 +71,17 @@ static void vgic_v2_sync_lr_elrsr(struct kvm_vcpu *vcpu, int lr, | |||
71 | struct vgic_lr lr_desc) | 71 | struct vgic_lr lr_desc) |
72 | { | 72 | { |
73 | if (!(lr_desc.state & LR_STATE_MASK)) | 73 | if (!(lr_desc.state & LR_STATE_MASK)) |
74 | __set_bit(lr, (unsigned long *)vcpu->arch.vgic_cpu.vgic_v2.vgic_elrsr); | 74 | vcpu->arch.vgic_cpu.vgic_v2.vgic_elrsr |= (1ULL << lr); |
75 | } | 75 | } |
76 | 76 | ||
77 | static u64 vgic_v2_get_elrsr(const struct kvm_vcpu *vcpu) | 77 | static u64 vgic_v2_get_elrsr(const struct kvm_vcpu *vcpu) |
78 | { | 78 | { |
79 | u64 val; | 79 | return vcpu->arch.vgic_cpu.vgic_v2.vgic_elrsr; |
80 | |||
81 | #if BITS_PER_LONG == 64 | ||
82 | val = vcpu->arch.vgic_cpu.vgic_v2.vgic_elrsr[1]; | ||
83 | val <<= 32; | ||
84 | val |= vcpu->arch.vgic_cpu.vgic_v2.vgic_elrsr[0]; | ||
85 | #else | ||
86 | val = *(u64 *)vcpu->arch.vgic_cpu.vgic_v2.vgic_elrsr; | ||
87 | #endif | ||
88 | return val; | ||
89 | } | 80 | } |
90 | 81 | ||
91 | static u64 vgic_v2_get_eisr(const struct kvm_vcpu *vcpu) | 82 | static u64 vgic_v2_get_eisr(const struct kvm_vcpu *vcpu) |
92 | { | 83 | { |
93 | u64 val; | 84 | return vcpu->arch.vgic_cpu.vgic_v2.vgic_eisr; |
94 | |||
95 | #if BITS_PER_LONG == 64 | ||
96 | val = vcpu->arch.vgic_cpu.vgic_v2.vgic_eisr[1]; | ||
97 | val <<= 32; | ||
98 | val |= vcpu->arch.vgic_cpu.vgic_v2.vgic_eisr[0]; | ||
99 | #else | ||
100 | val = *(u64 *)vcpu->arch.vgic_cpu.vgic_v2.vgic_eisr; | ||
101 | #endif | ||
102 | return val; | ||
103 | } | 85 | } |
104 | 86 | ||
105 | static u32 vgic_v2_get_interrupt_status(const struct kvm_vcpu *vcpu) | 87 | static u32 vgic_v2_get_interrupt_status(const struct kvm_vcpu *vcpu) |
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 862967852d5a..3aaca49de325 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c | |||
@@ -145,6 +145,20 @@ static void vgic_free_bitmap(struct vgic_bitmap *b) | |||
145 | b->shared = NULL; | 145 | b->shared = NULL; |
146 | } | 146 | } |
147 | 147 | ||
148 | /* | ||
149 | * Call this function to convert a u64 value to an unsigned long * bitmask | ||
150 | * in a way that works on both 32-bit and 64-bit LE and BE platforms. | ||
151 | * | ||
152 | * Warning: Calling this function may modify *val. | ||
153 | */ | ||
154 | static unsigned long *u64_to_bitmask(u64 *val) | ||
155 | { | ||
156 | #if defined(CONFIG_CPU_BIG_ENDIAN) && BITS_PER_LONG == 32 | ||
157 | *val = (*val >> 32) | (*val << 32); | ||
158 | #endif | ||
159 | return (unsigned long *)val; | ||
160 | } | ||
161 | |||
148 | static u32 *vgic_bitmap_get_reg(struct vgic_bitmap *x, | 162 | static u32 *vgic_bitmap_get_reg(struct vgic_bitmap *x, |
149 | int cpuid, u32 offset) | 163 | int cpuid, u32 offset) |
150 | { | 164 | { |
@@ -1442,7 +1456,7 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu) | |||
1442 | * active bit. | 1456 | * active bit. |
1443 | */ | 1457 | */ |
1444 | u64 eisr = vgic_get_eisr(vcpu); | 1458 | u64 eisr = vgic_get_eisr(vcpu); |
1445 | unsigned long *eisr_ptr = (unsigned long *)&eisr; | 1459 | unsigned long *eisr_ptr = u64_to_bitmask(&eisr); |
1446 | int lr; | 1460 | int lr; |
1447 | 1461 | ||
1448 | for_each_set_bit(lr, eisr_ptr, vgic->nr_lr) { | 1462 | for_each_set_bit(lr, eisr_ptr, vgic->nr_lr) { |
@@ -1505,7 +1519,7 @@ static void __kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu) | |||
1505 | 1519 | ||
1506 | level_pending = vgic_process_maintenance(vcpu); | 1520 | level_pending = vgic_process_maintenance(vcpu); |
1507 | elrsr = vgic_get_elrsr(vcpu); | 1521 | elrsr = vgic_get_elrsr(vcpu); |
1508 | elrsr_ptr = (unsigned long *)&elrsr; | 1522 | elrsr_ptr = u64_to_bitmask(&elrsr); |
1509 | 1523 | ||
1510 | /* Clear mappings for empty LRs */ | 1524 | /* Clear mappings for empty LRs */ |
1511 | for_each_set_bit(lr, elrsr_ptr, vgic->nr_lr) { | 1525 | for_each_set_bit(lr, elrsr_ptr, vgic->nr_lr) { |
@@ -1899,7 +1913,8 @@ int kvm_vgic_init(struct kvm *kvm) | |||
1899 | } | 1913 | } |
1900 | 1914 | ||
1901 | ret = kvm_phys_addr_ioremap(kvm, kvm->arch.vgic.vgic_cpu_base, | 1915 | ret = kvm_phys_addr_ioremap(kvm, kvm->arch.vgic.vgic_cpu_base, |
1902 | vgic->vcpu_base, KVM_VGIC_V2_CPU_SIZE); | 1916 | vgic->vcpu_base, KVM_VGIC_V2_CPU_SIZE, |
1917 | true); | ||
1903 | if (ret) { | 1918 | if (ret) { |
1904 | kvm_err("Unable to remap VGIC CPU to VCPU\n"); | 1919 | kvm_err("Unable to remap VGIC CPU to VCPU\n"); |
1905 | goto out; | 1920 | goto out; |