All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mostafa Saleh <smostafa@google.com>
To: Eric Auger <eric.auger@redhat.com>
Cc: qemu-devel@nongnu.org, jean-philippe@linaro.org,
	peter.maydell@linaro.org, qemu-arm@nongnu.org
Subject: Re: [RFC PATCH 05/16] hw/arm/smmuv3: Add page table walk for stage-2
Date: Thu, 16 Feb 2023 13:09:33 +0000	[thread overview]
Message-ID: <Y+4rDVGJdhnN+p9z@google.com> (raw)
In-Reply-To: <4e248ff8-3032-0697-d50c-d3b62b072a82@redhat.com>

Hi Eric,

On Wed, Feb 15, 2023 at 05:52:39PM +0100, Eric Auger wrote:
> > In preparation for adding stage-2 support. Add Stage-2 PTW code.
> > Only Aarch64 fromat is supported as stage-1.
> format
I will update it.

> > +        uint64_t subpage_size = 1ULL << level_shift(level, granule_sz);
> > +        uint64_t mask = subpage_size - 1;
> > +        uint32_t offset = iova_level_offset(iova, inputsize, level, granule_sz);
> > +        uint64_t pte, gpa;
> > +        dma_addr_t pte_addr = baseaddr + offset * sizeof(pte);
> > +        uint8_t ap;
> > +
> > +        if (get_pte(baseaddr, offset, &pte, info)) {
> > +                goto error;
> > +        }
> > +        trace_smmu_ptw_level(level, iova, subpage_size,
> > +                             baseaddr, offset, pte);
> I can the trace point names should be updated as well (and
> differentiated between S1/S2)
I was thinking we could leave those with stage argument, and only
update trace_smmu_ptw_level to have stage argument as the others.

> > +        if (is_permission_fault_s2(ap, perm)) {
> > +            info->type = SMMU_PTW_ERR_PERMISSION;
> don't we have to different S1 versus S2 faults?
Yes, I missed that, I see setting info->u.f_walk_eabt.s2 should be
enough, this will set the S2 field in the fault event.

> >  int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm,
> >               SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info)
> >  {
> > -    if (!cfg->aa64) {
> > -        /*
> > -         * This code path is not entered as we check this while decoding
> > -         * the configuration data in the derived SMMU model.
> > -         */
> > -        g_assert_not_reached();
> if that's still true for S2, maybe keep that check here upfront?
Stage-2 is checked in STE parsing and throws BAD_STE if not aa64,
which I believe is not correct, however I think we can just call
g_assert_not_reached() during STE parsing, I don’t see added value for
saving this field in SMMUTransCfg if we don’t use it.
I am not sure why this check exists for stage-1 as it is hardcoded in
decode_cd anyway.

> > +{
> > +    uint64_t ret;
> > +    /*
> > +     * Get the number of bits handled by next levels, then any extra bits in
> > +     * the address should index the concatenated tables. This relation can
> > +     * deduced from tables in ARM ARM: D8.2.7-9
> > +     */
> > +    int shift = (SMMU_MAX_LEVELS - start_level) * (granule - 3) + granule;
> can't we factorize anything with the S1 PTW?
> indexmask = (1ULL << (inputsize - (stride * (4 - level)))) - 1;
Yes, I think we can refactor some of these in common functions/macros, I
will do that in v2.


> > @@ -28,6 +28,7 @@
> >  #define SMMU_PCI_DEVFN(sid)   (sid & 0xFF)
> >  
> >  #define SMMU_MAX_VA_BITS      48
> > +#define SMMU_MAX_LEVELS       4
> can't this be reused as well with S1 PTW?
I believe yes, I will update it.

Thanks,
Mostafa

  reply	other threads:[~2023-02-16 13:09 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-05  9:43 [RFC PATCH 00/16] Add stage-2 translation for SMMUv3 Mostafa Saleh
2023-02-05  9:43 ` [RFC PATCH 01/16] hw/arm/smmuv3: Add missing fields for IDR0 Mostafa Saleh
2023-02-06 22:51   ` Richard Henderson
2023-02-15 16:16   ` Eric Auger
2023-02-05  9:43 ` [RFC PATCH 02/16] hw/arm/smmuv3: Update translation config to hold stage-2 Mostafa Saleh
2023-02-15 18:57   ` Eric Auger
2023-02-16 12:53     ` Mostafa Saleh
2023-02-05  9:43 ` [RFC PATCH 03/16] hw/arm/smmuv3: Rename smmu_ptw_64 Mostafa Saleh
2023-02-15 16:53   ` Eric Auger
2023-02-16 12:56     ` Mostafa Saleh
2023-02-16 16:44       ` Eric Auger
2023-02-05  9:43 ` [RFC PATCH 04/16] hw/arm/smmuv3: Add a system property to choose translation stage Mostafa Saleh
2023-02-15 16:29   ` Eric Auger
2023-02-16 12:58     ` Mostafa Saleh
2023-02-16 16:45       ` Eric Auger
2023-02-05  9:44 ` [RFC PATCH 05/16] hw/arm/smmuv3: Add page table walk for stage-2 Mostafa Saleh
2023-02-15 16:52   ` Eric Auger
2023-02-16 13:09     ` Mostafa Saleh [this message]
2023-02-16 16:50       ` Eric Auger
2023-02-05  9:44 ` [RFC PATCH 06/16] hw/arm/smmuv3: Parse STE config " Mostafa Saleh
2023-02-15 17:47   ` Eric Auger
2023-02-16 13:17     ` Mostafa Saleh
2023-02-05  9:44 ` [RFC PATCH 07/16] hw/arm/smmuv3: Check validity of stage-2 page table Mostafa Saleh
2023-02-15 18:53   ` Eric Auger
2023-02-16 13:20     ` Mostafa Saleh
2023-02-05  9:44 ` [RFC PATCH 08/16] hw/arm/smmuv3: Support S2AFFD Mostafa Saleh
2023-02-15 18:37   ` Eric Auger
2023-02-16 13:27     ` Mostafa Saleh
2023-02-05  9:44 ` [RFC PATCH 09/16] hw/arm/smmuv3: Don't touch CD if stage-1 is not supported Mostafa Saleh
2023-02-05  9:44 ` [RFC PATCH 10/16] hw/arm/smmuv3: Make TLB lookup work for stage-2 Mostafa Saleh
2023-02-16 11:32   ` Eric Auger
2023-02-16 13:49     ` Mostafa Saleh
2023-02-16 16:52       ` Eric Auger
2023-02-05  9:44 ` [RFC PATCH 11/16] hw/arm/smmuv3: Read VMID from STE Mostafa Saleh
2023-02-05  9:44 ` [RFC PATCH 12/16] hw/arm/smmuv3: Add VMID to tlb tagging Mostafa Saleh
2023-02-15 19:47   ` Jean-Philippe Brucker
2023-02-16 13:52     ` Mostafa Saleh
2023-02-16 10:17   ` Eric Auger
2023-02-16 13:53     ` Mostafa Saleh
2023-02-16 16:53       ` Eric Auger
2023-02-05  9:44 ` [RFC PATCH 13/16] hw/arm/smmuv3: Add CMDs related to stage 2 Mostafa Saleh
2023-02-16 11:56   ` Eric Auger
2023-02-16 13:58     ` Mostafa Saleh
2023-02-16 16:54       ` Eric Auger
2023-02-05  9:44 ` [RFC PATCH 14/16] hw/arm/smmuv3: Add stage-2 support in iova notifier Mostafa Saleh
2023-02-05  9:44 ` [RFC PATCH 15/16] hw/arm/smmuv3: Add fault configuration for stage-2 Mostafa Saleh
2023-02-15 18:55   ` Eric Auger
2023-02-16 14:01     ` Mostafa Saleh
2023-02-05  9:44 ` [RFC PATCH 16/16] hw/arm/smmuv3: Enable stage-2 support Mostafa Saleh

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=Y+4rDVGJdhnN+p9z@google.com \
    --to=smostafa@google.com \
    --cc=eric.auger@redhat.com \
    --cc=jean-philippe@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.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.