From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b81Rc-0000hc-7M for qemu-devel@nongnu.org; Wed, 01 Jun 2016 04:24:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b81RW-00007B-Gj for qemu-devel@nongnu.org; Wed, 01 Jun 2016 04:24:03 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33322) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b81RW-000073-9b for qemu-devel@nongnu.org; Wed, 01 Jun 2016 04:23:58 -0400 Received: by mail-wm0-x241.google.com with SMTP id a136so4498965wme.0 for ; Wed, 01 Jun 2016 01:23:58 -0700 (PDT) From: Dmitry Fleytman Date: Wed, 1 Jun 2016 11:23:30 +0300 Message-Id: <1464769426-22276-2-git-send-email-dmitry@daynix.com> In-Reply-To: <1464769426-22276-1-git-send-email-dmitry@daynix.com> References: <1464769426-22276-1-git-send-email-dmitry@daynix.com> Subject: [Qemu-devel] [PATCH v8 01/17] pci: fix unaligned access in pci_xxx_quad() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jason Wang , "Michael S. Tsirkin" , Yan Vugenfirer , Leonid Bloch , Shmulik Ladkani From: Dmitry Fleytman Replace legacy cpu_to_le64w()/le64_to_cpup() calls with stq_le_p()/ldq_le_p(). Motivation for this modification is that follow up patches add utility function pcie_dev_ser_num_init() for PCIe DSN capability creation which uses pci_set_quad() with a misaligned offset. Signed-off-by: Dmitry Fleytman Signed-off-by: Leonid Bloch Reviewed-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index ef6ba51..4420f47 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -465,16 +465,23 @@ pci_get_long(const uint8_t *config) return ldl_le_p(config); } +/* + * PCI capabilities and/or their fields + * are generally DWORD aligned only so + * mechanism used by pci_set/get_quad() + * must be tolerant to unaligned pointers + * + */ static inline void pci_set_quad(uint8_t *config, uint64_t val) { - cpu_to_le64w((uint64_t *)config, val); + stq_le_p(config, val); } static inline uint64_t pci_get_quad(const uint8_t *config) { - return le64_to_cpup((const uint64_t *)config); + return ldq_le_p(config); } static inline void -- 2.5.5