From nobody Wed Apr 10 15:19:22 2024 X-Original-To: dev-commits-src-main@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 4VF61k6P57z5HHbR; Wed, 10 Apr 2024 15:19:22 +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 4VF61k3HqKz4nN2; Wed, 10 Apr 2024 15:19:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712762362; 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=B2qIKRTJ81jh3/0JkubbmSfG81mVgNi9v2GKpjut6AU=; b=kVQx7jUNsdLG7FJn6V1KEhBQnGXjaRcrisYW+BzpkDuvyd4gwJUOt71IPDL+QotUYmh8pJ 961oqL++B2/YcG5H1XSk212G5vqiw7ZgqLRPdSds8JWtYGQrz8YLywAF6RPkvnFrDDjl8Z 3PcZ7QMg4D9G3YLWrxghBLp7YMykCR0aT/w/RnLPIIGu9jdGBKUm4s0GRBfm8Q4TMD5FlD BbVHoHomaEDFr4c+dCR+Hl86ubKjJsvM4T8OYQMztA+qUue3obFFr35uElhbp6O2/pC3Ix ZOTG8PyN9Vb/gUJY1EJ7TpZATEQNbsbSoVgxy4C9d+j7hICAh3gKrtNdN00+mA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712762362; a=rsa-sha256; cv=none; b=MEEi9x+9PF11+BXh7Yt1IufuOOBwBhCHy0LKIyhvxprEnIbGt93NrVkWUOubiEO2xkLpn/ I3thPXOgv1q6p9+hnJsPnq8nhFd8Zre2n2pZYoWsbzL25BYmcW1fMI5MrAqXep90z5oJcn TEvEX4tXhwC2WuPYWChItxniCZieIucZnW3UsZV7Sy/wUfY8X4K0DVPJFjaXL+nL1ZMA24 xqDjlDRefB4MS633xbEkdqmxoC6soX17J8x4Vud4BmPR7A7R1YuK/rngu9a/zOqyyNp5EN qWFj0R/Mxa6NvaB6wlnVrUfvsk5f5q0XUJRV7TCXekT6WgzM/+uoP9hEiryavw== 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=1712762362; 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=B2qIKRTJ81jh3/0JkubbmSfG81mVgNi9v2GKpjut6AU=; b=Btujh4mMuIhOfEeLoZ6vnPuOCvkb7wHYpzqFkcoK1a1bEAXy12GOZSvMGJJuzRtNsVnqd9 zh8OH1p3Xb0k9eQie+Aahda0w1OT2f5WdbYOhIjx4Ak4StXawrm7aYksqGAzyRjLhf1gtw NRZcE/6HNfnWBToDx+nZlS2R3USoT1ZN4MHq6JwxybNCIIZBqs5pDpjsSyl4GhX9X27/QB li3DT+f0ZErxzrXIBKl5kqRPpSZJmoHvU63jORd/Gs5G06Xq5HB5E7G/JNBy4TE3BgJzB8 NIQblRem0lVb8bUapcKPyfl3DN4bYEQkPvREnD6wiy01Dh5qAYjelLVSxC0T0A== 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 4VF61k2t99zjln; Wed, 10 Apr 2024 15:19:22 +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 43AFJMK4093569; Wed, 10 Apr 2024 15:19:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43AFJMEI093566; Wed, 10 Apr 2024 15:19:22 GMT (envelope-from git) Date: Wed, 10 Apr 2024 15:19:22 GMT Message-Id: <202404101519.43AFJMEI093566@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: 56a26fc1af60 - main - libvmmapi: Conditionalize compilation of some functions List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: dev-commits-src-main+owner@freebsd.org X-BeenThere: dev-commits-src-main@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: 56a26fc1af60e31732f8913ebe4c058095b6c721 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=56a26fc1af60e31732f8913ebe4c058095b6c721 commit 56a26fc1af60e31732f8913ebe4c058095b6c721 Author: Mark Johnston AuthorDate: 2024-04-03 17:45:06 +0000 Commit: Mark Johnston CommitDate: 2024-04-10 15:17:56 +0000 libvmmapi: Conditionalize compilation of some functions Hide definitions of several functions that currently don't have implementatations in the arm64 vmm port. In particular, add a WITH_VMMAPI_SNAPSHOT preprocessor variable that can be used to enable compilation of save/restore functions, and conditionalize compilation of some functions only used by amd64 bhyve. If in the long term they remain amd64-only, they can move to vmmapi_machdep.c, but for now it's not clear to me that that's the right thing to do. MFC after: 2 weeks Sponsored by: Innovate UK --- lib/libvmmapi/Makefile | 1 - lib/libvmmapi/amd64/Makefile.inc | 2 ++ lib/libvmmapi/amd64/vmmapi_machdep.c | 9 ++++++++- lib/libvmmapi/internal.h | 9 +-------- lib/libvmmapi/vmmapi.c | 10 ++++++++++ lib/libvmmapi/vmmapi.h | 4 +++- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/lib/libvmmapi/Makefile b/lib/libvmmapi/Makefile index dc7d48183439..1866c8fa5e7c 100644 --- a/lib/libvmmapi/Makefile +++ b/lib/libvmmapi/Makefile @@ -1,4 +1,3 @@ - PACKAGE=lib${LIB} LIB= vmmapi SHLIB_MAJOR= 6 diff --git a/lib/libvmmapi/amd64/Makefile.inc b/lib/libvmmapi/amd64/Makefile.inc index d122f742a667..a3da271433a1 100644 --- a/lib/libvmmapi/amd64/Makefile.inc +++ b/lib/libvmmapi/amd64/Makefile.inc @@ -1,3 +1,5 @@ SRCS+= ppt.c \ vmmapi_machdep.c \ vmmapi_freebsd_machdep.c + +CFLAGS+= -DWITH_VMMAPI_SNAPSHOT diff --git a/lib/libvmmapi/amd64/vmmapi_machdep.c b/lib/libvmmapi/amd64/vmmapi_machdep.c index 8990b28b4432..806c31abf426 100644 --- a/lib/libvmmapi/amd64/vmmapi_machdep.c +++ b/lib/libvmmapi/amd64/vmmapi_machdep.c @@ -77,7 +77,14 @@ const char *vm_capstrmap[] = { VM_RTC_WRITE, \ VM_RTC_READ, \ VM_RTC_SETTIME, \ - VM_RTC_GETTIME + VM_RTC_GETTIME, \ + VM_GET_GPA_PMAP, \ + VM_GLA2GPA, \ + VM_SET_INTINFO, \ + VM_GET_INTINFO, \ + VM_RESTART_INSTRUCTION, \ + VM_SNAPSHOT_REQ, \ + VM_RESTORE_TIME const cap_ioctl_t vm_ioctl_cmds[] = { VM_COMMON_IOCTLS, diff --git a/lib/libvmmapi/internal.h b/lib/libvmmapi/internal.h index 2b2f9eac3757..42be9ec59770 100644 --- a/lib/libvmmapi/internal.h +++ b/lib/libvmmapi/internal.h @@ -54,20 +54,13 @@ extern const char *vm_capstrmap[]; VM_GET_CAPABILITY, \ VM_STATS, \ VM_STAT_DESC, \ - VM_GET_GPA_PMAP, \ - VM_GLA2GPA, \ VM_GLA2GPA_NOFAULT, \ VM_ACTIVATE_CPU, \ VM_GET_CPUS, \ VM_SUSPEND_CPU, \ VM_RESUME_CPU, \ - VM_SET_INTINFO, \ - VM_GET_INTINFO, \ - VM_RESTART_INSTRUCTION, \ VM_SET_TOPOLOGY, \ - VM_GET_TOPOLOGY, \ - VM_SNAPSHOT_REQ, \ - VM_RESTORE_TIME + VM_GET_TOPOLOGY #define VM_PPT_IOCTLS \ VM_BIND_PPTDEV, \ diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c index 5dcad8a16703..0cf051567110 100644 --- a/lib/libvmmapi/vmmapi.c +++ b/lib/libvmmapi/vmmapi.c @@ -51,7 +51,9 @@ #include #include #include +#ifdef WITH_VMMAPI_SNAPSHOT #include +#endif #include "vmmapi.h" #include "internal.h" @@ -796,6 +798,7 @@ vm_get_stat_desc(struct vmctx *ctx, int index) return (NULL); } +#ifdef __amd64__ int vm_get_gpa_pmap(struct vmctx *ctx, uint64_t gpa, uint64_t *pte, int *num) { @@ -835,6 +838,7 @@ vm_gla2gpa(struct vcpu *vcpu, struct vm_guest_paging *paging, } return (error); } +#endif int vm_gla2gpa_nofault(struct vcpu *vcpu, struct vm_guest_paging *paging, @@ -860,6 +864,7 @@ vm_gla2gpa_nofault(struct vcpu *vcpu, struct vm_guest_paging *paging, #define min(a,b) (((a) < (b)) ? (a) : (b)) #endif +#ifdef __amd64__ int vm_copy_setup(struct vcpu *vcpu, struct vm_guest_paging *paging, uint64_t gla, size_t len, int prot, struct iovec *iov, int iovcnt, @@ -897,6 +902,7 @@ vm_copy_setup(struct vcpu *vcpu, struct vm_guest_paging *paging, } return (0); } +#endif void vm_copy_teardown(struct iovec *iov __unused, int iovcnt __unused) @@ -1041,6 +1047,7 @@ vm_resume_all_cpus(struct vmctx *ctx) return (error); } +#ifdef __amd64__ int vm_get_intinfo(struct vcpu *vcpu, uint64_t *info1, uint64_t *info2) { @@ -1067,7 +1074,9 @@ vm_set_intinfo(struct vcpu *vcpu, uint64_t info1) error = vcpu_ioctl(vcpu, VM_SET_INTINFO, &vmii); return (error); } +#endif +#ifdef WITH_VMMAPI_SNAPSHOT int vm_restart_instruction(struct vcpu *vcpu) { @@ -1098,6 +1107,7 @@ vm_restore_time(struct vmctx *ctx) dummy = 0; return (ioctl(ctx->fd, VM_RESTORE_TIME, &dummy)); } +#endif int vm_set_topology(struct vmctx *ctx, diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h index ea869a0c1749..d2a217c4d2e9 100644 --- a/lib/libvmmapi/vmmapi.h +++ b/lib/libvmmapi/vmmapi.h @@ -128,9 +128,11 @@ int vm_setup_memory(struct vmctx *ctx, size_t len, enum vm_mmap_style s); void *vm_map_gpa(struct vmctx *ctx, vm_paddr_t gaddr, size_t len); /* inverse operation to vm_map_gpa - extract guest address from host pointer */ vm_paddr_t vm_rev_map_gpa(struct vmctx *ctx, void *addr); +#ifdef __amd64__ int vm_get_gpa_pmap(struct vmctx *, uint64_t gpa, uint64_t *pte, int *num); int vm_gla2gpa(struct vcpu *vcpu, struct vm_guest_paging *paging, uint64_t gla, int prot, uint64_t *gpa, int *fault); +#endif int vm_gla2gpa_nofault(struct vcpu *vcpu, struct vm_guest_paging *paging, uint64_t gla, int prot, uint64_t *gpa, int *fault); @@ -220,7 +222,6 @@ int vm_get_x2apic_state(struct vcpu *vcpu, enum x2apic_state *s); int vm_set_x2apic_state(struct vcpu *vcpu, enum x2apic_state s); int vm_get_hpet_capabilities(struct vmctx *ctx, uint32_t *capabilities); -#endif /* * Translate the GLA range [gla,gla+len) into GPA segments in 'iov'. @@ -234,6 +235,7 @@ int vm_get_hpet_capabilities(struct vmctx *ctx, uint32_t *capabilities); int vm_copy_setup(struct vcpu *vcpu, struct vm_guest_paging *pg, uint64_t gla, size_t len, int prot, struct iovec *iov, int iovcnt, int *fault); +#endif void vm_copyin(struct iovec *guest_iov, void *host_dst, size_t len); void vm_copyout(const void *host_src, struct iovec *guest_iov, size_t len); void vm_copy_teardown(struct iovec *iov, int iovcnt);