[PATCH] xen/efi: Use blexit() instead of BUG_ON() in read_file()

Szymon Acedański posted 1 patch 5 days, 14 hours ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20260602122441.2961974-1-accek@invisiblethingslab.com
There is a newer version of this series
xen/common/efi/boot.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] xen/efi: Use blexit() instead of BUG_ON() in read_file()
Posted by Szymon Acedański 5 days, 14 hours ago
Follow-up to 880e40b187aa ("xen/efi: Fix boot from a device without
a file system"), which added a BUG_ON() guard in read_file().

But as Jan pointed out, before ExitBootServices BUG_ON()
is not functional. It results in a hang with no message.

On the other hand blexit() prints a message and returns back
to the bootloader.

Link: https://lore.kernel.org/xen-devel/bb0f007e-697e-4501-97ea-3b59cf494ec6@suse.com/T/#m4725c8cbc0946a5533aea03fc240267ef139648d
Signed-off-by: Szymon Acedański <accek@invisiblethingslab.com>
---
blexit() has been chosen over PrintErrMesg(), as the latter
is predominantly used in cases where an EFI call fails
(and it prints the status).

 xen/common/efi/boot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 2971ea8696..8f24df9bc2 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -849,7 +849,8 @@ static bool __init read_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name,
     if ( !name )
         PrintErrMesg(L"No filename", EFI_OUT_OF_RESOURCES);
 
-    BUG_ON(!dir_handle);
+    if ( !dir_handle )
+        blexit(L"BUG: !dir_handle in read_file()");
 
     what = L"Open";
     ret = dir_handle->Open(dir_handle, &FileHandle, name,
-- 
2.53.0


Re: [PATCH] xen/efi: Use blexit() instead of BUG_ON() in read_file()
Posted by Jan Beulich 5 days, 14 hours ago
On 02.06.2026 14:24, Szymon Acedański wrote:
> Follow-up to 880e40b187aa ("xen/efi: Fix boot from a device without
> a file system"), which added a BUG_ON() guard in read_file().
> 
> But as Jan pointed out, before ExitBootServices BUG_ON()
> is not functional. It results in a hang with no message.
> 
> On the other hand blexit() prints a message and returns back
> to the bootloader.
> 
> Link: https://lore.kernel.org/xen-devel/bb0f007e-697e-4501-97ea-3b59cf494ec6@suse.com/T/#m4725c8cbc0946a5533aea03fc240267ef139648d

While Linux uses Link:, as per sending-patches.pandoc we don't. It wants
to be Reported-by: instead, and there wants to be a Fixes: tag.

> Signed-off-by: Szymon Acedański <accek@invisiblethingslab.com>

With the above properly sorted:
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan

Re: [PATCH for-4.22] xen/efi: Use blexit() instead of BUG_ON() in read_file()
Posted by Andrew Cooper 5 days, 14 hours ago
On 02/06/2026 1:34 pm, Jan Beulich wrote:
> On 02.06.2026 14:24, Szymon Acedański wrote:
>> Follow-up to 880e40b187aa ("xen/efi: Fix boot from a device without
>> a file system"), which added a BUG_ON() guard in read_file().
>>
>> But as Jan pointed out, before ExitBootServices BUG_ON()
>> is not functional. It results in a hang with no message.
>>
>> On the other hand blexit() prints a message and returns back
>> to the bootloader.
>>
>> Link: https://lore.kernel.org/xen-devel/bb0f007e-697e-4501-97ea-3b59cf494ec6@suse.com/T/#m4725c8cbc0946a5533aea03fc240267ef139648d
> While Linux uses Link:, as per sending-patches.pandoc we don't. It wants
> to be Reported-by: instead, and there wants to be a Fixes: tag.
>
>> Signed-off-by: Szymon Acedański <accek@invisiblethingslab.com>
> With the above properly sorted:
> Reviewed-by: Jan Beulich <jbeulich@suse.com>

CC Oleksi.  We're past RC1 now, so everything needs release acks.

~Andrew

Re: [PATCH for-4.22] xen/efi: Use blexit() instead of BUG_ON() in read_file()
Posted by Oleksii Kurochko 5 days, 12 hours ago

On 6/2/26 3:10 PM, Andrew Cooper wrote:
> On 02/06/2026 1:34 pm, Jan Beulich wrote:
>> On 02.06.2026 14:24, Szymon Acedański wrote:
>>> Follow-up to 880e40b187aa ("xen/efi: Fix boot from a device without
>>> a file system"), which added a BUG_ON() guard in read_file().
>>>
>>> But as Jan pointed out, before ExitBootServices BUG_ON()
>>> is not functional. It results in a hang with no message.
>>>
>>> On the other hand blexit() prints a message and returns back
>>> to the bootloader.
>>>
>>> Link: https://lore.kernel.org/xen-devel/bb0f007e-697e-4501-97ea-3b59cf494ec6@suse.com/T/#m4725c8cbc0946a5533aea03fc240267ef139648d
>> While Linux uses Link:, as per sending-patches.pandoc we don't. It wants
>> to be Reported-by: instead, and there wants to be a Fixes: tag.
>>
>>> Signed-off-by: Szymon Acedański <accek@invisiblethingslab.com>
>> With the above properly sorted:
>> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> 
> CC Oleksi.  We're past RC1 now, so everything needs release acks.

Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>

Thanks.

~ Oleksii