spapr: Implement Open Firmware client interface
PATCH v12 1/1 spapr: Implement Open Firmware client interface
The PAPR platform which describes an OS environment that's presented by a combination of a hypervisor and firmware. The features it specifies require collaboration between the firmware and the hypervisor.
Since the beginning, the runtime component of the firmware (RTAS) has been implemented as a 20 byte shim which simply forwards it to a hypercall implemented in qemu. The boot time firmware component is SLOF - but a build that's specific to qemu, and has always needed to be updated in sync with it. Even though we've managed to limit the amount of runtime communication we need between qemu and SLOF, there's some, and it has become increasingly awkward to handle as we've implemented new features.
This implements a boot time OF client interface (CI) which is enabled by a new "x-vof" pseries machine option (stands for "Virtual Open Firmware). When enabled, QEMU implements the custom H_OF_CLIENT hcall which implements Open Firmware Client Interface (OF CI). This allows using a smaller stateless firmware which does not have to manage the device tree.
The new "vof.bin" firmware image is included with source code under pc-bios/. It also includes RTAS blob.
This implements a handful of CI methods just to get -kernel/-initrd working. In particular, this implements the device tree fetching and simple memory allocator - "claim" (an OF CI memory allocator) and updates "/memory@0/available" to report the client about available memory.
This implements changing some device tree properties which we know how to deal with, the rest is ignored. To allow changes, this skips fdt_pack() when x-vof=on as not packing the blob leaves some room for appending.
In absence of SLOF, this assigns phandles to device tree nodes to make device tree traversing work.
When x-vof=on, this adds "/chosen" every time QEMU (re)builds a tree.
This adds basic instances support which are managed by a hash map ihandle -> [phandle].
Before the guest started, the used memory is:
0..4000 - the initial firmware
10000..180000 - stack
This OF CI does not implement "interpret".
Unlike SLOF, this does not format uninitialized nvram. Instead, this includes a disk image with pre-formatted nvram.
With this basic support, this can only boot into kernel directly. However this is just enough for the petitboot kernel and initradmdisk to boot from any possible source. Note this requires reasonably recent guest kernel with:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=df5be5be8735
---
The example command line is:
-c 0 /home/aik/pbuild/qemu-killslof-localhost-ppc64/qemu-system-ppc64 \
-nodefaults \
-chardev stdio,id=STDIO0,signal=off,mux=on \
-device spapr-vty,id=svty0,reg=0x71000110,chardev=STDIO0 \
-mon id=MON0,chardev=STDIO0,mode=readline \
-nographic \
-vga none \
-enable-kvm \
-m 2G \
-machine pseries,x-vof=on,cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken,cap-ccf-assist=off \
-kernel pbuild/kernel-le-guest/vmlinux \
-initrd t/le.cpio \
-drive id=DRIVE0,if=none,file=./p/qemu-killslof/pc-bios/vof/nvram.bin,format=raw \
-global spapr-nvram.drive=DRIVE0 \
-snapshot \
-smp 8,threads=8 \
-L /home/aik/t/qemu-ppc64-bios/ \
-trace events=qemu_trace_events \
-d guest_errors \
-chardev socket,id=SOCKET0,server,nowait,path=qemu.mon.tmux26 \
-mon chardev=SOCKET0,mode=control
---
Changes:
v12:
* split VOF and SPAPR
v11:
* added g_autofree
* fixed gcc warnings
* fixed few leaks
* added nvram image to make "nvram --print-config" not crash; Note that contrary to MIN_NVRAM_SIZE (8 * KiB), the actual minimum size is 16K, or it just does not work (empty output from "nvram")
v10:
* now rebased to compile with meson
v9:
* remove special handling of /rtas/rtas-size as now we always add it in QEMU
* removed leftovers from scsi/grub/stdout/stdin/...
v8:
* no read/write/seek
* no @dev in instances
* the machine flag is "x-vof" for now
v7:
* now we have a small firmware which loads at 0 as SLOF and starts from 0x100 as SLOF
* no MBR/ELF/GRUB business in QEMU anymore
* blockdev is a separate patch
* networking is a separate patch
v6:
* borrowed a big chunk of commit log introduction from David
* fixed initial stack pointer (points to the highest address of stack)
* traces for "interpret" and others
* disabled translate_kernel_address() hack so grub can load (work in progress)
* added "milliseconds" for grub
* fixed "claim" allocator again
* moved FDT_MAX_SIZE to spapr.h as spapr_of_client.c wants it too for CAS
* moved the most code possible from spapr.c to spapr_of_client.c, such as RTAS, prom entry and FDT build/finalize
* separated blobs
* GRUB now proceeds to its console prompt (there are still other issues)
* parse MBR/GPT to find PReP and load GRUB
v5:
* made instances keep device and chardev pointers
* removed VIO dependencies
* print error if RTAS memory is not claimed as it should have been
* pack FDT as "quiesce"
v4:
* fixed open
* validate ihandles in "call-method"
v3:
* fixed phandles allocation
* s/__be32/uint32_t/ as we do not normally have __be32 type in qemu
* fixed size of /chosen/stdout
* bunch of renames
* do not create rtas properties at all, let the client deal with it; instead setprop allows changing these in the FDT
* no more packing FDT when bios=off - nobody needs it and getprop does not work otherwise
* allow updating initramdisk device tree properties (for zImage)
* added instances
* fixed stdout on OF's "write"
* removed special handling for stdout in OF client, spapr-vty handles it instead
v2:
* fixed claim()
* added "setprop"
* cleaner client interface and RTAS blobs management
* boots to petitboot and further to the target system
* more trace points
--- pc-bios/vof/Makefile | 18 + hw/ppc/vof.h | 44 ++ include/hw/ppc/spapr.h | 21 +- pc-bios/vof/vof.h | 44 ++ hw/ppc/spapr.c | 80 +++- hw/ppc/spapr_hcall.c | 8 +- hw/ppc/spapr_of_client.c | 132 ++++++ hw/ppc/vof.c | 905 +++++++++++++++++++++++++++++++++++++++ pc-bios/vof/bootmem.c | 13 + pc-bios/vof/ci.c | 108 +++++ pc-bios/vof/libc.c | 91 ++++ pc-bios/vof/main.c | 22 + hw/ppc/meson.build | 2 + hw/ppc/trace-events | 21 + pc-bios/README | 2 + pc-bios/vof.bin | Bin 0 -> 3680 bytes pc-bios/vof/entry.S | 51 +++ pc-bios/vof/l.lds | 48 +++ pc-bios/vof/nvram.bin | Bin 0 -> 16384 bytes 19 files changed, 1601 insertions(+), 9 deletions(-) create mode 100644 pc-bios/vof/Makefile create mode 100644 hw/ppc/vof.h create mode 100644 pc-bios/vof/vof.h create mode 100644 hw/ppc/spapr_of_client.c create mode 100644 hw/ppc/vof.c create mode 100644 pc-bios/vof/bootmem.c create mode 100644 pc-bios/vof/ci.c create mode 100644 pc-bios/vof/libc.c create mode 100644 pc-bios/vof/main.c create mode 100755 pc-bios/vof.bin create mode 100644 pc-bios/vof/entry.S create mode 100644 pc-bios/vof/l.lds create mode 100644 pc-bios/vof/nvram.bin
pc-bios/vof/Makefile new file +18 -0
@@ -0,0 +1,18 @@ +all: build-all + +build-all: vof.bin + +%.o: %.S + cc -m32 -mbig-endian -c -o $@ $< + +%.o: %.c + cc -m32 -mbig-endian -c -fno-stack-protector -Wno-builtin-declaration-mismatch -o $@ $< + +vof.elf: entry.o main.o libc.o ci.o bootmem.o + ld -nostdlib -e_start -Tl.lds -EB -o $@ $^ + +%.bin: %.elf + objcopy -O binary -j .text -j .data -j .toc -j .got2 $^ $@ + +clean: + rm -f *.o *.bin *.elf *~
hw/ppc/vof.h new file +44 -0
44 lines not on this page · raw message
include/hw/ppc/spapr.h +20 -1
@@ -12,6 +12,7 @@#include "hw/ppc/spapr_xive.h" /* For SpaprXive */ #include "hw/ppc/xics.h" /* For ICSState */ #include "hw/ppc/spapr_tpm_proxy.h" +#include "hw/ppc/vof.h" struct SpaprVioBus ;struct SpaprPhbState ;
@@ -178,6 +179,7 @@ struct SpaprMachineState {uint64_t kernel_addr;uint32_t initrd_base;long initrd_size; +Vof vof;uint64_t rtc_offset;/* Now used only during incoming migration */ struct PPCTimebase tb;bool has_graphics;
@@ -552,7 +554,8 @@ struct SpaprMachineState {/* Client Architecture support */ #define KVMPPC_H_CAS (KVMPPC_HCALL_BASE + 0x2)#define KVMPPC_H_UPDATE_DT (KVMPPC_HCALL_BASE + 0x3) -#define KVMPPC_HCALL_MAX KVMPPC_H_UPDATE_DT +#define KVMPPC_H_VOF_CLIENT (KVMPPC_HCALL_BASE + 0x5) +#define KVMPPC_HCALL_MAX KVMPPC_H_VOF_CLIENT/* * The hcall range 0xEF00 to 0xEF80 is reserved for use in facilitating
@@ -947,4 +950,20 @@ bool spapr_check_pagesize(SpaprMachineState *spapr, hwaddr pagesize,void spapr_set_all_lpcrs (target_ulong value,target_ulong mask);hwaddr spapr_get_rtas_addr (void ); + +void spapr_vof_client_dt_finalize (SpaprMachineState *spapr,void *fdt); +void spapr_vof_reset (SpaprMachineState *spapr,void *fdt, +target_ulong *stack_ptr); +void spapr_vof_quiesce (void ); +target_ulong spapr_h_vof_client (PowerPCCPU *cpu,SpaprMachineState *spapr, +target_ulong opcode,target_ulong *args); +target_ulong spapr_vof_client_architecture_support (CPUState *cs, +target_ulong ovec_addr); + +/* Copied from SLOF, and 4K is definitely not enough for GRUB */ +#define OF_STACK_SIZE 0x8000 + +/* 0..10000 is reserved for the VOF fw */ +#define OF_STACK_ADDR 0x10000 +#endif /* HW_SPAPR_H */
pc-bios/vof/vof.h new file +44 -0
44 lines not on this page · raw message
hw/ppc/spapr.c +73 -7
167 lines not on this page · raw message
hw/ppc/spapr_hcall.c +7 -1
@@ -1826,7 +1826,13 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu,spapr_setup_hpt (spapr); } - fdt =spapr_build_fdt (spapr, false, fdt_bufsize); +if (spapr->vof.on && spapr->vof.initrd_base && spapr->vof.initrd_size) { +/* Update initramdisk location so the right area gets reserved below */ + spapr->initrd_base = spapr->vof.initrd_base; + spapr->initrd_size = spapr->vof.initrd_size; + } + + fdt =spapr_build_fdt (spapr, spapr->vof.on, fdt_bufsize);g_free (spapr->fdt_blob); spapr->fdt_size =fdt_totalsize (fdt);
hw/ppc/spapr_of_client.c new file +132 -0
132 lines not on this page · raw message
hw/ppc/vof.c new file +905 -0
905 lines not on this page · raw message
pc-bios/vof/bootmem.c new file +13 -0
@@ -0,0 +1,13 @@ +#include "vof.h" + +void boot_from_memory (uint64_t initrd,uint64_t initrdsize) +{ +uint64_t kern[2 ]; +phandle chosen =ci_finddevice ("/chosen" ); + +if (ci_getprop (chosen,"qemu,boot-kernel" , kern,sizeof (kern)) != +sizeof (kern)) +return ; + +do_boot (kern[0 ], initrd, initrdsize); +}
pc-bios/vof/ci.c new file +108 -0
108 lines not on this page · raw message
pc-bios/vof/libc.c new file +91 -0
91 lines not on this page · raw message
pc-bios/vof/main.c new file +22 -0
@@ -0,0 +1,22 @@ +#include "vof.h" + + +void do_boot (unsigned long addr,unsigned long _r3,unsigned long _r4) +{ + register unsigned long r3 __asm__("r3") = _r3; + register unsigned long r4 __asm__("r4") = _r4; + register unsigned long r5 __asm__("r5") = (unsigned long) _prom_entry; + + ((client *)(uint32_t )addr)(); +} + +void entry_c (void ) +{ + registerunsigned long r3 __asm__("r3" ); + registerunsigned long r4 __asm__("r4" ); + registerunsigned long r5 __asm__("r5" ); +uint64_t initrd = r3, initrdsize = r4; + +boot_from_memory (initrd, initrdsize); +ci_panic ("*** No boot target ***\n" ); +}
hw/ppc/meson.build +2 -0
@@ -27,6 +27,8 @@ ppc_ss.add(when: 'CONFIG_PSERIES', if_true: files( 'spapr_nvdimm.c', 'spapr_rtas_ddw.c', 'spapr_numa.c', + 'spapr_of_client.c', + 'vof.c', )) ppc_ss.add(when: 'CONFIG_SPAPR_RNG', if_true: files('spapr_rng.c')) ppc_ss.add(when: ['CONFIG_PSERIES', 'CONFIG_LINUX'], if_true: files(
hw/ppc/trace-events +21 -0
@@ -71,6 +71,27 @@ spapr_rtas_ibm_configure_connector_invalid(uint32_t index) "DRC index: 0x%"PRIx3 spapr_vio_h_reg_crq(uint64_t reg, uint64_t queue_addr, uint64_t queue_len) "CRQ for dev 0x%" PRIx64 " registered at 0x%" PRIx64 "/0x%" PRIx64 spapr_vio_free_crq(uint32_t reg) "CRQ for dev 0x%" PRIx32 " freed" +# vof.c +vof_error_str_truncated(const char *s, int len) "%s truncated to %d" +vof_error_param(const char *method, int nargscheck, int nretcheck, int nargs, int nret) "%s takes/returns %d/%d, not %d/%d" +vof_error_unknown_service(const char *service, int nargs, int nret) "\"%s\" args=%d rets=%d" +vof_error_unknown_method(const char *method) "\"%s\"" +vof_error_unknown_ihandle_close(uint32_t ih) "ih=0x%x" +vof_error_unknown_path(const char *path) "\"%s\"" +vof_finddevice(const char *path, uint32_t ph) "\"%s\" => ph=0x%x" +vof_canon(const char *path) "\"%s\"" +vof_claim(uint32_t virt, uint32_t size, uint32_t align, uint32_t ret) "virt=0x%x size=0x%x align=0x%x => 0x%x" +vof_release(uint32_t virt, uint32_t size, uint32_t ret) "virt=0x%x size=0x%x => 0x%x" +vof_method(uint32_t ihandle, const char *method, uint32_t param, uint32_t ret, uint32_t ret2) "ih=0x%x \"%s\"(0x%x) => 0x%x 0x%x" +vof_getprop(uint32_t ph, const char *prop, uint32_t ret, const char *val) "ph=0x%x \"%s\" => len=%d [%s]" +vof_getproplen(uint32_t ph, const char *prop, uint32_t ret) "ph=0x%x \"%s\" => len=%d" +vof_setprop(uint32_t ph, const char *prop, const char *val, uint32_t ret) "ph=0x%x \"%s\" [%s] => len=%d" +vof_open(const char *path, uint32_t ph, uint32_t ih) "%s ph=0x%x => ih=0x%x" +vof_interpret(const char *cmd, uint32_t param1, uint32_t param2, uint32_t ret, uint32_t ret2) "[%s] 0x%x 0x%x => 0x%x 0x%x" +vof_package_to_path(uint32_t ph, const char *tmp, uint32_t ret) "ph=0x%x => %s len=%d" +vof_instance_to_path(uint32_t ih, uint32_t ph, const char *tmp, uint32_t ret) "ih=0x%x ph=0x%x => %s len=%d" +vof_instance_to_package(uint32_t ih, uint32_t ph) "ih=0x%x => ph=0x%x" + # ppc.c ppc_tb_adjust(uint64_t offs1, uint64_t offs2, int64_t diff, int64_t seconds) "adjusted from 0x%"PRIx64" to 0x%"PRIx64", diff %"PRId64" (%"PRId64"s)"
pc-bios/README +2 -0
@@ -16,6 +16,8 @@ https://github.com/aik/SLOF, and the image currently in qemu is built from git tag qemu-slof-20200717. +- vof is a minimalistic firmware to work with -machine pseries,x-vof=on. + - sgabios (the Serial Graphics Adapter option ROM) provides a means for legacy x86 software to communicate with an attached serial console as if a video card were attached. The master sources reside in a subversion
pc-bios/vof.bin new file binary +0 -0
pc-bios/vof/entry.S new file +51 -0
51 lines not on this page · raw message
pc-bios/vof/l.lds new file +48 -0
48 lines not on this page · raw message
pc-bios/vof/nvram.bin new file binary +0 -0
Signature · 1 line
2.17.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [PATCH qemu v12] spapr: Implement Open Firmware client interface
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
453ef2b spapr: Implement Open Firmware client interface
=== OUTPUT BEGIN ===
WARNING: line over 80 characters
#223: FILE: hw/ppc/spapr.c:4463:
+ ClientArchitectureSupportClass *casc = CLIENT_ARCHITECTURE_SUPPORT_CLASS(oc);
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #282:
new file mode 100644
WARNING: line over 80 characters
#1398: FILE: hw/ppc/vof.h:31:
+ INTERFACE_CHECK(ClientArchitectureSupport, (obj), TYPE_CLIENT_ARCHITECTURE_SUPPORT)
ERROR: code indent should never use tabs
#1514: FILE: pc-bios/vof/bootmem.c:5:
+^Iuint64_t kern[2];$
ERROR: code indent should never use tabs
#1515: FILE: pc-bios/vof/bootmem.c:6:
+^Iphandle chosen = ci_finddevice("/chosen");$
ERROR: code indent should never use tabs
#1517: FILE: pc-bios/vof/bootmem.c:8:
+^Iif (ci_getprop(chosen, "qemu,boot-kernel", kern, sizeof(kern)) !=$
ERROR: code indent should never use tabs
#1518: FILE: pc-bios/vof/bootmem.c:9:
+^I^I^Isizeof(kern))$
ERROR: code indent should never use tabs
#1519: FILE: pc-bios/vof/bootmem.c:10:
+^I^Ireturn;$
ERROR: code indent should never use tabs
#1521: FILE: pc-bios/vof/bootmem.c:12:
+^Ido_boot(kern[0], initrd, initrdsize);$
ERROR: externs should be avoided in .c files
#1540: FILE: pc-bios/vof/ci.c:12:
+extern uint32_t ci_entry(uint32_t params);
ERROR: externs should be avoided in .c files #1542: FILE: pc-bios/vof/ci.c:14:
+extern unsigned long hv_rtas(unsigned long params);
ERROR: externs should be avoided in .c files
#1543: FILE: pc-bios/vof/ci.c:15:
+extern unsigned int hv_rtas_size;
ERROR: code indent should never use tabs
#1547: FILE: pc-bios/vof/ci.c:19:
+^Ivoid *rtasbase;$
ERROR: code indent should never use tabs
#1548: FILE: pc-bios/vof/ci.c:20:
+^Iuint32_t rtassize = 0;$
ERROR: code indent should never use tabs
#1549: FILE: pc-bios/vof/ci.c:21:
+^Iphandle rtas;$
ERROR: code indent should never use tabs
#1551: FILE: pc-bios/vof/ci.c:23:
+^Iif (strcmp("call-method", (void *)(unsigned long) pargs->service))$
ERROR: braces {} are necessary for all arms of this statement #1551: FILE: pc-bios/vof/ci.c:23:
+ if (strcmp("call-method", (void *)(unsigned long) pargs->service))
[...]
ERROR: code indent should never use tabs
#1552: FILE: pc-bios/vof/ci.c:24:
+^I^Ireturn false;$
ERROR: code indent should never use tabs
#1554: FILE: pc-bios/vof/ci.c:26:
+^Iif (strcmp("instantiate-rtas", (void *)(unsigned long) pargs->args[0]))$
ERROR: braces {} are necessary for all arms of this statement #1554: FILE: pc-bios/vof/ci.c:26:
+ if (strcmp("instantiate-rtas", (void *)(unsigned long) pargs->args[0]))
[...]
ERROR: code indent should never use tabs
#1555: FILE: pc-bios/vof/ci.c:27:
+^I^Ireturn false;$
ERROR: code indent should never use tabs
#1557: FILE: pc-bios/vof/ci.c:29:
+^Irtas = ci_finddevice("/rtas");$
ERROR: code indent should never use tabs
#1558: FILE: pc-bios/vof/ci.c:30:
+^Ici_getprop(rtas, "rtas-size", &rtassize, sizeof(rtassize));$
ERROR: code indent should never use tabs
#1559: FILE: pc-bios/vof/ci.c:31:
+^Iif (rtassize < hv_rtas_size)$
ERROR: braces {} are necessary for all arms of this statement #1559: FILE: pc-bios/vof/ci.c:31:
+ if (rtassize < hv_rtas_size)
[...]
ERROR: code indent should never use tabs
#1560: FILE: pc-bios/vof/ci.c:32:
+^I^Ireturn false;$
ERROR: code indent should never use tabs #1562: FILE: pc-bios/vof/ci.c:34:
+^Irtasbase = (void *)(unsigned long) pargs->args[2];$
ERROR: code indent should never use tabs
#1564: FILE: pc-bios/vof/ci.c:36:
+^Imemcpy(rtasbase, hv_rtas, hv_rtas_size);$
ERROR: code indent should never use tabs
#1565: FILE: pc-bios/vof/ci.c:37:
+^Ipargs->args[pargs->nargs] = 0;$
ERROR: code indent should never use tabs #1566: FILE: pc-bios/vof/ci.c:38:
+^Ipargs->args[pargs->nargs + 1] = pargs->args[2];$
ERROR: code indent should never use tabs
#1568: FILE: pc-bios/vof/ci.c:40:
+^Ireturn true;$
ERROR: code indent should never use tabs #1573: FILE: pc-bios/vof/ci.c:45:
+^Iif (!prom_handle((void *)(unsigned long) args))$
ERROR: braces {} are necessary for all arms of this statement #1573: FILE: pc-bios/vof/ci.c:45:
+ if (!prom_handle((void *)(unsigned long) args))
[...]
ERROR: code indent should never use tabs
#1574: FILE: pc-bios/vof/ci.c:46:
+^I^Ici_entry(args);$
ERROR: braces {} are necessary for all arms of this statement #1588: FILE: pc-bios/vof/ci.c:60:
+ for (i = 0; i < nargs; i++)
[...]
ERROR: braces {} are necessary for all arms of this statement #1592: FILE: pc-bios/vof/ci.c:64:
+ for (i = 0; i < nret; i++)
[...]
ERROR: spaces required around that '+' (ctx:VxV)
#1593: FILE: pc-bios/vof/ci.c:65:
+ args.args[nargs+i] = 0;
^ERROR: braces {} are necessary for all arms of this statement #1595: FILE: pc-bios/vof/ci.c:67:
+ if (ci_entry((uint32_t)(&args)) < 0)
[...]
ERROR: code indent should never use tabs
#1603: FILE: pc-bios/vof/ci.c:75:
+^Icall_prom("exit", 0, 0);$
ERROR: code indent should never use tabs
#1608: FILE: pc-bios/vof/ci.c:80:
+^Ireturn call_prom("finddevice", 1, 1, path);$
ERROR: code indent should never use tabs
#1613: FILE: pc-bios/vof/ci.c:85:
+^Ireturn call_prom("getprop", 4, 1, ph, propname, prop, len);$
ERROR: code indent should never use tabs
#1618: FILE: pc-bios/vof/ci.c:90:
+^Ireturn call_prom("open", 1, 1, path);$
ERROR: code indent should never use tabs
#1623: FILE: pc-bios/vof/ci.c:95:
+^Icall_prom("close", 1, 0, ih);$
ERROR: code indent should never use tabs
#1628: FILE: pc-bios/vof/ci.c:100:
+^Iuint32_t ret = call_prom("claim", 3, 1, ADDR(virt), size, align);$
ERROR: code indent should never use tabs
#1630: FILE: pc-bios/vof/ci.c:102:
+^Ireturn (void *) (unsigned long) ret;$
ERROR: code indent should never use tabs
#1635: FILE: pc-bios/vof/ci.c:107:
+^Ireturn call_prom("release", 2, 1, ADDR(virt), size);$
ERROR: code indent should never use tabs
#1758: FILE: pc-bios/vof/libc.c:5:
+^Iint len = 0;$
ERROR: code indent should never use tabs
#1760: FILE: pc-bios/vof/libc.c:7:
+^Iwhile (*s != 0) {$
ERROR: code indent should never use tabs
#1761: FILE: pc-bios/vof/libc.c:8:
+^I^Ilen += 1;$
ERROR: code indent should never use tabs
#1762: FILE: pc-bios/vof/libc.c:9:
+^I^Is += 1;$
ERROR: code indent should never use tabs
#1763: FILE: pc-bios/vof/libc.c:10:
+^I}$
ERROR: code indent should never use tabs
#1765: FILE: pc-bios/vof/libc.c:12:
+^Ireturn len;$
ERROR: braces {} are necessary for all arms of this statement #1771: FILE: pc-bios/vof/libc.c:18:
+ if (*s1 != *s2)
[...]
ERROR: braces {} are necessary for all arms of this statement #1799: FILE: pc-bios/vof/libc.c:46:
+ if (*p1 != *p2)
[...]
ERROR: return is not a function, parentheses are not required #1800: FILE: pc-bios/vof/libc.c:47:
+ return (*p1 - *p2);
ERROR: else should follow close brace '}'
#1823: FILE: pc-bios/vof/libc.c:70:
+ }
+ else {
ERROR: code indent should never use tabs #1856: FILE: pc-bios/vof/main.c:6:
+^Iregister unsigned long r3 __asm__("r3") = _r3;$
ERROR: code indent should never use tabs #1857: FILE: pc-bios/vof/main.c:7:
+^Iregister unsigned long r4 __asm__("r4") = _r4;$
ERROR: code indent should never use tabs
#1858: FILE: pc-bios/vof/main.c:8:
+^Iregister unsigned long r5 __asm__("r5") = (unsigned long) _prom_entry;$
ERROR: code indent should never use tabs
#1860: FILE: pc-bios/vof/main.c:10:
+^I((client *)(uint32_t)addr)();$
ERROR: code indent should never use tabs
#1865: FILE: pc-bios/vof/main.c:15:
+^Iregister unsigned long r3 __asm__("r3");$
ERROR: code indent should never use tabs
#1866: FILE: pc-bios/vof/main.c:16:
+^Iregister unsigned long r4 __asm__("r4");$
ERROR: code indent should never use tabs
#1867: FILE: pc-bios/vof/main.c:17:
+^Iregister unsigned long r5 __asm__("r5");$
ERROR: code indent should never use tabs
#1868: FILE: pc-bios/vof/main.c:18:
+^Iuint64_t initrd = r3, initrdsize = r4;$
ERROR: code indent should never use tabs
#1870: FILE: pc-bios/vof/main.c:20:
+^Iboot_from_memory(initrd, initrdsize);$
ERROR: code indent should never use tabs
#1871: FILE: pc-bios/vof/main.c:21:
+^Ici_panic("*** No boot target ***\n");$
total: 63 errors, 3 warnings, 1743 lines checked
Commit 453ef2bd01c6 (spapr: Implement Open Firmware client interface) has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 84 lines · On Fri, 18 Dec 2020 13:50:40 +1100 Alexey Kardashevskiy <[email protected]> wrote:
The PAPR platform which describes an OS environment that's presented by a combination of a hypervisor and firmware. The features it specifies require collaboration between the firmware and the hypervisor.
Since the beginning, the runtime component of the firmware (RTAS) has been implemented as a 20 byte shim which simply forwards it to a hypercall implemented in qemu. The boot time firmware component is SLOF - but a build that's specific to qemu, and has always needed to be updated in sync with it. Even though we've managed to limit the amount of runtime communication we need between qemu and SLOF, there's some, and it has become increasingly awkward to handle as we've implemented new features.
This implements a boot time OF client interface (CI) which is enabled by a new "x-vof" pseries machine option (stands for "Virtual Open Firmware). When enabled, QEMU implements the custom
H_OF_CLIENThcall which implements Open Firmware Client Interface (OF CI). This allows using a smaller stateless firmware which does not have to manage the device tree.The new "vof.bin" firmware image is included with source code under pc-bios/. It also includes RTAS blob.
This implements a handful of CI methods just to get -kernel/-initrd working. In particular, this implements the device tree fetching and simple memory allocator - "claim" (an OF CI memory allocator) and updates "/memory@0/available" to report the client about available memory.
This implements changing some device tree properties which we know how to deal with, the rest is ignored. To allow changes, this skips
fdt_pack()when x-vof=on as not packing the blob leaves some room for appending.In absence of SLOF, this assigns phandles to device tree nodes to make device tree traversing work.
When x-vof=on, this adds "/chosen" every time QEMU (re)builds a tree.
This adds basic instances support which are managed by a hash map ihandle -> [phandle].
Before the guest started, the used memory is:
0..4000 - the initial firmware
10000..180000 - stackThis OF CI does not implement "interpret".
Unlike SLOF, this does not format uninitialized nvram. Instead, this includes a disk image with pre-formatted nvram.
With this basic support, this can only boot into kernel directly. However this is just enough for the petitboot kernel and initradmdisk to boot from any possible source. Note this requires reasonably recent guest kernel with:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=df5be5be8735Signed-off-by Alexey Kardashevskiy <[email protected]>---
The example command line is:
(quoted diff) +0
-22-c 0 /home/aik/pbuild/qemu-killslof-localhost-ppc64/qemu-system-ppc64 \ -nodefaults \ -chardev stdio,id=STDIO0,signal=off,mux=on \ -device spapr-vty,id=svty0,reg=0x71000110,chardev=STDIO0 \ -mon id=MON0,chardev=STDIO0,mode=readline \ -nographic \ -vga none \ -enable-kvm \ -m 2G \ -machine pseries,x-vof=on,cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken,cap-ccf-assist=off \ -kernel pbuild/kernel-le-guest/vmlinux \ -initrd t/le.cpio \ -drive id=DRIVE0,if=none,file=./p/qemu-killslof/pc-bios/vof/nvram.bin,format=raw \ -global spapr-nvram.drive=DRIVE0 \ -snapshot \ -smp 8,threads=8 \ -L /home/aik/t/qemu-ppc64-bios/ \ -trace events=qemu_trace_events \ -d guest_errors \ -chardev socket,id=SOCKET0,server,nowait,path=qemu.mon.tmux26 \ -mon chardev=SOCKET0,mode=control ---
Quoted 4 lines
Changes:
v12:
* split VOF and SPAPR
Thanks for the split. The VOF paths are now clearly identified in the sPAPR code, and well guarded by a check on x-vof. Rest of the patch looks good to me. I gave it a try with a stock fedora 33 kernel and initramfs and it booted really fast !
With the checkpatch complaints addressed,
and
Quoted 97 lines · Greg Kurz
Quoted 84 lines · On Fri, 18 Dec 2020 13:50:40 +1100 Alexey Kardashevskiy <[email protected]> wrote:
The PAPR platform which describes an OS environment that's presented by a combination of a hypervisor and firmware. The features it specifies require collaboration between the firmware and the hypervisor.
Since the beginning, the runtime component of the firmware (RTAS) has been implemented as a 20 byte shim which simply forwards it to a hypercall implemented in qemu. The boot time firmware component is SLOF - but a build that's specific to qemu, and has always needed to be updated in sync with it. Even though we've managed to limit the amount of runtime communication we need between qemu and SLOF, there's some, and it has become increasingly awkward to handle as we've implemented new features.
This implements a boot time OF client interface (CI) which is enabled by a new "x-vof" pseries machine option (stands for "Virtual Open Firmware). When enabled, QEMU implements the custom
H_OF_CLIENThcall which implements Open Firmware Client Interface (OF CI). This allows using a smaller stateless firmware which does not have to manage the device tree.The new "vof.bin" firmware image is included with source code under pc-bios/. It also includes RTAS blob.
This implements a handful of CI methods just to get -kernel/-initrd working. In particular, this implements the device tree fetching and simple memory allocator - "claim" (an OF CI memory allocator) and updates "/memory@0/available" to report the client about available memory.
This implements changing some device tree properties which we know how to deal with, the rest is ignored. To allow changes, this skips
fdt_pack()when x-vof=on as not packing the blob leaves some room for appending.In absence of SLOF, this assigns phandles to device tree nodes to make device tree traversing work.
When x-vof=on, this adds "/chosen" every time QEMU (re)builds a tree.
This adds basic instances support which are managed by a hash map ihandle -> [phandle].
Before the guest started, the used memory is:
0..4000 - the initial firmware
10000..180000 - stackThis OF CI does not implement "interpret".
Unlike SLOF, this does not format uninitialized nvram. Instead, this includes a disk image with pre-formatted nvram.
With this basic support, this can only boot into kernel directly. However this is just enough for the petitboot kernel and initradmdisk to boot from any possible source. Note this requires reasonably recent guest kernel with:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=df5be5be8735Signed-off-by Alexey Kardashevskiy <[email protected]>---
The example command line is:
(quoted diff) +0
-22-c 0 /home/aik/pbuild/qemu-killslof-localhost-ppc64/qemu-system-ppc64 \ -nodefaults \ -chardev stdio,id=STDIO0,signal=off,mux=on \ -device spapr-vty,id=svty0,reg=0x71000110,chardev=STDIO0 \ -mon id=MON0,chardev=STDIO0,mode=readline \ -nographic \ -vga none \ -enable-kvm \ -m 2G \ -machine pseries,x-vof=on,cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken,cap-ccf-assist=off \ -kernel pbuild/kernel-le-guest/vmlinux \ -initrd t/le.cpio \ -drive id=DRIVE0,if=none,file=./p/qemu-killslof/pc-bios/vof/nvram.bin,format=raw \ -global spapr-nvram.drive=DRIVE0 \ -snapshot \ -smp 8,threads=8 \ -L /home/aik/t/qemu-ppc64-bios/ \ -trace events=qemu_trace_events \ -d guest_errors \ -chardev socket,id=SOCKET0,server,nowait,path=qemu.mon.tmux26 \ -mon chardev=SOCKET0,mode=control ---Quoted 4 lines
Changes:
v12:
* split VOF and SPAPRThanks for the split. The VOF paths are now clearly identified in the sPAPR code, and well guarded by a check on x-vof. Rest of the patch looks good to me. I gave it a try with a stock fedora 33 kernel and initramfs and it booted really fast !
Quoted 1 line
With the checkpatch complaints addressed,
They all are about the firmware, not QEMU ifself, do we enforce it for such things as firmwares too?
Quoted 6 lines
Acked-by Greg Kurz <[email protected]>and
Tested-by Greg Kurz <[email protected]>
Thanks! Now I am thinking whether someone may want to use it for something else, like... dunno... ARM? :)
Signature · 1 line
Alexey
On Mon, 21 Dec 2020 23:06:40 +1100
Alexey Kardashevskiy <[email protected]> wrote:
[...]
Quoted 11 lines
Quoted 6 lines
Thanks for the split. The VOF paths are now clearly identified in the sPAPR code, and well guarded by a check on x-vof. Rest of the patch looks good to me. I gave it a try with a stock fedora 33 kernel and initramfs and it booted really fast !
With the checkpatch complaints addressed,
They all are about the firmware, not QEMU ifself, do we enforce it for such things as firmwares too?
Well, apparently checkpatch does :)
More seriously, this code is being added to the QEMU source tree, not like it is some foreign code imported as a git submodule, so I don't see why regular QEMU coding style guidelines wouldn't apply ?
Quoted 4 lines
Quoted 4 lines
Acked-by Greg Kurz <[email protected]>
Quoted 9 lines
Quoted 3 lines
and
Tested-by Greg Kurz <[email protected]>Thanks! Now I am thinking whether someone may want to use it for something else, like... dunno... ARM? :)
Well, Zoltan seemed to have some interest in using VOF for presumably other PowerPC based boards IIUC.
Another future work could be to add enough support to be able to start grub and boot from a virtio device. :)
Cheers,
--
Greg