mirror of
https://github.com/torvalds/linux.git
synced 2026-04-26 10:32:25 -04:00
Ensure that the DMA address of the framebuffer flush page is not larger than its hardware register. On GPUs older than Hopper, the register for the address can hold up to a 40-bit address (right-shifted by 8 so that it fits in the 32-bit register), and on Hopper and later it can be 52 bits (64-bit register where bits 52-63 must be zero). Recently it was discovered that under certain conditions, the flush page could be allocated outside this range. Although this bug was fixed, we can ensure that any future changes to this code don't accidentally generate an invalid page address. Signed-off-by: Timur Tabi <ttabi@nvidia.com> Reviewed-by: Lyude Paul <lyude@redhat.com> Signed-off-by: Lyude Paul <lyude@redhat.com> Link: https://patch.msgid.link/20251113230323.1271726-2-ttabi@nvidia.com
34 lines
972 B
C
34 lines
972 B
C
/* SPDX-License-Identifier: MIT
|
|
*
|
|
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
|
|
*/
|
|
#include "priv.h"
|
|
|
|
#include <nvhw/drf.h>
|
|
#include <nvhw/ref/gh100/dev_fb.h>
|
|
|
|
static void
|
|
gh100_fb_sysmem_flush_page_init(struct nvkm_fb *fb)
|
|
{
|
|
const u64 addr = fb->sysmem.flush_page_addr >> NV_PFB_NISO_FLUSH_SYSMEM_ADDR_SHIFT;
|
|
struct nvkm_device *device = fb->subdev.device;
|
|
|
|
// Ensure that the address is within hardware limits
|
|
WARN_ON(fb->sysmem.flush_page_addr > DMA_BIT_MASK(52));
|
|
|
|
nvkm_wr32(device, NV_PFB_FBHUB_PCIE_FLUSH_SYSMEM_ADDR_HI, upper_32_bits(addr));
|
|
nvkm_wr32(device, NV_PFB_FBHUB_PCIE_FLUSH_SYSMEM_ADDR_LO, lower_32_bits(addr));
|
|
}
|
|
|
|
static const struct nvkm_fb_func
|
|
gh100_fb = {
|
|
.sysmem.flush_page_init = gh100_fb_sysmem_flush_page_init,
|
|
.vidmem.size = ga102_fb_vidmem_size,
|
|
};
|
|
|
|
int
|
|
gh100_fb_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_fb **pfb)
|
|
{
|
|
return r535_fb_new(&gh100_fb, device, type, inst, pfb);
|
|
}
|