Skip to content

Commit 449b18b

Browse files
committed
target/ppc: Optimize hashchkp and hashstp when in CONFIG_USER_ONLY
Add a method equivalent to CHK_SV that works with decodetree. Use it in hash instructions to optimize when CONFIG_USER_ONLY is defined. Suggested-by: Matheus Ferst <[email protected]> Signed-off-by: Víctor Colombo <[email protected]>
1 parent d4adde4 commit 449b18b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

target/ppc/translate.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,18 @@ typedef struct opcode_t {
13001300

13011301
#define CHK_NONE
13021302

1303+
/* Helper for priv. check to be used in decodetree */
1304+
static inline bool do_check_sv(DisasContext *ctx)
1305+
{
1306+
#if !defined(CONFIG_USER_ONLY)
1307+
if (likely(ctx->pr != 0)) {
1308+
return false;
1309+
}
1310+
#endif
1311+
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_OPC);
1312+
return true;
1313+
}
1314+
13031315
/*****************************************************************************/
13041316
/* PowerPC instructions table */
13051317

target/ppc/translate/fixedpoint-impl.c.inc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,9 @@ static bool do_hash(DisasContext *ctx, arg_X *a, bool priv,
503503
return true;
504504
}
505505

506-
if (unlikely(priv && ctx->pr)) {
506+
if (unlikely(priv && do_check_sv(ctx))) {
507507
/* if instruction is privileged but the context is in user space */
508-
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_OPC);
509-
return 0;
508+
return true;
510509
}
511510

512511
if (a->ra == 0) {

0 commit comments

Comments
 (0)