From: "Arun Kodilkar, Sairaj" <sarunkod@amd.com>
To: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>,
<qemu-devel@nongnu.org>
Cc: <pbonzini@redhat.com>, <mst@redhat.com>, <mjt@tls.msk.ru>,
<marcel.apfelbaum@gmail.com>, <vasant.hegde@amd.com>,
<suravee.suthikulpanit@amd.com>, <santosh.shukla@amd.com>,
<Wei.Huang2@amd.com>, <joao.m.martins@oracle.com>,
<boris.ostrovsky@oracle.com>
Subject: Re: [PATCH 3/6] amd_iommu: Update bitmasks representing DTE reserved fields
Date: Sun, 16 Mar 2025 15:04:12 +0530 [thread overview]
Message-ID: <a6a1b0d3-7ab4-426a-a8ee-8934dedb9ae0@amd.com> (raw)
In-Reply-To: <0e4993c5-33d8-4dfc-8089-0efa50881f8e@oracle.com>
On 3/13/2025 7:53 PM, Alejandro Jimenez wrote:
>
>
> On 3/12/25 12:12 AM, Arun Kodilkar, Sairaj wrote:
>> Hi Alejandro,
>>
>> On 3/11/2025 8:54 PM, Alejandro Jimenez wrote:
>
> [...]
>
>>> --- a/hw/i386/amd_iommu.h
>>> +++ b/hw/i386/amd_iommu.h
>>> @@ -25,6 +25,8 @@
>>> #include "hw/i386/x86-iommu.h"
>>> #include "qom/object.h"
>>> +#define GENMASK64(h, l) (((~0ULL) >> (63 - (h) + (l))) << (l))
>>> +
>>
>> qemu provides the similar macro 'MAKE_64BIT_MASK' in file
>> 'include/qemu/bitops.h', you can use this existing macro
>> instead of redefining.
>
> Hi Sairaj,
>
> I became aware of MAKE_64BIT_MASK() because you used it in your recent
> patch, but as you mentioned they are similar but not the same. I
> personally find that using bit indexes is less prone to errors since
> that is the same format the spec uses to define the fields.
> So translating a RSVD[6:2] field from the spec becomes:
>
> GENMASK64(6, 2);
> vs
> MAKE_64BIT_MASK(6, 5);
>
> The latter is more prone to off-by-one errors in my opinion, specially
> when you are defining lots of masks. Perhaps more importantly, I'd like
> to progressively convert the amd_iommu definitions to use GENMASK() and
> the code that retrieves bit fields to use FIELD_GET().
>
> I am planning on later porting the generic GENMASK* definitions (from
> the kernel into "qemu/bitops.h", since the RISC-V IOMMU is also a
> consumer of GENMASK, but I am trying to keep the focus on the AMD vIOMMU
> for this series.
>
> Thank you,
> Alejandro
>
Hi Alejandro,
Yes indeed, GENMASK64() is more readable than the MAKE_64BIT_MASK().
and Since you are going to port it to generic layer, its better
to use GENMASK64().
Feel free to replace existing MAKE_64BIT_MASK() in my recent patches.
otherwise, I can modify it during next patch series.
Regards
Sairaj Kodilkar
>>
>>> /* Capability registers */
>>> #define AMDVI_CAPAB_BAR_LOW 0x04
>>> #define AMDVI_CAPAB_BAR_HIGH 0x08
>>> @@ -162,9 +164,10 @@
>>> #define AMDVI_FEATURE_PC (1ULL << 9) /* Perf
>>> counters */
>>> /* reserved DTE bits */
>>> -#define AMDVI_DTE_LOWER_QUAD_RESERVED 0x80300000000000fc
>>> -#define AMDVI_DTE_MIDDLE_QUAD_RESERVED 0x0000000000000100
>>> -#define AMDVI_DTE_UPPER_QUAD_RESERVED 0x08f0000000000000
>>> +#define AMDVI_DTE_QUAD0_RESERVED (GENMASK64(6, 2) |
>>> GENMASK64(63, 63))
>>> +#define AMDVI_DTE_QUAD1_RESERVED 0
>>> +#define AMDVI_DTE_QUAD2_RESERVED GENMASK64(53, 52)
>>> +#define AMDVI_DTE_QUAD3_RESERVED (GENMASK64(14, 0) |
>>> GENMASK64(53, 48))
>>> /* AMDVI paging mode */
>>> #define AMDVI_GATS_MODE (2ULL << 12)
>>
>> Regards
>> Sairaj Kodilkar
>
next prev parent reply other threads:[~2025-03-16 9:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 15:24 [PATCH 0/6] amd_iommu: Fixes to align with AMDVi specification Alejandro Jimenez
2025-03-11 15:24 ` [PATCH 1/6] amd_iommu: Fix Miscellanous Information Register 0 offsets Alejandro Jimenez
2025-03-17 12:37 ` Vasant Hegde
2025-03-11 15:24 ` [PATCH 2/6] amd_iommu: Fix Device ID decoding for INVALIDATE_IOTLB_PAGES command Alejandro Jimenez
2025-03-17 12:40 ` Vasant Hegde
2025-03-11 15:24 ` [PATCH 3/6] amd_iommu: Update bitmasks representing DTE reserved fields Alejandro Jimenez
2025-03-12 4:12 ` Arun Kodilkar, Sairaj
2025-03-13 14:23 ` Alejandro Jimenez
2025-03-16 9:34 ` Arun Kodilkar, Sairaj [this message]
2025-03-17 12:36 ` Vasant Hegde
2025-03-17 12:34 ` Vasant Hegde
2025-03-11 15:24 ` [PATCH 4/6] amd_iommu: Fix masks for Device Table Address Register Alejandro Jimenez
2025-03-12 5:32 ` Arun Kodilkar, Sairaj
2025-03-17 15:07 ` Vasant Hegde
2025-03-11 15:24 ` [PATCH 5/6] amd_iommu: Fix the calculation for Device Table size Alejandro Jimenez
2025-03-17 13:00 ` Vasant Hegde
2025-03-11 15:24 ` [PATCH 6/6] amd_iommu: Do not assume passthrough translation for devices with DTE[TV]=0 Alejandro Jimenez
2025-03-19 6:06 ` Vasant Hegde
2025-03-19 14:10 ` Alejandro Jimenez
2025-03-20 5:11 ` Arun Kodilkar, Sairaj
2025-03-20 16:56 ` Alejandro Jimenez
2025-03-21 8:37 ` Arun Kodilkar, Sairaj
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=a6a1b0d3-7ab4-426a-a8ee-8934dedb9ae0@amd.com \
--to=sarunkod@amd.com \
--cc=Wei.Huang2@amd.com \
--cc=alejandro.j.jimenez@oracle.com \
--cc=boris.ostrovsky@oracle.com \
--cc=joao.m.martins@oracle.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mjt@tls.msk.ru \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=santosh.shukla@amd.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=vasant.hegde@amd.com \
/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.