Skip to contentSkip to conversation

Fix PCIe LER when GRUB2 accesses non-enabled MMIO data from VGA

PATCH In review [email protected] 4 participants 7 messages Mar 28, 2018 – Mar 29, 2018 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 Fix PCIe LER when GRUB2 accesses non-enabled MMIO data from VGA

A GPU inserted into a PCIe I/O slot disappears during system startup. The problem centers around GRUB and a specific VGA init function in efi_uga.c. This causes an LER (link error recorvery) because the MMIO memory has not been enabled before attempting access.

The fix is to add the same coding used in other VGA drivers, specifically to add a check to insure that it is indeed a VGA controller. And then enable the MMIO address space with the specific bits.

---
v1:change class to subclass, remove parens around "enable mem" code

---
 grub-2.02/grub-core/video/efi_uga.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
grub-core/video/efi_uga.c +10 -1
Index: grub-2.02/grub-core/video/efi_uga.c
===================================================================
@@ -95,9 +95,18 @@ find_card (grub_pci_device_t dev, grub_p
 {
   struct find_framebuf_ctx *ctx = data;
   grub_pci_address_t addr;
+  grub_pci_address_t rcaddr;
+  grub_uint32_t subclass;
 
   addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
-  if (grub_pci_read (addr) >> 24 == 0x3)
+  subclass = (grub_pci_read (addr) >> 16) & 0xffff;
+  if (subclass != GRUB_PCI_CLASS_SUBCLASS_VGA)
+    return 0;
+
+  /* Enable MEM address spaces */
+  rcaddr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
+  grub_pci_write_word (rcaddr, grub_pci_read_word (rcaddr) | GRUB_PCI_COMMAND_MEM_ENABLED);
+
     {
       int i;
 
#2 lore raw
Quoted 5 lines · On Wed, Mar 28, 2018 at 11:42:18AM -0500, [email protected] wrote:

A GPU inserted into a PCIe I/O slot disappears during system startup. The problem centers around GRUB and a specific VGA init function in efi_uga.c. This causes an LER (link error recorvery) because the MMIO memory has not been enabled before attempting access.

Quoted 7 lines

The fix is to add the same coding used in other VGA drivers, specifically to add a check to insure that it is indeed a VGA controller. And then enable the MMIO address space with the specific bits.

Well, please do not add somebody RB tag if he/she did not explicitly asked you to do that. And even in that case I was not able to look at this patch in advance. So, my RB should not be here. Additionally, in this situation I would like to ask if Michael approved his RB?

Anyway, patch LGTM except one nitpick. I will apply the patch, in a week or so, with Michael's RB if I get confirmation that he approved it earlier.

Quoted 11 lines

---
v1:change class to subclass, remove parens around "enable mem" code

---
 grub-2.02/grub-core/video/efi_uga.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Index: grub-2.02/grub-core/video/efi_uga.c
===================================================================

grub-core/video/efi_uga.c find_card (grub_pci_device_t dev, grub_p · line 98

Quoted 4 lines
grub-core/video/efi_uga.c +1 -0
@@ -95,9 +95,18 @@ find_card (grub_pci_device_t dev, grub_p
 {
   struct find_framebuf_ctx *ctx = data;
   grub_pci_address_t addr;
+  grub_pci_address_t rcaddr;

This line should be together with the addr. I will fix it before committing the patch.

Thank you for doing the work.

Daniel

#3 lore raw
Quoted 10 lines · Daniel Kiper
Quoted 9 lines · On Wed, Mar 28, 2018 at 11:42:18AM -0500, [email protected] wrote:

A GPU inserted into a PCIe I/O slot disappears during system startup. The problem centers around GRUB and a specific VGA init function in efi_uga.c. This causes an LER (link error recorvery) because the MMIO memory has not been enabled before attempting access.

The fix is to add the same coding used in other VGA drivers, specifically to add a check to insure that it is indeed a VGA controller. And then enable the MMIO address space with the specific bits.

Quoted 8 lines
Quoted 3 lines

Well, please do not add somebody RB tag if he/she did not explicitly asked you to do that. And even in that case I was not able to look at this patch in advance. So, my RB should not be here. Additionally, in this situation I would like to ask if Michael approved his RB?

We did have discussion about the patch before it was submitted upstream but I did not ask for RB as well.

Quoted 3 lines

Anyway, patch LGTM except one nitpick. I will apply the patch, in a week or so, with Michael's RB if I get confirmation that he approved it earlier.

As I did not ask for it, it has to be removed.

Thanks for notifying this.
Michael

Quoted 28 lines
Quoted 12 lines

---
v1:change class to subclass, remove parens around "enable mem" code

---
 grub-2.02/grub-core/video/efi_uga.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Index: grub-2.02/grub-core/video/efi_uga.c
===================================================================

grub-core/video/efi_uga.c find_card (grub_pci_device_t dev, grub_p · line 98

Quoted 4 lines
grub-core/video/efi_uga.c +1 -0
@@ -95,9 +95,18 @@ find_card (grub_pci_device_t dev, grub_p
 {
   struct find_framebuf_ctx *ctx = data;
   grub_pci_address_t addr;
+  grub_pci_address_t rcaddr;

This line should be together with the addr. I will fix it before committing the patch.

Thank you for doing the work.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#4 lore raw
Quoted 20 lines · Michael Chang
Quoted 10 lines · Daniel Kiper
Quoted 9 lines · On Wed, Mar 28, 2018 at 11:42:18AM -0500, [email protected] wrote:

A GPU inserted into a PCIe I/O slot disappears during system startup. The problem centers around GRUB and a specific VGA init function in efi_uga.c. This causes an LER (link error recorvery) because the MMIO memory has not been enabled before attempting access.

The fix is to add the same coding used in other VGA drivers, specifically to add a check to insure that it is indeed a VGA controller. And then enable the MMIO address space with the specific bits.

Quoted 8 lines
Quoted 3 lines

Well, please do not add somebody RB tag if he/she did not explicitly asked you to do that. And even in that case I was not able to look at this patch in advance. So, my RB should not be here. Additionally, in this situation I would like to ask if Michael approved his RB?

Quoted 7 lines

We did have discussion about the patch before it was submitted upstream but I did not ask for RB as well.

Quoted 2 lines

Anyway, patch LGTM except one nitpick. I will apply the patch, in a week or so, with Michael's RB if I get confirmation that he approved it earlier.

As I did not ask for it, it has to be removed.

OK, I will commit this patch without your RB.

Daniel

#5 lore raw
Quoted 24 lines · Daniel Kiper
Quoted 23 lines · Michael Chang
Quoted 10 lines · Daniel Kiper
Quoted 9 lines · On Wed, Mar 28, 2018 at 11:42:18AM -0500, [email protected] wrote:

A GPU inserted into a PCIe I/O slot disappears during system startup. The problem centers around GRUB and a specific VGA init function in efi_uga.c. This causes an LER (link error recorvery) because the MMIO memory has not been enabled before attempting access.

The fix is to add the same coding used in other VGA drivers, specifically to add a check to insure that it is indeed a VGA controller. And then enable the MMIO address space with the specific bits.

Quoted 8 lines
Quoted 3 lines

Well, please do not add somebody RB tag if he/she did not explicitly asked you to do that. And even in that case I was not able to look at this patch in advance. So, my RB should not be here. Additionally, in this situation I would like to ask if Michael approved his RB?

We did have discussion about the patch before it was submitted upstream but I did not ask for RB as well.

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Anyway, patch LGTM except one nitpick. I will apply the patch, in a week or so, with Michael's RB if I get confirmation that he approved it earlier.

As I did not ask for it, it has to be removed.

OK, I will commit this patch without your RB.

Daniel

Sorry, I was not aware of this custom. I thought that if someone reviewed the code then that was an indication that it should be noted. I am aware of the more restrictive Acked-by which is normally sent by the "acker" to the submitter. I will be more mindful of this in the future. (This is my first posting to any of the GNU mail lists).

Thanks,
Mike

Acked-by foo: Foo took a quick glance at the proposed changes and thinks this is a sensible change Reviewed-by foo: Foo did a detailed review of the code and did not find any issues
#6 lore raw

Hi,

Quoted 30 lines · Mike Travis
Quoted 27 lines · Daniel Kiper
Quoted 26 lines · Michael Chang
Quoted 10 lines · Daniel Kiper
Quoted 9 lines · On Wed, Mar 28, 2018 at 11:42:18AM -0500, [email protected] wrote:

A GPU inserted into a PCIe I/O slot disappears during system startup. The problem centers around GRUB and a specific VGA init function in efi_uga.c.  This causes an LER (link error recorvery) because the MMIO memory has not been enabled before attempting access.

The fix is to add the same coding used in other VGA drivers, specifically to add a check to insure that it is indeed a VGA controller.  And then enable the MMIO address space with the specific bits.

Quoted 8 lines
Quoted 3 lines

Well, please do not add somebody RB tag if he/she did not explicitly asked you to do that. And even in that case I was not able to look at this patch in advance. So, my RB should not be here. Additionally, in this situation I would like to ask if Michael approved his RB?

We did have discussion about the patch before it was submitted upstream but I did not ask for RB as well.

Quoted 2 lines

Anyway, patch LGTM except one nitpick. I will apply the patch, in a week or so, with Michael's RB if I get confirmation that he approved it earlier.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

As I did not ask for it, it has to be removed.

OK, I will commit this patch without your RB.

Daniel

Sorry, I was not aware of this custom.  I thought that if someone reviewed the code then that was an indication that it should be noted. I am aware of the more restrictive Acked-by which is normally sent by the "acker" to the submitter.  I will be more mindful of this in the future.  (This is my first posting to any of the GNU mail lists).

Reviewed-by actually is stronger then Acked-by at least that is what I believe, I've always interpreted these 2 as:

Acked-by foo: Foo took a quick glance at the proposed changes and thinks this is a sensible change
Reviewed-by foo: Foo did a detailed review of the code and did not find any issues

Regards,

Hans

#7 lore raw
Quoted 48 lines · Hans de Goede

Hi,

Quoted 45 lines · Mike Travis
Quoted 30 lines · Daniel Kiper
Quoted 29 lines · Michael Chang
Quoted 11 lines · Daniel Kiper
Quoted 10 lines · On Wed, Mar 28, 2018 at 11:42:18AM -0500, [email protected] wrote:

A GPU inserted into a PCIe I/O slot disappears during system startup. The problem centers around GRUB and a specific VGA init function in efi_uga.c.?? This causes an LER (link error recorvery) because the MMIO memory has not been enabled before attempting access.

The fix is to add the same coding used in other VGA drivers, specifically
to add a check to insure that it is indeed a VGA controller.?? And then enable the MMIO address space with the specific bits.

Quoted 8 lines
Quoted 3 lines

Well, please do not add somebody RB tag if he/she did not explicitly asked you to do that. And even in that case I was not able to look at this patch in advance. So, my RB should not be here. Additionally, in this situation I would like to ask if Michael approved his RB?

We did have discussion about the patch before it was submitted upstream but I
did not ask for RB as well.

Quoted 3 lines

Anyway, patch LGTM except one nitpick. I will apply the patch, in a week or
so, with Michael's RB if I get confirmation that he approved it earlier.

Quoted 6 lines
Quoted 1 line

As I did not ask for it, it has to be removed.

OK, I will commit this patch without your RB.

Daniel

Sorry, I was not aware of this custom.?? I thought that if someone reviewed the code then that was an indication that it should be noted. I am aware of the more restrictive Acked-by which is normally sent by the "acker" to the submitter.?? I will be more mindful of this in the future.?? (This is my first posting to any of the GNU mail lists).

No problem.

Quoted 7 lines

Reviewed-by actually is stronger then Acked-by at least that is what I believe, I've always interpreted these 2 as:

Acked-by: foo: Foo took a quick glance at the proposed changes and
thinks this is a sensible change
Reviewed-by: foo: Foo did a detailed review of the code and did not find any issues

I think that you can take look at Documentation/process/submitting-patches.rst in Linux kernel source. Most of us more or less adhere to this. Well, I think that I should put something similar into GRUB2 tree.

Daniel