[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 5/5] amd/iommu: force atomic updates of remapping entries
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Wed, 19 Jul 2023 18:06:28 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=32viBMl9EE/KLt7NqlmidMJwmBBTveQsFg2kp5PX+2g=; b=D4tFVEiq6grkyoOg3SRGZeXgAJz+0MEO/P+vciTw6lfoHYHoWHuQMQ1LVv67F1RrR9II20hdR/gVFGO/Do2cLXJafOfeSCECHw08Sr42pnNsEF8yDTh/tm5GyhxXl8e116zERpswUdjV0F+eIBilfgB0Bc2jq8VoGvtKfeAi0xY6PAxsNPXpG0ZKw9U0Bk4muCsr1yNhqUFHkK9G1/E8NP6pJxCaR+hAuI4X6RtsULLH/hdHcIMZMQDyZgWDoeOD05kMNr3AOtG/X319+2W0B4GZd314lujhhtnck7dLKqmS4goIaOshTNI5TXBw2leTrASHcskSYdpTKHCottjm6w==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i+8SAMUVju0Ti7penZQRQh5E/DZm4Sp40O1Wcine6qk2yv1EF2tp3R0CQr8WskWzJyyWIMbonSDkbUkZNZM3DhRQ7oFhcwpHimgGBexM2gfM6X4jgBNGbeD+QkMtnZrKkxRoMK8n6PHdGKxzSJWMXzAF6xVq7GXnGuLZ3S8p9cShxXjzoOngG/AyrXsvE61DSajtKm4fzgOrvx5Iz8/tytTX0cuGWkj6UzI/X+sE1PugMr/USvdzaKGUbUH7EC5z1V0LYdxl+VI89mnxQd5/JMsMGYOlxdr1rKoiN5WBC6UasQ+sflh5xRVpLcAd4VSHCFLk+NQAaHWOPboMXJOagg==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Wed, 19 Jul 2023 16:06:43 +0000
- Ironport-data: A9a23:Il9uqKpVsnR5XUbYSAxfPmy5S7JeBmIKZBIvgKrLsJaIsI4StFCzt garIBnXP/zbYDGmfNpzaYWz8E8E7cDRnd83S1dv+y5mFC8U8JuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYWYpA1c/Ek/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKq04GpwUmAWP6gR5weBzihNVvrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXAAoLRS+Zp86G+rimDfhvwf58K83kLoxK7xmMzRmBZRonabbqZv2WoPpnhnI3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3j+OraYWNEjCJbZw9ckKwv GXJ8n6/GhgHHNee1SCE4jSngeqncSbTAdtMSubiqKY66LGV7l0QUyUQWX6GmKSSk0GBXskCd xwMyDV7+MDe82TuFLERRSaQonSJoxodUNp4CPAh5UeGza+8yxaUAC0IQyBMbPQitdQqXno62 1mRhdTrCDdz9rqPRhqgGqy8qDqzPW0QMjUEbCpcEQ8duYC8+Mc0kw7FSctlHOitlNrpFDrsw jeM6i8jm7EUis1N3KK+lbzavw+RSlHyZlZdzm3qsqiNtGuVuKbNi1SU1GXm
- Ironport-hdrordr: A9a23:DKSsXaFDA6mG1391pLqEN8eALOsnbusQ8zAXPiFKOGBom6mj/P xG88576faKskd2ZJhNo7y90eq7MArhHOdOkPMs1O6ZLXTbUQiTXf5fBOnZowEIQBeOjtK1vJ 0IG8JD4bvLYmSS5vyW3ODXKbgdKKTuytHSuQ4L9QYOcekXA5sQiDuRcjzrcXGeszM2YabRva Dsg/Z6mw==
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Wed, Jul 19, 2023 at 02:46:49PM +0200, Jan Beulich wrote:
> On 18.07.2023 14:43, Roger Pau Monne wrote:
> > Disable XT (x2APIC) support and thus 128 IRTE entries if cmpxchg16b is
> > not available, do so in order to avoid having to disable the IRTE (and
> > possibly loose interrupts) when updating the entry. Note this also
> > removes the usage of a while loop in order to disable the entry, since
> > RemapEn is no longer toggled when updating.
> >
> > Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> > ---
> > x2APIC support was added late enough on AMD that CPUs that I believe
> > all models that have x2APIC must also have CX16.
> >
> > The AMD-Vi manual contains the following advice in the "2.3.2 Making
> > Guest Interrupt Virtualization Changes" section:
> >
> > """
> > If RemapEn=1 before the change, the following steps may be followed to
> > change interrupt virtualization information:
> > * Set RemapEn=0 in the entry to disable interrupt virtualization;
> > device-initiated interrupt requests for the DeviceID and vector are
> > processed as IO_PAGE_FAULT events.
> > * Update the fields in the IRTE and invalidate the interrupt table
> > (see Section 2.4.5 [INVALIDATE_INTERRUPT_TABLE]).
> > * Set RemapEn=1 to virtualize interrupts from the device.
> > """
> >
> > However if the update of the IRTE is done atomically I assume that
> > setting RemapEn=0 is not longer necessary, and that the
> > INVALIDATE_INTERRUPT_TABLE command can be executed after the entry has
> > been (atomically) updated.
>
> There's one additional prereq to this: The IOMMU also needs to read
> 128-bit IRTEs atomically. I'm afraid we can't take this for given
> without it being said explicitly in the spec (I've just gone through
> and looked at all occurrences of "atomic", without finding anything
> applicable to IRTEs). If this can be resolved, I think I'm fine with
> the patch.
Hm, indeed I was taking for granted that the IOMMU will read the entry
atomically.
I was also worried about the IOMMU caching only parts of the IRTE, and
thus even when doing an atomic read of the full entry it could still
get inconsistent data if using previously cached parts of the entry.
The text in INVALIDATE_INTERRUPT_TABLE seems to suggest that IRTE
fields could be cached on a field by field basis.
I will raise a question with AMD in order to try to figure out whether
the IOMMU will do atomic reads, and also cache the full entry.
Thanks, Roger.
|