[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 02/11] target/ppc: add macros to check privilege level
From: |
Lucas Coutinho |
Subject: |
[PATCH 02/11] target/ppc: add macros to check privilege level |
Date: |
Wed, 15 Jun 2022 16:19:57 -0300 |
From: Matheus Ferst <matheus.ferst@eldorado.org.br>
Equivalent to CHK_SV and CHK_HV, but can be used in decodetree methods.
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Signed-off-by: Lucas Coutinho <lucas.coutinho@eldorado.org.br>
---
target/ppc/translate.c | 21 +++++++++++++++++++++
target/ppc/translate/fixedpoint-impl.c.inc | 7 ++-----
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index 920bb543cf..508ef6660d 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -6575,6 +6575,27 @@ static int times_16(DisasContext *ctx, int x)
} \
} while (0)
+#if !defined(CONFIG_USER_ONLY)
+#define REQUIRE_SV(CTX) \
+ do { \
+ if (unlikely((CTX)->pr)) { \
+ gen_priv_opc(CTX); \
+ return true; \
+ } \
+ } while (0)
+
+#define REQUIRE_HV(CTX) \
+ do { \
+ if (unlikely((CTX)->pr || !(CTX)->hv)) \
+ gen_priv_opc(CTX); \
+ return true; \
+ } \
+ } while (0)
+#else
+#define REQUIRE_SV(CTX) do { gen_priv_opc(CTX); return true; } while (0)
+#define REQUIRE_HV(CTX) do { gen_priv_opc(CTX); return true; } while (0)
+#endif
+
/*
* Helpers for implementing sets of trans_* functions.
* Defer the implementation of NAME to FUNC, with optional extra arguments.
diff --git a/target/ppc/translate/fixedpoint-impl.c.inc
b/target/ppc/translate/fixedpoint-impl.c.inc
index 1aab32be03..77d449c3cd 100644
--- a/target/ppc/translate/fixedpoint-impl.c.inc
+++ b/target/ppc/translate/fixedpoint-impl.c.inc
@@ -79,11 +79,8 @@ static bool do_ldst_quad(DisasContext *ctx, arg_D *a, bool
store, bool prefixed)
REQUIRE_INSNS_FLAGS(ctx, 64BX);
if (!prefixed && !(ctx->insns_flags2 & PPC2_LSQ_ISA207)) {
- if (ctx->pr) {
- /* lq and stq were privileged prior to V. 2.07 */
- gen_priv_exception(ctx, POWERPC_EXCP_PRIV_OPC);
- return true;
- }
+ /* lq and stq were privileged prior to V. 2.07 */
+ REQUIRE_SV(ctx);
if (ctx->le_mode) {
gen_align_no_le(ctx);
--
2.25.1
- [PATCH 00/11] target/ppc: Implement slbiag move slb* to decodetree, Lucas Coutinho, 2022/06/15
- [PATCH 01/11] target/ppc: receive DisasContext explicitly in GEN_PRIV, Lucas Coutinho, 2022/06/15
- [PATCH 02/11] target/ppc: add macros to check privilege level,
Lucas Coutinho <=
- [PATCH 03/11] target/ppc: Move slbie to decodetree, Lucas Coutinho, 2022/06/15
- [PATCH 04/11] target/ppc: Move slbieg to decodetree, Lucas Coutinho, 2022/06/15
- [PATCH 05/11] target/ppc: Move slbia to decodetree, Lucas Coutinho, 2022/06/15
- [PATCH 06/11] target/ppc: Move slbmte to decodetree, Lucas Coutinho, 2022/06/15
- [PATCH 08/11] target/ppc: Move slbmfee to decodetree, Lucas Coutinho, 2022/06/15