# Wierd kernel panic: Linux(with KMS)/Windows XP dual boot

## octapult

Hello!

I followed instructions from "radeon - Gentoo Linux Wiki" trying to setup a linux kernel with KMS supported and using xf86-video-ati as my xorg driver.

I added radeon/R700_rlc.bin in-kernel firmware blob into the kernel binary. 

I turned on KMS support. 

Compile and install.

Reboot. 

Kernel booted fine. 

X Windows worked fine. 

Compiz worked fine. 

3D games worked fine. 

Everthing seems perfect. 

Except that if I dual boot to Windows XP first and then reboot back to linux. I immediatly got kernel panic and system hardlock. 

I have to boot to a clean linux kernel with KMS turned off, then I can successfully reboot back to the kernel with KMS turned on.

How is this happening?

lspci -v

```

03:00.0 VGA compatible controller: ATI Technologies Inc R700 [Radeon HD 4870 X2] (prog-if 00 [VGA controller])

   Subsystem: ATI Technologies Inc Device 2542

   Flags: bus master, fast devsel, latency 0, IRQ 47

   Memory at d0000000 (64-bit, prefetchable) [size=256M]

   Memory at f5000000 (64-bit, non-prefetchable) [size=64K]

   I/O ports at 8000 [size=256]

   [virtual] Expansion ROM at f4000000 [disabled] [size=128K]

   Capabilities: [50] Power Management version 3

   Capabilities: [58] Express Legacy Endpoint, MSI 00

   Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+

   Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>

   Kernel driver in use: radeon

   Kernel modules: fglrx

03:00.1 Audio device: ATI Technologies Inc HD48x0 audio

   Subsystem: ATI Technologies Inc HD48x0 audio

   Flags: bus master, fast devsel, latency 0, IRQ 10

   Memory at f5010000 (64-bit, non-prefetchable) [size=16K]

   Capabilities: [50] Power Management version 3

   Capabilities: [58] Express Legacy Endpoint, MSI 00

   Capabilities: [a0] MSI: Enable- Count=1/1 Maskable- 64bit+

   Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>

04:00.0 Display controller: ATI Technologies Inc R700 [Radeon HD 4870 X2]

   Subsystem: ATI Technologies Inc Device 2042

   Flags: bus master, fast devsel, latency 0, IRQ 48

   Memory at e0000000 (64-bit, prefetchable) [size=256M]

   Memory at f7000000 (64-bit, non-prefetchable) [size=64K]

   I/O ports at 9000 [size=256]

   Expansion ROM at f6000000 [disabled] [size=128K]

   Capabilities: [50] Power Management version 3

   Capabilities: [58] Express Legacy Endpoint, MSI 00

   Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+

   Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>

   Kernel driver in use: radeon

   Kernel modules: fglrx

```

emerge --info

```

Portage 2.1.10.31 (default/linux/amd64/10.0, gcc-4.5.3, glibc-2.13-r4, 3.1.0-gentoo x86_64)

=================================================================

System uname: Linux-3.1.0-gentoo-x86_64-Intel-R-_Core-TM-2_Quad_CPU_Q6600_@_2.40GHz-with-gentoo-2.1

Timestamp of tree: Sat, 29 Oct 2011 04:30:01 +0000

app-shells/bash:          4.2_p10

dev-java/java-config:     2.1.11-r3

dev-lang/python:          2.7.2-r3, 3.1.4-r3, 3.2.2

dev-util/cmake:           2.8.6-r1

dev-util/pkgconfig:       0.26

sys-apps/baselayout:      2.1

sys-apps/openrc:          0.9.4

sys-apps/sandbox:         2.5

sys-devel/autoconf:       2.13, 2.68

sys-devel/automake:       1.11.1-r1

sys-devel/binutils:       2.21.1-r1

sys-devel/gcc:            4.5.3-r1

sys-devel/gcc-config:     1.4.1-r1

sys-devel/libtool:        2.4-r4

sys-devel/make:           3.82-r3

sys-kernel/linux-headers: 2.6.39 (virtual/os-headers)

sys-libs/glibc:           2.13-r4

Repositories: gentoo

ACCEPT_KEYWORDS="amd64 ~amd64"

ACCEPT_LICENSE="* -@EULA"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=core2 -O2 -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"

CXXFLAGS="-march=core2 -O2 -pipe"

DISTDIR="/usr/portage/distfiles"

FEATURES="assume-digests binpkg-logs distlocks ebuild-locks fixlafiles news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"

FFLAGS=""

GENTOO_MIRRORS="ftp://gentoo.cs.nctu.edu.tw/gentoo/"

LDFLAGS="-Wl,-O1 -Wl,--as-needed"

LINGUAS="zh_TW"

MAKEOPTS="-j5"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY=""

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="X acl alsa amd64 apng berkdb bzip2 cairo cdda cdr cli consolekit cracklib crypt cups cxx dbus dri dvd fontconfig fortran gdbm gdu gnome gpm gtk gudev iconv ipv6 jpeg jpeg2k kde mmx modules mudflap multilib ncurses nls nptl nptlonly ogg opengl openmp pam pcre png policykit pppd python qt3support qt4 readline session sqlite sse sse2 ssl svg sysfs tcpd truetype unicode vorbis xcb xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="zh_TW" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="radeon" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

```

.config

```

#

# Generic Driver Options

#

CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"

# CONFIG_DEVTMPFS is not set

CONFIG_STANDALONE=y

CONFIG_PREVENT_FIRMWARE_BUILD=y

CONFIG_FW_LOADER=y

CONFIG_FIRMWARE_IN_KERNEL=y

CONFIG_EXTRA_FIRMWARE="radeon/R700_rlc.bin"

CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware/"

# CONFIG_SYS_HYPERVISOR is not set

CONFIG_CONNECTOR=y

CONFIG_PROC_EVENTS=y

# CONFIG_MTD is not set

# CONFIG_PARPORT is not set

CONFIG_PNP=y

CONFIG_PNP_DEBUG_MESSAGES=y

......

# Graphics support

#

# CONFIG_AGP is not set

CONFIG_VGA_ARB=y

CONFIG_VGA_ARB_MAX_GPUS=16

# CONFIG_VGA_SWITCHEROO is not set

CONFIG_DRM=y

CONFIG_DRM_KMS_HELPER=y

CONFIG_DRM_TTM=y

# CONFIG_DRM_TDFX is not set

# CONFIG_DRM_R128 is not set

CONFIG_DRM_RADEON=y

CONFIG_DRM_RADEON_KMS=y

# CONFIG_DRM_MGA is not set

# CONFIG_DRM_VIA is not set

# CONFIG_DRM_SAVAGE is not set

# CONFIG_STUB_POULSBO is not set

# CONFIG_VGASTATE is not set

# CONFIG_VIDEO_OUTPUT_CONTROL is not set

CONFIG_FB=y

# CONFIG_FIRMWARE_EDID is not set

# CONFIG_FB_DDC is not set

# CONFIG_FB_BOOT_VESA_SUPPORT is not set

CONFIG_FB_CFB_FILLRECT=y

CONFIG_FB_CFB_COPYAREA=y

CONFIG_FB_CFB_IMAGEBLIT=y

# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set

# CONFIG_FB_SYS_FILLRECT is not set

# CONFIG_FB_SYS_COPYAREA is not set

# CONFIG_FB_SYS_IMAGEBLIT is not set

# CONFIG_FB_FOREIGN_ENDIAN is not set

# CONFIG_FB_SYS_FOPS is not set

# CONFIG_FB_WMT_GE_ROPS is not set

# CONFIG_FB_SVGALIB is not set

# CONFIG_FB_MACMODES is not set

# CONFIG_FB_BACKLIGHT is not set

# CONFIG_FB_MODE_HELPERS is not set

# CONFIG_FB_TILEBLITTING is not set

#

# Frame buffer hardware drivers

#

# CONFIG_FB_CIRRUS is not set

# CONFIG_FB_PM2 is not set

# CONFIG_FB_CYBER2000 is not set

# CONFIG_FB_ARC is not set

# CONFIG_FB_ASILIANT is not set

# CONFIG_FB_IMSTT is not set

# CONFIG_FB_VGA16 is not set

# CONFIG_FB_UVESA is not set

# CONFIG_FB_VESA is not set

# CONFIG_FB_EFI is not set

# CONFIG_FB_N411 is not set

# CONFIG_FB_HGA is not set

# CONFIG_FB_S1D13XXX is not set

# CONFIG_FB_NVIDIA is not set

# CONFIG_FB_RIVA is not set

# CONFIG_FB_LE80578 is not set

# CONFIG_FB_MATROX is not set

# CONFIG_FB_RADEON is not set

# CONFIG_FB_ATY128 is not set

# CONFIG_FB_ATY is not set

# CONFIG_FB_S3 is not set

# CONFIG_FB_SAVAGE is not set

# CONFIG_FB_SIS is not set

# CONFIG_FB_VIA is not set

# CONFIG_FB_NEOMAGIC is not set

# CONFIG_FB_KYRO is not set

# CONFIG_FB_3DFX is not set

# CONFIG_FB_VOODOO1 is not set

# CONFIG_FB_VT8623 is not set

# CONFIG_FB_TRIDENT is not set

# CONFIG_FB_ARK is not set

# CONFIG_FB_PM3 is not set

# CONFIG_FB_CARMINE is not set

# CONFIG_FB_GEODE is not set

# CONFIG_FB_TMIO is not set

# CONFIG_FB_UDL is not set

# CONFIG_FB_VIRTUAL is not set

# CONFIG_FB_METRONOME is not set

# CONFIG_FB_MB862XX is not set

# CONFIG_FB_BROADSHEET is not set

CONFIG_BACKLIGHT_LCD_SUPPORT=y

CONFIG_LCD_CLASS_DEVICE=y

CONFIG_LCD_PLATFORM=y

CONFIG_BACKLIGHT_CLASS_DEVICE=y

CONFIG_BACKLIGHT_GENERIC=y

# CONFIG_BACKLIGHT_PROGEAR is not set

# CONFIG_BACKLIGHT_APPLE is not set

# CONFIG_BACKLIGHT_SAHARA is not set

# CONFIG_BACKLIGHT_ADP8860 is not set

# CONFIG_BACKLIGHT_ADP8870 is not set

#

# Display device support

#

# CONFIG_DISPLAY_SUPPORT is not set

#

# Console display driver support

#

CONFIG_VGA_CONSOLE=y

CONFIG_VGACON_SOFT_SCROLLBACK=y

CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64

CONFIG_DUMMY_CONSOLE=y

CONFIG_FRAMEBUFFER_CONSOLE=y

CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y

# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set

# CONFIG_FB_CON_DECOR is not set

# CONFIG_FONTS is not set

CONFIG_FONT_8x8=y

CONFIG_FONT_8x16=y

CONFIG_LOGO=y

CONFIG_LOGO_LINUX_MONO=y

CONFIG_LOGO_LINUX_VGA16=y

CONFIG_LOGO_LINUX_CLUT224=y

.....

```

----------

## Hu

If you boot to Windows XP, then shutdown the system, then boot to Linux with KMS, does the system fail?  If you successfully, boot to Linux with KMS, then reboot to Windows XP without turning off power, does Windows XP still work?  If it does still work, can you successfully boot to Linux with KMS?

When the kernel locks up, what are the last messages displayed?

----------

## octapult

This is strange. I don't get kernel panic anymore. I turned on some setting about LCD Backlight support, I2C Device support, and GPIO support during last kernel compilation. And the kernel booted succesfully even I was in Windows XP beforehand.

I can't get error messages from the kernel panic since I don't get it anymore. I'm only sure that it happened while the kernel was trying to bring up framebuffer consoles.

I'm not familiar with Linux kernel's firmware blob mechanism. Do device drivers really write something onto the device's firmware so that they have conflicts between Windows and Linux? Aren't data on the device's firmware non-volatile?

----------

## NeddySeagoon

octapult,

The firmware is volatile for several reasons:-

1. It must be executed from RAM, as RAM is much faster than any non-volative storage.

2. It saves the vendor a few pennies providing RAM and an EEPROM.

The firmware is hardware specific and not related to the OS at all. It does not run in your CPU, it does something on the card.

It might not even be executed in the conventional sense. e.g. it could just be a state machine.

The firmware is provided separately and the device driver makes a call to have it loaded. It is not a part of the device driver, its a part of the device.

----------

## octapult

Uh-oh...I thought I had gotten rid of the kernel panic. In fact I still get it from time to time. These are situations that I found:

1. linux-kernel-kms => reboot => Windows XP => reboot => linux-kernel-kms  => kernel panic

2. linux-kernel-kms => reboot => Windows XP => poweroff => linux-kernel-kms => kernel panic

3. Once kernel panic => reboot => linux-kernel-kms => kernel panic => reboot => linux-kernel-kms => kernel panic

(I got the same kernel panic if I kept booting into the same kernel)

4. Once kernel panic => reboot => Windows XP => reboot => linux-kernel-kms => kernel panic

5. The only way to get rid of the kernel panic is to reboot into a kernel with KMS off:

Once kernel panic ==> linux-kernel-no-kms ==> reboot ==> linux-kernel-kms ==> boot successfully

Following is the kernel panic dump:

(I'm sorry I don't know how to dump the message when the system freezes. I had to write it down manually. It might not be 100% correct.)

```

[<ffffffff8128def6>] ? remove_conflicting_framebuffers+0x36/0x60

[<ffffffffxxxxxxxx>] ? pci_device_probe+0x80/0xb0

[<ffffffffxxxxxxxx>] ? driver_sysfs_add+0x72/0xa0

[<ffffffffxxxxxxxx>] ? driver_probe_device+0x87/0x1a0

[<ffffffffxxxxxxxx>] ? _driver_attach+0xa3/0xa0

[<ffffffffxxxxxxxx>] ? driver_probe_device+0x1a0/0x1a0

[<ffffffffxxxxxxxx>] ? bus_for_each_device+0x4e/0x80

[<ffffffffxxxxxxxx>] ? bus_add_driver+0x138/0x260

[<ffffffffxxxxxxxx>] ? ttm_init+0x63/0x63

[<ffffffffxxxxxxxx>] ? driver_register+0x6c/0x130

[<ffffffffxxxxxxxx>] ? ttm_init+0x63/0x63

[<ffffffffxxxxxxxx>] ? _pci_register_driver+0x4c/0xc0

[<ffffffffxxxxxxxx>] ? do_one_initcall+0x3a/0x170

[<ffffffffxxxxxxxx>] ? kernel_init+0x95/0x113

[<ffffffffxxxxxxxx>] ? kernel_thread_helper+0x4/0x10

[<ffffffffxxxxxxxx>] ? start_kernel+0x318/0x318

[<ffffffffxxxxxxxx>] ? gs_charge+0xb/0xb

Code: 54 24 08 31 c9 31 f6 48 89 df e8 b8 fe ff ff 48 8b 83 20.....

RIP [<ffffffff8108e594>] _mutex_init+0x4/0x30

  RSP <ffff88012b04dcd8>

CR2: 0000000000000008

--- [end trace 969eb3a16bd6d79a] ---

kernel panic - not syncing: Attempted to kill init!

Pid : 1, comm : swapper tainted : G  D  3.1.0-gentoo #7

Call Trace:

[<ffffffff815b9ca9>] ? panic+0x92/0x19a

[<ffffffffxxxxxxxx>] ? do_exit+0x731/0x830

[<ffffffffxxxxxxxx>] ? printk+0x40/0x45

[<ffffffffxxxxxxxx>] ? opps_end+0x9a/0xe0

[<ffffffffxxxxxxxx>] ? no_context+0xfd/0x270

[<ffffffffxxxxxxxx>] ? _alloc_pages_nodemask+0x11d/0x700

[<ffffffffxxxxxxxx>] ? do_page_fault+0x2b8/0x430

[<ffffffffxxxxxxxx>] ? _schedule+0x2bd/0x8b0

[<ffffffffxxxxxxxx>] ? pci_conf1_write+0xcb/0xf0

[<ffffffffxxxxxxxx>] ? pci_bus_write_config_dword+0x68/0x80

[<ffffffffxxxxxxxx>] ? page_fault+0x1f/0x30

[<ffffffffxxxxxxxx>] ? atom_parse++0x26c/0x280

[<ffffffffxxxxxxxx>] ? mutex_init+0x4/0x30

[<ffffffffxxxxxxxx>] ? radeon_atombios_init+0xbe/0x120

[<ffffffffxxxxxxxx>] ? rv770_init+0x55/0x2a0

[<ffffffffxxxxxxxx>] ? radeon_device_init+0x3fc/0x480

[<ffffffffxxxxxxxx>] ? radeon_driver_load_kms+0x92/0x170

[<ffffffffxxxxxxxx>] ? drm_get_pci_dev+0x186/0x2c0

[<ffffffffxxxxxxxx>] ? remove_conflicting_framebuffers+0x36/0x60

[<ffffffffxxxxxxxx>] ? pci_device_probe+0x80/0xb0

[<ffffffffxxxxxxxx>] ? driver_sysfs_add+0x72/0xa0

[<ffffffffxxxxxxxx>] ? driver_probe_device+0x87/0x1a0

[<ffffffffxxxxxxxx>] ? _driver_attach+0x93/0xa0

[<ffffffffxxxxxxxx>] ? driver_probe_device+0x1a0/0x1a0

[<ffffffffxxxxxxxx>] ? bus_for_each_device+0x4e/0x80

[<ffffffffxxxxxxxx>] ? bus_add_driver+0x138/0x260

[<ffffffffxxxxxxxx>] ? ttm_init+0x634/0x63

[<ffffffffxxxxxxxx>] ? driver_register+0x6c/0x130

[<ffffffffxxxxxxxx>] ? ttm_init+0x63/0x63

[<ffffffffxxxxxxxx>] ? do_one_initcall+0x3a/0x170

[<ffffffffxxxxxxxx>] ? kernel_init+0x95/0x113

[<ffffffffxxxxxxxx>] ? kernel_thread_helper+0x4/0x10

[<ffffffffxxxxxxxx>] ? start_kernel+0x318/0x318

[<ffffffffxxxxxxxx>] ? gs_change+0xb/0xb

panic occurred, switching back to text console

```

----------

