diff options
author | Dave Airlie <airlied@starflyer.(none)> | 2006-01-02 00:11:44 -0500 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2006-01-02 00:11:44 -0500 |
commit | 3528af1b189d0fbb4c7a3f121f46d9987b9af5b6 (patch) | |
tree | 565940d5d0ac96c063f15cba5a049103e2993466 /drivers/char/drm/savage_drv.h | |
parent | 952d751a140e961f7ac67f743cf94d1a37c736e8 (diff) |
drm: fix a LOR issue on FreeBSD for savage driver
Correct a LOR issue on FreeBSD by allocating temporary space and doing a single
DRM_COPY_FROM_USER rather than DRM_VERIFYAREA_READ followed by tons of
DRM_COPY_FROM_USER_UNCHECKED. I don't like the look of the temporary space
allocation, but I like the simplification in the rest of the file. Tested
with glxgears, tuxracer, and q3 on a savage4.
From: Eric Anholt <anholt@freebsd.org>
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/savage_drv.h')
-rw-r--r-- | drivers/char/drm/savage_drv.h | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/char/drm/savage_drv.h b/drivers/char/drm/savage_drv.h index 2f73558fb9cf..dd46cb85439c 100644 --- a/drivers/char/drm/savage_drv.h +++ b/drivers/char/drm/savage_drv.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* savage_drv.h -- Private header for the savage driver | 1 | /* savage_drv.h -- Private header for the savage driver */ |
2 | * | 2 | /* |
3 | * Copyright 2004 Felix Kuehling | 3 | * Copyright 2004 Felix Kuehling |
4 | * All Rights Reserved. | 4 | * All Rights Reserved. |
5 | * | 5 | * |
@@ -192,7 +192,7 @@ typedef struct drm_savage_private { | |||
192 | /* Err, there is a macro wait_event in include/linux/wait.h. | 192 | /* Err, there is a macro wait_event in include/linux/wait.h. |
193 | * Avoid unwanted macro expansion. */ | 193 | * Avoid unwanted macro expansion. */ |
194 | void (*emit_clip_rect) (struct drm_savage_private * dev_priv, | 194 | void (*emit_clip_rect) (struct drm_savage_private * dev_priv, |
195 | drm_clip_rect_t * pbox); | 195 | const drm_clip_rect_t * pbox); |
196 | void (*dma_flush) (struct drm_savage_private * dev_priv); | 196 | void (*dma_flush) (struct drm_savage_private * dev_priv); |
197 | } drm_savage_private_t; | 197 | } drm_savage_private_t; |
198 | 198 | ||
@@ -217,9 +217,9 @@ extern void savage_reclaim_buffers(drm_device_t * dev, DRMFILE filp); | |||
217 | 217 | ||
218 | /* state functions */ | 218 | /* state functions */ |
219 | extern void savage_emit_clip_rect_s3d(drm_savage_private_t * dev_priv, | 219 | extern void savage_emit_clip_rect_s3d(drm_savage_private_t * dev_priv, |
220 | drm_clip_rect_t * pbox); | 220 | const drm_clip_rect_t * pbox); |
221 | extern void savage_emit_clip_rect_s4(drm_savage_private_t * dev_priv, | 221 | extern void savage_emit_clip_rect_s4(drm_savage_private_t * dev_priv, |
222 | drm_clip_rect_t * pbox); | 222 | const drm_clip_rect_t * pbox); |
223 | 223 | ||
224 | #define SAVAGE_FB_SIZE_S3 0x01000000 /* 16MB */ | 224 | #define SAVAGE_FB_SIZE_S3 0x01000000 /* 16MB */ |
225 | #define SAVAGE_FB_SIZE_S4 0x02000000 /* 32MB */ | 225 | #define SAVAGE_FB_SIZE_S4 0x02000000 /* 32MB */ |
@@ -502,15 +502,6 @@ extern void savage_emit_clip_rect_s4(drm_savage_private_t * dev_priv, | |||
502 | 502 | ||
503 | #define BCI_WRITE( val ) *bci_ptr++ = (uint32_t)(val) | 503 | #define BCI_WRITE( val ) *bci_ptr++ = (uint32_t)(val) |
504 | 504 | ||
505 | #define BCI_COPY_FROM_USER(src,n) do { \ | ||
506 | unsigned int i; \ | ||
507 | for (i = 0; i < n; ++i) { \ | ||
508 | uint32_t val; \ | ||
509 | DRM_GET_USER_UNCHECKED(val, &((uint32_t*)(src))[i]); \ | ||
510 | BCI_WRITE(val); \ | ||
511 | } \ | ||
512 | } while(0) | ||
513 | |||
514 | /* | 505 | /* |
515 | * command DMA support | 506 | * command DMA support |
516 | */ | 507 | */ |
@@ -536,8 +527,8 @@ extern void savage_emit_clip_rect_s4(drm_savage_private_t * dev_priv, | |||
536 | 527 | ||
537 | #define DMA_WRITE( val ) *dma_ptr++ = (uint32_t)(val) | 528 | #define DMA_WRITE( val ) *dma_ptr++ = (uint32_t)(val) |
538 | 529 | ||
539 | #define DMA_COPY_FROM_USER(src,n) do { \ | 530 | #define DMA_COPY(src, n) do { \ |
540 | DRM_COPY_FROM_USER_UNCHECKED(dma_ptr, (src), (n)*4); \ | 531 | memcpy(dma_ptr, (src), (n)*4); \ |
541 | dma_ptr += n; \ | 532 | dma_ptr += n; \ |
542 | } while(0) | 533 | } while(0) |
543 | 534 | ||