diff mbox

[v2] ARM: Permit any ARMv6K CPU to read the MVFR0 and MVFR1 VFP registers.

Message ID 1333024868-1336-1-git-send-email-atowers@gmail.com
State New
Headers show

Commit Message

Andrew Towers March 29, 2012, 12:41 p.m. UTC
This patch replaces the ARM_FEATURE_VFP3 test when reading MVFR registers
with a test for a new feature flag ARM_FEATURE_MVFR, and sets this feature
for all ARMv6K cores (ARM1156 is not a v6K core, yet supports MVFR; qemu
does not support ARM1156 at this time.)

MVFR0 and MVFR1 were introduced in ARM1136JF-S r1p0 (ARMv6K, VFPv2) and are
present in ARM1156T2F-S (non-v6K), ARM1176JZF-S, ARM11MPCore and newer cores.
Reference: ARM DDI 0211H, 0290G, 0301H, 0360E.
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0211h/Ffbefjag.html

Without this change, the linux kernel will not boot with VFP support enabled
under ARM1176 system emulation, due to the unconditional use of MVFR1 at the
end of vfp_init() in arch/arm/vfp/vfpmodule.c:

  VFP support v0.3: implemetor 41 architecture 1 part 20 variant b rev 5
  Internal error: Oops - undefined instruction: 0 [#1]

Signed-off-by: Andrew Towers <atowers@gmail.com>
---

v2:
 * introduced ARM_FEATURE_MVFR, implied by ARM_FEATURE_V6K.

Paul: I'd love to work on an rPi board model, and I'll see what I can put
together, but much of the hardware is under NDA and I'm not in the loop..


 target-arm/cpu.h       |    1 +
 target-arm/helper.c    |    1 +
 target-arm/translate.c |    2 +-
 3 files changed, 3 insertions(+), 1 deletions(-)

Comments

Andreas Färber March 29, 2012, 1:10 p.m. UTC | #1
Am 29.03.2012 14:41, schrieb Andrew Towers:
> This patch replaces the ARM_FEATURE_VFP3 test when reading MVFR registers
> with a test for a new feature flag ARM_FEATURE_MVFR, and sets this feature
> for all ARMv6K cores (ARM1156 is not a v6K core, yet supports MVFR; qemu
> does not support ARM1156 at this time.)
> 
> MVFR0 and MVFR1 were introduced in ARM1136JF-S r1p0 (ARMv6K, VFPv2) and are
> present in ARM1156T2F-S (non-v6K), ARM1176JZF-S, ARM11MPCore and newer cores.
> Reference: ARM DDI 0211H, 0290G, 0301H, 0360E.
> http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0211h/Ffbefjag.html
> 
> Without this change, the linux kernel will not boot with VFP support enabled
> under ARM1176 system emulation, due to the unconditional use of MVFR1 at the
> end of vfp_init() in arch/arm/vfp/vfpmodule.c:
> 
>   VFP support v0.3: implemetor 41 architecture 1 part 20 variant b rev 5
>   Internal error: Oops - undefined instruction: 0 [#1]
> 
> Signed-off-by: Andrew Towers <atowers@gmail.com>

Feature inference looks good,

Reviewed-by: Andreas Färber <afaerber@suse.de>

> ---
> 
> v2:
>  * introduced ARM_FEATURE_MVFR, implied by ARM_FEATURE_V6K.
> 
> Paul: I'd love to work on an rPi board model, and I'll see what I can put
> together, but much of the hardware is under NDA and I'm not in the loop..

You might find the partial bcm2835 manual helpful:
http://www.raspberrypi.org/archives/615

Open-source drivers (esp. Linux) are also often a helpful source for
emulating NDA'ed hardware.

Regards,
Andreas
Peter Maydell March 29, 2012, 1:46 p.m. UTC | #2
On 29 March 2012 13:41, Andrew Towers <atowers@gmail.com> wrote:
> This patch replaces the ARM_FEATURE_VFP3 test when reading MVFR registers
> with a test for a new feature flag ARM_FEATURE_MVFR, and sets this feature
> for all ARMv6K cores (ARM1156 is not a v6K core, yet supports MVFR; qemu
> does not support ARM1156 at this time.)

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
and put into target-arm.next. I'll probably do a pullreq tomorrow.

Thanks!
-- PMM
diff mbox

Patch

diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 26c114b..4cbd389 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -383,6 +383,7 @@  enum arm_features {
     ARM_FEATURE_ARM_DIV, /* divide supported in ARM encoding */
     ARM_FEATURE_VFP4, /* VFPv4 (implies that NEON is v2) */
     ARM_FEATURE_GENERIC_TIMER,
+    ARM_FEATURE_MVFR, /* Media and VFP Feature Registers 0 and 1 */
 };
 
 static inline int arm_feature(CPUARMState *env, int feature)
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 1314f23..837e9b0 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -254,6 +254,7 @@  static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
     }
     if (arm_feature(env, ARM_FEATURE_V6K)) {
         set_feature(env, ARM_FEATURE_V6);
+        set_feature(env, ARM_FEATURE_MVFR);
     }
     if (arm_feature(env, ARM_FEATURE_V6)) {
         set_feature(env, ARM_FEATURE_V5);
diff --git a/target-arm/translate.c b/target-arm/translate.c
index b5861c8..46d1d3e 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -2906,7 +2906,7 @@  static int disas_vfp_insn(CPUARMState * env, DisasContext *s, uint32_t insn)
                         case ARM_VFP_MVFR0:
                         case ARM_VFP_MVFR1:
                             if (IS_USER(s)
-                                || !arm_feature(env, ARM_FEATURE_VFP3))
+                                || !arm_feature(env, ARM_FEATURE_MVFR))
                                 return 1;
                             tmp = load_cpu_field(vfp.xregs[rn]);
                             break;