From patchwork Wed Jul 13 13:20:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 71921 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1009804qga; Wed, 13 Jul 2016 06:37:24 -0700 (PDT) X-Received: by 10.37.85.139 with SMTP id j133mr5438605ybb.32.1468417037478; Wed, 13 Jul 2016 06:37:17 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e62si1258106ybf.15.2016.07.13.06.37.16; Wed, 13 Jul 2016 06:37:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752686AbcGMNfs (ORCPT + 30 others); Wed, 13 Jul 2016 09:35:48 -0400 Received: from mail-bl2nam02on0059.outbound.protection.outlook.com ([104.47.38.59]:58585 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752596AbcGMNfi (ORCPT ); Wed, 13 Jul 2016 09:35:38 -0400 X-Greylist: delayed 869 seconds by postgrey-1.27 at vger.kernel.org; Wed, 13 Jul 2016 09:35:33 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/Wi1V53zmSSD3wkk9NhFeC+3DvxpBkM7lbFfaDgBnNM=; b=v5RmtSfTuYkaBz2c64q+j5M4nyy1F3xUVqv/dFOJQ9JmNvATnhSLnA/zq+jbZ+Q9UTKAYXkf7SmrFakBmDzLFxdyHBGj7E2NPWS/nGJWufE4puS1hQobuNuCbclrmjbc2ZZM4Hk/EsUmKW8Hqvxpo2CfqsixEYa/PyN+lEZdSfQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; Received: from localhost.localdomain (114.109.128.54) by SN1PR12MB0445.namprd12.prod.outlook.com (10.162.105.139) with Microsoft SMTP Server (TLS) id 15.1.534.14; Wed, 13 Jul 2016 13:21:01 +0000 From: Suravee Suthikulpanit To: , , , CC: , , , Suravee Suthikulpanit Subject: [PART2 PATCH v4 01/11] iommu/amd: Detect and enable guest vAPIC support Date: Wed, 13 Jul 2016 08:20:22 -0500 Message-ID: <1468416032-7692-2-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468416032-7692-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1468416032-7692-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [114.109.128.54] X-ClientProxiedBy: SIXPR04CA0024.apcprd04.prod.outlook.com (10.162.171.14) To SN1PR12MB0445.namprd12.prod.outlook.com (10.162.105.139) X-MS-Office365-Filtering-Correlation-Id: 05c2f7ff-6c4d-4c9c-9fc8-08d3ab208a92 X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0445; 2:lwn9VWHYnDHtci50b3h9qkfL9j5uAy9zCOYuxDDQTq8i2ZXZhXg08QV/TX8H1hpg6tpZIsJ7fGSPv1ekcSZskPVh/F0iUDPO7Y1mcHyR16dLW2FE9dv9a2Yt8EcP0keOQ5/2knTW6hokfC1fTL8jRhpIuNzHwwKDh8YDfaTmOZSVQxi7Rz8AzUbfzp8T2X5D; 3:E4wtPDHRs/FHRJN7HwC0xopcqVgAB0WYOBQPqSFEdFz4oOalsIv4+BJZCMxWRLqb1RN9lJB9u0OQgjtRQBEKzQNTiDl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WK2O7IRTBqgmQMz3IlcZtuIJDdjLwrXyk627M8GYAMyj13i0LetPEJ1fe0vwSjl6an14ndZSBZiXm+9W8rKhWQDWVesnY5RtR2/6zuIztf0o0zlnRmwWccAfbp9Hbp1WRsVSQRFbZF63sBeJXxMaFaEB05wT86rm3K/QKTxc0UhUXEin8K2BGrHXn4b2w3S0/Rb7o8TG0F2Q5giF7jLAqNPaewb4t9mI3a1C8MD X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(211171220733660); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:SN1PR12MB0445; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0445; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0445; 4:7gs3vfLs6In04N5yeXMD55eROUX59ECSZACRXHBkqaUNnRukCYDu8fkadMgBZj0SThD0YMmGGSPsJznR7iWVFTIjeotjRm69lDLcEew3R8iOKo9X5fFLwc9khyq3IZVTaM9kOAuXhe0zpvlPnAvrSwX8oKMY11k3W8NZx0ANH0AtH1f4nh0iPfyYsfJ2basycMc6d9OCN5n+xJ7AxeNvnsOm9xkAjWPmg4/017V1c/vXkk568nEzoEjPq8GJsc61/sobwZldInYO/B8GahqQ722IVALvoywf1k/zYRjJyj9a0oxuQk34u62YR/SLeJ237aSvEHmWSupcFEGJIf7F3u4iE8v4GNp5WIHCE70snpliMg3nMFt3Cb/7s4yyJo7QsFyKsp6JTKjb6qJmM1RewOxkAhIGd6Rqixfu51gtYYc7Ua9tJn39MfQdqpGAPKdrjyvUAxPfm5COBHMT/JQWoQ== X-Forefront-PRVS: 000227DA0C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(189002)(199003)(229853001)(101416001)(77096005)(8676002)(6116002)(2950100001)(42186005)(586003)(81156014)(81166006)(2201001)(3846002)(50986999)(4326007)(76176999)(50466002)(36756003)(5003940100001)(68736007)(105586002)(305945005)(47776003)(66066001)(575784001)(86362001)(7846002)(50226002)(2906002)(48376002)(92566002)(106356001)(19580405001)(7736002)(33646002)(97736004)(189998001)(5001770100001)(19580395003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0445; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB0445; 23:px/MwSKt+x0YI0QFQ+y2jwyCfO5rcwmctYnZcRQua?= =?us-ascii?Q?afCoClJdIE2AOnu5cCdoeqlt1eKTq8RUhrNm7PgGUuq+66AiBJGwJaIC+wev?= =?us-ascii?Q?qjwZS92oHFn3EkGrkPP3R6/w2zKcRd0VyV/gHpAK4rdL8lO5jZjUQTGgUoN2?= =?us-ascii?Q?biFsKw1AblY0nIqpDmA2hjukDX2+CNDF0Ug7E3LSttr2ecxxzbevAelBPdBr?= =?us-ascii?Q?vlroseL8eETx1Pr6nY3NtWDjZfdjtlimwHaVWyhJTfL93xH5BnqVXxt6mcmk?= =?us-ascii?Q?Lgc0La7+ZJDQIaHOt5MNY9b99/zrLml726BspmL22PIpPyM2mmLknQmzbLtF?= =?us-ascii?Q?HK/CzUHNTTtpX4YmR99BkWhcHMyN9GrkO1zik19dAwTDJnHT+SFqom7wfeDP?= =?us-ascii?Q?Dumit5yrAg4dcepAYv3nNo/1cGtfEATw3WN/XXk+hxA7EEtBTbUPFWe/HPPU?= =?us-ascii?Q?a1MANxoU/MoLUYPIGbMC5xbnai8Jx7Nfo+if4MuBbbJOq9tonm9RL0aYL9c6?= =?us-ascii?Q?A2CLRWTFIpdQANMClgML8i4/+hwBUV8OnF8txX4f2qIsbUJQeu6jLF9YrbmF?= =?us-ascii?Q?xU4CSfRtAy81UFOZU5eDF7e87KXkTugUxUxAw7ggJswDMr8Ch8e3nHUQCw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DRE8uIklAvRUmrktrO0k13uSksxjwQVaJQp4L0h3pxEIWoK7SX0bUtGjdtu8xE03NoMbHYkxw==; 24:LaCZhiMAOsqfV2oJNnqXPkpG3gZBaHY73bCea6mqG5GnRdcKl1N2FR3ajmh+03YjWstU0qFvR934AixKd9bq/ie0V1+hWXgJbA6n6TePLOk=; 7:MonlJ81mck/8Qpm4V5WHBQOXBtK/1Xq/4N51sCCvH4GQOBwowGJeklMr2OVN9pp2zKufpuOceW7bGIcU8Ezh01Gk4YiVA91Omvt77AxmHokNhfaxLYl4E4y+96zM7/wSuJCje653tvZ36PzJnilv1EyJknG8Vge2NVM8XlInWgKVVmgNKFRvdcLHP0lKn99kQNPMhs20UU0Fgt2fnLDmY5v7G0dorP2OB6FJGpkC0hvCECdiso0f1xkbELWoImfN SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0445; 20:LKi5ajKVWFT6Wjcx/FFcGJ7JGVAK1ehVJBkeDclkdygSE8Cg3kRMly0cBW4/C2s2DMXqr31jCwWqV5QVl0FFRppz6aRog0RrT4PcN3yLXJb9V3u0O5GjiU3+duHGU091rZVxJdgVhP0jA5SUV0EkdEhecxCmB5+EC6+yHqWme82pnKPRq4sXLpx+pMFnYGyZABD3mY4UZDP+dR1bBQyfAqax1FV4QyzUyEwmYggljFEmzPCaQihBUP0mCHhGj8zT X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2016 13:21:01.6347 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0445 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suravee Suthikulpanit This patch introduces a new IOMMU driver parameter, amd_iommu_guest_ir, which can be used to specify different interrupt remapping mode for passthrough devices to VM guest: * legacy: Legacy interrupt remapping (w/ 32-bit IRTE) * vapic : Guest vAPIC interrupt remapping (w/ GA mode 128-bit IRTE) Note that in vapic mode, it can also supports legacy interrupt remapping for non-passthrough devices with the 128-bit IRTE. Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd_iommu_init.c | 73 +++++++++++++++++++++++++++++++++++++---- drivers/iommu/amd_iommu_proto.h | 1 + drivers/iommu/amd_iommu_types.h | 24 ++++++++++++++ 3 files changed, 92 insertions(+), 6 deletions(-) -- 1.9.1 diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index d091def..d0930b1 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -145,6 +145,8 @@ struct ivmd_header { bool amd_iommu_dump; bool amd_iommu_irq_remap __read_mostly; +int amd_iommu_guest_ir; + static bool amd_iommu_detected; static bool __initdata amd_iommu_disabled; static int amd_iommu_target_ivhd_type; @@ -1258,6 +1260,8 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h) iommu->mmio_phys_end = MMIO_REG_END_OFFSET; else iommu->mmio_phys_end = MMIO_CNTR_CONF_OFFSET; + if (((h->efr_attr & (0x1 << IOMMU_FEAT_GASUP_SHIFT)) == 0)) + amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY; break; case 0x11: case 0x40: @@ -1265,6 +1269,8 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h) iommu->mmio_phys_end = MMIO_REG_END_OFFSET; else iommu->mmio_phys_end = MMIO_CNTR_CONF_OFFSET; + if (((h->efr_reg & (0x1 << IOMMU_EFR_GASUP_SHIFT)) == 0)) + amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY; break; default: return -EINVAL; @@ -1488,6 +1494,14 @@ static int iommu_init_pci(struct amd_iommu *iommu) if (iommu_feature(iommu, FEATURE_PPR) && alloc_ppr_log(iommu)) return -ENOMEM; + /* Note: We have already checked GASup from IVRS table. + * Now, we need to make sure that GAMSup is set. + */ + if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) && + !iommu_feature(iommu, FEATURE_GAM_VAPIC)) + amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY_GA; + + if (iommu->cap & (1UL << IOMMU_CAP_NPCACHE)) amd_iommu_np_cache = true; @@ -1545,16 +1559,24 @@ static void print_iommu_info(void) dev_name(&iommu->dev->dev), iommu->cap_ptr); if (iommu->cap & (1 << IOMMU_CAP_EFR)) { - pr_info("AMD-Vi: Extended features: "); + pr_info("AMD-Vi: Extended features (%#llx):\n", + iommu->features); for (i = 0; i < ARRAY_SIZE(feat_str); ++i) { if (iommu_feature(iommu, (1ULL << i))) pr_cont(" %s", feat_str[i]); } + + if (iommu->features & FEATURE_GAM_VAPIC) + pr_cont(" GA_vAPIC"); + pr_cont("\n"); } } - if (irq_remapping_enabled) + if (irq_remapping_enabled) { pr_info("AMD-Vi: Interrupt remapping enabled\n"); + if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)) + pr_info("AMD-Vi: virtual APIC enabled\n"); + } } static int __init amd_iommu_init_pci(void) @@ -1852,6 +1874,22 @@ static void iommu_apply_resume_quirks(struct amd_iommu *iommu) iommu->stored_addr_lo | 1); } +static void iommu_enable_ga(struct amd_iommu *iommu) +{ +#ifdef CONFIG_IRQ_REMAP + switch (amd_iommu_guest_ir) { + case AMD_IOMMU_GUEST_IR_VAPIC: + iommu_feature_enable(iommu, CONTROL_GAM_EN); + /* Fall through */ + case AMD_IOMMU_GUEST_IR_LEGACY_GA: + iommu_feature_enable(iommu, CONTROL_GA_EN); + break; + default: + break; + } +#endif +} + /* * This function finally enables all IOMMUs found in the system after * they have been initialized @@ -1867,6 +1905,7 @@ static void early_enable_iommus(void) iommu_enable_command_buffer(iommu); iommu_enable_event_buffer(iommu); iommu_set_exclusion_range(iommu); + iommu_enable_ga(iommu); iommu_enable(iommu); iommu_flush_all_caches(iommu); } @@ -2147,10 +2186,16 @@ static int __init early_amd_iommu_init(void) * remapping tables. */ ret = -ENOMEM; - amd_iommu_irq_cache = kmem_cache_create("irq_remap_cache", - MAX_IRQS_PER_TABLE * sizeof(u32), - IRQ_TABLE_ALIGNMENT, - 0, NULL); + if (!AMD_IOMMU_GUEST_IR_GA(amd_iommu_guest_ir)) + amd_iommu_irq_cache = kmem_cache_create("irq_remap_cache", + MAX_IRQS_PER_TABLE * sizeof(u32), + IRQ_TABLE_ALIGNMENT, + 0, NULL); + else + amd_iommu_irq_cache = kmem_cache_create("irq_remap_cache", + MAX_IRQS_PER_TABLE * (sizeof(u64) * 2), + IRQ_TABLE_ALIGNMENT, + 0, NULL); if (!amd_iommu_irq_cache) goto out; @@ -2403,6 +2448,21 @@ static int __init parse_amd_iommu_dump(char *str) return 1; } +static int __init parse_amd_iommu_intr(char *str) +{ + for (; *str; ++str) { + if (strncmp(str, "legacy", 6) == 0) { + amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY; + break; + } + if (strncmp(str, "vapic", 5) == 0) { + amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_VAPIC; + break; + } + } + return 1; +} + static int __init parse_amd_iommu_options(char *str) { for (; *str; ++str) { @@ -2511,6 +2571,7 @@ static int __init parse_ivrs_acpihid(char *str) __setup("amd_iommu_dump", parse_amd_iommu_dump); __setup("amd_iommu=", parse_amd_iommu_options); +__setup("amd_iommu_intr=", parse_amd_iommu_intr); __setup("ivrs_ioapic", parse_ivrs_ioapic); __setup("ivrs_hpet", parse_ivrs_hpet); __setup("ivrs_acpihid", parse_ivrs_acpihid); diff --git a/drivers/iommu/amd_iommu_proto.h b/drivers/iommu/amd_iommu_proto.h index 0bd9eb3..faa3b48 100644 --- a/drivers/iommu/amd_iommu_proto.h +++ b/drivers/iommu/amd_iommu_proto.h @@ -38,6 +38,7 @@ extern int amd_iommu_enable(void); extern void amd_iommu_disable(void); extern int amd_iommu_reenable(int); extern int amd_iommu_enable_faulting(void); +extern int amd_iommu_guest_ir; /* IOMMUv2 specific functions */ struct iommu_domain; diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index 590956a..25f939b 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h @@ -92,6 +92,7 @@ #define FEATURE_GA (1ULL<<7) #define FEATURE_HE (1ULL<<8) #define FEATURE_PC (1ULL<<9) +#define FEATURE_GAM_VAPIC (1ULL<<21) #define FEATURE_PASID_SHIFT 32 #define FEATURE_PASID_MASK (0x1fULL << FEATURE_PASID_SHIFT) @@ -146,6 +147,8 @@ #define CONTROL_PPFINT_EN 0x0eULL #define CONTROL_PPR_EN 0x0fULL #define CONTROL_GT_EN 0x10ULL +#define CONTROL_GA_EN 0x11ULL +#define CONTROL_GAM_EN 0x19ULL #define CTRL_INV_TO_MASK (7 << CONTROL_INV_TIMEOUT) #define CTRL_INV_TO_NONE 0 @@ -329,6 +332,12 @@ #define IOMMU_CAP_NPCACHE 26 #define IOMMU_CAP_EFR 27 +/* IOMMU Feature Reporting Field (for IVHD type 10h */ +#define IOMMU_FEAT_GASUP_SHIFT 6 + +/* IOMMU Extended Feature Register (EFR) */ +#define IOMMU_EFR_GASUP_SHIFT 7 + #define MAX_DOMAIN_ID 65536 /* Protection domain flags */ @@ -682,4 +691,19 @@ static inline int get_hpet_devid(int id) return -EINVAL; } +enum amd_iommu_intr_mode_type { + AMD_IOMMU_GUEST_IR_LEGACY, + + /* This mode is not visible to users. It is used when + * we cannot fully enable vAPIC and fallback to only support + * legacy interrupt remapping via 128-bit IRTE. + */ + AMD_IOMMU_GUEST_IR_LEGACY_GA, + AMD_IOMMU_GUEST_IR_VAPIC, +}; + +#define AMD_IOMMU_GUEST_IR_GA(x) (x == AMD_IOMMU_GUEST_IR_VAPIC || \ + x == AMD_IOMMU_GUEST_IR_LEGACY_GA) + +#define AMD_IOMMU_GUEST_IR_VAPIC(x) (x == AMD_IOMMU_GUEST_IR_VAPIC) #endif /* _ASM_X86_AMD_IOMMU_TYPES_H */