[PULL 17/36] target/arm: Enforce M-profile VMRS/VMSR register restrictions

Maintainers: Jason Wang <jasowang@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Radoslaw Biernacki <rad@semihalf.com>, Vikram Garhwal <fnu.vikram@xilinx.com>, Jean-Christophe Dubois <jcd@tribudubois.net>, Laurent Vivier <lvivier@redhat.com>, Leif Lindholm <leif@nuviainc.com>, Thomas Huth <thuth@redhat.com>, Eric Auger <eric.auger@redhat.com>, Tyrone Ting <kfting@nuvoton.com>, Peter Chubb <peter.chubb@nicta.com.au>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Alistair Francis <alistair@alistair23.me>, Pavel Pisa <pisa@cmp.felk.cvut.cz>, Havard Skinnemoen <hskinnemoen@google.com>, Paolo Bonzini <pbonzini@redhat.com>
There is a newer version of this series
[PULL 17/36] target/arm: Enforce M-profile VMRS/VMSR register restrictions
Posted by Peter Maydell 5 years, 2 months ago
For M-profile before v8.1M, the only valid register for VMSR/VMRS is
the FPSCR.  We have a comment that states this, but the actual logic
to forbid accesses for any other register value is missing, so we
would end up with A-profile style behaviour.  Add the missing check.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20201119215617.29887-7-peter.maydell@linaro.org
---
 target/arm/translate-vfp.c.inc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc
index 2a67ed0f6e2..e100182a32c 100644
--- a/target/arm/translate-vfp.c.inc
+++ b/target/arm/translate-vfp.c.inc
@@ -622,7 +622,10 @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a)
          * Accesses to R15 are UNPREDICTABLE; we choose to undef.
          * (FPSCR -> r15 is a special case which writes to the PSR flags.)
          */
-        if (a->rt == 15 && (!a->l || a->reg != ARM_VFP_FPSCR)) {
+        if (a->reg != ARM_VFP_FPSCR) {
+            return false;
+        }
+        if (a->rt == 15 && !a->l) {
             return false;
         }
     }
-- 
2.20.1