linux/drivers
Linus Torvalds 818bebeb63 drm/xe: Don't hand out the flat CCS storage as usable VRAM
get_flat_ccs_offset() reads the base of the flat CCS storage from the
hardware, scales it by the number of enabled L3 nodes, and rounds the
result up to 128K.  Everything below that offset is then handed to the
VRAM allocator as usable memory.

Rounding a limit that means "usable memory ends here" upwards publishes
whatever lies between the real base and the rounded one as free memory,
and that memory belongs to the compression hardware.  The scaled value
has no reason to be 128K aligned, and on a Battlemage G21 with 16 GiB it
is not:

	flat CCS base: raw 0x3fafff800, rounded 0x3fb000000

so the last 2 KiB of page 0x3fafff000 is CCS storage, in the allocator's
pool.  Whatever is allocated there gets that tail overwritten by the
compression hardware, which needs no page-table entry, no buffer object
and no GPU submission to do it, and does it before userspace exists.

On this machine a Mesa VM's level-3 page table landed on that page on
every cold boot.  It lost the entry covering the compositor's
batch-buffer heap, so the compositor's first submission faulted fetching
its batch and gdm restarted it forever: a black screen on an otherwise
working machine.  Restarting gdm cleared it because the next VM's page
tables were allocated somewhere else.

Round down instead, to the page size the allocator works in.  On this
machine that excludes exactly one page.

Reading the reserved page afterwards shows what had been writing it:

	[369] 0xcccc000000000000
	[371] 0xcc77000000000000
	[373] 0xcccc000000000000
	[375] 0xcc77000000000000

compression metadata, two bytes per sixteen, sitting where the driver
used to hand out memory.

The assertion that should have caught this compares the offset against
GSMBASE - ccs_size for equality.  That value is 128K aligned, so it
agrees with the rounded-up offset precisely when the base is not
aligned - the check cannot fail in the case it exists to catch, and is
compiled out unless CONFIG_DRM_XE_DEBUG is set.  Replace it with one
that can fail: CCS storage must not run into GSM.

[ And this was a debug session from hell, enormously helped by an AI
  doing much of the grunt-work.

  I'd like to call it my tireless helper, but the AI several times
  stated flat out that this was impossible and unsolvable and that we
  should just write a report about it.

  I suspect those things have been trained by people who may not be
  quite as stubborn as I am.

  But while the AI was ready to give up several times, it did keep
  adding debug code and analyzing it faithfully when I pushed. So credit
  where credit is due and I let the AI write the commit message above.

  This is basically a one-liner fixing a bogus "round_up()" to a
  "round_down()", but there were 24 patches adding more and more debug
  information to this, and 18 kernel boot to finally narrow it down to
  this.   - Linus ]

Fixes: 3717339274 ("drm/xe/vram: fix ccs offset calculation")
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-08-20 20:12:39 -07:00
..
accel mm.git review status for mm-hotfixes-stable..mm-stable 2026-08-20 18:17:08 -07:00
accessibility
acpi CXL for v7.3 2026-08-20 15:02:09 -07:00
amba
android Rust changes for v7.3 2026-08-18 11:25:09 -07:00
ata ata changes for 7.3 2026-08-19 12:31:50 -07:00
atm
auxdisplay
base mm.git review status for mm-hotfixes-stable..mm-stable 2026-08-20 18:17:08 -07:00
bcma
block mm.git review status for mm-hotfixes-stable..mm-stable 2026-08-20 18:17:08 -07:00
bluetooth Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative 2026-08-07 15:40:27 -04:00
bus FSL SOC Changes for 7.3 2026-08-10 10:15:56 +02:00
cache
cdrom cdrom: fix stack out-of-bounds read in CDROMVOLCTRL 2026-07-20 21:54:52 -06:00
cdx
char This update includes the following changes: 2026-08-19 17:25:42 -07:00
clk pmdomain providers: 2026-08-19 09:28:46 -07:00
clocksource VDSO updates: 2026-08-18 16:56:25 -07:00
comedi comedi: comedi_parport: deal with premature interrupt 2026-07-17 14:50:35 +02:00
connector
counter Counter fixes for 7.2 2026-08-06 11:03:41 +02:00
cpufreq Driver core changes for 7.3-rc1 2026-08-19 10:42:18 -07:00
cpuidle
crypto vhost,vdpa,virtio: fixes, features 2026-08-20 17:07:50 -07:00
cxl Merge branch 'for-7.3/cxl-port-err-prep' into cxl-for-next 2026-08-05 13:55:07 -07:00
dax mm.git review status for mm-hotfixes-stable..mm-stable 2026-08-20 18:17:08 -07:00
dca
devfreq devfreq: Use sysfs_emit() for cpumask show callbacks 2026-07-22 15:38:37 -04:00
dibs net/dibs: Correct freeing of dmb_clientid_arr 2026-08-12 17:08:05 -07:00
dio
dma dmaengine fixes for v7.2 2026-08-02 09:19:40 -07:00
dma-buf
dpll Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-08-18 10:42:41 -07:00
edac x86/msr updates for v7.3: 2026-08-18 14:02:15 -07:00
eisa
extcon
firewire - Get rid of static_cpu_has() - one less API to care about testing CPU 2026-08-18 19:09:42 -07:00
firmware bitmap updates for v7.3 2026-08-20 11:41:46 -07:00
fpga fpga: dfl-fme-perf: Use sysfs_emit() for cpumask show 2026-07-22 15:38:37 -04:00
fsi
fwctl rust: introduce abstractions for fwctl 2026-08-14 19:21:17 -03:00
gnss
gpib gpio: legacy interface cleanups for 7.3 2026-07-27 09:56:49 +02:00
gpio gpio updates for v7.3-rc1 2026-08-19 09:10:07 -07:00
gpu drm/xe: Don't hand out the flat CCS storage as usable VRAM 2026-08-20 20:12:39 -07:00
greybus
hid Major changes: 2026-08-20 07:36:20 -07:00
hsi
hte
hv mm.git review status for mm-hotfixes-stable..mm-stable 2026-08-20 18:17:08 -07:00
hwmon hwmon updates for v7.3 2026-08-19 09:56:28 -07:00
hwspinlock
hwtracing bitmap updates for v7.3 2026-08-20 11:41:46 -07:00
i2c Driver core changes for 7.3-rc1 2026-08-19 10:42:18 -07:00
i3c
idle Merge branch 'intel-idle-lpi' 2026-08-07 21:22:50 +02:00
iio Linux 7.2 2026-08-18 14:21:04 +02:00
infiniband mm.git review status for mm-hotfixes-stable..mm-stable 2026-08-20 18:17:08 -07:00
input hid-for-linus-2026081901 2026-08-19 10:00:31 -07:00
interconnect
iommu iommufd v7.3 merge window pull request 2026-08-19 12:42:58 -07:00
ipack
irqchip Interrupt chip driver updates: 2026-08-18 15:24:18 -07:00
leds
macintosh
mailbox
mcb
md for-7.3/block-20260819 2026-08-20 13:55:16 -07:00
media bitmap updates for v7.3 2026-08-20 11:41:46 -07:00
memory Memory controller drivers for v7.3 2026-07-29 16:56:11 +02:00
memstick
message
mfd Driver core changes for 7.3-rc1 2026-08-19 10:42:18 -07:00
misc mm.git review status for mm-hotfixes-stable..mm-stable 2026-08-20 18:17:08 -07:00
mmc Networking changes for 7.3. 2026-08-20 08:16:04 -07:00
most
mtd Among the most important fixes that we have here, there are: 2026-07-17 09:30:17 -07:00
mux
net mm.git review status for mm-hotfixes-stable..mm-stable 2026-08-20 18:17:08 -07:00
nfc Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-08-18 10:42:41 -07:00
ntb
nubus
nvdimm vhost,vdpa,virtio: fixes, features 2026-08-20 17:07:50 -07:00
nvme nvme updates for Linux 7.3 2026-08-14 06:13:26 -06:00
nvmem nvmem: layouts: Add fixed-layout driver 2026-07-31 11:00:13 +02:00
of Driver core changes for 7.3-rc1 2026-08-19 10:42:18 -07:00
opp opp: Use clk_get_optional() to avoid leaving opp_table->clk as an error pointer 2026-08-06 11:54:14 +05:30
parisc
parport
pci VFIO updates for v7.3-rc1 2026-08-20 16:57:59 -07:00
pcmcia pcmcia: replace linux/gpio.h inclusions 2026-07-24 20:12:48 +02:00
peci
perf RISC-V updates for v7.3 2026-08-20 14:53:54 -07:00
phy gpio updates for v7.3-rc1 2026-08-19 09:10:07 -07:00
pinctrl Linux 7.2 2026-08-18 14:21:04 +02:00
platform Driver core changes for 7.3-rc1 2026-08-19 10:42:18 -07:00
pmdomain Driver core changes for 7.3-rc1 2026-08-19 10:42:18 -07:00
pnp Merge branches 'acpi-numa', 'acpi-misc' and 'pnp' 2026-08-07 20:01:31 +02:00
power power sequencing updates for v7.3-rc1 2026-08-19 09:08:06 -07:00
powercap x86/msr updates for v7.3: 2026-08-18 14:02:15 -07:00
pps
ps3
ptp Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-08-18 10:42:41 -07:00
pwm Driver core changes for 7.3-rc1 2026-08-19 10:42:18 -07:00
rapidio
ras
regulator regulator: Updates for v7.3 2026-08-19 09:36:58 -07:00
remoteproc
resctrl arm64 updates for 7.3 2026-08-18 11:57:17 -07:00
reset Linux 7.2-rc7 2026-08-10 01:20:05 +02:00
rpmsg
rtc
s390 for-7.3/block-20260819 2026-08-20 13:55:16 -07:00
sbus
scsi ata changes for 7.3 2026-08-19 12:31:50 -07:00
sh
siox
slimbus
soc spi: Updates for v7.3 2026-08-19 09:47:41 -07:00
soundwire soundwire: bus_type: Create IRQ mapping before calling driver probe() 2026-08-14 13:53:25 +01:00
spi spi: Updates for v7.3 2026-08-19 09:47:41 -07:00
spmi
ssb
staging Networking changes for 7.3. 2026-08-20 08:16:04 -07:00
target vfs-7.3-rc1.kthread 2026-08-17 11:35:12 -07:00
tc
tee soc: drivers for 7.3 2026-08-18 19:40:29 -07:00
thermal - Get rid of static_cpu_has() - one less API to care about testing CPU 2026-08-18 19:09:42 -07:00
thunderbolt thunderbolt: Initialize ->domain_released completion before it is being used 2026-07-30 06:47:32 +02:00
tty \n 2026-08-20 12:52:35 -07:00
ufs scsi: core: pair EH runtime PM get and put 2026-08-07 11:00:49 -04:00
uio uio_hv_generic: Bind to FCopy device by default 2026-07-17 14:50:09 +02:00
usb Networking changes for 7.3. 2026-08-20 08:16:04 -07:00
vdpa vduse: Add suspend 2026-08-19 06:38:48 -04:00
vfio mm.git review status for mm-hotfixes-stable..mm-stable 2026-08-20 18:17:08 -07:00
vhost vhost,vdpa,virtio: fixes, features 2026-08-20 17:07:50 -07:00
video mm.git review status for mm-hotfixes-stable..mm-stable 2026-08-20 18:17:08 -07:00
virt arm64 updates for 7.3 2026-08-18 11:57:17 -07:00
virtio virtio_ring: fix infinite loop in virtnet_poll_cleantx when device is broken 2026-08-19 06:38:47 -04:00
w1
watchdog watchdog updates for v7.3 2026-08-19 09:53:35 -07:00
xen xenbus: Unregister reboot notifier on init failure 2026-08-13 12:48:57 +02:00
zorro
Kconfig
Makefile