Merge tag 'efi-2019-07-rc3-2' of git://git.denx.de/u-boot-efi
authorTom Rini <trini@konsulko.com>
Sun, 19 May 2019 20:46:24 +0000 (16:46 -0400)
committerTom Rini <trini@konsulko.com>
Sun, 19 May 2019 20:46:24 +0000 (16:46 -0400)
Pull request for UEFI sub-system for v2019.07-rc3 (2)

Minor patches to improve UEFI specification compliance are provided.

To allow running the UEFI self compliance tests an outdated version of
the Unicode collation protocol has been added as a configuration option
(disabled by default).

12 files changed:
include/efi_api.h
include/efi_loader.h
lib/efi_loader/Kconfig
lib/efi_loader/Makefile
lib/efi_loader/efi_boottime.c
lib/efi_loader/efi_console.c
lib/efi_loader/efi_device_path_to_text.c
lib/efi_loader/efi_net.c
lib/efi_loader/efi_root_node.c
lib/efi_loader/efi_unicode_collation.c
lib/efi_loader/efi_variable.c
lib/efi_selftest/Makefile

index 755c4057939af5727f12bb3db40139a3513c0fcb..65584dd2d82a235612221b2e3c03f41a1a9f459a 100644 (file)
@@ -639,7 +639,7 @@ struct efi_simple_text_input_ex_protocol {
        struct efi_event *wait_for_key_ex;
        efi_status_t (EFIAPI *set_state) (
                struct efi_simple_text_input_ex_protocol *this,
-               u8 key_toggle_state);
+               u8 *key_toggle_state);
        efi_status_t (EFIAPI *register_key_notify) (
                struct efi_simple_text_input_ex_protocol *this,
                struct efi_key_data *key_data,
@@ -1425,6 +1425,11 @@ struct efi_driver_binding_protocol {
        efi_handle_t driver_binding_handle;
 };
 
+/* Deprecated version of the Unicode collation protocol */
+#define EFI_UNICODE_COLLATION_PROTOCOL_GUID \
+       EFI_GUID(0x1d85cd7f, 0xf43d, 0x11d2, \
+                0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
+/* Current version of the Unicode collation protocol */
 #define EFI_UNICODE_COLLATION_PROTOCOL2_GUID \
        EFI_GUID(0xa4c751fc, 0x23ae, 0x4c3e, \
                 0x92, 0xe9, 0x49, 0x64, 0xcf, 0x63, 0xf3, 0x49)
index 07ef14ba1cd4319f7ec2ee79a80a852aac7484ed..8167e6ffcbb26e839f285e7de913d438756b189c 100644 (file)
@@ -106,9 +106,12 @@ extern const struct efi_device_path_to_text_protocol efi_device_path_to_text;
 /* implementation of the EFI_DEVICE_PATH_UTILITIES_PROTOCOL */
 extern const struct efi_device_path_utilities_protocol
                                        efi_device_path_utilities;
-/* Implementation of the EFI_UNICODE_COLLATION_PROTOCOL */
+/* deprecated version of the EFI_UNICODE_COLLATION_PROTOCOL */
 extern const struct efi_unicode_collation_protocol
                                        efi_unicode_collation_protocol;
+/* current version of the EFI_UNICODE_COLLATION_PROTOCOL */
+extern const struct efi_unicode_collation_protocol
+                                       efi_unicode_collation_protocol2;
 extern const struct efi_hii_config_routing_protocol efi_hii_config_routing;
 extern const struct efi_hii_config_access_protocol efi_hii_config_access;
 extern const struct efi_hii_database_protocol efi_hii_database;
@@ -145,8 +148,10 @@ extern const efi_guid_t efi_file_info_guid;
 /* GUID for file system information */
 extern const efi_guid_t efi_file_system_info_guid;
 extern const efi_guid_t efi_guid_device_path_utilities_protocol;
-/* GUID of the Unicode collation protocol */
+/* GUID of the deprecated Unicode collation protocol */
 extern const efi_guid_t efi_guid_unicode_collation_protocol;
+/* GUID of the Unicode collation protocol */
+extern const efi_guid_t efi_guid_unicode_collation_protocol2;
 extern const efi_guid_t efi_guid_hii_config_routing_protocol;
 extern const efi_guid_t efi_guid_hii_config_access_protocol;
 extern const efi_guid_t efi_guid_hii_database_protocol;
index 6501ee56aaf110ea152e7e7bbf97a6e827aa168f..fc04ea39d0ab3e5947f03ea4c835e32aa3fc78fb 100644 (file)
@@ -36,14 +36,14 @@ config EFI_LOADER_HII
          U-Boot implements enough of its features to be able to run the UEFI
          Shell, but not more than that.
 
-config EFI_UNICODE_COLLATION_PROTOCOL
+config EFI_UNICODE_COLLATION_PROTOCOL2
        bool "Unicode collation protocol"
        default y
        help
          The Unicode collation protocol is used for lexical comparisons. It is
          required to run the UEFI shell.
 
-if EFI_UNICODE_COLLATION_PROTOCOL
+if EFI_UNICODE_COLLATION_PROTOCOL2
 
 config EFI_UNICODE_CAPITALIZATION
        bool "Support Unicode capitalization"
@@ -54,6 +54,17 @@ config EFI_UNICODE_CAPITALIZATION
          set, only the the correct handling of the letters of the codepage
          used by the FAT file system is ensured.
 
+config EFI_UNICODE_COLLATION_PROTOCOL
+       bool "Deprecated version of the Unicode collation protocol"
+       default n
+       help
+         In EFI 1.10 a version of the Unicode collation protocol using ISO
+         639-2 language codes existed. This protocol is not part of the UEFI
+         specification any longer. Unfortunately it is required to run the
+         UEFI Self Certification Test (SCT) II, version 2.6, 2017.
+
+         Choose this option for testing only. It is bound to be removed.
+
 endif
 
 config EFI_LOADER_BOUNCE_BUFFER
index f3d6773bf6b1fa633d5feabf9c435124c60b9257..01769ea58ba619e154af28594a453abf214aec8e 100644 (file)
@@ -30,7 +30,7 @@ obj-y += efi_memory.o
 obj-y += efi_root_node.o
 obj-y += efi_runtime.o
 obj-y += efi_setup.o
-obj-$(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL) += efi_unicode_collation.o
+obj-$(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2) += efi_unicode_collation.o
 obj-y += efi_variable.o
 obj-y += efi_watchdog.o
 obj-$(CONFIG_LCD) += efi_gop.o
index ec6f5758ded3d7812eb47957ee142be77061affa..971bd5ffa3e96f19beef17e2bb758dadfb197250 100644 (file)
@@ -1916,10 +1916,17 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
 static efi_status_t EFIAPI efi_get_next_monotonic_count(uint64_t *count)
 {
        static uint64_t mono;
+       efi_status_t ret;
 
        EFI_ENTRY("%p", count);
+       if (!count) {
+               ret = EFI_INVALID_PARAMETER;
+               goto out;
+       }
        *count = mono++;
-       return EFI_EXIT(EFI_SUCCESS);
+       ret = EFI_SUCCESS;
+out:
+       return EFI_EXIT(ret);
 }
 
 /**
@@ -2334,6 +2341,7 @@ efi_status_t EFIAPI efi_install_multiple_protocol_interfaces
        efi_va_list argptr;
        const efi_guid_t *protocol;
        void *protocol_interface;
+       efi_handle_t old_handle;
        efi_status_t r = EFI_SUCCESS;
        int i = 0;
 
@@ -2346,6 +2354,17 @@ efi_status_t EFIAPI efi_install_multiple_protocol_interfaces
                if (!protocol)
                        break;
                protocol_interface = efi_va_arg(argptr, void*);
+               /* Check that a device path has not been installed before */
+               if (!guidcmp(protocol, &efi_guid_device_path)) {
+                       struct efi_device_path *dp = protocol_interface;
+
+                       r = EFI_CALL(efi_locate_device_path(protocol, &dp,
+                                                           &old_handle));
+                       if (r == EFI_SUCCESS) {
+                               r = EFI_ALREADY_STARTED;
+                               break;
+                       }
+               }
                r = EFI_CALL(efi_install_protocol_interface(
                                                handle, protocol,
                                                EFI_NATIVE_INTERFACE,
@@ -2453,9 +2472,16 @@ static efi_status_t EFIAPI efi_calculate_crc32(const void *data,
                                               efi_uintn_t data_size,
                                               u32 *crc32_p)
 {
+       efi_status_t ret = EFI_SUCCESS;
+
        EFI_ENTRY("%p, %zu", data, data_size);
+       if (!data || !data_size || !crc32_p) {
+               ret = EFI_INVALID_PARAMETER;
+               goto out;
+       }
        *crc32_p = crc32(0, data, data_size);
-       return EFI_EXIT(EFI_SUCCESS);
+out:
+       return EFI_EXIT(ret);
 }
 
 /**
index 051fc1d339f7b929f3a34111c0a9ddd47c34c08e..b2cb18e6d67021c194dff39914c5b401a6e1967d 100644 (file)
@@ -136,6 +136,11 @@ static efi_status_t EFIAPI efi_cout_output_string(
 
        EFI_ENTRY("%p, %p", this, string);
 
+       if (!this || !string) {
+               ret = EFI_INVALID_PARAMETER;
+               goto out;
+       }
+
        buf = malloc(utf16_utf8_strlen(string) + 1);
        if (!buf) {
                ret = EFI_OUT_OF_RESOURCES;
@@ -825,7 +830,7 @@ out:
  * efi_cin_set_state() - set toggle key state
  *
  * @this:              instance of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
- * @key_toggle_state:  key toggle state
+ * @key_toggle_state:  pointer to key toggle state
  * Return:             status code
  *
  * This function implements the SetState service of the
@@ -836,9 +841,9 @@ out:
  */
 static efi_status_t EFIAPI efi_cin_set_state(
                struct efi_simple_text_input_ex_protocol *this,
-               u8 key_toggle_state)
+               u8 *key_toggle_state)
 {
-       EFI_ENTRY("%p, %u", this, key_toggle_state);
+       EFI_ENTRY("%p, %p", this, key_toggle_state);
        /*
         * U-Boot supports multiple console input sources like serial and
         * net console for which a key toggle state cannot be set at all.
index f3a95790766472323da24337d6c722d87c0089a9..96fd08971b73eb05c55fc5011664b28f68c8dd34 100644 (file)
@@ -79,9 +79,8 @@ static char *dp_acpi(char *s, struct efi_device_path *dp)
                struct efi_device_path_acpi_path *adp =
                        (struct efi_device_path_acpi_path *)dp;
 
-               s += sprintf(s, "Acpi(PNP%04X", EISA_PNP_NUM(adp->hid));
-               s += sprintf(s, ",%d", adp->uid);
-               s += sprintf(s, ")");
+               s += sprintf(s, "Acpi(PNP%04X,%d)", EISA_PNP_NUM(adp->hid),
+                            adp->uid);
                break;
        }
        default:
index e0e222a70bffc2a1051a04c378fd3116ddf1981d..d71c663068258be8ec909b8d81a4d8d5ba088815 100644 (file)
@@ -392,7 +392,7 @@ static efi_status_t EFIAPI efi_net_transmit
        efi_timer_check();
 
        /* Check parameters */
-       if (!this) {
+       if (!this || !buffer) {
                ret = EFI_INVALID_PARAMETER;
                goto out;
        }
@@ -408,7 +408,7 @@ static efi_status_t EFIAPI efi_net_transmit
                 * TODO: We would need to create the header
                 * if header_size != 0
                 */
-               ret = EFI_INVALID_PARAMETER;
+               ret = EFI_UNSUPPORTED;
                goto out;
        }
 
@@ -466,7 +466,7 @@ static efi_status_t EFIAPI efi_net_receive
        efi_timer_check();
 
        /* Check parameters */
-       if (!this) {
+       if (!this || !buffer || !buffer_size) {
                ret = EFI_INVALID_PARAMETER;
                goto out;
        }
index d8496cc3c279abf35bd513dcbfdced1c1ba5f2d3..f68b0fdc610fc9577923c305cfb70cca3b8f0035 100644 (file)
@@ -60,10 +60,15 @@ efi_status_t efi_root_node_register(void)
                         /* Device path utilities protocol */
                         &efi_guid_device_path_utilities_protocol,
                         (void *)&efi_device_path_utilities,
+#if CONFIG_IS_ENABLED(EFI_UNICODE_COLLATION_PROTOCOL2)
 #if CONFIG_IS_ENABLED(EFI_UNICODE_COLLATION_PROTOCOL)
-                        /* Unicode collation protocol */
+                        /* Deprecated Unicode collation protocol */
                         &efi_guid_unicode_collation_protocol,
                         (void *)&efi_unicode_collation_protocol,
+#endif
+                        /* Current Unicode collation protocol */
+                        &efi_guid_unicode_collation_protocol2,
+                        (void *)&efi_unicode_collation_protocol2,
 #endif
 #if CONFIG_IS_ENABLED(EFI_LOADER_HII)
                         /* HII string protocol */
index 7f3ea3c77e4e18ff6009a6b82714fc03e9774ddf..06fddca1c47b5da3a670525736aa735082c5156d 100644 (file)
@@ -26,8 +26,8 @@ static const u16 codepage[] = CP1250;
 static const u16 codepage[] = CP437;
 #endif
 
-/* GUID of the EFI_UNICODE_COLLATION_PROTOCOL */
-const efi_guid_t efi_guid_unicode_collation_protocol =
+/* GUID of the EFI_UNICODE_COLLATION_PROTOCOL2 */
+const efi_guid_t efi_guid_unicode_collation_protocol2 =
        EFI_UNICODE_COLLATION_PROTOCOL2_GUID;
 
 /**
@@ -318,7 +318,7 @@ static bool EFIAPI efi_str_to_fat(struct efi_unicode_collation_protocol *this,
        return ret;
 }
 
-const struct efi_unicode_collation_protocol efi_unicode_collation_protocol = {
+const struct efi_unicode_collation_protocol efi_unicode_collation_protocol2 = {
        .stri_coll = efi_stri_coll,
        .metai_match = efi_metai_match,
        .str_lwr = efi_str_lwr,
@@ -327,3 +327,30 @@ const struct efi_unicode_collation_protocol efi_unicode_collation_protocol = {
        .str_to_fat = efi_str_to_fat,
        .supported_languages = "en",
 };
+
+/*
+ * In EFI 1.10 a version of the Unicode collation protocol using ISO 639-2
+ * language codes existed. This protocol is not part of the UEFI specification
+ * any longer. Unfortunately it is required to run the UEFI Self Certification
+ * Test (SCT) II, version 2.6, 2017. So we implement it here for the sole
+ * purpose of running the SCT. It can be removed when a compliant SCT is
+ * available.
+ */
+#if CONFIG_IS_ENABLED(EFI_UNICODE_COLLATION_PROTOCOL)
+
+/* GUID of the EFI_UNICODE_COLLATION_PROTOCOL */
+const efi_guid_t efi_guid_unicode_collation_protocol =
+       EFI_UNICODE_COLLATION_PROTOCOL_GUID;
+
+const struct efi_unicode_collation_protocol efi_unicode_collation_protocol = {
+       .stri_coll = efi_stri_coll,
+       .metai_match = efi_metai_match,
+       .str_lwr = efi_str_lwr,
+       .str_upr = efi_str_upr,
+       .fat_to_str = efi_fat_to_str,
+       .str_to_fat = efi_str_to_fat,
+       /* ISO 639-2 language code */
+       .supported_languages = "eng",
+};
+
+#endif
index 37728c3c165ddabf2af7ca7f254ffdf93bcfd54d..28b1aa7505ae2d1f31f41380adcae42252f0a18a 100644 (file)
@@ -202,8 +202,10 @@ efi_status_t EFIAPI efi_get_variable(u16 *variable_name,
                len /= 2;
                *data_size = len;
 
-               if (in_size < len)
-                       return EFI_EXIT(EFI_BUFFER_TOO_SMALL);
+               if (in_size < len) {
+                       ret = EFI_BUFFER_TOO_SMALL;
+                       goto out;
+               }
 
                if (!data)
                        return EFI_EXIT(EFI_INVALID_PARAMETER);
@@ -217,8 +219,10 @@ efi_status_t EFIAPI efi_get_variable(u16 *variable_name,
 
                *data_size = len;
 
-               if (in_size < len)
-                       return EFI_EXIT(EFI_BUFFER_TOO_SMALL);
+               if (in_size < len) {
+                       ret = EFI_BUFFER_TOO_SMALL;
+                       goto out;
+               }
 
                if (!data)
                        return EFI_EXIT(EFI_INVALID_PARAMETER);
@@ -232,10 +236,11 @@ efi_status_t EFIAPI efi_get_variable(u16 *variable_name,
                return EFI_EXIT(EFI_DEVICE_ERROR);
        }
 
+out:
        if (attributes)
                *attributes = attr & EFI_VARIABLE_MASK;
 
-       return EFI_EXIT(EFI_SUCCESS);
+       return EFI_EXIT(ret);
 }
 
 static char *efi_variables_list;
index d0bebc7d0c4f37d70b895d07223fafd389931e61..cfbb40c8910c2364295867bcc19ee8231ea33a17 100644 (file)
@@ -38,7 +38,8 @@ efi_selftest_variables.o \
 efi_selftest_watchdog.o
 
 obj-$(CONFIG_EFI_DEVICE_PATH_TO_TEXT) += efi_selftest_devicepath.o
-obj-$(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL) += efi_selftest_unicode_collation.o
+obj-$(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2) += \
+efi_selftest_unicode_collation.o
 
 obj-$(CONFIG_CPU_V7) += efi_selftest_unaligned.o
 obj-$(CONFIG_EFI_LOADER_HII) += efi_selftest_hii.o