From patchwork Wed Jul 13 13:20:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 9228341 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CF7CE6088F for ; Wed, 13 Jul 2016 18:03:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5D6427FE4 for ; Wed, 13 Jul 2016 18:03:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8BFF2808F; Wed, 13 Jul 2016 18:03:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F60027FE4 for ; Wed, 13 Jul 2016 18:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932105AbcGMSA4 (ORCPT ); Wed, 13 Jul 2016 14:00:56 -0400 Received: from mail-co1nam03on0081.outbound.protection.outlook.com ([104.47.40.81]:26592 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751657AbcGMSAx (ORCPT ); Wed, 13 Jul 2016 14:00:53 -0400 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=5B3Xa33JSIQiuNNTMw5Ub8ixLUDVPXjGy5kpRgrse8o=; b=iu0PHAOijkwDOTDwXVI39Fl9TEb/bhFFDisMzeIKCTx+os6zisL7xD+b2XChGdNvcyaxF2QI3HWviUiJz5ltcVa6os4n839EHSvUGkleUd0ohDprfZbAlhvslG2pxCRmxCK3j2g5yym+v0woZmbjjjK234uD873N05ttyo7mvik= 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:24 +0000 From: Suravee Suthikulpanit To: , , , CC: , , , Suravee Suthikulpanit Subject: [PART2 PATCH v4 05/11] iommu/amd: Detect and initialize guest vAPIC log Date: Wed, 13 Jul 2016 08:20:26 -0500 Message-ID: <1468416032-7692-6-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: 3b57eb6d-3b13-4e9a-5e0b-08d3ab2097fa X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0445; 2:1/alQkPb46QZeJHo3ks5xdkqqY9yceO4DvjE2EtrWjaOXEJ6zZsVux+HeJm3bctcORW+yA3gaEzYJqcw00x6cDLg3wsV7sk4iHiykMcfRk6OsoiYxU4sZoJ2HTNn0CF1xgoRjjiamg894l6b0E8C+dDZgEfb3k7AeSGs0xweG0X34k4413DGU+fTkw00Zqcn; 3:+Fq1JJeXyr197QBrqeEeutaj6yMPSK/vU0qYcqVRS+faTlyM0IL0sSY7KDMe5sUt24eveyW6so12ecv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gvXgu1VezciggM/JKiV/S2GgrhAvahxAv8QGVg0oGkdncJ1KjpTVDBhLR4LmbyJScMpV58MZIXd5QbPjq8VqNjWAKwYugzsYt+XKwXSl2rK2G875cot+pAqxfn24kPLfNwA==; 20:Nk0/r7dw2FPJdF8bI+Giv9PzOAsUHossQ03P9nptjVDqPzoXDfNmcVkBwqbKbcrmIxB569e7J9yenUVROO13/BekzW7Xh0Gu1CIbw1WoX+/atsstuseRCXALd6zDwAhaKqyM2RAOoSdrtKxshxdUN5ZEUZsOG85dHqk39Oet7iuGzaLEElVcj3zgAqy8TFIkztPigt+SUR3HN4AeEdVs5Mlpl3v2wwuhErPVQi4N1YGsrKHWE45AtVhzlMupbzKpqIdjNeVxBjcTWV7xCZl7WXcrxbIeQToKZgsZ6vijVflLX6IvWl3fe8XBDby8x+r7WSexq/xEwx1gLIfLD2cKUrpL/8CrygVkf+VL1Pi5vHftky/315H7P6sJeKLazZFr7UytQ6GAt5EkVPCc8Hat9K3kCgLzhHDq44ID5Du6ns9b4i0GgnDy9SZwj3IpTh7gNbiZ1DPOynAzoYPlNY5UhRvXK7JX3eVcKi9sEsBnW8j05khLdDiZEbW2F93IsWh6 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); 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:GToAtAeEIVwXzjxPUWMS8dqqxWWJRyFfx1m01DbiwjdmlZjaCee/obpjHqQ4ll1ur8SRU2YrUytXF06JGqBN/WkmYPXJ22jAmVo48e0U+gCiR0qZThtUaiz90wDPXT38aVZv5VzTuzFuVDkJrdw5Esb0JDC/hH0uanRgl2yLF4edeyV+GSSDG9LKwQeS47je1o9w1wxvi+lSUo+aZhP7YjlNc22ORAMetqWvmLemumUSTvznfsZjnH3nbm5+1DGIrVCCxQKZXICAUo2f8ATQsfsdnc3E3J5UdwVdHK0wfn1lYUTLPtVHG8xdq6FTVDMf3cJ+4jwDBYiRM/ZEh7iCp0aJUuzP+0jtb7Ftr7jiaSbvpF7H5blHfLr4fclA1utQAKqIyIBjZS7vkpPFlafePaJ3ypvFN8vw8j92pB0ewXA= 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)(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:SlVIkiFb9UnN5Rdlk5/EWgBydYGtXqoLMhc1TxuOk?= =?us-ascii?Q?LLhO0zoPVW8o2a6yJDK9sLMS8mb+tPrzzVlVaYd2wx+NxZDAMaQNvRy8ZuHa?= =?us-ascii?Q?e+a7pXPzdn2D17d5W951gaWVKtH87pidmzCdTwLSiLYcfKgeRy1sqN3DqG/m?= =?us-ascii?Q?O56tUjXErjok/+RUr8YOTyl9L5uv63FBgkYjhjDwJnirmlxFsdQF8Z9mysmD?= =?us-ascii?Q?jrWECV+me/ykUQNDdVPv+3fCrrQDhRTr3gvmxgdjIKbw9uV1izsijVbh3uj9?= =?us-ascii?Q?HUlb2Bdhpb8Xkj2jLG6oHwEkq2QhAUZVxDH2MwESDChzqHkKZuf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UCv2/Lfy/kZnfFPpsl8F9xDIdy26oAnU9F8pYOHsP1rO4vK+BZxea7iKj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2016 13:21:24.1370 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0445 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Suravee Suthikulpanit This patch adds support to detect and initialize IOMMU Guest vAPIC log (GALOG). By default, it also enable GALog interrupt to notify IOMMU driver when GA Log entry is created. Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd_iommu_init.c | 112 +++++++++++++++++++++++++++++++++++++--- drivers/iommu/amd_iommu_types.h | 28 ++++++++++ 2 files changed, 133 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 6635cdf..44483a7 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -84,6 +84,7 @@ #define ACPI_DEVFLAG_LINT1 0x80 #define ACPI_DEVFLAG_ATSDIS 0x10000000 +#define LOOP_TIMEOUT 100000 /* * ACPI table definitions * @@ -388,6 +389,10 @@ static void iommu_disable(struct amd_iommu *iommu) iommu_feature_disable(iommu, CONTROL_EVT_INT_EN); iommu_feature_disable(iommu, CONTROL_EVT_LOG_EN); + /* Disable IOMMU GA_LOG */ + iommu_feature_disable(iommu, CONTROL_GALOG_EN); + iommu_feature_disable(iommu, CONTROL_GAINT_EN); + /* Disable IOMMU hardware itself */ iommu_feature_disable(iommu, CONTROL_IOMMU_EN); } @@ -673,6 +678,99 @@ static void __init free_ppr_log(struct amd_iommu *iommu) free_pages((unsigned long)iommu->ppr_log, get_order(PPR_LOG_SIZE)); } +static void __init free_ga_log(struct amd_iommu *iommu) +{ +#ifdef CONFIG_IRQ_REMAP + if (iommu->ga_log) + free_pages((unsigned long)iommu->ga_log, + get_order(GA_LOG_SIZE)); + if (iommu->ga_log_tail) + free_pages((unsigned long)iommu->ga_log_tail, + get_order(8)); +#endif +} + +static int iommu_ga_log_enable(struct amd_iommu *iommu) +{ +#ifdef CONFIG_IRQ_REMAP + u32 status, i; + + if (!iommu->ga_log) + return -EINVAL; + + status = readl(iommu->mmio_base + MMIO_STATUS_OFFSET); + + /* Check if already running */ + if (status & (MMIO_STATUS_GALOG_RUN_MASK)) + return 0; + + iommu_feature_enable(iommu, CONTROL_GAINT_EN); + iommu_feature_enable(iommu, CONTROL_GALOG_EN); + + for (i = 0; i < LOOP_TIMEOUT; ++i) { + status = readl(iommu->mmio_base + MMIO_STATUS_OFFSET); + if (status & (MMIO_STATUS_GALOG_RUN_MASK)) + break; + } + + if (i >= LOOP_TIMEOUT) + return -EINVAL; +#endif /* CONFIG_IRQ_REMAP */ + return 0; +} + +#ifdef CONFIG_IRQ_REMAP +static int iommu_init_ga_log(struct amd_iommu *iommu) +{ + u64 entry; + + if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)) + return 0; + + iommu->ga_log = (u8 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, + get_order(GA_LOG_SIZE)); + if (!iommu->ga_log) + goto err_out; + + iommu->ga_log_tail = (u8 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, + get_order(8)); + if (!iommu->ga_log_tail) + goto err_out; + + entry = (u64)virt_to_phys(iommu->ga_log) | GA_LOG_SIZE_512; + memcpy_toio(iommu->mmio_base + MMIO_GA_LOG_BASE_OFFSET, + &entry, sizeof(entry)); + entry = ((u64)virt_to_phys(iommu->ga_log) & 0xFFFFFFFFFFFFFULL) & ~7ULL; + memcpy_toio(iommu->mmio_base + MMIO_GA_LOG_TAIL_OFFSET, + &entry, sizeof(entry)); + writel(0x00, iommu->mmio_base + MMIO_GA_HEAD_OFFSET); + writel(0x00, iommu->mmio_base + MMIO_GA_TAIL_OFFSET); + + return 0; +err_out: + free_ga_log(iommu); + return -EINVAL; +} +#endif /* CONFIG_IRQ_REMAP */ + +static int iommu_init_ga(struct amd_iommu *iommu) +{ + int ret = 0; + +#ifdef CONFIG_IRQ_REMAP + /* 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; + + ret = iommu_init_ga_log(iommu); +#endif /* CONFIG_IRQ_REMAP */ + + return ret; +} + static void iommu_enable_gt(struct amd_iommu *iommu) { if (!iommu_feature(iommu, FEATURE_GT)) @@ -1146,6 +1244,7 @@ static void __init free_iommu_one(struct amd_iommu *iommu) free_command_buffer(iommu); free_event_buffer(iommu); free_ppr_log(iommu); + free_ga_log(iommu); iommu_unmap_mmio_space(iommu); } @@ -1438,6 +1537,7 @@ static int iommu_init_pci(struct amd_iommu *iommu) { int cap_ptr = iommu->cap_ptr; u32 range, misc, low, high; + int ret; iommu->dev = pci_get_bus_and_slot(PCI_BUS_NUM(iommu->devid), iommu->devid & 0xff); @@ -1494,13 +1594,9 @@ 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; - + ret = iommu_init_ga(iommu); + if (ret) + return ret; if (iommu->cap & (1UL << IOMMU_CAP_NPCACHE)) amd_iommu_np_cache = true; @@ -1657,6 +1753,8 @@ enable_faults: if (iommu->ppr_log != NULL) iommu_feature_enable(iommu, CONTROL_PPFINT_EN); + iommu_ga_log_enable(iommu); + return 0; } diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index 84d3918..d72ab15 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h @@ -70,6 +70,8 @@ #define MMIO_EXCL_LIMIT_OFFSET 0x0028 #define MMIO_EXT_FEATURES 0x0030 #define MMIO_PPR_LOG_OFFSET 0x0038 +#define MMIO_GA_LOG_BASE_OFFSET 0x00e0 +#define MMIO_GA_LOG_TAIL_OFFSET 0x00e8 #define MMIO_CMD_HEAD_OFFSET 0x2000 #define MMIO_CMD_TAIL_OFFSET 0x2008 #define MMIO_EVT_HEAD_OFFSET 0x2010 @@ -77,6 +79,8 @@ #define MMIO_STATUS_OFFSET 0x2020 #define MMIO_PPR_HEAD_OFFSET 0x2030 #define MMIO_PPR_TAIL_OFFSET 0x2038 +#define MMIO_GA_HEAD_OFFSET 0x2040 +#define MMIO_GA_TAIL_OFFSET 0x2048 #define MMIO_CNTR_CONF_OFFSET 0x4000 #define MMIO_CNTR_REG_OFFSET 0x40000 #define MMIO_REG_END_OFFSET 0x80000 @@ -112,6 +116,9 @@ #define MMIO_STATUS_EVT_INT_MASK (1 << 1) #define MMIO_STATUS_COM_WAIT_INT_MASK (1 << 2) #define MMIO_STATUS_PPR_INT_MASK (1 << 6) +#define MMIO_STATUS_GALOG_RUN_MASK (1 << 8) +#define MMIO_STATUS_GALOG_OVERFLOW_MASK (1 << 9) +#define MMIO_STATUS_GALOG_INT_MASK (1 << 10) /* event logging constants */ #define EVENT_ENTRY_SIZE 0x10 @@ -150,6 +157,8 @@ #define CONTROL_GT_EN 0x10ULL #define CONTROL_GA_EN 0x11ULL #define CONTROL_GAM_EN 0x19ULL +#define CONTROL_GALOG_EN 0x1CULL +#define CONTROL_GAINT_EN 0x1DULL #define CTRL_INV_TO_MASK (7 << CONTROL_INV_TIMEOUT) #define CTRL_INV_TO_NONE 0 @@ -228,6 +237,19 @@ #define PPR_REQ_FAULT 0x01 +/* Constants for GA Log handling */ +#define GA_LOG_ENTRIES 512 +#define GA_LOG_SIZE_SHIFT 56 +#define GA_LOG_SIZE_512 (0x8ULL << GA_LOG_SIZE_SHIFT) +#define GA_ENTRY_SIZE 8 +#define GA_LOG_SIZE (GA_ENTRY_SIZE * GA_LOG_ENTRIES) + +#define GA_TAG(x) (u32)(x & 0xffffffffULL) +#define GA_DEVID(x) (u16)(((x) >> 32) & 0xffffULL) +#define GA_REQ_TYPE(x) (((x) >> 60) & 0xfULL) + +#define GA_GUEST_NR 0x1 + #define PAGE_MODE_NONE 0x00 #define PAGE_MODE_1_LEVEL 0x01 #define PAGE_MODE_2_LEVEL 0x02 @@ -502,6 +524,12 @@ struct amd_iommu { /* Base of the PPR log, if present */ u8 *ppr_log; + /* Base of the GA log, if present */ + u8 *ga_log; + + /* Tail of the GA log, if present */ + u8 *ga_log_tail; + /* true if interrupts for this IOMMU are already enabled */ bool int_enabled;