Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Nov 2022 17:40:22 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 385e330c1c5d - stable/13 - bhyve: Drop volatile qualifiers from snapshot code
Message-ID:  <202211291740.2ATHeM3I051688@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=385e330c1c5de51d688e7511ffaac9ad58add34f

commit 385e330c1c5de51d688e7511ffaac9ad58add34f
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-11-11 15:02:26 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-11-29 17:40:12 +0000

    bhyve: Drop volatile qualifiers from snapshot code
    
    They accomplish nothing since the qualifier is casted away in calls to
    memcpy() and copyin()/copyout().  No functional change intended.
    
    MFC after:      2 weeks
    Reviewed by:    corvink, jhb
    Differential Revision:  https://reviews.freebsd.org/D37292
    
    (cherry picked from commit 8b1adff8bcbdf0e58878431c6ed5a14553178d4d)
---
 sys/amd64/include/vmm_snapshot.h | 10 +++++-----
 sys/amd64/vmm/vmm_snapshot.c     | 17 ++++++-----------
 usr.sbin/bhyve/snapshot.c        | 14 ++++++--------
 3 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/sys/amd64/include/vmm_snapshot.h b/sys/amd64/include/vmm_snapshot.h
index 8d1ecc1db4b1..d08f980e7988 100644
--- a/sys/amd64/include/vmm_snapshot.h
+++ b/sys/amd64/include/vmm_snapshot.h
@@ -101,13 +101,13 @@ struct vm_snapshot_meta {
 };
 
 void vm_snapshot_buf_err(const char *bufname, const enum vm_snapshot_op op);
-int vm_snapshot_buf(volatile void *data, size_t data_size,
-		    struct vm_snapshot_meta *meta);
+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_guest2host_addr(void **addrp, size_t len, bool restore_null,
-				struct vm_snapshot_meta *meta);
-int vm_snapshot_buf_cmp(volatile void *data, size_t data_size,
-			      struct vm_snapshot_meta *meta);
+    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 {										\
diff --git a/sys/amd64/vmm/vmm_snapshot.c b/sys/amd64/vmm/vmm_snapshot.c
index c77bb05f76b7..1e5f57028523 100644
--- a/sys/amd64/vmm/vmm_snapshot.c
+++ b/sys/amd64/vmm/vmm_snapshot.c
@@ -57,14 +57,11 @@ vm_snapshot_buf_err(const char *bufname, const enum vm_snapshot_op op)
 }
 
 int
-vm_snapshot_buf(volatile void *data, size_t data_size,
-	     struct vm_snapshot_meta *meta)
+vm_snapshot_buf(void *data, size_t data_size, struct vm_snapshot_meta *meta)
 {
 	struct vm_snapshot_buffer *buffer;
 	int op;
-	void *nv_data;
 
-	nv_data = __DEVOLATILE(void *, data);
 	buffer = &meta->buffer;
 	op = meta->op;
 
@@ -74,9 +71,9 @@ vm_snapshot_buf(volatile void *data, size_t data_size,
 	}
 
 	if (op == VM_SNAPSHOT_SAVE)
-		copyout(nv_data, buffer->buf, data_size);
+		copyout(data, buffer->buf, data_size);
 	else if (op == VM_SNAPSHOT_RESTORE)
-		copyin(buffer->buf, nv_data, data_size);
+		copyin(buffer->buf, data, data_size);
 	else
 		return (EINVAL);
 
@@ -106,13 +103,11 @@ vm_get_snapshot_size(struct vm_snapshot_meta *meta)
 }
 
 int
-vm_snapshot_buf_cmp(volatile void *data, size_t data_size,
-		    struct vm_snapshot_meta *meta)
+vm_snapshot_buf_cmp(void *data, size_t data_size, struct vm_snapshot_meta *meta)
 {
 	struct vm_snapshot_buffer *buffer;
 	int op;
 	int ret;
-	void *_data = *(void **)(void *)&data;
 
 	buffer = &meta->buffer;
 	op = meta->op;
@@ -125,9 +120,9 @@ vm_snapshot_buf_cmp(volatile void *data, size_t data_size,
 
 	if (op == VM_SNAPSHOT_SAVE) {
 		ret = 0;
-		copyout(_data, buffer->buf, data_size);
+		copyout(data, buffer->buf, data_size);
 	} else if (op == VM_SNAPSHOT_RESTORE) {
-		ret = memcmp(_data, buffer->buf, data_size);
+		ret = memcmp(data, buffer->buf, data_size);
 	} else {
 		ret = EINVAL;
 		goto done;
diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c
index 4ffdb315883c..029c291a3cd1 100644
--- a/usr.sbin/bhyve/snapshot.c
+++ b/usr.sbin/bhyve/snapshot.c
@@ -1625,8 +1625,7 @@ vm_snapshot_buf_err(const char *bufname, const enum vm_snapshot_op op)
 }
 
 int
-vm_snapshot_buf(volatile void *data, size_t data_size,
-		struct vm_snapshot_meta *meta)
+vm_snapshot_buf(void *data, size_t data_size, struct vm_snapshot_meta *meta)
 {
 	struct vm_snapshot_buffer *buffer;
 	int op;
@@ -1640,9 +1639,9 @@ vm_snapshot_buf(volatile void *data, size_t data_size,
 	}
 
 	if (op == VM_SNAPSHOT_SAVE)
-		memcpy(buffer->buf, (uint8_t *) data, data_size);
+		memcpy(buffer->buf, data, data_size);
 	else if (op == VM_SNAPSHOT_RESTORE)
-		memcpy((uint8_t *) data, buffer->buf, data_size);
+		memcpy(data, buffer->buf, data_size);
 	else
 		return (EINVAL);
 
@@ -1708,8 +1707,7 @@ done:
 }
 
 int
-vm_snapshot_buf_cmp(volatile void *data, size_t data_size,
-		    struct vm_snapshot_meta *meta)
+vm_snapshot_buf_cmp(void *data, size_t data_size, struct vm_snapshot_meta *meta)
 {
 	struct vm_snapshot_buffer *buffer;
 	int op;
@@ -1726,9 +1724,9 @@ vm_snapshot_buf_cmp(volatile void *data, size_t data_size,
 
 	if (op == VM_SNAPSHOT_SAVE) {
 		ret = 0;
-		memcpy(buffer->buf, (uint8_t *) data, data_size);
+		memcpy(buffer->buf, data, data_size);
 	} else if (op == VM_SNAPSHOT_RESTORE) {
-		ret = memcmp((uint8_t *) data, buffer->buf, data_size);
+		ret = memcmp(data, buffer->buf, data_size);
 	} else {
 		ret = EINVAL;
 		goto done;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202211291740.2ATHeM3I051688>