Merge tag 'efi-2019-10-rc5' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi

Pull request for UEFI sub-system for v2019.10-rc5

Bug fixes for the SetVariable() boot service.
diff --git a/lib/efi_loader/efi_unicode_collation.c b/lib/efi_loader/efi_unicode_collation.c
index 243c51a..c700be8 100644
--- a/lib/efi_loader/efi_unicode_collation.c
+++ b/lib/efi_loader/efi_unicode_collation.c
@@ -43,11 +43,6 @@
  * See the Unified Extensible Firmware Interface (UEFI) specification for
  * details.
  *
- * TODO:
- * The implementation does not follow the Unicode collation algorithm.
- * For ASCII characters it results in the same sort order as EDK2.
- * We could use table UNICODE_CAPITALIZATION_TABLE for better results.
- *
  * Return:	0: s1 == s2, > 0: s1 > s2, < 0: s1 < s2
  */
 static efi_intn_t EFIAPI efi_stri_coll(
diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index 48ee255..4c554c5 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -443,8 +443,6 @@
 	if (ret)
 		goto out;
 
-#define ACCESS_ATTR (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)
-
 	old_val = env_get(native_name);
 	if (old_val) {
 		old_val = parse_attr(old_val, &attr);
@@ -455,7 +453,9 @@
 			goto out;
 		}
 
-		if ((data_size == 0) || !(attributes & ACCESS_ATTR)) {
+		if ((data_size == 0 &&
+		     !(attributes & EFI_VARIABLE_APPEND_WRITE)) ||
+		    !attributes) {
 			/* delete the variable: */
 			env_set(native_name, NULL);
 			ret = EFI_SUCCESS;
@@ -470,7 +470,7 @@
 
 		if (attributes & EFI_VARIABLE_APPEND_WRITE) {
 			if (!prefix(old_val, "(blob)")) {
-				return EFI_DEVICE_ERROR;
+				ret = EFI_DEVICE_ERROR;
 				goto out;
 			}
 			old_size = strlen(old_val);
@@ -478,8 +478,9 @@
 			old_size = 0;
 		}
 	} else {
-		if ((data_size == 0) || !(attributes & ACCESS_ATTR) ||
-		    (attributes & EFI_VARIABLE_APPEND_WRITE)) {
+		if ((data_size == 0 &&
+		     !(attributes & EFI_VARIABLE_APPEND_WRITE)) ||
+		    !attributes) {
 			/* delete, but nothing to do */
 			ret = EFI_NOT_FOUND;
 			goto out;