diff options
author | Dave Airlie <airlied@linux.ie> | 2005-10-09 10:36:50 +0000 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2005-10-09 10:36:50 +0000 |
commit | 524fb1440760a14c53fb3f238aad6c3cdb7e6a08 (patch) | |
tree | f6c825d3f990238c7229614d2ac739f59335feda | |
parent | e526211b86ec5343002978debfcf78f74a10c69e (diff) |
Secure the Radeon PCIE GART tables in framebuffer memory by not allowingXORG-6_8_99_901
the clients to get access to a secure area of framebuffer.
-rw-r--r-- | src/radeon.h | 1 | ||||
-rw-r--r-- | src/radeon_dri.c | 25 | ||||
-rw-r--r-- | src/radeon_driver.c | 12 | ||||
-rw-r--r-- | src/radeon_exa.c | 21 |
4 files changed, 24 insertions, 35 deletions
diff --git a/src/radeon.h b/src/radeon.h index c820d9e..2bf8d9a 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -337,6 +337,7 @@ typedef struct { CARD32 MemCntl; CARD32 BusCntl; unsigned long FbMapSize; /* Size of frame buffer, in bytes */ + unsigned long FbSecureSize; /* Size of secured fb area at end of framebuffer */ int Flags; /* Saved copy of mode flags */ /* VE/M6 support */ diff --git a/src/radeon_dri.c b/src/radeon_dri.c index 57c5b15..40c1296 100644 --- a/src/radeon_dri.c +++ b/src/radeon_dri.c @@ -1283,7 +1283,7 @@ Bool RADEONDRIScreenInit(ScreenPtr pScreen) pDRIInfo->ddxDriverMinorVersion = RADEON_VERSION_MINOR; pDRIInfo->ddxDriverPatchVersion = RADEON_VERSION_PATCH; pDRIInfo->frameBufferPhysicalAddress = (void *)info->LinearAddr; - pDRIInfo->frameBufferSize = info->FbMapSize; + pDRIInfo->frameBufferSize = info->FbMapSize - info->FbSecureSize; pDRIInfo->frameBufferStride = (pScrn->displayWidth * info->CurrentLayout.pixel_bytes); pDRIInfo->ddxDrawableTableEntry = RADEON_MAX_DRAWABLES; @@ -1987,28 +1987,13 @@ void RADEONDRIAllocatePCIGARTTable(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; RADEONInfoPtr info = RADEONPTR(pScrn); - FBAreaPtr fbarea; - int width; - int height; - int width_bytes; - int size_bytes; if (info->cardType!=CARD_PCIE || info->drmMinor<19) return; - size_bytes = RADEON_PCIGART_TABLE_SIZE; - width = pScrn->displayWidth; - width_bytes = width * (pScrn->bitsPerPixel / 8); - height = (size_bytes + width_bytes - 1)/width_bytes; - - fbarea = xf86AllocateOffscreenArea(pScreen, width, height, 256, NULL, NULL, NULL); + if (info->FbSecureSize==0) + return; - if (!fbarea) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "PCI GART Table allocation failed due to stupid memory manager\n"); - } else { - info->pciGartSize = size_bytes; - info->pciGartOffset = RADEON_ALIGN((fbarea->box.x1 + fbarea->box.y1 * width) * - info->CurrentLayout.pixel_bytes, 256); - - } + info->pciGartSize = RADEON_PCIGART_TABLE_SIZE; + info->pciGartOffset = (info->FbMapSize - info->FbSecureSize); } diff --git a/src/radeon_driver.c b/src/radeon_driver.c index caa85ce..8dc3271 100644 --- a/src/radeon_driver.c +++ b/src/radeon_driver.c @@ -2761,6 +2761,8 @@ static Bool RADEONPreInitConfig(ScrnInfoPtr pScrn) pScrn->videoRam &= ~1023; info->FbMapSize = pScrn->videoRam * 1024; + info->FbSecureSize = 0; + #ifdef XF86DRI /* AGP/PCI */ /* Proper autodetection of an AGP capable device requires examining @@ -2844,6 +2846,10 @@ static Bool RADEONPreInitConfig(ScrnInfoPtr pScrn) "Invalid BusType option, using detected type\n"); } } + + /* if the card is PCI Express reserve the last 32k for the gart table */ + if (info->cardType == CARD_PCIE) + info->FbSecureSize = RADEON_PCIGART_TABLE_SIZE; #endif xf86GetOptValBool(info->Options, OPTION_SHOWCACHE, &info->showCache); if (info->showCache) @@ -5158,7 +5164,7 @@ Bool RADEONSetupMemXAA_DRI(int scrnIndex, ScreenPtr pScreen) * pixmap cache. Should be enough for a fullscreen background * image plus some leftovers. */ - info->textureSize = info->FbMapSize - 5 * bufferSize - depthSize; + info->textureSize = info->FbMapSize - info->FbSecureSize - 5 * bufferSize - depthSize; /* If that gives us less than half the available memory, let's * be greedy and grab some more. Sorry, I care more about 3D @@ -5178,7 +5184,7 @@ Bool RADEONSetupMemXAA_DRI(int scrnIndex, ScreenPtr pScreen) */ if (info->textureSize < 0) { info->textureSize = info->FbMapSize - 2 * bufferSize - depthSize - - 2 * width_bytes - 16384 - RADEON_PCIGART_TABLE_SIZE; + - 2 * width_bytes - 16384 - info->FbSecureSize; } /* Check to see if there is more room available after the 8192nd @@ -5261,7 +5267,7 @@ Bool RADEONSetupMemXAA_DRI(int scrnIndex, ScreenPtr pScreen) info->backY = info->backOffset / width_bytes; info->backX = (info->backOffset - (info->backY * width_bytes)) / cpp; - scanlines = info->FbMapSize / width_bytes; + scanlines = (info->FbMapSize-info->FbSecureSize) / width_bytes; if (scanlines > 8191) scanlines = 8191; diff --git a/src/radeon_exa.c b/src/radeon_exa.c index 9e96286..3cbadf0 100644 --- a/src/radeon_exa.c +++ b/src/radeon_exa.c @@ -380,7 +380,7 @@ Bool RADEONSetupMemEXA (ScreenPtr pScreen) screen_size = pScrn->virtualY * byteStride; info->exa.card.memoryBase = info->FB + pScrn->fbOffset; - info->exa.card.memorySize = info->FbMapSize; + info->exa.card.memorySize = info->FbMapSize - info->FbSecureSize; info->exa.card.offScreenBase = screen_size; xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Allocating from a screen of %ld kb\n", @@ -397,17 +397,14 @@ Bool RADEONSetupMemEXA (ScreenPtr pScreen) info->frontOffset = 0; info->frontPitch = pScrn->displayWidth; - if ((info->cardType==CARD_PCIE) && info->drmMinor >= 19) { - info->pciGartSize = RADEON_PCIGART_TABLE_SIZE; - info->pciGartOffset = RADEON_ALIGN(info->exa.card.offScreenBase, - 256); - info->exa.card.offScreenBase = info->pciGartOffset + - info->pciGartSize; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Will use %d kb for PCI GART at offset 0x%08x\n", - RADEON_PCIGART_TABLE_SIZE / 1024, - (int)info->pciGartOffset); - } + RADEONDRIAllocatePCIGARTTable(pScreen); + + if (info->cardType==CARD_PCIE) + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Will use %d kb for PCI GART at offset 0x%08x\n", + RADEON_PCIGART_TABLE_SIZE / 1024, + (int)info->pciGartOffset); + /* Reserve a static area for the back buffer the same size as the * visible screen. XXX: This would be better initialized in ati_dri.c * when GLX is set up, but the offscreen memory manager's allocations |