From d589010512005bfc698f30417911e4b14478c81b Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Wed, 22 Jun 2022 01:30:39 -0700 Subject: [PATCH] hw/arm/smmu-common: Add a nested flag to SMMUState Add a nested flag in the SMMUState, passed in from device property. Signed-off-by: Nicolin Chen --- hw/arm/smmu-common.c | 1 + hw/arm/smmuv3.c | 5 +++++ include/hw/arm/smmu-common.h | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 9a8ac45431..c5f3e02065 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -683,6 +683,7 @@ static Property smmu_dev_properties[] = { DEFINE_PROP_UINT8("bus_num", SMMUState, bus_num, 0), DEFINE_PROP_LINK("primary-bus", SMMUState, primary_bus, TYPE_PCI_BUS, PCIBus *), + DEFINE_PROP_BOOL("nested", SMMUState, nested, false), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index c3871ae067..64ca4c5542 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -1746,6 +1746,11 @@ static void smmu_realize(DeviceState *d, Error **errp) SysBusDevice *dev = SYS_BUS_DEVICE(d); Error *local_err = NULL; + if (s->stage && strcmp("1", s->stage)) { + /* Only support nested with an stage1 only vSMMU */ + sys->nested = false; + } + c->parent_realize(d, &local_err); if (local_err) { error_propagate(errp, local_err); diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index fd8d772da1..eae5d4d05b 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -22,6 +22,7 @@ #include "hw/sysbus.h" #include "hw/pci/pci.h" #include "qom/object.h" +#include "sysemu/iommufd.h" #define SMMU_PCI_BUS_MAX 256 #define SMMU_PCI_DEVFN_MAX 256 @@ -136,6 +137,9 @@ struct SMMUState { const char *mrtypename; MemoryRegion iomem; + /* Nested SMMU */ + bool nested; + GHashTable *smmu_pcibus_by_busptr; GHashTable *configs; /* cache for configuration data */ GHashTable *iotlb; -- 2.41.0.windows.1