Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/nouveau/nouveau: bios pointers may be unaligned, use proper accessors

This can show up on SPARC or other architectures that don't handle
unaligned accesses. The kernel normally fixes these up, but it shouldn't
have to.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96836
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>

authored by

Ilia Mirkin and committed by
Ben Skeggs
9936aeea 69b62498

+4 -6
+2 -4
drivers/gpu/drm/nouveau/nouveau_bios.h
··· 31 31 32 32 #define DCB_LOC_ON_CHIP 0 33 33 34 - #define ROM16(x) le16_to_cpu(*(u16 *)&(x)) 35 - #define ROM32(x) le32_to_cpu(*(u32 *)&(x)) 36 - #define ROM48(x) ({ u8 *p = &(x); (u64)ROM16(p[4]) << 32 | ROM32(p[0]); }) 37 - #define ROM64(x) le64_to_cpu(*(u64 *)&(x)) 34 + #define ROM16(x) get_unaligned_le16(&(x)) 35 + #define ROM32(x) get_unaligned_le32(&(x)) 38 36 #define ROMPTR(d,x) ({ \ 39 37 struct nouveau_drm *drm = nouveau_drm((d)); \ 40 38 ROM16(x) ? &drm->vbios.data[ROM16(x)] : NULL; \
+2 -2
drivers/gpu/drm/nouveau/nvkm/subdev/mxm/mxms.c
··· 23 23 */ 24 24 #include "mxms.h" 25 25 26 - #define ROM16(x) le16_to_cpu(*(u16 *)&(x)) 27 - #define ROM32(x) le32_to_cpu(*(u32 *)&(x)) 26 + #define ROM16(x) get_unaligned_le16(&(x)) 27 + #define ROM32(x) get_unaligned_le32(&(x)) 28 28 29 29 static u8 * 30 30 mxms_data(struct nvkm_mxm *mxm)