summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-04-22 18:32:08 -0400
committerTom Rini <trini@konsulko.com>2023-04-22 18:32:08 -0400
commit39bc4e12aba9b415c2bc19c0209661146c6e6f2a (patch)
tree1133f0583ce5dbfdcc650f0c4ded1aa4496be10f
parent802132c48a2e6b66ec83b7bb66fb96f2ba87c957 (diff)
parentb10bfd0019f601e2608370ed47741da201423d55 (diff)
downloadu-boot-39bc4e12aba9b415c2bc19c0209661146c6e6f2a.tar.gz
Merge tag 'efi-2023-07-rc1-2' of https://source.denx.de/u-boot/custodians/u-boot-efi
Pull request for efi-2023-07-rc1-2 Documentation: * Describe Python coding style UEFI: * Enable tests for authenticated capsules on the sandbox * Fix pylint warnings * Correct struct efi_hii_keyboard_layout definition
-rw-r--r--configs/sandbox_defconfig1
-rw-r--r--configs/sandbox_flattree_defconfig1
-rw-r--r--doc/develop/codingstyle.rst7
-rw-r--r--include/efi_api.h2
-rw-r--r--lib/efi_loader/efi_capsule.c6
-rw-r--r--test/py/tests/test_efi_capsule/conftest.py27
-rw-r--r--test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py35
-rw-r--r--test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py41
-rw-r--r--test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py38
-rw-r--r--test/py/tests/test_efi_fit.py4
10 files changed, 78 insertions, 84 deletions
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index ae27cac240..657de0ab6f 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -336,6 +336,7 @@ CONFIG_ERRNO_STR=y
CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
CONFIG_EFI_CAPSULE_ON_DISK=y
CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
+CONFIG_EFI_CAPSULE_AUTHENTICATE=y
CONFIG_EFI_SECURE_BOOT=y
CONFIG_TEST_FDTDEC=y
CONFIG_UNIT_TEST=y
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index e9fcc5b0cb..8c2bceae22 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -226,6 +226,7 @@ CONFIG_ERRNO_STR=y
CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
CONFIG_EFI_CAPSULE_ON_DISK=y
CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y
+CONFIG_EFI_CAPSULE_AUTHENTICATE=y
CONFIG_UNIT_TEST=y
CONFIG_UT_TIME=y
CONFIG_UT_DM=y
diff --git a/doc/develop/codingstyle.rst b/doc/develop/codingstyle.rst
index 1d5d0192b3..3d05a6b988 100644
--- a/doc/develop/codingstyle.rst
+++ b/doc/develop/codingstyle.rst
@@ -19,6 +19,10 @@ The following rules apply:
applies only to Linux, not to U-Boot. Only large hunks which are copied
unchanged from Linux may retain that comment format.
+* Python code shall conform to `PEP8 (Style Guide for Python Code)
+ <https://peps.python.org/pep-0008/>`_. Use `pylint
+ <https://github.com/pylint-dev/pylint>`_ for checking the code.
+
* Use patman to send your patches (``tools/patman/patman -H`` for full
instructions). With a few tags in your commits this will check your patches
and take care of emailing them.
@@ -67,6 +71,9 @@ documentation is strongly advised. The Linux kernel `kernel-doc
<https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html>`_
documentation applies with no changes.
+Our Python code documentation follows `PEP257 (Docstring Conventions)
+<https://peps.python.org/pep-0257/>`_.
+
Use structures for I/O access
-----------------------------
diff --git a/include/efi_api.h b/include/efi_api.h
index dc6e5ce236..2fd0221c1c 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -1173,7 +1173,7 @@ struct efi_hii_keyboard_layout {
efi_guid_t guid;
u32 layout_descriptor_string_offset;
u8 descriptor_count;
- struct efi_key_descriptor descriptors[];
+ /* struct efi_key_descriptor descriptors[]; follows here */
} __packed;
struct efi_hii_keyboard_package {
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index d5d3ede7ae..7a6f195cbc 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -404,12 +404,6 @@ out:
return status;
}
-#else
-efi_status_t efi_capsule_authenticate(const void *capsule, efi_uintn_t capsule_size,
- void **image, efi_uintn_t *image_size)
-{
- return EFI_UNSUPPORTED;
-}
#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */
static __maybe_unused bool fwu_empty_capsule(struct efi_capsule_header *capsule)
diff --git a/test/py/tests/test_efi_capsule/conftest.py b/test/py/tests/test_efi_capsule/conftest.py
index 4879f2b5c2..0e5137de60 100644
--- a/test/py/tests/test_efi_capsule/conftest.py
+++ b/test/py/tests/test_efi_capsule/conftest.py
@@ -2,30 +2,21 @@
# Copyright (c) 2020, Linaro Limited
# Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
-import os
-import os.path
-import re
-from subprocess import call, check_call, check_output, CalledProcessError
-import pytest
-from capsule_defs import *
+"""Fixture for UEFI capsule test
+"""
-#
-# Fixture for UEFI capsule test
-#
+from subprocess import call, check_call, CalledProcessError
+import pytest
+from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR, EFITOOLS_PATH
@pytest.fixture(scope='session')
def efi_capsule_data(request, u_boot_config):
- """Set up a file system to be used in UEFI capsule and
- authentication test.
-
- Args:
- request: Pytest request object.
- u_boot_config: U-boot configuration.
+ """Set up a file system to be used in UEFI capsule and authentication test
+ and return a ath to disk image to be used for testing
- Return:
- A path to disk image to be used for testing
+ request -- Pytest request object.
+ u_boot_config -- U-boot configuration.
"""
- global CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR
mnt_point = u_boot_config.persistent_data_dir + '/test_efi_capsule'
data_dir = mnt_point + CAPSULE_DATA_DIR
diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py
index d28b53a1a1..9ee152818d 100644
--- a/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py
+++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py
@@ -1,16 +1,13 @@
# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2020, Linaro Limited
# Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
-#
-# U-Boot UEFI: Firmware Update Test
-"""
+"""U-Boot UEFI: Firmware Update Test
This test verifies capsule-on-disk firmware update for FIT images
"""
-from subprocess import check_call, check_output, CalledProcessError
import pytest
-from capsule_defs import *
+from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR
@pytest.mark.boardspec('sandbox_flattree')
@@ -24,15 +21,18 @@ from capsule_defs import *
@pytest.mark.buildconfigspec('cmd_nvedit_efi')
@pytest.mark.buildconfigspec('cmd_sf')
@pytest.mark.slow
-class TestEfiCapsuleFirmwareFit(object):
+class TestEfiCapsuleFirmwareFit():
+ """Test capsule-on-disk firmware update for FIT images
+ """
+
def test_efi_capsule_fw1(
self, u_boot_config, u_boot_console, efi_capsule_data):
- """
- Test Case 1 - Update U-Boot and U-Boot environment on SPI Flash
- but with an incorrect GUID value in the capsule
- No update should happen
- 0x100000-0x150000: U-Boot binary (but dummy)
- 0x150000-0x200000: U-Boot environment (but dummy)
+ """Test Case 1
+ Update U-Boot and U-Boot environment on SPI Flash
+ but with an incorrect GUID value in the capsule
+ No update should happen
+ 0x100000-0x150000: U-Boot binary (but dummy)
+ 0x150000-0x200000: U-Boot environment (but dummy)
"""
# other tests might have run and the
# system might not be in a clean state.
@@ -74,8 +74,6 @@ class TestEfiCapsuleFirmwareFit(object):
capsule_early = u_boot_config.buildconfig.get(
'config_efi_capsule_on_disk_early')
- capsule_auth = u_boot_config.buildconfig.get(
- 'config_efi_capsule_authenticate')
# reboot
u_boot_console.restart_uboot(expect_reset = capsule_early)
@@ -107,11 +105,12 @@ class TestEfiCapsuleFirmwareFit(object):
def test_efi_capsule_fw2(
self, u_boot_config, u_boot_console, efi_capsule_data):
+ """Test Case 2
+ Update U-Boot and U-Boot environment on SPI Flash
+ 0x100000-0x150000: U-Boot binary (but dummy)
+ 0x150000-0x200000: U-Boot environment (but dummy)
"""
- Test Case 2 - Update U-Boot and U-Boot environment on SPI Flash
- 0x100000-0x150000: U-Boot binary (but dummy)
- 0x150000-0x200000: U-Boot environment (but dummy)
- """
+
disk_img = efi_capsule_data
with u_boot_console.log.section('Test Case 2-a, before reboot'):
output = u_boot_console.run_command_list([
diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py
index 8c2d616fd0..ba8429e83c 100644
--- a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py
+++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py
@@ -3,10 +3,8 @@
# Copyright (c) 2022, Arm Limited
# Author: AKASHI Takahiro <takahiro.akashi@linaro.org>,
# adapted to FIT images by Vincent Stehlé <vincent.stehle@arm.com>
-#
-# U-Boot UEFI: Firmware Update (Signed capsule with FIT images) Test
-"""
+"""U-Boot UEFI: Firmware Update (Signed capsule with FIT images) Test
This test verifies capsule-on-disk firmware update
with signed capsule files containing FIT images
"""
@@ -25,15 +23,18 @@ from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR
@pytest.mark.buildconfigspec('cmd_nvedit_efi')
@pytest.mark.buildconfigspec('cmd_sf')
@pytest.mark.slow
-class TestEfiCapsuleFirmwareSignedFit(object):
+class TestEfiCapsuleFirmwareSignedFit():
+ """Capsule-on-disk firmware update test
+ """
+
def test_efi_capsule_auth1(
self, u_boot_config, u_boot_console, efi_capsule_data):
- """
- Test Case 1 - Update U-Boot on SPI Flash, FIT image format
- 0x100000-0x150000: U-Boot binary (but dummy)
+ """Test Case 1
+ Update U-Boot on SPI Flash, FIT image format
+ x150000: U-Boot binary (but dummy)
- If the capsule is properly signed, the authentication
- should pass and the firmware be updated.
+ If the capsule is properly signed, the authentication
+ should pass and the firmware be updated.
"""
disk_img = efi_capsule_data
with u_boot_console.log.section('Test Case 1-a, before reboot'):
@@ -103,13 +104,13 @@ class TestEfiCapsuleFirmwareSignedFit(object):
def test_efi_capsule_auth2(
self, u_boot_config, u_boot_console, efi_capsule_data):
- """
- Test Case 2 - Update U-Boot on SPI Flash, FIT image format
- 0x100000-0x150000: U-Boot binary (but dummy)
+ """Test Case 2
+ Update U-Boot on SPI Flash, FIT image format
+ 0x100000-0x150000: U-Boot binary (but dummy)
- If the capsule is signed but with an invalid key,
- the authentication should fail and the firmware
- not be updated.
+ If the capsule is signed but with an invalid key,
+ the authentication should fail and the firmware
+ not be updated.
"""
disk_img = efi_capsule_data
with u_boot_console.log.section('Test Case 2-a, before reboot'):
@@ -182,12 +183,12 @@ class TestEfiCapsuleFirmwareSignedFit(object):
def test_efi_capsule_auth3(
self, u_boot_config, u_boot_console, efi_capsule_data):
- """
- Test Case 3 - Update U-Boot on SPI Flash, FIT image format
- 0x100000-0x150000: U-Boot binary (but dummy)
+ """Test Case 3
+ Update U-Boot on SPI Flash, FIT image format
+ 0x100000-0x150000: U-Boot binary (but dummy)
- If the capsule is not signed, the authentication
- should fail and the firmware not be updated.
+ If the capsule is not signed, the authentication
+ should fail and the firmware not be updated.
"""
disk_img = efi_capsule_data
with u_boot_console.log.section('Test Case 3-a, before reboot'):
diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py
index 2bbaa9cc55..710d9925a3 100644
--- a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py
+++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py
@@ -1,10 +1,8 @@
# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2021, Linaro Limited
# Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
-#
-# U-Boot UEFI: Firmware Update (Signed capsule with raw images) Test
-"""
+"""U-Boot UEFI: Firmware Update (Signed capsule with raw images) Test
This test verifies capsule-on-disk firmware update
with signed capsule files containing raw images
"""
@@ -23,15 +21,17 @@ from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR
@pytest.mark.buildconfigspec('cmd_nvedit_efi')
@pytest.mark.buildconfigspec('cmd_sf')
@pytest.mark.slow
-class TestEfiCapsuleFirmwareSignedRaw(object):
+class TestEfiCapsuleFirmwareSignedRaw():
+ """Firmware Update (Signed capsule with raw images) Test
+ """
+
def test_efi_capsule_auth1(
self, u_boot_config, u_boot_console, efi_capsule_data):
- """
- Test Case 1 - Update U-Boot on SPI Flash, raw image format
- 0x100000-0x150000: U-Boot binary (but dummy)
+ """Test Case 1 - Update U-Boot on SPI Flash, raw image format
+ 0x100000-0x150000: U-Boot binary (but dummy)
- If the capsule is properly signed, the authentication
- should pass and the firmware be updated.
+ If the capsule is properly signed, the authentication
+ should pass and the firmware be updated.
"""
disk_img = efi_capsule_data
with u_boot_console.log.section('Test Case 1-a, before reboot'):
@@ -100,13 +100,12 @@ class TestEfiCapsuleFirmwareSignedRaw(object):
def test_efi_capsule_auth2(
self, u_boot_config, u_boot_console, efi_capsule_data):
- """
- Test Case 2 - Update U-Boot on SPI Flash, raw image format
- 0x100000-0x150000: U-Boot binary (but dummy)
+ """Test Case 2 - Update U-Boot on SPI Flash, raw image format
+ 0x100000-0x150000: U-Boot binary (but dummy)
- If the capsule is signed but with an invalid key,
- the authentication should fail and the firmware
- not be updated.
+ If the capsule is signed but with an invalid key,
+ the authentication should fail and the firmware
+ not be updated.
"""
disk_img = efi_capsule_data
with u_boot_console.log.section('Test Case 2-a, before reboot'):
@@ -179,12 +178,11 @@ class TestEfiCapsuleFirmwareSignedRaw(object):
def test_efi_capsule_auth3(
self, u_boot_config, u_boot_console, efi_capsule_data):
- """
- Test Case 3 - Update U-Boot on SPI Flash, raw image format
- 0x100000-0x150000: U-Boot binary (but dummy)
+ """Test Case 3 - Update U-Boot on SPI Flash, raw image format
+ 0x100000-0x150000: U-Boot binary (but dummy)
- If the capsule is not signed, the authentication
- should fail and the firmware not be updated.
+ If the capsule is not signed, the authentication
+ should fail and the firmware not be updated.
"""
disk_img = efi_capsule_data
with u_boot_console.log.section('Test Case 3-a, before reboot'):
diff --git a/test/py/tests/test_efi_fit.py b/test/py/tests/test_efi_fit.py
index 92d071f783..7b7c98fb04 100644
--- a/test/py/tests/test_efi_fit.py
+++ b/test/py/tests/test_efi_fit.py
@@ -433,11 +433,13 @@ def test_efi_fit_launch(u_boot_console):
sys_arch = cons.config.buildconfig.get('config_sys_arch', '"sandbox"')[1:-1]
is_sandbox = sys_arch == 'sandbox'
+ if is_sandbox:
+ old_dtb = cons.config.dtb
+
try:
if is_sandbox:
# Use our own device tree file, will be restored afterwards.
control_dtb = make_dtb('internal', False)
- old_dtb = cons.config.dtb
cons.config.dtb = control_dtb
# Run tests