[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/21] hw/arm/smmuv3: Add knob to choose translation stage and ena
|
From: |
Peter Maydell |
|
Subject: |
[PULL 11/21] hw/arm/smmuv3: Add knob to choose translation stage and enable stage-2 |
|
Date: |
Tue, 30 May 2023 14:26:10 +0100 |
From: Mostafa Saleh <smostafa@google.com>
As everything is in place, we can use a new system property to
advertise which stage is supported and remove bad_ste from STE
stage2 config.
The property added arm-smmuv3.stage can have 3 values:
- "1": Stage-1 only is advertised.
- "2": Stage-2 only is advertised.
If not passed or an unsupported value is passed, it will default to
stage-1.
Advertise VMID16.
Don't try to decode CD, if stage-2 is configured.
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Mostafa Saleh <smostafa@google.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Message-id: 20230516203327.2051088-11-smostafa@google.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
include/hw/arm/smmuv3.h | 1 +
hw/arm/smmuv3.c | 32 ++++++++++++++++++++++----------
2 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h
index 6031d7d325f..d183a627669 100644
--- a/include/hw/arm/smmuv3.h
+++ b/include/hw/arm/smmuv3.h
@@ -62,6 +62,7 @@ struct SMMUv3State {
qemu_irq irq[4];
QemuMutex mutex;
+ char *stage;
};
typedef enum {
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
index 17e1359be47..5c598c84285 100644
--- a/hw/arm/smmuv3.c
+++ b/hw/arm/smmuv3.c
@@ -21,6 +21,7 @@
#include "hw/irq.h"
#include "hw/sysbus.h"
#include "migration/vmstate.h"
+#include "hw/qdev-properties.h"
#include "hw/qdev-core.h"
#include "hw/pci/pci.h"
#include "cpu.h"
@@ -241,14 +242,17 @@ void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo
*info)
static void smmuv3_init_regs(SMMUv3State *s)
{
- /**
- * IDR0: stage1 only, AArch64 only, coherent access, 16b ASID,
- * multi-level stream table
- */
- s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1); /* stage 1 supported */
+ /* Based on sys property, the stages supported in smmu will be
advertised.*/
+ if (s->stage && !strcmp("2", s->stage)) {
+ s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S2P, 1);
+ } else {
+ s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1);
+ }
+
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, TTF, 2); /* AArch64 PTW only */
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, COHACC, 1); /* IO coherent */
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, ASID16, 1); /* 16-bit ASID */
+ s->idr[0] = FIELD_DP32(s->idr[0], IDR0, VMID16, 1); /* 16-bit VMID */
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, TTENDIAN, 2); /* little endian */
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, STALL_MODEL, 1); /* No stall */
/* terminated transaction will always be aborted/error returned */
@@ -451,10 +455,6 @@ static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *ste)
goto bad_ste;
}
- /* This is still here as stage 2 has not been fully enabled yet. */
- qemu_log_mask(LOG_UNIMP, "SMMUv3 does not support stage 2 yet\n");
- goto bad_ste;
-
return 0;
bad_ste:
@@ -733,7 +733,7 @@ static int smmuv3_decode_config(IOMMUMemoryRegion *mr,
SMMUTransCfg *cfg,
return ret;
}
- if (cfg->aborted || cfg->bypassed) {
+ if (cfg->aborted || cfg->bypassed || (cfg->stage == 2)) {
return 0;
}
@@ -1804,6 +1804,17 @@ static const VMStateDescription vmstate_smmuv3 = {
}
};
+static Property smmuv3_properties[] = {
+ /*
+ * Stages of translation advertised.
+ * "1": Stage 1
+ * "2": Stage 2
+ * Defaults to stage 1
+ */
+ DEFINE_PROP_STRING("stage", SMMUv3State, stage),
+ DEFINE_PROP_END_OF_LIST()
+};
+
static void smmuv3_instance_init(Object *obj)
{
/* Nothing much to do here as of now */
@@ -1820,6 +1831,7 @@ static void smmuv3_class_init(ObjectClass *klass, void
*data)
&c->parent_phases);
c->parent_realize = dc->realize;
dc->realize = smmu_realize;
+ device_class_set_props(dc, smmuv3_properties);
}
static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
--
2.34.1
- [PULL 00/21] target-arm queue, Peter Maydell, 2023/05/30
- [PULL 04/21] hw/arm/smmuv3: Refactor stage-1 PTW, Peter Maydell, 2023/05/30
- [PULL 15/21] target/arm: Explicitly select short-format FSR for M-profile, Peter Maydell, 2023/05/30
- [PULL 18/21] arm/Kconfig: Make TCG dependence explicit, Peter Maydell, 2023/05/30
- [PULL 03/21] hw/arm/smmuv3: Update translation config to hold stage-2, Peter Maydell, 2023/05/30
- [PULL 08/21] hw/arm/smmuv3: Add VMID to TLB tagging, Peter Maydell, 2023/05/30
- [PULL 10/21] hw/arm/smmuv3: Add stage-2 support in iova notifier, Peter Maydell, 2023/05/30
- [PULL 11/21] hw/arm/smmuv3: Add knob to choose translation stage and enable stage-2,
Peter Maydell <=
- [PULL 17/21] arm/Kconfig: Keep Kconfig default entries in default.mak as documentation, Peter Maydell, 2023/05/30
- [PULL 13/21] hw/arm/xlnx-zynqmp: fix unsigned error when checking the RPUs number, Peter Maydell, 2023/05/30
- [PULL 02/21] hw/arm/smmuv3: Add missing fields for IDR0, Peter Maydell, 2023/05/30
- [PULL 12/21] hw/dma/xilinx_axidma: Check DMASR.HALTED to prevent infinite loop., Peter Maydell, 2023/05/30
- [PULL 01/21] fsl-imx6: Add SNVS support for i.MX6 boards, Peter Maydell, 2023/05/30
- [PULL 09/21] hw/arm/smmuv3: Add CMDs related to stage-2, Peter Maydell, 2023/05/30
- [PULL 19/21] Update copyright dates to 2023, Peter Maydell, 2023/05/30
- [PULL 06/21] hw/arm/smmuv3: Parse STE config for stage-2, Peter Maydell, 2023/05/30
- [PULL 05/21] hw/arm/smmuv3: Add page table walk for stage-2, Peter Maydell, 2023/05/30
- [PULL 14/21] tests/qtest: Run arm-specific tests only if the required machine is available, Peter Maydell, 2023/05/30