x86: qemu: add fw_cfg interface support for qemu-x86 targets
v6 cover x86: qemu: add fw_cfg interface support for qemu-x86 targets
The fw_cfg interface provided by QEMU allow guests to retrieve various information about the system, e.g. cpu number, variaous firmware data, kernel setup, etc. The fw_cfg interface can be accessed through 3 IO ports (on x86), using x86 in/out instructions.
- 0x510: select configuration items to access
- 0x511: reading this port will return data selected in 0x510
- 0x514: this can be used to detect if DMA interface is available
If fw_cfg DMA interface is available, it can be used to accelerate accesses.
This patchset adds the following supports for qemu-x86 targets:
+ the fw_cfg driver itself
+ add a U-Boot command 'fw' to support direct accessing kernel informtion from fw_cfg interface, this saves the time of loading them from hard disk or network again, through emulated devices.
+ use fw_cfg to get cpu number at runtime, so smp boot no longer relies on the cpu node hard-coded in dts files.
Changes in v6:
- fix oneline comment
- do not update bootargs when kernel cmdline only contains '\0'
Miao Yan (8):
x86: adjust ramdisk load address
x86: qemu: add fw_cfg support
x86: qemu: add a cpu uclass driver for qemu target
x86: fix a typo in function name
x86: use actual CPU number for allocating memory
x86: qemu: fix cpu device in smp boot
x86: qemu: remove cpu node in device tree
x86: qemu: add documentaion for the fw_cfg interface
arch/x86/cpu/mp_init.c | 84 +++++++++++- arch/x86/cpu/qemu/Makefile | 2 +- arch/x86/cpu/qemu/cpu.c | 46 +++++++ arch/x86/cpu/qemu/fw_cfg.c | 283 +++++++++++++++++++++++++++++++++++++++ arch/x86/cpu/qemu/qemu.c | 3 + arch/x86/dts/qemu-x86_i440fx.dts | 9 +- arch/x86/dts/qemu-x86_q35.dts | 9 +- arch/x86/include/asm/fw_cfg.h | 93 +++++++++++++ doc/README.x86 | 34 ++++- include/configs/x86-common.h | 3 +- 10 files changed, 539 insertions(+), 27 deletions(-) create mode 100644 arch/x86/cpu/qemu/cpu.c create mode 100644 arch/x86/cpu/qemu/fw_cfg.c create mode 100644 arch/x86/include/asm/fw_cfg.h
Signature · 1 line
1.9.1
PATCH v6 1/8 x86: adjust ramdisk load address
By default, ramdisk load address is defined to 02000000 in env string. When loading bzImage to 01000000 (default address), there's a chance that the ramdisk header would be overwritten by the kernel. Thus increase the gap and make ramdisk load at 04000000 by default and also this patch introduces a new configuration item CONFIG_RAMDISK_ADDR for this purpose
--- include/configs/x86-common.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/configs/x86-common.h +2 -1
@@ -208,6 +208,7 @@#define CONFIG_HOSTNAME x86#define CONFIG_BOOTFILE "bzImage"#define CONFIG_LOADADDR 0x1000000 +#define CONFIG_RAMDISK_ADDR 0x4000000#define CONFIG_EXTRA_ENV_SETTINGS \ CONFIG_STD_DEVICES_SETTINGS \
@@ -215,7 +216,7 @@"netdev=eth0\0" \"consoledev=ttyS0\0" \"othbootargs=acpi=off\0" \ -"ramdiskaddr=0x2000000\0" \ +"ramdiskaddr=0x4000000\0" \"ramdiskfile=initramfs.gz\0" #define CONFIG_RAMBOOTCOMMAND \
Signature · 1 line
1.9.1
PATCH v6 1/8 x86: adjust ramdisk load address
Quoted 10 lines · Miao Yan
By default, ramdisk load address is defined to 02000000 in env string. When loading bzImage to 01000000 (default address), there's a chance that the ramdisk header would be overwritten by the kernel. Thus increase the gap and make ramdisk load at 04000000 by default and also this patch introduces a new configuration item
CONFIG_RAMDISK_ADDRfor this purposeSigned-off-by Miao Yan <[email protected]>Reviewed-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>---
applied to u-boot-x86/next, thanks!
PATCH v6 2/8 x86: qemu: add fw_cfg support
In reply to Miao YanThe QEMU fw_cfg interface allows the guest to retrieve various data information from QEMU. For example, APCI/SMBios tables, number of online cpus, kernel data and command line, etc.
This patch adds support for QEMU fw_cfg interface.
---
Changes in v6:
- fix oneline comment
- do not update bootargs when kernel cmdline only contains '\0'
arch/x86/cpu/qemu/Makefile | 2 +- arch/x86/cpu/qemu/fw_cfg.c | 283 ++++++++++++++++++++++++++++++++++++++++++ arch/x86/cpu/qemu/qemu.c | 3 + arch/x86/include/asm/fw_cfg.h | 93 ++++++++++++++ 4 files changed, 380 insertions(+), 1 deletion(-) create mode 100644 arch/x86/cpu/qemu/fw_cfg.c create mode 100644 arch/x86/include/asm/fw_cfg.h
arch/x86/cpu/qemu/Makefile +1 -1
@@ -7,5 +7,5 @@ ifndef CONFIG_EFI_STUB obj-y += car.o dram.o endif -obj-y += qemu.o +obj-y += fw_cfg.o qemu.o obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi.o dsdt.o
arch/x86/cpu/qemu/fw_cfg.c new file +283 -0
283 lines not on this page · raw message
arch/x86/cpu/qemu/qemu.c +3 -0
@@ -11,6 +11,7 @@#include <asm/processor.h> #include <asm/arch/device.h> #include <asm/arch/qemu.h> +#include <asm/fw_cfg.h> static bool i440fx;
@@ -57,6 +58,8 @@ static void qemu_chipset_init(void)x86_pci_write_config32 (PCI_BDF (0 ,0 ,0 ),PCIEX_BAR ,CONFIG_PCIE_ECAM_BASE |BAR_EN ); } + +qemu_fwcfg_init (); }int arch_cpu_init (void )
arch/x86/include/asm/fw_cfg.h new file +93 -0
93 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v6 2/8 x86: qemu: add fw_cfg support
Quoted 14 lines · Miao Yan
The QEMU
fw_cfginterface allows the guest to retrieve various data information from QEMU. For example, APCI/SMBios tables, number of online cpus, kernel data and command line, etc.This patch adds support for QEMU
fw_cfginterface.Signed-off-by Miao Yan <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>---
Changes in v6:
- fix oneline comment
- do not update bootargs when kernel cmdline only contains '\0'
Quoted 8 lines
arch/x86/cpu/qemu/Makefile | 2 +- arch/x86/cpu/qemu/fw_cfg.c | 283 ++++++++++++++++++++++++++++++++++++++++++ arch/x86/cpu/qemu/qemu.c | 3 + arch/x86/include/asm/fw_cfg.h | 93 ++++++++++++++ 4 files changed, 380 insertions(+), 1 deletion(-) create mode 100644 arch/x86/cpu/qemu/fw_cfg.c create mode 100644 arch/x86/include/asm/fw_cfg.h
PATCH v6 2/8 x86: qemu: add fw_cfg support
Quoted 24 lines · Bin Meng
Quoted 14 lines · Miao Yan
The QEMU
fw_cfginterface allows the guest to retrieve various data information from QEMU. For example, APCI/SMBios tables, number of online cpus, kernel data and command line, etc.This patch adds support for QEMU
fw_cfginterface.Signed-off-by Miao Yan <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>---
Changes in v6:
- fix oneline comment
- do not update bootargs when kernel cmdline only contains '\0'Quoted 8 lines
arch/x86/cpu/qemu/Makefile | 2 +- arch/x86/cpu/qemu/fw_cfg.c | 283 ++++++++++++++++++++++++++++++++++++++++++ arch/x86/cpu/qemu/qemu.c | 3 + arch/x86/include/asm/fw_cfg.h | 93 ++++++++++++++ 4 files changed, 380 insertions(+), 1 deletion(-) create mode 100644 arch/x86/cpu/qemu/fw_cfg.c create mode 100644 arch/x86/include/asm/fw_cfg.h
Quoted 1 line
Tested-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH v6 3/8 x86: qemu: add a cpu uclass driver for qemu target
In reply to Miao YanAdd a cpu uclass driver for qemu. Previously, the qemu target gets cpu number from board dts files, which are manually created at compile time. This does not scale when more cpus are assigned to guest as the dts files must be modified as well.
This patch adds a cpu uclass driver for qemu targets to directly read online cpu number from firmware.
--- arch/x86/cpu/qemu/Makefile | 2 +- arch/x86/cpu/qemu/cpu.c | 57 ++++++++++++++++++++++++++++++++++++++++ arch/x86/dts/qemu-x86_i440fx.dts | 4 +-- arch/x86/dts/qemu-x86_q35.dts | 4 +-- 4 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 arch/x86/cpu/qemu/cpu.c
arch/x86/cpu/qemu/Makefile +1 -1
@@ -7,5 +7,5 @@ ifndef CONFIG_EFI_STUB obj-y += car.o dram.o endif -obj-y += fw_cfg.o qemu.o +obj-y += cpu.o fw_cfg.o qemu.o obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi.o dsdt.o
arch/x86/cpu/qemu/cpu.c new file +57 -0
57 lines not on this page · raw message
arch/x86/dts/qemu-x86_i440fx.dts +2 -2
@@ -32,14 +32,14 @@ cpu@0 { device_type = "cpu"; - compatible = "cpu-x86"; + compatible = "cpu-qemu"; reg = <0>; intel,apic-id = <0>; }; cpu at 1 { device_type = "cpu"; - compatible = "cpu-x86"; + compatible = "cpu-qemu"; reg = <1>; intel,apic-id = <1>; };
arch/x86/dts/qemu-x86_q35.dts +2 -2
@@ -43,14 +43,14 @@ cpu at 0 { device_type = "cpu"; - compatible = "cpu-x86"; + compatible = "cpu-qemu"; reg = <0>; intel,apic-id = <0>; }; cpu at 1 { device_type = "cpu"; - compatible = "cpu-x86"; + compatible = "cpu-qemu"; reg = <1>; intel,apic-id = <1>; };
Signature · 1 line
1.9.1
PATCH v6 3/8 x86: qemu: add a cpu uclass driver for qemu target
Quoted 11 lines · Miao Yan
Add a cpu uclass driver for qemu. Previously, the qemu target gets cpu number from board dts files, which are manually created at compile time. This does not scale when more cpus are assigned to guest as the dts files must be modified as well.
This patch adds a cpu uclass driver for qemu targets to directly read online cpu number from firmware.
Signed-off-by Miao Yan <[email protected]>Reviewed-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>
Quoted 8 lines
--- arch/x86/cpu/qemu/Makefile | 2 +- arch/x86/cpu/qemu/cpu.c | 57 ++++++++++++++++++++++++++++++++++++++++ arch/x86/dts/qemu-x86_i440fx.dts | 4 +-- arch/x86/dts/qemu-x86_q35.dts | 4 +-- 4 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 arch/x86/cpu/qemu/cpu.c
PATCH v6 3/8 x86: qemu: add a cpu uclass driver for qemu target
Quoted 21 lines · Bin Meng
Quoted 11 lines · Miao Yan
Add a cpu uclass driver for qemu. Previously, the qemu target gets cpu number from board dts files, which are manually created at compile time. This does not scale when more cpus are assigned to guest as the dts files must be modified as well.
This patch adds a cpu uclass driver for qemu targets to directly read online cpu number from firmware.
Signed-off-by Miao Yan <[email protected]>Reviewed-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>Quoted 8 lines
--- arch/x86/cpu/qemu/Makefile | 2 +- arch/x86/cpu/qemu/cpu.c | 57 ++++++++++++++++++++++++++++++++++++++++ arch/x86/dts/qemu-x86_i440fx.dts | 4 +-- arch/x86/dts/qemu-x86_q35.dts | 4 +-- 4 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 arch/x86/cpu/qemu/cpu.c
Quoted 1 line
Tested-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH v6 4/8 x86: fix a typo in function name
In reply to Miao YanRename 'find_cpu_by_apid_id' to 'find_cpu_by_apic_id'. This should be a typo.
--- arch/x86/cpu/mp_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/cpu/mp_init.c +3 -3
@@ -104,7 +104,7 @@ static void ap_do_flight_plan(struct udevice *cpu) } } -static int find_cpu_by_apid_id (int apic_id,struct udevice **devp) +static int find_cpu_by_apic_id (int apic_id,struct udevice **devp) {struct udevice *dev;
@@ -137,7 +137,7 @@ static void ap_init(unsigned int cpu_index)enable_lapic (); apic_id =lapicid (); - ret =find_cpu_by_apid_id (apic_id, &dev); + ret =find_cpu_by_apic_id (apic_id, &dev);if (ret) {debug ("Unknown CPU apic_id %x\n" , apic_id); goto done;
@@ -432,7 +432,7 @@ static int init_bsp(struct udevice **devp)lapic_setup (); apic_id =lapicid (); - ret =find_cpu_by_apid_id (apic_id, devp); + ret =find_cpu_by_apic_id (apic_id, devp);if (ret) {printf ("Cannot find boot CPU, APIC ID %d\n" , apic_id);return ret;
Signature · 1 line
1.9.1
PATCH v6 4/8 x86: fix a typo in function name
Quoted 7 lines · Miao Yan
Rename '
find_cpu_by_apid_id' to 'find_cpu_by_apic_id'. This should be a typo.Signed-off-by Miao Yan <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>---
applied to u-boot-x86/next, thanks!
PATCH v6 5/8 x86: use actual CPU number for allocating memory
In reply to Miao YanUse actual CPU number, instead of maximum cpu configured, to allocate stack memory in 'load_sipi_vector'
--- arch/x86/cpu/mp_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/cpu/mp_init.c +3 -3
@@ -210,7 +210,7 @@ static int save_bsp_msrs(char *start, int size)return msr_count; } -static int load_sipi_vector (atomic_t **ap_countp) +static int load_sipi_vector (atomic_t **ap_countp,int num_cpus) {struct sipi_params_16bit *params16;struct sipi_params *params;
@@ -239,7 +239,7 @@ static int load_sipi_vector(atomic_t **ap_countp) params->idt_ptr = (uint32_t )x86_get_idt (); params->stack_size =CONFIG_AP_STACK_SIZE ; - size = params->stack_size *CONFIG_MAX_CPUS ; + size = params->stack_size * num_cpus; stack =memalign (size,4096 );if (!stack)return -ENOMEM ;
@@ -483,7 +483,7 @@ int mp_init(struct mp_params *p) mp_info.records = p->flight_plan;/* Load the SIPI vector */ - ret =load_sipi_vector (&ap_count); + ret =load_sipi_vector (&ap_count, num_cpus);if (ap_count ==NULL )return -1 ;
Signature · 1 line
1.9.1
PATCH v6 5/8 x86: use actual CPU number for allocating memory
Quoted 10 lines · Miao Yan
Use actual CPU number, instead of maximum cpu configured, to allocate stack memory in '
load_sipi_vector'Signed-off-by Miao Yan <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>--- arch/x86/cpu/mp_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
PATCH v6 5/8 x86: use actual CPU number for allocating memory
Quoted 12 lines · Bin Meng
Quoted 10 lines · Miao Yan
Use actual CPU number, instead of maximum cpu configured, to allocate stack memory in '
load_sipi_vector'Signed-off-by Miao Yan <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>--- arch/x86/cpu/mp_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 1 line
Tested-by Bin Meng <[email protected]>
applied to u-boot-x86/next, thanks!
PATCH v6 6/8 x86: qemu: fix cpu device in smp boot
In reply to Miao YanCurrently, when booting with more that one CPU enabled, U-Boot scans 'cpu' node in device tree and calculates CPU number. This does not scale well as changing CPU number also requires modifying .dts and re-compiling U-Boot.
This patch uses fw_cfg interface provided by QEMU to detect online CPU number at runtime, and dynamically adds 'cpu' device to U-Boot's driver model.
---
Changes in v6:
- remove cpu_qemu_bind
arch/x86/cpu/mp_init.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ arch/x86/cpu/qemu/cpu.c | 11 -------- 2 files changed, 72 insertions(+), 11 deletions(-)
arch/x86/cpu/mp_init.c +72 -0
@@ -20,8 +20,11 @@#include <asm/mtrr.h> #include <asm/processor.h> #include <asm/sipi.h> +#include <asm/fw_cfg.h> #include <dm/device-internal.h> #include <dm/uclass-internal.h> +#include <dm/lists.h> +#include <dm/root.h> #include <linux/linkage.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -441,6 +444,69 @@ static int init_bsp(struct udevice **devp)return 0 ; } +#ifdef CONFIG_QEMU +static int qemu_cpu_fixup (void ) +{ +int ret; +int cpu_num; +int cpu_online; +struct udevice *dev, *pdev; +struct cpu_platdata *plat; +char *cpu; + +/* first we need to find '/cpus' */ +for (device_find_first_child (dm_root (), &pdev); + pdev; +device_find_next_child (&pdev)) { +if (!strcmp (pdev->name,"cpus" )) +break ; + } +if (!pdev) { +printf ("unable to find cpus device\n" ); +return -ENODEV ; + } + +/* calculate cpus that are already bound */ + cpu_num =0 ; +for (uclass_find_first_device (UCLASS_CPU , &dev); + dev; +uclass_find_next_device (&dev)) { + cpu_num++; + } + +/* get actual cpu number */ + cpu_online =qemu_fwcfg_online_cpus (); +if (cpu_online <0 ) { +printf ("unable to get online cpu number: %d\n" , cpu_online); +return cpu_online; + } + +/* bind addtional cpus */ + dev =NULL ; +for (; cpu_num < cpu_online; cpu_num++) { +/* +* allocate device name here as device_bind_driver() does +* not copy device name, 8 bytes are enough for +* sizeof("cpu@") + 3 digits cpu number + '\0' +*/ + cpu =malloc (8 ); +if (!cpu) { +printf ("unable to allocate device name\n" ); +return -ENOMEM ; + } +sprintf (cpu,"cpu@%d" , cpu_num); + ret =device_bind_driver (pdev,"cpu_qemu" , cpu, &dev); +if (ret) { +printf ("binding cpu@%d failed: %d\n" , cpu_num, ret); +return ret; + } + plat =dev_get_parent_platdata (dev); + plat->cpu_id = cpu_num; + } +return 0 ; +} +#endif +int mp_init (struct mp_params *p) {int num_aps;
@@ -454,6 +520,12 @@ int mp_init(struct mp_params *p)if (ret)return ret; +#ifdef CONFIG_QEMU + ret =qemu_cpu_fixup (); +if (ret) +return ret; +#endif + ret =init_bsp (&cpu);if (ret) {debug ("Cannot init boot CPU: err=%d\n" , ret);
arch/x86/cpu/qemu/cpu.c +0 -11
@@ -13,16 +13,6 @@DECLARE_GLOBAL_DATA_PTR ; -int cpu_qemu_bind (struct udevice *dev) -{ -struct cpu_platdata *plat =dev_get_parent_platdata (dev); - - plat->cpu_id =fdtdec_get_int (gd->fdt_blob, dev->of_offset, -"intel,apic-id" ,-1 ); - -return 0 ; -} -int cpu_qemu_get_desc (struct udevice *dev,char *buf,int size) {if (size <CPU_MAX_NAME_LEN )
@@ -52,6 +42,5 @@ U_BOOT_DRIVER(cpu_qemu_drv) = { .name = "cpu_qemu", .id = UCLASS_CPU, .of_match = cpu_qemu_ids, - .bind = cpu_qemu_bind, .ops = &cpu_qemu_ops, };
Signature · 1 line
1.9.1
PATCH v6 6/8 x86: qemu: fix cpu device in smp boot
Quoted 9 lines · Miao Yan
Currently, when booting with more that one CPU enabled, U-Boot scans 'cpu' node in device tree and calculates CPU number. This does not scale well as changing CPU number also requires modifying .dts and re-compiling U-Boot.
This patch uses
fw_cfginterface provided by QEMU to detect online CPU number at runtime, and dynamically adds 'cpu' device to U-Boot's driver model.
Quoted 5 lines
Signed-off-by Miao Yan <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>---
applied to u-boot-x86/next, thanks!
PATCH v6 7/8 x86: qemu: remove cpu node in device tree
In reply to Miao YanRemove 'cpu' node in device tree for QEMU targets, and let U-Boot detect and fix up those information at runtime.
--- arch/x86/dts/qemu-x86_i440fx.dts | 7 ------- arch/x86/dts/qemu-x86_q35.dts | 7 ------- 2 files changed, 14 deletions(-)
arch/x86/dts/qemu-x86_i440fx.dts +0 -7
@@ -36,13 +36,6 @@ reg = <0>; intel,apic-id = <0>; }; - - cpu at 1 { - device_type = "cpu"; - compatible = "cpu-qemu"; - reg = <1>; - intel,apic-id = <1>; - }; }; tsc-timer {
arch/x86/dts/qemu-x86_q35.dts +0 -7
@@ -47,13 +47,6 @@ reg = <0>; intel,apic-id = <0>; }; - - cpu at 1 { - device_type = "cpu"; - compatible = "cpu-qemu"; - reg = <1>; - intel,apic-id = <1>; - }; }; tsc-timer {
Signature · 1 line
1.9.1
PATCH v6 7/8 x86: qemu: remove cpu node in device tree
Quoted 7 lines · Miao Yan
Remove 'cpu' node in device tree for QEMU targets, and let U-Boot detect and fix up those information at runtime.
Signed-off-by Miao Yan <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>---
applied to u-boot-x86/next, thanks!
PATCH v6 8/8 x86: qemu: add documentaion for the fw_cfg interface
In reply to Miao YanDocument the usage of 'qfw' command
--- doc/README.x86 | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-)
doc/README.x86 +31 -3
@@ -295,9 +295,37 @@ show QEMU's VGA console window. Note this will disable QEMU's serial output. If you want to check both consoles, use '-serial stdio'. Multicore is also supported by QEMU via '-smp n' where n is the number of cores -to instantiate. Currently the default U-Boot built for QEMU supports 2 cores. -In order to support more cores, you need add additional cpu nodes in the device -tree and change CONFIG_MAX_CPUS accordingly. +to instantiate. Note, the maximum supported CPU number in QEMU is 255. + +The fw_cfg interface in QEMU also provides information about kernel data, initrd, +command-line arguments and more. U-Boot supports directly accessing these informtion +from fw_cfg interface, this saves the time of loading them from hard disk or +network again, through emulated devices. To use it , simply providing them in +QEMU command line: + +$ qemu-system-i386 -nographic -bios path/to/u-boot.rom -m 1024 -kernel /path/to/bzImage + -append 'root=/dev/ram console=ttyS0' -initrd /path/to/initrd -smp 8 + +Note: -initrd and -smp are both optional + +Then start QEMU, in U-Boot command line use the following U-Boot command to setup kernel: + + => qfw +qfw - QEMU firmware interface + +Usage: +qfw <command> + - list : print firmware(s) currently loaded + - cpus : print online cpu number + - load <kernel addr> <initrd addr> : load kernel and initrd (if any) and setup for zboot + +=> qfw load +loading kernel to address 01000000 size 5d9d30 initrd 04000000 size 1b1ab50 + +Here the kernel (bzImage) is loaded to 01000000 and initrd is to 04000000. Then, 'zboot' +can be used to boot the kernel: + +=> zboot 02000000 - 04000000 1b1ab50 CPU Microcode -------------
Signature · 1 line
1.9.1
PATCH v6 8/8 x86: qemu: add documentaion for the fw_cfg interface
Quoted 6 lines · Miao Yan
Document the usage of 'qfw' command
Signed-off-by Miao Yan <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>---
applied to u-boot-x86/next, thanks!
v6 cover x86: qemu: add fw_cfg interface support for qemu-x86 targets
In reply to Miao YanHi Bin,
2016-01-07 17:31 GMT+08:00 Miao Yan <[email protected]>:
Quoted 52 lines
The
fw_cfginterface provided by QEMU allow guests to retrieve various information about the system, e.g. cpu number, variaous firmware data, kernel setup, etc. Thefw_cfginterface can be accessed through 3 IO ports (on x86), using x86 in/out instructions.-
0x510: select configuration items to access
-0x511: reading this port will return data selected in0x510
-0x514: this can be used to detect if DMA interface is availableIf
fw_cfgDMA interface is available, it can be used to accelerate accesses.This patchset adds the following supports for qemu-x86 targets:
+ the
fw_cfgdriver itself+ add a U-Boot command 'fw' to support direct accessing kernel informtion from
fw_cfginterface, this saves the time of loading them from hard disk or network again, through emulated devices.+ use
fw_cfgto get cpu number at runtime, so smp boot no longer relies on the cpu node hard-coded in dts files.Changes in v6:
- fix oneline comment
- do not update bootargs when kernel cmdline only contains '\0'Miao Yan (8):
x86: adjust ramdisk load address
x86: qemu: addfw_cfgsupport
x86: qemu: add a cpu uclass driver for qemu target
x86: fix a typo in function name
x86: use actual CPU number for allocating memory
x86: qemu: fix cpu device in smp boot
x86: qemu: remove cpu node in device tree
x86: qemu: add documentaion for thefw_cfginterfacearch/x86/cpu/mp_init.c | 84 +++++++++++- arch/x86/cpu/qemu/Makefile | 2 +- arch/x86/cpu/qemu/cpu.c | 46 +++++++ arch/x86/cpu/qemu/fw_cfg.c | 283 +++++++++++++++++++++++++++++++++++++++ arch/x86/cpu/qemu/qemu.c | 3 + arch/x86/dts/qemu-x86_i440fx.dts | 9 +- arch/x86/dts/qemu-x86_q35.dts | 9 +- arch/x86/include/asm/fw_cfg.h | 93 +++++++++++++ doc/README.x86 | 34 ++++- include/configs/x86-common.h | 3 +- 10 files changed, 539 insertions(+), 27 deletions(-) create mode 100644 arch/x86/cpu/qemu/cpu.c create mode 100644 arch/x86/cpu/qemu/fw_cfg.c create mode 100644 arch/x86/include/asm/fw_cfg.h
Quoted 3 lines
--
1.9.1
Is v6 OK for integration ? Thanks.
v6 cover x86: qemu: add fw_cfg interface support for qemu-x86 targets
Hi Miao,
Quoted 55 lines · Miao Yan
Hi Bin,
2016-01-07 17:31 GMT+08:00 Miao Yan <[email protected]>:
Quoted 52 lines
The
fw_cfginterface provided by QEMU allow guests to retrieve various information about the system, e.g. cpu number, variaous firmware data, kernel setup, etc. Thefw_cfginterface can be accessed through 3 IO ports (on x86), using x86 in/out instructions.-
0x510: select configuration items to access
-0x511: reading this port will return data selected in0x510
-0x514: this can be used to detect if DMA interface is availableIf
fw_cfgDMA interface is available, it can be used to accelerate accesses.This patchset adds the following supports for qemu-x86 targets:
+ the
fw_cfgdriver itself+ add a U-Boot command 'fw' to support direct accessing kernel informtion from
fw_cfginterface, this saves the time of loading them from hard disk or network again, through emulated devices.+ use
fw_cfgto get cpu number at runtime, so smp boot no longer relies on the cpu node hard-coded in dts files.Changes in v6:
- fix oneline comment
- do not update bootargs when kernel cmdline only contains '\0'Miao Yan (8):
x86: adjust ramdisk load address
x86: qemu: addfw_cfgsupport
x86: qemu: add a cpu uclass driver for qemu target
x86: fix a typo in function name
x86: use actual CPU number for allocating memory
x86: qemu: fix cpu device in smp boot
x86: qemu: remove cpu node in device tree
x86: qemu: add documentaion for thefw_cfginterfacearch/x86/cpu/mp_init.c | 84 +++++++++++- arch/x86/cpu/qemu/Makefile | 2 +- arch/x86/cpu/qemu/cpu.c | 46 +++++++ arch/x86/cpu/qemu/fw_cfg.c | 283 +++++++++++++++++++++++++++++++++++++++ arch/x86/cpu/qemu/qemu.c | 3 + arch/x86/dts/qemu-x86_i440fx.dts | 9 +- arch/x86/dts/qemu-x86_q35.dts | 9 +- arch/x86/include/asm/fw_cfg.h | 93 +++++++++++++ doc/README.x86 | 34 ++++- include/configs/x86-common.h | 3 +- 10 files changed, 539 insertions(+), 27 deletions(-) create mode 100644 arch/x86/cpu/qemu/cpu.c create mode 100644 arch/x86/cpu/qemu/fw_cfg.c create mode 100644 arch/x86/include/asm/fw_cfg.h
Quoted 5 lines
Quoted 3 lines
--
1.9.1Is v6 OK for integration ? Thanks.
Yes, will be applied soon.
Regards,
Bin