qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Ethan MILON" <ethan.milon@eviden.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [PATCH v3 0/7] amd_iommu: Fixes to align with AMDVi specification
Date: Mon, 16 Jun 2025 18:54:09 -0400	[thread overview]
Message-ID: <f5a8e3b0-a7e5-487a-82c4-d54d565a657e@oracle.com> (raw)
In-Reply-To: <eba82f72-fd87-4f47-b5a9-86dbccb6b90a@linaro.org>

Hi Phil,

On 6/16/25 2:59 AM, Philippe Mathieu-Daudé wrote:
> Hi Alejandro,
> 
> On 12/6/25 22:59, Alejandro Jimenez wrote:
>> Hi Ethan,
>>
>> On 6/12/25 4:36 AM, Ethan MILON wrote:
>>> Hi,
>>>
>>> Is this series the right place to include the following minor fix?
>>>
>>
>> I would defer this change for two reasons:
>>
>> 1) This series has been reviewed and tested already. I was hoping it 
>> would be included on the Jun 1st pull but I sent v3 too late for that. 
>> I think it is ready so I would like to leave it as is unless there are 
>> any objections ...
>>
>>
>>> diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
>>> index 0775c..18d30e1 100644
>>> --- a/hw/i386/amd_iommu.c
>>> +++ b/hw/i386/amd_iommu.c
>>> @@ -140,7 +140,7 @@ static void amdvi_writeq(AMDVIState *s, hwaddr addr,
>>> uint64_t val)
>>>   {
>>>       uint64_t romask = ldq_le_p(&s->romask[addr]);
>>>       uint64_t w1cmask = ldq_le_p(&s->w1cmask[addr]);
>>> -    uint32_t oldval = ldq_le_p(&s->mmior[addr]);
>>> +    uint64_t oldval = ldq_le_p(&s->mmior[addr]);
>>>       stq_le_p(&s->mmior[addr],
>>>               ((oldval & romask) | (val & ~romask)) & ~(val & w1cmask));
>>>   }
>>>
>>> This corrects the type of oldval to match the return type of ldq_le_p().
>>>
>>
>> 2) This fix is needed, but it is likely better as part of additional 
>> changes that are needed to cleanup/fix the XTSup support. i.e. there 
>> are unhandled writes to the 0x170, 0x178, and 0x180 MMIO offsets, and 
>> those depend on MMIO 0x18[IntCapXTEn]=1. I think the truncation of 
>> oldval that you found is causing XTEn and IntCapXTEn bits on the 
>> control registers to be ignored, but ultimately things are not broken 
>> enough (yet).
> 
> I agree with Ethan it is better to avoid hidden truncation, because it
> just makes debugging experience harder.
> 

I agree that Ethan found a bug that must be fixed. I am answering his 
initial question of whether this series is the right place to fix it by 
pointing out that this bug uncovers that there is more to do than just 
fixing this specific error, and it could be included in a series to 
address those larger problems that I mentioned above.

On the other hand, it is probably better just to fix this specific bug 
now since it is simple enough, which is why I asked Ethan to send a 
commit and I will add it (he should get credit)

> If this is the expected behavior, better add a comment, or use
> extract64() which makes the truncation explicit.
> 

It is not the expected behavior, the truncation is a bug. It doesn't yet 
cause any issues because amdvi_writeq() is currently only called to 
handle MMIO writes for a few offsets/register, mostly to 
AMDVI_MMIO_CONTROL, and the romask for the offset is 0. This means that 
the bug doesn't really change the value that is ultimately written to 
the emulated MMIO register, but it could cause problems in the future.

Thank you,
Alejandro


> Regards,
> 
> Phil.
> 
>> In other words, I think there is a lot more work to do in here, and it 
>> is something I am looking into.
>>
>> I suspect Vasant might have spotted this problem already, so he might 
>> even have some fixes queued up...
>>
>> That being said, if you want to send a patch with your S-b I'll add it 
>> to this series.
>>
>> Alejandro
>>
>>> Thanks,
>>> Ethan
>>>
>>> On 5/29/25 9:30 PM, Alejandro Jimenez wrote:
>>>> Caution: External email. Do not open attachments or click links, 
>>>> unless this email comes from a known sender and you know the content 
>>>> is safe.
>>>>
>>>>
>>>> The main reason for sending this new revision so soon is that v2 
>>>> included a
>>>> duplicated [PATCH 5/7]. I fixed a typo in the commit subject and missed
>>>> removing the old patch. Apologies for the mistake.
>>>>
>>>> Additional changes in v3:
>>>> - Fixed typo on [PATCH 1/7] subject line (s/Miscellanous/ 
>>>> Miscellaneous/).
>>>> - Added 'Fixes:' tag to [PATCH 5/7].
>>>> - Added Vasant's R-b to patches 4,5,7.
>>>>
>>>> Thank you,
>>>> Alejandro
>>>>
>>>> v2:
>>>> https://lore.kernel.org/qemu-devel/20250528221725.3554040-1- 
>>>> alejandro.j.jimenez@oracle.com/
>>>>
>>>> v1:
>>>> https://lore.kernel.org/all/20250311152446.45086-1- 
>>>> alejandro.j.jimenez@oracle.com/
>>>>
>>>>
>>>> Alejandro Jimenez (7):
>>>>    amd_iommu: Fix Miscellaneous Information Register 0 offsets
>>>>    amd_iommu: Fix Device ID decoding for INVALIDATE_IOTLB_PAGES command
>>>>    amd_iommu: Update bitmasks representing DTE reserved fields
>>>>    amd_iommu: Fix masks for various IOMMU MMIO Registers
>>>>    amd_iommu: Fix mask to retrieve Interrupt Table Root Pointer from 
>>>> DTE
>>>>    amd_iommu: Fix the calculation for Device Table size
>>>>    amd_iommu: Remove duplicated definitions
>>>>
>>>>   hw/i386/amd_iommu.c | 15 ++++++------
>>>>   hw/i386/amd_iommu.h | 59 +++++++++++++++++++++ 
>>>> +-----------------------
>>>>   2 files changed, 37 insertions(+), 37 deletions(-)
>>>>
>>>>
>>>> base-commit: 80db93b2b88f9b3ed8927ae7ac74ca30e643a83e
>>>> -- 
>>>> 2.43.5
>>>>
>>>>
>>
>>
> 



      reply	other threads:[~2025-06-16 22:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-29 19:30 [PATCH v3 0/7] amd_iommu: Fixes to align with AMDVi specification Alejandro Jimenez
2025-05-29 19:30 ` [PATCH v3 1/7] amd_iommu: Fix Miscellaneous Information Register 0 offsets Alejandro Jimenez
2025-05-29 19:30 ` [PATCH v3 2/7] amd_iommu: Fix Device ID decoding for INVALIDATE_IOTLB_PAGES command Alejandro Jimenez
2025-05-29 19:30 ` [PATCH v3 3/7] amd_iommu: Update bitmasks representing DTE reserved fields Alejandro Jimenez
2025-05-29 19:30 ` [PATCH v3 4/7] amd_iommu: Fix masks for various IOMMU MMIO Registers Alejandro Jimenez
2025-05-29 19:30 ` [PATCH v3 5/7] amd_iommu: Fix mask to retrieve Interrupt Table Root Pointer from DTE Alejandro Jimenez
2025-05-29 19:30 ` [PATCH v3 6/7] amd_iommu: Fix the calculation for Device Table size Alejandro Jimenez
2025-05-29 19:30 ` [PATCH v3 7/7] amd_iommu: Remove duplicated definitions Alejandro Jimenez
2025-06-12  8:36 ` [PATCH v3 0/7] amd_iommu: Fixes to align with AMDVi specification Ethan MILON
2025-06-12 20:59   ` Alejandro Jimenez
2025-06-16  6:59     ` Philippe Mathieu-Daudé
2025-06-16 22:54       ` Alejandro Jimenez [this message]

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=f5a8e3b0-a7e5-487a-82c4-d54d565a657e@oracle.com \
    --to=alejandro.j.jimenez@oracle.com \
    --cc=ethan.milon@eviden.com \
    --cc=philmd@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).