git: 55096ebddc15 - stable/15 - arm64/vmm: Move the vgic_max_cpu_count() check
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 18 Nov 2025 15:02:56 UTC
The branch stable/15 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=55096ebddc1557b7f0e4cb294878fcc8621de37b
commit 55096ebddc1557b7f0e4cb294878fcc8621de37b
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-11-04 16:58:25 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-11-18 14:57:42 +0000
arm64/vmm: Move the vgic_max_cpu_count() check
vm_alloc_vcpu() is called quite frequently, and we don't need to apply
the vgic limit unless we're actually allocating a vcpu structure for the
first time.
No functional change intended.
Reviewed by: andrew
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D53580
(cherry picked from commit f3a7ed2047dffaebbfbb3920e993e9df424be728)
---
sys/arm64/vmm/vmm.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/sys/arm64/vmm/vmm.c b/sys/arm64/vmm/vmm.c
index dfaba058e205..5225b995a75d 100644
--- a/sys/arm64/vmm/vmm.c
+++ b/sys/arm64/vmm/vmm.c
@@ -394,10 +394,6 @@ vm_alloc_vcpu(struct vm *vm, int vcpuid)
if (vcpuid < 0 || vcpuid >= vm_get_maxcpus(vm))
return (NULL);
- /* Some interrupt controllers may have a CPU limit */
- if (vcpuid >= vgic_max_cpu_count(vm->cookie))
- return (NULL);
-
vcpu = (struct vcpu *)
atomic_load_acq_ptr((uintptr_t *)&vm->vcpu[vcpuid]);
if (__predict_true(vcpu != NULL))
@@ -406,6 +402,12 @@ vm_alloc_vcpu(struct vm *vm, int vcpuid)
sx_xlock(&vm->vcpus_init_lock);
vcpu = vm->vcpu[vcpuid];
if (vcpu == NULL && !vm->dying) {
+ /* Some interrupt controllers may have a CPU limit */
+ if (vcpuid >= vgic_max_cpu_count(vm->cookie)) {
+ sx_xunlock(&vm->vcpus_init_lock);
+ return (NULL);
+ }
+
vcpu = vcpu_alloc(vm, vcpuid);
vcpu_init(vcpu);