[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL V4 05/31] pci: fix unaligned access in pci_xxx_quad()
From: |
Jason Wang |
Subject: |
[Qemu-devel] [PULL V4 05/31] pci: fix unaligned access in pci_xxx_quad() |
Date: |
Thu, 2 Jun 2016 14:47:56 +0800 |
From: Dmitry Fleytman <address@hidden>
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 <address@hidden>
Signed-off-by: Leonid Bloch <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Jason Wang <address@hidden>
---
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.7.4
- [Qemu-devel] [PULL V4 00/31] Net patches, Jason Wang, 2016/06/02
- [Qemu-devel] [PULL V4 02/31] net: mipsnet: check packet length against buffer, Jason Wang, 2016/06/02
- [Qemu-devel] [PULL V4 01/31] net/tap: Allocating Large sized arrays to heap, Jason Wang, 2016/06/02
- [Qemu-devel] [PULL V4 03/31] net: vl: Move default_net to vl.c, Jason Wang, 2016/06/02
- [Qemu-devel] [PULL V4 05/31] pci: fix unaligned access in pci_xxx_quad(),
Jason Wang <=
- [Qemu-devel] [PULL V4 04/31] net/net: Add SocketReadState for reuse codes, Jason Wang, 2016/06/02
- [Qemu-devel] [PULL V4 06/31] msix: make msix_clr_pending() visible for clients, Jason Wang, 2016/06/02
- [Qemu-devel] [PULL V4 07/31] pci: Introduce define for PM capability version 1.1, Jason Wang, 2016/06/02
- [Qemu-devel] [PULL V4 08/31] pcie: Add support for PCIe CAP v1, Jason Wang, 2016/06/02
- [Qemu-devel] [PULL V4 10/31] vmxnet3: Use generic function for DSN capability definition, Jason Wang, 2016/06/02
- [Qemu-devel] [PULL V4 09/31] pcie: Introduce function for DSN capability creation, Jason Wang, 2016/06/02
- [Qemu-devel] [PULL V4 11/31] net: Introduce Toeplitz hash calculator, Jason Wang, 2016/06/02
- [Qemu-devel] [PULL V4 12/31] net: Add macros for MAC address tracing, Jason Wang, 2016/06/02
- [Qemu-devel] [PULL V4 13/31] vmxnet3: Use common MAC address tracing macros, Jason Wang, 2016/06/02
- [Qemu-devel] [PULL V4 15/31] rtl8139: Move more TCP definitions to common header, Jason Wang, 2016/06/02