From nobody Tue Feb 20 14:23:26 2024 X-Original-To: dev-commits-src-branches@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 4TfM8G4mdFz5C8KC; Tue, 20 Feb 2024 14:23:26 +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 4TfM8G3DjTz56d3; Tue, 20 Feb 2024 14:23:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708439006; 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=wZMJAJlBwFb2bqjw2YPxWmFitPzXebKPNOCXN62n2NY=; b=xoM1gSuUNrYXU4dTsCp/rjGXfyEDw58SDVPaQZqo8A8hmHEJ1CXPdw/aieb3wgjubN6aye 3goLTWdvUcKlAZkOWkxE72exLR0LVUqNhy1v6uZJeACZsKJuFhLBiUW54HWqhmVURaWCf/ 7zA0DrqllYdLMB6J5mKKomSV3NQAOjQrnJHksZKfOTHifUfziCCvutUonN8tEvl3CrYNtG KBHcDR3ymw/c8HgjgzFD2TuEIxqBgISsX9CNZdAfC91neLBx8YLN0hcBBsMqJBZ2lHX1WT tndTYICOM2qFr3zscnmdxBDP1Q1E54IDv6cbglD8KgGkmIc4srkWunXDvoaLZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708439006; 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=wZMJAJlBwFb2bqjw2YPxWmFitPzXebKPNOCXN62n2NY=; b=BWpiGfQR8oaAb//wodvVMT8tmZcN6eiOzYC3Tb1obiGVbIS1GBmPpIOwcMjL8SP1a5ozPl pTawpo6YFFJFole+kBhPVNDHGr5NnhN3EHn3hO1SBCV65NSHAKZPYZFrelPSdg5MbqQY0s Dpwjzq9h5cA1BX9Qqt8vV/M2662V55zYp30og8K3dYbIx2q5oiTfgB5ol0qNgETBky+PXH LCXMj0S7Nq7OuWGFb3nAPOqr4MMFSmZujA69fZDDYhnfb+SL6js2JM/sIQxVHCapWk3YlJ 6BzOIfM0FK0jZlyxvJDOv0IAatMcdchU0BIFWYS1jyhX1NoQ9Jb2J01vkJRXLw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708439006; a=rsa-sha256; cv=none; b=iIvJrPOmG8YvHOlJ7xqyi93yPNtwrEIcxoYPu3yN2Og9lGmVATtKUSIC9jL2+gVGZWHF0f i2Fzx+is61gqJ/yxYHnaRGO4z5/yZmTkwia2wc3T9ZsYvTSshsWZGBRp/n7C5KHLhjsb0H 9kjFJcVCkJp4MJmHrOB+IhBMnS6u0CxzihmkI/TvhJiJDGymboR32tyeISzZZeO7jx8HpH T0B5aRddszJKhrgp9AfSxSOD2II0aQJKvcH4ZoXBcMkxmPDBdMUGC1/zEscAXlg58tbYBN 5Hy2FQDQwoaTBUJ/JMZzHyQaihG5UTXaNYKzEBBHcpV5aJhpl4TSt4xZlXoMqQ== 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 4TfM8G2H1hzLx9; Tue, 20 Feb 2024 14:23:26 +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 41KENQpe086197; Tue, 20 Feb 2024 14:23:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41KENQOI086194; Tue, 20 Feb 2024 14:23:26 GMT (envelope-from git) Date: Tue, 20 Feb 2024 14:23:26 GMT Message-Id: <202402201423.41KENQOI086194@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 14e782708d37 - stable/14 - vmm: Fix compiling error with BHYVE_SNAPSHOT List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 14e782708d375f19a8e19a4c7a42c5032f9997ee Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=14e782708d375f19a8e19a4c7a42c5032f9997ee commit 14e782708d375f19a8e19a4c7a42c5032f9997ee Author: Vitaliy Gusev AuthorDate: 2024-02-06 15:36:17 +0000 Commit: Mark Johnston CommitDate: 2024-02-20 14:21:14 +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 (cherry picked from commit 7572fe89ada63719b558c6b844e2743cd3ff6b6a) --- 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 dae4b1001182..5f078397eb95 100644 --- a/sys/amd64/vmm/vmm_snapshot.c +++ b/sys/amd64/vmm/vmm_snapshot.c @@ -58,7 +58,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; @@ -69,11 +69,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; @@ -99,36 +102,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); -}