mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] vgacon: Fall back to the dummy console if mapping VGA memory fails
@ 2026-11-12  0:28 Matt Turner
  2026-11-12  8:47 ` Magnus Lindholm
  0 siblings, 1 reply; 4+ messages in thread
From: Matt Turner @ 2026-11-12  0:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Helge Deller
  Cc: linux-fbdev, dri-devel, linux-kernel, linux-alpha, stable, Matt Turner

On Alpha, setup_arch() registers vgacon whenever CONFIG_VGA_CONSOLE is
enabled. On Marvel (EV7) systems whose SRM console is serial, no VGA
hose is set, so marvel_ioremap() finds no hose for 0xb8000 and returns
NULL. vgacon_startup() then probes video memory through that NULL
pointer and oopses in console_init():

  Unable to handle kernel paging request at virtual address 0000000000000000
  pc is at vgacon_startup+0x174/0x910

VGA_MAP_MEM() is ioremap() on Alpha and powerpc and can fail. Treat
failure like a failed probe and fall back to the dummy console. If a
VGA card is present, locate_and_init_vga() still switches to vgacon
once PCI is up.

Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
 drivers/video/console/vgacon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index e7e6750f1f87..09f7c376b468 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -324,6 +324,8 @@ static const char *vgacon_startup(void)
 	}
 
 	vga_vram_base = VGA_MAP_MEM(vga_vram_base, vga_vram_size);
+	if (!vga_vram_base)
+		goto no_vga;
 	vga_vram_end = vga_vram_base + vga_vram_size;
 
 	/*

---
base-commit: fa4ad798f6f681031775266044ba1b0cf3c670bd
change-id: 20261111-vgacon-ioremap-null-ad4c7184b807

Best regards,
--  
Matt Turner <mattst88@gmail.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] vgacon: Fall back to the dummy console if mapping VGA memory fails
  2026-11-12  0:28 [PATCH] vgacon: Fall back to the dummy console if mapping VGA memory fails Matt Turner
@ 2026-11-12  8:47 ` Magnus Lindholm
  2026-11-12  9:23   ` Michael Cree
  2026-11-12 10:45   ` Helge Deller
  0 siblings, 2 replies; 4+ messages in thread
From: Magnus Lindholm @ 2026-11-12  8:47 UTC (permalink / raw)
  To: Matt Turner
  Cc: Greg Kroah-Hartman, Helge Deller, linux-fbdev, dri-devel,
	linux-kernel, linux-alpha, stable

Hi Matt,

On Thu, Nov 12, 2026 at 1:30 AM Matt Turner <mattst88@gmail.com> wrote:
>
> On Alpha, setup_arch() registers vgacon whenever CONFIG_VGA_CONSOLE is
> enabled. On Marvel (EV7) systems whose SRM console is serial, no VGA
> hose is set, so marvel_ioremap() finds no hose for 0xb8000 and returns
> NULL. vgacon_startup() then probes video memory through that NULL
> pointer and oopses in console_init():
>
>   Unable to handle kernel paging request at virtual address 0000000000000000
>   pc is at vgacon_startup+0x174/0x910
>
> VGA_MAP_MEM() is ioremap() on Alpha and powerpc and can fail. Treat
> failure like a failed probe and fall back to the dummy console. If a
> VGA card is present, locate_and_init_vga() still switches to vgacon
> once PCI is up.
>
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Matt Turner <mattst88@gmail.com>
> ---
>  drivers/video/console/vgacon.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
> index e7e6750f1f87..09f7c376b468 100644
> --- a/drivers/video/console/vgacon.c
> +++ b/drivers/video/console/vgacon.c
> @@ -324,6 +324,8 @@ static const char *vgacon_startup(void)
>         }
>
>         vga_vram_base = VGA_MAP_MEM(vga_vram_base, vga_vram_size);
> +       if (!vga_vram_base)
> +               goto no_vga;
>         vga_vram_end = vga_vram_base + vga_vram_size;
>
>         /*
>
> ---
> base-commit: fa4ad798f6f681031775266044ba1b0cf3c670bd
> change-id: 20261111-vgacon-ioremap-null-ad4c7184b807
>
> Best regards,
> --
> Matt Turner <mattst88@gmail.com>
>
>

Nice fix! this must have been lingering here for a long time?
Cross-builds passed for generic Alpha, including Marvel. The shared
vgacon code also compiled successfully for x86-64.

Alpha QEMU fault injection confirmed the early dummy fallback and
successful VGA takeover when only the first mapping fails. Without
your check, the injected NULL mapping faults.

Forcing the later mapping to fail too exposes a separate takeover
issue: the console core installs vgacon despite the failed mapping,
leading to a NULL dereference. I don't see that as blocking this fix:
finding the VGA hose normally resolves the mapping failure on Marvel.

Reviewed-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Magnus Lindholm <linmag7@gmail.com>

Thanks,
Magnus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] vgacon: Fall back to the dummy console if mapping VGA memory fails
  2026-11-12  8:47 ` Magnus Lindholm
@ 2026-11-12  9:23   ` Michael Cree
  2026-11-12 10:45   ` Helge Deller
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Cree @ 2026-11-12  9:23 UTC (permalink / raw)
  To: Magnus Lindholm
  Cc: Matt Turner, Greg Kroah-Hartman, Helge Deller, linux-fbdev,
	dri-devel, linux-kernel, linux-alpha, stable

On Thu, Nov 12, 2026 at 09:47:05AM +0100, Magnus Lindholm wrote:
> Hi Matt,
> 
> On Thu, Nov 12, 2026 at 1:30 AM Matt Turner <mattst88@gmail.com> wrote:
> >
> > On Alpha, setup_arch() registers vgacon whenever CONFIG_VGA_CONSOLE is
> > enabled. On Marvel (EV7) systems whose SRM console is serial, no VGA
> > hose is set, so marvel_ioremap() finds no hose for 0xb8000 and returns
> > NULL. vgacon_startup() then probes video memory through that NULL
> > pointer and oopses in console_init():
> >
> >   Unable to handle kernel paging request at virtual address 0000000000000000
> >   pc is at vgacon_startup+0x174/0x910
> >
> > VGA_MAP_MEM() is ioremap() on Alpha and powerpc and can fail. Treat
> > failure like a failed probe and fall back to the dummy console. If a
> > VGA card is present, locate_and_init_vga() still switches to vgacon
> > once PCI is up.
> >
> > Cc: stable@vger.kernel.org
> > Assisted-by: Claude:claude-opus-5-5
> > Signed-off-by: Matt Turner <mattst88@gmail.com>
> > ---
> >  drivers/video/console/vgacon.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
> > index e7e6750f1f87..09f7c376b468 100644
> > --- a/drivers/video/console/vgacon.c
> > +++ b/drivers/video/console/vgacon.c
> > @@ -324,6 +324,8 @@ static const char *vgacon_startup(void)
> >         }
> >
> >         vga_vram_base = VGA_MAP_MEM(vga_vram_base, vga_vram_size);
> > +       if (!vga_vram_base)
> > +               goto no_vga;
> >         vga_vram_end = vga_vram_base + vga_vram_size;
> >
> >         /*
> >
> > ---
> > base-commit: fa4ad798f6f681031775266044ba1b0cf3c670bd
> > change-id: 20261111-vgacon-ioremap-null-ad4c7184b807
> >
> > Best regards,
> > --
> > Matt Turner <mattst88@gmail.com>
> >
> >
> 
> Nice fix! this must have been lingering here for a long time?
> Cross-builds passed for generic Alpha, including Marvel. The shared
> vgacon code also compiled successfully for x86-64.

I wonder whether this is the reason why my ES45 would never boot with
an AGP video card.  SRM could bring up the console but I recall the
kernel crashed early on.  In contrast, it boots fine with a PCI radeon
card. Not sure if I am going to get a chance to test it out in the
near future though ...

Cheers,
Michael.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] vgacon: Fall back to the dummy console if mapping VGA memory fails
  2026-11-12  8:47 ` Magnus Lindholm
  2026-11-12  9:23   ` Michael Cree
@ 2026-11-12 10:45   ` Helge Deller
  1 sibling, 0 replies; 4+ messages in thread
From: Helge Deller @ 2026-11-12 10:45 UTC (permalink / raw)
  To: Matt Turner, Magnus Lindholm
  Cc: Greg Kroah-Hartman, linux-fbdev, dri-devel, linux-kernel, linux-alpha

On 11/12/26 09:47, Magnus Lindholm wrote:
> Hi Matt,
> 
> On Thu, Nov 12, 2026 at 1:30 AM Matt Turner <mattst88@gmail.com> wrote:
>>
>> On Alpha, setup_arch() registers vgacon whenever CONFIG_VGA_CONSOLE is
>> enabled. On Marvel (EV7) systems whose SRM console is serial, no VGA
>> hose is set, so marvel_ioremap() finds no hose for 0xb8000 and returns
>> NULL. vgacon_startup() then probes video memory through that NULL
>> pointer and oopses in console_init():
>>
>>    Unable to handle kernel paging request at virtual address 0000000000000000
>>    pc is at vgacon_startup+0x174/0x910
>>
>> VGA_MAP_MEM() is ioremap() on Alpha and powerpc and can fail. Treat
>> failure like a failed probe and fall back to the dummy console. If a
>> VGA card is present, locate_and_init_vga() still switches to vgacon
>> once PCI is up.
>>
>> Cc: stable@vger.kernel.org
>> Assisted-by: Claude:claude-opus-5-5
>> Signed-off-by: Matt Turner <mattst88@gmail.com>
>> ---
>>   drivers/video/console/vgacon.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
>> index e7e6750f1f87..09f7c376b468 100644
>> --- a/drivers/video/console/vgacon.c
>> +++ b/drivers/video/console/vgacon.c
>> @@ -324,6 +324,8 @@ static const char *vgacon_startup(void)
>>          }
>>
>>          vga_vram_base = VGA_MAP_MEM(vga_vram_base, vga_vram_size);
>> +       if (!vga_vram_base)
>> +               goto no_vga;
>>          vga_vram_end = vga_vram_base + vga_vram_size;
>>
>>          /*
>>
> ....
> 
> Reviewed-by: Magnus Lindholm <linmag7@gmail.com>
> Tested-by: Magnus Lindholm <linmag7@gmail.com>
applied to fbdev git tree.

Thanks!
Helge

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-12  9:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12  0:28 [PATCH] vgacon: Fall back to the dummy console if mapping VGA memory fails Matt Turner
2026-11-12  8:47 ` Magnus Lindholm
2026-11-12  9:23   ` Michael Cree
2026-11-12 10:45   ` Helge Deller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®