From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [kvm-unit-tests PATCH v3 7/8] x86: share pci-testdev hdr in common lib Date: Mon, 18 Jan 2016 19:01:03 +0100 Message-ID: <1453140064-9040-8-git-send-email-drjones@redhat.com> References: <1453140064-9040-1-git-send-email-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: pbonzini@redhat.com, mst@redhat.com, agordeev@redhat.com, rkrcmar@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:34416 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756150AbcARSBX (ORCPT ); Mon, 18 Jan 2016 13:01:23 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id A8FC119F201 for ; Mon, 18 Jan 2016 18:01:23 +0000 (UTC) In-Reply-To: <1453140064-9040-1-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Andrew Jones Reviewed-by: Radim Kr=C4=8Dm=C3=A1=C5=99 --- lib/pci.h | 22 +++++++++++++++++++++- x86/vmexit.c | 14 ++------------ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/lib/pci.h b/lib/pci.h index 65fcd9444461c..9e62d120a52d6 100644 --- a/lib/pci.h +++ b/lib/pci.h @@ -19,4 +19,24 @@ unsigned long pci_bar_addr(pcidevaddr_t dev, int bar= _num); bool pci_bar_is_memory(pcidevaddr_t dev, int bar_num); bool pci_bar_is_valid(pcidevaddr_t dev, int bar_num); =20 -#endif +/* + * pci-testdev is a driver for the pci-testdev qemu pci device. The + * device enables testing mmio and portio exits, and measuring their + * speed. + */ +#define PCI_VENDOR_ID_REDHAT 0x1b36 +#define PCI_DEVICE_ID_REDHAT_TEST 0x0005 + +#define PCI_TESTDEV_NUM_BARS 2 + +struct pci_test_dev_hdr { + uint8_t test; + uint8_t width; + uint8_t pad0[2]; + uint32_t offset; + uint32_t data; + uint32_t count; + uint8_t name[]; +}; + +#endif /* PCI_H */ diff --git a/x86/vmexit.c b/x86/vmexit.c index 81ac7a88fda93..375524f6f7d96 100644 --- a/x86/vmexit.c +++ b/x86/vmexit.c @@ -134,16 +134,6 @@ static void wr_tsc_adjust_msr(void) wrmsr(MSR_TSC_ADJUST, 0x0); } =20 -struct pci_test_dev_hdr { - uint8_t test; - uint8_t width; - uint8_t pad0[2]; - uint32_t offset; - uint32_t data; - uint32_t count; - uint8_t name[]; -}; - static struct pci_test { unsigned iobar; unsigned ioport; @@ -397,9 +387,9 @@ int main(int ac, char **av) pm_tmr_blk =3D fadt->pm_tmr_blk; printf("PM timer port is %x\n", pm_tmr_blk); =20 - pcidev =3D pci_find_dev(0x1b36, 0x0005); + pcidev =3D pci_find_dev(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_TE= ST); if (pcidev) { - for (i =3D 0; i < 2; i++) { + for (i =3D 0; i < PCI_TESTDEV_NUM_BARS; i++) { if (!pci_bar_is_valid(pcidev, i)) { continue; } --=20 2.4.3