diff mbox

Linux 3.7-rc1 (nouveau_bios_score oops).

Message ID 20121020202846.GA5826@joi.lan (mailing list archive)
State New, archived
Headers show

Commit Message

Marcin Ślusarz Oct. 20, 2012, 8:28 p.m. UTC
On Sat, Oct 20, 2012 at 12:42:38PM +0200, Heinz Diehl wrote:
> On 20.10.2012, Martin Peres wrote: 
> 
> > Can you test the attached patch too ? I rebased the previous one I sent on
> > top on 3.7-rc1 as I accidentally used an older version.
> 
> Yes, of course.
> 
> Tried it. Unfortunately, the crash remains the same as reported.

Try this one.

Now, the question is: could 3.6 kernel get VBIOS by ACPI?
If yes, please mount debugfs and send vbios.rom to me please.
(cat /sys/kernel/debug/dri/0/vbios.rom > vbios.rom)

---
From: Marcin Slusarz <marcin.slusarz@gmail.com>
Subject: [PATCH] drm/nouveau: validate vbios size

Without checking, we could detect vbios size as 0, allocate 0-byte array
(kmalloc returns invalid pointer for such allocation) and crash in
nouveau_bios_score while checking for vbios signature.

Reported-by: Heinz Diehl <htd@fritha.org>
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
---
 drivers/gpu/drm/nouveau/core/subdev/bios/base.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

Comments

Marcin Ślusarz Oct. 20, 2012, 8:35 p.m. UTC | #1
On Sat, Oct 20, 2012 at 10:28:46PM +0200, Marcin Slusarz wrote:
> On Sat, Oct 20, 2012 at 12:42:38PM +0200, Heinz Diehl wrote:
> > On 20.10.2012, Martin Peres wrote: 
> > 
> > > Can you test the attached patch too ? I rebased the previous one I sent on
> > > top on 3.7-rc1 as I accidentally used an older version.
> > 
> > Yes, of course.
> > 
> > Tried it. Unfortunately, the crash remains the same as reported.
> 
> Try this one.
> 
> Now, the question is: could 3.6 kernel get VBIOS by ACPI?
> If yes, please mount debugfs and send vbios.rom to me please.
> (cat /sys/kernel/debug/dri/0/vbios.rom > vbios.rom)
> 
> ---
> From: Marcin Slusarz <marcin.slusarz@gmail.com>
> Subject: [PATCH] drm/nouveau: validate vbios size
> 
> Without checking, we could detect vbios size as 0, allocate 0-byte array
> (kmalloc returns invalid pointer for such allocation) and crash in
> nouveau_bios_score while checking for vbios signature.
> 
> Reported-by: Heinz Diehl <htd@fritha.org>

And of course:
Reported-by: Pawe? Sikora <pawel.sikora@agmk.net>

> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> ---
>  drivers/gpu/drm/nouveau/core/subdev/bios/base.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/base.c b/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
> index dcb5c2b..824eea0 100644
> --- a/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
> +++ b/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
> @@ -72,7 +72,7 @@ nouveau_bios_shadow_of(struct nouveau_bios *bios)
>  	}
>  
>  	data = of_get_property(dn, "NVDA,BMP", &size);
> -	if (data) {
> +	if (data && size) {
>  		bios->size = size;
>  		bios->data = kmalloc(bios->size, GFP_KERNEL);
>  		if (bios->data)
> @@ -104,6 +104,9 @@ nouveau_bios_shadow_pramin(struct nouveau_bios *bios)
>  		goto out;
>  
>  	bios->size = nv_rd08(bios, 0x700002) * 512;
> +	if (!bios->size)
> +		goto out;
> +
>  	bios->data = kmalloc(bios->size, GFP_KERNEL);
>  	if (bios->data) {
>  		for (i = 0; i < bios->size; i++)
> @@ -155,6 +158,9 @@ nouveau_bios_shadow_prom(struct nouveau_bios *bios)
>  
>  	/* read entire bios image to system memory */
>  	bios->size = nv_rd08(bios, 0x300002) * 512;
> +	if (!bios->size)
> +		goto out;
> +
>  	bios->data = kmalloc(bios->size, GFP_KERNEL);
>  	if (bios->data) {
>  		for (i = 0; i < bios->size; i++)
> @@ -194,6 +200,8 @@ nouveau_bios_shadow_acpi(struct nouveau_bios *bios)
>  	bios->size = 0;
>  	if (nouveau_acpi_get_bios_chunk(data, 0, 3) == 3)
>  		bios->size = data[2] * 512;
> +	if (!bios->size)
> +		return;
>  
>  	bios->data = kmalloc(bios->size, GFP_KERNEL);
>  	for (i = 0; bios->data && i < bios->size; i += cnt) {
> @@ -229,12 +237,14 @@ nouveau_bios_shadow_pci(struct nouveau_bios *bios)
>  static int
>  nouveau_bios_score(struct nouveau_bios *bios, const bool writeable)
>  {
> -	if (!bios->data || bios->data[0] != 0x55 || bios->data[1] != 0xAA) {
> +	if (bios->size < 3 || !bios->data || bios->data[0] != 0x55 ||
> +			bios->data[1] != 0xAA) {
>  		nv_info(bios, "... signature not found\n");
>  		return 0;
>  	}
>  
> -	if (nvbios_checksum(bios->data, bios->data[2] * 512)) {
> +	if (nvbios_checksum(bios->data,
> +			min_t(u32, bios->data[2] * 512, bios->size))) {
>  		nv_info(bios, "... checksum invalid\n");
>  		/* if a ro image is somewhat bad, it's probably all rubbish */
>  		return writeable ? 2 : 1;
> --
Heinz Diehl Oct. 20, 2012, 9:20 p.m. UTC | #2
On 20.10.2012, Marcin Slusarz wrote: 

> Try this one.

It works, now I can boot again. However, nouveau seems to be dead now.
The dmesg output with your patch on top of 3.7-rc1 is:

[    3.685909] [drm] Initialized i915 1.6.0 20080730 for 0000:00:02.0 on minor 0
[    3.687784] nouveau  [  DEVICE][0000:01:00.0] BOOT0  : 0x0a8800b1
[    3.689960] nouveau  [  DEVICE][0000:01:00.0] Chipset: GT218 (NVA8)
[    3.692471] nouveau  [  DEVICE][0000:01:00.0] Family : NV50
[    3.695716] nouveau  [   VBIOS][0000:01:00.0] checking PRAMIN for image...
[    3.697087] nouveau  [   VBIOS][0000:01:00.0] ... signature not found
[    3.698471] nouveau  [   VBIOS][0000:01:00.0] checking PROM for image...
[    3.699838] nouveau  [   VBIOS][0000:01:00.0] ... signature not found
[    3.701223] nouveau  [   VBIOS][0000:01:00.0] checking ACPI for image...
[    3.702684] ACPI Error: Field [ROMI] Base+Offset+Width 0+24+1 is beyond end of region [VROM] (length 24) (20120913/exfldio-210)
[    3.704139] ACPI Error: Method parse/execution failed[\_SB_.PCI0.PEG1.GFX0._ROM] (Node ffff880142e85cf8), AE_AML_REGION_LIMIT (20120913/psparse-536)
[    3.716183] failed to evaluate ROM got AE_AML_REGION_LIMIT
[    3.718776] nouveau  [   VBIOS][0000:01:00.0] ... signature not found
[    3.721349] nouveau  [   VBIOS][0000:01:00.0] checking PCIROM for image...
[    3.724111] nouveau 0000:01:00.0: Invalid ROM contents
[    3.726663] nouveau  [   VBIOS][0000:01:00.0] ... signature not found
[    3.729159] nouveau E[   VBIOS][0000:01:00.0] unable to locate usable image
[    3.731677] nouveau E[  DEVICE][0000:01:00.0] failed to create 0x10000001, -22
[    3.734231] nouveau E[     DRM] failed to create 0x80000080, -22
[    3.736097] nouveau: probe of 0000:01:00.0 failed with error -22
[    3.740523] dracut: Starting plymouth daemon

And here's the same output with plain vanilla 3.6.2:

[    3.588791] [drm] nouveau 0000:01:00.0: Detected an NV50 generation card (0x0a8800b1)
[    3.599783] vga_switcheroo: enabled
[    3.601303] [drm] nouveau 0000:01:00.0: Checking PRAMIN for VBIOS
[    3.602817] [drm] nouveau 0000:01:00.0: ... BIOS signature not found
[    3.604294] [drm] nouveau 0000:01:00.0: Checking PROM for VBIOS
[    3.605822] [drm] nouveau 0000:01:00.0: ... BIOS signature not found
[    3.607310] [drm] nouveau 0000:01:00.0: Checking ACPI for VBIOS
[    3.856854] [drm] nouveau 0000:01:00.0: ... appears to be valid
[    3.859409] [drm] nouveau 0000:01:00.0: Using VBIOS from ACPI
[    3.861907] [drm] nouveau 0000:01:00.0: BIT BIOS found
[    3.864369] [drm] nouveau 0000:01:00.0: Bios version 70.18.5d.00
[    3.866829] [drm] nouveau 0000:01:00.0: TMDS table version 2.0
[    3.869479] [drm] nouveau 0000:01:00.0: MXM: no VBIOS data, nothing to do
[    3.870871] [drm] nouveau 0000:01:00.0: DCB version 4.0
[    3.872220] [drm] nouveau 0000:01:00.0: DCB outp 00: 02014300 00000000
[    3.873611] [drm] nouveau 0000:01:00.0: DCB conn 00: 00000040
[    3.874994] [drm] nouveau 0000:01:00.0: DCB conn 01: 00410146
[    3.876367] [drm] nouveau 0000:01:00.0: DCB conn 02: 00001261
[    3.877719] [drm] nouveau 0000:01:00.0: DCB conn 03: 00002330
[    3.879043] [drm] nouveau 0000:01:00.0: DCB conn 04: 00000400
[    3.880355] [drm] nouveau 0000:01:00.0: DCB conn 05: 00000560
[    3.881662] [drm] nouveau 0000:01:00.0: Adaptor not initialised, running VBIOS init tables.
[    3.882961] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 0 at offset 0xDECD
[    3.936538] [drm] nouveau 0000:01:00.0: 0xDE34: i2c wr fail: -6
[    3.957932] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 1 at offset 0xE378
[    3.987046] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 2 at offset 0xEF4B
[    3.988396] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 3 at offset 0xEF64
[    3.990741] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 4 at offset 0xF04B
[    3.992020] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table at offset 0xF0B0
[    4.018084] [TTM] Zone  kernel: Available graphics memory: 1917766 kiB
[    4.019438] [TTM] Initializing pool allocator
[    4.020694] [TTM] Initializing DMA pool allocator
[    4.021914] [drm] nouveau 0000:01:00.0: Detected 1024MiB VRAM (DDR3)
[    4.024515] [drm] nouveau 0000:01:00.0: 512 MiB GART (aperture)
[    4.083748] [drm] Supports vblank timestamp caching Rev 1 (10.10.2010).
[    4.084909] [drm] No driver support for vblank timestamp query.
[    4.085985] [drm] nouveau 0000:01:00.0: ACPI backlight interface available, not registering our own
[    4.246449] [drm] nouveau 0000:01:00.0: 3 available performance level(s)
[    4.247560] [drm] nouveau 0000:01:00.0: 0: core 135MHz shader 270MHz memory 135MHz voltage 850mV
[    4.248707] [drm] nouveau 0000:01:00.0: 1: core 405MHz shader 810MHz memory 405MHz voltage 850mV
[    4.249807] [drm] nouveau 0000:01:00.0: 3: core 606MHz shader 1468MHz memory 667MHz voltage 1000mV
[    4.250946] [drm] nouveau 0000:01:00.0: c: core 405MHz shader 810MHz memory 405MHz
[    4.289382] [drm] nouveau 0000:01:00.0: MM: using COPY for buffer copies
[    4.668174] No connectors reported connected with modes
[    4.669252] [drm] Cannot find any crtc or sizes - going 1024x768
[    4.683844] [drm] nouveau 0000:01:00.0: allocated 1024x768 fb: 0x2c0000, bo ffff88013ab53400
[    4.685057] fb1: nouveaufb frame buffer device
[    4.686244] [drm] Initialized nouveau 1.0.0 20120316 for 0000:01:00.0 on minor 1
[    4.691233] dracut: Starting plymouth daemon
 
> Now, the question is: could 3.6 kernel get VBIOS by ACPI?
> If yes, please mount debugfs and send vbios.rom to me please.
> (cat /sys/kernel/debug/dri/0/vbios.rom > vbios.rom)

There's no such file on my machine (with mounted debugfs, of course).
Marcin Ślusarz Oct. 20, 2012, 9:42 p.m. UTC | #3
On Sat, Oct 20, 2012 at 11:20:36PM +0200, Heinz Diehl wrote:
> On 20.10.2012, Marcin Slusarz wrote: 
> 
> > Try this one.
> 
> It works, now I can boot again. However, nouveau seems to be dead now.
> The dmesg output with your patch on top of 3.7-rc1 is:
> 
> [    3.685909] [drm] Initialized i915 1.6.0 20080730 for 0000:00:02.0 on minor 0
> [    3.687784] nouveau  [  DEVICE][0000:01:00.0] BOOT0  : 0x0a8800b1
> [    3.689960] nouveau  [  DEVICE][0000:01:00.0] Chipset: GT218 (NVA8)
> [    3.692471] nouveau  [  DEVICE][0000:01:00.0] Family : NV50
> [    3.695716] nouveau  [   VBIOS][0000:01:00.0] checking PRAMIN for image...
> [    3.697087] nouveau  [   VBIOS][0000:01:00.0] ... signature not found
> [    3.698471] nouveau  [   VBIOS][0000:01:00.0] checking PROM for image...
> [    3.699838] nouveau  [   VBIOS][0000:01:00.0] ... signature not found
> [    3.701223] nouveau  [   VBIOS][0000:01:00.0] checking ACPI for image...
> [    3.702684] ACPI Error: Field [ROMI] Base+Offset+Width 0+24+1 is beyond end of region [VROM] (length 24) (20120913/exfldio-210)
> [    3.704139] ACPI Error: Method parse/execution failed[\_SB_.PCI0.PEG1.GFX0._ROM] (Node ffff880142e85cf8), AE_AML_REGION_LIMIT (20120913/psparse-536)
> [    3.716183] failed to evaluate ROM got AE_AML_REGION_LIMIT
> [    3.718776] nouveau  [   VBIOS][0000:01:00.0] ... signature not found
> [    3.721349] nouveau  [   VBIOS][0000:01:00.0] checking PCIROM for image...
> [    3.724111] nouveau 0000:01:00.0: Invalid ROM contents
> [    3.726663] nouveau  [   VBIOS][0000:01:00.0] ... signature not found
> [    3.729159] nouveau E[   VBIOS][0000:01:00.0] unable to locate usable image
> [    3.731677] nouveau E[  DEVICE][0000:01:00.0] failed to create 0x10000001, -22
> [    3.734231] nouveau E[     DRM] failed to create 0x80000080, -22
> [    3.736097] nouveau: probe of 0000:01:00.0 failed with error -22
> [    3.740523] dracut: Starting plymouth daemon
> 
> And here's the same output with plain vanilla 3.6.2:
> 
> [    3.588791] [drm] nouveau 0000:01:00.0: Detected an NV50 generation card (0x0a8800b1)
> [    3.599783] vga_switcheroo: enabled
> [    3.601303] [drm] nouveau 0000:01:00.0: Checking PRAMIN for VBIOS
> [    3.602817] [drm] nouveau 0000:01:00.0: ... BIOS signature not found
> [    3.604294] [drm] nouveau 0000:01:00.0: Checking PROM for VBIOS
> [    3.605822] [drm] nouveau 0000:01:00.0: ... BIOS signature not found
> [    3.607310] [drm] nouveau 0000:01:00.0: Checking ACPI for VBIOS
> [    3.856854] [drm] nouveau 0000:01:00.0: ... appears to be valid
> [    3.859409] [drm] nouveau 0000:01:00.0: Using VBIOS from ACPI
> [    3.861907] [drm] nouveau 0000:01:00.0: BIT BIOS found
> [    3.864369] [drm] nouveau 0000:01:00.0: Bios version 70.18.5d.00
> [    3.866829] [drm] nouveau 0000:01:00.0: TMDS table version 2.0
> [    3.869479] [drm] nouveau 0000:01:00.0: MXM: no VBIOS data, nothing to do
> [    3.870871] [drm] nouveau 0000:01:00.0: DCB version 4.0
> [    3.872220] [drm] nouveau 0000:01:00.0: DCB outp 00: 02014300 00000000
> [    3.873611] [drm] nouveau 0000:01:00.0: DCB conn 00: 00000040
> [    3.874994] [drm] nouveau 0000:01:00.0: DCB conn 01: 00410146
> [    3.876367] [drm] nouveau 0000:01:00.0: DCB conn 02: 00001261
> [    3.877719] [drm] nouveau 0000:01:00.0: DCB conn 03: 00002330
> [    3.879043] [drm] nouveau 0000:01:00.0: DCB conn 04: 00000400
> [    3.880355] [drm] nouveau 0000:01:00.0: DCB conn 05: 00000560
> [    3.881662] [drm] nouveau 0000:01:00.0: Adaptor not initialised, running VBIOS init tables.
> [    3.882961] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 0 at offset 0xDECD
> [    3.936538] [drm] nouveau 0000:01:00.0: 0xDE34: i2c wr fail: -6
> [    3.957932] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 1 at offset 0xE378
> [    3.987046] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 2 at offset 0xEF4B
> [    3.988396] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 3 at offset 0xEF64
> [    3.990741] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 4 at offset 0xF04B
> [    3.992020] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table at offset 0xF0B0
> [    4.018084] [TTM] Zone  kernel: Available graphics memory: 1917766 kiB
> [    4.019438] [TTM] Initializing pool allocator
> [    4.020694] [TTM] Initializing DMA pool allocator
> [    4.021914] [drm] nouveau 0000:01:00.0: Detected 1024MiB VRAM (DDR3)
> [    4.024515] [drm] nouveau 0000:01:00.0: 512 MiB GART (aperture)
> [    4.083748] [drm] Supports vblank timestamp caching Rev 1 (10.10.2010).
> [    4.084909] [drm] No driver support for vblank timestamp query.
> [    4.085985] [drm] nouveau 0000:01:00.0: ACPI backlight interface available, not registering our own
> [    4.246449] [drm] nouveau 0000:01:00.0: 3 available performance level(s)
> [    4.247560] [drm] nouveau 0000:01:00.0: 0: core 135MHz shader 270MHz memory 135MHz voltage 850mV
> [    4.248707] [drm] nouveau 0000:01:00.0: 1: core 405MHz shader 810MHz memory 405MHz voltage 850mV
> [    4.249807] [drm] nouveau 0000:01:00.0: 3: core 606MHz shader 1468MHz memory 667MHz voltage 1000mV
> [    4.250946] [drm] nouveau 0000:01:00.0: c: core 405MHz shader 810MHz memory 405MHz
> [    4.289382] [drm] nouveau 0000:01:00.0: MM: using COPY for buffer copies
> [    4.668174] No connectors reported connected with modes
> [    4.669252] [drm] Cannot find any crtc or sizes - going 1024x768
> [    4.683844] [drm] nouveau 0000:01:00.0: allocated 1024x768 fb: 0x2c0000, bo ffff88013ab53400
> [    4.685057] fb1: nouveaufb frame buffer device
> [    4.686244] [drm] Initialized nouveau 1.0.0 20120316 for 0000:01:00.0 on minor 1
> [    4.691233] dracut: Starting plymouth daemon
>
> > Now, the question is: could 3.6 kernel get VBIOS by ACPI?
> > If yes, please mount debugfs and send vbios.rom to me please.
> > (cat /sys/kernel/debug/dri/0/vbios.rom > vbios.rom)
> 
> There's no such file on my machine (with mounted debugfs, of course).

On 3.6 kernel? (It doesn't exist on 3.7)
Note that it may be in other directory than "0".

Marcin
Marcin Ślusarz Oct. 20, 2012, 9:45 p.m. UTC | #4
On Sat, Oct 20, 2012 at 11:42:17PM +0200, Marcin Slusarz wrote:
> On Sat, Oct 20, 2012 at 11:20:36PM +0200, Heinz Diehl wrote:
> > On 20.10.2012, Marcin Slusarz wrote: 
> > 
> > > Try this one.
> > 
> > It works, now I can boot again. However, nouveau seems to be dead now.
> > The dmesg output with your patch on top of 3.7-rc1 is:
> > 
> > [    3.685909] [drm] Initialized i915 1.6.0 20080730 for 0000:00:02.0 on minor 0
> > [    3.687784] nouveau  [  DEVICE][0000:01:00.0] BOOT0  : 0x0a8800b1
> > [    3.689960] nouveau  [  DEVICE][0000:01:00.0] Chipset: GT218 (NVA8)
> > [    3.692471] nouveau  [  DEVICE][0000:01:00.0] Family : NV50
> > [    3.695716] nouveau  [   VBIOS][0000:01:00.0] checking PRAMIN for image...
> > [    3.697087] nouveau  [   VBIOS][0000:01:00.0] ... signature not found
> > [    3.698471] nouveau  [   VBIOS][0000:01:00.0] checking PROM for image...
> > [    3.699838] nouveau  [   VBIOS][0000:01:00.0] ... signature not found
> > [    3.701223] nouveau  [   VBIOS][0000:01:00.0] checking ACPI for image...
> > [    3.702684] ACPI Error: Field [ROMI] Base+Offset+Width 0+24+1 is beyond end of region [VROM] (length 24) (20120913/exfldio-210)
> > [    3.704139] ACPI Error: Method parse/execution failed[\_SB_.PCI0.PEG1.GFX0._ROM] (Node ffff880142e85cf8), AE_AML_REGION_LIMIT (20120913/psparse-536)
> > [    3.716183] failed to evaluate ROM got AE_AML_REGION_LIMIT
> > [    3.718776] nouveau  [   VBIOS][0000:01:00.0] ... signature not found
> > [    3.721349] nouveau  [   VBIOS][0000:01:00.0] checking PCIROM for image...
> > [    3.724111] nouveau 0000:01:00.0: Invalid ROM contents
> > [    3.726663] nouveau  [   VBIOS][0000:01:00.0] ... signature not found
> > [    3.729159] nouveau E[   VBIOS][0000:01:00.0] unable to locate usable image
> > [    3.731677] nouveau E[  DEVICE][0000:01:00.0] failed to create 0x10000001, -22
> > [    3.734231] nouveau E[     DRM] failed to create 0x80000080, -22
> > [    3.736097] nouveau: probe of 0000:01:00.0 failed with error -22
> > [    3.740523] dracut: Starting plymouth daemon
> > 
> > And here's the same output with plain vanilla 3.6.2:
> > 
> > [    3.588791] [drm] nouveau 0000:01:00.0: Detected an NV50 generation card (0x0a8800b1)
> > [    3.599783] vga_switcheroo: enabled
> > [    3.601303] [drm] nouveau 0000:01:00.0: Checking PRAMIN for VBIOS
> > [    3.602817] [drm] nouveau 0000:01:00.0: ... BIOS signature not found
> > [    3.604294] [drm] nouveau 0000:01:00.0: Checking PROM for VBIOS
> > [    3.605822] [drm] nouveau 0000:01:00.0: ... BIOS signature not found
> > [    3.607310] [drm] nouveau 0000:01:00.0: Checking ACPI for VBIOS
> > [    3.856854] [drm] nouveau 0000:01:00.0: ... appears to be valid
> > [    3.859409] [drm] nouveau 0000:01:00.0: Using VBIOS from ACPI
> > [    3.861907] [drm] nouveau 0000:01:00.0: BIT BIOS found
> > [    3.864369] [drm] nouveau 0000:01:00.0: Bios version 70.18.5d.00
> > [    3.866829] [drm] nouveau 0000:01:00.0: TMDS table version 2.0
> > [    3.869479] [drm] nouveau 0000:01:00.0: MXM: no VBIOS data, nothing to do
> > [    3.870871] [drm] nouveau 0000:01:00.0: DCB version 4.0
> > [    3.872220] [drm] nouveau 0000:01:00.0: DCB outp 00: 02014300 00000000
> > [    3.873611] [drm] nouveau 0000:01:00.0: DCB conn 00: 00000040
> > [    3.874994] [drm] nouveau 0000:01:00.0: DCB conn 01: 00410146
> > [    3.876367] [drm] nouveau 0000:01:00.0: DCB conn 02: 00001261
> > [    3.877719] [drm] nouveau 0000:01:00.0: DCB conn 03: 00002330
> > [    3.879043] [drm] nouveau 0000:01:00.0: DCB conn 04: 00000400
> > [    3.880355] [drm] nouveau 0000:01:00.0: DCB conn 05: 00000560
> > [    3.881662] [drm] nouveau 0000:01:00.0: Adaptor not initialised, running VBIOS init tables.
> > [    3.882961] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 0 at offset 0xDECD
> > [    3.936538] [drm] nouveau 0000:01:00.0: 0xDE34: i2c wr fail: -6
> > [    3.957932] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 1 at offset 0xE378
> > [    3.987046] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 2 at offset 0xEF4B
> > [    3.988396] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 3 at offset 0xEF64
> > [    3.990741] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table 4 at offset 0xF04B
> > [    3.992020] [drm] nouveau 0000:01:00.0: Parsing VBIOS init table at offset 0xF0B0
> > [    4.018084] [TTM] Zone  kernel: Available graphics memory: 1917766 kiB
> > [    4.019438] [TTM] Initializing pool allocator
> > [    4.020694] [TTM] Initializing DMA pool allocator
> > [    4.021914] [drm] nouveau 0000:01:00.0: Detected 1024MiB VRAM (DDR3)
> > [    4.024515] [drm] nouveau 0000:01:00.0: 512 MiB GART (aperture)
> > [    4.083748] [drm] Supports vblank timestamp caching Rev 1 (10.10.2010).
> > [    4.084909] [drm] No driver support for vblank timestamp query.
> > [    4.085985] [drm] nouveau 0000:01:00.0: ACPI backlight interface available, not registering our own
> > [    4.246449] [drm] nouveau 0000:01:00.0: 3 available performance level(s)
> > [    4.247560] [drm] nouveau 0000:01:00.0: 0: core 135MHz shader 270MHz memory 135MHz voltage 850mV
> > [    4.248707] [drm] nouveau 0000:01:00.0: 1: core 405MHz shader 810MHz memory 405MHz voltage 850mV
> > [    4.249807] [drm] nouveau 0000:01:00.0: 3: core 606MHz shader 1468MHz memory 667MHz voltage 1000mV
> > [    4.250946] [drm] nouveau 0000:01:00.0: c: core 405MHz shader 810MHz memory 405MHz
> > [    4.289382] [drm] nouveau 0000:01:00.0: MM: using COPY for buffer copies
> > [    4.668174] No connectors reported connected with modes
> > [    4.669252] [drm] Cannot find any crtc or sizes - going 1024x768
> > [    4.683844] [drm] nouveau 0000:01:00.0: allocated 1024x768 fb: 0x2c0000, bo ffff88013ab53400
> > [    4.685057] fb1: nouveaufb frame buffer device
> > [    4.686244] [drm] Initialized nouveau 1.0.0 20120316 for 0000:01:00.0 on minor 1
> > [    4.691233] dracut: Starting plymouth daemon
> >
> > > Now, the question is: could 3.6 kernel get VBIOS by ACPI?
> > > If yes, please mount debugfs and send vbios.rom to me please.
> > > (cat /sys/kernel/debug/dri/0/vbios.rom > vbios.rom)
> > 
> > There's no such file on my machine (with mounted debugfs, of course).
> 
> On 3.6 kernel? (It doesn't exist on 3.7)
> Note that it may be in other directory than "0".

Oh, you need CONFIG_DRM_NOUVEAU_DEBUG too.
Heinz Diehl Oct. 21, 2012, 8:54 a.m. UTC | #5
On 21.10.2012, Marcin Slusarz wrote: 

> On 3.6 kernel? (It doesn't exist on 3.7)
> Note that it may be in other directory than "0".

[root@wildsau linux-3.6.2]# cat .config | grep -i "nouveau"
CONFIG_DRM_NOUVEAU=m
CONFIG_DRM_NOUVEAU_BACKLIGHT=y
CONFIG_DRM_NOUVEAU_DEBUG=y

I grepped the whole disk, there's no vbios.rom at all.
diff mbox

Patch

diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/base.c b/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
index dcb5c2b..824eea0 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
@@ -72,7 +72,7 @@  nouveau_bios_shadow_of(struct nouveau_bios *bios)
 	}
 
 	data = of_get_property(dn, "NVDA,BMP", &size);
-	if (data) {
+	if (data && size) {
 		bios->size = size;
 		bios->data = kmalloc(bios->size, GFP_KERNEL);
 		if (bios->data)
@@ -104,6 +104,9 @@  nouveau_bios_shadow_pramin(struct nouveau_bios *bios)
 		goto out;
 
 	bios->size = nv_rd08(bios, 0x700002) * 512;
+	if (!bios->size)
+		goto out;
+
 	bios->data = kmalloc(bios->size, GFP_KERNEL);
 	if (bios->data) {
 		for (i = 0; i < bios->size; i++)
@@ -155,6 +158,9 @@  nouveau_bios_shadow_prom(struct nouveau_bios *bios)
 
 	/* read entire bios image to system memory */
 	bios->size = nv_rd08(bios, 0x300002) * 512;
+	if (!bios->size)
+		goto out;
+
 	bios->data = kmalloc(bios->size, GFP_KERNEL);
 	if (bios->data) {
 		for (i = 0; i < bios->size; i++)
@@ -194,6 +200,8 @@  nouveau_bios_shadow_acpi(struct nouveau_bios *bios)
 	bios->size = 0;
 	if (nouveau_acpi_get_bios_chunk(data, 0, 3) == 3)
 		bios->size = data[2] * 512;
+	if (!bios->size)
+		return;
 
 	bios->data = kmalloc(bios->size, GFP_KERNEL);
 	for (i = 0; bios->data && i < bios->size; i += cnt) {
@@ -229,12 +237,14 @@  nouveau_bios_shadow_pci(struct nouveau_bios *bios)
 static int
 nouveau_bios_score(struct nouveau_bios *bios, const bool writeable)
 {
-	if (!bios->data || bios->data[0] != 0x55 || bios->data[1] != 0xAA) {
+	if (bios->size < 3 || !bios->data || bios->data[0] != 0x55 ||
+			bios->data[1] != 0xAA) {
 		nv_info(bios, "... signature not found\n");
 		return 0;
 	}
 
-	if (nvbios_checksum(bios->data, bios->data[2] * 512)) {
+	if (nvbios_checksum(bios->data,
+			min_t(u32, bios->data[2] * 512, bios->size))) {
 		nv_info(bios, "... checksum invalid\n");
 		/* if a ro image is somewhat bad, it's probably all rubbish */
 		return writeable ? 2 : 1;