From nobody Tue Feb 06 15:40:43 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 4TTnWv6vbZz59T5B; Tue, 6 Feb 2024 15:40:43 +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 4TTnWv5NkXz4nQ6; Tue, 6 Feb 2024 15:40:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707234043; 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=duRN3vBTasOBKM3h3858jbH0CULLhNPpbnz1FV7NGqA=; b=vQJhopLdksdzUDYh9o4JNj9Rtme9M5qa3u0ddXyDrqhxcP39NIHMDSdVgOHHWyAIGg1UZW Py9XrUChNLVlgxxb4Kjn9N06VRkglUP7I5TM2CsTpLnjhhBo6gfmOtu9cl9lFRUrzZNaT/ PJKFJTufNJFXdAhZGdA03fkHeYKu036EcoIuV+T9zqCp75zA/s3EvX1u9w5yFAjrMQRW4k 8hd3oZzdDQKAFEBWLrMVS3vvlJY8kwhJayMqCbv7THInCb1M+7S7221VvHkJu3ygCvbVpQ 9gyGjriAgOrTgNB+WAIQmoDVn7dHGPXtBRlISiHpt/qlRh2FOPkCiivNtSTOyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707234043; 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=duRN3vBTasOBKM3h3858jbH0CULLhNPpbnz1FV7NGqA=; b=Kexx8hwmi+jZTh+GJKzPVySlxvNUOUP+Pw60gvPmbHnUxGaMhfBgnW4Kso0EPy4bZSk/DK lfC030nm2EIwYvc+RBvjyGFP0wHmC0Du+AKOVwDoodbRfYDzld8sI8mDHEOTZi1FbZadX8 ZJh9ERbbCvW9BiK22lKvd6QI8ltzMO81x/L+acxYXNVrHf2Kj7GmK5hrmC5vsLEt8ecWTM s3qHkIureVx2PR5qX3IGMA2KoPP2IxrqFT89lBu1/tZXOXT6v3SE0g1Iu//Vx6Ld4VoTuD BZHMPt7aXTL6yUHSSlKy+xk93hzdJyfQ34t4c678GDz9Xfz5VvUWkqEseUfo4w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707234043; a=rsa-sha256; cv=none; b=IMjP2rN1ZtahJLoqpOfkB26JEcKHRYzGrOFffcAyrpWmliwXVVQ3ROlK29ffKDE2m6GaR/ YSsBP230M9ScZdMAPvhcBo8jiwYo/aLvCddulhDyIfN74e3PYweXMakF6w7SUyJJmdsNp6 G2xlOOACFKRuKbT73mhDSQUwmTsd3T+uGMrNpwdUAB7fXdst+SMIN+n9PeZQbk+6Z+s7tq vIBzCPxBRfpjD/I01OAxqNrLA/vaQ71bw29gQHZchswQilXCDYiF2KQdoUI7YFZLDKAuUv oCD6QktOcHnW6rkKNg83aB1TM78IlF9dZ5p67IACIU69+sPOTuiUV3TviFU6VA== 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 4TTnWv4SK7zTr3; Tue, 6 Feb 2024 15:40:43 +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 416FehxH091502; Tue, 6 Feb 2024 15:40:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 416FehUh091499; Tue, 6 Feb 2024 15:40:43 GMT (envelope-from git) Date: Tue, 6 Feb 2024 15:40:43 GMT Message-Id: <202402061540.416FehUh091499@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: 7572fe89ada6 - main - vmm: Fix compiling error with BHYVE_SNAPSHOT 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: owner-dev-commits-src-all@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: 7572fe89ada63719b558c6b844e2743cd3ff6b6a Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7572fe89ada63719b558c6b844e2743cd3ff6b6a commit 7572fe89ada63719b558c6b844e2743cd3ff6b6a Author: Vitaliy Gusev AuthorDate: 2024-02-06 15:36:17 +0000 Commit: Mark Johnston CommitDate: 2024-02-06 15:38:34 +0000 vmm: Fix compiling error with BHYVE_SNAPSHOT The return values of copyin() and copyout() must be checked. vm_snapshot_buf_cmp() is unused by the kernel and was incorrectly implemented, so just remove it. Reviewed by: markj Sponsored by: vStack MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D43754 --- sys/amd64/include/vmm_snapshot.h | 7 +++++-- sys/amd64/vmm/vmm_snapshot.c | 44 +++++++--------------------------------- 2 files changed, 12 insertions(+), 39 deletions(-) diff --git a/sys/amd64/include/vmm_snapshot.h b/sys/amd64/include/vmm_snapshot.h index 5ed00c71d58a..b39c342bf6d9 100644 --- a/sys/amd64/include/vmm_snapshot.h +++ b/sys/amd64/include/vmm_snapshot.h @@ -98,8 +98,6 @@ void vm_snapshot_buf_err(const char *bufname, const enum vm_snapshot_op op); int vm_snapshot_buf(void *data, size_t data_size, struct vm_snapshot_meta *meta); size_t vm_get_snapshot_size(struct vm_snapshot_meta *meta); -int vm_snapshot_buf_cmp(void *data, size_t data_size, - struct vm_snapshot_meta *meta); #define SNAPSHOT_BUF_OR_LEAVE(DATA, LEN, META, RES, LABEL) \ do { \ @@ -113,6 +111,10 @@ do { \ #define SNAPSHOT_VAR_OR_LEAVE(DATA, META, RES, LABEL) \ SNAPSHOT_BUF_OR_LEAVE(&(DATA), sizeof(DATA), (META), (RES), LABEL) +#ifndef _KERNEL +int vm_snapshot_buf_cmp(void *data, size_t data_size, + struct vm_snapshot_meta *meta); + /* compare the value in the meta buffer with the data */ #define SNAPSHOT_BUF_CMP_OR_LEAVE(DATA, LEN, META, RES, LABEL) \ do { \ @@ -126,4 +128,5 @@ do { \ #define SNAPSHOT_VAR_CMP_OR_LEAVE(DATA, META, RES, LABEL) \ SNAPSHOT_BUF_CMP_OR_LEAVE(&(DATA), sizeof(DATA), (META), (RES), LABEL) +#endif /* _KERNEL */ #endif diff --git a/sys/amd64/vmm/vmm_snapshot.c b/sys/amd64/vmm/vmm_snapshot.c index 54de57e04c4a..cd53f05a1603 100644 --- a/sys/amd64/vmm/vmm_snapshot.c +++ b/sys/amd64/vmm/vmm_snapshot.c @@ -57,7 +57,7 @@ int vm_snapshot_buf(void *data, size_t data_size, struct vm_snapshot_meta *meta) { struct vm_snapshot_buffer *buffer; - int op; + int op, error; buffer = &meta->buffer; op = meta->op; @@ -68,11 +68,14 @@ vm_snapshot_buf(void *data, size_t data_size, struct vm_snapshot_meta *meta) } if (op == VM_SNAPSHOT_SAVE) - copyout(data, buffer->buf, data_size); + error = copyout(data, buffer->buf, data_size); else if (op == VM_SNAPSHOT_RESTORE) - copyin(buffer->buf, data, data_size); + error = copyin(buffer->buf, data, data_size); else - return (EINVAL); + error = EINVAL; + + if (error) + return (error); buffer->buf += data_size; buffer->buf_rem -= data_size; @@ -98,36 +101,3 @@ vm_get_snapshot_size(struct vm_snapshot_meta *meta) return (length); } - -int -vm_snapshot_buf_cmp(void *data, size_t data_size, struct vm_snapshot_meta *meta) -{ - struct vm_snapshot_buffer *buffer; - int op; - int ret; - - buffer = &meta->buffer; - op = meta->op; - - if (buffer->buf_rem < data_size) { - printf("%s: buffer too small\r\n", __func__); - ret = E2BIG; - goto done; - } - - if (op == VM_SNAPSHOT_SAVE) { - ret = 0; - copyout(data, buffer->buf, data_size); - } else if (op == VM_SNAPSHOT_RESTORE) { - ret = memcmp(data, buffer->buf, data_size); - } else { - ret = EINVAL; - goto done; - } - - buffer->buf += data_size; - buffer->buf_rem -= data_size; - -done: - return (ret); -}