From f03d8ea330d69f3a98093dfa2633635dff355f90 Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Mon, 20 Feb 2017 22:43:10 +0200 Subject: hw/pcie: fix Extended Configuration Space for devices with no Extended Capabilities Absence of any Extended Capabilities is required to be indicated by an Extended Capability header with a Capability ID of 0000h, a Capability Version of 0h, and a Next Capability Offset of 000h. Instead of inserting a 'NULL' capability is simpler to mark the start of the Extended Configuration Space as read-only to achieve the same behaviour. Signed-off-by: Marcel Apfelbaum Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/compat.h | 4 ++++ include/hw/pci/pci.h | 2 ++ 2 files changed, 6 insertions(+) (limited to 'include') diff --git a/include/hw/compat.h b/include/hw/compat.h index b7db438..ce3bfe3 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -18,6 +18,10 @@ .driver = "pci-bridge",\ .property = "shpc",\ .value = "on",\ + },{\ + .driver = TYPE_PCI_DEVICE,\ + .property = "x-pcie-extcap-init",\ + .value = "off",\ }, #define HW_COMPAT_2_7 \ diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 713ede0..a37a2d5 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -183,6 +183,8 @@ enum { /* Link active status in endpoint capability is always set */ #define QEMU_PCIE_LNKSTA_DLLLA_BITNR 8 QEMU_PCIE_LNKSTA_DLLLA = (1 << QEMU_PCIE_LNKSTA_DLLLA_BITNR), +#define QEMU_PCIE_EXTCAP_INIT_BITNR 9 + QEMU_PCIE_EXTCAP_INIT = (1 << QEMU_PCIE_EXTCAP_INIT_BITNR), }; #define TYPE_PCI_DEVICE "pci-device" -- cgit v1.1 From c2cabb34220d63f93e4a0162a26535cbd1f30243 Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Mon, 20 Feb 2017 22:43:11 +0200 Subject: hw/virtio: fix error enabling flags in Device Control register When the virtio devices are PCI Express, make error-enabling flags writable to respect the PCIe spec. Signed-off-by: Marcel Apfelbaum Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/compat.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/hw/compat.h b/include/hw/compat.h index ce3bfe3..c98776a 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -22,6 +22,10 @@ .driver = TYPE_PCI_DEVICE,\ .property = "x-pcie-extcap-init",\ .value = "off",\ + },{\ + .driver = "virtio-pci",\ + .property = "x-pcie-deverr-init",\ + .value = "off",\ }, #define HW_COMPAT_2_7 \ -- cgit v1.1 From d584f1b9ca7452ed8d6cd80f7fccd79d667ae49b Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Mon, 20 Feb 2017 22:43:12 +0200 Subject: hw/virtio: fix Link Control Register for PCI Express virtio devices Make several Link Control Register flags writable to conform with the PCI Express spec. Signed-off-by: Marcel Apfelbaum Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/compat.h | 4 ++++ include/hw/pci/pcie.h | 3 +++ 2 files changed, 7 insertions(+) (limited to 'include') diff --git a/include/hw/compat.h b/include/hw/compat.h index c98776a..0931aa5 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -26,6 +26,10 @@ .driver = "virtio-pci",\ .property = "x-pcie-deverr-init",\ .value = "off",\ + },{\ + .driver = "virtio-pci",\ + .property = "x-pcie-lnkctl-init",\ + .value = "off",\ }, #define HW_COMPAT_2_7 \ diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 163c519..11c6247 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -96,6 +96,9 @@ uint8_t pcie_cap_flags_get_vector(PCIDevice *dev); void pcie_cap_deverr_init(PCIDevice *dev); void pcie_cap_deverr_reset(PCIDevice *dev); +void pcie_cap_lnkctl_init(PCIDevice *dev); +void pcie_cap_lnkctl_reset(PCIDevice *dev); + void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot); void pcie_cap_slot_reset(PCIDevice *dev); void pcie_cap_slot_write_config(PCIDevice *dev, -- cgit v1.1 From 27ce0f3afc9dd25d21b43bbce505157afd93d111 Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Mon, 20 Feb 2017 22:43:13 +0200 Subject: hw/virtio: fix Power Management Control Register for PCI Express virtio devices Make Power Management State flag writable to conform with the PCI Express spec. Signed-off-by: Marcel Apfelbaum Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/compat.h | 4 ++++ include/hw/pci/pcie.h | 2 ++ 2 files changed, 6 insertions(+) (limited to 'include') diff --git a/include/hw/compat.h b/include/hw/compat.h index 0931aa5..90606f9 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -30,6 +30,10 @@ .driver = "virtio-pci",\ .property = "x-pcie-lnkctl-init",\ .value = "off",\ + },{\ + .driver = "virtio-pci",\ + .property = "x-pcie-pm-init",\ + .value = "off",\ }, #define HW_COMPAT_2_7 \ diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 11c6247..3d8f24b 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -63,6 +63,8 @@ typedef enum { struct PCIExpressDevice { /* Offset of express capability in config space */ uint8_t exp_cap; + /* Offset of Power Management capability in config space */ + uint8_t pm_cap; /* SLOT */ bool hpev_notified; /* Logical AND of conditions for hot plug event. -- cgit v1.1