Re: [SeaBIOS] [Qemu-devel] [PATCH RFC 2/3] acpi: load and link tables from /etc/acpi/
Not sure how much it counts, but I personally can agree with you on this direction :) One note below: @@ -603,8 +604,72 @@ acpi_setup(void) if (! CONFIG_ACPI) return; +int acpi_generate = 1; + dprintf(3, init ACPI tables\n); +struct romfile_s *file = NULL; +for (;;) { +file = romfile_findprefix(/etc/acpi/, file); +if (!file) +break; + +/* + * Disable ACPI table generation. All ACPI tables must come from + * etc/acpi/ romfile entries. + */ +acpi_generate = 0; + [...] +} + +linker_link(/etc/linker-script); + +if (!acpi_generate) { +return; +} + +dprintf(3, generate ACPI tables\n); + // This code is hardcoded for PIIX4 Power Management device. struct pci_device *pci = pci_find_init_device(acpi_find_tbl, NULL); if (!pci) Are you deliberately calling linker_link() independently from acpi_generate? My hunch is that linker_link() only makes sense if acpi_generate == 0 (ie. qemu has passed down at least one table to repoint some pointer to), but I may be missing a use case. Thanks Laszlo ___ SeaBIOS mailing list SeaBIOS@seabios.org http://www.seabios.org/mailman/listinfo/seabios
Re: [SeaBIOS] [Qemu-devel] [PATCH RFC 2/3] acpi: load and link tables from /etc/acpi/
On Mon, Apr 29, 2013 at 01:41:01PM +0200, Laszlo Ersek wrote: Not sure how much it counts, but I personally can agree with you on this direction :) One note below: @@ -603,8 +604,72 @@ acpi_setup(void) if (! CONFIG_ACPI) return; +int acpi_generate = 1; + dprintf(3, init ACPI tables\n); +struct romfile_s *file = NULL; +for (;;) { +file = romfile_findprefix(/etc/acpi/, file); +if (!file) +break; + +/* + * Disable ACPI table generation. All ACPI tables must come from + * etc/acpi/ romfile entries. + */ +acpi_generate = 0; + [...] +} + +linker_link(/etc/linker-script); + +if (!acpi_generate) { +return; +} + +dprintf(3, generate ACPI tables\n); + // This code is hardcoded for PIIX4 Power Management device. struct pci_device *pci = pci_find_init_device(acpi_find_tbl, NULL); if (!pci) Are you deliberately calling linker_link() independently from acpi_generate? My hunch is that linker_link() only makes sense if acpi_generate == 0 (ie. qemu has passed down at least one table to repoint some pointer to), but I may be missing a use case. Thanks Laszlo In theory linker code is unrelated to acpi, and host can the linker to patch any romfile. I could add if (!acpi_generate) but it just seems like adding code to remove something potentially useful. -- MST ___ SeaBIOS mailing list SeaBIOS@seabios.org http://www.seabios.org/mailman/listinfo/seabios
[SeaBIOS] [PATCH 2/2] pci: load memory window setup from host
Load memory window setup for pci from host. This makes it possible for host to make sure setup matches hardware exactly: especially important for when ACPI tables are loaded from host. This will also make it easier to add more chipsets down the road. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- src/paravirt.c | 25 - src/pciinit.c | 54 -- src/util.h | 8 +++- 3 files changed, 71 insertions(+), 16 deletions(-) diff --git a/src/paravirt.c b/src/paravirt.c index 85aa423..067a4dc 100644 --- a/src/paravirt.c +++ b/src/paravirt.c @@ -91,14 +91,35 @@ qemu_preinit(void) dprintf(1, Ram Size=0x%08x (0x%016llx high)\n, RamSize, RamSizeOver4G); } +struct pci_mem *qemu_get_pci_mem(void) +{ +int psize; +struct pci_mem *mem = romfile_loadfile(etc/pci-info, psize); +if (!mem) +return NULL; +if (psize sizeof *mem) { +free(mem); +return NULL; +} +mem-start32 = le64_to_cpu(mem-start32); +mem-end32 = le64_to_cpu(mem-end32); +mem-start64 = le64_to_cpu(mem-start64); +mem-end64 = le64_to_cpu(mem-end64); +return mem; +} + void qemu_platform_setup(void) { +struct pci_mem *mem; + if (!CONFIG_QEMU) return; qemu_cfg_init(); +mem = qemu_get_pci_mem(); + if (runningOnXen()) { pci_probe_devices(); xen_hypercall_setup(); @@ -107,7 +128,7 @@ qemu_platform_setup(void) } // Initialize pci -pci_setup(); +pci_setup(mem); smm_device_setup(); smm_setup(); @@ -120,6 +141,8 @@ qemu_platform_setup(void) mptable_setup(); smbios_setup(); acpi_setup(); +if (mem) +free(mem); } diff --git a/src/pciinit.c b/src/pciinit.c index bb9355f..f3bac02 100644 --- a/src/pciinit.c +++ b/src/pciinit.c @@ -361,6 +361,8 @@ static void pci_enable_default_vga(void) void i440fx_mem_addr_setup(struct pci_device *dev, void *arg) { +if (arg) + /* use supplied memory */; if (RamSize = 0x8000) pcimem_start = 0x8000; else if (RamSize = 0xc000) @@ -383,8 +385,9 @@ void mch_mem_addr_setup(struct pci_device *dev, void *arg) pci_config_writel(bdf, Q35_HOST_BRIDGE_PCIEXBAR, lower); add_e820(addr, size, E820_RESERVED); -/* setup pci i/o window (above mmconfig) */ -pcimem_start = addr + size; +/* unless done already, setup pci i/o window (above mmconfig) */ +if (!arg) + pcimem_start = addr + size; pci_slot_get_irq = mch_pci_slot_get_irq; } @@ -397,11 +400,11 @@ static const struct pci_device_id pci_platform_tbl[] = { PCI_DEVICE_END }; -static void pci_bios_init_platform(void) +static void pci_bios_init_platform(struct pci_mem *mem) { struct pci_device *pci; foreachpci(pci) { -pci_init_device(pci_platform_tbl, pci, NULL); +pci_init_device(pci_platform_tbl, pci, mem); } } @@ -762,10 +765,14 @@ static void pci_region_map_entries(struct pci_bus *busses, struct pci_region *r) } } -static void pci_bios_map_devices(struct pci_bus *busses) +static void pci_bios_map_devices(struct pci_bus *busses, struct pci_mem *mem) { if (pci_bios_init_root_regions(busses)) { struct pci_region r64_mem, r64_pref; + +if (mem mem-start64 = mem-end64) +panic(PCI: out of 32bit address space\n); + r64_mem.list = NULL; r64_pref.list = NULL; pci_region_migrate_64bit_entries(busses[0].r[PCI_REGION_TYPE_MEM], @@ -781,14 +788,27 @@ static void pci_bios_map_devices(struct pci_bus *busses) u64 align_mem = pci_region_align(r64_mem); u64 align_pref = pci_region_align(r64_pref); -r64_mem.base = ALIGN(0x1LL + RamSizeOver4G, align_mem); -r64_pref.base = ALIGN(r64_mem.base + sum_mem, align_pref); -pcimem64_start = r64_mem.base; -pcimem64_end = r64_pref.base + sum_pref; +if (mem) { +/* + * Non prefetcheable memory at start of the window, + * prefetcheable memory at the end. + * This way OS has the maximum flexibility for + * allocating the rest of the memory. + */ +r64_mem.base = ALIGN(mem-start64, align_mem); +r64_pref.base = ALIGN_DOWN(mem-end64 - sum_pref + 1, align_pref); +if (sum_pref r64_pref.base r64_mem.base + sum_mem) +panic(PCI: out of 64bit address space\n); +} else { +r64_mem.base = ALIGN(0x1LL + RamSizeOver4G, align_mem); +r64_pref.base = ALIGN(r64_mem.base + sum_mem, align_pref); +pcimem64_start = r64_mem.base; +pcimem64_end = r64_pref.base + sum_pref; +} pci_region_map_entries(busses, r64_mem); pci_region_map_entries(busses, r64_pref); -} else { +} else if (!mem) { // no bars mapped high - drop 64bit window (see dsdt)
Re: [SeaBIOS] [PATCH 1/2] paravirt: init qemu cfg earlier
On Mon, Apr 29, 2013 at 06:21:43PM +0300, Michael S. Tsirkin wrote: This will make it possible to use fw config info for pci initialization. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- src/paravirt.c | 2 ++ src/post.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/paravirt.c b/src/paravirt.c index e5027d0..85aa423 100644 --- a/src/paravirt.c +++ b/src/paravirt.c @@ -97,6 +97,8 @@ qemu_platform_setup(void) if (!CONFIG_QEMU) return; +qemu_cfg_init(); That wont work - the romfile stuff is needed earlier (eg, in boot_init()). -Kevin ___ SeaBIOS mailing list SeaBIOS@seabios.org http://www.seabios.org/mailman/listinfo/seabios
Re: [SeaBIOS] [PATCH 2/2] pci: load memory window setup from host
On Mon, Apr 29, 2013 at 06:21:40PM +0300, Michael S. Tsirkin wrote: Load memory window setup for pci from host. This makes it possible for host to make sure setup matches hardware exactly: especially important for when ACPI tables are loaded from host. This will also make it easier to add more chipsets down the road. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- src/paravirt.c | 25 - src/pciinit.c | 54 -- src/util.h | 8 +++- 3 files changed, 71 insertions(+), 16 deletions(-) diff --git a/src/paravirt.c b/src/paravirt.c index 85aa423..067a4dc 100644 --- a/src/paravirt.c +++ b/src/paravirt.c @@ -91,14 +91,35 @@ qemu_preinit(void) dprintf(1, Ram Size=0x%08x (0x%016llx high)\n, RamSize, RamSizeOver4G); } +struct pci_mem *qemu_get_pci_mem(void) +{ +int psize; +struct pci_mem *mem = romfile_loadfile(etc/pci-info, psize); +if (!mem) +return NULL; +if (psize sizeof *mem) { Please always add parenthesis to sizeof calls. +free(mem); +return NULL; +} +mem-start32 = le64_to_cpu(mem-start32); +mem-end32 = le64_to_cpu(mem-end32); +mem-start64 = le64_to_cpu(mem-start64); +mem-end64 = le64_to_cpu(mem-end64); +return mem; +} + void qemu_platform_setup(void) { +struct pci_mem *mem; + if (!CONFIG_QEMU) return; qemu_cfg_init(); +mem = qemu_get_pci_mem(); + if (runningOnXen()) { pci_probe_devices(); xen_hypercall_setup(); @@ -107,7 +128,7 @@ qemu_platform_setup(void) } // Initialize pci -pci_setup(); +pci_setup(mem); I don't understand why this code is being added to paravirt.c. Just update pciinit.c with the romfile_loadfile() calls it needs. There is no reason to change the order of initialization or to add parameters to pci_setup. Otherwise, I'm fine with having QEMU send the PCI windows explicitly to SeaBIOS. -Kevin ___ SeaBIOS mailing list SeaBIOS@seabios.org http://www.seabios.org/mailman/listinfo/seabios
Re: [SeaBIOS] [PATCH 2/2] pci: load memory window setup from host
On Mon, Apr 29, 2013 at 07:27:29PM -0400, Kevin O'Connor wrote: On Mon, Apr 29, 2013 at 06:21:40PM +0300, Michael S. Tsirkin wrote: Load memory window setup for pci from host. This makes it possible for host to make sure setup matches hardware exactly: especially important for when ACPI tables are loaded from host. This will also make it easier to add more chipsets down the road. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- src/paravirt.c | 25 - src/pciinit.c | 54 -- src/util.h | 8 +++- 3 files changed, 71 insertions(+), 16 deletions(-) diff --git a/src/paravirt.c b/src/paravirt.c index 85aa423..067a4dc 100644 --- a/src/paravirt.c +++ b/src/paravirt.c @@ -91,14 +91,35 @@ qemu_preinit(void) dprintf(1, Ram Size=0x%08x (0x%016llx high)\n, RamSize, RamSizeOver4G); } +struct pci_mem *qemu_get_pci_mem(void) +{ +int psize; +struct pci_mem *mem = romfile_loadfile(etc/pci-info, psize); +if (!mem) +return NULL; +if (psize sizeof *mem) { Please always add parenthesis to sizeof calls. +free(mem); +return NULL; +} +mem-start32 = le64_to_cpu(mem-start32); +mem-end32 = le64_to_cpu(mem-end32); +mem-start64 = le64_to_cpu(mem-start64); +mem-end64 = le64_to_cpu(mem-end64); +return mem; +} + void qemu_platform_setup(void) { +struct pci_mem *mem; + if (!CONFIG_QEMU) return; qemu_cfg_init(); +mem = qemu_get_pci_mem(); + if (runningOnXen()) { pci_probe_devices(); xen_hypercall_setup(); @@ -107,7 +128,7 @@ qemu_platform_setup(void) } // Initialize pci -pci_setup(); +pci_setup(mem); I don't understand why this code is being added to paravirt.c. Just update pciinit.c with the romfile_loadfile() calls it needs. There is no reason to change the order of initialization or to add parameters to pci_setup. Don't we need to do qemu_cfg_init to load the list of files before we can call romfile_loadfile? Otherwise, I'm fine with having QEMU send the PCI windows explicitly to SeaBIOS. -Kevin ___ SeaBIOS mailing list SeaBIOS@seabios.org http://www.seabios.org/mailman/listinfo/seabios
Re: [SeaBIOS] [PATCH 1/2] paravirt: init qemu cfg earlier
On Mon, Apr 29, 2013 at 07:23:37PM -0400, Kevin O'Connor wrote: On Mon, Apr 29, 2013 at 06:21:43PM +0300, Michael S. Tsirkin wrote: This will make it possible to use fw config info for pci initialization. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- src/paravirt.c | 2 ++ src/post.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/paravirt.c b/src/paravirt.c index e5027d0..85aa423 100644 --- a/src/paravirt.c +++ b/src/paravirt.c @@ -97,6 +97,8 @@ qemu_platform_setup(void) if (!CONFIG_QEMU) return; +qemu_cfg_init(); That wont work - the romfile stuff is needed earlier (eg, in boot_init()). -Kevin True I was confused: static void maininit(void) { // Initialize internal interfaces. interface_init(); // Setup platform devices. platform_hardware_setup(); ... } I see this interface_init - qemu_cfg_init platform_hardware_setup - qemu_platform_setup - pci_setup So it's already called before pci_setup. As you said no need to change things. -- MST ___ SeaBIOS mailing list SeaBIOS@seabios.org http://www.seabios.org/mailman/listinfo/seabios