qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-arm: Don't report presence of EL2 if it doesn't exist
@ 2016-02-02 18:20 Peter Maydell
  2016-02-03 12:30 ` [Qemu-devel] [Qemu-arm] " Sergey Fedorov
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Maydell @ 2016-02-02 18:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Edgar E. Iglesias, qemu-arm, patches

We already modify the processor feature bits to not report EL3
support to the guest if EL3 isn't enabled for the CPU we're emulating.
Add similar support for not reporting EL2 unless it is enabled.
This is necessary because real world guest code running at EL3
(trusted firmware or bootloaders) will query the ID registers to
determine whether it should start a guest Linux kernel in EL2 or EL3.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
When full EL2 arrives and we have the CPU property for it then
this will expand a bit to look like the 'if (!cpu->has_el3)'
condition just above it.

 target-arm/cpu.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/target-arm/cpu.c b/target-arm/cpu.c
index 6c34476..0cc075d 100644
--- a/target-arm/cpu.c
+++ b/target-arm/cpu.c
@@ -650,6 +650,15 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
         cpu->id_aa64pfr0 &= ~0xf000;
     }
 
+    if (!arm_feature(env, ARM_FEATURE_EL2)) {
+        /* Disable the hypervisor feature bits in the processor feature
+         * registers if we don't have EL2. These are id_pfr1[15:12] and
+         * id_aa64pfr0_el1[11:8].
+         */
+        cpu->id_aa64pfr0 &= ~0xf00;
+        cpu->id_pfr1 &= ~0xf000;
+    }
+
     if (!cpu->has_mpu) {
         unset_feature(env, ARM_FEATURE_MPU);
     }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [Qemu-arm] [PATCH] target-arm: Don't report presence of EL2 if it doesn't exist
  2016-02-02 18:20 [Qemu-devel] [PATCH] target-arm: Don't report presence of EL2 if it doesn't exist Peter Maydell
@ 2016-02-03 12:30 ` Sergey Fedorov
  0 siblings, 0 replies; 2+ messages in thread
From: Sergey Fedorov @ 2016-02-03 12:30 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: qemu-arm, patches

On 02.02.2016 21:20, Peter Maydell wrote:
> We already modify the processor feature bits to not report EL3
> support to the guest if EL3 isn't enabled for the CPU we're emulating.
> Add similar support for not reporting EL2 unless it is enabled.
> This is necessary because real world guest code running at EL3
> (trusted firmware or bootloaders) will query the ID registers to
> determine whether it should start a guest Linux kernel in EL2 or EL3.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Sergey Fedorov <serge.fdrv@gmail.com>

> ---
> When full EL2 arrives and we have the CPU property for it then
> this will expand a bit to look like the 'if (!cpu->has_el3)'
> condition just above it.
>
>  target-arm/cpu.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/target-arm/cpu.c b/target-arm/cpu.c
> index 6c34476..0cc075d 100644
> --- a/target-arm/cpu.c
> +++ b/target-arm/cpu.c
> @@ -650,6 +650,15 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
>          cpu->id_aa64pfr0 &= ~0xf000;
>      }
>  
> +    if (!arm_feature(env, ARM_FEATURE_EL2)) {
> +        /* Disable the hypervisor feature bits in the processor feature
> +         * registers if we don't have EL2. These are id_pfr1[15:12] and
> +         * id_aa64pfr0_el1[11:8].
> +         */
> +        cpu->id_aa64pfr0 &= ~0xf00;
> +        cpu->id_pfr1 &= ~0xf000;
> +    }
> +
>      if (!cpu->has_mpu) {
>          unset_feature(env, ARM_FEATURE_MPU);
>      }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-03 12:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-02 18:20 [Qemu-devel] [PATCH] target-arm: Don't report presence of EL2 if it doesn't exist Peter Maydell
2016-02-03 12:30 ` [Qemu-devel] [Qemu-arm] " Sergey Fedorov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).