ASR 26 returns a Compatibility Feature Register (CFR) when the
crypto feature is on.  Without the crypto feature, a read keeps
strand status as before.

Return an empty CFR. Each instruction patch sets its bit.
Guests can read the CFR before using each crypto instruction.

Based on OSA (Oracle SPARC Architecture) 2011:
- 5.5 (Ancillary State Registers), table 5-8
- 5.5.11 Compatibility Feature Register (CFR), table 5-15

Signed-off-by: Stian Halseth <[email protected]>
---
 target/sparc/insns.decode |  5 ++++-
 target/sparc/translate.c  | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode
index 242ec42016..55f8528ffe 100644
--- a/target/sparc/insns.decode
+++ b/target/sparc/insns.decode
@@ -106,7 +106,10 @@ CALL    01 i:s30
     RDTICK_CMPR     10 rd:5  101000 10111 0 0000000000000
     RDSTICK         10 rd:5  101000 11000 0 0000000000000
     RDSTICK_CMPR    10 rd:5  101000 11001 0 0000000000000
-    RDSTRAND_STATUS 10 rd:5  101000 11010 0 0000000000000
+    {
+      RDCFR           10 rd:5  101000 11010 0 0000000000000
+      RDSTRAND_STATUS 10 rd:5  101000 11010 0 0000000000000
+    }
   ]
 
   # The v8 manual, section B.30 STBAR instruction, says
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index b93feb074b..a1562f5047 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -3022,6 +3022,20 @@ static TCGv do_rdstrand_status(DisasContext *dc, TCGv 
dst)
 
 TRANS(RDSTRAND_STATUS, HYPV, do_rd_special, true, a->rd, do_rdstrand_status)
 
+/* CFR bits (OSA 2011, 5.5.11) */
+#define CFR_AES         (1 << 0)
+#define CFR_SHA1        (1 << 5)
+#define CFR_SHA256      (1 << 6)
+#define CFR_SHA512      (1 << 7)
+#define CFR_CRC32C      (1 << 11)
+
+static TCGv do_rdcfr(DisasContext *dc, TCGv dst)
+{
+    return tcg_constant_tl(0);
+}
+
+TRANS(RDCFR, CRYPTO, do_rd_special, true, a->rd, do_rdcfr)
+
 static TCGv do_rdpsr(DisasContext *dc, TCGv dst)
 {
     gen_helper_rdpsr(dst, tcg_env);
-- 
2.43.0


Reply via email to