[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v8 01/17] pci: fix unaligned access in pci_xxx_quad(
From: |
Dmitry Fleytman |
Subject: |
[Qemu-devel] [PATCH v8 01/17] pci: fix unaligned access in pci_xxx_quad() |
Date: |
Wed, 1 Jun 2016 11:23:30 +0300 |
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>
---
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
- [Qemu-devel] [PATCH v8 00/17] Introduce Intel 82574 GbE Controller Emulation (e1000e), Dmitry Fleytman, 2016/06/01
- [Qemu-devel] [PATCH v8 01/17] pci: fix unaligned access in pci_xxx_quad(),
Dmitry Fleytman <=
- [Qemu-devel] [PATCH v8 02/17] msix: make msix_clr_pending() visible for clients, Dmitry Fleytman, 2016/06/01
- [Qemu-devel] [PATCH v8 04/17] pcie: Add support for PCIe CAP v1, Dmitry Fleytman, 2016/06/01
- [Qemu-devel] [PATCH v8 05/17] pcie: Introduce function for DSN capability creation, Dmitry Fleytman, 2016/06/01
- [Qemu-devel] [PATCH v8 03/17] pci: Introduce define for PM capability version 1.1, Dmitry Fleytman, 2016/06/01
- [Qemu-devel] [PATCH v8 07/17] net: Introduce Toeplitz hash calculator, Dmitry Fleytman, 2016/06/01
- [Qemu-devel] [PATCH v8 06/17] vmxnet3: Use generic function for DSN capability definition, Dmitry Fleytman, 2016/06/01
- [Qemu-devel] [PATCH v8 08/17] net: Add macros for MAC address tracing, Dmitry Fleytman, 2016/06/01
- [Qemu-devel] [PATCH v8 09/17] vmxnet3: Use common MAC address tracing macros, Dmitry Fleytman, 2016/06/01
- [Qemu-devel] [PATCH v8 11/17] rtl8139: Move more TCP definitions to common header, Dmitry Fleytman, 2016/06/01
- [Qemu-devel] [PATCH v8 13/17] vmxnet3: Use pci_dma_* API instead of cpu_physical_memory_*, Dmitry Fleytman, 2016/06/01