KVM/arm64 fixes for 6.8, take #1

- Don't source the VFIO Kconfig twice
 
 - Fix protected-mode locking order between kvm and vcpus
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEn9UcU+C1Yxj9lZw9I9DQutE9ekMFAmXDlY4ACgkQI9DQutE9
 ekN6nRAAi0JEvY80wiztUSqolhT0/M2oewwxuJ9TcCvMbRhndcoEUKki4OqdhIth
 QOVVSNd2LNSRaObNAr0nRpwB2Kdn372l3AtlIieYAnlER/idXQaTPuhR3mmby2LP
 zhQdgPQm1Nju6ga7FbjFvlXo9hkZPbt8gaW7kP/K/SttFm+3a5ycqpB+U0ttvGqf
 PhhImP3xPDnkQXe7NasTKAOkBtB8l2Q/ByqoN5+Xk3SgGRh8o/Uu3E4t3A8/7VmW
 dRB24gbgnAbbgY4P7IsMrCAtHl0dFfkrEef8Ri6pw3nVd/SMzH52MbizQROd2flh
 Qvhld/UBzGbk+oRf6JJ9AzXdY2vGl0LDGw4VxEfvn+JpB2wMRhcmnupcwTdkJq6g
 lyzH9aOHJmNnPRvSDapHMIvlUxmV5ay4XGBopd0jUWaZoB3vsoxW2wPPA52iP66p
 82cXWtOUPmsRE49D7+jVxtLjrw0gf9BQyGZ7StTxuhSKsoEGyHgrsSvuI4s4hohd
 VUrUf76xLi9yKnk4hYZ3Sbgz0KAHXRwkK2l5oW5zwL3BI5JnwgtFBB0R9e8hbYbN
 nVMO6Q5Xwc3VJKNmGQTLCzBEIaeLsR5k+w9kYDatCDSMqfZq6evu/ipGqtup7fK9
 9u+FfFosnXEYnC/cstqPwVO9DIVjzjeDEEz5JtUUoiKSBMOGcLQ=
 =wb0z
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Paolo Bonzini 2024-02-16 12:02:31 -05:00
commit 8046fa5fc2
2 changed files with 17 additions and 11 deletions

View File

@ -3,7 +3,6 @@
# KVM configuration
#
source "virt/lib/Kconfig"
source "virt/kvm/Kconfig"
menuconfig VIRTUALIZATION

View File

@ -101,6 +101,17 @@ void __init kvm_hyp_reserve(void)
hyp_mem_base);
}
static void __pkvm_destroy_hyp_vm(struct kvm *host_kvm)
{
if (host_kvm->arch.pkvm.handle) {
WARN_ON(kvm_call_hyp_nvhe(__pkvm_teardown_vm,
host_kvm->arch.pkvm.handle));
}
host_kvm->arch.pkvm.handle = 0;
free_hyp_memcache(&host_kvm->arch.pkvm.teardown_mc);
}
/*
* Allocates and donates memory for hypervisor VM structs at EL2.
*
@ -181,7 +192,7 @@ static int __pkvm_create_hyp_vm(struct kvm *host_kvm)
return 0;
destroy_vm:
pkvm_destroy_hyp_vm(host_kvm);
__pkvm_destroy_hyp_vm(host_kvm);
return ret;
free_vm:
free_pages_exact(hyp_vm, hyp_vm_sz);
@ -194,23 +205,19 @@ int pkvm_create_hyp_vm(struct kvm *host_kvm)
{
int ret = 0;
mutex_lock(&host_kvm->lock);
mutex_lock(&host_kvm->arch.config_lock);
if (!host_kvm->arch.pkvm.handle)
ret = __pkvm_create_hyp_vm(host_kvm);
mutex_unlock(&host_kvm->lock);
mutex_unlock(&host_kvm->arch.config_lock);
return ret;
}
void pkvm_destroy_hyp_vm(struct kvm *host_kvm)
{
if (host_kvm->arch.pkvm.handle) {
WARN_ON(kvm_call_hyp_nvhe(__pkvm_teardown_vm,
host_kvm->arch.pkvm.handle));
}
host_kvm->arch.pkvm.handle = 0;
free_hyp_memcache(&host_kvm->arch.pkvm.teardown_mc);
mutex_lock(&host_kvm->arch.config_lock);
__pkvm_destroy_hyp_vm(host_kvm);
mutex_unlock(&host_kvm->arch.config_lock);
}
int pkvm_init_host_vm(struct kvm *host_kvm)