Skip to content

Commit 8046fa5

Browse files
committed
Merge tag 'kvmarm-fixes-6.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm64 fixes for 6.8, take #1 - Don't source the VFIO Kconfig twice - Fix protected-mode locking order between kvm and vcpus
2 parents e67391c + 42dfa94 commit 8046fa5

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

arch/arm64/kvm/Kconfig

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# KVM configuration
44
#
55

6-
source "virt/lib/Kconfig"
76
source "virt/kvm/Kconfig"
87

98
menuconfig VIRTUALIZATION

arch/arm64/kvm/pkvm.c

+17-10
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ void __init kvm_hyp_reserve(void)
101101
hyp_mem_base);
102102
}
103103

104+
static void __pkvm_destroy_hyp_vm(struct kvm *host_kvm)
105+
{
106+
if (host_kvm->arch.pkvm.handle) {
107+
WARN_ON(kvm_call_hyp_nvhe(__pkvm_teardown_vm,
108+
host_kvm->arch.pkvm.handle));
109+
}
110+
111+
host_kvm->arch.pkvm.handle = 0;
112+
free_hyp_memcache(&host_kvm->arch.pkvm.teardown_mc);
113+
}
114+
104115
/*
105116
* Allocates and donates memory for hypervisor VM structs at EL2.
106117
*
@@ -181,7 +192,7 @@ static int __pkvm_create_hyp_vm(struct kvm *host_kvm)
181192
return 0;
182193

183194
destroy_vm:
184-
pkvm_destroy_hyp_vm(host_kvm);
195+
__pkvm_destroy_hyp_vm(host_kvm);
185196
return ret;
186197
free_vm:
187198
free_pages_exact(hyp_vm, hyp_vm_sz);
@@ -194,23 +205,19 @@ int pkvm_create_hyp_vm(struct kvm *host_kvm)
194205
{
195206
int ret = 0;
196207

197-
mutex_lock(&host_kvm->lock);
208+
mutex_lock(&host_kvm->arch.config_lock);
198209
if (!host_kvm->arch.pkvm.handle)
199210
ret = __pkvm_create_hyp_vm(host_kvm);
200-
mutex_unlock(&host_kvm->lock);
211+
mutex_unlock(&host_kvm->arch.config_lock);
201212

202213
return ret;
203214
}
204215

205216
void pkvm_destroy_hyp_vm(struct kvm *host_kvm)
206217
{
207-
if (host_kvm->arch.pkvm.handle) {
208-
WARN_ON(kvm_call_hyp_nvhe(__pkvm_teardown_vm,
209-
host_kvm->arch.pkvm.handle));
210-
}
211-
212-
host_kvm->arch.pkvm.handle = 0;
213-
free_hyp_memcache(&host_kvm->arch.pkvm.teardown_mc);
218+
mutex_lock(&host_kvm->arch.config_lock);
219+
__pkvm_destroy_hyp_vm(host_kvm);
220+
mutex_unlock(&host_kvm->arch.config_lock);
214221
}
215222

216223
int pkvm_init_host_vm(struct kvm *host_kvm)

0 commit comments

Comments
 (0)