[RFC v4 11/31] hw/arm/smmu: Add PTE NS/NSTable helpers

Tao Tang posted 31 patches 1 month, 2 weeks ago
Maintainers: Eric Auger <eric.auger@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
[RFC v4 11/31] hw/arm/smmu: Add PTE NS/NSTable helpers
Posted by Tao Tang 1 month, 2 weeks ago
Add helper macros for NS and NSTable bits and group PTE attribute
accessors for clarity. No functional change beyond the new helpers.

Signed-off-by: Tao Tang <tangtao1634@phytium.com.cn>
---
 hw/arm/smmu-internal.h | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h
index d143d296f34..a0454f720da 100644
--- a/hw/arm/smmu-internal.h
+++ b/hw/arm/smmu-internal.h
@@ -58,16 +58,28 @@
     ((level == 3) &&                                                    \
      ((pte & ARM_LPAE_PTE_TYPE_MASK) == ARM_LPAE_L3_PTE_TYPE_PAGE))
 
+/* Block & page descriptor attributes */
+/* Non-secure bit */
+#define PTE_NS(pte) \
+    (extract64(pte, 5, 1))
+
 /* access permissions */
 
 #define PTE_AP(pte) \
     (extract64(pte, 6, 2))
 
+/* access flag */
+#define PTE_AF(pte) \
+    (extract64(pte, 10, 1))
+
+
+/* Table descriptor attributes */
 #define PTE_APTABLE(pte) \
     (extract64(pte, 61, 2))
 
-#define PTE_AF(pte) \
-    (extract64(pte, 10, 1))
+#define PTE_NSTABLE(pte) \
+    (extract64(pte, 63, 1))
+
 /*
  * TODO: At the moment all transactions are considered as privileged (EL1)
  * as IOMMU translation callback does not pass user/priv attributes.
-- 
2.34.1
Re: [RFC v4 11/31] hw/arm/smmu: Add PTE NS/NSTable helpers
Posted by Eric Auger 1 month, 1 week ago

On 2/21/26 11:15 AM, Tao Tang wrote:
> Add helper macros for NS and NSTable bits and group PTE attribute
> accessors for clarity. No functional change beyond the new helpers.
>
> Signed-off-by: Tao Tang <tangtao1634@phytium.com.cn>
> ---
>  hw/arm/smmu-internal.h | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h
> index d143d296f34..a0454f720da 100644
> --- a/hw/arm/smmu-internal.h
> +++ b/hw/arm/smmu-internal.h
> @@ -58,16 +58,28 @@
>      ((level == 3) &&                                                    \
>       ((pte & ARM_LPAE_PTE_TYPE_MASK) == ARM_LPAE_L3_PTE_TYPE_PAGE))
>  
> +/* Block & page descriptor attributes */
Maybe use the spec terminology:
Stage 1 attribute fields in VMSAv8-64 Block and Page descriptors
vs 7 Stage 1 VMSAv8-64 Table descriptor fields

By the way AF belongs to both

> +/* Non-secure bit */
> +#define PTE_NS(pte) \
> +    (extract64(pte, 5, 1))
> +
>  /* access permissions */
>  
>  #define PTE_AP(pte) \
>      (extract64(pte, 6, 2))
>  
> +/* access flag */
> +#define PTE_AF(pte) \
> +    (extract64(pte, 10, 1))
> +
> +
> +/* Table descriptor attributes */
>  #define PTE_APTABLE(pte) \
>      (extract64(pte, 61, 2))
>  
> -#define PTE_AF(pte) \
> -    (extract64(pte, 10, 1))
> +#define PTE_NSTABLE(pte) \
> +    (extract64(pte, 63, 1))
> +
>  /*
>   * TODO: At the moment all transactions are considered as privileged (EL1)
>   * as IOMMU translation callback does not pass user/priv attributes.
Eric
Re: [RFC v4 11/31] hw/arm/smmu: Add PTE NS/NSTable helpers
Posted by Tao Tang 1 month, 1 week ago
Hi Eric,

On 2026/3/3 01:07, Eric Auger wrote:
>
> On 2/21/26 11:15 AM, Tao Tang wrote:
>> Add helper macros for NS and NSTable bits and group PTE attribute
>> accessors for clarity. No functional change beyond the new helpers.
>>
>> Signed-off-by: Tao Tang <tangtao1634@phytium.com.cn>
>> ---
>>   hw/arm/smmu-internal.h | 16 ++++++++++++++--
>>   1 file changed, 14 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h
>> index d143d296f34..a0454f720da 100644
>> --- a/hw/arm/smmu-internal.h
>> +++ b/hw/arm/smmu-internal.h
>> @@ -58,16 +58,28 @@
>>       ((level == 3) &&                                                    \
>>        ((pte & ARM_LPAE_PTE_TYPE_MASK) == ARM_LPAE_L3_PTE_TYPE_PAGE))
>>   
>> +/* Block & page descriptor attributes */
> Maybe use the spec terminology:
> Stage 1 attribute fields in VMSAv8-64 Block and Page descriptors
> vs 7 Stage 1 VMSAv8-64 Table descriptor fields
>
> By the way AF belongs to both



I’ll rework the comments to use the spec terminology and avoid grouping 
AF too narrowly under Block/Page wording.


Best regards,

Tao

>
>> +/* Non-secure bit */
>> +#define PTE_NS(pte) \
>> +    (extract64(pte, 5, 1))
>> +
>>   /* access permissions */
>>   
>>   #define PTE_AP(pte) \
>>       (extract64(pte, 6, 2))
>>   
>> +/* access flag */
>> +#define PTE_AF(pte) \
>> +    (extract64(pte, 10, 1))
>> +
>> +
>> +/* Table descriptor attributes */
>>   #define PTE_APTABLE(pte) \
>>       (extract64(pte, 61, 2))
>>   
>> -#define PTE_AF(pte) \
>> -    (extract64(pte, 10, 1))
>> +#define PTE_NSTABLE(pte) \
>> +    (extract64(pte, 63, 1))
>> +
>>   /*
>>    * TODO: At the moment all transactions are considered as privileged (EL1)
>>    * as IOMMU translation callback does not pass user/priv attributes.
> Eric


Re: [RFC v4 11/31] hw/arm/smmu: Add PTE NS/NSTable helpers
Posted by Pierrick Bouvier 1 month, 2 weeks ago
On 2/21/26 2:15 AM, Tao Tang wrote:
> Add helper macros for NS and NSTable bits and group PTE attribute
> accessors for clarity. No functional change beyond the new helpers.
> 
> Signed-off-by: Tao Tang <tangtao1634@phytium.com.cn>
> ---
>   hw/arm/smmu-internal.h | 16 ++++++++++++++--
>   1 file changed, 14 insertions(+), 2 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>