Skip to content

Commit c5e2bf0

Browse files
committed
Merge tag 'kvmarm-fixes-5.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm64 fixes for 5.14, take #2 - Plug race between enabling MTE and creating vcpus - Fix off-by-one bug when checking whether an address range is RAM
2 parents 18712c1 + c4d7c51 commit c5e2bf0

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

arch/arm64/kvm/arm.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,14 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
9494
kvm->arch.return_nisv_io_abort_to_user = true;
9595
break;
9696
case KVM_CAP_ARM_MTE:
97-
if (!system_supports_mte() || kvm->created_vcpus)
98-
return -EINVAL;
99-
r = 0;
100-
kvm->arch.mte_enabled = true;
97+
mutex_lock(&kvm->lock);
98+
if (!system_supports_mte() || kvm->created_vcpus) {
99+
r = -EINVAL;
100+
} else {
101+
r = 0;
102+
kvm->arch.mte_enabled = true;
103+
}
104+
mutex_unlock(&kvm->lock);
101105
break;
102106
default:
103107
r = -EINVAL;

arch/arm64/kvm/hyp/nvhe/mem_protect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static bool range_is_memory(u64 start, u64 end)
193193
{
194194
struct kvm_mem_range r1, r2;
195195

196-
if (!find_mem_range(start, &r1) || !find_mem_range(end, &r2))
196+
if (!find_mem_range(start, &r1) || !find_mem_range(end - 1, &r2))
197197
return false;
198198
if (r1.start != r2.start)
199199
return false;

0 commit comments

Comments
 (0)