summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Freudenberger <freude@linux.ibm.com>2024-05-14 11:09:32 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-06-16 14:40:00 +0300
commit08de19f2b7a8d4234894c985f16bad28c2f97c00 (patch)
tree0f04b415c701cf7881675ebfd128f4e1ca839385
parentedaaf1f94e242a9090478d13ae6c192cb823bbff (diff)
downloadlinux-08de19f2b7a8d4234894c985f16bad28c2f97c00.tar.xz
s390/cpacf: Make use of invalid opcode produce a link error
commit 32e8bd6423fc127d2b37bdcf804fd76af3bbec79 upstream. Instead of calling BUG() at runtime introduce and use a prototype for a non-existing function to produce a link error during compile when a not supported opcode is used with the __cpacf_query() or __cpacf_check_opcode() inline functions. Suggested-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Harald Freudenberger <freude@linux.ibm.com> Reviewed-by: Holger Dengler <dengler@linux.ibm.com> Reviewed-by: Juergen Christ <jchrist@linux.ibm.com> Cc: stable@vger.kernel.org Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/s390/include/asm/cpacf.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/arch/s390/include/asm/cpacf.h b/arch/s390/include/asm/cpacf.h
index fa31f71cf574..0f6ff2008a15 100644
--- a/arch/s390/include/asm/cpacf.h
+++ b/arch/s390/include/asm/cpacf.h
@@ -161,6 +161,13 @@
typedef struct { unsigned char bytes[16]; } cpacf_mask_t;
+/*
+ * Prototype for a not existing function to produce a link
+ * error if __cpacf_query() or __cpacf_check_opcode() is used
+ * with an invalid compile time const opcode.
+ */
+void __cpacf_bad_opcode(void);
+
static __always_inline void __cpacf_query_rre(u32 opc, u8 r1, u8 r2,
cpacf_mask_t *mask)
{
@@ -232,7 +239,7 @@ static __always_inline void __cpacf_query(unsigned int opcode,
__cpacf_query_rre(CPACF_PRNO, 2, 4, mask);
break;
default:
- BUG();
+ __cpacf_bad_opcode();
}
}
@@ -257,7 +264,8 @@ static __always_inline int __cpacf_check_opcode(unsigned int opcode)
case CPACF_KMA:
return test_facility(146); /* check for MSA8 */
default:
- BUG();
+ __cpacf_bad_opcode();
+ return 0;
}
}