2017-06-23 11:57:17

by Suthikulpanit, Suravee

[permalink] [raw]
Subject: [PATCH] iommu/amd: Fix interrupt remapping when disable guest_mode

Pass-through devices to VM guest can get updated affinity
information via irq_set_affinity(). Currently, AMD IOMMU driver
in GA mode ignores the updated information if the pass-through
device is setup to use vAPIC, which could cause invalid interrupt
remapping when not running in guest_mode.

Also, the guest_mode bit should be set and cleared only when
SVM updates posted-interrupt information via irq_set_vcpu_affinity().

Signed-off-by: Suravee Suthikulpanit <[email protected]>
Cc: Joerg Roedel <[email protected]>
---
drivers/iommu/amd_iommu.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index b17536d6..1055863 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -3883,7 +3883,6 @@ static void irte_ga_prepare(void *entry,

irte->lo.val = 0;
irte->hi.val = 0;
- irte->lo.fields_remap.guest_mode = dev_data ? dev_data->use_vapic : 0;
irte->lo.fields_remap.int_type = delivery_mode;
irte->lo.fields_remap.dm = dest_mode;
irte->hi.fields.vector = vector;
@@ -3939,10 +3938,10 @@ static void irte_ga_set_affinity(void *entry, u16 devid, u16 index,
struct irte_ga *irte = (struct irte_ga *) entry;
struct iommu_dev_data *dev_data = search_dev_data(devid);

- if (!dev_data || !dev_data->use_vapic) {
+ if (!dev_data || !dev_data->use_vapic ||
+ !irte->lo.fields_remap.guest_mode) {
irte->hi.fields.vector = vector;
irte->lo.fields_remap.destination = dest_apicid;
- irte->lo.fields_remap.guest_mode = 0;
modify_irte_ga(devid, index, irte, NULL);
}
}
--
1.8.3.1


2017-06-24 16:44:54

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] iommu/amd: Fix interrupt remapping when disable guest_mode

Hi Suravee,

[auto build test WARNING on iommu/next]
[also build test WARNING on v4.12-rc6 next-20170623]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Suravee-Suthikulpanit/iommu-amd-Fix-interrupt-remapping-when-disable-guest_mode/20170624-162701
base: https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git next
config: x86_64-randconfig-b0-06242320 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

All warnings (new ones prefixed by >>):

drivers/iommu/amd_iommu.c: In function 'irte_ga_prepare':
>> drivers/iommu/amd_iommu.c:4002: warning: unused variable 'dev_data'

vim +/dev_data +4002 drivers/iommu/amd_iommu.c

880ac60e Suravee Suthikulpanit 2016-08-23 3986 {
880ac60e Suravee Suthikulpanit 2016-08-23 3987 union irte *irte = (union irte *) entry;
880ac60e Suravee Suthikulpanit 2016-08-23 3988
880ac60e Suravee Suthikulpanit 2016-08-23 3989 irte->val = 0;
880ac60e Suravee Suthikulpanit 2016-08-23 3990 irte->fields.vector = vector;
880ac60e Suravee Suthikulpanit 2016-08-23 3991 irte->fields.int_type = delivery_mode;
880ac60e Suravee Suthikulpanit 2016-08-23 3992 irte->fields.destination = dest_apicid;
880ac60e Suravee Suthikulpanit 2016-08-23 3993 irte->fields.dm = dest_mode;
880ac60e Suravee Suthikulpanit 2016-08-23 3994 irte->fields.valid = 1;
880ac60e Suravee Suthikulpanit 2016-08-23 3995 }
880ac60e Suravee Suthikulpanit 2016-08-23 3996
880ac60e Suravee Suthikulpanit 2016-08-23 3997 static void irte_ga_prepare(void *entry,
880ac60e Suravee Suthikulpanit 2016-08-23 3998 u32 delivery_mode, u32 dest_mode,
d98de49a Suravee Suthikulpanit 2016-08-23 3999 u8 vector, u32 dest_apicid, int devid)
880ac60e Suravee Suthikulpanit 2016-08-23 4000 {
880ac60e Suravee Suthikulpanit 2016-08-23 4001 struct irte_ga *irte = (struct irte_ga *) entry;
d98de49a Suravee Suthikulpanit 2016-08-23 @4002 struct iommu_dev_data *dev_data = search_dev_data(devid);
880ac60e Suravee Suthikulpanit 2016-08-23 4003
880ac60e Suravee Suthikulpanit 2016-08-23 4004 irte->lo.val = 0;
880ac60e Suravee Suthikulpanit 2016-08-23 4005 irte->hi.val = 0;
880ac60e Suravee Suthikulpanit 2016-08-23 4006 irte->lo.fields_remap.int_type = delivery_mode;
880ac60e Suravee Suthikulpanit 2016-08-23 4007 irte->lo.fields_remap.dm = dest_mode;
880ac60e Suravee Suthikulpanit 2016-08-23 4008 irte->hi.fields.vector = vector;
880ac60e Suravee Suthikulpanit 2016-08-23 4009 irte->lo.fields_remap.destination = dest_apicid;
880ac60e Suravee Suthikulpanit 2016-08-23 4010 irte->lo.fields_remap.valid = 1;

:::::: The code at line 4002 was first introduced by commit
:::::: d98de49a53e48f51332e97568127e722415e1232 iommu/amd: Enable vAPIC interrupt remapping mode by default

:::::: TO: Suravee Suthikulpanit <[email protected]>
:::::: CC: Joerg Roedel <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (3.25 kB)
.config.gz (20.86 kB)
Download all attachments