Commit 42ca4c7d authored by Suravee Suthikulpanit's avatar Suravee Suthikulpanit Committed by Guo Mengqi
Browse files

iommu/amd: Use cmpxchg_double() when updating 128-bit IRTE

mainline inclusion
from mainline-v5.9-rc4
commit e52d58d5
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7R8MI
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e52d58d54a321d4fe9d0ecdabe4f8774449f0d6e

--------------------------------

mainline inclusion
from mainline-v5.9-rc4
commit e52d58d5
category: bugfix
bugzilla: 189075
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e52d58d54a321d4fe9d0ecdabe4f8774449f0d6e



--------------------------------

When using 128-bit interrupt-remapping table entry (IRTE) (a.k.a GA mode),
current driver disables interrupt remapping when it updates the IRTE
so that the upper and lower 64-bit values can be updated safely.

However, this creates a small window, where the interrupt could
arrive and result in IO_PAGE_FAULT (for interrupt) as shown below.

  IOMMU Driver            Device IRQ
  ============            ===========
  irte.RemapEn=0
       ...
   change IRTE            IRQ from device ==> IO_PAGE_FAULT !!
       ...
  irte.RemapEn=1

This scenario has been observed when changing irq affinity on a system
running I/O-intensive workload, in which the destination APIC ID
in the IRTE is updated.

Instead, use cmpxchg_double() to update the 128-bit IRTE at once without
disabling the interrupt remapping. However, this means several features,
which require GA (128-bit IRTE) support will also be affected if cmpxchg16b
is not supported (which is unprecedented for AMD processors w/ IOMMU).

Fixes: 880ac60e ("iommu/amd: Introduce interrupt remapping ops structure")
Reported-by: default avatarSean Osborne <sean.m.osborne@oracle.com>
Signed-off-by: default avatarSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Tested-by: default avatarErik Rockstrom <erik.rockstrom@oracle.com>
Reviewed-by: default avatarJoao Martins <joao.m.martins@oracle.com>
Link: https://lore.kernel.org/r/20200903093822.52012-3-suravee.suthikulpanit@amd.com


Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
Signed-off-by: default avatarGuo Mengqi <guomengqi3@huawei.com>
parent 111c6eca
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment