Alexey Kardashevskiy [Tue, 19 Jul 2022 04:19:29 +0000 (14:19 +1000)]
version: update to
20220719
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Jordan Niethe [Tue, 12 Jul 2022 00:46:24 +0000 (10:46 +1000)]
OF: Add a separate direct kernel loading word
Currently, go-64 is used for booting a kernel from qemu (i.e. -kernel).
However, there is an expectation from users that this should be able to
boot not just vmlinux kernels but things like Zimages too.
The bootwrapper of a BE zImage is a 32-bit ELF. Attempting to load that
with go-64 means that it will be ran with MSR_SF set (64-bit mode). This
crashes early in boot (usually due to what should be 32-bit operations
being done with 64-bit registers eventually leading to an incorrect
address being generated and branched to).
Note that our 64-bit payloads are prepared to enter with MSR_SF cleared
and set it themselves very early.
Add a new word named go-direct that will execute any simple payload
in-place and will enter with MSR_SF cleared. This allows booting a BE
zImage from qemu with -machine kernel-addr=0.
Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Mon, 10 Jan 2022 03:55:53 +0000 (14:55 +1100)]
version: update to
20220110
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Cédric Le Goater [Wed, 5 Jan 2022 16:22:38 +0000 (17:22 +0100)]
make.rules: Compile SLOF for power5
By default, SLOF would implement the cpu_to_le64() helper with
the 'stdbrx' instruction which is invalid under POWER5+ and 970
CPUs. This breaks the QEMU pseries machine with such CPUs when
virtio or USB devices or in use.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Fri, 12 Nov 2021 07:12:57 +0000 (18:12 +1100)]
version: update to
20211112
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Thomas Huth [Fri, 1 Oct 2021 07:10:10 +0000 (09:10 +0200)]
Silence some trivial compiler warning in the js2x code
We enabled additional compiler warnings in commit
26d8ba170355c9, but
so far we did not address the additional warnings in the js2x code
yet. This patch fixes at least some of the trivial warnings there.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Thu, 30 Sep 2021 06:48:14 +0000 (16:48 +1000)]
js2x: Fix compile and cleanup
This moves shared symbols out from the header file and leaves only
the minimum in bmc.h.
This fixes a "while (...); {" bug spotted by the modern gcc.
This fixes cleanup as otherwise the board-js2x/Makefile's "clean" tries
cleaning "rtas" which tries cleaning all libs (not just the ones it uses)
and that in turn triggers generation of lib/libtpm/Makefile.dep which
fails due to missing ./board-js2x/include/version.h.
This fixes create_reloc_table.sh to build with newer toolchains which
otherwise fail with:
ld: cannot use executable file 'reloc_table.o' as input to a link
This adds js2x compile to the travis script to know when it breaks
again.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Thomas Huth [Tue, 31 Aug 2021 09:33:44 +0000 (11:33 +0200)]
travis.yml: Compile-test the qemu build
Since we're already using Travis for some testing, we should also
compile-test the sources with the pre-installed Advanced Toolchain
compiler there.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Thomas Huth [Tue, 31 Aug 2021 09:33:43 +0000 (11:33 +0200)]
travis.yml: Update to Focal Fossa
It's better to use a newer version of the compiler which might catch
more issues in the code.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Thomas Huth [Tue, 31 Aug 2021 09:33:42 +0000 (11:33 +0200)]
travis.yml: Fix keywords
All the documentation on travis-ci.com talks about "jobs:" instead of
"matrix:" these days, so let's also use this keywords now. Also fix
a typo in "inlcude" - it's weird that Travis did not complain about
this, but it's certainly better to have this fixed.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Fri, 17 Sep 2021 17:38:05 +0000 (13:38 -0400)]
tcgbios: Disable platform hierarchy in case of failure
In the rare case of a TPM 2 failure, disable the platform hierarchy after
disabling the endorsement and owner hierarchies.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Thomas Huth [Wed, 8 Sep 2021 12:52:41 +0000 (14:52 +0200)]
lib/libc/README.txt: Fix "cannel" typo
It should be "channel" instead of "cannel", obviously.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Thomas Huth [Wed, 1 Sep 2021 07:39:36 +0000 (09:39 +0200)]
Fix the URL to the Linux kernel coding style
It has been moved to a new location in the Linux git repository
quite a while ago already.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Thomas Huth [Mon, 30 Aug 2021 12:13:20 +0000 (14:13 +0200)]
slof/fs/accept: Replace TABs with spaces
SLOF coding style is to use spaces in Forth code, not TABs, and the TAB
in the (accept) function breaks the right indentation in my editor, so
let's replace the TABs in this file with spaces now.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Thomas Huth [Wed, 1 Sep 2021 09:16:41 +0000 (11:16 +0200)]
Mention the CR vs. LF problem in the documentation
Let's hope that this will help to avoid that people run into the same
problem again in the future. At least we've got some lines of documentation
this way where we can point people to who try to use "nc" in the wrong way.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Thu, 30 Sep 2021 06:37:42 +0000 (16:37 +1000)]
Revert "make: Define default rule for .c when V=1 or V=2"
This reverts commit
283d88c46c1d4d2ae65f0a3eaf582d0c124d37db as:
- it wrongly assumes the default V=0 (V=1 is the default);
- the new rule broke js2x;
- does not really solve the original problem of printing partial
filenames in gcc error messages.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Sun, 11 Jul 2021 13:50:05 +0000 (23:50 +1000)]
version: update to
20210711
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Fri, 9 Jul 2021 15:39:03 +0000 (11:39 -0400)]
Travis: Add script for running tests on Travis
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Fri, 9 Jul 2021 15:39:02 +0000 (11:39 -0400)]
tcgbios: Add test cases and test script to run them
Add test cases for sha1, sha256, sha384, and sha512 and a test script
to run the test cases.
The tests are passing on little and big endian machines (Fedora 28).
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Fri, 9 Jul 2021 15:39:01 +0000 (11:39 -0400)]
tcgbios: Use The proper sha function for each PCR bank
Instead of just using sha256 for all PCR banks (and truncating
the value or zero-padding it) use the proper hash function for
each one of the banks. For unimplemented hashes, fill the buffer
with 0xff.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Fri, 9 Jul 2021 15:39:00 +0000 (11:39 -0400)]
tcgbios: Use assembly for 32 bit rotr in sha256
Use assembly for the 32 bit rotr in the sha256 implementation
similar to the assembly used in the sha1 and sha512 implementations.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Fri, 9 Jul 2021 15:38:59 +0000 (11:38 -0400)]
tcgbios: Change format of S_CRTM_VERSION string to ucs-2
Change the format of the S_CRTM_VERSION string to ucs-2 since this
is what seems to be commonly used by other firmwares following
insight from a TCG work group member.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Tested-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Thu, 8 Jul 2021 21:36:55 +0000 (17:36 -0400)]
tpm: Add firmware API call 2HASH-EXT-LOG
Add a new firmware API call with the name 2HASH-EXT-LOG that will be used
by trusted grub for measuring, logging, and extending TPM PCRs.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Fri, 9 Jul 2021 02:53:10 +0000 (22:53 -0400)]
tcgbios: Add implementations for sha1, sha384, and sha512
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Fri, 9 Jul 2021 02:53:09 +0000 (22:53 -0400)]
tcgbios: Fix a typo in the sha256 algo description
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Wed, 30 Jun 2021 03:01:39 +0000 (13:01 +1000)]
tcgbios: Fix warnings
This fixes gcc warnings from -Waddress-of-packed-member and -Wzero-length-bounds.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Tested-by: Stefan Berger <stefanb@linux.ibm.com>
---
tpm_drivers.c: In function ‘spapr_send_crq_and_wait’:
tpm_drivers.c:153:2: warning: converting a packed ‘struct crq’ pointer (alignment 1) to a ‘uint64_t’ {aka ‘long long unsigned int’} pointer alignment 8) may result in an unaligned pointer value [-Waddress-of-packed-member]
153 | rc = hv_send_crq(unit, (uint64_t *)crq);
| ^~
tpm_drivers.c:34:8: note: defined here
34 | struct crq {
| ^~~
tpm_drivers.c: In function ‘spapr_vtpm_senddata’:
tpm_drivers.c:346:2: warning: converting a packed ‘struct crq’ pointer (alignment 1) to a ‘uint64_t’ {aka ‘long long unsigned int’} pointer (alignment 8) may result in an unaligned pointer value [-Waddress-of-packed-member]
346 | rc = hv_send_crq(spapr_vtpm.unit, (uint64_t *)&crq);
| ^~
tpm_drivers.c:34:8: note: defined here
34 | struct crq {
| ^~~
[CC] common-libs
[CC] common-libs
tcgbios.c: In function ‘tpm20_write_EfiSpecIdEventStruct’:
tcgbios.c:708:24: warning: array subscript ‘numAlgs’ is outside the bounds of an interior zero-length array ‘struct TCG_EfiSpecIdEventAlgorithmSize[0]’ [-Wzero-length-bounds]
708 | event.hdr.digestSizes[numAlgs].algorithmId =
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from tpm_drivers.h:20,
from tcgbios.c:27:
tcgbios_int.h:92:4: note: while referencing ‘digestSizes’
92 | } digestSizes[0];
| ^~~~~~~~~~~
tcgbios.c:710:24: warning: array subscript ‘numAlgs’ is outside the bounds of an interior zero-length array ‘struct TCG_EfiSpecIdEventAlgorithmSize[0]’ [-Wzero-length-bounds]
710 | event.hdr.digestSizes[numAlgs].digestSize = cpu_to_log16(hsize);
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from tpm_drivers.h:20,
from tcgbios.c:27:
tcgbios_int.h:92:4: note: while referencing ‘digestSizes’
92 | } digestSizes[0];
| ^~~~~~~~~~~
Thomas Huth [Thu, 27 May 2021 10:05:37 +0000 (12:05 +0200)]
Fix bad header guard in version.h
The #define in version.h does not match the #ifndef in the line before
due to a typo in the suffix ("_F" instead of "_H"). Fix it, and while
we're at it, also remove the underscore at the beginning to avoid that
we're using an identifier here that is reserved by the C standard.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Wed, 9 Jun 2021 16:48:41 +0000 (12:48 -0400)]
tcgbios: Fix details in log entries
Fix two details of the logs:
- Set the filed SpecErrata to 2 as required by specs.
- Write the separator into the log entry's event field.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Wed, 17 Feb 2021 04:54:18 +0000 (15:54 +1100)]
version: update to
20210217
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Wed, 27 Jan 2021 08:39:44 +0000 (19:39 +1100)]
Makefile: Actually compile with -Wextra
-Wextra enables a bunch of rather useful checks which this fixes.
The only exception is -Wno-unused-parameter, one thing at the time.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Wed, 27 Jan 2021 08:39:14 +0000 (19:39 +1100)]
slof/prim: Compile with -Wextra
-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>
Alexey Kardashevskiy [Wed, 27 Jan 2021 08:38:30 +0000 (19:38 +1100)]
libtpm: Compile with -Wextra
-Wextra enables a bunch of rather useful checks which this fixes.
Note this adds MIN() in tpm_gpt_set_lba1() so it may potentially fail
which is unlikely as the length comes from disk-label's block-size which
is used in other places.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Wed, 27 Jan 2021 08:38:12 +0000 (19:38 +1100)]
libnvram: Compile with -Wextra
-Wextra enables a bunch of rather useful checks which this fixes.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Wed, 27 Jan 2021 08:37:55 +0000 (19:37 +1100)]
libhv: Compile with -Wextra
-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>
Alexey Kardashevskiy [Wed, 27 Jan 2021 08:37:39 +0000 (19:37 +1100)]
libnet: Compile with -Wextra
-Wextra enables a bunch of rather useful checks which this fixes.
This also fixes unused parameters warning by passing meaningful value and
doing sanity checks.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v2:
* updated commit log about using AF_INET/etc
* replaced cast to int with size_t in pxelinux_load_cfg
* added (alen == 0) in ping()
Alexey Kardashevskiy [Wed, 27 Jan 2021 08:37:21 +0000 (19:37 +1100)]
e1000: Compile with -Wextra
-Wextra enables a bunch of rather useful checks which this fixes.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Wed, 27 Jan 2021 08:37:02 +0000 (19:37 +1100)]
virtio: Compile with -Wextra
-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>
Alexey Kardashevskiy [Wed, 27 Jan 2021 08:33:23 +0000 (19:33 +1100)]
veth: Compile with -Wextra
-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>
Alexey Kardashevskiy [Wed, 27 Jan 2021 08:30:11 +0000 (19:30 +1100)]
usb: Compile with -Wextra
-Wextra enables a bunch of rather useful checks which this fixes with
one exception of -Wunused-parameter - this fixes it for debug macros only
and leave the rest for the future as more functional change is needed.
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v2:
* updated debug macros to fix -Wunused-parameter
---
These are not fixed:
====== Building common libraries ======
[CC] usb-core.o
[CC] usb-ohci.o
[CC] usb-hid.o
[CC] usb-xhci.o
/home/aik/p/slof/lib/libusb/usb-core.c: In function ‘usb_set_address’:
/home/aik/p/slof/lib/libusb/usb-core.c:244:58: warning: unused parameter ‘port’ [-Wunused-parameter]
static int usb_set_address(struct usb_dev *dev, uint32_t port)
^~~~
/home/aik/p/slof/lib/libusb/usb-xhci.c: In function ‘xhci_send_enable_slot’:
/home/aik/p/slof/lib/libusb/usb-xhci.c:353:67: warning: unused parameter ‘port’ [-Wunused-parameter]
static void xhci_send_enable_slot(struct xhci_hcd *xhcd, uint32_t port)
^~~~
/home/aik/p/slof/lib/libusb/usb-ohci.c: In function ‘ohci_dump_regs’:
/home/aik/p/slof/lib/libusb/usb-ohci.c:42:46: warning: unused parameter ‘regs’ [-Wunused-parameter]
static void ohci_dump_regs(struct ohci_regs *regs)
^~~~
/home/aik/p/slof/lib/libusb/usb-core.c: In function ‘usb_handle_device’:
/home/aik/p/slof/lib/libusb/usb-core.c:444:80: warning: unused parameter ‘cfg’ [-Wunused-parameter]
static int usb_handle_device(struct usb_dev *dev, struct usb_dev_config_descr *cfg,
^~~
/home/aik/p/slof/lib/libusb/usb-xhci.c: In function ‘fill_setup_trb’:
/home/aik/p/slof/lib/libusb/usb-xhci.c:1026:13: warning: unused parameter ‘size’ [-Wunused-parameter]
uint32_t size)
^~~~
/home/aik/p/slof/lib/libusb/usb-xhci.c: In function ‘xhci_transfer_bulk’:
/home/aik/p/slof/lib/libusb/usb-xhci.c:1217:60: warning: unused parameter ‘td’ [-Wunused-parameter]
static int xhci_transfer_bulk(struct usb_pipe *pipe, void *td, void *td_phys,
^~
/home/aik/p/slof/lib/libusb/usb-xhci.c:1217:70: warning: unused parameter ‘td_phys’ [-Wunused-parameter]
static int xhci_transfer_bulk(struct usb_pipe *pipe, void *td, void *td_phys,
^~~~~~~
/home/aik/p/slof/lib/libusb/usb-xhci.c: In function ‘xhci_get_pipe_intr’:
/home/aik/p/slof/lib/libusb/usb-xhci.c:1364:22: warning: unused parameter ‘len’ [-Wunused-parameter]
char *buf, size_t len)
^~~
Alexey Kardashevskiy [Wed, 27 Jan 2021 08:33:49 +0000 (19:33 +1100)]
elf: Compile with -Wextra
-Wextra enables a bunch of rather useful checks which this fixes.
This changes the return value for the case when no ELF headers were found
to avoid (ugly-ish) cast of -1 to unsigned.
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v2:
* cast the return value to (int)
* added missing (long)
Alexey Kardashevskiy [Wed, 27 Jan 2021 08:35:36 +0000 (19:35 +1100)]
libc: Compile with -Wextra
-Wextra enables a bunch of rather useful checks which this fixes.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v2:
* replaced cast to int with cast to size_t
Alexey Kardashevskiy [Wed, 27 Jan 2021 08:36:37 +0000 (19:36 +1100)]
helpers: Define MIN()
We already have MAX() defined, add MIN() to the common helpers header.
Using the common helper also fixes a bug in tpmdrivers's MIN() where
it was reverted.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v2:
* updated the comment about a fixed bug
Thomas Huth [Sun, 24 Jan 2021 07:41:27 +0000 (08:41 +0100)]
virtio-serial: Remove superfluous serial-* words
These likely were a blind copy-n-paste from hvterm.fs, but they
simply do not make any sense in virtio-serial.fs. The hvterm.fs is
always included from OF.fs, so the serial-* words are globally there.
virtio-serial.fs is only used within the virtio-serial device tree
nodes, to adding the serial-* words there is just superfluous.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Fri, 17 Jul 2020 01:09:49 +0000 (11:09 +1000)]
version: update to
20200717
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Thu, 16 Jul 2020 04:33:08 +0000 (14:33 +1000)]
fdt: Avoid recursion when traversing tree
A loop over peers does not need recursion which becomes a problem with
hundreds devices.
This was discovered with "-smp 2048,cores=512,threads=4".
Suggested-by: Jordan Niethe <jniethe5@gmail.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Gustavo Romero [Mon, 22 Jun 2020 20:48:13 +0000 (16:48 -0400)]
board-qemu: Fix comment about SLOF start address
On QEMU pseries (and alike environments) the PC starts at 0x100, hence SLOF
starts at address 0x100, not at 0x0 as the current comment informs. After
that fix the comment also matches the comment above it about the __start
load position, which is correct.
Signed-off-by: Gustavo Romero <gromero@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Wed, 13 May 2020 02:26:46 +0000 (12:26 +1000)]
version: update to
20200513
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Tue, 12 May 2020 15:44:52 +0000 (11:44 -0400)]
tcgbios: Measure the bootloader file read from disk
Measure the bootloader file read from disk into PCR 4 and log it with
the description 'BOOTLOADER' and the event type EV_COMPACT_HASH
(code 0xc). Since the loaded file should be an ELF file, have its size
determined and only the bytes from the ELF image measured rather than
the whole buffer that it was read into and is much bigger (0x700000
bytes).
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Tue, 12 May 2020 15:44:51 +0000 (11:44 -0400)]
tcgbios: Implement tpm_hash_log_extend_event_buffer
Implement tpm_hash_log_extend_event_buffer() that allows to measure
the contents of a buffer into a given PCR and log it with the
given event type and description. The caller may choose to have
the size of an ELF image file detected so that only data from the
ELF image are hashed rather than the much larger buffer.
Besides using this function call now for measuring the bootloader
read from a GPT partition, we also intend to use it for calls from
the firmware API that allow us to measure and log data from a boot
loader, such as grub. Grub will then invoke this function with a
buffer whose size it knows and will not need the ELF file size
detection.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Tue, 12 May 2020 15:44:50 +0000 (11:44 -0400)]
elf: Implement elf_get_file_size to determine size of an ELF image
Implement elf_get_file_size to determine the size of an ELF image
that has been loaded into a buffer much larger than the actual size
of the original file. We determine the size by searching for the
farthest offset declared by the ELF headers.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Mon, 30 Mar 2020 12:10:29 +0000 (08:10 -0400)]
tcgbios: Add support for SHA3 type of algorithms
Add support for SHA3 type of algorithms that the vTPM may support
some time in the future.
The algorithms are assigned in "TCG Algorithm Registry"
https://trustedcomputinggroup.org/resource/tcg-algorithm-registry/
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Mon, 30 Mar 2020 12:10:28 +0000 (08:10 -0400)]
tcgbios: Fix the vendorInfoSize to be of type uint8_t
The vendorInfoSize is a uint8_t rather than a uint32_t.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Mon, 30 Mar 2020 12:10:27 +0000 (08:10 -0400)]
tcgbios: Only write logs for PCRs that are allocated
Only write the logs for those PCRs that are allocated in
banks.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Wed, 11 Mar 2020 02:37:22 +0000 (13:37 +1100)]
make: Define default rule for .c when V=1 or V=2
The default .o:.c rule passes a short file name to gcc to when doing
"make -C <dir>", we do this a lot for all the libraries.
The file names printed in gcc errors are relative to <dir> and this
prevents vim from navigating through errors.
This passes the full file name to gcc to make it print errors with
absolute path so vim can navigate through errors nicely.
This makes it optional when V=1 or V=2 is passed.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Fri, 27 Mar 2020 01:04:37 +0000 (12:04 +1100)]
version: update to
20200327
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Greg Kurz [Thu, 26 Mar 2020 10:32:43 +0000 (11:32 +0100)]
slof: Only close stdout for virtio-serial devices
Recent commit
cf28264196e5 fixed an issue where a virtio-serial device
wouldn't shutdown properly during quiesce. The fix is to close stdout
just before quiesce. As expected this causes some messages to not
appear anymore, like the well known ones from prom_init():
Quiescing Open Firmware ...
Booting Linux via __start() @ 0x0000000002000000 ...
Actually all messages are discarded until the OS driver finally takes
control of the device, which may represent a fair amount of logging.
This is suboptimal but this still better than hanging in SLOF.
The hammer is a bit too big though because the change also affects
spapr-vty based consoles, which have no reason to stop working
after quiesce.
Move the hack from the common code to the virtio-serial code so that
it doesn't affect other device types anymore. Register a quiesce hook
that closes stdout in virtio-serial.fs.
While here, as suggested by Segher, bring back some robustness in the
shutdown method.
Reported-by: Fabiano Rosas <farosas@linux.ibm.com>
Fixes:
cf28264196e5 "virtio-serial: Rework shutdown sequence"
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Mon, 16 Mar 2020 22:43:26 +0000 (09:43 +1100)]
version: update to
20200317
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Mon, 16 Mar 2020 01:24:06 +0000 (12:24 +1100)]
rtas: Move FWNMI log space reservation to QEMU
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>
Alexey Kardashevskiy [Thu, 12 Mar 2020 03:53:42 +0000 (14:53 +1100)]
version: update to
20200312
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Mon, 9 Mar 2020 22:43:17 +0000 (23:43 +0100)]
virtio-serial: Close device completely
Linux closes stdout at the end of prom_init which triggers the FW quiesce
code which closes the virtio-serial instance. This misses stopping the
virtio queues. However this seemed working for a little longer (until the
Linux driver took over) till
300384f3dc68 which moved the VQ descriptors
around which caused use-after-free corruption.
This adds virtio_queue_term_vq(), cleanup in the forth driver and a few
checks.
Fixes:
300384f3dc68 ("virtio: Store queue descriptors in virtio_device")
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
[groug: - fix changelog
- don't restore emit]
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Greg Kurz [Mon, 9 Mar 2020 22:43:12 +0000 (23:43 +0100)]
virtio-serial: Rework shutdown sequence
The "io" word of term-io.fs opens two separate instances of the device
for stdin and stdout. The prom_init() function in Linux closes stdin at
some point, which internally calls quiesce and shuts the device down
through a quiesce hook.
When the "open-count" variable in virtio-serial.fs reaches 0, ie. when
closing the last instance, we call "close" two times, which is clearly
wrong. This never hits however because the stdout instance is never
closed which prevents "open-count" to reach 0.
It would make more sense to shutdown the device when closing the last
instance, for symmetry with the first open that initializes the device.
Change the shutdown sequence to do that rather than relying on a quiesce
hook.
Have quiesce to explicitly close stdout, which is supposedly the last
instance, and shutdown the device.
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Greg Kurz [Mon, 9 Mar 2020 22:43:06 +0000 (23:43 +0100)]
virtio-serial: Don't override some words
term-io.fs already overrides "emit", "key" and "key?" with its own version:
- "term-io-emit" calls the "write" method of the "stdout" instance, which
then calls "virtio-serial-putchar"
- "term-io-key" calls the "read" method of the "stdout" instance, which then
calls "virtio-serial-getchar"
- "term-io-key?" calls "serial-key?" if the device is a serial device, which
is the case here and we already override "serial-key?" with
"virtio-serial-term-key?".
It thus looks weird to rely on these shortcuts. Especially, when IOMMU is
enabled, we need a valid instance in "dmap-map-in" and going through
"term-io-emit" buys us that.
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Wed, 11 Mar 2020 02:43:42 +0000 (13:43 +1100)]
llfw: Fix debug printf warnings
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Cédric Le Goater [Wed, 4 Mar 2020 18:07:21 +0000 (19:07 +0100)]
virtio: Fix typo in virtio_serial_init()
Fixes:
300384f3dc68 ("virtio: Store queue descriptors in virtio_device")
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Mon, 17 Feb 2020 01:02:49 +0000 (12:02 +1100)]
version: update to
20200221
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Tue, 21 Jan 2020 20:01:47 +0000 (15:01 -0500)]
tcgbios: Measure the GPT table
Measure and log the GPT table including LBA1 and all GPT table entries
with a non-zero Type GUID.
We follow the specification "TCG PC Client Platform Firmware Profile
Specification" for the format of what needs to be logged and measured.
See section "Event Logging" subsection "Measuring UEFI Variables" for
the UEFI_GPT_DATA structure.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Tue, 21 Jan 2020 20:01:46 +0000 (15:01 -0500)]
tcgbios: Implement menu to clear TPM 2 and activate its PCR banks
Implement a TPM 2 menu and enable the user to clear the TPM
and its activate PCR banks.
The main TPM menu is activated by pressing the 't' key during
firmware startup.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Tue, 21 Jan 2020 20:01:45 +0000 (15:01 -0500)]
tcgbios: Add TPM 2.0 support and firmware API
This patch adds TPM 2.0 support along with the firmware API that Linux
uses to transfer the firmware log.
The firmware API follows the "PFW Virtual TPM Driver" specification.
The API has callers in existing Linux code (prom_init.c) from TPM 1.2
times but the API also works for TPM 2.0 without modifications.
The TPM 2.0 support logs PCR extensions of measurements of code and data.
For this part we follow the TCG specification "TCG PC Client
Platform Firmware Profile Specification" (section "Event Logging").
Other relevant specs for the construction of TPM commands are:
- Trusted Platform Module Library; Part 2 Structures
- Trusted Platform Module Library; Part 3 Commands
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
[aik: removed new blank lines at EOF]
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Tue, 21 Jan 2020 20:01:44 +0000 (15:01 -0500)]
tpm: Add sha256 implementation
The following patch adds a SHA256 implementation based on the algorithm
description in NIST FIPS PUB 180-4. The patch includes test cases that test
the sha256 implementation and pass on big and little endian ppc64 hosts.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Tue, 21 Jan 2020 20:01:43 +0000 (15:01 -0500)]
tpm: Add TPM CRQ driver implementation
This patch adds a TPM driver for the CRQ interface as used by
the QEMU PAPR implementation.
Also add a Readme that explains the benefits and installation procedure
for the vTPM.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Tue, 21 Jan 2020 20:01:42 +0000 (15:01 -0500)]
qemu: Make print_version variable accessible
Make the print_version global variable accessible so that
we can measure the firmware version.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Tue, 21 Jan 2020 20:01:41 +0000 (15:01 -0500)]
slof: Make linker script variables accessible
Make linker script variables related to 'text' addresses available
to the code so we can measure the static core root of trust contents.
When hashing the 'data' part of SLOF we do not end up with the same
measurements for the same firmware when booting with different
configurations, so we don't make those available.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Stefan Berger [Tue, 21 Jan 2020 20:01:40 +0000 (15:01 -0500)]
slof: Implement SLOF_get_keystroke() and SLOF_reset()
Implement SLOF_get_keystroke() and SLOF_reset() helper functions.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Greg Kurz [Mon, 10 Feb 2020 13:16:09 +0000 (14:16 +0100)]
fdt: Delete nodes of devices removed between boot and CAS
We recently fixed node creation at CAS in order to support early hotplug
of devices between boot and CAS. Let's handle node removal now to support
early hot *un*plug of devices.
This is achieved by associating a generation number to each FDT received
from QEMU and tagging all nodes with this number in a "slof,from-fdt"
property. The generation number is kept in the fdt-generation# variable.
It starts at 0 for the initial boot time FDT, and it is incremented at
each subsequent CAS. All boot time nodes hence get "slof,from-fdt" == 0,
all nodes present at CAS get "slof,from-fdt" == 1 and so on in case the
guest calls CAS again. If a device gets hot unplugged before quiesce, we
hence can detect it doesn't have the right generation number and thus
delete the node from the DT. Note that this only affects nodes coming
from the FDT. Nodes created by SLOF don't have the "slof,from-fdt"
property, and therefore cannot be candidates to deletion.
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Greg Kurz [Wed, 5 Feb 2020 18:21:42 +0000 (19:21 +0100)]
fdt: Fix update of "interrupt-controller" node at CAS
Now that QEMU passes a full FDT at CAS without rebooting, a guest that
has switched from XICS to XIVE ends up being presented an malformed
"interrupt-controller" node in the DT:
# dtc -I fs -O dts /proc/device-tree
<stdout>: Warning (unit_address_vs_reg): /interrupt-controller: node has a reg or ranges property, but no unit name
...
interrupt-controller {
ibm,xive-eq-sizes = <0x10>;
device_type = "power-ivpe";
ibm,interrupt-server-ranges = <0x00 0x03>;
compatible = "ibm,power-ivpe";
#interrupt-cells = <0x02>;
reg = <0x60302 0x31b0000 0x00 0x10000 0x60302 0x31a0000 0x00 0x10000>;
phandle = <0xe7448a8>;
ibm,xive-lisn-ranges = <0x00 0x03>;
interrupt-controller;
};
The node should have its unit set to "
60302031b0000" as reported by dtc.
Also the node still has an "ibm,interrupt-server-ranges" property which
only makes sense with XICS.
This happens because we find an existing "interrupt-controller" node,
which describes a XICS controller, and we _wrongly_ decide to copy
all the properties from the new node into it. Delete the existing node
instead so that we create a new node with the appropriate properties
and unit name.
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Wed, 5 Feb 2020 18:21:37 +0000 (19:21 +0100)]
fdt: Fix creating new nodes at H_CAS
So far we only allowed new ibm,dynamic-reconfiguration-memory and memory
nodes in the FDT update blob at ibm,client-architecture-support (CAS).
DRC do not have unit addresses and are easy, for memory nodes we use
an address from the node name.
For early hot plugged PCI devices (plugged after reset but before CAS)
we have to have a similar hack as for memory@ but parse the address
differently because of different binding.
Instead, this changes new nodes creation. At pass#0 when we copy phandles
from the FDT update blob to SLOF, we create new nodes with all
new properties and call "finish-device" only after all properties are
copied to the new nodes. At this point we particularly care about "reg"
as this is the unit address which SLOF parses for us and sets the unit
address in "finish-device"; we could skip other properties for later
passes.
Note this creates naked nodes with no methods normally added to the nodes
as this bypasses normal discovery which SLOF performs at start. So
if pass#1 does not find the node created in pass#0, this points to
missing "decode-unit" at the new node parent (happens when adding bridge-
under-bridge) and this prints a message and resets.
While at this, fix few trailing spaces and comments.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
[groug: - use fdt-reg-unit to set the unit name
- consolidate finish-device and unit name for nodes and subnodes
with a new fdt-cas-finish-device word ]
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Tue, 31 Dec 2019 02:03:44 +0000 (13:03 +1100)]
elf64: Add LE64 ABIv1/2 support for loading images to given address
c2358afb40d4 ("Add support for 64bit LE ABI v1 and v2 support") added
little endian ELF support for one of two ELF loading helpers, this fixes
oversight. With this changes, 'boot disk:2,boot\zImage' is able to handle
little-endian zimages.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Mon, 30 Dec 2019 03:01:24 +0000 (14:01 +1100)]
ext2/4: Add basic extent tree support
This allows booting from ext4 filesystems when EXT4_EXTENTS_FL is set in
inode.
Based on:
https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Mon, 30 Dec 2019 02:59:51 +0000 (13:59 +1100)]
ext2: Read all 64bit of inode number
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Mon, 30 Dec 2019 02:59:25 +0000 (13:59 +1100)]
ext2: Read size of group descriptors
When incompat flags has INCOMPAT_64BIT set ("Enable a filesystem size
over 2^32 blocks"), the group descriptor size is stored at 0xFE
and these days it is 0x40 so use that rather than the default value
of 0x20.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Tue, 24 Dec 2019 02:25:37 +0000 (13:25 +1100)]
ext2: Rename group-desc-size
A le32 value at 0x20 offset in supernode is:
0x20 __le32 s_blocks_per_group Blocks per group
Size of group descriptors is a le16 value at 0xfe.
Rename group-desc-size according to the ext2/4 spec.
This should cause no behavioral change.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Mon, 30 Dec 2019 02:58:35 +0000 (13:58 +1100)]
ext2: Prepare for extending
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Mon, 30 Dec 2019 02:01:43 +0000 (13:01 +1100)]
disk-label: Support Linux GPT partition type
This adds support for:
"Linux filesystem data"
0FC63DAF-8483-4772-8E79-
3D69D8477DE4
Previously, Linux used the same GUID for the data partitions as Windows
(Basic data partition:
EBD0A0A2-B9E5-4433-87C0-
68B6B72699C7).
The new GUID (Linux filesystem data:
0FC63DAF-8483-4772-8E79-
3D69D8477DE4)
was defined jointly by GPT fdisk and GNU.
Source:
https://en.wikipedia.org/wiki/GUID_Partition_Table#cite_note-linwin-40
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Tue, 24 Dec 2019 02:22:23 +0000 (13:22 +1100)]
disk-label: Prepare for extenting
We are going to add limited support for ext4 and Linux GPT partitions.
This moves try-ext2-files and (interpose-filesystem) earlier to be called
from try-gpt-dos-partition.
This simplifies UUID defining and handling.
This should cause no behavioral change.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Tue, 17 Dec 2019 00:23:00 +0000 (11:23 +1100)]
version: update to
20191217
This is aiming qemu 5.0.
This is equal to
20191206, however that was a partial
backport for regression happened in qemu 4.2 and
that got the
20191209 tag which will take over
20191206 when updated although that would be a downgrade
so we need a bigger tag.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Fri, 6 Dec 2019 01:05:14 +0000 (12:05 +1100)]
version: update to
20191206
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Thu, 5 Dec 2019 03:36:00 +0000 (14:36 +1100)]
fdt: Fix updating the tree at H_CAS
The previous approach to merge the QEMU FDT into the existing tree and
then patch it turned to be broken as we patch properties based on their
names only so we patch not just what QEMU provides (which was
the intention) but also all properties SLOF created. This breaks one of
them - "interrupt-map" - it is created by QEMU for a PHB but SLOF creates
it for PCI bridges and since they have different sizes, patching phandles
at fixed offset fails.
Rather than skipping certain nodes in the SLOF tree, this uses different
approach: now we read the QEMU FDT in 3 passes:
1. find all phandle/linux-phandle properties and store these in the SLOF
internal tree to allow phandle->node lookup later;
2. walk through all FDT properties, patch them if needed using
phandles from the SLOF tree and save patched values in SLOF properties;
3. delete phandle/linux-phandle properties created in 1. This is safe
as SLOF does not create these properties anyway.
Fixes:
44d06f9e68cf ("fdt: Update phandles after H_CAS")
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Wed, 4 Dec 2019 06:13:00 +0000 (17:13 +1100)]
ibm,client-architecture-support: Fix stack handling
fdt-fix-cas-node returns the end address after it's finished which
the caller (ibm,client-architecture-support) does not use or drop.
This renames fdt-fix-cas-node to (fdt-fix-cas-node) and adds a wrapper
on top of that which does the drop. This will be used later for 2-pass
tree patching.
While at this, exit the function if memory allocation failed.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Wed, 4 Dec 2019 02:06:27 +0000 (13:06 +1100)]
virtio: Enable IOMMU
When QEMU is started with iommu_platform=on, the guest driver must accept
it or the device will fail.
This enables IOMMU support for virtio-net, -scsi, -block, -serial, -9p
devices. -serial and -9p are only compile tested though.
For virtio-net we map all RX buffers once and TX when xmit() is called
and unmap older pages when we are about to reuse the VQ descriptor.
As all other devices are synchronous, we unmap IOMMU pages right after
completion of a transaction.
This depends on QEMU's:
https://patchwork.ozlabs.org/patch/1194067/
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Tested-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
Changes:
v5:
* fixed queue size calculation
* reworked virtio_free_desc() to only unmap what is has mapped
v4:
* ditched vqs->id in virtio_queue_init_vq
v2:
* added Mike's fs/dma-instance-function.fs
* total rework
Michael Roth [Wed, 4 Dec 2019 02:08:33 +0000 (13:08 +1100)]
dma: Define default dma methods for using by client/package instances
They call parent node (which is a device) methods.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Thu, 7 Nov 2019 06:54:58 +0000 (17:54 +1100)]
virtio-net: Init queues after features negotiation
Every virtio device negotiates virtio protocol features before setting
up internal queue descriptors with one exception which is virtio-net.
This moves virtio_queue_init_vq() later to have feature negotiation
happened sooner. This is going to be used for IOMMU setup later.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Alexey Kardashevskiy [Thu, 7 Nov 2019 06:47:13 +0000 (17:47 +1100)]
virtio: Store queue descriptors in virtio_device
At the moment desc/avail/used pointers are read from the device every
time we need them. This works for now unless iommu_platform=on is used,
desc/avail/used stored in the config space are bus addresses while
SLOF should keep using the guest physical addresses.
virtio-net stores queue descriptors already, virtio-serial does it in
global statics, move them into virtio_device.
The next patch will use this to allow IOMMU.
While at this, move repeating avail->flags/idx setup into
virtio_queue_init_vq() except virtio-serial which vq_rx->avail->idx is
setup differently.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
Changes:
v4:
* removed vqs::id as it is not really used
* replaced vq_size with vq->size in virtio-serial.c
Alexey Kardashevskiy [Wed, 13 Nov 2019 07:17:04 +0000 (18:17 +1100)]
pci-phb: Reimplement dma-map-in/out
The immediate problem with the code is that it relies on memory allocator
aligning addresses to the size. This is true for SLOF but not for GRUB
and in unaligned situations we end up mapping more pages than bm-alloc
allocated.
This fixes the problem by calculating aligned DMA size before calling
bm-alloc.
While at this, simplify the code by removing global variables. Also
replace 1000/fff (the default 4K IOMMU page size) with tce-ps/mask.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
Changes:
v4:
* fixed code comments, tab/spaces
* fixed bm-alloc failure handling
Alexey Kardashevskiy [Thu, 7 Nov 2019 06:20:45 +0000 (17:20 +1100)]
sloffs: Fix -Wunused-result gcc warnings in read/write
This fixes these:
sloffs.c:466:2: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
read(fd, data, header_len);
^~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v2:
* size_t -> ssize_t
* %ld for size_t -> %zd
* changed error handling in sloffs_header() - now it frees sloffs->name
Alexey Kardashevskiy [Wed, 6 Nov 2019 02:55:54 +0000 (13:55 +1100)]
client: Load initramdisk location
For ages both vmlinux and zImage accepted the initramdisk location
in r3/r4 [1] [2]. If r3==r4==0, vmlinux looks at the device tree for
/chosen/linux,initrd-{start|end} but zImage does not so the QEMU user
can only pass vmlinux via -kernel if -initrd is passed as well.
This initializes r3/r4 to point to the initramdisk location when present.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/kernel/prom_init.c?h=v5.3#n3230
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/boot/of.c?h=v5.3#n89
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v2:
* improved readability
Alexey Kardashevskiy [Wed, 6 Nov 2019 03:56:12 +0000 (14:56 +1100)]
virtio: Make virtio_set_qaddr static
It is never called outside of virtio, make it static.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Thu, 7 Nov 2019 05:48:37 +0000 (16:48 +1100)]
allocator: Fix format strings for DEBUG
This silences multiple gcc warnings; no functional change otherwise.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Tue, 22 Oct 2019 03:37:50 +0000 (14:37 +1100)]
version: update to
20191022
This includes fixes for fullFDT render on CAS and gcc9.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Thomas Huth [Mon, 30 Sep 2019 07:43:47 +0000 (09:43 +0200)]
ipv6: Fix gcc9 warnings
GCC 9 introduced some new compiler warnings that occur when taking the
address of a packed struct, e.g.:
lib/libnet/icmpv6.c:173:21: warning: taking address of packed member of
‘struct ip6hdr’ may result in an unaligned pointer value [-Waddress-of-packed-member]
173 | rtr = find_router (&(ip6h->src));
| ^~~~~~~~~~~~
Since these warnings are mainly about the ip6_addr_t values that are
embedded in these packed structs, and ip6_addr_t is reasonable small
(just 128 bit), let's fix it by passing around the IPv6 addresses by
value instead of pointer, which looks a little bit nicer anyway.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Alexey Kardashevskiy [Tue, 22 Oct 2019 02:53:42 +0000 (13:53 +1100)]
libusb: Fix compiler warnings with gcc9
gcc9 enforces -Waddress-of-packed-member, fix this.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>