From patchwork Tue Nov 29 14:48:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Gordeev X-Patchwork-Id: 9452271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 98E2E60235 for ; Tue, 29 Nov 2016 14:49:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DE0228384 for ; Tue, 29 Nov 2016 14:49:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8298D2838D; Tue, 29 Nov 2016 14:49:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38F4028384 for ; Tue, 29 Nov 2016 14:49:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933327AbcK2OtC (ORCPT ); Tue, 29 Nov 2016 09:49:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47288 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932984AbcK2Os7 (ORCPT ); Tue, 29 Nov 2016 09:48:59 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 99E4761E64 for ; Tue, 29 Nov 2016 14:48:59 +0000 (UTC) Received: from dhcp-27-118.brq.redhat.com (dhcp-27-122.brq.redhat.com [10.34.27.122]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uATEmt0x007256; Tue, 29 Nov 2016 09:48:58 -0500 From: Alexander Gordeev To: kvm@vger.kernel.org Cc: Alexander Gordeev , Thomas Huth , Andrew Jones Subject: [kvm-unit-tests PATCH 2/4] pci: Assert when PCI bus address can not be translated Date: Tue, 29 Nov 2016 15:48:51 +0100 Message-Id: <2ce796c2ddfe691658b17f2e6e79c8a9acc76c6d.1480430576.git.agordeev@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 29 Nov 2016 14:48:59 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cc: Thomas Huth Cc: Andrew Jones Signed-off-by: Alexander Gordeev --- lib/pci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pci.c b/lib/pci.c index 6bd54cbac1bb..fdd88296f0ae 100644 --- a/lib/pci.c +++ b/lib/pci.c @@ -43,11 +43,15 @@ phys_addr_t pci_bar_get_addr(pcidevaddr_t dev, int bar_num) uint32_t bar = pci_bar_get(dev, bar_num); uint32_t mask = pci_bar_mask(bar); uint64_t addr = bar & mask; + phys_addr_t phys_addr; if (pci_bar_is64(dev, bar_num)) addr |= (uint64_t)pci_bar_get(dev, bar_num + 1) << 32; - return pci_translate_addr(dev, addr); + phys_addr = pci_translate_addr(dev, addr); + assert(phys_addr != INVALID_PHYS_ADDR); + + return phys_addr; } void pci_bar_set_addr(pcidevaddr_t dev, int bar_num, phys_addr_t addr)