hw/arm/smmu-common: Add support for nested TLB
commitd7cdf89c276abeb392cbf9b9d0dde5060a8c778f
authorMostafa Saleh <smostafa@google.com>
Mon, 15 Jul 2024 08:45:10 +0000 (15 08:45 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 18 Jul 2024 12:49:29 +0000 (18 13:49 +0100)
treeeafb11691c7e35a20e88efc82bfda6c747adf915
parent7eb57be1efb8cdcf613fd8b089295ed5a4f48d7d
hw/arm/smmu-common: Add support for nested TLB

This patch adds support for nested (combined) TLB entries.
The main function combine_tlb() is not used here but in the next
patches, but to simplify the patches it is introduced first.

Main changes:
1) New field added in the SMMUTLBEntry struct: parent_perm, for
   nested TLB, holds the stage-2 permission, this can be used to know
   the origin of a permission fault from a cached entry as caching
   the “and” of the permissions loses this information.

   SMMUPTWEventInfo is used to hold information about PTW faults so
   the event can be populated, the value of stage used to be set
   based on the current stage for TLB permission faults, however
   with the parent_perm, it is now set based on which perm has
   the missing permission

   When nesting is not enabled it has the same value as perm which
   doesn't change the logic.

2) As combined TLB implementation is used, the combination logic
   chooses:
   - tg and level from the entry which has the smallest addr_mask.
   - Based on that the iova that would be cached is recalculated.
   - Translated_addr is chosen from stage-2.

Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Signed-off-by: Mostafa Saleh <smostafa@google.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 20240715084519.1189624-11-smostafa@google.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
hw/arm/smmu-common.c
include/hw/arm/smmu-common.h