EFI Network drivers being disabled when booting with Grub via PXE


Gustavo Henrique
 

Hello all,
I am facing an issue, if anyone can help me with this, I would appreciate a lot.
When I boot directly on Grub via USB drive then select UEFI Shell .efi (also in USB drive) to boot, the network drivers work fine, I can list them using drivers command as shown bellow (just some examples, not all network drivers are listed):

19E 0000000A D N N 1 0 Simple Network Protocol Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(A2F436EA-A127-4EF8-957C-8048606FF670)
1A3 0000000A B N N 2 11 IP4 Network Service Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(9FB1A1F3-3B71-4324-B39A-745CBB015FFF)
1AA 0000000A B N N 2 2 TCP Network Service Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(1A7E4468-2F55-4A56-903C-01265EB7622B)
1AC 0000000A B N N 8 1 UEFI PXE Base Code Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(B95E9FDA-26DE-48D2-8807-1F9107AC5E3A)

So, the problem isn't with Grub itself. The problem happens when I boot via PXE. The server sends the Grub .efi file, that is loaded with no problems, and then I boot the UEFI Shell. Then, all the network drivers seems to be disabled, take a look to drivers command:

19E 0000000A D N N 1 0 Simple Network Protocol Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(A2F436EA-A127-4EF8-957C-8048606FF670)
1A3 0000000A ? N N 0 0 IP4 Network Service Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(9FB1A1F3-3B71-4324-B39A-745CBB015FFF)
1AA 0000000A ? N N 0 0 TCP Network Service Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(1A7E4468-2F55-4A56-903C-01265EB7622B)
1AC 0000000A ? N N 0 0 UEFI PXE Base Code Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(B95E9FDA-26DE-48D2-8807-1F9107AC5E3A)

As you can see, except for the Simple Network Protocol Driver, all network drivers are shown as "?" type and no devices are managed by them (they look all disabled). I try to connect them using "connect -r" command, it does nothing. Tried also "reconnect" command, but it hangs forever with the prompt cursor blinking.
Do you know why it's happening and how I can bypass it?

PS.: Booting directly on UEFI Shell via PXE this issue does not reproduce, the drivers are ok, the problem is the combination PXE + Grub.

Thanks in advance!


Laszlo Ersek
 

On 06/30/21 19:42, gustavohenriquesm@... wrote:
Hello all,
I am facing an issue, if anyone can help me with this, I would appreciate a lot.
When I boot directly on Grub via USB drive then select UEFI Shell .efi (also in USB drive) to boot, the network drivers work fine, I can list them using drivers command as shown bellow (just some examples, not all network drivers are listed):

19E 0000000A D N N 1 0 Simple Network Protocol Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(A2F436EA-A127-4EF8-957C-8048606FF670)
1A3 0000000A B N N 2 11 IP4 Network Service Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(9FB1A1F3-3B71-4324-B39A-745CBB015FFF)
1AA 0000000A B N N 2 2 TCP Network Service Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(1A7E4468-2F55-4A56-903C-01265EB7622B)
1AC 0000000A B N N 8 1 UEFI PXE Base Code Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(B95E9FDA-26DE-48D2-8807-1F9107AC5E3A)

So, the problem isn't with Grub itself. The problem happens when I boot via PXE. The server sends the Grub .efi file, that is loaded with no problems, and then I boot the UEFI Shell. Then, all the network drivers seems to be disabled, take a look to drivers command:

19E 0000000A D N N 1 0 Simple Network Protocol Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(A2F436EA-A127-4EF8-957C-8048606FF670)
1A3 0000000A ? N N 0 0 IP4 Network Service Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(9FB1A1F3-3B71-4324-B39A-745CBB015FFF)
1AA 0000000A ? N N 0 0 TCP Network Service Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(1A7E4468-2F55-4A56-903C-01265EB7622B)
1AC 0000000A ? N N 0 0 UEFI PXE Base Code Driver Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(B95E9FDA-26DE-48D2-8807-1F9107AC5E3A)

As you can see, except for the Simple Network Protocol Driver, all network drivers are shown as "?" type and no devices are managed by them (they look all disabled). I try to connect them using "connect -r" command, it does nothing. Tried also "reconnect" command, but it hangs forever with the prompt cursor blinking.
Do you know why it's happening and how I can bypass it?

PS.: Booting directly on UEFI Shell via PXE this issue does not reproduce, the drivers are ok, the problem is the combination PXE + Grub.

Thanks in advance!
When you boot grub via PXE, grub will open the SNP interface (IIRC) in
exclusive driver mode, to force off all other (dependent) drivers, such
as MNP, ARP, IP, TCP, and so on. This is in preparation for grub itself
netbooting the next stages (kernel + initrd) via TFTP, if I understand
correctly, for which grub wants to use SNP without interference from
other drivers. Netbooting grub, then launching the UEFI shell *from*
grub, is a really strange use case, AFAICT, and grub might not release SNP.

Just a guess.
Laszlo


Gustavo Henrique
 

Hi Laszlo,

> Netbooting grub, then launching the UEFI shell *from*
grub, is a really strange use case
That was just for testing purposes, the real scenario is another
application that runs on UEFI and sends some files to a tftp server.

When you boot grub via PXE, grub will open the SNP interface (IIRC) in
exclusive driver mode, to force off all other (dependent) drivers, such
as MNP, ARP, IP, TCP, and so on
That was exactly the problem.
GRUB opens network protocol in exclusive mode, as you said (Code snippet
from the GRUB network driver):

/* Try to reopen SNP exlusively to close any active MNP protocol instance
that may compete for packet polling
*/
net = grub_efi_open_protocol (dev->efi_handle, &net_io_guid,
GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE);

Changing this line of the code solves it.


Thank you so much sir!

Em qui., 1 de jul. de 2021 às 08:39, Laszlo Ersek <lersek@...>
escreveu:

On 06/30/21 19:42, gustavohenriquesm@... wrote:
Hello all,
I am facing an issue, if anyone can help me with this, I would
appreciate a lot.
When I boot directly on Grub via USB drive then select UEFI Shell .efi
(also in USB drive) to boot, the network drivers work fine, I can list them
using drivers command as shown bellow (just some examples, not all network
drivers are listed):

19E 0000000A D N N 1 0 Simple Network Protocol Driver
Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(A2F436EA-A127-4EF8-957C-8048606FF670)
1A3 0000000A B N N 2 11 IP4 Network Service Driver
Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(9FB1A1F3-3B71-4324-B39A-745CBB015FFF)
1AA 0000000A B N N 2 2 TCP Network Service Driver
Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(1A7E4468-2F55-4A56-903C-01265EB7622B)
1AC 0000000A B N N 8 1 UEFI PXE Base Code Driver
Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(B95E9FDA-26DE-48D2-8807-1F9107AC5E3A)

So, the problem isn't with Grub itself. The problem happens when I boot
via PXE. The server sends the Grub .efi file, that is loaded with no
problems, and then I boot the UEFI Shell. Then, all the network drivers
seems to be disabled, take a look to drivers command:

19E 0000000A D N N 1 0 Simple Network Protocol Driver
Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(A2F436EA-A127-4EF8-957C-8048606FF670)
1A3 0000000A ? N N 0 0 IP4 Network Service Driver
Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(9FB1A1F3-3B71-4324-B39A-745CBB015FFF)
1AA 0000000A ? N N 0 0 TCP Network Service Driver
Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(1A7E4468-2F55-4A56-903C-01265EB7622B)
1AC 0000000A ? N N 0 0 UEFI PXE Base Code Driver
Fv(AF4A9118-29A7-4F62-BB8C-E5B79013CB2E)/FvFile(B95E9FDA-26DE-48D2-8807-1F9107AC5E3A)

As you can see, except for the Simple Network Protocol Driver, all
network drivers are shown as "?" type and no devices are managed by them
(they look all disabled). I try to connect them using "connect -r" command,
it does nothing. Tried also "reconnect" command, but it hangs forever with
the prompt cursor blinking.
Do you know why it's happening and how I can bypass it?

PS.: Booting directly on UEFI Shell via PXE this issue does not
reproduce, the drivers are ok, the problem is the combination PXE + Grub.

Thanks in advance!
When you boot grub via PXE, grub will open the SNP interface (IIRC) in
exclusive driver mode, to force off all other (dependent) drivers, such
as MNP, ARP, IP, TCP, and so on. This is in preparation for grub itself
netbooting the next stages (kernel + initrd) via TFTP, if I understand
correctly, for which grub wants to use SNP without interference from
other drivers. Netbooting grub, then launching the UEFI shell *from*
grub, is a really strange use case, AFAICT, and grub might not release SNP.

Just a guess.
Laszlo