Skip to contentSkip to conversation

powerpc/kvm: Fix ifdef to remove build warning

PATCH Applied Madhavan Srinivasan 2 participants 6 messages May 18, 2025 – Aug 28, 2025

Subsystems (2)
lore
Share & tools
lore

Madhavan Srinivasan

author maintainer
#0 lore raw

PATCH v2 1/4 powerpc/kvm: Fix ifdef to remove build warning

When compiling for pseries or powernv defconfig with "make C=1", these warning were reported bu sparse tool in powerpc/kernel/kvm.c

arch/powerpc/kernel/kvm.c:635:9: warning: switch with no cases arch/powerpc/kernel/kvm.c:646:9: warning: switch with no cases

Currently #ifdef were added after the switch case which are specific for BOOKE and PPC_BOOK3S_32. These are not enabled in pseries/powernv defconfig. Fix it by moving the #ifdef before switch(){}

Fixes cbe487fac7fc0 ("KVM: PPC: Add mtsrin PV code")

---
Changelog v1:
- Changed the patch title
- Added tags

 arch/powerpc/kernel/kvm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/kernel/kvm.c +4 -4
index 5b3c093611ba..7209d00a9c25 100644
@@ -632,19 +632,19 @@ static void __init kvm_check_ins(u32 *inst, u32 features)
 #endif
 	}
 
-	switch (inst_no_rt & ~KVM_MASK_RB) {
 #ifdef CONFIG_PPC_BOOK3S_32
+	switch (inst_no_rt & ~KVM_MASK_RB) {
 	case KVM_INST_MTSRIN:
 		if (features & KVM_MAGIC_FEAT_SR) {
 			u32 inst_rb = _inst & KVM_MASK_RB;
 			kvm_patch_ins_mtsrin(inst, inst_rt, inst_rb);
 		}
 		break;
-#endif
 	}
+#endif
 
-	switch (_inst) {
 #ifdef CONFIG_BOOKE
+	switch (_inst) {
 	case KVM_INST_WRTEEI_0:
 		kvm_patch_ins_wrteei_0(inst);
 		break;
@@ -652,8 +652,8 @@ static void __init kvm_check_ins(u32 *inst, u32 features)
 	case KVM_INST_WRTEEI_1:
 		kvm_patch_ins_wrtee(inst, 0, 1);
 		break;
-#endif
 	}
+#endif
 }
 
 extern u32 kvm_template_start[];
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH v2 2/4 powerpc/perf: make isa207_pmu_format_group struct static

isa207_pmu_format_group struct is local to the source and does not need to be in global scope, so make it static

Cleans up sparse warning:
arch/powerpc/perf/isa207-common.c:40:30: warning: symbol 'isa207_pmu_format_group' was not declared. Should it be static?

---
Changelog v1:
- Added tested by tag

 arch/powerpc/perf/isa207-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/perf/isa207-common.c +1 -1
index 2b3547fdba4a..bbef51849f33 100644
@@ -37,7 +37,7 @@ static struct attribute *isa207_pmu_format_attr[] = {
 	NULL,
 };
 
-const struct attribute_group isa207_pmu_format_group = {
+static const struct attribute_group isa207_pmu_format_group = {
 	.name = "format",
 	.attrs = isa207_pmu_format_attr,
 };
Signature · 1 line
2.49.0
#2 lore raw

Re: [PATCH v2 2/4] powerpc/perf: make isa207_pmu_format_group struct static

kernel test robot noticed the following build errors:

Hi Madhavan,

kernel test robot noticed the following build errors:

[auto build test ERROR on powerpc/next]
[also build test ERROR on powerpc/fixes linus/master powerpc/topic/ppc-kvm v6.15-rc6 next-20250516] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Madhavan-Srinivasan/powerpc-perf-make-isa207_pmu_format_group-struct-static/20250518-124244
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
patch link:    https://lore.kernel.org/r/20250518044107.39928-2-maddy%40linux.ibm.com
patch subject: [PATCH v2 2/4] powerpc/perf: make isa207_pmu_format_group struct static
config: powerpc64-randconfig-002-20250518 (https://download.01.org/0day-ci/archive/20250518/[email protected]/config)
compiler: powerpc64-linux-gcc (GCC) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250518/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> powerpc64-linux-ld: arch/powerpc/perf/power8-pmu.o:arch/powerpc/perf/power8-pmu.c:199: undefined reference to `isa207_pmu_format_group'
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#3 lore raw

PATCH v2 3/4 powerpc/prom_init: Fix shellcheck warnings

In reply to Madhavan Srinivasan

Fix "Double quote to prevent globbing and word splitting." warning from shellcheck

---
Changelog v1:
- Added tags

 arch/powerpc/kernel/prom_init_check.sh | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
arch/powerpc/kernel/prom_init_check.sh +8 -8
index 69623b9045d5..3090b97258ae 100644
@@ -15,8 +15,8 @@
 
 has_renamed_memintrinsics()
 {
-	grep -q "^CONFIG_KASAN=y$" ${KCONFIG_CONFIG} && \
-		! grep -q "^CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX=y" ${KCONFIG_CONFIG}
+	grep -q "^CONFIG_KASAN=y$" "${KCONFIG_CONFIG}" && \
+		! grep -q "^CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX=y" "${KCONFIG_CONFIG}"
 }
 
 if has_renamed_memintrinsics
@@ -42,15 +42,15 @@ check_section()
 {
     file=$1
     section=$2
-    size=$(objdump -h -j $section $file 2>/dev/null | awk "\$2 == \"$section\" {print \$3}")
+    size=$(objdump -h -j "$section" "$file" 2>/dev/null | awk "\$2 == \"$section\" {print \$3}")
     size=${size:-0}
-    if [ $size -ne 0 ]; then
+    if [ "$size" -ne 0 ]; then
 	ERROR=1
 	echo "Error: Section $section not empty in prom_init.c" >&2
     fi
 }
 
-for UNDEF in $($NM -u $OBJ | awk '{print $2}')
+for UNDEF in $($NM -u "$OBJ" | awk '{print $2}')
 do
 	# On 64-bit nm gives us the function descriptors, which have
 	# a leading . on the name, so strip it off here.
@@ -87,8 +87,8 @@ do
 	fi
 done
 
-check_section $OBJ .data
-check_section $OBJ .bss
-check_section $OBJ .init.data
+check_section "$OBJ" .data
+check_section "$OBJ" .bss
+check_section "$OBJ" .init.data
 
 exit $ERROR
Signature · 1 line
2.49.0
author maintainer
#4 lore raw

PATCH v2 4/4 powerpc/boot/install.sh: Fix shellcheck warnings

In reply to Madhavan Srinivasan

Fix shellcheck warning such as
"Double quote to prevent globbing and word splitting." and Use $(...) notation instead of legacy backticks ....

---
Changelog v1:
-Added tested by tag

 arch/powerpc/boot/install.sh | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
arch/powerpc/boot/install.sh +7 -7
index 101fcb397a0f..c3df6c27ce75 100755
@@ -19,19 +19,19 @@
 set -e
 
 # this should work for both the pSeries zImage and the iSeries vmlinux.sm
-image_name=`basename $2`
+image_name=$(basename "$2")
 
 
 echo "Warning: '${INSTALLKERNEL}' command not available... Copying" \
      "directly to $4/$image_name-$1" >&2
 
-if [ -f $4/$image_name-$1 ]; then
-	mv $4/$image_name-$1 $4/$image_name-$1.old
+if [ -f "$4"/"$image_name"-"$1" ]; then
+	mv "$4"/"$image_name"-"$1" "$4"/"$image_name"-"$1".old
 fi
 
-if [ -f $4/System.map-$1 ]; then
-	mv $4/System.map-$1 $4/System-$1.old
+if [ -f "$4"/System.map-"$1" ]; then
+	mv "$4"/System.map-"$1" "$4"/System-"$1".old
 fi
 
-cat $2 > $4/$image_name-$1
-cp $3 $4/System.map-$1
+cat "$2" > "$4"/"$image_name"-"$1"
+cp "$3" "$4"/System.map-"$1"
Signature · 1 line
2.49.0
author maintainer Applied
#5 lore raw
In reply to Madhavan Srinivasan
Quoted 11 lines · Madhavan Srinivasan

When compiling for pseries or powernv defconfig with "make C=1", these warning were reported bu sparse tool in powerpc/kernel/kvm.c

arch/powerpc/kernel/kvm.c:635:9: warning: switch with no cases arch/powerpc/kernel/kvm.c:646:9: warning: switch with no cases

Currently #ifdef were added after the switch case which are specific for BOOKE and PPC_BOOK3S_32. These are not enabled in pseries/powernv defconfig. Fix it by moving the #ifdef before switch(){}

[...]

Applied to powerpc/fixes.

[1/4] powerpc/kvm: Fix ifdef to remove build warning

      https://git.kernel.org/powerpc/c/88688a2c8ac6c8036d983ad8b34ce191c46a10aa
[3/4] powerpc/prom_init: Fix shellcheck warnings
      https://git.kernel.org/powerpc/c/d40ae9033418095642f65f4fd54dc5a7d292ee39
[4/4] powerpc/boot/install.sh: Fix shellcheck warnings
      https://git.kernel.org/powerpc/c/8763d2257f5231cfdfd8a53594647927dbf8bb06

Thanks