From patchwork Tue Feb 4 16:53:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 3577871 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A8F9C9F382 for ; Tue, 4 Feb 2014 16:54:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9B13D201DE for ; Tue, 4 Feb 2014 16:54:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B6ABF201F7 for ; Tue, 4 Feb 2014 16:54:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932139AbaBDQx4 (ORCPT ); Tue, 4 Feb 2014 11:53:56 -0500 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]:49541 "EHLO cam-admin0.cambridge.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932104AbaBDQxy (ORCPT ); Tue, 4 Feb 2014 11:53:54 -0500 Received: from mudshark.cambridge.arm.com (mudshark.cambridge.arm.com [10.1.203.36]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id s14GrXkk003306; Tue, 4 Feb 2014 16:53:33 GMT Received: by mudshark.cambridge.arm.com (Postfix, from userid 1000) id 9D060C2B18; Tue, 4 Feb 2014 16:53:32 +0000 (GMT) From: Will Deacon To: kvm@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, penberg@kernel.org, marc.zyngier@arm.com, arnd@arndb.de Subject: [PATCH 06/17] kvm tools: pci: ensure BARs are naturally aligned Date: Tue, 4 Feb 2014 16:53:21 +0000 Message-Id: <1391532812-2043-7-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: <1391532812-2043-1-git-send-email-will.deacon@arm.com> References: <1391532812-2043-1-git-send-email-will.deacon@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.5 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 BARs must be naturally aligned, so enforce this in the PCI IO space allocator. Signed-off-by: Will Deacon --- tools/kvm/pci.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/kvm/pci.c b/tools/kvm/pci.c index e735352eb042..c4442c85b5cf 100644 --- a/tools/kvm/pci.c +++ b/tools/kvm/pci.c @@ -18,11 +18,13 @@ static union pci_config_address pci_config_address; */ static u32 io_space_blocks = KVM_PCI_MMIO_AREA; +/* + * BARs must be naturally aligned, so enforce this in the allocator. + */ u32 pci_get_io_space_block(u32 size) { - u32 block = io_space_blocks; - io_space_blocks += size; - + u32 block = ALIGN(io_space_blocks, size); + io_space_blocks = block + size; return block; }