From nobody Wed Apr 10 15:19:05 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VF61P5pJKz5HHQM; Wed, 10 Apr 2024 15:19:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VF61P3g02z4mxy; Wed, 10 Apr 2024 15:19:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712762345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=I8HNd+uT1swtsq2InmvFo6cp95d7fDvMoPY+0Mfuh1w=; b=xVN7KonBUHJAh9LDuNHyBPxbepFcGe4vmBwP3E8GkPRiDJIQtLnI+hvMTzCBhTb/psWdBt dtLcsnfqWb48bo5Cyy9r7oHaCgSfJepLM/cWXoYRPYoj2MoLBHbcLiCOnTquIrn91osMYq mf8+2ukX5IbBPUwjftWerRkdT+JBq7f+xbPt55KkJqBkhgqtp9Ok216Mc2vq1syI/LAqPH HpYDFBb4rJQKs7Pqy3W2Uw1RzVnaHy4Rgv31NHI+W5p7yRnvLqpPixY5J3LN/3KdRIQ1qd sy/vZKQQEPlw9C/GhWu7Na8tIwU3HRjRVISzWTpaxJ7cMPI4J7lE21TmoLBYpQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712762345; a=rsa-sha256; cv=none; b=hK5W+Gt5WpxKXZ1czjU1/CaANDeeKKVLNvFwCY5ar45GflsHnwqT9nTL7K5EHzaxURZux0 5dlSRyOdjyoFfmf446nsu+4bW1/TER5yVxl4CWOiSkvWggjtAOmNPqhfUFzGGwaSyDjF0g JykwX4zP3oxDucovGhzCI1fcns1WfA6OG2gNNvoOCd7Vwn8fO/nA/+epPTK95dVmXebZV3 +AfOKzekZ6QZcerLEd+hMi/TupaCyV8KlsiWBYg2fPTndCap05diHTyNsGt1nxq5H31kBC icF0RaLYlQnq9O7S949xCNF6/Quciom9YqOap2cmHCo0A88+Ld3DJ5VubDVsyg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712762345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=I8HNd+uT1swtsq2InmvFo6cp95d7fDvMoPY+0Mfuh1w=; b=jzDwuaST978h6lDyf1D7BFSpJtbmP6k5RohzqMlJS2RomptQDYUUP5eI0gdhiSEXHgWiXf CxJ7GynRXOAokxFCiOZuwLWHtN4qfk05/DCBSbP4WCSV8ohjT6+r48TjsUtKG1tIezpMIH X7AnmoeIGbfDHuH6nPIlXoM3C8cffCMXkTDAXTRiHLy5GcSMGeAiqs/EfIiDsO5C+Mf2Wb VEe6F2SMqUu8CLYvx3of80xDMoT5HtV9NVktZgLFirq//aRxaiutLNGAdmCMF2Zvm68uFj icAD3jgvhcdtI9t2Yg0jQ1kWGkHy+aZxNAKAFWex62DNttUjlvhBwXlgd7ttVQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VF61P2nyhzjSH; Wed, 10 Apr 2024 15:19:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43AFJ54L092790; Wed, 10 Apr 2024 15:19:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43AFJ5xP092787; Wed, 10 Apr 2024 15:19:05 GMT (envelope-from git) Date: Wed, 10 Apr 2024 15:19:05 GMT Message-Id: <202404101519.43AFJ5xP092787@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 85efb31d50af - main - libvmmapi: Move VM capability names to vmmapi_machdep.c List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: dev-commits-src-all+owner@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 85efb31d50af3cf6987d74f4abe9c54ae493f3a6 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=85efb31d50af3cf6987d74f4abe9c54ae493f3a6 commit 85efb31d50af3cf6987d74f4abe9c54ae493f3a6 Author: Mark Johnston AuthorDate: 2024-04-03 16:55:36 +0000 Commit: Mark Johnston 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); }