git: 85efb31d50af - main - libvmmapi: Move VM capability names to vmmapi_machdep.c
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 10 Apr 2024 15:19:05 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=85efb31d50af3cf6987d74f4abe9c54ae493f3a6
commit 85efb31d50af3cf6987d74f4abe9c54ae493f3a6
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-04-03 16:55:36 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-04-10 15:17:55 +0000
libvmmapi: Move VM capability names to vmmapi_machdep.c
Add some missing entries while here.
Reviewed by: corvink, jhb
MFC after: 2 weeks
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D41000
---
lib/libvmmapi/amd64/vmmapi_machdep.c | 15 +++++++++++++++
lib/libvmmapi/internal.h | 2 ++
lib/libvmmapi/vmmapi.c | 23 +++++------------------
3 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/lib/libvmmapi/amd64/vmmapi_machdep.c b/lib/libvmmapi/amd64/vmmapi_machdep.c
index 5ed198d7b76a..c19e9c6f935f 100644
--- a/lib/libvmmapi/amd64/vmmapi_machdep.c
+++ b/lib/libvmmapi/amd64/vmmapi_machdep.c
@@ -37,6 +37,21 @@
#include "vmmapi.h"
#include "internal.h"
+const char *vm_capstrmap[] = {
+ [VM_CAP_HALT_EXIT] = "hlt_exit",
+ [VM_CAP_MTRAP_EXIT] = "mtrap_exit",
+ [VM_CAP_PAUSE_EXIT] = "pause_exit",
+ [VM_CAP_UNRESTRICTED_GUEST] = "unrestricted_guest",
+ [VM_CAP_ENABLE_INVPCID] = "enable_invpcid",
+ [VM_CAP_BPT_EXIT] = "bpt_exit",
+ [VM_CAP_RDPID] = "rdpid",
+ [VM_CAP_RDTSCP] = "rdtscp",
+ [VM_CAP_IPI_EXIT] = "ipi_exit",
+ [VM_CAP_MASK_HWINTR] = "mask_hwintr",
+ [VM_CAP_RFLAGS_TF] = "rflags_tf",
+ [VM_CAP_MAX] = NULL,
+};
+
int
vm_set_desc(struct vcpu *vcpu, int reg,
uint64_t base, uint32_t limit, uint32_t access)
diff --git a/lib/libvmmapi/internal.h b/lib/libvmmapi/internal.h
index e312e21958ca..973a70afe022 100644
--- a/lib/libvmmapi/internal.h
+++ b/lib/libvmmapi/internal.h
@@ -24,4 +24,6 @@ struct vcpu {
int vcpu_ioctl(struct vcpu *vcpu, u_long cmd, void *arg);
+extern const char *vm_capstrmap[];
+
#endif /* !__VMMAPI_INTERNAL_H__ */
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index 2401f7cd2428..cc765deb904c 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -711,27 +711,14 @@ vm_readwrite_kernemu_device(struct vcpu *vcpu, vm_paddr_t gpa,
return (rc);
}
-static const char *capstrmap[] = {
- [VM_CAP_HALT_EXIT] = "hlt_exit",
- [VM_CAP_MTRAP_EXIT] = "mtrap_exit",
- [VM_CAP_PAUSE_EXIT] = "pause_exit",
- [VM_CAP_UNRESTRICTED_GUEST] = "unrestricted_guest",
- [VM_CAP_ENABLE_INVPCID] = "enable_invpcid",
- [VM_CAP_BPT_EXIT] = "bpt_exit",
- [VM_CAP_RDPID] = "rdpid",
- [VM_CAP_RDTSCP] = "rdtscp",
- [VM_CAP_IPI_EXIT] = "ipi_exit",
- [VM_CAP_MASK_HWINTR] = "mask_hwintr",
- [VM_CAP_RFLAGS_TF] = "rflags_tf",
-};
-
int
vm_capability_name2type(const char *capname)
{
int i;
- for (i = 0; i < (int)nitems(capstrmap); i++) {
- if (strcmp(capstrmap[i], capname) == 0)
+ for (i = 0; i < VM_CAP_MAX; i++) {
+ if (vm_capstrmap[i] != NULL &&
+ strcmp(vm_capstrmap[i], capname) == 0)
return (i);
}
@@ -741,8 +728,8 @@ vm_capability_name2type(const char *capname)
const char *
vm_capability_type2name(int type)
{
- if (type >= 0 && type < (int)nitems(capstrmap))
- return (capstrmap[type]);
+ if (type >= 0 && type < VM_CAP_MAX)
+ return (vm_capstrmap[type]);
return (NULL);
}