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

Configure Feed

Select the types of activity you want to include in your feed.

iommupt: Avoid a compiler bug with sw_bit

gcc 13, in some cases, gets confused if the __builtin_constant_p() is
inside the switch. It thinks that bitnr can have the value max+1 and
fails. Lift the check outside the switch to avoid it.

Fixes: ef7bfe5bbffd ("iommupt/x86: Support SW bits and permit PT_FEAT_DMA_INCOHERENT")
Fixes: 5448c1558f60 ("iommupt: Add the Intel VT-d second stage page table format")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202511242012.I7g504Ab-lkp@intel.com/
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

authored by

Jason Gunthorpe and committed by
Joerg Roedel
5de863ef 152c862c

+8 -8
+4 -4
drivers/iommu/generic_pt/fmt/vtdss.h
··· 174 174 175 175 static inline u64 vtdss_pt_sw_bit(unsigned int bitnr) 176 176 { 177 + if (__builtin_constant_p(bitnr) && bitnr > 10) 178 + BUILD_BUG(); 179 + 177 180 /* Bits marked Ignored in the specification */ 178 181 switch (bitnr) { 179 182 case 0: ··· 187 184 return BIT_ULL(63); 188 185 /* Some bits in 9-3 are available in some entries */ 189 186 default: 190 - if (__builtin_constant_p(bitnr)) 191 - BUILD_BUG(); 192 - else 193 - PT_WARN_ON(true); 187 + PT_WARN_ON(true); 194 188 return 0; 195 189 } 196 190 }
+4 -4
drivers/iommu/generic_pt/fmt/x86_64.h
··· 175 175 176 176 static inline u64 x86_64_pt_sw_bit(unsigned int bitnr) 177 177 { 178 + if (__builtin_constant_p(bitnr) && bitnr > 12) 179 + BUILD_BUG(); 180 + 178 181 /* Bits marked Ignored/AVL in the specification */ 179 182 switch (bitnr) { 180 183 case 0: ··· 188 185 return BIT_ULL((bitnr - 2) + 52); 189 186 /* Some bits in 8,6,4,3 are available in some entries */ 190 187 default: 191 - if (__builtin_constant_p(bitnr)) 192 - BUILD_BUG(); 193 - else 194 - PT_WARN_ON(true); 188 + PT_WARN_ON(true); 195 189 return 0; 196 190 } 197 191 }