All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 34/37] target/arm: Implement the ARMv8.2-AA32HPD extension
Date: Thu, 13 Dec 2018 14:54:42 +0000	[thread overview]
Message-ID: <20181213145445.17935-35-peter.maydell@linaro.org> (raw)
In-Reply-To: <20181213145445.17935-1-peter.maydell@linaro.org>

From: Richard Henderson <richard.henderson@linaro.org>

The bulk of the work here, beyond base HPD, is defining the
TTBCR2 register.  In addition we must check TTBCR.T2E, which
is not present (RES0) for AArch64.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20181203203839.757-11-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target/arm/cpu.h    |  9 +++++++++
 target/arm/cpu.c    |  4 ++++
 target/arm/helper.c | 37 +++++++++++++++++++++++++++++--------
 3 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index b8dbdb5e014..11ec2cce767 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -1548,6 +1548,15 @@ FIELD(ID_ISAR6, FHM, 8, 4)
 FIELD(ID_ISAR6, SB, 12, 4)
 FIELD(ID_ISAR6, SPECRES, 16, 4)
 
+FIELD(ID_MMFR4, SPECSEI, 0, 4)
+FIELD(ID_MMFR4, AC2, 4, 4)
+FIELD(ID_MMFR4, XNX, 8, 4)
+FIELD(ID_MMFR4, CNP, 12, 4)
+FIELD(ID_MMFR4, HPDS, 16, 4)
+FIELD(ID_MMFR4, LSM, 20, 4)
+FIELD(ID_MMFR4, CCIDX, 24, 4)
+FIELD(ID_MMFR4, EVT, 28, 4)
+
 FIELD(ID_AA64ISAR0, AES, 4, 4)
 FIELD(ID_AA64ISAR0, SHA1, 8, 4)
 FIELD(ID_AA64ISAR0, SHA2, 12, 4)
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 60411f6bfe0..0b185f8d309 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1932,6 +1932,10 @@ static void arm_max_initfn(Object *obj)
             t = cpu->isar.id_isar6;
             t = FIELD_DP32(t, ID_ISAR6, DP, 1);
             cpu->isar.id_isar6 = t;
+
+            t = cpu->id_mmfr4;
+            t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */
+            cpu->id_mmfr4 = t;
         }
 #endif
     }
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 57af6b77a1b..037cece1334 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -2728,6 +2728,7 @@ static void vmsa_ttbcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
                              uint64_t value)
 {
     ARMCPU *cpu = arm_env_get_cpu(env);
+    TCR *tcr = raw_ptr(env, ri);
 
     if (arm_feature(env, ARM_FEATURE_LPAE)) {
         /* With LPAE the TTBCR could result in a change of ASID
@@ -2735,6 +2736,8 @@ static void vmsa_ttbcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
          */
         tlb_flush(CPU(cpu));
     }
+    /* Preserve the high half of TCR_EL1, set via TTBCR2.  */
+    value = deposit64(tcr->raw_tcr, 0, 32, value);
     vmsa_ttbcr_raw_write(env, ri, value);
 }
 
@@ -2837,6 +2840,16 @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = {
     REGINFO_SENTINEL
 };
 
+/* Note that unlike TTBCR, writing to TTBCR2 does not require flushing
+ * qemu tlbs nor adjusting cached masks.
+ */
+static const ARMCPRegInfo ttbcr2_reginfo = {
+    .name = "TTBCR2", .cp = 15, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 3,
+    .access = PL1_RW, .type = ARM_CP_ALIAS,
+    .bank_fieldoffsets = { offsetofhigh32(CPUARMState, cp15.tcr_el[3]),
+                           offsetofhigh32(CPUARMState, cp15.tcr_el[1]) },
+};
+
 static void omap_ticonfig_write(CPUARMState *env, const ARMCPRegInfo *ri,
                                 uint64_t value)
 {
@@ -5437,6 +5450,10 @@ void register_cp_regs_for_features(ARMCPU *cpu)
     } else {
         define_arm_cp_regs(cpu, vmsa_pmsa_cp_reginfo);
         define_arm_cp_regs(cpu, vmsa_cp_reginfo);
+        /* TTCBR2 is introduced with ARMv8.2-A32HPD.  */
+        if (FIELD_EX32(cpu->id_mmfr4, ID_MMFR4, HPDS) != 0) {
+            define_one_arm_cp_reg(cpu, &ttbcr2_reginfo);
+        }
     }
     if (arm_feature(env, ARM_FEATURE_THUMB2EE)) {
         define_arm_cp_regs(cpu, t2ee_cp_reginfo);
@@ -9751,12 +9768,14 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
         if (tg == 2) { /* 16KB pages */
             stride = 11;
         }
-        if (aarch64) {
-            if (el > 1) {
-                hpd = extract64(tcr->raw_tcr, 24, 1);
-            } else {
-                hpd = extract64(tcr->raw_tcr, 41, 1);
-            }
+        if (aarch64 && el > 1) {
+            hpd = extract64(tcr->raw_tcr, 24, 1);
+        } else {
+            hpd = extract64(tcr->raw_tcr, 41, 1);
+        }
+        if (!aarch64) {
+            /* For aarch32, hpd0 is not enabled without t2e as well.  */
+            hpd &= extract64(tcr->raw_tcr, 6, 1);
         }
     } else {
         /* We should only be here if TTBR1 is valid */
@@ -9773,8 +9792,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
         if (tg == 1) { /* 16KB pages */
             stride = 11;
         }
-        if (aarch64) {
-            hpd = extract64(tcr->raw_tcr, 42, 1);
+        hpd = extract64(tcr->raw_tcr, 42, 1);
+        if (!aarch64) {
+            /* For aarch32, hpd1 is not enabled without t2e as well.  */
+            hpd &= extract64(tcr->raw_tcr, 6, 1);
         }
     }
 
-- 
2.19.2

  parent reply	other threads:[~2018-12-13 14:55 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13 14:54 [Qemu-devel] [PULL 00/37] target-arm queue Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 01/37] hw: arm: musicpal: drop TYPE_WM8750 in object_property_set_link() Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 02/37] Allow AArch64 processors to boot from a kernel placed over 4GB Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 03/37] musicpal: Convert sysbus init function to realize function Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 04/37] block/noenand: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 05/37] char/grlib_apbuart: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 06/37] core/empty_slot: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 07/37] display/g364fb: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 08/37] dma/puv3_dma: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 09/37] gpio/puv3_gpio: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 10/37] milkymist-softusb: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 11/37] input/pl050: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 12/37] intc/puv3_intc: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 13/37] milkymist-hpdmc: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 14/37] milkymist-pfpu: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 15/37] puv3_pm.c: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 16/37] nvram/ds1225y: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 17/37] pci-bridge/dec: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 18/37] timer/etraxfs_timer: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 19/37] timer/grlib_gptimer: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 20/37] timer/puv3_ost: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 21/37] usb/tusb6010: " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 22/37] xen_backend: remove xen_sysdev_init() function Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 23/37] core/sysbus: remove the SysBusDeviceClass::init path Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 24/37] hw/arm: versal: Remove bogus virtio-mmio creation Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 25/37] hw/arm: versal: Reduce number of virtio-mmio instances Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 26/37] hw/arm: versal: Use IRQs 111 - 118 for virtio-mmio Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 27/37] hw/arm: versal: Correct the nr of IRQs to 192 Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 28/37] target/arm: Move id_aa64mmfr* to ARMISARegisters Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 29/37] target/arm: Add HCR_EL2 bits up to ARMv8.5 Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 30/37] target/arm: Add SCR_EL3 " Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 31/37] target/arm: Fix HCR_EL2.TGE check in arm_phys_excp_target_el Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 32/37] target/arm: Tidy scr_write Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 33/37] target/arm: Implement the ARMv8.1-HPD extension Peter Maydell
2018-12-13 14:54 ` Peter Maydell [this message]
2018-12-13 14:54 ` [Qemu-devel] [PULL 35/37] target/arm: Introduce arm_hcr_el2_eff Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 36/37] target/arm: Use arm_hcr_el2_eff more places Peter Maydell
2018-12-13 14:54 ` [Qemu-devel] [PULL 37/37] target/arm: Implement the ARMv8.1-LOR extension Peter Maydell
2018-12-14 16:43 ` [Qemu-devel] [PULL 00/37] target-arm queue Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181213145445.17935-35-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.