Re: [PATCH] Modify UEFI anti-bricking code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



於 六,2013-06-01 於 16:06 -0400,Matthew Garrett 提到:
> +               unsigned long dummy_size = remaining_size + 1024;
> +               void *dummy = kmalloc(dummy_size, GFP_ATOMIC);
> +               efi_char16_t efi_name[6] = { 'D', 'U', 'M', 'M', 'Y', 0 };
> +               efi_guid_t guid = EFI_GUID(0x4424ac57, 0xbe4b, 0x47dd, 0x9e,
> +                                          0x97, 0xed, 0x50, 0xf0, 0x9f, 0x92,
> +                                          0xa9);
> +
> +               status = efi.set_variable(efi_name, &guid, attributes,
> +                                         dummy_size, dummy);
> +
> +               if (status == EFI_SUCCESS) {
> +                       /*
> +                        * This should have failed, so if it didn't make sure
> +                        * that we delete it...
> +                        */
> +                       efi.set_variable(efi_name, &guid, attributes, 0,
> +                                        dummy);
> +               } 

Oliver raised a question for if power fails between that succesful
attempt and the deletion?

Due to the create/delete operating are not atomic, I think that will be
better we try to delete DUMMY object in efi_enter_virtual_mode() or when
efivars initial.

The following diff tested on OVMF for delete DUMMY object when system
boot, for reference.


Thanks a lot!
Joey Lee


diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 63e167a..72770b0 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -861,6 +861,10 @@ void __init efi_enter_virtual_mode(void)
 	u64 end, systab, start_pfn, end_pfn;
 	void *p, *va, *new_memmap = NULL;
 	int count = 0;
+	efi_char16_t efi_name[6] = { 'D', 'U', 'M', 'M', 'Y', 0 };
+	efi_guid_t guid = EFI_GUID(0x4424ac57, 0xbe4b, 0x47dd, 0x9e,
+				   0x97, 0xed, 0x50, 0xf0, 0x9f, 0x92,
+				   0xa9);
 
 	efi.systab = NULL;
 
@@ -981,6 +985,9 @@ void __init efi_enter_virtual_mode(void)
 		runtime_code_page_mkexec();
 
 	kfree(new_memmap);
+
+	/* clean DUMMY object */
+	efi.set_variable(efi_name, &guid, 0, 0, NULL);
 }
 
 /*


--
To unsubscribe from this list: send the line "unsubscribe linux-efi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux