Re: [PATCH] mmc: sdhci: Write to HOST_CONTROL2 register for HS400 speed mode
Hi Peng, On 09/06/21 8:56 pm, Aswath Govindraju wrote: > Hi Peng, > > On 10/05/21 7:18 pm, Aswath Govindraju wrote: >> Hi Peng, >> >> On 07/04/21 3:52 am, Jaehoon Chung wrote: >>> On 4/5/21 11:44 PM, Aswath Govindraju wrote: From: Faiz Abbas Enable HS400 speed mode by writing to HOST_CONTROL2 register. Signed-off-by: Faiz Abbas Signed-off-by: Aswath Govindraju >>> >>> Reviewed-by: Jaehoon Chung >>> >> >> Can you please pick this patch if there are no comments. >> > > May I know if this okay to be merged ? > A gentle reminder on this patch. This patch has other dependencies that and are pending merge[1][2]. [1] - https://patchwork.ozlabs.org/project/uboot/list/?series=247000 [2] - https://patchwork.ozlabs.org/project/uboot/list/?series=245579 Thanks, Aswath > Thanks, > Aswath > >> Thanks, >> Aswath >> >>> Best Regards, >>> Jaehoon Chung >>> --- drivers/mmc/sdhci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index d9ab6a0a839e..eea4701d8af5 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -507,6 +507,9 @@ void sdhci_set_uhs_timing(struct sdhci_host *host) case MMC_HS_200: reg |= SDHCI_CTRL_UHS_SDR104; break; + case MMC_HS_400: + reg |= SDHCI_CTRL_HS400; + break; default: reg |= SDHCI_CTRL_UHS_SDR12; } >>> >> >
Re: [PATCH 17/27] ppc: Remove T1023RBD boards and T1024RDB_SECURE_BOOT
On 7/15/21 11:06 PM, Tom Rini wrote: On Thu, Jul 15, 2021 at 10:24:09AM +0200, gianluca wrote: Hello list! I know this mail will be OT, but I am worried about what will happen to a new project using the PowerPC T2080,e6500 64-bit PPC on this web site: https://www.powerpc-notebook.org I suspect the same architecture will be move outside the official Linux release when the same device-model will not match the kernel. And this will be a pity for all people who are believe on architectures and the power of opensource other than x86 and arm processors. So, this project will be a no-go or dead project before it will be launched. Are my worries overkill? I hope so. The platform can come back if someone is going to be actively maintaining the support. No one had been doing that, so I'm not sure what hidden breakage existed underneath the technical debt. Thanks a lot Tom. I will report this to the open progress ppc platform group. I think they will do whatever it takes to maintain this platform as soon as possible. Regards, -- Eurek s.r.l. | Electronic Engineering| http://www.eurek.it via Celletta 8/B, 40026 Imola, Italy | Phone: +39-(0)542-609120 p.iva 00690621206 - c.f. 04020030377 | Fax: +39-(0)542-609212
Re: [PATCH] serial: pl011: Resend the character if FIFO is full in debug uart
On 18.07.21 10:36, Chen Baozi wrote: pl01x_putc() might return -EAGAIN if there was no space in FIFO. In that case, high-level caller should wait until there is space and resend the character. Signed-off-by: Chen Baozi --- drivers/serial/serial_pl01x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index 76b96ad414..17b26aed81 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -417,7 +417,7 @@ static inline void _debug_uart_putc(int ch) { struct pl01x_regs *regs = (struct pl01x_regs *)CONFIG_DEBUG_UART_BASE; - pl01x_putc(regs, ch); + while (pl01x_putc(regs, ch) == -EAGAIN); I just recently also stumbled over this problem, that this serial driver did "swallow" many char's in the early debug stage. Coding style is a bit non-optimal though IMHO. Please move the ";" into the next newline instead. Other than that: Reviewed-by: Stefan Roese Thanks, Stefan
Re: [PATCH] Nokia RX-51: Update documentation about flashing
Hi, On 18/06/21 6:59 pm, Pali Rohár wrote: > This change contains update for doc/README.nokia_rx51 documentation file > with information how to load U-Boot image to device RAM without need to > flash it and also how to flash it into OneNAND via 0x flasher. > > Signed-off-by: Pali Rohár Can you please convert this file to rST ? Thanks and regards, Lokesh > --- > doc/README.nokia_rx51 | 45 +++ > 1 file changed, 45 insertions(+) > > diff --git a/doc/README.nokia_rx51 b/doc/README.nokia_rx51 > index 1be077514f03..e739b02088ea 100644 > --- a/doc/README.nokia_rx51 > +++ b/doc/README.nokia_rx51 > @@ -22,6 +22,51 @@ following repository: > >https://github.com/pali/u-boot-maemo > > +To generate combined.bin image from u-boot.bin and kernel.bin (either uImage > +or zImage) use: > + > + sh u-boot-gen-combined u-boot.bin kernel.bin combined.bin > + > +Original Maemo Fremantle PR1.3 zImage kernel binary is available at: > + > + > http://repository.maemo.org/pool/maemo5.0/free/k/kernel/kernel_2.6.28-20103103+0m5_armel.deb > + > +To unpack it (from DEB/AR, TAR and FIASCO) call commands: > + > + ar x kernel_2.6.28-20103103+0m5_armel.deb data.tar.gz > + tar -O -xf data.tar.gz ./boot/zImage-2.6.28-20103103+0m5.fiasco > > kernel_2.6.28-20103103+0m5.fiasco > + 0x -M kernel_2.6.28-20103103+0m5.fiasco -u > + > +Flashed image must start with 2 kB "NOLO!img" header which contains size of > +the image. Header consist of bytes "NOLO!img\x02\x00\x00\x00\x00\x00\x00\x00" > +followed by 4 byte little endian size of the image and rest of the 2 kB > header > +are just zero bytes. > + > +Nokia proprietary flasher and also open source 0x flasher automatically > +prepend required "NOLO!img" header and both applications expect that image > +does not contain "NOLO!img" header. Adding "NOLO!img" header is required > +only in case using "nandwrite" tool for flashing. > + > +Open source 0x flasher is available in following repository: > + > + https://github.com/pali/0x > + > +It is possible to load u-boot.bin via USB to N900 RAM and boot it without > +need to flashing it. Via 0x running at host PC it is done: > + > + 0x -m u-boot.bin -l -b > + > +0x support also flashing kernel image either via USB or directly on > +N900 device. Flashing u-boot/kernel/combined image is done as: > + > + 0x -m combined.bin -f > + > +Via 0x is possible to generate also standard flashable image in Nokia > +FIASCO format which contains metadata information like device identification > +(RX-51) and version string (v2021.04): > + > + 0x -m RX-51:v2021.04:kernel:u-boot.bin -g u-boot.fiasco > + > There is support for hardware watchdog. Hardware watchdog is started by > NOLO so u-boot must kick watchdog to prevent reboot device (but not very > often, max every 2 seconds). There is also support for framebuffer display >
[GIT PULL] TI changes for v2021.10-rc1
Hi Tom, Please find the PR for master branch targeted for v2021.10-rc1 tag. Details about the PR are updated in the tag message. Gitlab CI report: https://source.denx.de/u-boot/custodians/u-boot-ti/-/pipelines/8254 The following changes since commit c11f5abce84f630c92304683d5bde3204c5612c4: Merge branch '2021-07-14-build-and-host-updates' (2021-07-14 20:10:34 -0400) are available in the Git repository at: https://source.denx.de/u-boot/custodians/u-boot-ti.git tags/ti-v2021.10-rc1 for you to fetch changes up to 652982309d316b14aae5805d09239f89eb89f038: Nokia RX-51: Add check for /lib/ld-linux.so.2 in test script (2021-07-15 17:56:05 +0530) - Enabled distro boot for all TI platforms. - Cleanup for AM335x Guardian Board - PRUSS rproc on AM65 platform. - Add PMIC support for J7200 - Misc fixes for Nokia RX-51 Adam Ford (5): configs: omap3x_logic: Fix boot hang by reducing SYS_MALLOC_F_LEN arm: omap3: Make try_unlock_memory() static arm: omap3: Make secureworld_exit() static arm: omap3: Make secure_unlock_mem() static configs: am3517_evm: Fix boot hang Aswath Govindraju (2): configs: am64x_evm_a53_defconfig: Move TF-A load address to 0x701c arm: dts: k3-am64-main: Reserve OCMRAM for DMSC-lite and secure proxy communication Gireesh Hiremath (15): configs: am335x_guardian: Enable clock driver configs: am335x_guardian: add ubi fastmap support configs: am335x_guardian: add memtest configs am335x, guardian: set environment variable autoload to no am335x, guardian: code cleanup and boot optimization configs: am335x_guardian: set boot delay configs: am335x_guardian: disable spl command am335x, guardian: update swi logic am335x, guardian: Enable backlight configs: am335x_guardian: Enable display config drivers: video: hx8238 fix build bug am335x, guardian: Enable panel driver Himax HX8238D am335x, guardian: software update available status is stored in AM3352 RTC scracth register configs: am335x_guardian: Enable bootcount nvmem support configs: am335x_guardian: add register maps support Gowtham Tammana (6): arm: mach-k3: am642_init: Add missing ddr guard power: pmic: tps65941: Add compatible for LP876441 arm/dts: k3-j7200-r5-common: Add pmic lp876441 node arm/dts: k3-j7200-r5-common: Add VTM node arm/dts: k3-j7200-r5-common: Hook buck1_reg to vtm supply configs: j7200_evm_r5_defconfig: Enable AVS, PMIC and dependent configs Keerthy (2): soc: ti: pruss: Add a platform driver for PRUSS in TI SoCs remoteproc: pru: Add support for various PRU cores on K3 AM65x SoCs Lokesh Vutla (3): arm: dts: k3-am654-base-board: Add r5 specific u-boot dtsi arm: dts: ti: k3-am65-main: Add ICSSG nodes configs: am65x_evm_a53: Enable PRUSS remoteproc Moses Christopher (3): am335x, guardian: mem: Add board dependent mem values am335x, guardian: set tftp_load_addr in environment am335x, guardian: Update pinmux configuration Pali Rohár (3): Nokia RX-51: Add support for booting kernel in zImage format Nokia RX-51: Load bootmenu also from uSD card Nokia RX-51: Add check for /lib/ld-linux.so.2 in test script Tom Rini (7): ti: am335x_evm: Switch to DISTRO_BOOT only ti: am43xx_evm: Switch to DISTRO_BOOT only arm: ti: environment: Move in to ti: omap5: Switch to generic distro boot for non-Android cases configs: j721e_evm: Switch envboot out for distro_bootcmd arm: omap4: Disable USB_TTY and related options configs: am65x_evm: Switch envboot out for distro_bootcmd MAINTAINERS | 2 + arch/arm/dts/am335x-guardian-u-boot.dtsi | 11 + arch/arm/dts/am335x-guardian.dts | 14 +- arch/arm/dts/k3-am64-main.dtsi| 12 +- arch/arm/dts/k3-am65-main.dtsi| 463 ++ arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 205 ++-- .../dts/k3-am654-r5-base-board-u-boot.dtsi| 207 arch/arm/dts/k3-am654-r5-base-board.dts | 2 - .../arm/dts/k3-j7200-r5-common-proc-board.dts | 38 ++ .../include/asm/arch-am33xx/mem-guardian.h| 63 +++ arch/arm/include/asm/arch-omap3/sys_proto.h | 2 - arch/arm/mach-k3/am642_init.c | 2 +- arch/arm/mach-omap2/am33xx/Kconfig| 2 + arch/arm/mach-omap2/am33xx/board.c| 4 + arch/arm/mach-omap2/mem-common.c | 4 + arch/arm/mach-omap2/omap3/board.c | 21 +- board/bosch/guardian/board.c | 152 +- board/bosch/guardian/mux.c| 3 +- board/nokia/rx51/lowlevel_init.S | 12 +- configs/am335x_boneblack_vboot_defconfig | 2 +- configs/am335x_evm_defconfig | 2 +- configs/am335x_evm_spiboot_defconfig | 2 +- configs/am335x_guardian_defconfig | 30 +- configs/am335x_hs_evm_de
Re: [PATCH v3 2/9] arm: dts: imx8mp: Add common u-boot dtsi
Hi Tim, Simon, On 13.07.21 22:17, Simon Glass wrote: > Hi Tim, > > On Mon, 12 Jul 2021 at 14:58, Tim Harvey wrote: >> >> On Mon, Jul 12, 2021 at 12:44 PM Simon Glass wrote: >>> >>> Hi Tim, >>> >>> On Mon, 12 Jul 2021 at 10:42, Tim Harvey wrote: On Sat, Jul 10, 2021 at 5:23 AM Heiko Schocher wrote: > > Hello Tim, > > On 09.07.21 16:47, Tim Harvey wrote: >> On Wed, Jul 7, 2021 at 5:58 AM Teresa Remmet wrote: >>> >>> Factor out the common node settings for dm-spl and dm-pre-reloc >>> and move them to imx8mp-u-boot.dtsi >>> >>> Signed-off-by: Teresa Remmet >>> Reviewed-by: Fabio Estevam >>> Reviewed-by: Heiko Schocher >>> --- >>> Changes in v3: >>> - Moved binman nodes to common imx8mp-u-boot.dtsi >>> Changes in v2: >>> - none >>> >>> arch/arm/dts/imx8mp-evk-u-boot.dtsi | 143 + >>> .../imx8mp-phyboard-pollux-rdk-u-boot.dtsi| 39 + >>> arch/arm/dts/imx8mp-u-boot.dtsi | 149 ++ >>> 3 files changed, 153 insertions(+), 178 deletions(-) >>> create mode 100644 arch/arm/dts/imx8mp-u-boot.dtsi >>> >>> >> >> Teresa, >> >> I've noticed many of the imx8m boards migrating to using binman for >> image packaging. >> >> Doesn't this change from having a single flash.bin encompasing the SPL >> and U-Boot proper to having split files? I noticed that happened with >> imx8mm_evk for example when it switched to binman. > > Yes, but you can easy generate there a single image again. > >> What are the benefits to using binman? > > Beside the pros from binmal in general, I see the benefit in special > for imx8mp, that you can get all infos you need for signing the image > from within the image. No need to save some log output from U-Boot > build and parse this output ... > (+cc Simon) Heiko, And what are the pros from binman in general? I've read over tools/binman/binman.rst so I'm assuming you mean what is described there as benefits. How do you get all the details needed for signing the image from binman? If I make imx8mm_evk_defconfig which produces via binman flash.bin and u-boot.itb I get the following: $ ./tools/binman/binman ls -i flash.bin binman: Cannot find FDT map in image $ ./tools/binman/binman ls -i u-boot.itb binman: Cannot find FDT map in image >>> >>> As the message says, you need an 'fdtmap' in the image: >>> >>>fdtmap { >>>}: >>> >> >> Simon, >> >> Sorry I still don't quite understand: >> >> diff --git a/arch/arm/dts/imx8mm-evk-u-boot.dtsi >> b/arch/arm/dts/imx8mm-evk-u-boot.dtsi >> index f200afac9f..c6d8932fa4 100644 >> --- a/arch/arm/dts/imx8mm-evk-u-boot.dtsi >> +++ b/arch/arm/dts/imx8mm-evk-u-boot.dtsi >> @@ -163,6 +163,9 @@ >> itb { >> filename = "u-boot.itb"; >> >> + fdtmap { >> + }; >> + >> fit { >> description = "Configuration to load ATF before >> U-Boot"; >> #address-cells = <1>; >> >> >> $ make imx8mm_evk_defconfig >> $ make >> $ ./tools/binman/binman ls -i u-boot.itb >> Name Image-pos SizeEntry-type Offset Uncomp-size >> -- >> main-section 0 a3875 section 0 >> fdtmap 0 48d fdtmap 0 >> fit 48d a33e8 fit48d >> >> For signing we need the loadaddr/offset/size of the components within >> the FIT image. Since binman is calling mkimage to create FIT images it >> seems outside the scope of binman to be able to dump details on the >> actual FIT image. Perhaps mkimage or another tool is to be used for >> that detail? > > Yes, binman does not look inside FITs at presnt. You may want to look > at dump_image? > >> I would very much like to understand how to use binman to get the various offsets needed for signing an IMX image for use with HAB. >>> >>> You should be able to add signing support to binman for your use case. >>> See for example how vblock.py works. >> >> I see... so your saying instead of using an external tool to generate >> a txt template with the offset/size values for the various blobs >> instead we need to implement for example a habv4.py to add a habv4 >> entry and the python class would have access to the content handles to >> determine the addr/size in order to create the text template file fed >> to the NXP code signing tool? > > Yes that should work. It is in fact what binman is designed for > (producing images, with all the signing, etc.) Ah, sounds interesting! @Tim: Do you have time to look into this topic? bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82
Re: [PATCH v3 2/9] arm: dts: imx8mp: Add common u-boot dtsi
Hello Tim, On 12.07.21 18:42, Tim Harvey wrote: > On Sat, Jul 10, 2021 at 5:23 AM Heiko Schocher wrote: >> >> Hello Tim, >> >> On 09.07.21 16:47, Tim Harvey wrote: >>> On Wed, Jul 7, 2021 at 5:58 AM Teresa Remmet wrote: Factor out the common node settings for dm-spl and dm-pre-reloc and move them to imx8mp-u-boot.dtsi Signed-off-by: Teresa Remmet Reviewed-by: Fabio Estevam Reviewed-by: Heiko Schocher --- Changes in v3: - Moved binman nodes to common imx8mp-u-boot.dtsi Changes in v2: - none arch/arm/dts/imx8mp-evk-u-boot.dtsi | 143 + .../imx8mp-phyboard-pollux-rdk-u-boot.dtsi| 39 + arch/arm/dts/imx8mp-u-boot.dtsi | 149 ++ 3 files changed, 153 insertions(+), 178 deletions(-) create mode 100644 arch/arm/dts/imx8mp-u-boot.dtsi > >>> >>> Teresa, >>> >>> I've noticed many of the imx8m boards migrating to using binman for >>> image packaging. >>> >>> Doesn't this change from having a single flash.bin encompasing the SPL >>> and U-Boot proper to having split files? I noticed that happened with >>> imx8mm_evk for example when it switched to binman. >> >> Yes, but you can easy generate there a single image again. >> >>> What are the benefits to using binman? >> >> Beside the pros from binmal in general, I see the benefit in special >> for imx8mp, that you can get all infos you need for signing the image >> from within the image. No need to save some log output from U-Boot >> build and parse this output ... >> > > (+cc Simon) > > Heiko, > > And what are the pros from binman in general? I've read over > tools/binman/binman.rst so I'm assuming you mean what is described > there as benefits. Yes! > How do you get all the details needed for signing the image from binman? Not from binman directly, instead for getting the offset and length of the images you want to sign, I simply used "fdtget" to read them from the u-boot image: (extract from my yocto class... WIP also): dec2hex() { echo 0x$(printf '%x' $1) } # $1 ... fit image name # $2 ... part of fit image fit_get_off() { val=$(fdtget $1 /images/$2 data-position) # dec -> hex dec2hex $val } # $1 ... fit image name # $2 ... part of fit image fit_get_len() { val=$(fdtget $1 /images/$2 data-size) dec2hex $val } example for atf: off=$(fit_get_off u-boot.itb atf) len=$(fit_get_len u-boot.itb atf) Hope this helps? > If I make imx8mm_evk_defconfig which produces via binman flash.bin and > u-boot.itb I get the following: > > $ ./tools/binman/binman ls -i flash.bin > binman: Cannot find FDT map in image > $ ./tools/binman/binman ls -i u-boot.itb > binman: Cannot find FDT map in image > > I would very much like to understand how to use binman to get the > various offsets needed for signing an IMX image for use with HAB. > > Thanks, > > Tim > bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de
Re: [PATCH 16/17] i2c: Rename SPL/TPL_I2C_SUPPORT to I2C
Hello Simon, On 11.07.21 05:14, Simon Glass wrote: > Rename these options so that CONFIG_IS_ENABLED can be used with them. > > Signed-off-by: Simon Glass > --- > > arch/arm/cpu/armv8/fsl-layerscape/spl.c| 2 +- > arch/arm/mach-omap2/Kconfig| 6 +++--- > arch/arm/mach-omap2/am33xx/Kconfig | 4 ++-- > arch/arm/mach-omap2/boot-common.c | 2 +- > arch/arm/mach-sunxi/board.c| 2 +- > arch/powerpc/cpu/mpc83xx/Kconfig | 14 +++--- > arch/riscv/cpu/fu740/Kconfig | 2 +- > board/freescale/ls1021aqds/ls1021aqds.c| 2 +- > common/spl/Kconfig | 6 +++--- > configs/A10-OLinuXino-Lime_defconfig | 2 +- > configs/A10s-OLinuXino-M_defconfig | 2 +- > configs/A13-OLinuXino_defconfig| 2 +- > configs/A20-OLinuXino-Lime2-eMMC_defconfig | 2 +- > configs/A20-OLinuXino-Lime2_defconfig | 2 +- > configs/A20-OLinuXino-Lime_defconfig | 2 +- > configs/A20-OLinuXino_MICRO-eMMC_defconfig | 2 +- > configs/A20-OLinuXino_MICRO_defconfig | 2 +- > configs/A20-Olimex-SOM-EVB_defconfig | 2 +- > configs/A20-Olimex-SOM204-EVB-eMMC_defconfig | 2 +- > configs/A20-Olimex-SOM204-EVB_defconfig| 2 +- > configs/Ainol_AW1_defconfig| 2 +- > configs/Ampe_A76_defconfig | 2 +- > configs/Auxtek-T003_defconfig | 2 +- > configs/Auxtek-T004_defconfig | 2 +- > configs/Bananapi_M2_Ultra_defconfig| 2 +- > configs/Bananapi_defconfig | 2 +- > configs/Bananapro_defconfig| 2 +- > configs/CHIP_defconfig | 2 +- > configs/CHIP_pro_defconfig | 2 +- > configs/Chuwi_V7_CW0825_defconfig | 2 +- > configs/Cubieboard2_defconfig | 2 +- > configs/Cubieboard_defconfig | 2 +- > configs/Cubietruck_defconfig | 2 +- > configs/Empire_electronix_d709_defconfig | 2 +- > configs/Empire_electronix_m712_defconfig | 2 +- > configs/Hyundai_A7HD_defconfig | 2 +- > configs/Itead_Ibox_A20_defconfig | 2 +- > configs/Lamobo_R1_defconfig| 2 +- > configs/Linksprite_pcDuino3_Nano_defconfig | 2 +- > configs/Linksprite_pcDuino3_defconfig | 2 +- > configs/Linksprite_pcDuino_defconfig | 2 +- > configs/MK808C_defconfig | 2 +- > configs/MSI_Primo73_defconfig | 2 +- > configs/Mele_A1000_defconfig | 2 +- > configs/Mele_M3_defconfig | 2 +- > configs/Mele_M5_defconfig | 2 +- > configs/Mini-X_defconfig | 2 +- > configs/Orangepi_defconfig | 2 +- > configs/Orangepi_mini_defconfig| 2 +- > configs/P1010RDB-PA_36BIT_NAND_defconfig | 2 +- > configs/P1010RDB-PA_36BIT_SDCARD_defconfig | 2 +- > configs/P1010RDB-PA_36BIT_SPIFLASH_defconfig | 2 +- > configs/P1010RDB-PA_NAND_defconfig | 2 +- > configs/P1010RDB-PA_SDCARD_defconfig | 2 +- > configs/P1010RDB-PA_SPIFLASH_defconfig | 2 +- > configs/P1010RDB-PB_36BIT_NAND_defconfig | 2 +- > configs/P1010RDB-PB_36BIT_SDCARD_defconfig | 2 +- > configs/P1010RDB-PB_36BIT_SPIFLASH_defconfig | 2 +- > configs/P1010RDB-PB_NAND_defconfig | 2 +- > configs/P1010RDB-PB_SDCARD_defconfig | 2 +- > configs/P1010RDB-PB_SPIFLASH_defconfig | 2 +- > configs/P1020RDB-PC_36BIT_NAND_defconfig | 2 +- > configs/P1020RDB-PC_36BIT_SDCARD_defconfig | 2 +- > configs/P1020RDB-PC_36BIT_SPIFLASH_defconfig | 2 +- > configs/P1020RDB-PC_NAND_defconfig | 2 +- > configs/P1020RDB-PC_SDCARD_defconfig | 2 +- > configs/P1020RDB-PC_SPIFLASH_defconfig | 2 +- > configs/P1020RDB-PD_NAND_defconfig | 2 +- > configs/P1020RDB-PD_SDCARD_defconfig | 2 +- > configs/P1020RDB-PD_SPIFLASH_defconfig | 2 +- > configs/P2020RDB-PC_36BIT_NAND_defconfig | 2 +- > configs/P2020RDB-PC_36BIT_SDCARD_defconfig | 2 +- > configs/P2020RDB-PC_36BIT_SPIFLASH_defconfig | 2 +- > configs/P2020RDB-PC_NAND_defconfig | 2 +- > configs/P2020RDB-PC_SDCARD_defconfig | 2 +- > configs/P2020RDB-PC_SPIFLASH_defconfig | 2 +- > configs/T1024RDB_NAND_defconfig| 2 +- > configs/T1024RDB_SDCARD_defconfig
Re: [PATCH 15/17] i2c: Create a new Kconfig for I2C
Hello Simon, On 11.07.21 05:14, Simon Glass wrote: > At present we have CONFIG_SPL_I2C but not CONFIG_I2C. The reason > CONFIG_I2C is not strictly necessary is that: > > a) We have CONFIG_SYS_I2C_LEGACY and CONFIG_DM_I2C for the two possible >i2c stacks > b) In U-Boot proper, we always build drivers/i2c/ regardless of the >options > > Still, it is better to have CONFIG_I2C - it makes U-Boot proper similar to > SPL/TPL, so we can (in a future commit) simplify the Makefile rules. > > Enable it by default, since as above, we have separate options > (SYS_I2C_LEGACY and DM_I2C) to control whether it is 'really' enabled. > > Once we have migrated I2C to driver model, we can drop SYS_I2C_LEGACY and > make DM_I2C become I2C. For now, this lets us simplify the Makefile rules. > > Signed-off-by: Simon Glass > --- > > drivers/i2c/Kconfig | 26 -- > 1 file changed, 24 insertions(+), 2 deletions(-) Reviewed-by: Heiko Schocher Thanks! bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de
Re: [PATCH 14/17] i2c: Drop unused CONFIG_I2C
Hello Simon, On 11.07.21 05:14, Simon Glass wrote: > This actually does nothing but is defined by a few dozen boards. Drop it, > so we can define a real one. > > Signed-off-by: Simon Glass > --- > > include/configs/bur_am335x_common.h| 1 - > include/configs/siemens-am33x-common.h | 1 - > include/configs/ti_armv7_common.h | 1 - > scripts/config_whitelist.txt | 1 - > 4 files changed, 4 deletions(-) Reviewed-by: Heiko Schocher bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de
Re: [PATCH 13/17] i2c: Fix the migration warning
Hello Simon, On 11.07.21 05:14, Simon Glass wrote: > While there is a CONFIG_I2C it does not really mean anything and is > defined by only a few dozen boards. This should key off > CONFIG_SYS_I2C_LEGACY instead. > > Fix it. > > Signed-off-by: Simon Glass > --- > > Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Heiko Schocher bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de
Re: [PATCH 12/17] i2c: Rename CONFIG_SYS_I2C to CONFIG_SYS_I2C_LEGACY
Hello Simon, On 11.07.21 05:14, Simon Glass wrote: > It is quite confusing that CONFIG_SYS_I2C selects the legacy I2C and > CONFIG_DM_I2C selects the current I2C. The deadline to migrate I2C is less > than a year away. > > Also we want to have a CONFIG_I2C for U-Boot proper just like we have > CONFIG_SPL_I2C for SPL, so we can simplify the Makefile rules. > > Rename this symbol so it is clear it is going away. > > Signed-off-by: Simon Glass > --- > > README| 7 -- > arch/arm/cpu/armv8/fsl-layerscape/soc.c | 2 +- > arch/arm/cpu/armv8/fsl-layerscape/spl.c | 2 +- > .../include/asm/arch-fsl-layerscape/config.h | 2 +- > arch/arm/mach-kirkwood/include/mach/config.h | 2 +- > board/Arcturus/ucp1020/spl.c | 2 +- > board/compulab/common/Makefile| 2 +- > board/compulab/common/eeprom.h| 2 +- > board/freescale/p1_p2_rdb_pc/spl.c| 2 +- > board/renesas/draak/draak.c | 2 +- > board/renesas/salvator-x/salvator-x.c | 4 ++-- > board/renesas/ulcb/ulcb.c | 2 +- > board/somlabs/visionsom-6ull/visionsom-6ull.c | 2 +- > board/tqc/tqma6/tqma6.c | 4 ++-- > cmd/date.c| 4 ++-- > cmd/eeprom.c | 2 +- > cmd/i2c.c | 24 +-- > common/board_f.c | 4 ++-- > common/stdio.c| 2 +- > drivers/i2c/Makefile | 2 +- > include/asm-generic/global_data.h | 2 +- > include/config_fallbacks.h| 4 ++-- > include/configs/M5208EVBE.h | 2 +- > include/configs/M52277EVB.h | 2 +- > include/configs/M5235EVB.h| 2 +- > include/configs/M5253DEMO.h | 2 +- > include/configs/M5275EVB.h| 2 +- > include/configs/M53017EVB.h | 2 +- > include/configs/M5329EVB.h| 2 +- > include/configs/M5373EVB.h| 2 +- > include/configs/M54451EVB.h | 2 +- > include/configs/M54455EVB.h | 2 +- > include/configs/MPC8349EMDS.h | 2 +- > include/configs/MPC8349EMDS_SDRAM.h | 2 +- > include/configs/MPC837XERDB.h | 2 +- > include/configs/MPC8540ADS.h | 2 +- > include/configs/MPC8548CDS.h | 2 +- > include/configs/MPC8560ADS.h | 2 +- > include/configs/P1010RDB.h| 2 +- > include/configs/P2041RDB.h| 2 +- > include/configs/T102xRDB.h| 2 +- > include/configs/T104xRDB.h| 2 +- > include/configs/T208xQDS.h| 2 +- > include/configs/T208xRDB.h| 2 +- > include/configs/T4240RDB.h| 2 +- > include/configs/UCP1020.h | 2 +- > include/configs/astro_mcf5373l.h | 2 +- > include/configs/bur_am335x_common.h | 2 +- > include/configs/cl-som-imx7.h | 2 +- > include/configs/cm_fx6.h | 2 +- > include/configs/colibri_pxa270.h | 2 +- > include/configs/corenet_ds.h | 2 +- > include/configs/db-88f6720.h | 2 +- > include/configs/db-88f6820-gp.h | 2 +- > include/configs/db-mv784mp-gp.h | 2 +- > include/configs/devkit3250.h | 2 +- > include/configs/ds414.h | 2 +- > include/configs/eb_cpu5282.h | 2 +- > include/configs/edminiv2.h| 2 +- > include/configs/el6x_common.h | 2 +- > include/configs/embestmx6boards.h | 2 +- > include/configs/ethernut5.h | 2 +- > include/configs/flea3.h | 2 +- > include/configs/gw_ventana.h | 2 +- > include/configs/ids8313.h | 2 +- > include/configs/imx8mp_evk.h | 2 +- > include/configs/imx8mq_evk.h | 2 +- > include/configs/imx8mq_phanbell.h | 2 +- > include/configs/km/km-mpc83xx.h | 2 +- > include/configs/km/km_arm.h | 2 +- > include/configs/km/pg-wcom-ls102xa.h | 2 +- > include/configs/kzm9g.h | 2 +- > include/configs/legoev3.h | 2 +- > include/configs/ls1012a_common.h | 2 +- > include/configs/ls1021aiot.h | 2 +- > include/configs/ls1021aqds.h | 2 +- > include/configs/ls1021atsn.h | 2 +- > include/configs/ls1021atwr.h | 2 +- > include/configs/ls1028a_common.h | 2 +- > inc
Re: IMX8M Mini HAB secure boot - working?
Hello Tim, On 12.07.21 18:06, Tim Harvey wrote: > On Sat, Jul 10, 2021 at 5:24 AM Heiko Schocher wrote: >> >> Hi Tim, Stefano, >> >> On 10.07.21 11:14, Stefano Babic wrote: >>> Hi Tim, >>> >>> On 10.07.21 02:05, Tim Harvey wrote: Greetings, Has anyone successfully used secure boot with IMX8M Mini or other IMX8M? Peng's recent series got merged with the exception of what looks like the addition of couple of 'caam' commands to blob/deblob DEK's. There are no guides yet however I'm following the guides for the downstream NXP U-Boot and thus far have been able to get the SPL to boot with no HAB events but when it tries to authenticate the FIT image it validate_ivt fails with 'Error: Invalid IVT structure'. >>> >>> Heiko tested this and found it, if I am not wrong he found the cause. Added >>> him in CC. >>> >>> I have also planned to test this, it is on my TODO list... >> >> I am currently not in my office, the whole next week ... so I could not >> check my current state of the patches... but I found a problem, yes. >> >> The problem was that the ROM API loaded the IVT header to a >> memallocated address, which does of course not fit with the >> address you have in IVT header ... >> >> I have not full access to my development setup ,and found on my local >> some old state of the patches may you can try them? >> >> Of course they need a rework, other solution, but it shows the problem >> hopefully... >> > > Heiko, > > Thank you - that was indeed the issue and your patches resolve it. I Cool! Thanks for testing! > have not seen your patch posted to the list and your commit msg makes Yes, as they are WIP not posted yet ... and I thought, I make something wrong ... but if you have the same problem, it seems it is a real bug! > it seem like your not sure if you should make it SoC dependent. Do you > plan on submitting these to the mailing list? The question is: is my approach to fix it the way to go? If you think so, I can send them .. but give me please some time as I am just back from vacation... Fast look into it: spl_load_simple_fit_fix_load() must also check if there is at "fit" pointer an IVT header, if not, return simply fit pointer. Question: dependent on SoC ... as it is in common code, and I think we need this "fix" only for imx8m?, so yes, it should be SoC dependent or better only imx8m? code defines this function... if possible. Therefore the weak function approach. If you find time for looking at it, I am fine, if you use my patches as base and you can post them? bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de
RE: [PATCH V2 10/46] arm: imx8ulp: add container support
Hi Stefano, > Subject: Re: [PATCH V2 10/46] arm: imx8ulp: add container support > > Hi peng, Ye, > > On 29.06.21 04:32, Peng Fan (OSS) wrote: > > From: Ye Li > > > > i.MX8ULP support using ROM API to load container image, it use same > > ROM API as i.MX8MN/MP, and use same container format as > i.MX8QM/QXP. > > > > Signed-off-by: Ye Li > > Signed-off-by: Peng Fan > > --- > > arch/arm/include/asm/arch-imx8ulp/sys_proto.h | 2 + > > arch/arm/include/asm/mach-imx/image.h | 2 + > > arch/arm/include/asm/mach-imx/sys_proto.h | 2 +- > > arch/arm/mach-imx/Kconfig | 2 +- > > arch/arm/mach-imx/image-container.c | 42 - > > arch/arm/mach-imx/imx8ulp/soc.c | 2 + > > arch/arm/mach-imx/spl_imx_romapi.c| 172 > ++ > > 7 files changed, 177 insertions(+), 47 deletions(-) > > > > diff --git a/arch/arm/include/asm/arch-imx8ulp/sys_proto.h > > b/arch/arm/include/asm/arch-imx8ulp/sys_proto.h > > index 8894611a0f..a8f632f45e 100644 > > --- a/arch/arm/include/asm/arch-imx8ulp/sys_proto.h > > +++ b/arch/arm/include/asm/arch-imx8ulp/sys_proto.h > > @@ -10,5 +10,7 @@ > > > > This breaks after bisecting all mx8mn boards. For example: > > aarch64: + imx8mn_beacon_2g > +arch/arm/mach-imx/imx8ulp/Kconfig:10:warning: config symbol defined > without type > += WARNING == This board > uses > +CONFIG_SPL_FIT_GENERATOR. Please migrate to binman instead, to avoid > +the proliferation of arch-specific scripts with no tests. > + > +WARNING 'lpddr4_pmu_train_1d_imem.bin' not found, resulting binary is > not-functional > +arch/arm/mach-imx/spl_imx_romapi.c: In function > 'spl_romapi_load_image_stream': > +arch/arm/mach-imx/spl_imx_romapi.c:352:5: error: lvalue required as > left operand of assignment > + 352 | gd = pgd; I forgot to replace this. diff --git a/arch/arm/mach-imx/spl_imx_romapi.c b/arch/arm/mach-imx/spl_imx_romapi.c index 564cc400c1..17c35ced13 100644 --- a/arch/arm/mach-imx/spl_imx_romapi.c +++ b/arch/arm/mach-imx/spl_imx_romapi.c @@ -349,7 +349,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image, ret = g_rom_api->download_image(p, 0, imagesize, ((uintptr_t)p) ^ imagesize); - gd = pgd; + set_gd(pgd); if (ret != ROM_API_OKAY) printf("ROM download failure %d\n", imagesize); I'll rebase, run the buildman and repost. Thanks, Peng. > + | ^ > +make[2]: *** [scripts/Makefile.build:266: > arch/arm/mach-imx/spl_imx_romapi.o] Error 1 > +make[1]: *** [Makefile:1815: arch/arm/mach-imx] Error 2 > +make: *** [Makefile:171: sub-make] Error 2 > > Peng, in the series there are 2 patches related to i.MX7ULP that are unrelated > to the object this series. I am taking them out and applying to -master, you > do > not need to repost them. > > I have checked if I can apply some of the patches here, but it becomes a > mess if I do. So please repost them after fixing this. > > Best regards, > Stefano > > > extern unsigned long rom_pointer[]; > > > > +ulong spl_romapi_raw_seekable_read(u32 offset, u32 size, void *buf); > > +ulong spl_romapi_get_uboot_base(u32 image_offset, u32 rom_bt_dev); > > enum bt_mode get_boot_mode(void); > > #endif > > diff --git a/arch/arm/include/asm/mach-imx/image.h > > b/arch/arm/include/asm/mach-imx/image.h > > index 547beeb986..ee67ca96f4 100644 > > --- a/arch/arm/include/asm/mach-imx/image.h > > +++ b/arch/arm/include/asm/mach-imx/image.h > > @@ -64,4 +64,6 @@ struct generate_key_blob_hdr { > > u8 algorithm; > > u8 mode; > > } __packed; > > + > > +int get_container_size(ulong addr, u16 *header_length); > > #endif > > diff --git a/arch/arm/include/asm/mach-imx/sys_proto.h > > b/arch/arm/include/asm/mach-imx/sys_proto.h > > index e3ee58c9f8..444834995e 100644 > > --- a/arch/arm/include/asm/mach-imx/sys_proto.h > > +++ b/arch/arm/include/asm/mach-imx/sys_proto.h > > @@ -145,7 +145,7 @@ struct rproc_att { > > u32 size; /* size of reg range */ > > }; > > > > -#ifdef CONFIG_IMX8M > > +#if defined(CONFIG_IMX8M) || defined(CONFIG_IMX8ULP) > > struct rom_api { > > u16 ver; > > u16 tag; > > diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig > > index 26bfc5ccc4..c089664375 100644 > > --- a/arch/arm/mach-imx/Kconfig > > +++ b/arch/arm/mach-imx/Kconfig > > @@ -161,7 +161,7 @@ config DDRMC_VF610_CALIBRATION > > > > config SPL_IMX_ROMAPI_LOADADDR > > hex "Default load address to load image through ROM API" > > - depends on IMX8MN || IMX8MP > > + depends on IMX8MN || IMX8MP || IMX8ULP > > > > config IMX_DCD_ADDR > > hex "DCD Blocks location on the image" > > diff --git a/arch/arm/mach-imx/image-container.c > > b/arch/arm/mach-imx/image-container.c > > index 9e18f6630f..c3f62872c6 100644 > > --- a/arch/arm/mach-imx/image-container.
Re: [PATCH v2 4/5] efi: Use 16-bit unicode strings
On Mon, Jul 19, 2021 at 03:07:50AM +0200, Heinrich Schuchardt wrote: > On 7/19/21 3:01 AM, Tom Rini wrote: > > On Mon, Jul 19, 2021 at 02:41:46AM +0200, Heinrich Schuchardt wrote: > > > On 7/18/21 10:14 PM, Simon Glass wrote: > > > > At present we use wide characters for unicode but this is not necessary. > > > > Change the code to use the 'u' literal instead. This helps to fix build > > > > warnings for sandbox on rpi. > > > > > > > > Signed-off-by: Simon Glass > > > > Suggested-by: Heinrich Schuchardt > > > > > > According to https://en.cppreference.com/w/c/language/string_literal u"" > > > literals are supported since C11. In our Makefile we have CSTD_FLAG := > > > -std=gnu11. > > > > > > Once we have changed all u"" to L"" we can remove -fshort-wchar from our > > > Makefiles. > > Sorry, I meant 'change4 all L"" to u""'. > > -fshort-wchar interpretes all L"" as 16bit strings. Ah, OK. So, still, time for an spatch? -- Tom signature.asc Description: PGP signature
[PATCH] Makefile: Remove DM_VIDEO and DM_SPI_FLASH checks
As we have now completed the DM_VIDEO and DM_SPI_FLASH migrations we can remove the checks. Signed-off-by: Tom Rini --- Makefile | 4 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index 9fac1a02ca6e..ca2432c8ce9d 100644 --- a/Makefile +++ b/Makefile @@ -1125,10 +1125,6 @@ ifneq ($(CONFIG_DM),y) @echo >&2 "See doc/driver-model/migration.rst for more info." @echo >&2 "" endif - $(call deprecated,CONFIG_DM_VIDEO,video,v2019.07,\ - $(CONFIG_LCD)$(CONFIG_VIDEO)) - $(call deprecated,CONFIG_DM_SPI_FLASH,SPI flash,v2019.07,\ - $(CONFIG_SPI_FLASH)) $(call deprecated,CONFIG_WDT,DM watchdog,v2019.10,\ $(CONFIG_WATCHDOG)$(CONFIG_HW_WATCHDOG)) $(call deprecated,CONFIG_DM_ETH,Ethernet drivers,v2020.07,$(CONFIG_NET)) -- 2.17.1
Re: [PATCH v2 4/5] efi: Use 16-bit unicode strings
On 7/19/21 3:01 AM, Tom Rini wrote: On Mon, Jul 19, 2021 at 02:41:46AM +0200, Heinrich Schuchardt wrote: On 7/18/21 10:14 PM, Simon Glass wrote: At present we use wide characters for unicode but this is not necessary. Change the code to use the 'u' literal instead. This helps to fix build warnings for sandbox on rpi. Signed-off-by: Simon Glass Suggested-by: Heinrich Schuchardt According to https://en.cppreference.com/w/c/language/string_literal u"" literals are supported since C11. In our Makefile we have CSTD_FLAG := -std=gnu11. Once we have changed all u"" to L"" we can remove -fshort-wchar from our Makefiles. Sorry, I meant 'change4 all L"" to u""'. -fshort-wchar interpretes all L"" as 16bit strings. [snip] diff --git a/include/efi_loader.h b/include/efi_loader.h index b81180cfda8..cad7961942b 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -924,7 +924,7 @@ efi_status_t efi_capsule_authenticate(const void *capsule, efi_uintn_t capsule_size, void **image, efi_uintn_t *image_size); -#define EFI_CAPSULE_DIR L"\\EFI\\UpdateCapsule\\" +#define EFI_CAPSULE_DIR u"\\EFI\\UpdateCapsule\\" This brings us more, not less, instances of u"" rather than L"". Should we perhaps make a coccinelle "spatch" to update everything globally and drop -fshort-wchar ?
[PATCH v2 3/3] snow: Enable unit tests
It is useful to have a board with unit tests enabled, to check that this does not break. Let's choose snow, since it is not under active development and it is glorious. Signed-off-by: Simon Glass Reviewed-by: Jaehoon Chung --- (no changes since v1) configs/snow_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/snow_defconfig b/configs/snow_defconfig index 6090fea2b8f..63a5713a602 100644 --- a/configs/snow_defconfig +++ b/configs/snow_defconfig @@ -92,3 +92,5 @@ CONFIG_VIDEO_BRIDGE_NXP_PTN3460=y CONFIG_LCD=y CONFIG_TPM=y CONFIG_ERRNO_STR=y +CONFIG_UNIT_TEST=y +# CONFIG_UT_LIB_ASN1 is not set -- 2.32.0.402.g57bb445576-goog
[PATCH v2 2/3] test: Fix size_t formats in strlcat test
Some of the printf() formats do not match their types. Fix this. Reported-by: Minkyu Kang Signed-off-by: Simon Glass --- Changes in v2: - Fix some size_t warnings with recent compilers test/lib/strlcat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lib/strlcat.c b/test/lib/strlcat.c index ee61684c405..a0ec037388b 100644 --- a/test/lib/strlcat.c +++ b/test/lib/strlcat.c @@ -48,7 +48,7 @@ static int do_test_strlcat(struct unit_test_state *uts, int line, size_t align1, if (expected != actual) { ut_failf(uts, __FILE__, line, __func__, "strlcat(s2, s1, 2) == len2 < n ? min(len1 + len2, n) : n", -"Expected %#lx (%ld), got %#lx (%ld)", +"Expected %#zx (%zd), got %#zx (%zd)", expected, expected, actual, actual); return CMD_RET_FAILURE; } @@ -66,7 +66,7 @@ static int do_test_strlcat(struct unit_test_state *uts, int line, size_t align1, if (len2 < n && s2[i] != '\0') { ut_failf(uts, __FILE__, line, __func__, "n < len1 && s2[len2 + n] == '\\0'", -"Expected s2[%ld] = '\\0', got %d ('%c')", +"Expected s2[%zd] = '\\0', got %d ('%c')", i, s2[i], s2[i]); return CMD_RET_FAILURE; } -- 2.32.0.402.g57bb445576-goog
[PATCH v2 1/3] samsung: exynos: Convert SROMC interface to a driver
Add a bus driver for this and use it to configure the bus parameters for the Ethernet interface. Drop the old pre-driver-model code. Switch over to use driver model for Ethernet. Signed-off-by: Simon Glass Reviewed-by: Jaehoon Chung --- (no changes since v1) arch/arm/Kconfig | 1 + arch/arm/dts/exynos5250-smdk5250.dts | 1 + arch/arm/mach-exynos/include/mach/sromc.h | 18 -- board/samsung/common/Makefile | 2 +- board/samsung/common/board.c | 78 --- board/samsung/common/sromc.c | 76 ++ board/samsung/smdkv310/smdkv310.c | 9 --- configs/arndale_defconfig | 1 - configs/odroid-xu3_defconfig | 1 - configs/peach-pi_defconfig| 1 - configs/peach-pit_defconfig | 1 - configs/smdk5250_defconfig| 1 - configs/smdk5420_defconfig| 1 - configs/smdkv310_defconfig| 1 - configs/snow_defconfig| 1 - configs/spring_defconfig | 1 - include/fdtdec.h | 2 - lib/fdtdec.c | 2 - 18 files changed, 79 insertions(+), 119 deletions(-) create mode 100644 board/samsung/common/sromc.c diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 7f493a8e8fd..28f187cc8dd 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -661,6 +661,7 @@ config ARCH_EXYNOS select DM select DM_GPIO select DM_I2C + select DM_ETH select DM_KEYBOARD select DM_SERIAL select DM_SPI diff --git a/arch/arm/dts/exynos5250-smdk5250.dts b/arch/arm/dts/exynos5250-smdk5250.dts index e542a790761..afe0cca48a9 100644 --- a/arch/arm/dts/exynos5250-smdk5250.dts +++ b/arch/arm/dts/exynos5250-smdk5250.dts @@ -41,6 +41,7 @@ }; sromc@1225 { + compatible = "samsung,exynos5-sromc"; bank = <1>; srom-timing = <1 9 12 1 6 1 1>; width = <2>; diff --git a/arch/arm/mach-exynos/include/mach/sromc.h b/arch/arm/mach-exynos/include/mach/sromc.h index 15c9ccc723d..ac229e0d169 100644 --- a/arch/arm/mach-exynos/include/mach/sromc.h +++ b/arch/arm/mach-exynos/include/mach/sromc.h @@ -33,22 +33,4 @@ struct s5p_sromc { /* Configure the Band Width and Bank Control Regs for required SROMC Bank */ void s5p_config_sromc(u32 srom_bank, u32 srom_bw_conf, u32 srom_bc_conf); -enum { - FDT_SROM_PMC, - FDT_SROM_TACP, - FDT_SROM_TAH, - FDT_SROM_TCOH, - FDT_SROM_TACC, - FDT_SROM_TCOS, - FDT_SROM_TACS, - - FDT_SROM_TIMING_COUNT, -}; - -struct fdt_sromc { - u8 bank;/* srom bank number */ - u8 width; /* bus width in bytes */ - unsigned int timing[FDT_SROM_TIMING_COUNT]; /* timing parameters */ -}; - #endif /* __ASM_ARCH_SROMC_H_ */ diff --git a/board/samsung/common/Makefile b/board/samsung/common/Makefile index 3593c77cbc2..d31b81abf1e 100644 --- a/board/samsung/common/Makefile +++ b/board/samsung/common/Makefile @@ -7,7 +7,7 @@ obj-$(CONFIG_USB_GADGET_DOWNLOAD) += gadget.o obj-$(CONFIG_MISC_COMMON) += misc.o ifndef CONFIG_SPL_BUILD -obj-$(CONFIG_BOARD_COMMON) += board.o +obj-$(CONFIG_BOARD_COMMON) += board.o sromc.o ifdef CONFIG_EXYNOS5_DT obj-y += exynos5-dt.o obj-$(CONFIG_BOARD_TYPES) += exynos5-dt-types.o diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c index 104d2a65746..1c2fe025e89 100644 --- a/board/samsung/common/board.c +++ b/board/samsung/common/board.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -195,83 +194,6 @@ int power_init_board(void) } #endif -#ifdef CONFIG_SMC911X -static int decode_sromc(const void *blob, struct fdt_sromc *config) -{ - int err; - int node; - - node = fdtdec_next_compatible(blob, 0, COMPAT_SAMSUNG_EXYNOS5_SROMC); - if (node < 0) { - debug("Could not find SROMC node\n"); - return node; - } - - config->bank = fdtdec_get_int(blob, node, "bank", 0); - config->width = fdtdec_get_int(blob, node, "width", 2); - - err = fdtdec_get_int_array(blob, node, "srom-timing", config->timing, - FDT_SROM_TIMING_COUNT); - if (err < 0) { - debug("Could not decode SROMC configuration Error: %s\n", - fdt_strerror(err)); - return -FDT_ERR_NOTFOUND; - } - return 0; -} -#endif - -int board_eth_init(struct bd_info *bis) -{ -#ifdef CONFIG_SMC911X - u32 smc_bw_conf, smc_bc_conf; - struct fdt_sromc config; - fdt_addr_t base_addr; - int node; - - node = decode_sromc(gd->fdt_blob, &config); - if (node < 0) { - debug("%s: Could not find sromc configuration\n", __func__); - return 0; - } - node = fdtdec_next_compat
Re: [PULL] u-boot-mips
On Sun, Jul 18, 2021 at 10:04:26PM +0200, Daniel Schwierzeck wrote: > Gitlab: > https://source.denx.de/u-boot/custodians/u-boot-mips/-/pipelines/8294 > > Azure: > > https://dev.azure.com/danielschwierzeck/u-boot/_build/results?buildId=25&view=results > > > The following changes since commit f929ce50727bf1019323d6c199dfd3a5755c5474: > > Merge branch '2021-07-16-cleanup-image-support' (2021-07-17 11:39:50 -0400) > > are available in the Git repository at: > > https://source.denx.de/u-boot/custodians/u-boot-mips.git/ > tags/mips-pull-2021-07-18 > > for you to fetch changes up to 526ceb43878bfcaaeffbb988e363e89500695bee: > > MIPS: malta: enable PCI driver model (2021-07-18 20:37:39 +0200) > Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
Re: [PATCH v2 4/5] efi: Use 16-bit unicode strings
On Mon, Jul 19, 2021 at 02:41:46AM +0200, Heinrich Schuchardt wrote: > On 7/18/21 10:14 PM, Simon Glass wrote: > > At present we use wide characters for unicode but this is not necessary. > > Change the code to use the 'u' literal instead. This helps to fix build > > warnings for sandbox on rpi. > > > > Signed-off-by: Simon Glass > > Suggested-by: Heinrich Schuchardt > > According to https://en.cppreference.com/w/c/language/string_literal u"" > literals are supported since C11. In our Makefile we have CSTD_FLAG := > -std=gnu11. > > Once we have changed all u"" to L"" we can remove -fshort-wchar from our > Makefiles. [snip] > > diff --git a/include/efi_loader.h b/include/efi_loader.h > > index b81180cfda8..cad7961942b 100644 > > --- a/include/efi_loader.h > > +++ b/include/efi_loader.h > > @@ -924,7 +924,7 @@ efi_status_t efi_capsule_authenticate(const void > > *capsule, > > efi_uintn_t capsule_size, > > void **image, efi_uintn_t *image_size); > > > > -#define EFI_CAPSULE_DIR L"\\EFI\\UpdateCapsule\\" > > +#define EFI_CAPSULE_DIR u"\\EFI\\UpdateCapsule\\" This brings us more, not less, instances of u"" rather than L"". Should we perhaps make a coccinelle "spatch" to update everything globally and drop -fshort-wchar ? -- Tom signature.asc Description: PGP signature
Re: [PATCH v2 5/5] sandbox: Detect the host bit size automatically
On 7/18/21 10:14 PM, Simon Glass wrote: At present if you build sandbox on a 32-bit host a lot of errors are produced. This is because CONFIG_HOST_64BIT is enabled by default. It is quite annoying to have to change that manually before building sandbox. It is also quite confusing for new users. Add a way to detect the setting and add the appropriate CONFIG_HOST_64BIT=y or CONFIG_HOST_32BIT=y to the defconfig, to avoid this issue. Signed-off-by: Simon Glass --- Changes in v2: - Drop patches previously applied - Put all the packages in gcc.rst Makefile | 11 ++- arch/sandbox/Kconfig | 13 - scripts/kconfig/Makefile | 14 +- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index bc404c8f989..0257d202597 100644 --- a/Makefile +++ b/Makefile @@ -565,8 +565,17 @@ export KBUILD_DEFCONFIG KBUILD_KCONFIG config: scripts_basic outputmakefile FORCE $(Q)$(MAKE) $(build)=scripts/kconfig $@ +# If nothing is specified explicitly, detect the bit size for sandbox, +# referred to from arch/sandbox/Kconfig +# Add it to the end of the defconfig file %config: scripts_basic outputmakefile FORCE - $(Q)$(MAKE) $(build)=scripts/kconfig $@ + $(Q)if test -f $(srctree)/configs/$@ && \ + ! grep -Eq "CONFIG_HOST_(32|64)BIT=y" $(srctree)/configs/$@; then \ + echo '#include \nint main(void) { printf("CONFIG_HOST_%dBIT=y\\n", __WORDSIZE); return 0; }' \ +| gcc -x c - -o get_word_size; \ + extra=$$(./get_word_size); \ + fi; \ + $(MAKE) $(build)=scripts/kconfig EXTRA_DEFCONFIG=$$extra $@ else # === diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index f83282d9d56..01b2a3fcad1 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -35,12 +35,12 @@ config SYS_CONFIG_NAME choice prompt "Run sandbox on 32/64-bit host" - default HOST_64BIT + default HOST_DETECT_BIT help - Sandbox can be built on 32-bit and 64-bit hosts. - The default is to build on a 64-bit host and run - on a 64-bit host. If you want to run sandbox on - a 32-bit host, change it here. + Sandbox can be built on 32-bit and 64-bit hosts. This is generally + auto-detected but you can force a particular word size here. If you + see strange warnings about SANDBOX_BITS_PER_LONG then you may have + selected the wrong value. config HOST_32BIT bool "32-bit host" @@ -49,6 +49,9 @@ config HOST_32BIT config HOST_64BIT bool "64-bit host" +config HOST_DETECT_BIT %s/BIT/BITNESS/ HOST_DETECT_BITNESS would better express the meaning of the flag. Cf. https://en.wiktionary.org/wiki/bitness + bool "Auto-detect bit size" The flag does not enable detecting the size of a bit. boot "Auto-detect bitness." Best regards Heinrich + endchoice config SANDBOX_CRASH_RESET diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index d52128425ce..8e14db7ade3 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -12,6 +12,9 @@ PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig \ # Set SRCARCH to .. fake this Makefile. SRCARCH := .. +# For U-Boot, EXTRA_DEFCONFIG contains a line to be added to the defconfig +# before processing. If empty, no line is added. + ifdef KBUILD_KCONFIG Kconfig := $(KBUILD_KCONFIG) else @@ -92,8 +95,17 @@ else endif endif +# If EXTRA_DEFCONFIG is defined, add it to the end of the defconfig, before +# processing. This allows the caller to change a setting on the fly %_defconfig: $(obj)/conf - $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) + $(Q)defconfig="$(srctree)/arch/$(SRCARCH)/configs/$@"; \ + if [ -n "$(EXTRA_DEFCONFIG)" ]; then \ + cat $$defconfig >defconfig_tmp; \ + echo $(EXTRA_DEFCONFIG) >>defconfig_tmp; \ + $< $(silent) --defconfig=defconfig_tmp $(Kconfig); \ + else \ + $< $(silent) --defconfig=$$defconfig $(Kconfig); \ + fi # Added for U-Boot (backward compatibility) %_config: %_defconfig
Re: [PATCH v2 4/5] efi: Use 16-bit unicode strings
On 7/18/21 10:14 PM, Simon Glass wrote: At present we use wide characters for unicode but this is not necessary. Change the code to use the 'u' literal instead. This helps to fix build warnings for sandbox on rpi. Signed-off-by: Simon Glass Suggested-by: Heinrich Schuchardt According to https://en.cppreference.com/w/c/language/string_literal u"" literals are supported since C11. In our Makefile we have CSTD_FLAG := -std=gnu11. Once we have changed all u"" to L"" we can remove -fshort-wchar from our Makefiles. Reviewed-by: Heinrich Schuchardt --- (no changes since v1) include/efi_loader.h | 2 +- lib/efi_loader/efi_bootmgr.c | 12 +- lib/efi_loader/efi_boottime.c | 2 +- lib/efi_loader/efi_capsule.c | 20 ++-- lib/efi_loader/efi_helper.c | 2 +- lib/efi_loader/efi_image_loader.c | 8 +- lib/efi_loader/efi_setup.c| 20 ++-- lib/efi_loader/efi_signature.c| 4 +- lib/efi_loader/efi_string.c | 2 +- lib/efi_loader/efi_var_common.c | 14 +-- lib/efi_loader/efi_variable.c | 6 +- lib/efi_loader/efi_variable_tee.c | 2 +- lib/efi_loader/helloworld.c | 40 +++ lib/efi_selftest/dtbdump.c| 82 +++--- lib/efi_selftest/efi_selftest.c | 2 +- lib/efi_selftest/efi_selftest_block_device.c | 6 +- lib/efi_selftest/efi_selftest_devicepath.c| 2 +- lib/efi_selftest/efi_selftest_exception.c | 2 +- lib/efi_selftest/efi_selftest_fdt.c | 6 +- lib/efi_selftest/efi_selftest_hii.c | 8 +- lib/efi_selftest/efi_selftest_load_file.c | 4 +- lib/efi_selftest/efi_selftest_loadimage.c | 4 +- .../efi_selftest_miniapp_exception.c | 4 +- lib/efi_selftest/efi_selftest_miniapp_exit.c | 8 +- .../efi_selftest_miniapp_return.c | 2 +- lib/efi_selftest/efi_selftest_reset.c | 2 +- lib/efi_selftest/efi_selftest_textoutput.c| 12 +- .../efi_selftest_unicode_collation.c | 38 +++ lib/efi_selftest/efi_selftest_util.c | 106 +- lib/efi_selftest/efi_selftest_variables.c | 22 ++-- .../efi_selftest_variables_runtime.c | 4 +- lib/efi_selftest/initrddump.c | 60 +- 32 files changed, 254 insertions(+), 254 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index b81180cfda8..cad7961942b 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -924,7 +924,7 @@ efi_status_t efi_capsule_authenticate(const void *capsule, efi_uintn_t capsule_size, void **image, efi_uintn_t *image_size); -#define EFI_CAPSULE_DIR L"\\EFI\\UpdateCapsule\\" +#define EFI_CAPSULE_DIR u"\\EFI\\UpdateCapsule\\" /* Hook at initialization */ efi_status_t efi_launch_capsules(void); diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 1fe19237f9a..8c04ecbdc83 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -46,8 +46,8 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, void **load_options) { struct efi_load_option lo; - u16 varname[] = L"Boot"; - u16 hexmap[] = L"0123456789ABCDEF"; + u16 varname[] = u"Boot"; + u16 hexmap[] = u"0123456789ABCDEF"; void *load_option; efi_uintn_t size; efi_status_t ret; @@ -83,7 +83,7 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS; - ret = efi_set_variable_int(L"BootCurrent", + ret = efi_set_variable_int(u"BootCurrent", &efi_global_variable_guid, attributes, sizeof(n), &n, false); if (ret != EFI_SUCCESS) @@ -149,7 +149,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options) /* BootNext */ size = sizeof(bootnext); - ret = efi_get_variable_int(L"BootNext", + ret = efi_get_variable_int(u"BootNext", &efi_global_variable_guid, NULL, &size, &bootnext, NULL); if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) { @@ -158,7 +158,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options) log_err("BootNext must be 16-bit integer\n"); /* delete BootNext */ - ret = efi_set_variable_int(L"BootNext", + ret = efi_set_variable_int(u"BootNext", &efi_global_variable_
Re: Pull request for efi-2021-10-rc1-2
On Sun, Jul 18, 2021 at 03:56:05PM +0200, Heinrich Schuchardt wrote: > Dear Tom, > > The following changes since commit f929ce50727bf1019323d6c199dfd3a5755c5474: > > Merge branch '2021-07-16-cleanup-image-support' (2021-07-17 11:39:50 > -0400) > > are available in the Git repository at: > > https://source.denx.de/u-boot/custodians/u-boot-efi.git > tags/efi-2021-10-rc1-2 > > for you to fetch changes up to 316ab801c0d91c02b21b8be1e3db7e69555364e9: > > doc: Update CapsuleUpdate READMEs (2021-07-18 14:43:56 +0200) > > Gitlab showed no problems: > https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/8290 > Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
[PATCH] lib: rsa: Extract public key from private key if keyfile argument is used
If the 'keyfile' (-G) argument is used, there is little value to require 'keydir' (-k) argument since the public key can also be extracted from the private key itself. Signed-off-by: Donald Chan --- lib/rsa/rsa-sign.c | 28 +--- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c index f4ed11e74a..f70f352311 100644 --- a/lib/rsa/rsa-sign.c +++ b/lib/rsa/rsa-sign.c @@ -49,16 +49,16 @@ static int rsa_err(const char *msg) } /** - * rsa_pem_get_pub_key() - read a public key from a .crt file + * rsa_pem_get_pub_key() - read a public key from a private key file or .crt file * - * @keydir:Directory containins the key - * @name Name of key file (will have a .crt extension) + * @keydir:Directory containing the key, can be NULL + * @name Name of key file (will apply a .crt extension if keydir is not NULL) * @evpp Returns EVP_PKEY object, or NULL on failure * @return 0 if ok, -ve on error (in which case *evpp will be set to NULL) */ static int rsa_pem_get_pub_key(const char *keydir, const char *name, EVP_PKEY **evpp) { - char path[1024]; + char path[1024] = {0}; EVP_PKEY *key = NULL; X509 *cert; FILE *f; @@ -68,7 +68,10 @@ static int rsa_pem_get_pub_key(const char *keydir, const char *name, EVP_PKEY ** return -EINVAL; *evpp = NULL; - snprintf(path, sizeof(path), "%s/%s.crt", keydir, name); + if (keydir && name) + snprintf(path, sizeof(path), "%s/%s.crt", keydir, name); + else if (name) + snprintf(path, sizeof(path), "%s", name); f = fopen(path, "r"); if (!f) { fprintf(stderr, "Couldn't open RSA certificate: '%s': %s\n", @@ -76,7 +79,13 @@ static int rsa_pem_get_pub_key(const char *keydir, const char *name, EVP_PKEY ** return -EACCES; } - /* Read the certificate */ + /* See if it contains a PEM private key? */ + if (PEM_read_PrivateKey(f, evpp, NULL, path)) { + fclose(f); + return 0; + } + + /* Not a PEM private key, read the certificate */ cert = NULL; if (!PEM_read_X509(f, &cert, NULL, NULL)) { rsa_err("Couldn't read certificate"); @@ -672,7 +681,12 @@ int rsa_add_verify_data(struct image_sign_info *info, void *keydest) if (ret) return ret; } - ret = rsa_get_pub_key(info->keydir, info->keyname, e, &pkey); + if (info->keydir && info->keyname) + ret = rsa_get_pub_key(info->keydir, info->keyname, e, &pkey); + else if (info->keyfile) + ret = rsa_get_pub_key(NULL, info->keyfile, e, &pkey); + else + ret = -EINVAL; if (ret) goto err_get_pub_key; #if OPENSSL_VERSION_NUMBER < 0x1010L || \ -- 2.16.6
[PATCH v2 10/10] sandbox: tpm: Support extending a PCR multiple times
It is fairly easy to handle this case and it makes the emulator more useful, since PCRs are commonly extended several times. Add support for this, using U-Boot's sha256 support. For now sandbox only supports a single PCR, but that is enough for the tests that currently exist. Signed-off-by: Simon Glass --- Changes in v2: - Drop the constant sandbox_extended_once_pcr since we can calculate it - Update the commit message to explain that there is only one PCR drivers/tpm/tpm2_tis_sandbox.c | 24 ++-- test/py/tests/test_tpm2.py | 18 +- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/drivers/tpm/tpm2_tis_sandbox.c b/drivers/tpm/tpm2_tis_sandbox.c index 3c4bbcdf2ee..ac6eb143539 100644 --- a/drivers/tpm/tpm2_tis_sandbox.c +++ b/drivers/tpm/tpm2_tis_sandbox.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "sandbox_common.h" /* Hierarchies */ @@ -39,13 +40,6 @@ enum tpm2_cap_tpm_property { #define SANDBOX_TPM_PCR_NB 1 -static const u8 sandbox_extended_once_pcr[] = { - 0xf5, 0xa5, 0xfd, 0x42, 0xd1, 0x6a, 0x20, 0x30, - 0x27, 0x98, 0xef, 0x6e, 0xd3, 0x09, 0x97, 0x9b, - 0x43, 0x00, 0x3d, 0x23, 0x20, 0xd9, 0xf0, 0xe8, - 0xea, 0x98, 0x31, 0xa9, 0x27, 0x59, 0xfb, 0x4b, -}; - /* * Information about our TPM emulation. This is preserved in the sandbox * state file if enabled. @@ -407,15 +401,17 @@ static int sandbox_tpm2_extend(struct udevice *dev, int pcr_index, const u8 *extension) { struct sandbox_tpm2 *tpm = dev_get_priv(dev); - int i; + sha256_context ctx; + + /* Zero the PCR if this is the first use */ + if (!tpm->pcr_extensions[pcr_index]) + memset(tpm->pcr[pcr_index], '\0', TPM2_DIGEST_LEN); - /* Only simulate the first extensions from all '0' with only '0' */ - for (i = 0; i < TPM2_DIGEST_LEN; i++) - if (tpm->pcr[pcr_index][i] || extension[i]) - return TPM2_RC_FAILURE; + sha256_starts(&ctx); + sha256_update(&ctx, tpm->pcr[pcr_index], TPM2_DIGEST_LEN); + sha256_update(&ctx, extension, TPM2_DIGEST_LEN); + sha256_finish(&ctx, tpm->pcr[pcr_index]); - memcpy(tpm->pcr[pcr_index], sandbox_extended_once_pcr, - TPM2_DIGEST_LEN); tpm->pcr_extensions[pcr_index]++; return 0; diff --git a/test/py/tests/test_tpm2.py b/test/py/tests/test_tpm2.py index 70f906da511..ac04f7191ec 100644 --- a/test/py/tests/test_tpm2.py +++ b/test/py/tests/test_tpm2.py @@ -216,7 +216,9 @@ def test_tpm2_pcr_extend(u_boot_console): output = u_boot_console.run_command('echo $?') assert output.endswith('0') -read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % ram) +# Read the value back into a different place so we can still use 'ram' as +# our zero bytes +read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % (ram + 0x20)) output = u_boot_console.run_command('echo $?') assert output.endswith('0') assert 'f5 a5 fd 42 d1 6a 20 30 27 98 ef 6e d3 09 97 9b' in read_pcr @@ -226,6 +228,20 @@ def test_tpm2_pcr_extend(u_boot_console): new_updates = int(re.findall(r'\d+', str)[0]) assert (updates + 1) == new_updates +u_boot_console.run_command('tpm2 pcr_extend 0 0x%x' % ram) +output = u_boot_console.run_command('echo $?') +assert output.endswith('0') + +read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % (ram + 0x20)) +output = u_boot_console.run_command('echo $?') +assert output.endswith('0') +assert '7a 05 01 f5 95 7b df 9c b3 a8 ff 49 66 f0 22 65' in read_pcr +assert 'f9 68 65 8b 7a 9c 62 64 2c ba 11 65 e8 66 42 f5' in read_pcr + +str = re.findall(r'\d+ known updates', read_pcr)[0] +new_updates = int(re.findall(r'\d+', str)[0]) +assert (updates + 2) == new_updates + @pytest.mark.buildconfigspec('cmd_tpm_v2') def test_tpm2_cleanup(u_boot_console): """Ensure the TPM is cleared from password or test related configuration.""" -- 2.32.0.402.g57bb445576-goog
[PATCH v2 09/10] sandbox: tpm: Correct handling of SANDBOX_TPM_PCR_NB
This is the number of PCRs, so the current check is off by one. Also the map itself should not be checked, just the resulting pcr_index, to avoid confusing people who read the code. Fix these problems. Signed-off-by: Simon Glass --- Changes in v2: - Add new patch to correct handling of SANDBOX_TPM_PCR_NB drivers/tpm/tpm2_tis_sandbox.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/tpm/tpm2_tis_sandbox.c b/drivers/tpm/tpm2_tis_sandbox.c index ed9c9a0bc9f..3c4bbcdf2ee 100644 --- a/drivers/tpm/tpm2_tis_sandbox.c +++ b/drivers/tpm/tpm2_tis_sandbox.c @@ -642,15 +642,8 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const u8 *sendbuf, for (i = 0; i < pcr_array_sz; i++) pcr_map += (u64)sent[i] << (i * 8); - if (pcr_map >> SANDBOX_TPM_PCR_NB) { - printf("Sandbox TPM handles up to %d PCR(s)\n", - SANDBOX_TPM_PCR_NB); - rc = TPM2_RC_VALUE; - return sandbox_tpm2_fill_buf(recv, recv_len, tag, rc); - } - if (!pcr_map) { - printf("Empty PCR map.\n"); + printf("Empty PCR map\n"); rc = TPM2_RC_VALUE; return sandbox_tpm2_fill_buf(recv, recv_len, tag, rc); } @@ -659,6 +652,13 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const u8 *sendbuf, if (pcr_map & BIT(i)) pcr_index = i; + if (pcr_index >= SANDBOX_TPM_PCR_NB) { + printf("Invalid index %d, sandbox TPM handles up to %d PCR(s)\n", + pcr_index, SANDBOX_TPM_PCR_NB); + rc = TPM2_RC_VALUE; + return sandbox_tpm2_fill_buf(recv, recv_len, tag, rc); + } + /* Write tag */ put_unaligned_be16(tag, recv); recv += sizeof(tag); @@ -692,9 +692,9 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const u8 *sendbuf, pcr_index = get_unaligned_be32(sendbuf + sizeof(tag) + sizeof(length) + sizeof(command)); - if (pcr_index > SANDBOX_TPM_PCR_NB) { - printf("Sandbox TPM handles up to %d PCR(s)\n", - SANDBOX_TPM_PCR_NB); + if (pcr_index >= SANDBOX_TPM_PCR_NB) { + printf("Invalid index %d, sandbox TPM handles up to %d PCR(s)\n", + pcr_index, SANDBOX_TPM_PCR_NB); rc = TPM2_RC_VALUE; } -- 2.32.0.402.g57bb445576-goog
[PATCH v2 08/10] sandbox: tpm: Support storing device state in tpm2
At present the tpm2 emulator does not support storing the device state. Add this so we can handle the normal vboot flow through the sandbox executables (VPL->SPL etc.) with the TPM contents staying in place. Note: sandbox has not yet been converted to use livetree for the state information, since livetree does not yet support writing to the tree. Signed-off-by: Simon Glass --- (no changes since v1) drivers/tpm/tpm2_tis_sandbox.c | 139 + 1 file changed, 139 insertions(+) diff --git a/drivers/tpm/tpm2_tis_sandbox.c b/drivers/tpm/tpm2_tis_sandbox.c index 1d38a79a867..ed9c9a0bc9f 100644 --- a/drivers/tpm/tpm2_tis_sandbox.c +++ b/drivers/tpm/tpm2_tis_sandbox.c @@ -79,6 +79,145 @@ struct sandbox_tpm2 { static struct sandbox_tpm2 s_state, *g_state; +/** + * sandbox_tpm2_read_state() - read the sandbox EC state from the state file + * + * If data is available, then blob and node will provide access to it. If + * not this function sets up an empty TPM. + * + * @blob: Pointer to device tree blob, or NULL if no data to read + * @node: Node offset to read from + */ +static int sandbox_tpm2_read_state(const void *blob, int node) +{ + struct sandbox_tpm2 *state = &s_state; + char prop_name[20]; + const char *prop; + int len; + int i; + + if (!blob) + return 0; + state->tests_done = fdtdec_get_int(blob, node, "tests-done", 0); + + for (i = 0; i < TPM2_HIERARCHY_NB; i++) { + snprintf(prop_name, sizeof(prop_name), "pw%d", i); + + prop = fdt_getprop(blob, node, prop_name, &len); + if (len > TPM2_DIGEST_LEN) + return log_msg_ret("pw", -E2BIG); + if (prop) { + memcpy(state->pw[i], prop, len); + state->pw_sz[i] = len; + } + } + + for (i = 0; i < TPM2_PROPERTY_NB; i++) { + snprintf(prop_name, sizeof(prop_name), "properties%d", i); + state->properties[i] = fdtdec_get_uint(blob, node, prop_name, + 0); + } + + for (i = 0; i < SANDBOX_TPM_PCR_NB; i++) { + int subnode; + + snprintf(prop_name, sizeof(prop_name), "pcr%d", i); + subnode = fdt_subnode_offset(blob, node, prop_name); + if (subnode < 0) + continue; + prop = fdt_getprop(blob, subnode, "value", &len); + if (len != TPM2_DIGEST_LEN) + return log_msg_ret("pcr", -E2BIG); + memcpy(state->pcr[i], prop, TPM2_DIGEST_LEN); + state->pcr_extensions[i] = fdtdec_get_uint(blob, subnode, + "extensions", 0); + } + + for (i = 0; i < NV_SEQ_COUNT; i++) { + struct nvdata_state *nvd = &state->nvdata[i]; + + sprintf(prop_name, "nvdata%d", i); + prop = fdt_getprop(blob, node, prop_name, &len); + if (len > NV_DATA_SIZE) + return log_msg_ret("nvd", -E2BIG); + if (prop) { + memcpy(nvd->data, prop, len); + nvd->length = len; + nvd->present = true; + } + } + s_state.valid = true; + + return 0; +} + +/** + * sandbox_tpm2_write_state() - Write out our state to the state file + * + * The caller will ensure that there is a node ready for the state. The node + * may already contain the old state, in which case it is overridden. + * + * @blob: Device tree blob holding state + * @node: Node to write our state into + */ +static int sandbox_tpm2_write_state(void *blob, int node) +{ + const struct sandbox_tpm2 *state = g_state; + char prop_name[20]; + int i; + + if (!state) + return 0; + + /* +* We are guaranteed enough space to write basic properties. This is +* SANDBOX_STATE_MIN_SPACE. +* +* We could use fdt_add_subnode() to put each set of data in its +* own node - perhaps useful if we add access information to each. +*/ + fdt_setprop_u32(blob, node, "tests-done", state->tests_done); + + for (i = 0; i < TPM2_HIERARCHY_NB; i++) { + if (state->pw_sz[i]) { + snprintf(prop_name, sizeof(prop_name), "pw%d", i); + fdt_setprop(blob, node, prop_name, state->pw[i], + state->pw_sz[i]); + } + } + + for (i = 0; i < TPM2_PROPERTY_NB; i++) { + snprintf(prop_name, sizeof(prop_name), "properties%d", i); + fdt_setprop_u32(blob, node, prop_name, state->properties[i]); + } + + for (i = 0; i < SANDBOX_TPM_PCR_NB; i++) { + int subnode; + + snprintf(prop_name, sizeof(prop_name), "pcr%d", i); +
[PATCH v2 07/10] sandbox: tpm: Support nvdata in TPM2
Add support for this feature in the TPM2 emulator, to support Chromium OS vboot. Signed-off-by: Simon Glass --- (no changes since v1) drivers/tpm/tpm2_tis_sandbox.c | 68 ++ include/tpm-v2.h | 2 + 2 files changed, 70 insertions(+) diff --git a/drivers/tpm/tpm2_tis_sandbox.c b/drivers/tpm/tpm2_tis_sandbox.c index c287ca2278f..1d38a79a867 100644 --- a/drivers/tpm/tpm2_tis_sandbox.c +++ b/drivers/tpm/tpm2_tis_sandbox.c @@ -11,6 +11,7 @@ #include #include #include +#include "sandbox_common.h" /* Hierarchies */ enum tpm2_hierarchy { @@ -73,6 +74,7 @@ struct sandbox_tpm2 { u32 properties[TPM2_PROPERTY_NB]; u8 pcr[SANDBOX_TPM_PCR_NB][TPM2_DIGEST_LEN]; u32 pcr_extensions[SANDBOX_TPM_PCR_NB]; + struct nvdata_state nvdata[NV_SEQ_COUNT]; }; static struct sandbox_tpm2 s_state, *g_state; @@ -109,6 +111,10 @@ static int sandbox_tpm2_check_session(struct udevice *dev, u32 command, u16 tag, case TPM2_CC_DAM_RESET: case TPM2_CC_DAM_PARAMETERS: case TPM2_CC_PCR_EXTEND: + case TPM2_CC_NV_READ: + case TPM2_CC_NV_WRITE: + case TPM2_CC_NV_WRITELOCK: + case TPM2_CC_NV_DEFINE_SPACE: if (tag != TPM2_ST_SESSIONS) { printf("Session required for command 0x%x\n", command); return TPM2_RC_AUTH_CONTEXT; @@ -137,6 +143,10 @@ static int sandbox_tpm2_check_session(struct udevice *dev, u32 command, u16 tag, break; case TPM2_RH_PLATFORM: *hierarchy = TPM2_HIERARCHY_PLATFORM; + if (command == TPM2_CC_NV_READ || + command == TPM2_CC_NV_WRITE || + command == TPM2_CC_NV_WRITELOCK) + *auth += sizeof(u32); break; default: printf("Wrong handle 0x%x\n", handle); @@ -573,6 +583,64 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const u8 *sendbuf, sandbox_tpm2_fill_buf(recv, recv_len, tag, rc); break; + case TPM2_CC_NV_READ: { + int index, seq; + + index = get_unaligned_be32(sendbuf + TPM2_HDR_LEN + 4); + length = get_unaligned_be16(sent); + /* ignore offset */ + seq = sb_tpm_index_to_seq(index); + if (seq < 0) + return log_msg_ret("index", -EINVAL); + printf("tpm: nvread index=%#02x, len=%#02x, seq=%#02x\n", index, + length, seq); + *recv_len = TPM2_HDR_LEN + 6 + length; + memset(recvbuf, '\0', *recv_len); + put_unaligned_be32(length, recvbuf + 2); + sb_tpm_read_data(tpm->nvdata, seq, recvbuf, +TPM2_HDR_LEN + 4 + 2, length); + break; + } + case TPM2_CC_NV_WRITE: { + int index, seq; + + index = get_unaligned_be32(sendbuf + TPM2_HDR_LEN + 4); + length = get_unaligned_be16(sent); + sent += sizeof(u16); + + /* ignore offset */ + seq = sb_tpm_index_to_seq(index); + if (seq < 0) + return log_msg_ret("index", -EINVAL); + printf("tpm: nvwrite index=%#02x, len=%#02x, seq=%#02x\n", index, + length, seq); + memcpy(&tpm->nvdata[seq].data, sent, length); + tpm->nvdata[seq].present = true; + *recv_len = TPM2_HDR_LEN + 2; + memset(recvbuf, '\0', *recv_len); + break; + } + case TPM2_CC_NV_DEFINE_SPACE: { + int policy_size, index, seq; + + policy_size = get_unaligned_be16(sent + 12); + index = get_unaligned_be32(sent + 2); + sent += 14 + policy_size; + length = get_unaligned_be16(sent); + seq = sb_tpm_index_to_seq(index); + if (seq < 0) + return -EINVAL; + printf("tpm: define_space index=%x, len=%x, seq=%x, policy_size=%x\n", + index, length, seq, policy_size); + sb_tpm_define_data(tpm->nvdata, seq, length); + *recv_len = 12; + memset(recvbuf, '\0', *recv_len); + break; + } + case TPM2_CC_NV_WRITELOCK: + *recv_len = 12; + memset(recvbuf, '\0', *recv_len); + break; default: printf("TPM2 command %02x unknown in Sandbox\n", command); rc = TPM2_RC_COMMAND_CODE; diff --git a/include/tpm-v2.h b/include/tpm-v2.h index 247b3869676..949a13c917a 100644 --- a/include/tpm-v2.h +++ b/include/tpm-v2.h @@ -32,6 +32,8 @@ struct udevice; #define TPM2_MAX_TPM_PROPERTIES ((TPM2_MAX_CAP_BUFFER - sizeof(u32) /* TPM2_CAP *
[PATCH v2 06/10] sandbox: tpm: Track whether the state is valid
Add checking as to whether the current TPM state is valid, so we can implement reading/writing the state. Signed-off-by: Simon Glass --- (no changes since v1) drivers/tpm/tpm2_tis_sandbox.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/tpm/tpm2_tis_sandbox.c b/drivers/tpm/tpm2_tis_sandbox.c index 5e0bd304699..c287ca2278f 100644 --- a/drivers/tpm/tpm2_tis_sandbox.c +++ b/drivers/tpm/tpm2_tis_sandbox.c @@ -49,6 +49,7 @@ static const u8 sandbox_extended_once_pcr[] = { * Information about our TPM emulation. This is preserved in the sandbox * state file if enabled. * + * @valid: true if this is valid (only used in s_state) * @init_done: true if open() has been called * @startup_done: true if TPM2_CC_STARTUP has been processed * @tests_done: true if TPM2_CC_SELF_TEST has be processed @@ -62,6 +63,7 @@ static const u8 sandbox_extended_once_pcr[] = { * @nvdata: non-volatile data, used to store important things for the platform */ struct sandbox_tpm2 { + bool valid; /* TPM internal states */ bool init_done; bool startup_done; @@ -73,6 +75,8 @@ struct sandbox_tpm2 { u32 pcr_extensions[SANDBOX_TPM_PCR_NB]; }; +static struct sandbox_tpm2 s_state, *g_state; + /* * Check the tag validity depending on the command (authentication required or * not). If authentication is required, check it is valid. Update the auth @@ -606,11 +610,13 @@ static int sandbox_tpm2_probe(struct udevice *dev) /* Use the TPM v2 stack */ priv->version = TPM_V2; - memset(tpm, 0, sizeof(*tpm)); - priv->pcr_count = 32; priv->pcr_select_min = 2; + if (s_state.valid) + memcpy(tpm, &s_state, sizeof(*tpm)); + g_state = tpm; + return 0; } -- 2.32.0.402.g57bb445576-goog
[PATCH v2 05/10] sandbox: tpm: Finish comments for struct sandbox_tpm2
Tidy up the missing comments for this struct. Signed-off-by: Simon Glass --- (no changes since v1) drivers/tpm/tpm2_tis_sandbox.c | 20 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/tpm/tpm2_tis_sandbox.c b/drivers/tpm/tpm2_tis_sandbox.c index 24c804a5645..5e0bd304699 100644 --- a/drivers/tpm/tpm2_tis_sandbox.c +++ b/drivers/tpm/tpm2_tis_sandbox.c @@ -45,19 +45,31 @@ static const u8 sandbox_extended_once_pcr[] = { 0xea, 0x98, 0x31, 0xa9, 0x27, 0x59, 0xfb, 0x4b, }; +/* + * Information about our TPM emulation. This is preserved in the sandbox + * state file if enabled. + * + * @init_done: true if open() has been called + * @startup_done: true if TPM2_CC_STARTUP has been processed + * @tests_done: true if TPM2_CC_SELF_TEST has be processed + * @pw: TPM password per hierarchy + * @pw_sz: Size of each password in bytes + * @properties: TPM properties + * @pcr: TPM Platform Configuration Registers. Each of these holds a hash and + * can be 'extended' a number of times, meaning another hash is added into + * its value (initial value all zeroes) + * @pcr_extensions: Number of times each PCR has been extended (starts at 0) + * @nvdata: non-volatile data, used to store important things for the platform + */ struct sandbox_tpm2 { /* TPM internal states */ bool init_done; bool startup_done; bool tests_done; - /* TPM password per hierarchy */ char pw[TPM2_HIERARCHY_NB][TPM2_DIGEST_LEN + 1]; int pw_sz[TPM2_HIERARCHY_NB]; - /* TPM properties */ u32 properties[TPM2_PROPERTY_NB]; - /* TPM PCRs */ u8 pcr[SANDBOX_TPM_PCR_NB][TPM2_DIGEST_LEN]; - /* TPM PCR extensions */ u32 pcr_extensions[SANDBOX_TPM_PCR_NB]; }; -- 2.32.0.402.g57bb445576-goog
[PATCH v2 04/10] sandbox: tpm: Correct handling of get-capability
This function current handles the kernel case incorrectly. Fix it, and use the shorter TPM_HDR_LEN while we are here. Signed-off-by: Simon Glass --- (no changes since v1) drivers/tpm/tpm_tis_sandbox.c | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/tpm/tpm_tis_sandbox.c b/drivers/tpm/tpm_tis_sandbox.c index 85b22afa4d9..efbeb00ab63 100644 --- a/drivers/tpm/tpm_tis_sandbox.c +++ b/drivers/tpm/tpm_tis_sandbox.c @@ -140,16 +140,13 @@ static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, printf("Get flags index %#02x\n", index); *recv_len = 22; memset(recvbuf, '\0', *recv_len); - data = recvbuf + TPM_RESPONSE_HEADER_LENGTH + - sizeof(uint32_t); + data = recvbuf + TPM_HDR_LEN + sizeof(uint32_t); switch (index) { case FIRMWARE_NV_INDEX: break; case KERNEL_NV_INDEX: handle_cap_flag_space(&data, index); - *recv_len = data - recvbuf - - TPM_RESPONSE_HEADER_LENGTH - - sizeof(uint32_t); + *recv_len = data - recvbuf; break; case TPM_CAP_FLAG_PERMANENT: { struct tpm_permanent_flags *pflags; @@ -166,15 +163,12 @@ static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, printf(" ** Unknown flags index %x\n", index); return -ENOSYS; } - put_unaligned_be32(*recv_len, - recvbuf + - TPM_RESPONSE_HEADER_LENGTH); + put_unaligned_be32(*recv_len, recvbuf + TPM_HDR_LEN); break; case TPM_CAP_NV_INDEX: index = get_unaligned_be32(sendbuf + 18); printf("Get cap nv index %#02x\n", index); - put_unaligned_be32(22, recvbuf + - TPM_RESPONSE_HEADER_LENGTH); + put_unaligned_be32(22, recvbuf + TPM_HDR_LEN); break; default: printf(" ** Unknown 0x65 command type %#02x\n", -- 2.32.0.402.g57bb445576-goog
[PATCH v2 02/10] sandbox: tpm: Tidy up reading and writing of device state
At present this code assumes that the TPM data has been read but this may not be the case. Refactor the code to use a separate pointer so we know the current state of the data. Add error checking for the data size. Signed-off-by: Simon Glass --- (no changes since v1) drivers/tpm/tpm_tis_sandbox.c | 35 --- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/tpm/tpm_tis_sandbox.c b/drivers/tpm/tpm_tis_sandbox.c index 294d98da606..f22ed846f0a 100644 --- a/drivers/tpm/tpm_tis_sandbox.c +++ b/drivers/tpm/tpm_tis_sandbox.c @@ -20,7 +20,7 @@ static struct tpm_state { bool valid; struct nvdata_state nvdata[NV_SEQ_COUNT]; -} g_state; +} s_state, *g_state; /** * sandbox_tpm_read_state() - read the sandbox EC state from the state file @@ -33,6 +33,7 @@ static struct tpm_state { */ static int sandbox_tpm_read_state(const void *blob, int node) { + struct tpm_state *state = &s_state; const char *prop; int len; int i; @@ -41,22 +42,27 @@ static int sandbox_tpm_read_state(const void *blob, int node) return 0; for (i = 0; i < NV_SEQ_COUNT; i++) { + struct nvdata_state *nvd = &state->nvdata[i]; char prop_name[20]; sprintf(prop_name, "nvdata%d", i); prop = fdt_getprop(blob, node, prop_name, &len); - if (prop && len == NV_DATA_SIZE) { - memcpy(g_state.nvdata[i].data, prop, NV_DATA_SIZE); - g_state.nvdata[i].present = true; + if (len >= NV_DATA_SIZE) + return log_msg_ret("nvd", -E2BIG); + if (prop) { + memcpy(nvd->data, prop, len); + nvd->length = len; + nvd->present = true; } } - g_state.valid = true; + + s_state.valid = true; return 0; } /** - * cros_ec_write_state() - Write out our state to the state file + * sandbox_tpm_write_state() - Write out our state to the state file * * The caller will ensure that there is a node ready for the state. The node * may already contain the old state, in which case it is overridden. @@ -66,20 +72,25 @@ static int sandbox_tpm_read_state(const void *blob, int node) */ static int sandbox_tpm_write_state(void *blob, int node) { + const struct tpm_state *state = g_state; int i; + if (!state) + return 0; + /* * We are guaranteed enough space to write basic properties. * We could use fdt_add_subnode() to put each set of data in its * own node - perhaps useful if we add access informaiton to each. */ for (i = 0; i < NV_SEQ_COUNT; i++) { + const struct nvdata_state *nvd = &state->nvdata[i]; char prop_name[20]; - if (g_state.nvdata[i].present) { - sprintf(prop_name, "nvdata%d", i); - fdt_setprop(blob, node, prop_name, - g_state.nvdata[i].data, NV_DATA_SIZE); + if (nvd->present) { + snprintf(prop_name, sizeof(prop_name), "nvdata%d", i); + fdt_setprop(blob, node, prop_name, nvd->data, + nvd->length); } } @@ -233,7 +244,9 @@ static int sandbox_tpm_probe(struct udevice *dev) { struct tpm_state *tpm = dev_get_priv(dev); - memcpy(tpm, &g_state, sizeof(*tpm)); + if (s_state.valid) + memcpy(tpm, &s_state, sizeof(*tpm)); + g_state = tpm; return 0; } -- 2.32.0.402.g57bb445576-goog
[PATCH v2 03/10] sandbox: tpm: Support the define-space command
Add support for this command, moving away from the previous approach of hard-coding the initial data in the driver, now that the kernel-space data has to be set up by the higher-level vboot code. Signed-off-by: Simon Glass --- (no changes since v1) drivers/tpm/sandbox_common.c | 11 +++ drivers/tpm/sandbox_common.h | 12 drivers/tpm/tpm_tis_sandbox.c | 11 +++ 3 files changed, 34 insertions(+) diff --git a/drivers/tpm/sandbox_common.c b/drivers/tpm/sandbox_common.c index 13f5e030a5f..7e0b2502e35 100644 --- a/drivers/tpm/sandbox_common.c +++ b/drivers/tpm/sandbox_common.c @@ -64,3 +64,14 @@ void sb_tpm_write_data(struct nvdata_state nvdata[NV_SEQ_COUNT], else memcpy(&nvdata[seq].data, buf + data_ofs, length); } + +void sb_tpm_define_data(struct nvdata_state nvdata[NV_SEQ_COUNT], + enum sandbox_nv_space seq, int length) +{ + struct nvdata_state *nvd = &nvdata[seq]; + + if (length > NV_DATA_SIZE) + log_err("Invalid length %x (max %x)\n", length, NV_DATA_SIZE); + nvd->length = length; + nvd->present = true; +} diff --git a/drivers/tpm/sandbox_common.h b/drivers/tpm/sandbox_common.h index aa5292d7945..e822a200fd3 100644 --- a/drivers/tpm/sandbox_common.h +++ b/drivers/tpm/sandbox_common.h @@ -93,4 +93,16 @@ void sb_tpm_write_data(struct nvdata_state nvdata[NV_SEQ_COUNT], enum sandbox_nv_space seq, const u8 *buf, int data_ofs, int length); +/** + * sb_tpm_define_data() - Set up non-volatile data + * + * If @length is too large, an error is logged and nothing is written. + * + * @nvdata: Current nvdata state + * @seq: Sequence number to set up + * @length: Length of space in bytes + */ +void sb_tpm_define_data(struct nvdata_state nvdata[NV_SEQ_COUNT], + enum sandbox_nv_space seq, int length); + #endif diff --git a/drivers/tpm/tpm_tis_sandbox.c b/drivers/tpm/tpm_tis_sandbox.c index f22ed846f0a..85b22afa4d9 100644 --- a/drivers/tpm/tpm_tis_sandbox.c +++ b/drivers/tpm/tpm_tis_sandbox.c @@ -210,6 +210,17 @@ static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, memset(recvbuf, '\0', *recv_len); break; case TPM_CMD_NV_DEFINE_SPACE: + index = get_unaligned_be32(sendbuf + 12); + length = get_unaligned_be32(sendbuf + 77); + seq = sb_tpm_index_to_seq(index); + if (seq < 0) + return -EINVAL; + printf("tpm: define_space index=%#02x, len=%#02x, seq=%#02x\n", + index, length, seq); + sb_tpm_define_data(tpm->nvdata, seq, length); + *recv_len = 12; + memset(recvbuf, '\0', *recv_len); + break; case 0x15: /* pcr read */ case 0x5d: /* force clear */ case 0x6f: /* physical enable */ -- 2.32.0.402.g57bb445576-goog
[PATCH v2 01/10] sandbox: tpm: Split out common nvdata code
We want to support nvdata in TPM2 as well. To avoid code duplicating the associated code, move it into a common file. Drop the special-case logic for the kernel space. This can be handled by the higher-level code now, i.e. in vboot itself. Signed-off-by: Simon Glass --- (no changes since v1) drivers/tpm/Makefile | 4 +- drivers/tpm/sandbox_common.c | 66 drivers/tpm/sandbox_common.h | 96 + drivers/tpm/tpm_tis_sandbox.c | 111 +++--- 4 files changed, 172 insertions(+), 105 deletions(-) create mode 100644 drivers/tpm/sandbox_common.c create mode 100644 drivers/tpm/sandbox_common.h diff --git a/drivers/tpm/Makefile b/drivers/tpm/Makefile index f64d20067f8..c65be526700 100644 --- a/drivers/tpm/Makefile +++ b/drivers/tpm/Makefile @@ -6,11 +6,11 @@ obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm-uclass.o obj-$(CONFIG_TPM_ATMEL_TWI) += tpm_atmel_twi.o obj-$(CONFIG_TPM_TIS_INFINEON) += tpm_tis_infineon.o obj-$(CONFIG_TPM_TIS_LPC) += tpm_tis_lpc.o -obj-$(CONFIG_TPM_TIS_SANDBOX) += tpm_tis_sandbox.o +obj-$(CONFIG_TPM_TIS_SANDBOX) += tpm_tis_sandbox.o sandbox_common.o obj-$(CONFIG_TPM_ST33ZP24_I2C) += tpm_tis_st33zp24_i2c.o obj-$(CONFIG_TPM_ST33ZP24_SPI) += tpm_tis_st33zp24_spi.o obj-$(CONFIG_$(SPL_TPL_)TPM2_CR50_I2C) += cr50_i2c.o -obj-$(CONFIG_TPM2_TIS_SANDBOX) += tpm2_tis_sandbox.o +obj-$(CONFIG_TPM2_TIS_SANDBOX) += tpm2_tis_sandbox.o sandbox_common.o obj-$(CONFIG_TPM2_TIS_SPI) += tpm2_tis_spi.o obj-$(CONFIG_TPM2_FTPM_TEE) += tpm2_ftpm_tee.o diff --git a/drivers/tpm/sandbox_common.c b/drivers/tpm/sandbox_common.c new file mode 100644 index 000..13f5e030a5f --- /dev/null +++ b/drivers/tpm/sandbox_common.c @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Common features for sandbox TPM1 and TPM2 implementations + * + * Copyright 2021 Google LLC + */ + +#define LOG_CATEGORY UCLASS_TPM + +#include +#include +#include +#include +#include "sandbox_common.h" + +#define TPM_ERR_CODE_OFS (2 + 4) /* after tag and size */ + +int sb_tpm_index_to_seq(u32 index) +{ + index &= ~HR_NV_INDEX; + switch (index) { + case FIRMWARE_NV_INDEX: + return NV_SEQ_FIRMWARE; + case KERNEL_NV_INDEX: + return NV_SEQ_KERNEL; + case BACKUP_NV_INDEX: + return NV_SEQ_BACKUP; + case FWMP_NV_INDEX: + return NV_SEQ_FWMP; + case MRC_REC_HASH_NV_INDEX: + return NV_SEQ_REC_HASH; + case 0: + return NV_SEQ_GLOBAL_LOCK; + case TPM_NV_INDEX_LOCK: + return NV_SEQ_ENABLE_LOCKING; + } + + printf("Invalid nv index %#x\n", index); + return -1; +} + +void sb_tpm_read_data(const struct nvdata_state nvdata[NV_SEQ_COUNT], + enum sandbox_nv_space seq, u8 *buf, int data_ofs, + int length) +{ + const struct nvdata_state *nvd = &nvdata[seq]; + + if (!nvd->present) + put_unaligned_be32(TPM_BADINDEX, buf + TPM_ERR_CODE_OFS); + else if (length > nvd->length) + put_unaligned_be32(TPM_BAD_DATASIZE, buf + TPM_ERR_CODE_OFS); + else + memcpy(buf + data_ofs, &nvd->data, length); +} + +void sb_tpm_write_data(struct nvdata_state nvdata[NV_SEQ_COUNT], + enum sandbox_nv_space seq, const u8 *buf, int data_ofs, + int length) +{ + struct nvdata_state *nvd = &nvdata[seq]; + + if (length > nvd->length) + log_err("Invalid length %x (max %x)\n", length, nvd->length); + else + memcpy(&nvdata[seq].data, buf + data_ofs, length); +} diff --git a/drivers/tpm/sandbox_common.h b/drivers/tpm/sandbox_common.h new file mode 100644 index 000..aa5292d7945 --- /dev/null +++ b/drivers/tpm/sandbox_common.h @@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Common features for sandbox TPM1 and TPM2 implementations + * + * Copyright 2021 Google LLC + */ + +#ifndef __TPM_SANDBOX_COMMON_H +#define __TPM_SANDBOX_COMMON_H + +/* + * These numbers derive from adding the sizes of command fields as shown in + * the TPM commands manual. + */ +#define TPM_HDR_LEN10 + +/* These are the different non-volatile spaces that we emulate */ +enum sandbox_nv_space { + NV_SEQ_ENABLE_LOCKING, + NV_SEQ_GLOBAL_LOCK, + NV_SEQ_FIRMWARE, + NV_SEQ_KERNEL, + NV_SEQ_BACKUP, + NV_SEQ_FWMP, + NV_SEQ_REC_HASH, + + NV_SEQ_COUNT, +}; + +/* TPM NVRAM location indices */ +#define FIRMWARE_NV_INDEX 0x1007 +#define KERNEL_NV_INDEX0x1008 +#define BACKUP_NV_INDEX0x1009 +#define FWMP_NV_INDEX 0x100a +#define MRC_REC_HASH_NV_INDEX 0x100b + +/* Size of each non-volatile space */ +#define NV_DATA_SIZE 0x28 + +/** + * struct nvdata_state - state of a single non-volatile-data 'space' + *
[PATCH v2 00/10] tpm: Enhance sandbox tpm2 emulation
At present the TPM2 emulator lacks the ability to load and save the state. This means it cannot be used for verify-boot flow that includes multiple phases (e.g. VPL and SPL). It also lacks support for non-volatile data storage. This series adds these features to the TPM2 emulator, with some code from TPM1 moving into a common file. A few other clean-ups are included to make the two emulators more similar. Changes in v2: - Add new patch to correct handling of SANDBOX_TPM_PCR_NB - Drop the constant sandbox_extended_once_pcr since we can calculate it - Update the commit message to explain that there is only one PCR Simon Glass (10): sandbox: tpm: Split out common nvdata code sandbox: tpm: Tidy up reading and writing of device state sandbox: tpm: Support the define-space command sandbox: tpm: Correct handling of get-capability sandbox: tpm: Finish comments for struct sandbox_tpm2 sandbox: tpm: Track whether the state is valid sandbox: tpm: Support nvdata in TPM2 sandbox: tpm: Support storing device state in tpm2 sandbox: tpm: Correct handling of SANDBOX_TPM_PCR_NB sandbox: tpm: Support extending a PCR multiple times drivers/tpm/Makefile | 4 +- drivers/tpm/sandbox_common.c | 77 + drivers/tpm/sandbox_common.h | 108 + drivers/tpm/tpm2_tis_sandbox.c | 283 + drivers/tpm/tpm_tis_sandbox.c | 171 ++-- include/tpm-v2.h | 2 + test/py/tests/test_tpm2.py | 18 ++- 7 files changed, 505 insertions(+), 158 deletions(-) create mode 100644 drivers/tpm/sandbox_common.c create mode 100644 drivers/tpm/sandbox_common.h -- 2.32.0.402.g57bb445576-goog
[PATCH v2 4/5] efi: Use 16-bit unicode strings
At present we use wide characters for unicode but this is not necessary. Change the code to use the 'u' literal instead. This helps to fix build warnings for sandbox on rpi. Signed-off-by: Simon Glass Suggested-by: Heinrich Schuchardt --- (no changes since v1) include/efi_loader.h | 2 +- lib/efi_loader/efi_bootmgr.c | 12 +- lib/efi_loader/efi_boottime.c | 2 +- lib/efi_loader/efi_capsule.c | 20 ++-- lib/efi_loader/efi_helper.c | 2 +- lib/efi_loader/efi_image_loader.c | 8 +- lib/efi_loader/efi_setup.c| 20 ++-- lib/efi_loader/efi_signature.c| 4 +- lib/efi_loader/efi_string.c | 2 +- lib/efi_loader/efi_var_common.c | 14 +-- lib/efi_loader/efi_variable.c | 6 +- lib/efi_loader/efi_variable_tee.c | 2 +- lib/efi_loader/helloworld.c | 40 +++ lib/efi_selftest/dtbdump.c| 82 +++--- lib/efi_selftest/efi_selftest.c | 2 +- lib/efi_selftest/efi_selftest_block_device.c | 6 +- lib/efi_selftest/efi_selftest_devicepath.c| 2 +- lib/efi_selftest/efi_selftest_exception.c | 2 +- lib/efi_selftest/efi_selftest_fdt.c | 6 +- lib/efi_selftest/efi_selftest_hii.c | 8 +- lib/efi_selftest/efi_selftest_load_file.c | 4 +- lib/efi_selftest/efi_selftest_loadimage.c | 4 +- .../efi_selftest_miniapp_exception.c | 4 +- lib/efi_selftest/efi_selftest_miniapp_exit.c | 8 +- .../efi_selftest_miniapp_return.c | 2 +- lib/efi_selftest/efi_selftest_reset.c | 2 +- lib/efi_selftest/efi_selftest_textoutput.c| 12 +- .../efi_selftest_unicode_collation.c | 38 +++ lib/efi_selftest/efi_selftest_util.c | 106 +- lib/efi_selftest/efi_selftest_variables.c | 22 ++-- .../efi_selftest_variables_runtime.c | 4 +- lib/efi_selftest/initrddump.c | 60 +- 32 files changed, 254 insertions(+), 254 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index b81180cfda8..cad7961942b 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -924,7 +924,7 @@ efi_status_t efi_capsule_authenticate(const void *capsule, efi_uintn_t capsule_size, void **image, efi_uintn_t *image_size); -#define EFI_CAPSULE_DIR L"\\EFI\\UpdateCapsule\\" +#define EFI_CAPSULE_DIR u"\\EFI\\UpdateCapsule\\" /* Hook at initialization */ efi_status_t efi_launch_capsules(void); diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 1fe19237f9a..8c04ecbdc83 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -46,8 +46,8 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, void **load_options) { struct efi_load_option lo; - u16 varname[] = L"Boot"; - u16 hexmap[] = L"0123456789ABCDEF"; + u16 varname[] = u"Boot"; + u16 hexmap[] = u"0123456789ABCDEF"; void *load_option; efi_uintn_t size; efi_status_t ret; @@ -83,7 +83,7 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS; - ret = efi_set_variable_int(L"BootCurrent", + ret = efi_set_variable_int(u"BootCurrent", &efi_global_variable_guid, attributes, sizeof(n), &n, false); if (ret != EFI_SUCCESS) @@ -149,7 +149,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options) /* BootNext */ size = sizeof(bootnext); - ret = efi_get_variable_int(L"BootNext", + ret = efi_get_variable_int(u"BootNext", &efi_global_variable_guid, NULL, &size, &bootnext, NULL); if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) { @@ -158,7 +158,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options) log_err("BootNext must be 16-bit integer\n"); /* delete BootNext */ - ret = efi_set_variable_int(L"BootNext", + ret = efi_set_variable_int(u"BootNext", &efi_global_variable_guid, 0, 0, NULL, false); @@ -178,7 +178,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options) } /* BootOrder */ - bootorder = efi_get_var(L"BootOrder", &efi_global_variable_guid, &size); + bootorder = efi_get_var(u"BootOrder", &efi_global_variable_guid
[PATCH v2 5/5] sandbox: Detect the host bit size automatically
At present if you build sandbox on a 32-bit host a lot of errors are produced. This is because CONFIG_HOST_64BIT is enabled by default. It is quite annoying to have to change that manually before building sandbox. It is also quite confusing for new users. Add a way to detect the setting and add the appropriate CONFIG_HOST_64BIT=y or CONFIG_HOST_32BIT=y to the defconfig, to avoid this issue. Signed-off-by: Simon Glass --- Changes in v2: - Drop patches previously applied - Put all the packages in gcc.rst Makefile | 11 ++- arch/sandbox/Kconfig | 13 - scripts/kconfig/Makefile | 14 +- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index bc404c8f989..0257d202597 100644 --- a/Makefile +++ b/Makefile @@ -565,8 +565,17 @@ export KBUILD_DEFCONFIG KBUILD_KCONFIG config: scripts_basic outputmakefile FORCE $(Q)$(MAKE) $(build)=scripts/kconfig $@ +# If nothing is specified explicitly, detect the bit size for sandbox, +# referred to from arch/sandbox/Kconfig +# Add it to the end of the defconfig file %config: scripts_basic outputmakefile FORCE - $(Q)$(MAKE) $(build)=scripts/kconfig $@ + $(Q)if test -f $(srctree)/configs/$@ && \ + ! grep -Eq "CONFIG_HOST_(32|64)BIT=y" $(srctree)/configs/$@; then \ + echo '#include \nint main(void) { printf("CONFIG_HOST_%dBIT=y\\n", __WORDSIZE); return 0; }' \ +| gcc -x c - -o get_word_size; \ + extra=$$(./get_word_size); \ + fi; \ + $(MAKE) $(build)=scripts/kconfig EXTRA_DEFCONFIG=$$extra $@ else # === diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index f83282d9d56..01b2a3fcad1 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -35,12 +35,12 @@ config SYS_CONFIG_NAME choice prompt "Run sandbox on 32/64-bit host" - default HOST_64BIT + default HOST_DETECT_BIT help - Sandbox can be built on 32-bit and 64-bit hosts. - The default is to build on a 64-bit host and run - on a 64-bit host. If you want to run sandbox on - a 32-bit host, change it here. + Sandbox can be built on 32-bit and 64-bit hosts. This is generally + auto-detected but you can force a particular word size here. If you + see strange warnings about SANDBOX_BITS_PER_LONG then you may have + selected the wrong value. config HOST_32BIT bool "32-bit host" @@ -49,6 +49,9 @@ config HOST_32BIT config HOST_64BIT bool "64-bit host" +config HOST_DETECT_BIT + bool "Auto-detect bit size" + endchoice config SANDBOX_CRASH_RESET diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index d52128425ce..8e14db7ade3 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -12,6 +12,9 @@ PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig \ # Set SRCARCH to .. fake this Makefile. SRCARCH := .. +# For U-Boot, EXTRA_DEFCONFIG contains a line to be added to the defconfig +# before processing. If empty, no line is added. + ifdef KBUILD_KCONFIG Kconfig := $(KBUILD_KCONFIG) else @@ -92,8 +95,17 @@ else endif endif +# If EXTRA_DEFCONFIG is defined, add it to the end of the defconfig, before +# processing. This allows the caller to change a setting on the fly %_defconfig: $(obj)/conf - $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) + $(Q)defconfig="$(srctree)/arch/$(SRCARCH)/configs/$@"; \ + if [ -n "$(EXTRA_DEFCONFIG)" ]; then \ + cat $$defconfig >defconfig_tmp; \ + echo $(EXTRA_DEFCONFIG) >>defconfig_tmp; \ + $< $(silent) --defconfig=defconfig_tmp $(Kconfig); \ + else \ + $< $(silent) --defconfig=$$defconfig $(Kconfig); \ + fi # Added for U-Boot (backward compatibility) %_config: %_defconfig -- 2.32.0.402.g57bb445576-goog
[PATCH v2 3/5] doc: sandbox: Fix up dependencies
These are out of date. Update them and point to the existing build instructions to avoid duplication. Add a few that are missing. Signed-off-by: Simon Glass --- Changes in v2: - Add python3-pycryptodome also, for test_fit_ecdsa.py doc/arch/sandbox.rst | 6 +- doc/build/gcc.rst| 6 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst index e052b6bdb09..493d6deaf00 100644 --- a/doc/arch/sandbox.rst +++ b/doc/arch/sandbox.rst @@ -43,11 +43,7 @@ Note that standalone/API support is not available at present. Prerequisites - -Here are some packages that are worth installing if you are doing sandbox or -tools development in U-Boot: - - python3-pytest lzma lzma-alone lz4 python3 python3-virtualenv - libssl1.0-dev +Install the dependencies noted in :doc:`../build/gcc`. Basic Operation diff --git a/doc/build/gcc.rst b/doc/build/gcc.rst index c51b3e73b83..8ffb4e3447b 100644 --- a/doc/build/gcc.rst +++ b/doc/build/gcc.rst @@ -26,8 +26,10 @@ Depending on the build targets further packages maybe needed sudo apt-get install bc bison build-essential coccinelle \ device-tree-compiler dfu-util efitools flex gdisk liblz4-tool \ libguestfs-tools libncurses-dev libpython3-dev libsdl2-dev libssl-dev \ - lzma-alone openssl python3 python3-coverage python3-pyelftools \ - python3-pytest python3-sphinxcontrib.apidoc python3-sphinx-rtd-theme swig + lz4 lzma lzma-alone openssl python3 python3-coverage \ + python3-pycryptodome python3-pyelftools python3-pytest \ + python3-sphinxcontrib.apidoc python3-sphinx-rtd-theme python3-virtualenv \ + swig SUSE based ~~ -- 2.32.0.402.g57bb445576-goog
[PATCH v2 2/5] pci: swap_case: Allow compilation on 32-bit machines
At present this driver assumes that ulong is 64-bits long. On 32-bit machines it is not. Use the 64-bit code only on 64-bit machines. This makes things work correctly on 32-bit machines. Signed-off-by: Simon Glass --- Changes in v2: - Update commit message to indicate that things work now drivers/misc/swap_case.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/misc/swap_case.c b/drivers/misc/swap_case.c index 3cbc8f37ec5..7093ad1cd4f 100644 --- a/drivers/misc/swap_case.c +++ b/drivers/misc/swap_case.c @@ -302,7 +302,6 @@ static int sandbox_swap_case_write_io(struct udevice *dev, unsigned int addr, } static int pci_ea_bar2_magic = PCI_EA_BAR2_MAGIC; -static int pci_ea_bar4_magic = PCI_EA_BAR4_MAGIC; static int sandbox_swap_case_map_physmem(struct udevice *dev, phys_addr_t addr, unsigned long *lenp, void **ptrp) @@ -332,12 +331,22 @@ static int sandbox_swap_case_map_physmem(struct udevice *dev, *ptrp = &pci_ea_bar2_magic; *lenp = PCI_CAP_EA_SIZE_LO; break; +#ifdef CONFIG_HOST_64BIT + /* +* This cannot be work on a 32-bit machine since *lenp is ulong +* which is 32-bits, but it needs to have a 64-bit value +* assigned +*/ case (phys_addr_t)((PCI_CAP_EA_BASE_HI4 << 32) | - PCI_CAP_EA_BASE_LO4): + PCI_CAP_EA_BASE_LO4): { + static int pci_ea_bar4_magic = PCI_EA_BAR4_MAGIC; + *ptrp = &pci_ea_bar4_magic; *lenp = (PCI_CAP_EA_SIZE_HI << 32) | PCI_CAP_EA_SIZE_LO; break; + } +#endif default: return -ENOENT; } -- 2.32.0.402.g57bb445576-goog
[PATCH v2 1/5] checkpatch: Support wide strings
From: Joe Perches Allow prefixing typical strings with L for wide strings and u for unicode strings. Signed-off-by: Joe Perches Signed-off-by: Simon Glass --- This was found on LKML: https://lore.kernel.org/lkml/1508280192.6530.31.ca...@perches.com/T/ It likely wasn't applied because it did not show up in patchwork correctly, due to the patch being inline: https://lore.kernel.org/patchwork/patch/842121/ In any case, it needed rebasing and updating to support 'u'. Heinrich, perhaps you can send this upstream since you have the context? Changes in v2: - Add new patch to reduce checkpatch unicode-string spam scripts/checkpatch.pl | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 08a827535aa..b244682c7c9 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -411,7 +411,7 @@ our $Binary = qr{(?i)0b[01]+$Int_type?}; our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?}; our $Int = qr{[0-9]+$Int_type?}; our $Octal = qr{0[0-7]+$Int_type?}; -our $String= qr{"[X\t]*"}; +our $String= qr{(?:\b[Lu])?"[X\t]*"}; our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?}; our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?}; our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?}; @@ -5673,7 +5673,8 @@ sub process { } # concatenated string without spaces between elements - if ($line =~ /$String[A-Za-z0-9_]/ || $line =~ /[A-Za-z0-9_]$String/) { + if ($line =~ /$String[A-Z_]/ || + ($line =~ /([A-Za-z0-9_]+)$String/ && $1 !~ /^[Lu]$/)) { if (CHK("CONCATENATED_STRING", "Concatenated strings should use spaces between elements\n" . $herecurr) && $fix) { @@ -5686,7 +5687,7 @@ sub process { } # uncoalesced string fragments - if ($line =~ /$String\s*"/) { + if ($line =~ /$String\s*[Lu]?"/) { if (WARN("STRING_FRAGMENTS", "Consecutive strings are generally better as a single string\n" . $herecurr) && $fix) { -- 2.32.0.402.g57bb445576-goog
[PATCH v2 0/5] Fix compiler warnings for 32-bit ARM
These were noticed when building sandbox on a Raspberry Pi 400, which uses 32-bit linux. To make this work, I enabled CONFIG_HOST_32BIT in 'make menuconfig'. It would be nice if that were automatic, since we have the logic already in arch/sandbox/config.mk So this series adds that. It also fixes the unicode warnings of the form: /usr/bin/ld: warning: arch/sandbox/cpu/start.o uses 2-byte wchar_t yet the output is to use 4-byte wchar_t; use of wchar_t values across objects may fail as suggested by Heinrich. Changes in v2: - Add new patch to reduce checkpatch unicode-string spam - Update commit message to indicate that things work now - Add python3-pycryptodome also, for test_fit_ecdsa.py - Drop patches previously applied - Put all the packages in gcc.rst Joe Perches (1): checkpatch: Support wide strings Simon Glass (4): pci: swap_case: Allow compilation on 32-bit machines doc: sandbox: Fix up dependencies efi: Use 16-bit unicode strings sandbox: Detect the host bit size automatically Makefile | 11 +- arch/sandbox/Kconfig | 13 ++- doc/arch/sandbox.rst | 6 +- doc/build/gcc.rst | 6 +- drivers/misc/swap_case.c | 13 ++- include/efi_loader.h | 2 +- lib/efi_loader/efi_bootmgr.c | 12 +- lib/efi_loader/efi_boottime.c | 2 +- lib/efi_loader/efi_capsule.c | 20 ++-- lib/efi_loader/efi_helper.c | 2 +- lib/efi_loader/efi_image_loader.c | 8 +- lib/efi_loader/efi_setup.c| 20 ++-- lib/efi_loader/efi_signature.c| 4 +- lib/efi_loader/efi_string.c | 2 +- lib/efi_loader/efi_var_common.c | 14 +-- lib/efi_loader/efi_variable.c | 6 +- lib/efi_loader/efi_variable_tee.c | 2 +- lib/efi_loader/helloworld.c | 40 +++ lib/efi_selftest/dtbdump.c| 82 +++--- lib/efi_selftest/efi_selftest.c | 2 +- lib/efi_selftest/efi_selftest_block_device.c | 6 +- lib/efi_selftest/efi_selftest_devicepath.c| 2 +- lib/efi_selftest/efi_selftest_exception.c | 2 +- lib/efi_selftest/efi_selftest_fdt.c | 6 +- lib/efi_selftest/efi_selftest_hii.c | 8 +- lib/efi_selftest/efi_selftest_load_file.c | 4 +- lib/efi_selftest/efi_selftest_loadimage.c | 4 +- .../efi_selftest_miniapp_exception.c | 4 +- lib/efi_selftest/efi_selftest_miniapp_exit.c | 8 +- .../efi_selftest_miniapp_return.c | 2 +- lib/efi_selftest/efi_selftest_reset.c | 2 +- lib/efi_selftest/efi_selftest_textoutput.c| 12 +- .../efi_selftest_unicode_collation.c | 38 +++ lib/efi_selftest/efi_selftest_util.c | 106 +- lib/efi_selftest/efi_selftest_variables.c | 22 ++-- .../efi_selftest_variables_runtime.c | 4 +- lib/efi_selftest/initrddump.c | 60 +- scripts/checkpatch.pl | 7 +- scripts/kconfig/Makefile | 14 ++- 39 files changed, 305 insertions(+), 273 deletions(-) -- 2.32.0.402.g57bb445576-goog
[PULL] u-boot-mips
Gitlab: https://source.denx.de/u-boot/custodians/u-boot-mips/-/pipelines/8294 Azure: https://dev.azure.com/danielschwierzeck/u-boot/_build/results?buildId=25&view=results The following changes since commit f929ce50727bf1019323d6c199dfd3a5755c5474: Merge branch '2021-07-16-cleanup-image-support' (2021-07-17 11:39:50 -0400) are available in the Git repository at: https://source.denx.de/u-boot/custodians/u-boot-mips.git/ tags/mips-pull-2021-07-18 for you to fetch changes up to 526ceb43878bfcaaeffbb988e363e89500695bee: MIPS: malta: enable PCI driver model (2021-07-18 20:37:39 +0200) - mips: gardena-smart-gateway: adjust config to new production values - mips: malta: convert to PCI DM and ETH DM Daniel Schwierzeck (6): dm: pci: add option to map virtual system memory base address pci: gt64120: convert to driver model pci: msc01: convert to driver model MIPS: malta: add DT bindings for PCI host controller MIPS: malta: add support for PCI driver model MIPS: malta: enable PCI driver model Reto Schneider (1): mips: mt7688: gardena-smart-gateway: Adjust to production values arch/mips/Kconfig | 4 ++ arch/mips/dts/mti,malta.dts| 28 + board/imgtec/malta/malta.c | 80 +- configs/gardena-smart-gateway-mt7688_defconfig | 11 +++- drivers/pci/Kconfig| 13 + drivers/pci/pci-uclass.c | 9 ++- drivers/pci/pci_gt64120.c | 74 +++- drivers/pci/pci_msc01.c| 72 ++- 8 files changed, 284 insertions(+), 7 deletions(-)
Re: [PATCH v2 0/6] Convert MIPS Malta boards to PCI DM
Am Donnerstag, den 15.07.2021, 20:53 +0200 schrieb Daniel Schwierzeck: > This series converts the PCI host controller drivers used by MIPS > Malta and the board-specific PCI setup code to PCI driver model. > Because the AMD PCNET driver is already converted to ETH driver > model, simply enable CONFIG_DM_ETH as well. > > A patch in PCI uclass core is currently required for MIPS wanting > to use PCI DM (except Octeon MIPS64) due to CONFIG_SYS_SDRAM_BASE > being used as a virtual address on all MIPS boards. > > The series for now is only tested with Qemu and the GT64120 PCI > controller. The Malta Qemu tests are already covered by U-Boot CI > Support for the MSC01 controller is prepared. The used PCI controller > depends on the plugged core card (Qemu emulates the CoreLV card with > GT64120). > > Dynamic selection of the according PCI DT nodes via > CONFIG_OF_BOARD_FIXUP > is prepared but not yet enabled. This requires fixing of the call > order of > fix_fdt() in board_init_f, otherwise the passed-in rw_fdt_blob > pointer > will point to a read-only NOR flash address. I'll send a separate > RFC patch for this. > > I'll send a cleanup series for removing non-DM code after the merge > windows has closed and the PCI DM conversion deadline has been > enforced. > > Changes in v2: > - add empty line before return statements > - add empty line before return statements > - use dm_pci_clrset_config32() where possible > > Daniel Schwierzeck (6): > dm: pci: add option to map virtual system memory base address > pci: gt64120: convert to driver model > pci: msc01: convert to driver model > MIPS: malta: add DT bindings for PCI host controller > MIPS: malta: add support for PCI driver model > MIPS: malta: enable PCI driver model > > arch/mips/Kconfig | 4 ++ > arch/mips/dts/mti,malta.dts | 28 + > board/imgtec/malta/malta.c | 80 > - > drivers/pci/Kconfig | 13 ++ > drivers/pci/pci-uclass.c| 9 +++-- > drivers/pci/pci_gt64120.c | 74 +- > drivers/pci/pci_msc01.c | 72 - > 7 files changed, 274 insertions(+), 6 deletions(-) > applied to u-boot-mips -- - Daniel
Pull request for efi-2021-10-rc1-2
Dear Tom, The following changes since commit f929ce50727bf1019323d6c199dfd3a5755c5474: Merge branch '2021-07-16-cleanup-image-support' (2021-07-17 11:39:50 -0400) are available in the Git repository at: https://source.denx.de/u-boot/custodians/u-boot-efi.git tags/efi-2021-10-rc1-2 for you to fetch changes up to 316ab801c0d91c02b21b8be1e3db7e69555364e9: doc: Update CapsuleUpdate READMEs (2021-07-18 14:43:56 +0200) Gitlab showed no problems: https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/8290 Pull request for efi-2021-10-rc1-2 * Correct device path nodes for GUID partitions * Embed keys to check update capsules instead of providing then in DTB * Increase event log buffer size for measured boot. Alfonso Sánchez-Beato (1): efi_loader: set partition GUID in device path for SIG_TYPE_GUID Ilias Apalodimas (3): efi_capsule: Move signature from DTB to .rodata mkeficapsule: Remove dtb related options doc: Update CapsuleUpdate READMEs Masahisa Kojima (1): efi_loader: increase eventlog buffer size Masami Hiramatsu (1): efi_loader: Use %pD to log device-path instead of local efi_dp_str() board/emulation/common/Makefile | 1 - board/emulation/common/qemu_capsule.c | 43 -- doc/board/emulation/qemu_capsule_update.rst | 203 doc/develop/uefi/uefi.rst | 125 +++ include/asm-generic/sections.h | 2 + lib/efi_loader/Kconfig | 10 +- lib/efi_loader/Makefile | 8 + lib/efi_loader/efi_capsule.c| 24 ++- lib/efi_loader/efi_capsule_key.S| 17 +++ lib/efi_loader/efi_device_path.c| 10 +- tools/mkeficapsule.c| 229 +--- 11 files changed, 192 insertions(+), 480 deletions(-) delete mode 100644 board/emulation/common/qemu_capsule.c delete mode 100644 doc/board/emulation/qemu_capsule_update.rst create mode 100644 lib/efi_loader/efi_capsule_key.S
Re: [PATCH 06/22] Makefile: Avoid rebuilding .dtb files each time
On Sun, Jul 18, 2021 at 5:41 AM Simon Glass wrote: > > Drop the FORCE from the rule that builds .dtb files and let the normal > dependency checking do its work. This should work correctly, at least > for .dts files that don't use /include/. > > Signed-off-by: Simon Glass > --- > > scripts/Makefile.lib | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > Applied to u-boot-dm, thanks! I am no longer working on U-Boot, but this patch is obviously wrong. if_changed_dep must always have FORCE as the prerequisite. If it is not working, you may miss adding the objects to the 'targets'. Somebody had broken the build system? -- Best Regards Masahiro Yamada
[PATCH] serial: pl011: Enable DEBUG_UART_PL011 in SPL
Commit b81406db51a6 ("arm: serial: Add debug UART capability to the pl01x driver") add supports to use pl01x as a debug UART. However, due to CONFIG_IS_ENABLED macro requires CONFIG_SPL_* prefix, the _debug_uart_init() would not choose TYPE_PL011 in SPL build. This patch fixes the bug by judging CONFIG_DEBUG_UART_PL011 explicitly. Signed-off-by: Chen Baozi --- drivers/serial/serial_pl01x.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index 17b26aed81..f00663a814 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -404,8 +404,11 @@ static void _debug_uart_init(void) { #ifndef CONFIG_DEBUG_UART_SKIP_INIT struct pl01x_regs *regs = (struct pl01x_regs *)CONFIG_DEBUG_UART_BASE; - enum pl01x_type type = CONFIG_IS_ENABLED(DEBUG_UART_PL011) ? - TYPE_PL011 : TYPE_PL010; +#if defined(CONFIG_DEBUG_UART_PL011) + enum pl01x_type type = TYPE_PL011; +#else + enum pl01x_type type = TYPE_PL010; +#endif pl01x_generic_serial_init(regs, type); pl01x_generic_setbrg(regs, type, -- 2.28.0
[PATCH] serial: pl011: Resend the character if FIFO is full in debug uart
pl01x_putc() might return -EAGAIN if there was no space in FIFO. In that case, high-level caller should wait until there is space and resend the character. Signed-off-by: Chen Baozi --- drivers/serial/serial_pl01x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index 76b96ad414..17b26aed81 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -417,7 +417,7 @@ static inline void _debug_uart_putc(int ch) { struct pl01x_regs *regs = (struct pl01x_regs *)CONFIG_DEBUG_UART_BASE; - pl01x_putc(regs, ch); + while (pl01x_putc(regs, ch) == -EAGAIN); } DEBUG_UART_FUNCS -- 2.28.0
[PATCH 1/1] efi_loader: select GPT partition support
The UEFI specification requires support for GPT partition tables. The device path node of GPT partition uses the partition UUID. Let CONFIG_EFI_LOADER select the necessary GPT related configuration settings. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 156b391521..c4741ffec1 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -12,6 +12,9 @@ config EFI_LOADER depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8 select LIB_UUID + select PARTITIONS + select EFI_PARTITION + select PARTITION_UUIDS select HAVE_BLOCK_DEVICE select REGEX imply CFB_CONSOLE_ANSI -- 2.32.0
[PATCH 1/1] efi_loader: select GPT partition support
The UEFI specification requires support for GPT partition tables. The device path node of GPT partition uses the partition UUID. Let CONFIG_EFI_LOADER select the necessary GPT related configuration settings. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 156b391521..c4741ffec1 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -12,6 +12,9 @@ config EFI_LOADER depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8 select LIB_UUID + select PARTITIONS + select EFI_PARTITION + select PARTITION_UUIDS select HAVE_BLOCK_DEVICE select REGEX imply CFB_CONSOLE_ANSI -- 2.32.0
Re: [PATCH] efi_loader: set partition GUID in device path for SIG_TYPE_GUID
On 15.07.21 15:31, Alfonso Sánchez-Beato wrote: > Previously, the GPT device GUID was being used instead of the partition, > which was incorrect. > > Signed-off-by: Alfonso Sánchez-Beato > Reviewed-by: Heinrich Schuchardt Building fails on some platforms with +lib/efi_loader/efi_device_path.c:855:49: error: 'struct disk_partition' has no member named 'uuid' + 855 | if (uuid_str_to_bin(info.uuid, + | ^ https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/8287 The availability of the field depends on CONFIG_PARTITION_UUIDS. You could let EFI_LOADER select PARTITION_UUIDS in lib/efi_loader/Kconfig. Best regards Heinrich > --- > lib/efi_loader/efi_device_path.c | 7 +-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/lib/efi_loader/efi_device_path.c > b/lib/efi_loader/efi_device_path.c > index 76c2f82fe6..a2c19538ad 100644 > --- a/lib/efi_loader/efi_device_path.c > +++ b/lib/efi_loader/efi_device_path.c > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > #include > #include /* U16_MAX */ > > @@ -851,8 +852,10 @@ static void *dp_part_node(void *buf, struct blk_desc > *desc, int part) > break; > case SIG_TYPE_GUID: > hddp->signature_type = 2; > - memcpy(hddp->partition_signature, &desc->guid_sig, > -sizeof(hddp->partition_signature)); > + if (uuid_str_to_bin(info.uuid, > + hddp->partition_signature, 1)) > + printf("Partition no. %d: invalid guid: %s\n", > +part, info.uuid); > break; > } > >
Re: [PATCH] efi_loader: replace board_get_usable_ram_top by gd->ram_top
On 7/9/21 12:46 PM, Patrick Delaunay wrote: As gd->ram_top = board_get_usable_ram_top() in board_r the EFI loader don't need to call this function again and after relocation. This patch avoid issue if board assumed that this function is called only one time and before relocation. Hello Patrick, Which implementation of board_get_usable_ram_top() assumes that it is called only once before relocation? Please, mention this in the commit message. gd->ram_top is set in multiple places: arch/arm/mach-rockchip/spl.c:149: gd->ram_top = gd->ram_base + get_effective_memsize(); arch/arm/mach-rockchip/spl.c:150: gd->ram_top = board_get_usable_ram_top(gd->ram_size); arch/arm/cpu/armv8/fsl-layerscape/spl.c:114:gd->ram_top = gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size; I guess you refer to: common/board_f.c:345: gd->ram_top = gd->ram_base + get_effective_memsize(); common/board_f.c:346: gd->ram_top = board_get_usable_ram_top(gd->mon_len); I would not expect board_get_usable_ram_top(gd->mon_len) and board_get_usable_ram_top(0) to be the same. So, please, describe in your patch why you assume that board_get_usable_ram_top(gd->mon_len) is the value we should use. Best regards Heinrich Signed-off-by: Patrick Delaunay --- https://source.denx.de/u-boot/custodians/u-boot-stm/-/pipelines/7399 lib/efi_loader/efi_memory.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index be2f655dff..f5bc37a20a 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -731,7 +730,7 @@ efi_status_t efi_add_conventional_memory_map(u64 ram_start, u64 ram_end, __weak void efi_add_known_memory(void) { - u64 ram_top = board_get_usable_ram_top(0) & ~EFI_PAGE_MASK; + u64 ram_top = gd->ram_top & ~EFI_PAGE_MASK; int i; /*