aboutsummaryrefslogtreecommitdiff
path: root/lib/libhvcall
AgeCommit message (Collapse)AuthorFilesLines
2021-02-12libhv: Compile with -WextraAlexey Kardashevskiy1-1/+1
-Wextra enables a bunch of rather useful checks which this fixes. Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2020-03-17rtas: Move FWNMI log space reservation to QEMUAlexey Kardashevskiy1-9/+0
This reverts commit 674d0d0cf66d4 ("rtas: Reserve space for FWNMI log") which expanded the RTAS blob size to match the QEMU expectation about the RTAS area available for FWNMI logs. Instead, it relies on QEMU passing the "rtas-size" property and passes it through untouched. This adds a check that QEMU allocated enough for RTAS blob. This adds a fallback to the default 20 bytes "rtas-size" if none specified by QEMU. While we are here, replace 's" /rtas" find-node' with 'rtas-node' which we just set above. Reviewed-by: Greg Kurz <groug@kaod.org> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2019-08-27rtas: Reserve space for FWNMI logAlexey Kardashevskiy1-0/+9
The Firmware Assisted Non-Maskable Interrupts Option (FWNMI) feature requires some space for RTAS log which is in the RTAS blob area. This expands the RTAS blob size to 2k. More details here: https://patchwork.ozlabs.org/patch/1146765/ Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2019-07-18rtas: Integrate RTAS blobAlexey Kardashevskiy5-1/+42
We implement RTAS as a simple binary blob which calls directly into QEMU via a custom hcall. So far we were relying on QEMU putting the RTAS blob to the guest memory with its location in linux,rtas-base/rtas-size. The problems with this are: 1. we need to peek a location in the guest ram in addition to slof, FDT and sometime kernel and init ram disk; having one less image makes QEMU's life easier. 2. for secure VMs, it is yet another image which needs to be signed and verified. This implements "instantiate-rtas" completely in SLOF, including KVM PR support ("broken sc1"). Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
2018-04-04broken_sc1: check for H_PRIVILEGENikunj A Dadhania2-5/+6
Recently, found that when DAWR was disabled by linux kernel, the hcall started returning H_UNSUPPORTED, and VM did not boot up as broken_sc1 patched up SC calls falsely. Instead of checking for various returns, check if its not in privilege mode and patch sc1 in that case. CC: Michael Ellerman <michael@ellerman.id.au> CC: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2017-11-06fdt: Pass the resulting device tree to QEMUAlexey Kardashevskiy3-1/+8
This creates flatten device tree and passes it to QEMU via a custom hypercall right before jumping to RTAS. This preloads strings with 40 property names from CPU and PCI device nodes and the strings lookup only searches within these. Test results on a guest with 256 CPUs and 256 virtual Intel E1000 devices running on a POWER8 box: FDTsize=366024 Strings=15888 Struct=350080 Reused str=12457 242 ms A simple guest (one CPU, no PCI) with this patch as is: FDTsize=15940 Strings=3148 Struct=12736 Reused str=84 7 ms While we are here, fix the version handling in fdt-init. It only matters a little for the fdt-debug==1 case though. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> --- Changes: v6: * fix memory sizes for free-mem * store correct chosen-cpu to the header (used to be just 0) * fdt-skip-string uses zcount now and works 30% faster * moved to a new file - fdt-fl.fs v5: * applied latest comments from Segher * s/fdt-property/fdt-copy-property/, s/fdt-properties/fdt-copy-properties/ * reduced the temporary buffers to 1MB each as the guest uses 1MB in total anyway * do not pass root phandle to fdt-flatten-tree, it fetches it from device-tree itself * reworked fdt-copy-properties to use for-all-words proposed by Segher v4: * reworked fdt-properties, works lot faster * do not store "name" properties as nodes have names already v3: * fixed stack handling after hcall returned * fixed format versions in both rendering and parsing paths * rebased on top of removed unused hvcalls * renamed used variables to have fdtfl- prefixes as there are already some for parsing the initial dt v2: * fixed comments from review * added strings cache * changed last_compat_vers from 0x17 to 0x16 as suggested by dwg --- I tested the blob by storing it from QEMU to a file and decompiling it.
2017-10-24Revert various SLOF-to-QEMU private hypercallsAlexey Kardashevskiy3-17/+1
This reverts commits: 604d28cc3 "board-qemu: add private hcall to inform host on "phandle" update" 089fc18a9 "libhvcall: drop unused KVMPPC_H_REPORT_MC_ERR and KVMPPC_H_NMI_MCE defines" 1c17c13a5 "rtas: Improve error handling in instantiate-rtas" f9a60de30 "Add private HCALL to inform updated RTAS base and entry" A bigger hammer is coming soon which will pass the entire device tree to QEMU, not just some random bits. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Greg Kurz <groug@kaod.org>
2017-07-25board-qemu: add private hcall to inform host on "phandle" updateGreg Kurz3-0/+9
The "interrupt-map" property in each PHB node references the "phandle" property of the "interrupt-controller" node. This is used by the guest OS to setup IRQs for any PCI device plugged into the PHB. QEMU sets this property to an arbitrary value in the flattened DT passed to SLOF. Since commit 82954d4c1088, SLOF has some generic code to convert all references to any "phandle" property to a SLOF specific value. This is is perfectly okay for coldplug devices, since the guest OS only sees the converted value in "interrupt-map". It is a problem though for hotplug devices. Since they don't go through SLOF, the guest OS receives the arbitrary value set by QEMU and fails to setup IRQs. In order to support PHB hotplug, this patch introduces a new private hcall, which allows SLOF to tell QEMU that a "phandle" was converted from an old value to a new value. Suggested-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Greg Kurz <groug@kaod.org> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2017-07-11libhvcall: drop unused KVMPPC_H_REPORT_MC_ERR and KVMPPC_H_NMI_MCE definesGreg Kurz1-2/+0
These defines were introduced to add support for FWNMI in KVM guests. This has been WIP since 2015 and the KVM part finally made it to kvm-ppc-next. Latest work on the QEMU side [1] no longer needs KVMPPC_H_REPORT_MC_ERR. The KVMPPC_HCALL_MAX define is never used anywhere, and moreover it is bogus since there's no KVMPPC_H_NMI_MCE private hcall. [1] http://lists.nongnu.org/archive/html/qemu-ppc/2015-12/msg00199.html Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-01Move the code for rfill into a separate functionThomas Huth2-1/+39
The code from the FAST_RFILL macro uses a local array as a temporary buffer - which gets allocated in the stack frame of the engine() function. Since engine() can be called recursively, this can cause stack overflows. So let's move the rfill code into a separate function to avoid these problems. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-03-23Include make.rules in the library MakefilesThomas Huth1-0/+2
Make sure to include make.rules from the Makefiles in the common lib folder to get some more sane console output during the build process. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2014-08-27Add private HCALL to inform updated RTAS base and entryNikunj A. Dadhania3-1/+10
This patch adds a private HCALL to inform qemu the updated rtas-base and rtas-entry address when OS invokes the call "instantiate-rtas". This is required as qemu allocates the error reporting structure in RTAS space upon a machine check exception and hence needs to know the updated RTAS. Enhancements to qemu to handle the private HCALL, prepare error log and invoke machine check notification routine are in a separate patch. Signed-off-by: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Aravinda Prasad <aravinda@linux.vnet.ibm.com> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-04-04Isolate sc 1 detection logicAlexander Graf1-28/+28
Under weird circumstances we ended up with unsynchronized data and text section references between the stage1 and paflof binaries. This patch moves the initial sc 1 detection logic to work without any persistent state, making it properly reentrant regardless of the place we end up hitting the code at. This fixes broken sc 1 detection for me on PR KVM. Signed-off-by: Alexander Graf <agraf@suse.de> [aik: added r0 to clobber list and $(FLAG) to AS1FLAGS as suggested by agraf, tested on pHyp] Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2013-12-17Work around missing sc 1 traps on pHypAlexander Graf5-1/+174
When running a pseries guest in PR KVM on top of pHyp, sc 1 instructions are handled directly by pHyp, so we don't get to see them. That means we need to get inventive. Invent a new instruction that behaves like sc 1, but really is a reserved instruction that traps. This instruction can be used by KVM to emulate sc 1 behavior. This patch adds the SLOF support for it. With this, SLOF detects whether it's running on such a broken setup and if so patches itself to execute the fake sc 1 instruction instead of the real one. Furthermore, we also hook into "quiesce" which Linux calls when it boots. This gives us the chance to also patch Linux when it boots up, so it uses the fake sc 1 too. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-12-16Output banner and initial display output in VNC windowNikunj A Dadhania4-2/+17
Initial display output does not show up in the VGA/VNC window. Create replay buffer to store the initial output and when vga/vnc console starts, dump the buffer there. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-10-09Add ibm,client-architecture-support methodNikunj A Dadhania4-1/+23
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2012-10-17SLOF: Support PAPR NVRAM RTAS callsqemu-slof-20121018Nikunj A. Dadhania1-0/+14
BenH still need to ACK this though. From: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com> * Determines size of the flash using device tree. * Provides nvram access functions for RTAS_NVRAM * Allocates temporary buffer of nvram in SLOF code and use that in C. (sbrk not available) * NVRAM_LENGTH is used at various places, make sure it is well guarded and also use dynamically determined size once an RTAS-NVRAM is found. * Use NVRAM_LENGTH as a variable in case of RTAS_NVRAM, not very elegant though Signed-off-by: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com> -- Changelog from v1: * #define cleanups suggested by Thomas/Benh * Fix makefile which missed passing $FLAG for building llfw * renamed vio-nvram.fs as rtas-nvram.fs
2012-02-22Expose hv-logical-memop to forth codeBenjamin Herrenschmidt4-0/+31
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2012-01-19Move virtio to a separate libraryBenjamin Herrenschmidt7-545/+1
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2012-01-11Fix virtio access sizeqemu-slof-20120111Benjamin Herrenschmidt1-5/+11
We don't support 8-bytes PIO Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2011-12-20hvterm: Update hvterm routines to take the termno as an argumentMichael Ellerman3-13/+14
Currently the hvterm routines always use termno=0. This works because QEMU has code that recognies termno=0 and chooses a "default" vty. It would be more correct if the hvterm routines took the termno as an argument. That way if we open a vty other than the default the output will correctly go to that vty. Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
2011-11-24Support for virtio-block PCI devicesThomas Huth7-2/+544
The virtio devices are preferred way of providing virtualized devices on KVM/qemu. Here's now the basic support for virtio block devices. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12Add wrapper for H_PUT_TCE hypervisor callThomas Huth3-0/+10
H_PUT_TCE is needed for getting the DMA transfers working in the virtual environment. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12Improved cache-inhibited access functionsThomas Huth1-2/+2
Implemented the CI functions in cache.h (which are required by net-snk) and fixed a bug in hv_logical_ci_store in libhvcall. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12Move MMIO accessors to board-js2x and implement h-calls based ones for qemuBenjamin Herrenschmidt4-2/+73
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2011-03-22Initial qemu/KVM board supportBenjamin Herrenschmidt5-0/+273
Added a new board for SLOF running on KVM/qemu. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>