From nobody Sat Apr 20 07:27:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1579025698; cv=none; d=zohomail.com; s=zohoarc; b=c/w1QnK/mI3rvETvdJt+RkL+Oq3JnmwsFckzUbEarrVHAI34wlsGsRFrVc/Ra6gFRxK3AZaQpq3iEDyJVgSptPZCgxIdu1+GKQBZr1/SFvG/B/9BxBZay84GXEOQTdHVfHd1dZKLByFQsueikxqfDnjxh8QrXwBDWpyo5RuM/Lw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579025698; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=cQ1SAxaK3wvJlPA1tsLy5tVWMjEnFS64IzDVLMsLh3Q=; b=N5FwKZzJkFhtNxNNb0OsKPrBgoyUivxEsmLTyDv7TXN95ZL5NHIOsIntxJYrtpQYa4w6dhm2uaXSPiAHL5UFopl5NZskRKbqwK0xt4oderEbfDUeDRJJClqWO4IijSadOvLUYRh7w7EqOMmxkQEnOn5QSEISzUB+LxLweGUwULA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1579025698893110.06000911075591; Tue, 14 Jan 2020 10:14:58 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1irQhl-00063h-Ky; Tue, 14 Jan 2020 18:14:17 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1irQhj-00063V-Uz for xen-devel@lists.xenproject.org; Tue, 14 Jan 2020 18:14:15 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a85778cb-36f9-11ea-841f-12813bfff9fa; Tue, 14 Jan 2020 18:14:09 +0000 (UTC) X-Inumbo-ID: a85778cb-36f9-11ea-841f-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1579025649; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=F71AmoTdBipS6G0kM9p80fk7xVzzi/AMSt2cqLM8zyA=; b=ajtez9x09GDMiG+KN+hMoP9UAkzsxJEMGEX4qEAfsJ+So8MnfNuvi5EN JYrsJgSTZHMw3jhLiTr3Fnp1+nppZCugTKGkMhqP80fxbWpIMJ5zA8YA7 1gWbA7SF9caV62O9pXa1jESeWwksLiaJrINht7QBbhMauK8WcR63UCQdD 0=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: lWvwvicNXMcC3Tj4Q5I0AzV5+nHcemSdDXPWh6cqEbWhCipIS8x8/+eui1qnGzyBql1RaR859l /oYKIUdusRPNcpdy4ClChphOSr2AyJGLZ98MmdvqWl6MQRGbFnMF89Jt/ongmYBXu9VE33EtEj /drg7bvN1/YWaneoMCR57okw7giY7QDnoPH43hRejkOAAUOqHKq1uUenF2jfA8WNuwb88MY2f3 DmOuKsdtQL3KLeUZimAl8nNvefED2AFmYm21Eyhk7Px9czWCMCvRDlwo2zsC1FE8WFROaUd2vm tSQ= X-SBRS: 2.7 X-MesageID: 10899659 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,319,1574139600"; d="scan'208";a="10899659" From: Roger Pau Monne To: Date: Tue, 14 Jan 2020 19:13:45 +0100 Message-ID: <20200114181345.27565-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] x86/hvmloader: align BAR position to 4K X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Ian Jackson , Wei Liu , Jan Beulich , Roger Pau Monne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) When placing BARs with sizes smaller than 4K multiple BARs can end up mapped to the same guest physical address, and thus won't work correctly. Align all BARs placement to 4K in hvmloader to prevent such overlapping. Note that the guest can still move the BARs around and create this collisions, and that BARs not filling up a physical page might leak access to other MMIO regions placed in the same host physical page. This is however no worse than what's currently done, and hence should be considered an improvement over the current state. Signed-off-by: Roger Pau Monn=C3=A9 Tested-by: Jason Andryuk --- tools/firmware/hvmloader/pci.c | 4 ++++ tools/firmware/hvmloader/util.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/tools/firmware/hvmloader/pci.c b/tools/firmware/hvmloader/pci.c index 0b708bf578..c433b34cd6 100644 --- a/tools/firmware/hvmloader/pci.c +++ b/tools/firmware/hvmloader/pci.c @@ -489,6 +489,10 @@ void pci_setup(void) =20 resource->base =3D base; =20 + if ( (bar_data & PCI_BASE_ADDRESS_SPACE) =3D=3D + PCI_BASE_ADDRESS_SPACE_MEMORY ) + resource->base =3D ROUNDUP(resource->base, PAGE_SIZE); + pci_writel(devfn, bar_reg, bar_data); if (using_64bar) pci_writel(devfn, bar_reg + 4, bar_data_upper); diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/uti= l.h index 7bca6418d2..b5554b5844 100644 --- a/tools/firmware/hvmloader/util.h +++ b/tools/firmware/hvmloader/util.h @@ -51,6 +51,8 @@ void __bug(char *file, int line) __attribute__((noreturn)= ); #define MB(mb) (mb##ULL << 20) #define GB(gb) (gb##ULL << 30) =20 +#define ROUNDUP(x, a) (((x) + (a) - 1) & ~((a) - 1)) + static inline int test_bit(unsigned int b, const void *p) { return !!(((const uint8_t *)p)[b>>3] & (1u<<(b&7))); --=20 2.24.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel