On 2017-10-28 03:10, Otavio Pontes wrote:
> 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 <[email protected]>
> ---
> arch/x86/include/asm/pci_x86.h | 2 ++
> arch/x86/kernel/jailhouse.c | 16 ++++++++++++++++
> arch/x86/pci/mmconfig-shared.c | 4 ++--
> 3 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h
> index d08eacd298c2..114a39efb10c 100644
> --- a/arch/x86/include/asm/pci_x86.h
> +++ b/arch/x86/include/asm/pci_x86.h
> @@ -147,6 +147,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 eedce3f921b4..70a7d7ab0549 100644
> --- a/arch/x86/kernel/jailhouse.c
> +++ b/arch/x86/kernel/jailhouse.c
> @@ -12,6 +12,7 @@
>
> #include <linux/acpi_pmtmr.h>
> #include <linux/kernel.h>
> +#include <linux/pci.h>
> #include <linux/serial_8250.h>
> #include <asm/apic.h>
> #include <asm/cpu.h>
> @@ -26,11 +27,14 @@
> */
> struct jailhouse_setup_data {
> struct setup_data header;
> + u64 pci_mmconfig_base;
> u16 pm_timer_address;
> u16 num_cpus;
> u8 cpu_ids[255];
> };
>
> +static u64 pci_mmconfig_base;
> +
> static uint32_t jailhouse_cpuid_base(void)
> {
> if (boot_cpu_data.cpuid_level < 0 ||
> @@ -130,6 +134,16 @@ static unsigned int x2apic_get_apic_id(unsigned long id)
> return id;
> }
>
> +static int jailhouse_pci_init(void)
Missing __init here - added while merging.
Jan
> +{
> + if (pci_mmconfig_base) {
> + pci_mmconfig_add(0, 0, 0xff, pci_mmconfig_base);
> + pci_mmcfg_arch_init();
> + }
> +
> + return 0;
> +}
> +
> static void __init jailhouse_init_platform(void)
> {
> /*
> @@ -149,6 +163,7 @@ static void __init jailhouse_init_platform(void)
>
> x86_init.timers.timer_init = jailhouse_timer_init;
> x86_init.irqs.pre_vector_init = x86_init_noop;
> + x86_init.pci.init = jailhouse_pci_init;
> legacy_pic = &null_legacy_pic;
>
> x86_platform.get_wallclock = jailhouse_get_wallclock;
> @@ -158,6 +173,7 @@ static void __init jailhouse_init_platform(void)
> data = early_memremap(pa_data, sizeof(*data));
> pmtmr_ioport = data->pm_timer_address;
> printk(KERN_INFO "Jailhouse: PM-Timer IO Port: %#x\n", pmtmr_ioport);
> + pci_mmconfig_base = data->pci_mmconfig_base;
>
> /*
> * Register x2APIC handlers early. We need them when running
> diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c
> index dd30b7e08bc2..53ce81d5126d 100644
> --- a/arch/x86/pci/mmconfig-shared.c
> +++ b/arch/x86/pci/mmconfig-shared.c
> @@ -93,8 +93,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;
>
>
--
You received this message because you are subscribed to the Google Groups
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.