spapr: Implement Open Firmware client interface
PATCH v17 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..e60 - the initial firmware
8000..10000 - stack
400000.. - kernel
3ea0000.. - initramdisk
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 immediate benefit is much faster booting time which especially crucial with fully emulated early CPU bring up environments. Also this may come handy when/if GRUB-in-the-userspace sees light of the day.
This separates VOF and sPAPR in a hope that VOF bits may be reused by other POWERPC boards which do not support pSeries.
This is coded in assumption that later on we might be adding support for booting from QEMU backends (blockdev is the first candidate) without devices/drivers in between as OF1275 does not require that and it is quite easy to so.
---
The example command line is:
/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 pb/rootfs.cpio.xz \
-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:
v17:
* mv hw/ppc/vof.h include/hw/ppc/vof.h
* VofMachineIfClass -> VofMachineClass; it is not VofMachineInterface as nobody used this scheme, usually "Interface" is dropped, a couple of times it is "xxxInterfaceClass" or "xxxIfClass", as used the latter as it is used by include/hw/vmstate-if.h
* added SPDX
* other fixes from v16 review
v16:
* rebased on dwg/ppc-for-6.1
* s/SpaprVofInterface/VofMachineInterface/
v15:
* bugfix: claimed memory for the VOF itself
* ditched OF_STACK_ADDR and allocate one instead, now it starts from 0x8000 because it is aligned to its size (no particular reason though)
* coding style
* moved nvram.bin up one level
* ditched bool in the firmware
* made debugging code conditional using trace_event_get_state() + qemu_loglevel_mask()
* renamed the CAS interface to SpaprVofInterface
* added "write" which for now dumps the message and ihandle via
trace point for early debug assistance
* commented on when we allocate of_instances in vof_build_dt()
* store fw_size is SpaprMachine to let spapr_vof_reset() claim it
* many small fixes from v14's review
v14:
* check for truncates in readstr()
* ditched a separate vof_reset()
* spapr->vof is a pointer now, dropped the "on" field
* removed rtas_base from vof and updated comment why we allow setting it
* added myself to maintainers
* updated commit log about blockdev and other possible platforms
* added a note why new hcall is 0x5
* no in place endianness convertion in spapr_h_vof_client
* converted all cpu_physical_memory_read/write to address_space_rw
* git mv hw/ppc/spapr_vof_client.c hw/ppc/spapr_vof.c
v13:
* rebase on latest ppc-for-6.0
* shuffled code around to touch spapr.c less
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 + include/hw/ppc/spapr.h | 17 +- include/hw/ppc/vof.h | 41 ++ pc-bios/vof/vof.h | 43 ++ hw/ppc/spapr.c | 76 +++- hw/ppc/spapr_hcall.c | 26 +- hw/ppc/spapr_vof.c | 153 +++++++ hw/ppc/vof.c | 978 +++++++++++++++++++++++++++++++++++++++++ pc-bios/vof/bootmem.c | 14 + pc-bios/vof/ci.c | 91 ++++ pc-bios/vof/libc.c | 92 ++++ pc-bios/vof/main.c | 21 + MAINTAINERS | 11 + hw/ppc/meson.build | 2 + hw/ppc/trace-events | 24 + pc-bios/README | 2 + pc-bios/vof-nvram.bin | Bin 0 -> 16384 bytes pc-bios/vof.bin | Bin 0 -> 3128 bytes pc-bios/vof/entry.S | 51 +++ pc-bios/vof/l.lds | 48 ++ 20 files changed, 1696 insertions(+), 12 deletions(-) create mode 100644 pc-bios/vof/Makefile create mode 100644 include/hw/ppc/vof.h create mode 100644 pc-bios/vof/vof.h create mode 100644 hw/ppc/spapr_vof.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 100644 pc-bios/vof-nvram.bin create mode 100755 pc-bios/vof.bin create mode 100644 pc-bios/vof/entry.S create mode 100644 pc-bios/vof/l.lds
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 -o $@ $< + +vof.elf: entry.o main.o ci.o bootmem.o libc.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 vof.bin vof.elf *~
include/hw/ppc/spapr.h +16 -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 ;
@@ -180,6 +181,8 @@ struct SpaprMachineState {uint64_t kernel_addr;uint32_t initrd_base;long initrd_size; +long fw_size; +Vof *vof;uint64_t rtc_offset;/* Now used only during incoming migration */ struct PPCTimebase tb;bool has_graphics;
@@ -554,7 +557,9 @@ 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 +/* 0x4 was used for KVMPPC_H_UPDATE_PHANDLE in SLOF */ +#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
@@ -945,4 +950,14 @@ 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 );bool spapr_memory_hot_unplug_supported (SpaprMachineState *spapr); + +void spapr_vof_reset (SpaprMachineState *spapr,void *fdt, +target_ulong *stack_ptr,Error **errp); +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); +void spapr_vof_client_dt_finalize (SpaprMachineState *spapr,void *fdt); +#endif /* HW_SPAPR_H */
include/hw/ppc/vof.h new file +41 -0
41 lines not on this page · raw message
pc-bios/vof/vof.h new file +43 -0
43 lines not on this page · raw message
hw/ppc/spapr.c +66 -10
151 lines not on this page · raw message
hw/ppc/spapr_hcall.c +25 -1
@@ -1806,7 +1806,13 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu,spapr_setup_hpt (spapr); } - fdt =spapr_build_fdt (spapr, false, fdt_bufsize); +if (spapr->vof && 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 !=NULL , fdt_bufsize);g_free (spapr->fdt_blob); spapr->fdt_size =fdt_totalsize (fdt);
@@ -1850,6 +1856,24 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,return ret; } +target_ulong spapr_vof_client_architecture_support (CPUState *cs, +target_ulong ovec_addr) +{ +SpaprMachineState *spapr =SPAPR_MACHINE (qdev_get_machine ()); + +target_ulong ret =do_client_architecture_support (POWERPC_CPU (cs), spapr, + ovec_addr,FDT_MAX_SIZE ); + +/* +* This adds stdout and generates phandles for boottime and CAS FDTs. +* It is alright to update the FDT here as do_client_architecture_support() +* does not pack it. +*/ +spapr_vof_client_dt_finalize (spapr, spapr->fdt_blob); + +return ret; +} + static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu, SpaprMachineState *spapr, target_ulong opcode,
hw/ppc/spapr_vof.c new file +153 -0
153 lines not on this page · raw message
hw/ppc/vof.c new file +978 -0
978 lines not on this page · raw message
pc-bios/vof/bootmem.c new file +14 -0
@@ -0,0 +1,14 @@ +#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 +91 -0
91 lines not on this page · raw message
pc-bios/vof/libc.c new file +92 -0
92 lines not on this page · raw message
pc-bios/vof/main.c new file +21 -0
@@ -0,0 +1,21 @@ +#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" ); +}
MAINTAINERS +11 -0
@@ -1368,6 +1368,17 @@ F: pc-bios/canyonlands.dt[sb] F: pc-bios/u-boot-sam460ex-20100605.bin F: roms/u-boot-sam460ex +Virtual Open Firmware (VOF) +M: Alexey Kardashevskiy <[email protected]> +M: David Gibson <[email protected]> +M: Greg Kurz <[email protected]> +L: [email protected] +S: Maintained +F: hw/ppc/spapr_vof* +F: hw/ppc/vof* +F: pc-bios/vof/* +F: pc-bios/vof* + RISC-V Machines --------------- OpenTitan
hw/ppc/meson.build +2 -0
@@ -28,6 +28,8 @@ ppc_ss.add(when: 'CONFIG_PSERIES', if_true: files( 'spapr_rtas_ddw.c', 'spapr_numa.c', 'pef.c', + 'spapr_vof.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 +24 -0
@@ -71,6 +71,30 @@ 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_error_write(uint32_t ih) "ih=0x%x" +vof_finddevice(const char *path, uint32_t ph) "\"%s\" => ph=0x%x" +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 vallen, uint32_t ret) "ph=0x%x \"%s\" [%s] len=%d => ret=%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" +vof_write(uint32_t ih, unsigned cb, const char *msg) "ih=0x%x [%u] \"%s\"" +vof_avail(uint64_t start, uint64_t end, uint64_t size) "0x%"PRIx64"..0x%"PRIx64" size=%"PRId64 +vof_claimed(uint64_t start, uint64_t end, uint64_t size) "0x%"PRIx64"..0x%"PRIx64" size=%"PRId64 + # 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-20210217. +- 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-nvram.bin new file binary +0 -0
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
Signature · 1 line
2.17.1
Quoted 332 lines · Alexey Kardashevskiy
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..e60 - the initial firmware
8000..10000 - stack
400000.. - kernel
3ea0000.. - initramdiskThis 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=df5be5be8735The immediate benefit is much faster booting time which especially crucial with fully emulated early CPU bring up environments. Also this may come handy when/if GRUB-in-the-userspace sees light of the day.
This separates VOF and sPAPR in a hope that VOF bits may be reused by other POWERPC boards which do not support pSeries.
This is coded in assumption that later on we might be adding support for booting from QEMU backends (blockdev is the first candidate) without devices/drivers in between as OF1275 does not require that and it is quite easy to so.
Signed-off-by Alexey Kardashevskiy <[email protected]>---
The example command line is:
/home/aik/pbuild/qemu-killslof-localhost-ppc64/qemu-system-ppc64\(quoted diff) +0
-21-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 pb/rootfs.cpio.xz \ -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:
v17:
* mvhw/ppc/vof.hinclude/hw/ppc/vof.h
* VofMachineIfClass -> VofMachineClass; it is not VofMachineInterface as nobody used this scheme, usually "Interface" is dropped, a couple of times it is "xxxInterfaceClass" or "xxxIfClass", as used the latter as it is used byinclude/hw/vmstate-if.h
* added SPDX
* other fixes from v16 reviewv16:
* rebased on dwg/ppc-for-6.1
* s/SpaprVofInterface/VofMachineInterface/v15:
* bugfix: claimed memory for the VOF itself
* ditchedOF_STACK_ADDRand allocate one instead, now it starts from0x8000because it is aligned to its size (no particular reason though)
* coding style
* moved nvram.bin up one level
* ditched bool in the firmware
* made debugging code conditional usingtrace_event_get_state()+qemu_loglevel_mask()
* renamed the CAS interface to SpaprVofInterface
* added "write" which for now dumps the message and ihandle via
trace point for early debug assistance
* commented on when we allocateof_instancesinvof_build_dt()
* storefw_sizeis SpaprMachine to letspapr_vof_reset()claim it
* many small fixes from v14's reviewv14:
* check for truncates inreadstr()
* ditched a separatevof_reset()
*spapr->vofis a pointer now, dropped the "on" field
* removedrtas_basefrom vof and updated comment why we allow setting it
* added myself to maintainers
* updated commit log about blockdev and other possible platforms
* added a note why new hcall is0x5
* no in place endianness convertion inspapr_h_vof_client
* converted all cpu_physical_memory_read/write toaddress_space_rw
* git mvhw/ppc/spapr_vof_client.chw/ppc/spapr_vof.cv13:
* rebase on latest ppc-for-6.0
* shuffled code around to touchspapr.clessv12:
* split VOF and SPAPRv11:
* addedg_autofree
* fixed gcc warnings
* fixed few leaks
* added nvram image to make "nvram --print-config" not crash; Note that contrary toMIN_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 mesonv9:
* 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 nowv7:
* now we have a small firmware which loads at 0 as SLOF and starts from0x100as SLOF
* no MBR/ELF/GRUB business in QEMU anymore
* blockdev is a separate patch
* networking is a separate patchv6:
* 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
* disabledtranslate_kernel_address()hack so grub can load (work in progress)
* added "milliseconds" for grub
* fixed "claim" allocator again
* movedFDT_MAX_SIZEtospapr.hasspapr_of_client.cwants it too for CAS
* moved the most code possible fromspapr.ctospapr_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 GRUBv5:
* 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__be32type 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 insteadv2:
* fixedclaim()
* 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 + include/hw/ppc/spapr.h | 17 +- include/hw/ppc/vof.h | 41 ++ pc-bios/vof/vof.h | 43 ++ hw/ppc/spapr.c | 76 +++- hw/ppc/spapr_hcall.c | 26 +- hw/ppc/spapr_vof.c | 153 +++++++ hw/ppc/vof.c | 978 +++++++++++++++++++++++++++++++++++++++++ pc-bios/vof/bootmem.c | 14 + pc-bios/vof/ci.c | 91 ++++ pc-bios/vof/libc.c | 92 ++++ pc-bios/vof/main.c | 21 + MAINTAINERS | 11 + hw/ppc/meson.build | 2 + hw/ppc/trace-events | 24 + pc-bios/README | 2 + pc-bios/vof-nvram.bin | Bin 0 -> 16384 bytes pc-bios/vof.bin | Bin 0 -> 3128 bytes pc-bios/vof/entry.S | 51 +++ pc-bios/vof/l.lds | 48 ++ 20 files changed, 1696 insertions(+), 12 deletions(-)create mode 100644 pc-bios/vof/Makefile
create mode 100644include/hw/ppc/vof.h
create mode 100644pc-bios/vof/vof.h
create mode 100644hw/ppc/spapr_vof.c
create mode 100644hw/ppc/vof.c
create mode 100644pc-bios/vof/bootmem.c
create mode 100644pc-bios/vof/ci.c
create mode 100644pc-bios/vof/libc.c
create mode 100644pc-bios/vof/main.c
create mode 100644 pc-bios/vof-nvram.bin
create mode 100755 pc-bios/vof.bin
create mode 100644pc-bios/vof/entry.S
create mode 100644pc-bios/vof/l.ldspc-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 -o $@ $< + +vof.elf: entry.o main.o ci.o bootmem.o libc.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 vof.bin vof.elf *~include/hw/ppc/spapr.h +16
-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 ;@@ -180,6 +181,8 @@ struct SpaprMachineState {uint64_t kernel_addr;uint32_t initrd_base;long initrd_size; +long fw_size; +Vof *vof;uint64_t rtc_offset;/* Now used only during incoming migration */ struct PPCTimebase tb;bool has_graphics;@@ -554,7 +557,9 @@ 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 +/* 0x4 was used for KVMPPC_H_UPDATE_PHANDLE in SLOF */ +#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 @@ -945,4 +950,14 @@ 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 );bool spapr_memory_hot_unplug_supported (SpaprMachineState *spapr); + +void spapr_vof_reset (SpaprMachineState *spapr,void *fdt, +target_ulong *stack_ptr,Error **errp); +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); +void spapr_vof_client_dt_finalize (SpaprMachineState *spapr,void *fdt); +#endif /* HW_SPAPR_H */ include/hw/ppc/vof.h new file +0
-0
include/hw/ppc/vof.h line 10
Quoted 10 lines
include/hw/ppc/vof.h new file +10
-0@@ -0,0 +1,41 @@ +/* +* Virtual Open Firmware +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef HW_VOF_H +#define HW_VOF_H + +typedef struct Vof { + uint32_t top_addr; /* copied from rma_size */
Uff, found a bug here - when -m8G, spapr->rma_size is 0x2.0000.0000 on radix but because of uint32_t it becomes 0 and things break so another respin is coming in a day or two.
Signature · 1 line
Alexey