Received: by 10.223.185.116 with SMTP id b49csp4746402wrg; Tue, 6 Mar 2018 23:42:23 -0800 (PST) X-Google-Smtp-Source: AG47ELtywEagl6YPKiehswBSi+zeFFQ3NUeMTzFoH8/DnEIz1il3UZjU0v5QYy6ZbVWbiePRZ6y3 X-Received: by 10.101.64.197 with SMTP id u5mr17607292pgp.23.1520408543460; Tue, 06 Mar 2018 23:42:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520408543; cv=none; d=google.com; s=arc-20160816; b=LllnfvKr19I4pYU85bEL3FGoBuWeCRfC9DGktac6DL23qOwLSyKvRaRQrrQB38M60p mUbH0v45NQ8AMSFZXPu2XN7rgsercj6maxpYUGhzkt2mOQ/KyyzG+BUOcDTpbEwGJZ5q 6LOjGA0bWO6eWmfPxWtGr0LtPNi0R3Qxmx4HCRBSjjYMhM6Io9Au1E/g5uKUttL+Xp7y aVqlFPOzChlu2Zxb+vcWesADsVZZt7nRDitjOLhtQqeFpKgKynPg0RlaAHBFZAdyaFHv rTplX9yoKTM/v2Pgf2f+DFUf0gg0ZkjjzV++T71fleTKbR1MUeseJCSKDrq2gHOFa9l7 JIxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=2SPc5Ov84BgbGCmGKLV14mlu6PsFS6IkemlcefZMseI=; b=1IJ4D3xnTSRJxAHpSfvRXnYV87b5sjRH4MviV0uj+mnj5UTB+IDL2v4BsDvJL001pe kyId8cc9QdQdFBc0Wudu64YLsmS8u6AVGEM/RBO/1h0GsqxzkVLsu8aMUDz2vRfDpYcZ vU1O9+scTjJPdt7e+6eyildZySCPt3Zx+diDmlzjRy0PFM6L65/cSk6j3yBakeftKn3Y DRgdNhbypa6aodDWsM1LX7gq2dwNvJkn/+vkW7XbF1JUxYNdIBZy3tAzeeEeRFtvhE/2 8KhZbcLU5+CJSJM3YxTCoBzidSkcCDF7mfWldIygloSjjY/xlbdeHrwgaSIEQJz/Gr3b 1xmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e20si3301574pfi.359.2018.03.06.23.42.09; Tue, 06 Mar 2018 23:42:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754128AbeCGHkj (ORCPT + 99 others); Wed, 7 Mar 2018 02:40:39 -0500 Received: from david.siemens.de ([192.35.17.14]:35655 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751130AbeCGHji (ORCPT ); Wed, 7 Mar 2018 02:39:38 -0500 Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w277dMVP015233 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 7 Mar 2018 08:39:22 +0100 Received: from md1f2u6c.ww002.siemens.net ([167.87.11.133]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w277dIAj004697; Wed, 7 Mar 2018 08:39:21 +0100 From: Jan Kiszka To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Bjorn Helgaas Cc: x86@kernel.org, Linux Kernel Mailing List , jailhouse-dev@googlegroups.com, linux-pci@vger.kernel.org, virtualization@lists.linux-foundation.org, Andy Shevchenko Subject: [PATCH v5 3/7] x86/jailhouse: Enable PCI mmconfig access in inmates Date: Wed, 7 Mar 2018 08:39:14 +0100 Message-Id: <2ee9e4401fa22377b3965893a558120f169be82b.1520408357.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Otavio Pontes Use the PCI mmconfig base address exported by jailhouse in boot parameters in order to access the memory mapped PCI configuration space. Signed-off-by: Otavio Pontes [Jan: rebased, fixed !CONFIG_PCI_MMCONFIG, used pcibios_last_bus] Signed-off-by: Jan Kiszka Reviewed-by: Andy Shevchenko --- arch/x86/include/asm/pci_x86.h | 2 ++ arch/x86/kernel/jailhouse.c | 8 ++++++++ arch/x86/pci/mmconfig-shared.c | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h index eb66fa9cd0fc..959d618dbb17 100644 --- a/arch/x86/include/asm/pci_x86.h +++ b/arch/x86/include/asm/pci_x86.h @@ -151,6 +151,8 @@ extern int pci_mmconfig_insert(struct device *dev, u16 seg, u8 start, u8 end, phys_addr_t addr); extern int pci_mmconfig_delete(u16 seg, u8 start, u8 end); extern struct pci_mmcfg_region *pci_mmconfig_lookup(int segment, int bus); +extern struct pci_mmcfg_region *__init pci_mmconfig_add(int segment, int start, + int end, u64 addr); extern struct list_head pci_mmcfg_list; diff --git a/arch/x86/kernel/jailhouse.c b/arch/x86/kernel/jailhouse.c index b68fd895235a..fa183a131edc 100644 --- a/arch/x86/kernel/jailhouse.c +++ b/arch/x86/kernel/jailhouse.c @@ -124,6 +124,14 @@ static int __init jailhouse_pci_arch_init(void) if (pcibios_last_bus < 0) pcibios_last_bus = 0xff; +#ifdef CONFIG_PCI_MMCONFIG + if (setup_data.pci_mmconfig_base) { + pci_mmconfig_add(0, 0, pcibios_last_bus, + setup_data.pci_mmconfig_base); + pci_mmcfg_arch_init(); + } +#endif + return 0; } diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c index 96684d0adcf9..0e590272366b 100644 --- a/arch/x86/pci/mmconfig-shared.c +++ b/arch/x86/pci/mmconfig-shared.c @@ -94,8 +94,8 @@ static struct pci_mmcfg_region *pci_mmconfig_alloc(int segment, int start, return new; } -static struct pci_mmcfg_region *__init pci_mmconfig_add(int segment, int start, - int end, u64 addr) +struct pci_mmcfg_region *__init pci_mmconfig_add(int segment, int start, + int end, u64 addr) { struct pci_mmcfg_region *new; -- 2.13.6