From nobody Sun Oct 23 15:18:40 2022 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 4MwMKs0bHrz4gdKK; Sun, 23 Oct 2022 15:18:41 +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 4MwMKs07hCz3fdD; Sun, 23 Oct 2022 15:18:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666538321; 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=BC9a+p8pz5njQdMzVVL7vVCgHyA/ZEmn2E6fXhDjVtY=; b=KwPMHjQD1S69LAFKpB5XUkI82p6Pwsn78rHwF6ulg+GKwAXHKicF3nAOxkN8Yn79SMa7mq 7Sf7FeAs+voSzATH9yRgykoTpfar/6pGydfbG2qiAFKq1mVG4ndRfOWAdKHyvdYLh719Bz pn7OeuPJ4IXfn2DPNGMYDmpkgjAeo1M6SoHm8rRIFLA4Tc9rOIqyTE78whJxB/MrKlAV9x hMt6Tm0QIvSovzNHvR1s3AHp6stldMZgTQ/VKKKFy/KpKFWNY70kLyI5BhZhb4IMYXoqRd mWh8xvSXvDqD31PTReK65kXCMQfLbatiEkDEkpNlOQvxe1EYDunEDLcetrcoiw== 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 4MwMKr6Jc6zwBn; Sun, 23 Oct 2022 15:18:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29NFIee7076300; Sun, 23 Oct 2022 15:18:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29NFIe9I076299; Sun, 23 Oct 2022 15:18:40 GMT (envelope-from git) Date: Sun, 23 Oct 2022 15:18:40 GMT Message-Id: <202210231518.29NFIe9I076299@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: 63898728b544 - main - bhyve: Avoid arithmetic on void pointers 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: owner-dev-commits-src-main@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: 63898728b544763d85c062c8515c12a0c3a60e0a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666538321; 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=BC9a+p8pz5njQdMzVVL7vVCgHyA/ZEmn2E6fXhDjVtY=; b=P/hy7HXOViwEpWuG8f4sfytK2UqUP0/lbqvs3u6mywmq4IJxSp9a65LRpCBCYFlqDWHWgU DzhM8IK74uw22RR75nHAPu3selqy4otSqtnWKOJVjXegmu/3niC6kP+3QtDhLCroSqHdQk S6SIGs6bjzqXbpb0YZ05O+YNSF2/G4ERJhlyWt+GyO7Ar1sOyGivJ06JsOTR7Q23AFqtvX FdupGMImKNS9HGHPIZhL+CW7ROtfMeo7ZiMi4PDb7X2RdARdYD8shGjMCEDfrdb7Pa8vyU gAp1faMXA+lP5WFCQX+fDG6Et7XTyHPO/yFs4rpP2bXtZdCyNgOEYSR3J8aH6A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666538321; a=rsa-sha256; cv=none; b=uq+P8E214h6s23Ozl+F6KcG3M/pY6AXaByGBG+vftY/0Lqv3y5EpVRdWOtshKlqvq4cW1t 0V8wYjVfjPshMJdgiZawPYGYt+K3oDYrkv3SrJ7OKwxa+P91R+YVeo8sexdAGLTCbp5nP8 qh7l+/RvLsRaWtcRgZl3Jgbt7azMuE77hvz46G/QGcdOPDscLehfk/zo/eG+Alsh7XiHp9 egN3k7B5xrb+BJV9F6yI2LBOMsGcXPHpM4EDyb6kIxAc/+zlJN316RwESDFeWAFd94yFWj xuDsPfeBBfoGumRfw0zqyiIQ+R+Ouiyi1K14/8QZZs77ZPedvhAfr3j2K6sCiA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=63898728b544763d85c062c8515c12a0c3a60e0a commit 63898728b544763d85c062c8515c12a0c3a60e0a Author: Mark Johnston AuthorDate: 2022-10-22 17:40:20 +0000 Commit: Mark Johnston CommitDate: 2022-10-23 15:11:33 +0000 bhyve: Avoid arithmetic on void pointers No functional change intended. MFC after: 1 week --- usr.sbin/bhyve/iov.c | 4 ++-- usr.sbin/bhyve/net_backends.c | 6 +++--- usr.sbin/bhyve/pci_e82545.c | 4 ++-- usr.sbin/bhyve/pci_hda.c | 28 ++++++++++++++-------------- usr.sbin/bhyve/pci_hda.h | 2 +- usr.sbin/bhyve/pci_passthru.c | 2 +- usr.sbin/bhyve/pci_virtio_console.c | 4 ++-- usr.sbin/bhyve/pci_virtio_scsi.c | 2 +- usr.sbin/bhyve/rfb.c | 21 ++++++++++++--------- usr.sbin/bhyve/snapshot.c | 4 ++-- 10 files changed, 40 insertions(+), 37 deletions(-) diff --git a/usr.sbin/bhyve/iov.c b/usr.sbin/bhyve/iov.c index af36cb056229..a70abf079413 100644 --- a/usr.sbin/bhyve/iov.c +++ b/usr.sbin/bhyve/iov.c @@ -111,7 +111,7 @@ iov_to_buf(const struct iovec *iov, int niov, void **buf) return (-1); for (i = 0, ptr = 0; i < niov; i++) { - memcpy(*buf + ptr, iov[i].iov_base, iov[i].iov_len); + memcpy((uint8_t *)*buf + ptr, iov[i].iov_base, iov[i].iov_len); ptr += iov[i].iov_len; } @@ -137,7 +137,7 @@ buf_to_iov(const void *buf, size_t buflen, const struct iovec *iov, int niov, for (i = 0; i < niov && off < buflen; i++) { len = MIN(iov[i].iov_len, buflen - off); - memcpy(iov[i].iov_base, buf + off, len); + memcpy(iov[i].iov_base, (const uint8_t *)buf + off, len); off += len; } diff --git a/usr.sbin/bhyve/net_backends.c b/usr.sbin/bhyve/net_backends.c index a20199a0b76e..8c6b226a455d 100644 --- a/usr.sbin/bhyve/net_backends.c +++ b/usr.sbin/bhyve/net_backends.c @@ -752,8 +752,8 @@ netmap_send(struct net_backend *be, const struct iovec *iov, nm_buf_len = 0; for (j = 0; j < iovcnt; j++) { + uint8_t *iov_frag_buf = iov[j].iov_base; int iov_frag_size = iov[j].iov_len; - void *iov_frag_buf = iov[j].iov_base; totlen += iov_frag_size; @@ -834,7 +834,7 @@ netmap_recv(struct net_backend *be, const struct iovec *iov, int iovcnt) struct netmap_priv *priv = (struct netmap_priv *)be->opaque; struct netmap_slot *slot = NULL; struct netmap_ring *ring; - void *iov_frag_buf; + uint8_t *iov_frag_buf; int iov_frag_size; ssize_t totlen = 0; uint32_t head; @@ -847,8 +847,8 @@ netmap_recv(struct net_backend *be, const struct iovec *iov, int iovcnt) iov_frag_size = iov->iov_len; do { + uint8_t *nm_buf; int nm_buf_len; - void *nm_buf; if (head == ring->tail) { return (0); diff --git a/usr.sbin/bhyve/pci_e82545.c b/usr.sbin/bhyve/pci_e82545.c index d630e9d1d090..ba0523b9b28e 100644 --- a/usr.sbin/bhyve/pci_e82545.c +++ b/usr.sbin/bhyve/pci_e82545.c @@ -1007,7 +1007,7 @@ e82545_iov_checksum(struct iovec *iov, int iovcnt, int off, int len) odd = 0; while (len > 0 && iovcnt > 0) { now = MIN(len, iov->iov_len - off); - s = e82545_buf_checksum(iov->iov_base + off, now); + s = e82545_buf_checksum((uint8_t *)iov->iov_base + off, now); sum += odd ? (s << 8) : s; odd ^= (now & 1); len -= now; @@ -1320,7 +1320,7 @@ e82545_transmit(struct e82545_softc *sc, uint16_t head, uint16_t tail, left -= now, hdrp += now) { now = MIN(left, iov->iov_len); memcpy(hdrp, iov->iov_base, now); - iov->iov_base += now; + iov->iov_base = (uint8_t *)iov->iov_base + now; iov->iov_len -= now; if (iov->iov_len == 0) { iov++; diff --git a/usr.sbin/bhyve/pci_hda.c b/usr.sbin/bhyve/pci_hda.c index 9ebfbfbaa5bf..88f58a5fcc66 100644 --- a/usr.sbin/bhyve/pci_hda.c +++ b/usr.sbin/bhyve/pci_hda.c @@ -201,7 +201,7 @@ static int hda_signal_state_change(struct hda_codec_inst *hci); static int hda_response(struct hda_codec_inst *hci, uint32_t response, uint8_t unsol); static int hda_transfer(struct hda_codec_inst *hci, uint8_t stream, - uint8_t dir, void *buf, size_t count); + uint8_t dir, uint8_t *buf, size_t count); static void hda_set_pib(struct hda_softc *sc, uint8_t stream_ind, uint32_t pib); static uint64_t hda_get_clock_ns(void); @@ -793,8 +793,8 @@ hda_corb_run(struct hda_softc *sc) corb->rp++; corb->rp %= corb->size; - verb = hda_dma_ld_dword(corb->dma_vaddr + \ - HDA_CORB_ENTRY_LEN * corb->rp); + verb = hda_dma_ld_dword((uint8_t *)corb->dma_vaddr + + HDA_CORB_ENTRY_LEN * corb->rp); err = hda_send_command(sc, verb); assert(!err); @@ -1088,10 +1088,10 @@ hda_response(struct hda_codec_inst *hci, uint32_t response, uint8_t unsol) rirb->wp++; rirb->wp %= rirb->size; - hda_dma_st_dword(rirb->dma_vaddr + HDA_RIRB_ENTRY_LEN * \ - rirb->wp, response); - hda_dma_st_dword(rirb->dma_vaddr + HDA_RIRB_ENTRY_LEN * \ - rirb->wp + 0x04, response_ex); + hda_dma_st_dword((uint8_t *)rirb->dma_vaddr + + HDA_RIRB_ENTRY_LEN * rirb->wp, response); + hda_dma_st_dword((uint8_t *)rirb->dma_vaddr + + HDA_RIRB_ENTRY_LEN * rirb->wp + 0x04, response_ex); hda_set_reg_by_offset(sc, HDAC_RIRBWP, rirb->wp); @@ -1107,7 +1107,7 @@ hda_response(struct hda_codec_inst *hci, uint32_t response, uint8_t unsol) static int hda_transfer(struct hda_codec_inst *hci, uint8_t stream, uint8_t dir, - void *buf, size_t count) + uint8_t *buf, size_t count) { struct hda_softc *sc = NULL; struct hda_stream_desc *st = NULL; @@ -1161,11 +1161,11 @@ hda_transfer(struct hda_codec_inst *hci, uint8_t stream, uint8_t dir, bdle_desc = &bdl[st->be]; if (dir) - *(uint32_t *)buf = \ - hda_dma_ld_dword(bdle_desc->addr + st->bp); + *(uint32_t *)buf = hda_dma_ld_dword( + (uint8_t *)bdle_desc->addr + st->bp); else - hda_dma_st_dword(bdle_desc->addr + st->bp, - *(uint32_t *)buf); + hda_dma_st_dword((uint8_t *)bdle_desc->addr + + st->bp, *(uint32_t *)buf); buf += HDA_DMA_ACCESS_LEN; st->bp += HDA_DMA_ACCESS_LEN; @@ -1205,8 +1205,8 @@ hda_set_pib(struct hda_softc *sc, uint8_t stream_ind, uint32_t pib) /* LPIB Alias */ hda_set_reg_by_offset(sc, 0x2000 + off + HDAC_SDLPIB, pib); if (sc->dma_pib_vaddr) - *(uint32_t *)(sc->dma_pib_vaddr + stream_ind * \ - HDA_DMA_PIB_ENTRY_LEN) = pib; + *(uint32_t *)((uint8_t *)sc->dma_pib_vaddr + stream_ind * + HDA_DMA_PIB_ENTRY_LEN) = pib; } static uint64_t hda_get_clock_ns(void) diff --git a/usr.sbin/bhyve/pci_hda.h b/usr.sbin/bhyve/pci_hda.h index e86867192193..50cbac82a1a6 100644 --- a/usr.sbin/bhyve/pci_hda.h +++ b/usr.sbin/bhyve/pci_hda.h @@ -84,7 +84,7 @@ struct hda_ops { int (*response)(struct hda_codec_inst *hci, uint32_t response, uint8_t unsol); int (*transfer)(struct hda_codec_inst *hci, uint8_t stream, - uint8_t dir, void *buf, size_t count); + uint8_t dir, uint8_t *buf, size_t count); }; #define HDA_EMUL_SET(x) DATA_SET(hda_codec_class_set, x); diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c index 8d76d564b4ae..b28277f7975e 100644 --- a/usr.sbin/bhyve/pci_passthru.c +++ b/usr.sbin/bhyve/pci_passthru.c @@ -438,7 +438,7 @@ msix_table_write(struct vmctx *ctx, int vcpu, struct passthru_softc *sc, assert(entry_offset % 4 == 0); vector_control = entry->vector_control; - dest32 = (uint32_t *)((void *)entry + entry_offset); + dest32 = (uint32_t *)((uint8_t *)entry + entry_offset); *dest32 = data; /* If MSI-X hasn't been enabled, do nothing */ if (pi->pi_msix.enabled) { diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index fa16bfb84d79..44d0da720226 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -585,8 +585,8 @@ pci_vtcon_control_send(struct pci_vtcon_softc *sc, memcpy(iov.iov_base, ctrl, sizeof(struct pci_vtcon_control)); if (payload != NULL && len > 0) - memcpy(iov.iov_base + sizeof(struct pci_vtcon_control), - payload, len); + memcpy((uint8_t *)iov.iov_base + + sizeof(struct pci_vtcon_control), payload, len); vq_relchain(vq, req.idx, sizeof(struct pci_vtcon_control) + len); vq_endchains(vq, 1); diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c index 537b2a58097b..7f8d5a8866c9 100644 --- a/usr.sbin/bhyve/pci_virtio_scsi.c +++ b/usr.sbin/bhyve/pci_virtio_scsi.c @@ -590,7 +590,7 @@ pci_vtscsi_controlq_notify(void *vsc, struct vqueue_info *vq) bufsize = iov_to_buf(iov, n, &buf); iolen = pci_vtscsi_control_handle(sc, buf, bufsize); - buf_to_iov(buf + bufsize - iolen, iolen, iov, n, + buf_to_iov((uint8_t *)buf + bufsize - iolen, iolen, iov, n, bufsize - iolen); /* diff --git a/usr.sbin/bhyve/rfb.c b/usr.sbin/bhyve/rfb.c index ad5fc4fc88e0..7f7a3514051e 100644 --- a/usr.sbin/bhyve/rfb.c +++ b/usr.sbin/bhyve/rfb.c @@ -322,7 +322,8 @@ rfb_recv_set_pixfmt_msg(struct rfb_softc *rc __unused, int cfd) { struct rfb_pixfmt_msg pixfmt_msg; - (void)stream_read(cfd, ((void *)&pixfmt_msg)+1, sizeof(pixfmt_msg)-1); + (void)stream_read(cfd, (uint8_t *)&pixfmt_msg + 1, + sizeof(pixfmt_msg) - 1); } static void @@ -332,7 +333,7 @@ rfb_recv_set_encodings_msg(struct rfb_softc *rc, int cfd) int i; uint32_t encoding; - (void)stream_read(cfd, ((void *)&enc_msg)+1, sizeof(enc_msg)-1); + (void)stream_read(cfd, (uint8_t *)&enc_msg + 1, sizeof(enc_msg) - 1); for (i = 0; i < htons(enc_msg.numencs); i++) { (void)stream_read(cfd, &encoding, sizeof(encoding)); @@ -727,7 +728,7 @@ rfb_recv_update_msg(struct rfb_softc *rc, int cfd) { struct rfb_updt_msg updt_msg; - (void)stream_read(cfd, ((void *)&updt_msg) + 1 , sizeof(updt_msg) - 1); + (void)stream_read(cfd, (uint8_t *)&updt_msg + 1 , sizeof(updt_msg) - 1); if (rc->enc_extkeyevent_ok && (!rc->enc_extkeyevent_send)) { rfb_send_extended_keyevent_update_msg(rc, cfd); @@ -744,7 +745,7 @@ rfb_recv_key_msg(struct rfb_softc *rc, int cfd) { struct rfb_key_msg key_msg; - (void)stream_read(cfd, ((void *)&key_msg) + 1, sizeof(key_msg) - 1); + (void)stream_read(cfd, (uint8_t *)&key_msg + 1, sizeof(key_msg) - 1); console_key_event(key_msg.down, htonl(key_msg.sym), htonl(0)); rc->input_detected = true; @@ -756,10 +757,12 @@ rfb_recv_client_msg(struct rfb_softc *rc, int cfd) struct rfb_client_msg client_msg; struct rfb_extended_key_msg extkey_msg; - (void)stream_read(cfd, ((void *)&client_msg) + 1, sizeof(client_msg) - 1); + (void)stream_read(cfd, (uint8_t *)&client_msg + 1, + sizeof(client_msg) - 1); - if (client_msg.subtype == RFB_CLIENTMSG_EXT_KEYEVENT ) { - (void)stream_read(cfd, ((void *)&extkey_msg) + 2, sizeof(extkey_msg) - 2); + if (client_msg.subtype == RFB_CLIENTMSG_EXT_KEYEVENT) { + (void)stream_read(cfd, (uint8_t *)&extkey_msg + 2, + sizeof(extkey_msg) - 2); console_key_event((int)extkey_msg.down, htonl(extkey_msg.sym), htonl(extkey_msg.code)); rc->input_detected = true; } @@ -770,7 +773,7 @@ rfb_recv_ptr_msg(struct rfb_softc *rc, int cfd) { struct rfb_ptr_msg ptr_msg; - (void)stream_read(cfd, ((void *)&ptr_msg) + 1, sizeof(ptr_msg) - 1); + (void)stream_read(cfd, (uint8_t *)&ptr_msg + 1, sizeof(ptr_msg) - 1); console_ptr_event(ptr_msg.button, htons(ptr_msg.x), htons(ptr_msg.y)); rc->input_detected = true; @@ -783,7 +786,7 @@ rfb_recv_cuttext_msg(struct rfb_softc *rc __unused, int cfd) unsigned char buf[32]; int len; - len = stream_read(cfd, ((void *)&ct_msg) + 1, sizeof(ct_msg) - 1); + len = stream_read(cfd, (uint8_t *)&ct_msg + 1, sizeof(ct_msg) - 1); ct_msg.length = htonl(ct_msg.length); while (ct_msg.length > 0) { len = stream_read(cfd, buf, ct_msg.length > sizeof(buf) ? diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c index 1ca36432fc08..881c91973a02 100644 --- a/usr.sbin/bhyve/snapshot.c +++ b/usr.sbin/bhyve/snapshot.c @@ -452,7 +452,7 @@ lookup_struct(enum snapshot_req struct_id, struct restore_state *rstate, assert(file_offset + size <= rstate->kdata_len); *struct_size = (size_t)size; - return (rstate->kdata_map + file_offset); + return ((uint8_t *)rstate->kdata_map + file_offset); } } @@ -481,7 +481,7 @@ lookup_check_dev(const char *dev_name, struct restore_state *rstate, assert(file_offset + size <= rstate->kdata_len); *data_size = (size_t)size; - return (rstate->kdata_map + file_offset); + return ((uint8_t *)rstate->kdata_map + file_offset); } return (NULL);