Message ID | 20240701110241.2005222-18-smostafa@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | SMMUv3 nested translation support | expand |
On Mon, Jul 01, 2024 at 11:02:39AM +0000, Mostafa Saleh wrote: > Everything is in place, consolidate parsing of STE cfg and setting > translation stage. > > Advertise nesting if stage requested is "nested". > > Signed-off-by: Mostafa Saleh <smostafa@google.com> Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org> > --- > hw/arm/smmuv3.c | 35 ++++++++++++++++++++++++++--------- > 1 file changed, 26 insertions(+), 9 deletions(-) > > diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c > index 6c18dc0acf..807f26f2da 100644 > --- a/hw/arm/smmuv3.c > +++ b/hw/arm/smmuv3.c > @@ -261,6 +261,9 @@ static void smmuv3_init_regs(SMMUv3State *s) > /* 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 if (s->stage && !strcmp("nested", s->stage)) { > + s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1); > + s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S2P, 1); > } else { > s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1); > } > @@ -425,8 +428,6 @@ static bool s2_pgtable_config_valid(uint8_t sl0, uint8_t t0sz, uint8_t gran) > > static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *ste) > { > - cfg->stage = SMMU_STAGE_2; > - > if (STE_S2AA64(ste) == 0x0) { > qemu_log_mask(LOG_UNIMP, > "SMMUv3 AArch32 tables not supported\n"); > @@ -509,6 +510,27 @@ bad_ste: > return -EINVAL; > } > > +static void decode_ste_config(SMMUTransCfg *cfg, uint32_t config) > +{ > + > + if (STE_CFG_ABORT(config)) { > + cfg->aborted = true; > + return; > + } > + if (STE_CFG_BYPASS(config)) { > + cfg->bypassed = true; > + return; > + } > + > + if (STE_CFG_S1_ENABLED(config)) { > + cfg->stage = SMMU_STAGE_1; > + } > + > + if (STE_CFG_S2_ENABLED(config)) { > + cfg->stage |= SMMU_STAGE_2; > + } > +} > + > /* Returns < 0 in case of invalid STE, 0 otherwise */ > static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, > STE *ste, SMMUEventInfo *event) > @@ -525,13 +547,9 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, > > config = STE_CONFIG(ste); > > - if (STE_CFG_ABORT(config)) { > - cfg->aborted = true; > - return 0; > - } > + decode_ste_config(cfg, config); > > - if (STE_CFG_BYPASS(config)) { > - cfg->bypassed = true; > + if (cfg->aborted || cfg->bypassed) { > return 0; > } > > @@ -704,7 +722,6 @@ static int decode_cd(SMMUv3State *s, SMMUTransCfg *cfg, > > /* we support only those at the moment */ > cfg->aa64 = true; > - cfg->stage = SMMU_STAGE_1; > > cfg->oas = oas2bits(CD_IPS(cd)); > cfg->oas = MIN(oas2bits(SMMU_IDR5_OAS), cfg->oas); > -- > 2.45.2.803.g4e1b14247a-goog >
Hi Mostafa, On 7/1/24 13:02, Mostafa Saleh wrote: > Everything is in place, consolidate parsing of STE cfg and setting > translation stage. > > Advertise nesting if stage requested is "nested". Reviewed-by: Eric Auger <eric.auger@redhat.com> Eric > > Signed-off-by: Mostafa Saleh <smostafa@google.com> > --- > hw/arm/smmuv3.c | 35 ++++++++++++++++++++++++++--------- > 1 file changed, 26 insertions(+), 9 deletions(-) > > diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c > index 6c18dc0acf..807f26f2da 100644 > --- a/hw/arm/smmuv3.c > +++ b/hw/arm/smmuv3.c > @@ -261,6 +261,9 @@ static void smmuv3_init_regs(SMMUv3State *s) > /* 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 if (s->stage && !strcmp("nested", s->stage)) { > + s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1); > + s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S2P, 1); > } else { > s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1); > } > @@ -425,8 +428,6 @@ static bool s2_pgtable_config_valid(uint8_t sl0, uint8_t t0sz, uint8_t gran) > > static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *ste) > { > - cfg->stage = SMMU_STAGE_2; > - > if (STE_S2AA64(ste) == 0x0) { > qemu_log_mask(LOG_UNIMP, > "SMMUv3 AArch32 tables not supported\n"); > @@ -509,6 +510,27 @@ bad_ste: > return -EINVAL; > } > > +static void decode_ste_config(SMMUTransCfg *cfg, uint32_t config) > +{ > + > + if (STE_CFG_ABORT(config)) { > + cfg->aborted = true; > + return; > + } > + if (STE_CFG_BYPASS(config)) { > + cfg->bypassed = true; > + return; > + } > + > + if (STE_CFG_S1_ENABLED(config)) { > + cfg->stage = SMMU_STAGE_1; > + } > + > + if (STE_CFG_S2_ENABLED(config)) { > + cfg->stage |= SMMU_STAGE_2; > + } > +} > + > /* Returns < 0 in case of invalid STE, 0 otherwise */ > static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, > STE *ste, SMMUEventInfo *event) > @@ -525,13 +547,9 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, > > config = STE_CONFIG(ste); > > - if (STE_CFG_ABORT(config)) { > - cfg->aborted = true; > - return 0; > - } > + decode_ste_config(cfg, config); > > - if (STE_CFG_BYPASS(config)) { > - cfg->bypassed = true; > + if (cfg->aborted || cfg->bypassed) { > return 0; > } > > @@ -704,7 +722,6 @@ static int decode_cd(SMMUv3State *s, SMMUTransCfg *cfg, > > /* we support only those at the moment */ > cfg->aa64 = true; > - cfg->stage = SMMU_STAGE_1; > > cfg->oas = oas2bits(CD_IPS(cd)); > cfg->oas = MIN(oas2bits(SMMU_IDR5_OAS), cfg->oas);
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 6c18dc0acf..807f26f2da 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -261,6 +261,9 @@ static void smmuv3_init_regs(SMMUv3State *s) /* 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 if (s->stage && !strcmp("nested", s->stage)) { + s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1); + s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S2P, 1); } else { s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1); } @@ -425,8 +428,6 @@ static bool s2_pgtable_config_valid(uint8_t sl0, uint8_t t0sz, uint8_t gran) static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *ste) { - cfg->stage = SMMU_STAGE_2; - if (STE_S2AA64(ste) == 0x0) { qemu_log_mask(LOG_UNIMP, "SMMUv3 AArch32 tables not supported\n"); @@ -509,6 +510,27 @@ bad_ste: return -EINVAL; } +static void decode_ste_config(SMMUTransCfg *cfg, uint32_t config) +{ + + if (STE_CFG_ABORT(config)) { + cfg->aborted = true; + return; + } + if (STE_CFG_BYPASS(config)) { + cfg->bypassed = true; + return; + } + + if (STE_CFG_S1_ENABLED(config)) { + cfg->stage = SMMU_STAGE_1; + } + + if (STE_CFG_S2_ENABLED(config)) { + cfg->stage |= SMMU_STAGE_2; + } +} + /* Returns < 0 in case of invalid STE, 0 otherwise */ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, STE *ste, SMMUEventInfo *event) @@ -525,13 +547,9 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, config = STE_CONFIG(ste); - if (STE_CFG_ABORT(config)) { - cfg->aborted = true; - return 0; - } + decode_ste_config(cfg, config); - if (STE_CFG_BYPASS(config)) { - cfg->bypassed = true; + if (cfg->aborted || cfg->bypassed) { return 0; } @@ -704,7 +722,6 @@ static int decode_cd(SMMUv3State *s, SMMUTransCfg *cfg, /* we support only those at the moment */ cfg->aa64 = true; - cfg->stage = SMMU_STAGE_1; cfg->oas = oas2bits(CD_IPS(cd)); cfg->oas = MIN(oas2bits(SMMU_IDR5_OAS), cfg->oas);
Everything is in place, consolidate parsing of STE cfg and setting translation stage. Advertise nesting if stage requested is "nested". Signed-off-by: Mostafa Saleh <smostafa@google.com> --- hw/arm/smmuv3.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)