From patchwork Tue Jun 16 08:10:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenfan X-Patchwork-Id: 484826 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 810C01400A0 for ; Tue, 16 Jun 2015 18:13:36 +1000 (AEST) Received: from localhost ([::1]:38534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4lzy-000555-Ih for incoming@patchwork.ozlabs.org; Tue, 16 Jun 2015 04:13:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4lzP-0004As-Mi for qemu-devel@nongnu.org; Tue, 16 Jun 2015 04:13:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4lzN-0004bS-OV for qemu-devel@nongnu.org; Tue, 16 Jun 2015 04:12:59 -0400 Received: from [59.151.112.132] (port=41971 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4lzN-0004Xn-DN for qemu-devel@nongnu.org; Tue, 16 Jun 2015 04:12:57 -0400 X-IronPort-AV: E=Sophos;i="5.13,622,1427731200"; d="scan'208";a="97125600" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 16 Jun 2015 16:16:50 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t5G8B5Rr021003; Tue, 16 Jun 2015 16:11:05 +0800 Received: from G08FNSTD131468.g08.fujitsu.local (10.167.226.78) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 16 Jun 2015 16:12:43 +0800 From: Chen Fan To: Date: Tue, 16 Jun 2015 16:10:47 +0800 Message-ID: <8c5428d545c9134dfff64581e54cbe1159b3a3a5.1434356309.git.chen.fan.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.167.226.78] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: izumi.taku@jp.fujitsu.com, alex.williamson@redhat.com Subject: [Qemu-devel] [RFC v10 03/19] pcie: modify the capability size assert X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org because the capabilities need to be DWORD aligned, so the size should DWORD aligned too, and then the last capability size can to be the greatest 0x1000. e.g. if I have a capability starting 4 bytes from the end, 0xFFC. The max size should be 4 bytes, 0x1000 - 0xFFC, not 3 bytes, 0xFFF - 0xFFC. Signed-off-by: Chen Fan Reviewed-by: Marcel Apfelbaum --- hw/pci/pcie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 1463e65..6cdd4a1 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -595,7 +595,7 @@ void pcie_add_capability(PCIDevice *dev, assert(offset >= PCI_CONFIG_SPACE_SIZE); assert(offset < offset + size); - assert(offset + size < PCIE_CONFIG_SPACE_SIZE); + assert(offset + size <= PCIE_CONFIG_SPACE_SIZE); assert(size >= 8); assert(pci_is_express(dev));