R600/RV770 command checker
Subsystems (2)
Attached is patch which add command checker. This patch suffered a bit of my unlukiness or simply my skill to use git reset --hard beyond reasons. So, I did loose the regs_src/r600 file that i use to deeply test this patch on various R6XX/R7XX hw. This patch as a new one which only had little testing (Xorg + Quake3 which i believe should cover enough ground).
There is a bunch of area than can be improved :
- compute exact mipmap size rather than more than likely slightly overestimating it.
- support for stream out buffer
- support for GS shader
Quoted 1 line
From code point of view i don't like the hugly split of
radeon_drv.h
in 2 files so i can include one in the r600_cs.c. I think better solution is to provide helper function to extract information we want in the legacy case (note that we don't use this information in the legacy case...).
Any others things i should change ?
Cheers,
Jerome
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
--
PATCH 1/1 drm/radeon/kms: r600/r700 cs checker
This patch add cs checker to r600/r700 hw. Command stream checking will rewrite some of the cs value in order to restrict GPU access to BO size. This doesn't break old userspace but just enforce safe value. It should break any things that was using the r600/r700 cs ioctl to do forbidden things (malicious software), though we are not aware of such things.
Here is the list of thing we check :
- enforcing resource size
- enforcing color buffer slice tile max, will restrict cb access
We don't check for shader bigger than the BO in which they are supposed to be, such use would lead to GPU lockup and is harmless from security POV, as far as we can tell (note that even checking for this wouldn't prevent someone to write bogus shader that lead to lockup).
Needed to split radeon_drv.h in 2 in order to allow it's inclusion in r600_cs.c which is shared btw KMS & UMS.
--- drivers/gpu/drm/radeon/Makefile | 5 + drivers/gpu/drm/radeon/r300_cmdbuf.c | 1 + drivers/gpu/drm/radeon/r600.c | 6 + drivers/gpu/drm/radeon/r600_blit.c | 1 + drivers/gpu/drm/radeon/r600_cp.c | 23 + drivers/gpu/drm/radeon/r600_cs.c | 807 ++++++++++--- drivers/gpu/drm/radeon/r600d.h | 333 ++++++- drivers/gpu/drm/radeon/radeon.h | 6 + drivers/gpu/drm/radeon/radeon_cp.c | 1 + drivers/gpu/drm/radeon/radeon_drv.c | 1 + drivers/gpu/drm/radeon/radeon_drv.h | 1819 +----------------------------- drivers/gpu/drm/radeon/radeon_drv_priv.h | 1849 ++++++++++++++++++++++++++++++ drivers/gpu/drm/radeon/radeon_irq.c | 1 + drivers/gpu/drm/radeon/radeon_state.c | 1 + drivers/gpu/drm/radeon/reg_srcs/r600 | 841 ++++++++++++++ drivers/gpu/drm/radeon/rv770.c | 6 + 16 files changed, 3695 insertions(+), 2006 deletions(-) create mode 100644 drivers/gpu/drm/radeon/radeon_drv_priv.h create mode 100644 drivers/gpu/drm/radeon/reg_srcs/r600
drivers/gpu/drm/radeon/Makefile +5 -0
@@ -30,6 +30,9 @@ $(obj)/r420_reg_safe.h: $(src)/reg_srcs/r420 $(obj)/mkregtable $(obj)/rs600_reg_safe.h: $(src)/reg_srcs/rs600 $(obj)/mkregtable $(call if_changed,mkregtable) +$(obj)/r600_reg_safe.h: $(src)/reg_srcs/r600 $(obj)/mkregtable + $(call if_changed,mkregtable) + $(obj)/r100.o: $(obj)/r100_reg_safe.h $(obj)/rn50_reg_safe.h $(obj)/r200.o: $(obj)/r200_reg_safe.h
@@ -42,6 +45,8 @@ $(obj)/r420.o: $(obj)/r420_reg_safe.h $(obj)/rs600.o: $(obj)/rs600_reg_safe.h +$(obj)/r600_cs.o: $(obj)/r600_reg_safe.h + radeon-y := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o \ radeon_irq.o r300_cmdbuf.o r600_cp.o # add KMS driver
drivers/gpu/drm/radeon/r300_cmdbuf.c +1 -0
@@ -35,6 +35,7 @@#include "drm.h" #include "radeon_drm.h" #include "radeon_drv.h" +#include "radeon_drv_priv.h" #include "r300_reg.h" #include <asm/unaligned.h>
drivers/gpu/drm/radeon/r600.c +6 -0
@@ -1077,21 +1077,27 @@ void r600_gpu_init(struct radeon_device *rdev)switch (rdev->config.r600.max_tile_pipes) {case 1 : tiling_config |=PIPE_TILING (0 ); + rdev->config.r600.tiling_npipes =1 ;break ;case 2 : tiling_config |=PIPE_TILING (1 ); + rdev->config.r600.tiling_npipes =2 ;break ;case 4 : tiling_config |=PIPE_TILING (2 ); + rdev->config.r600.tiling_npipes =4 ;break ;case 8 : tiling_config |=PIPE_TILING (3 ); + rdev->config.r600.tiling_npipes =8 ;break ;default :break ; } + rdev->config.r600.tiling_nbanks =4 << ((ramcfg &NOOFBANK_MASK ) >>NOOFBANK_SHIFT ); tiling_config |=BANK_TILING ((ramcfg &NOOFBANK_MASK ) >>NOOFBANK_SHIFT ); tiling_config |=GROUP_SIZE (0 ); + rdev->config.r600.tiling_group_size =256 ; tmp = (ramcfg &NOOFROWS_MASK ) >>NOOFROWS_SHIFT ;if (tmp >3 ) { tiling_config |=ROW_TILING (3 );
drivers/gpu/drm/radeon/r600_blit.c +1 -0
@@ -27,6 +27,7 @@#include "drm.h" #include "radeon_drm.h" #include "radeon_drv.h" +#include "radeon_drv_priv.h" #include "r600_blit_shaders.h"
drivers/gpu/drm/radeon/r600_cp.c +23 -0
@@ -30,6 +30,7 @@#include "drm.h" #include "radeon_drm.h" #include "radeon_drv.h" +#include "radeon_drv_priv.h" #define PFP_UCODE_SIZE 576#define PM4_UCODE_SIZE 1792
@@ -873,6 +874,17 @@ static void r600_gfx_init(struct drm_device *dev,RADEON_WRITE (R600_GB_TILING_CONFIG , gb_tiling_config);RADEON_WRITE (R600_DCP_TILING_CONFIG , (gb_tiling_config &0xffff ));RADEON_WRITE (R600_HDP_TILING_CONFIG , (gb_tiling_config &0xffff )); +if (gb_tiling_config &0xc0 ) { + dev_priv->r600_group_size =512 ; + }else { + dev_priv->r600_group_size =256 ; + } + dev_priv->r600_npipes =1 << ((gb_tiling_config >>1 ) &0x7 ); +if (gb_tiling_config &0x30 ) { + dev_priv->r600_nbanks =8 ; + }else { + dev_priv->r600_nbanks =4 ; + }RADEON_WRITE (R600_CC_RB_BACKEND_DISABLE , cc_rb_backend_disable);RADEON_WRITE (R600_CC_GC_SHADER_PIPE_CONFIG , cc_gc_shader_pipe_config);
@@ -1444,6 +1456,17 @@ static void r700_gfx_init(struct drm_device *dev,RADEON_WRITE (R600_GB_TILING_CONFIG , gb_tiling_config);RADEON_WRITE (R600_DCP_TILING_CONFIG , (gb_tiling_config &0xffff ));RADEON_WRITE (R600_HDP_TILING_CONFIG , (gb_tiling_config &0xffff )); +if (gb_tiling_config &0xc0 ) { + dev_priv->r600_group_size =512 ; + }else { + dev_priv->r600_group_size =256 ; + } + dev_priv->r600_npipes =1 << ((gb_tiling_config >>1 ) &0x7 ); +if (gb_tiling_config &0x30 ) { + dev_priv->r600_nbanks =8 ; + }else { + dev_priv->r600_nbanks =4 ; + }RADEON_WRITE (R600_CC_RB_BACKEND_DISABLE , cc_rb_backend_disable);RADEON_WRITE (R600_CC_GC_SHADER_PIPE_CONFIG , cc_gc_shader_pipe_config);
drivers/gpu/drm/radeon/r600_cs.c +618 -189
1,176 lines not on this page · raw message
drivers/gpu/drm/radeon/r600d.h +332 -1
344 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon.h +6 -0
@@ -693,6 +693,9 @@ struct r600_asic {unsigned sx_max_export_pos_size;unsigned sx_max_export_smx_size;unsigned sq_num_cf_insts; +unsigned tiling_nbanks; +unsigned tiling_npipes; +unsigned tiling_group_size; };struct rv770_asic {
@@ -713,6 +716,9 @@ struct rv770_asic {unsigned sc_prim_fifo_size;unsigned sc_hiz_tile_fifo_size;unsigned sc_earlyz_tile_fifo_fize; +unsigned tiling_nbanks; +unsigned tiling_npipes; +unsigned tiling_group_size; };union radeon_asic_config {
drivers/gpu/drm/radeon/radeon_cp.c +1 -0
@@ -34,6 +34,7 @@#include "drm_sarea.h" #include "radeon_drm.h" #include "radeon_drv.h" +#include "radeon_drv_priv.h" #include "r300_reg.h" #define RADEON_FIFO_DEBUG 0
drivers/gpu/drm/radeon/radeon_drv.c +1 -0
@@ -33,6 +33,7 @@#include "drm.h" #include "radeon_drm.h" #include "radeon_drv.h" +#include "radeon_drv_priv.h" #include "drm_pciids.h" #include <linux/console.h>
drivers/gpu/drm/radeon/radeon_drv.h +3 -1816
1,349 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_drv_priv.h new file +1849 -0
1,849 lines not on this page · raw message
drivers/gpu/drm/radeon/reg_srcs/r600 new file +841 -0
841 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 10 lines
1.6.6 ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com --
Part of the diff is not shown here. View the raw message.
Quoted 19 lines · Jerome Glisse
Attached is patch which add command checker. This patch suffered a bit of my unlukiness or simply my skill to use git reset --hard beyond reasons. So, I did loose the regs_src/r600 file that i use to deeply test this patch on various R6XX/R7XX hw. This patch as a new one which only had little testing (Xorg + Quake3 which i believe should cover enough ground).
There is a bunch of area than can be improved :
- compute exact mipmap size rather than more than likely slightly overestimating it.
- support for stream out buffer
- support for GS shaderQuoted 1 line
From code point of view i don't like the hugly split of
radeon_drv.hin 2 files so i can include one in the
r600_cs.c. I think better solution is to provide helper function to extract information we want in the legacy case (note that we don't use this information in the legacy case...).
Quoted 5 lines
Any others things i should change ?
Cheers,
Jerome
Feels better with the patch :)
Jerome
Quoted 1 line
From
c7dd31e7707452f55a478169d807e9e86da79e5dMon Sep 17 00:00:00 2001
From: Jerome Glisse <[email protected]>
Date: Thu, 28 Jan 2010 23:31:52 +0100
Subject: [PATCH] drm/radeon/kms: r600/r700 cs checker
This patch add cs checker to r600/r700 hw. Command stream checking will rewrite some of the cs value in order to restrict GPU access to BO size. This doesn't break old userspace but just enforce safe value. It should break any things that was using the r600/r700 cs ioctl to do forbidden things (malicious software), though we are not aware of such things.
Here is the list of thing we check :
- enforcing resource size
- enforcing color buffer slice tile max, will restrict cb access
We don't check for shader bigger than the BO in which they are supposed to be, such use would lead to GPU lockup and is harmless from security POV, as far as we can tell (note that even checking for this wouldn't prevent someone to write bogus shader that lead to lockup).
Needed to split radeon_drv.h in 2 in order to allow it's inclusion in r600_cs.c which is shared btw KMS & UMS.
--- drivers/gpu/drm/radeon/Makefile | 5 + drivers/gpu/drm/radeon/r300_cmdbuf.c | 1 + drivers/gpu/drm/radeon/r600.c | 6 + drivers/gpu/drm/radeon/r600_blit.c | 1 + drivers/gpu/drm/radeon/r600_cp.c | 23 + drivers/gpu/drm/radeon/r600_cs.c | 807 ++++++++++--- drivers/gpu/drm/radeon/r600d.h | 333 ++++++- drivers/gpu/drm/radeon/radeon.h | 6 + drivers/gpu/drm/radeon/radeon_cp.c | 1 + drivers/gpu/drm/radeon/radeon_drv.c | 1 + drivers/gpu/drm/radeon/radeon_drv.h | 1819 +----------------------------- drivers/gpu/drm/radeon/radeon_drv_priv.h | 1849 ++++++++++++++++++++++++++++++ drivers/gpu/drm/radeon/radeon_irq.c | 1 + drivers/gpu/drm/radeon/radeon_state.c | 1 + drivers/gpu/drm/radeon/reg_srcs/r600 | 841 ++++++++++++++ drivers/gpu/drm/radeon/rv770.c | 6 + 16 files changed, 3695 insertions(+), 2006 deletions(-) create mode 100644 drivers/gpu/drm/radeon/radeon_drv_priv.h create mode 100644 drivers/gpu/drm/radeon/reg_srcs/r600
drivers/gpu/drm/radeon/Makefile +5 -0
@@ -30,6 +30,9 @@ $(obj)/r420_reg_safe.h: $(src)/reg_srcs/r420 $(obj)/mkregtable $(obj)/rs600_reg_safe.h: $(src)/reg_srcs/rs600 $(obj)/mkregtable $(call if_changed,mkregtable) +$(obj)/r600_reg_safe.h: $(src)/reg_srcs/r600 $(obj)/mkregtable + $(call if_changed,mkregtable) + $(obj)/r100.o: $(obj)/r100_reg_safe.h $(obj)/rn50_reg_safe.h $(obj)/r200.o: $(obj)/r200_reg_safe.h
@@ -42,6 +45,8 @@ $(obj)/r420.o: $(obj)/r420_reg_safe.h $(obj)/rs600.o: $(obj)/rs600_reg_safe.h +$(obj)/r600_cs.o: $(obj)/r600_reg_safe.h + radeon-y := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o \ radeon_irq.o r300_cmdbuf.o r600_cp.o # add KMS driver
drivers/gpu/drm/radeon/r300_cmdbuf.c +1 -0
@@ -35,6 +35,7 @@#include "drm.h" #include "radeon_drm.h" #include "radeon_drv.h" +#include "radeon_drv_priv.h" #include "r300_reg.h" #include <asm/unaligned.h>
drivers/gpu/drm/radeon/r600.c +6 -0
@@ -1077,21 +1077,27 @@ void r600_gpu_init(struct radeon_device *rdev)switch (rdev->config.r600.max_tile_pipes) {case 1 : tiling_config |=PIPE_TILING (0 ); + rdev->config.r600.tiling_npipes =1 ;break ;case 2 : tiling_config |=PIPE_TILING (1 ); + rdev->config.r600.tiling_npipes =2 ;break ;case 4 : tiling_config |=PIPE_TILING (2 ); + rdev->config.r600.tiling_npipes =4 ;break ;case 8 : tiling_config |=PIPE_TILING (3 ); + rdev->config.r600.tiling_npipes =8 ;break ;default :break ; } + rdev->config.r600.tiling_nbanks =4 << ((ramcfg &NOOFBANK_MASK ) >>NOOFBANK_SHIFT ); tiling_config |=BANK_TILING ((ramcfg &NOOFBANK_MASK ) >>NOOFBANK_SHIFT ); tiling_config |=GROUP_SIZE (0 ); + rdev->config.r600.tiling_group_size =256 ; tmp = (ramcfg &NOOFROWS_MASK ) >>NOOFROWS_SHIFT ;if (tmp >3 ) { tiling_config |=ROW_TILING (3 );
drivers/gpu/drm/radeon/r600_blit.c +1 -0
@@ -27,6 +27,7 @@#include "drm.h" #include "radeon_drm.h" #include "radeon_drv.h" +#include "radeon_drv_priv.h" #include "r600_blit_shaders.h"
drivers/gpu/drm/radeon/r600_cp.c +23 -0
@@ -30,6 +30,7 @@#include "drm.h" #include "radeon_drm.h" #include "radeon_drv.h" +#include "radeon_drv_priv.h" #define PFP_UCODE_SIZE 576#define PM4_UCODE_SIZE 1792
@@ -873,6 +874,17 @@ static void r600_gfx_init(struct drm_device *dev,RADEON_WRITE (R600_GB_TILING_CONFIG , gb_tiling_config);RADEON_WRITE (R600_DCP_TILING_CONFIG , (gb_tiling_config &0xffff ));RADEON_WRITE (R600_HDP_TILING_CONFIG , (gb_tiling_config &0xffff )); +if (gb_tiling_config &0xc0 ) { + dev_priv->r600_group_size =512 ; + }else { + dev_priv->r600_group_size =256 ; + } + dev_priv->r600_npipes =1 << ((gb_tiling_config >>1 ) &0x7 ); +if (gb_tiling_config &0x30 ) { + dev_priv->r600_nbanks =8 ; + }else { + dev_priv->r600_nbanks =4 ; + }RADEON_WRITE (R600_CC_RB_BACKEND_DISABLE , cc_rb_backend_disable);RADEON_WRITE (R600_CC_GC_SHADER_PIPE_CONFIG , cc_gc_shader_pipe_config);
@@ -1444,6 +1456,17 @@ static void r700_gfx_init(struct drm_device *dev,RADEON_WRITE (R600_GB_TILING_CONFIG , gb_tiling_config);RADEON_WRITE (R600_DCP_TILING_CONFIG , (gb_tiling_config &0xffff ));RADEON_WRITE (R600_HDP_TILING_CONFIG , (gb_tiling_config &0xffff )); +if (gb_tiling_config &0xc0 ) { + dev_priv->r600_group_size =512 ; + }else { + dev_priv->r600_group_size =256 ; + } + dev_priv->r600_npipes =1 << ((gb_tiling_config >>1 ) &0x7 ); +if (gb_tiling_config &0x30 ) { + dev_priv->r600_nbanks =8 ; + }else { + dev_priv->r600_nbanks =4 ; + }RADEON_WRITE (R600_CC_RB_BACKEND_DISABLE , cc_rb_backend_disable);RADEON_WRITE (R600_CC_GC_SHADER_PIPE_CONFIG , cc_gc_shader_pipe_config);
drivers/gpu/drm/radeon/r600_cs.c +618 -189
1,176 lines not on this page · raw message
drivers/gpu/drm/radeon/r600d.h +332 -1
344 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon.h +6 -0
@@ -693,6 +693,9 @@ struct r600_asic {unsigned sx_max_export_pos_size;unsigned sx_max_export_smx_size;unsigned sq_num_cf_insts; +unsigned tiling_nbanks; +unsigned tiling_npipes; +unsigned tiling_group_size; };struct rv770_asic {
@@ -713,6 +716,9 @@ struct rv770_asic {unsigned sc_prim_fifo_size;unsigned sc_hiz_tile_fifo_size;unsigned sc_earlyz_tile_fifo_fize; +unsigned tiling_nbanks; +unsigned tiling_npipes; +unsigned tiling_group_size; };union radeon_asic_config {
drivers/gpu/drm/radeon/radeon_cp.c +1 -0
@@ -34,6 +34,7 @@#include "drm_sarea.h" #include "radeon_drm.h" #include "radeon_drv.h" +#include "radeon_drv_priv.h" #include "r300_reg.h" #define RADEON_FIFO_DEBUG 0
drivers/gpu/drm/radeon/radeon_drv.c +1 -0
@@ -33,6 +33,7 @@#include "drm.h" #include "radeon_drm.h" #include "radeon_drv.h" +#include "radeon_drv_priv.h" #include "drm_pciids.h" #include <linux/console.h>
drivers/gpu/drm/radeon/radeon_drv.h +3 -1816
1,349 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_drv_priv.h new file +1849 -0
1,849 lines not on this page · raw message
drivers/gpu/drm/radeon/reg_srcs/r600 new file +841 -0
841 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.6
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
Part of the diff is not shown here. View the raw message.
Quoted 7 lines · Jerome Glisse
Attached is patch which add command checker. This patch suffered a bit of my unlukiness or simply my skill to use git reset --hard beyond reasons. So, I did loose the regs_src/r600 file that i use to deeply test this patch on various R6XX/R7XX hw. This patch as a new one which only had little testing (Xorg + Quake3 which i believe should cover enough ground).
patch?
Quoted 3 lines
There is a bunch of area than can be improved :
- compute exact mipmap size rather than more than likely slightly overestimating it.
Also note that cube maps have 8 face alignment.
Quoted 10 lines
- support for stream out buffer
- support for GS shaderQuoted 1 line
From code point of view i don't like the hugly split of
radeon_drv.hin 2 files so i can include one in the
r600_cs.c. I think better solution is to provide helper function to extract information we want in the legacy case (note that we don't use this information in the legacy case...).Any others things i should change ?
How much does this patch affect performance compared to the old path?
Alex
Quoted 5 lines
Cheers,
Jerome
Quoted 12 lines
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
--