[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 12/19] xen: add PCI MMIO areas to memory map
From: |
Daniel Kiper |
Subject: |
Re: [PATCH v4 12/19] xen: add PCI MMIO areas to memory map |
Date: |
Fri, 9 Nov 2018 20:14:57 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Fri, Nov 02, 2018 at 01:37:31PM +0100, Juergen Gross wrote:
> Add possible PCI space MMIO areas as "Reserved" to the memory map in
> order to avoid using those areas for special Xen pages later.
>
> Signed-off-by: Juergen Gross <address@hidden>
Reviewed-by: Daniel Kiper <address@hidden> but I would like to
here something from Roger here too.
Daniel
> ---
> V4: new patch (Roger Pau Monné)
> ---
> grub-core/kern/i386/xen/pvh.c | 70
> +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 70 insertions(+)
>
> diff --git a/grub-core/kern/i386/xen/pvh.c b/grub-core/kern/i386/xen/pvh.c
> index 58e6fefd5..442351d1d 100644
> --- a/grub-core/kern/i386/xen/pvh.c
> +++ b/grub-core/kern/i386/xen/pvh.c
> @@ -20,6 +20,7 @@
> #include <grub/misc.h>
> #include <grub/memory.h>
> #include <grub/mm.h>
> +#include <grub/pci.h>
> #include <grub/i386/cpuid.h>
> #include <grub/i386/io.h>
> #include <grub/xen.h>
> @@ -170,6 +171,73 @@ grub_xen_sort_mmap (void)
> }
> }
>
> +static grub_uint64_t
> +grub_xen_pci_read (grub_pci_address_t addr, grub_uint32_t is_64bit)
> +{
> + grub_uint64_t val;
> +
> + val = grub_pci_read (addr);
> + if (is_64bit)
> + {
> + addr += sizeof (grub_uint32_t);
> + val |= ((grub_uint64_t) grub_pci_read (addr)) << 32;
> + }
> +
> + return val;
> +}
> +
> +static void
> +grub_xen_pci_write (grub_pci_address_t addr, grub_uint64_t val,
> + grub_uint32_t is_64bit)
> +{
> + grub_pci_write (addr, (grub_uint32_t) val);
> + if (is_64bit)
> + {
> + addr += sizeof (grub_uint32_t);
> + grub_pci_write (addr, val >> 32);
> + }
> +}
> +
> +static int
> +grub_xen_pci_mmap (grub_pci_device_t dev,
> + grub_pci_id_t pciid __attribute__ ((unused)),
> + void *data __attribute__ ((unused)))
> +{
> + int reg;
> + grub_pci_address_t addr;
> + grub_uint32_t val;
> + grub_uint64_t mmio_addr, mmio_size;
> +
> + if (nr_map_entries == ARRAY_SIZE (map))
> + return 1;
> +
> + for (reg = GRUB_PCI_REG_ADDRESSES; reg < GRUB_PCI_REG_CIS_POINTER;
> + reg += sizeof (grub_uint32_t))
> + {
> + addr = grub_pci_make_address (dev, reg);
> + val = grub_pci_read (addr);
> + if (val == 0 ||
> + (val & GRUB_PCI_ADDR_SPACE_MASK) != GRUB_PCI_ADDR_SPACE_MEMORY)
> + continue;
> +
> + val &= GRUB_PCI_ADDR_MEM_TYPE_MASK;
> + mmio_addr = grub_xen_pci_read (addr, val);
> + grub_xen_pci_write (addr, ~0ULL, val);
> + mmio_size = ~(grub_xen_pci_read (addr, val) & ~0x0fULL) + 1;
> + grub_xen_pci_write (addr, mmio_addr, val);
> +
> + map[nr_map_entries].type = GRUB_MEMORY_RESERVED;
> + map[nr_map_entries].addr = mmio_addr;
> + map[nr_map_entries].len = mmio_size;
> + nr_map_entries++;
> +
> + if (val)
> + reg += sizeof (grub_uint32_t);
> + }
> +
> + return 0;
> +}
> +
> static void
> grub_xen_get_mmap (void)
> {
> @@ -182,6 +250,8 @@ grub_xen_get_mmap (void)
> grub_xen_panic ("Could not get memory map from Xen.\n");
> nr_map_entries = memmap.nr_entries;
>
> + grub_pci_iterate (grub_xen_pci_mmap, NULL);
> +
> grub_xen_sort_mmap ();
> }
>
> --
> 2.16.4
- [PATCH v4 00/19] xen: add pvh guest support, Juergen Gross, 2018/11/02
- [PATCH v4 16/19] grub-module-verifier: Ignore all_video for xenpvh, Juergen Gross, 2018/11/02
- [PATCH v4 17/19] xen_pvh: support building a standalone image, Juergen Gross, 2018/11/02
- [PATCH v4 15/19] xen_pvh: add build runes for grub-core, Juergen Gross, 2018/11/02
- [PATCH v4 19/19] xen_pvh: add support to configure, Juergen Gross, 2018/11/02
- [PATCH v4 13/19] xen: setup Xen specific data for PVH, Juergen Gross, 2018/11/02