qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
@ 2020-05-20  0:24 Julien Freche
  2020-05-20  0:32 ` [Bug 1879587] " Julien Freche
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Julien Freche @ 2020-05-20  0:24 UTC (permalink / raw)
  To: qemu-devel

Public bug reported:

I am running into a situation where I have:
- A hypervisor running in EL2, AA64
- A guest running in EL1, AA32

We trap certain accesses to special registers such as DACR (via
HCR.TVM). One instruction that is trapped is:

ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

The guest is running in SVC mode. So, LR should refer to LR_svc there.
LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
the actual ESR value is: 0xfe00dc0

If we decode the 'rt':
>>> (0xfe00dc0 >> 5) & 0x1f
14

My understanding is that 14 is incorrect in the context of AA64. rt
should be set to 18. The current mode being SVC, LR refers to LR_svc not
LR_usr. In other words, the mapping between registers in AA64 and AA32
doesn't seem to be accounted for. I've tested this with Qemu 5.0.0

Let me know if that makes sense and if you would like more info. I am also happy to test patches.
Thanks for all the great work on Qemu!

** Affects: qemu
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  New

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

* [Bug 1879587] Re: Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
  2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
@ 2020-05-20  0:32 ` Julien Freche
  2020-07-30 11:15 ` Peter Maydell
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Julien Freche @ 2020-05-20  0:32 UTC (permalink / raw)
  To: qemu-devel

This is with qemu-system-aarch64 - forgot to mention it explicitly. So,
it will only affect qemu for ARM 64-bit.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  New

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

* [Bug 1879587] Re: Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
  2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
  2020-05-20  0:32 ` [Bug 1879587] " Julien Freche
@ 2020-07-30 11:15 ` Peter Maydell
  2020-08-03 16:59 ` Peter Maydell
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2020-07-30 11:15 UTC (permalink / raw)
  To: qemu-devel

** Tags added: arm

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  New

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

* [Bug 1879587] Re: Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
  2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
  2020-05-20  0:32 ` [Bug 1879587] " Julien Freche
  2020-07-30 11:15 ` Peter Maydell
@ 2020-08-03 16:59 ` Peter Maydell
  2020-08-03 17:58 ` Julien Freche
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2020-08-03 16:59 UTC (permalink / raw)
  To: qemu-devel

Thanks for the bug report; I think this patch should fix it:

https://patchew.org/QEMU/20200803165409.15099-1-peter.maydell@linaro.org/

Any chance you could test it?


** Changed in: qemu
       Status: New => In Progress

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  In Progress

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

* [Bug 1879587] Re: Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
  2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
                   ` (2 preceding siblings ...)
  2020-08-03 16:59 ` Peter Maydell
@ 2020-08-03 17:58 ` Julien Freche
  2020-08-03 18:03 ` Julien Freche
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Julien Freche @ 2020-08-03 17:58 UTC (permalink / raw)
  To: qemu-devel

Of course. I just tested the patch (used the branch from
https://github.com/patchew-project/qemu) and it didn't seem to help.
Could that be linked to the fact that the translation is only in the SMC
exception path? It should probably target the MSR exception path also
(and probably others too). It's just a guess as I am not very familiar
with the code. If that's enough info, do let me know how to gather more
useful information.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  In Progress

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

* [Bug 1879587] Re: Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
  2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
                   ` (3 preceding siblings ...)
  2020-08-03 17:58 ` Julien Freche
@ 2020-08-03 18:03 ` Julien Freche
  2020-08-04 12:44 ` Peter Maydell
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Julien Freche @ 2020-08-03 18:03 UTC (permalink / raw)
  To: qemu-devel

Maybe it's covered by EXCP_HYP_TRAP already...

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  In Progress

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

* [Bug 1879587] Re: Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
  2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
                   ` (4 preceding siblings ...)
  2020-08-03 18:03 ` Julien Freche
@ 2020-08-04 12:44 ` Peter Maydell
  2020-08-04 19:00 ` Julien Freche
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2020-08-04 12:44 UTC (permalink / raw)
  To: qemu-devel

Hmm, that's odd. The switch statement fall-throughs and case labels mean
that that code should be executed for all exceptions taken to AArch64
except for IRQ/FIQ/VIRQ/VFIQ. (You could probably confirm that by
running QEMU under a debugger and putting in suitable breakpoints.)

Do you have a test case image/command line I could use to reproduce the
issue ?

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  In Progress

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

* [Bug 1879587] Re: Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
  2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
                   ` (5 preceding siblings ...)
  2020-08-04 12:44 ` Peter Maydell
@ 2020-08-04 19:00 ` Julien Freche
  2020-08-04 19:17 ` Peter Maydell
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Julien Freche @ 2020-08-04 19:00 UTC (permalink / raw)
  To: qemu-devel

Unfortunately, I won't be able to send the code or binary for the
hypervisor as of now (it will become available at some point in the
future though). I've done a bit of debugging on the QEMU code and it
seems like the approach you are taking works fine in general but the
register mapping code doesn't seem quite right. Applying this patch (on
top of yours):

>From e2182581dcdeedc2cb88cd21b88b4db744677737 Mon Sep 17 00:00:00 2001
From: Julien Freche <julien@bedrocksystems.com>
Date: Tue, 4 Aug 2020 11:54:49 -0700
Subject: [PATCH] Possible fix

---
 target/arm/helper.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/target/arm/helper.c b/target/arm/helper.c
index 60b80228fd..455c92b891 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -9619,17 +9619,16 @@ static int aarch64_regnum(CPUARMState *env, int aarch32_reg)
         switch (mode) {
         case ARM_CPU_MODE_USR:
         case ARM_CPU_MODE_SYS:
-            return 14;
         case ARM_CPU_MODE_HYP:
-            return 16;
+            return 14;
         case ARM_CPU_MODE_IRQ:
-            return 18;
+            return 16;
         case ARM_CPU_MODE_SVC:
-            return 20;
+            return 18;
         case ARM_CPU_MODE_ABT:
-            return 22;
+            return 20;
         case ARM_CPU_MODE_UND:
-            return 24;
+            return 22;
         case ARM_CPU_MODE_FIQ:
             return 30;
         default:
-- 
2.28.0

Based on the ARM documentation, I would think that LR_svc maps to X18,
not X20. I fixed the ones that seemed wrong but I haven't check every
possible case so you may want to double check this. With the patch I was
able to boot Linux correctly.

Let me know if that makes sense

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  In Progress

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

* [Bug 1879587] Re: Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
  2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
                   ` (6 preceding siblings ...)
  2020-08-04 19:00 ` Julien Freche
@ 2020-08-04 19:17 ` Peter Maydell
  2020-08-05 10:55 ` Peter Maydell
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2020-08-04 19:17 UTC (permalink / raw)
  To: qemu-devel

Whoops, yes. I somehow misread that table (I think I failed to spot that
there is no LR_hyp and it just shares r14 with usr/sys, so I did a
cut-n-paste of the SP cases to LR, which isn't right). I think your
adjustment to the patch is correct. I'll do a v2 patch for you to test,
but it will just be those fixes applied to v1.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  In Progress

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

* [Bug 1879587] Re: Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
  2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
                   ` (7 preceding siblings ...)
  2020-08-04 19:17 ` Peter Maydell
@ 2020-08-05 10:55 ` Peter Maydell
  2020-08-05 15:05 ` Julien Freche
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2020-08-05 10:55 UTC (permalink / raw)
  To: qemu-devel

v2 is here https://patches.linaro.org/patch/247434/ -- hoping to put
that in master today...

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  In Progress

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

* [Bug 1879587] Re: Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
  2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
                   ` (8 preceding siblings ...)
  2020-08-05 10:55 ` Peter Maydell
@ 2020-08-05 15:05 ` Julien Freche
  2020-08-05 15:19 ` Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Julien Freche @ 2020-08-05 15:05 UTC (permalink / raw)
  To: qemu-devel

It seems like this is your patch plus my fixup so this is good to me and
already tested locally. Thanks again.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  In Progress

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

* [Bug 1879587] Re: Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
  2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
                   ` (9 preceding siblings ...)
  2020-08-05 15:05 ` Julien Freche
@ 2020-08-05 15:19 ` Philippe Mathieu-Daudé
  2020-08-05 15:27 ` Julien Freche
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-08-05 15:19 UTC (permalink / raw)
  To: qemu-devel

Hey Julien, what fixup do you need on top of Peter's v2?

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  In Progress

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

* [Bug 1879587] Re: Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
  2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
                   ` (10 preceding siblings ...)
  2020-08-05 15:19 ` Philippe Mathieu-Daudé
@ 2020-08-05 15:27 ` Julien Freche
  2020-08-05 16:42 ` Peter Maydell
  2020-08-20 15:01 ` Thomas Huth
  13 siblings, 0 replies; 15+ messages in thread
From: Julien Freche @ 2020-08-05 15:27 UTC (permalink / raw)
  To: qemu-devel

Peter's v2 already includes the fixup (update #6)

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  In Progress

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

* [Bug 1879587] Re: Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
  2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
                   ` (11 preceding siblings ...)
  2020-08-05 15:27 ` Julien Freche
@ 2020-08-05 16:42 ` Peter Maydell
  2020-08-20 15:01 ` Thomas Huth
  13 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2020-08-05 16:42 UTC (permalink / raw)
  To: qemu-devel

** Changed in: qemu
       Status: In Progress => Fix Committed

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  Fix Committed

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

* [Bug 1879587] Re: Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64
  2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
                   ` (12 preceding siblings ...)
  2020-08-05 16:42 ` Peter Maydell
@ 2020-08-20 15:01 ` Thomas Huth
  13 siblings, 0 replies; 15+ messages in thread
From: Thomas Huth @ 2020-08-20 15:01 UTC (permalink / raw)
  To: qemu-devel

https://git.qemu.org/?p=qemu.git;a=commitdiff;h=a65dabf71a9f9b949

** Changed in: qemu
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1879587

Title:
  Register number in ESR is incorrect for certain banked registers when
  switching from AA32 to AA64

Status in QEMU:
  Fix Released

Bug description:
  I am running into a situation where I have:
  - A hypervisor running in EL2, AA64
  - A guest running in EL1, AA32

  We trap certain accesses to special registers such as DACR (via
  HCR.TVM). One instruction that is trapped is:

  ee03ef10  ->    mcr     15, 0, lr, cr3, cr0, {0}

  The guest is running in SVC mode. So, LR should refer to LR_svc there.
  LR_svc is mapped to X18 in AA64. So, ESR should reflect that. However,
  the actual ESR value is: 0xfe00dc0

  If we decode the 'rt':
  >>> (0xfe00dc0 >> 5) & 0x1f
  14

  My understanding is that 14 is incorrect in the context of AA64. rt
  should be set to 18. The current mode being SVC, LR refers to LR_svc
  not LR_usr. In other words, the mapping between registers in AA64 and
  AA32 doesn't seem to be accounted for. I've tested this with Qemu
  5.0.0

  Let me know if that makes sense and if you would like more info. I am also happy to test patches.
  Thanks for all the great work on Qemu!

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1879587/+subscriptions


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

end of thread, other threads:[~2020-08-20 15:26 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20  0:24 [Bug 1879587] [NEW] Register number in ESR is incorrect for certain banked registers when switching from AA32 to AA64 Julien Freche
2020-05-20  0:32 ` [Bug 1879587] " Julien Freche
2020-07-30 11:15 ` Peter Maydell
2020-08-03 16:59 ` Peter Maydell
2020-08-03 17:58 ` Julien Freche
2020-08-03 18:03 ` Julien Freche
2020-08-04 12:44 ` Peter Maydell
2020-08-04 19:00 ` Julien Freche
2020-08-04 19:17 ` Peter Maydell
2020-08-05 10:55 ` Peter Maydell
2020-08-05 15:05 ` Julien Freche
2020-08-05 15:19 ` Philippe Mathieu-Daudé
2020-08-05 15:27 ` Julien Freche
2020-08-05 16:42 ` Peter Maydell
2020-08-20 15:01 ` Thomas Huth

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).