From nobody Tue Nov 29 01:11:00 2022 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 4NLkmh5QdGz4jSTL; Tue, 29 Nov 2022 01:11:00 +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 4NLkmh4Xrjz4321; Tue, 29 Nov 2022 01:11:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669684260; 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=Nf2ZVPi/18l2aFX5yk0a9h+JjoUUA70IoJFdyGbIWcI=; b=upU5pDPAHwDv43FQQ7u5GNCECmrw5m+3na8iFCm3HH8nruktev6dcjI3wYdEHOV6bmnEgj 1PsZzZB609q0sU6GWKQLI8mfnL/2PnvwxWsmRkeOsWwierIsSWHcogRdi6w2YIlMDaE08q 7YiyYleyn8TEYl32gF6EOmK7xctYXVBfkD6coI7ENA2LzStpJsiPUXlt/2Z4N77n+2Ig9o 2jF40NdTDU9k7e/IcN+P7LjvQl4F4lo1b8JbQaNovDSymHgDU2oRw/i04WucwaXVCJ2umg amA8z2kGryyP6FSm7i5MrxoAEM5NQFvAyQaNHI9DBn7CN0yXlZdZWoPRBSQMVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669684260; 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=Nf2ZVPi/18l2aFX5yk0a9h+JjoUUA70IoJFdyGbIWcI=; b=buNiqsqZvppvAycXj51uG0Vnkb5cel28Y/2caYzKMzt6LkdDudDKofO2BneggBNgHyVlRa UkoXcsjzlqPKvL5Onif5dza6lYKERtVg/BOxcg8dk8WbXgAJlNc4NHBGYMsxi36XBG53nB rPfoGOF4PmcuOVEV63StAU4heXDmvXW8OJ0moOdDI3iFA4gw+yPoZgjyekRSDW+Z/ZcMJF 3RrqYGazq0Gokm5vbkt7iDLA808RQiQvb+0kIN/AbYB558+vOShXaQ4xzlYf6DL5XqTLar Ai3A8wsXBsdCBn83iUp5M4ZfYEYpqqZotVAXokEMraUeBf0knYZ+VVANdsjnTg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669684260; a=rsa-sha256; cv=none; b=sIBVWgV63HhKY0xPfoe19wiuldtwxhDBkD4YWlrPb0UwNqKbtGFNv+1dR734aXmI+6y8cY eq5bMmu6pcMDxC0k7UQZLgt8dyGJ3XDpWbe3ora3xQwMzl/HTUEHVwHNZJLBB1X6po20V9 DTPgj/NY6MduEFfOhV+TBMZjmdMqym9W0fso0PGejNLkz6pGZV/RzsKzZjF3MMnoJSLa6s tRNHoUzKZjeHd1+o/iLZ8M032/ywzSBf44EbPyhMfdWNu1qUBENM+SwUCdPaxHlVgJ8tb7 H9uo1cSLZRBGgMUpsBJvlg3QgifTb6q1c4AdP+XHExsd7f/c8dnuKXKBi6yuOQ== 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 4NLkmh3dk9zyS7; Tue, 29 Nov 2022 01:11:00 +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 2AT1B07p045336; Tue, 29 Nov 2022 01:11:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AT1B09e045335; Tue, 29 Nov 2022 01:11:00 GMT (envelope-from git) Date: Tue, 29 Nov 2022 01:11:00 GMT Message-Id: <202211290111.2AT1B09e045335@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 32b21dd2719f - main - 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/main X-Git-Reftype: branch X-Git-Commit: 32b21dd2719f87811b66deeeb513acf7067f8fac Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=32b21dd2719f87811b66deeeb513acf7067f8fac commit 32b21dd2719f87811b66deeeb513acf7067f8fac Author: John Baldwin AuthorDate: 2022-11-29 01:10:07 +0000 Commit: John Baldwin CommitDate: 2022-11-29 01:10:07 +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 --- 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 3f5cbe221bd6..b4a8b623eca9 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);