Skip to content

Commit 32e8bd6

Browse files
hfreudehcahca
authored andcommitted
s390/cpacf: Make use of invalid opcode produce a link error
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 <[email protected]> Signed-off-by: Harald Freudenberger <[email protected]> Reviewed-by: Holger Dengler <[email protected]> Reviewed-by: Juergen Christ <[email protected]> Cc: [email protected] Signed-off-by: Heiko Carstens <[email protected]>
1 parent 830999b commit 32e8bd6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

arch/s390/include/asm/cpacf.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@
166166

167167
typedef struct { unsigned char bytes[16]; } cpacf_mask_t;
168168

169+
/*
170+
* Prototype for a not existing function to produce a link
171+
* error if __cpacf_query() or __cpacf_check_opcode() is used
172+
* with an invalid compile time const opcode.
173+
*/
174+
void __cpacf_bad_opcode(void);
175+
169176
static __always_inline void __cpacf_query_rre(u32 opc, u8 r1, u8 r2,
170177
cpacf_mask_t *mask)
171178
{
@@ -237,7 +244,7 @@ static __always_inline void __cpacf_query(unsigned int opcode,
237244
__cpacf_query_rre(CPACF_PRNO, 2, 4, mask);
238245
break;
239246
default:
240-
BUG();
247+
__cpacf_bad_opcode();
241248
}
242249
}
243250

@@ -262,7 +269,8 @@ static __always_inline int __cpacf_check_opcode(unsigned int opcode)
262269
case CPACF_KMA:
263270
return test_facility(146); /* check for MSA8 */
264271
default:
265-
BUG();
272+
__cpacf_bad_opcode();
273+
return 0;
266274
}
267275
}
268276

0 commit comments

Comments
 (0)