From patchwork Thu Aug 27 08:52:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 7081941 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0EE2F9F1C2 for ; Thu, 27 Aug 2015 08:53:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3EEF62094D for ; Thu, 27 Aug 2015 08:53:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 57BC620944 for ; Thu, 27 Aug 2015 08:53:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752489AbbH0Iw5 (ORCPT ); Thu, 27 Aug 2015 04:52:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39379 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750802AbbH0Iw4 (ORCPT ); Thu, 27 Aug 2015 04:52:56 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 056DB2F3; Thu, 27 Aug 2015 08:52:56 +0000 (UTC) Received: from redhat.com (ovpn-116-110.ams2.redhat.com [10.36.116.110]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t7R8qsD6002302; Thu, 27 Aug 2015 04:52:54 -0400 Date: Thu, 27 Aug 2015 11:52:53 +0300 From: "Michael S. Tsirkin" To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 2/2] pci-test: allow bar > 4k Message-ID: <1440665434-2893-2-git-send-email-mst@redhat.com> References: <1440665434-2893-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1440665434-2893-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP vmexit using test assumes BAR size is exactly 4K. Remove this restriction, allow any BAR size. Signed-off-by: Michael S. Tsirkin --- x86/vmexit.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/x86/vmexit.c b/x86/vmexit.c index 7e9af15..3ff7fbf 100644 --- a/x86/vmexit.c +++ b/x86/vmexit.c @@ -407,7 +407,7 @@ bool test_wanted(struct test *test, char *wanted[], int nwanted) int main(int ac, char **av) { int i; - unsigned long membar = 0, base, offset; + unsigned long membar = 0, base, offset, size; void *m; pcidevaddr_t pcidev; @@ -425,12 +425,18 @@ int main(int ac, char **av) continue; } if (pci_bar_is_memory(pcidev, i)) { + int p; + + size = pci_bar_size(pcidev, i); membar = pci_bar_addr(pcidev, i); - base = membar & ~4095; + base = membar & ~(size - 1); offset = membar - base; - m = alloc_vpages(1); - - install_page((void *)read_cr3(), base, m); + m = alloc_vpages(size / 4096); + + for (p = 0; p < size; p += 4096) { + install_page((void *)read_cr3(), base + p, + m + p); + } pci_test.memaddr = m + offset; } else { pci_test.iobar = pci_bar_addr(pcidev, i);