From c68d463286cd481cfbc4b0207fafef1ef5506d3b Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 21 Jul 2021 11:39:25 +0200 Subject: [PATCH] s390/hwcaps: add sanity checks Add BUILD_BUG_ON() sanity checks to make sure the hwcap string array contains a string for each hwcap. Signed-off-by: Heiko Carstens --- arch/s390/include/asm/elf.h | 2 ++ arch/s390/kernel/processor.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h index 88f7b7e7c08a..f02273831473 100644 --- a/arch/s390/include/asm/elf.h +++ b/arch/s390/include/asm/elf.h @@ -114,6 +114,7 @@ enum { HWCAP_NR_VXRS_PDE2 = 19, HWCAP_NR_NNPA = 20, HWCAP_NR_PCI_MIO = 21, + HWCAP_NR_MAX }; /* Bits present in AT_HWCAP. */ @@ -142,6 +143,7 @@ enum { enum { HWCAP_INT_NR_SIE = 0, + HWCAP_INT_NR_MAX }; /* Internal bits, not exposed via elf */ diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c index 1eb2410d9fb2..e0efe946d8f0 100644 --- a/arch/s390/kernel/processor.c +++ b/arch/s390/kernel/processor.c @@ -141,6 +141,8 @@ static void show_cpu_summary(struct seq_file *m, void *v) }; int i, cpu; + BUILD_BUG_ON(ARRAY_SIZE(hwcap_str) != HWCAP_NR_MAX); + BUILD_BUG_ON(ARRAY_SIZE(int_hwcap_str) != HWCAP_INT_NR_MAX); seq_printf(m, "vendor_id : IBM/S390\n" "# processors : %i\n" "bogomips per cpu: %lu.%02lu\n",