git: 5baa83cfcbd8 - main - riscv/vmm: Remove a redundant maxcpu check in vm_alloc_vcpu()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 31 Oct 2025 14:19:34 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=5baa83cfcbd87109dc8a61fbb2e183998cc2d5c5
commit 5baa83cfcbd87109dc8a61fbb2e183998cc2d5c5
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-10-31 14:08:45 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-10-31 14:08:45 +0000
riscv/vmm: Remove a redundant maxcpu check in vm_alloc_vcpu()
aplic_max_cpu_count() just returns the VM's max vCPU count, and
vm_alloc_vcpu() already checks that. Just remove this check so that
it's easier to merge vm_alloc_vcpu() into MI code.
If the APLIC really does require us to lower the limit, we should
instead adjust vm->maxcpu in vm_create().
No functional change intended.
Reviewed by: br
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D53496
---
sys/riscv/vmm/vmm.c | 4 ----
sys/riscv/vmm/vmm_aplic.c | 10 ----------
sys/riscv/vmm/vmm_aplic.h | 1 -
3 files changed, 15 deletions(-)
diff --git a/sys/riscv/vmm/vmm.c b/sys/riscv/vmm/vmm.c
index 24b4be89af48..a9eb9d144336 100644
--- a/sys/riscv/vmm/vmm.c
+++ b/sys/riscv/vmm/vmm.c
@@ -319,10 +319,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 >= aplic_max_cpu_count(vm->cookie))
- return (NULL);
-
vcpu = (struct vcpu *)
atomic_load_acq_ptr((uintptr_t *)&vm->vcpu[vcpuid]);
if (__predict_true(vcpu != NULL))
diff --git a/sys/riscv/vmm/vmm_aplic.c b/sys/riscv/vmm/vmm_aplic.c
index 4df41f2de1a5..74cb4fef4273 100644
--- a/sys/riscv/vmm/vmm_aplic.c
+++ b/sys/riscv/vmm/vmm_aplic.c
@@ -577,13 +577,3 @@ aplic_sync_hwstate(struct hypctx *hypctx)
{
}
-
-int
-aplic_max_cpu_count(struct hyp *hyp)
-{
- int16_t max_count;
-
- max_count = vm_get_maxcpus(hyp->vm);
-
- return (max_count);
-}
diff --git a/sys/riscv/vmm/vmm_aplic.h b/sys/riscv/vmm/vmm_aplic.h
index 49510221b419..96018fe9adda 100644
--- a/sys/riscv/vmm/vmm_aplic.h
+++ b/sys/riscv/vmm/vmm_aplic.h
@@ -49,6 +49,5 @@ void aplic_cpuinit(struct hypctx *hypctx);
void aplic_cpucleanup(struct hypctx *hypctx);
void aplic_flush_hwstate(struct hypctx *hypctx);
void aplic_sync_hwstate(struct hypctx *hypctx);
-int aplic_max_cpu_count(struct hyp *hyp);
#endif /* !_VMM_APLIC_H_ */