From nobody Thu Jan 26 20:27:17 2023 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 4P2sh61j7Vz3btFR; Thu, 26 Jan 2023 20:27:18 +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 4P2sh55CClz3RHc; Thu, 26 Jan 2023 20:27:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674764837; 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=i4Ex90ImGawGQoYxKlm0+0j3QS4k71rJg+M/Oy3egtA=; b=FxDqIbrq70Bz28eAiSxgYNRdnWR1pJzJnJBv/yuFGVUaRkn3A3jR6S87oKsdFM7F0gPghx CL8aJWdsH350u1JMkBZozBcp07ihl8AuueOEXnRPW+aEaz6YShEsTK8DeCnbBn7aFmj+uC Vjm6KI855WxSl4OzuUDLPlqR27hIDAJ9yqXn/EnLFU/sdGTLgQdWvaRaDSIK6SWnwIHnQ8 uDuotT9wRAL/fRvzJpC05xnZMazi4/eLEC+Jotk80SKs8vVMoRRECtcc09pMPoQcOpAzK2 1UVxKiS07uAK9qGT2QV2668s6TNaohM+rEJF614wj+6KrkACQ1aFPCSj8OHdqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674764837; 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=i4Ex90ImGawGQoYxKlm0+0j3QS4k71rJg+M/Oy3egtA=; b=FU27fBg/AhhQBdzlcmk408SkKeFCK3Jr0MH5CedLx0IJg9/xOmfCslCYZk8ACRVY6flBGZ ttHw3EMtPM4ulB9NMG9niYWUHpiWl1pBM/DZ8Btetxamo2sDV+ZpP8jUNw7rzwp4G0QFpe FDtv9/DW7HuIk5eYKgwaBt6H5wYVinXSH1iTga8pV/5k/aroEm1Hmy2NO05vn+cY263F8E D9zRzmYuNpqCS/H7J1k19sdw3T3ailLR9Gw4N5P7gSXPigZtZwtB3g6YZJ2rwdgl+AOemp bszAhdV20L3hHNTKbUx67LuypymIJRWct69Wmxz3bzPIpFEMq5K0l1hi1w55uQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674764837; a=rsa-sha256; cv=none; b=gGFLdGBJoLVJf00WeFUilvJBqDcm/05vefxV53Hjnm+aBCxZHsiSbSXwC3RpGyEkepz2Lp Reoi9PKQu+PHuJ/+8b4XPS7cq3GA3KnLNYyEYMxe1OgGixiZOmaqM9rtdp0yMIJAeB09m1 jqlbgAPfsPXzase7N1FFpJ3+/Ol4OPFmyDtpTbNEz4vkL+GmUeiIX8EEAAhVK7jkHXYzdG R+CZFVDX3okToSvL3aawv+IxoXeiQ52Fhsd5tlgaRJ7xpb/UgbN+Xb/qh90ZGbw9z+3Qaf k2dm7tVuu+l6HxoMzyRed++H/BLVcc1cZFIpTEmfJnVGj1tu9C1+FVEBxe85RQ== 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 4P2sh54KFwzjgW; Thu, 26 Jan 2023 20:27:17 +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 30QKRHnl064976; Thu, 26 Jan 2023 20:27:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30QKRHmK064975; Thu, 26 Jan 2023 20:27:17 GMT (envelope-from git) Date: Thu, 26 Jan 2023 20:27:17 GMT Message-Id: <202301262027.30QKRHmK064975@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: cee36581281d - stable/13 - bhyve: Appease warning about a potentially unaligned pointer. 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: cee36581281d4b3ce67e14dd16178d9543b5b64f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=cee36581281d4b3ce67e14dd16178d9543b5b64f commit cee36581281d4b3ce67e14dd16178d9543b5b64f Author: John Baldwin AuthorDate: 2022-11-29 01:10:07 +0000 Commit: John Baldwin CommitDate: 2023-01-26 20:24:09 +0000 bhyve: Appease warning about a potentially unaligned pointer. When initializing the device model for a PCI pass through device that uses MSI-X, bhyve reads the MSI-X capability from the real device to save a copy in the emulated PCI config space. It also saves a copy in a local struct msixcap on the stack. Since struct msixcap is packed, GCC complains that casting a pointer to the struct to a uint32_t pointer may result in an unaligned pointer. This path is not performance critical, so to appease the compiler, simply change the pointer to a char * and use memcpy to copy the 4 bytes read in each iteration of the loop. Reviewed by: corvink, bz, markj Differential Revision: https://reviews.freebsd.org/D37490 (cherry picked from commit 32b21dd2719f87811b66deeeb513acf7067f8fac) --- usr.sbin/bhyve/pci_passthru.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c index 049b49b67c60..285874f3925d 100644 --- a/usr.sbin/bhyve/pci_passthru.c +++ b/usr.sbin/bhyve/pci_passthru.c @@ -212,7 +212,7 @@ cfginitmsi(struct passthru_softc *sc) struct pcisel sel; struct pci_devinst *pi; struct msixcap msixcap; - uint32_t *msixcap_ptr; + char *msixcap_ptr; pi = sc->psc_pi; sel = sc->psc_sel; @@ -249,15 +249,15 @@ cfginitmsi(struct passthru_softc *sc) */ sc->psc_msix.capoff = ptr; caplen = 12; - msixcap_ptr = (uint32_t*) &msixcap; + msixcap_ptr = (char *)&msixcap; capptr = ptr; while (caplen > 0) { u32 = read_config(&sel, capptr, 4); - *msixcap_ptr = u32; + memcpy(msixcap_ptr, &u32, 4); pci_set_cfgdata32(pi, capptr, u32); caplen -= 4; capptr += 4; - msixcap_ptr++; + msixcap_ptr += 4; } } ptr = read_config(&sel, ptr + PCICAP_NEXTPTR, 1);