From patchwork Thu Sep 27 16:46:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10618213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EB3315E8 for ; Thu, 27 Sep 2018 16:48:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C977C2B582 for ; Thu, 27 Sep 2018 16:48:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC2C22B592; Thu, 27 Sep 2018 16:48:17 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 82D022B582 for ; Thu, 27 Sep 2018 16:48:16 +0000 (UTC) Received: from localhost ([::1]:38038 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5ZSZ-0001sV-Mp for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Sep 2018 12:48:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5ZQe-0007tg-RZ for qemu-devel@nongnu.org; Thu, 27 Sep 2018 12:46:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5ZQc-0002RQ-92 for qemu-devel@nongnu.org; Thu, 27 Sep 2018 12:46:16 -0400 Received: from mail-co1nam03on0053.outbound.protection.outlook.com ([104.47.40.53]:43024 helo=NAM03-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g5ZQb-0002B6-Ui for qemu-devel@nongnu.org; Thu, 27 Sep 2018 12:46:14 -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:X-MS-Exchange-SenderADCheck; bh=vFyvFY5iCkVI8Mjyp31a8TNyLCJAZO7sanEBQ76JdrU=; b=3DfIINa0nt1QPS6D3r7xb8evCKiUaAmn8MoHlAiJXANuzoogMsJOSUmuUaDXDvTPmSW7xryQ08aCFegA54xcdMLt93mFvg+Aqr+DfMSA8Cb/FfxdsbP4nVWUSRYPyF8ZfvLR0P1xA9Jca/N3XTkL+KQwuib0vpLPRed5eSgsIvA= Received: from DM6PR12MB2682.namprd12.prod.outlook.com (20.176.116.31) by DM6PR12MB2748.namprd12.prod.outlook.com (20.176.118.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Thu, 27 Sep 2018 16:46:00 +0000 Received: from DM6PR12MB2682.namprd12.prod.outlook.com ([fe80::7c34:f2e8:a8a9:cab8]) by DM6PR12MB2682.namprd12.prod.outlook.com ([fe80::7c34:f2e8:a8a9:cab8%3]) with mapi id 15.20.1164.024; Thu, 27 Sep 2018 16:46:00 +0000 From: "Singh, Brijesh" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v4 7/9] i386: acpi: add IVHD device entry for IOAPIC Thread-Index: AQHUVoGRe/n5Et/nVkW/NscuU3hz2g== Date: Thu, 27 Sep 2018 16:46:00 +0000 Message-ID: <1538066739-13095-8-git-send-email-brijesh.singh@amd.com> References: <1538066739-13095-1-git-send-email-brijesh.singh@amd.com> In-Reply-To: <1538066739-13095-1-git-send-email-brijesh.singh@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CY4PR1201CA0007.namprd12.prod.outlook.com (2603:10b6:910:16::17) To DM6PR12MB2682.namprd12.prod.outlook.com (2603:10b6:5:4a::31) authentication-results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.77.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM6PR12MB2748; 20:YFQ8bNb7bGRIYArKwFnoTo7rGdVbFIoanXKFmdbp6v2ItHFl63sSVTlszTkJ4QOQNlyEyeJZ0oz4xQMZtBrzhe97GtjoyGlCRgNj6o7FhCc3WlHc+y9SeX91O6qy0NPAxaPjHr9+hio85I0ERSdJLUr1cB0BtiK8+14ncGfVwC47n1D6cjjCd74t15EwBfB8Fy/085EG5hf29pg5djQACsZo9lX9ITurc1cFYHpDK3J0Su/jl5P3CnJBMNRGkp8e x-ms-office365-filtering-correlation-id: 4b6ed322-4e1d-438b-76ce-08d62498b44d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DM6PR12MB2748; x-ms-traffictypediagnostic: DM6PR12MB2748: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(767451399110)(85827821059158); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051); SRVR:DM6PR12MB2748; BCL:0; PCL:0; RULEID:; SRVR:DM6PR12MB2748; x-forefront-prvs: 0808323E97 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(39860400002)(136003)(396003)(376002)(199004)(189003)(8676002)(6916009)(2351001)(54906003)(86362001)(105586002)(14454004)(7736002)(966005)(106356001)(99286004)(34290500001)(36756003)(2906002)(305945005)(68736007)(81156014)(478600001)(5660300001)(5640700003)(6116002)(3846002)(26005)(81166006)(39060400002)(2616005)(14444005)(446003)(76176011)(2900100001)(6486002)(6506007)(5250100002)(8936002)(316002)(476003)(11346002)(256004)(71200400001)(52116002)(71190400001)(53936002)(2501003)(6306002)(66066001)(6436002)(486006)(97736004)(102836004)(25786009)(4326008)(6512007)(186003)(386003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2748; H:DM6PR12MB2682.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: nFBHpwHH4qb6EIn/VSLMxiHymxpOz6XF3RdGyq43t2ttk8hpejsuUVTQP6pg8oqjn0Ct9mspeCxxg759hoGWFsUiMvWt4p2GtqDyAJS1L+Hw7MPUhQduZQnr7c0PXEHUSmXOPxhgA0bvqeZAvtOOWYzssdE64v+MTrimSf6N8UJRDEh8lbmxyqoQ/P2/j9ZhZgTdHneXG/qKrMlLgV2KdR/mIqDUfcGYSDtrmMwiXMI7qPDPsZaov7c5ApzNX354nLtLutyJXXEIPvUS+yN8wnuMQ5eicWJRL2c/+2Ifz1VFUSSJTYriDf/wzcRnrD7jQGVm/VzfsFlgeVnwVhj8Aj6CV8sNwPZCPG7p6Fup2S8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b6ed322-4e1d-438b-76ce-08d62498b44d X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Sep 2018 16:46:00.1790 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2748 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.40.53 Subject: [Qemu-devel] [PATCH v4 7/9] i386: acpi: add IVHD device entry for IOAPIC X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Lendacky, Thomas" , "Singh, Brijesh" , Eduardo Habkost , "Michael S. Tsirkin" , Peter Xu , Paolo Bonzini , "Suthikulpanit, Suravee" , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When interrupt remapping is enabled, add a special IVHD device (type IOAPIC). Signed-off-by: Brijesh Singh Cc: Peter Xu Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: Tom Lendacky Cc: Suravee Suthikulpanit Acked-by: Peter Xu --- hw/i386/acpi-build.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 1599caa..1ef396d 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2467,9 +2467,12 @@ build_dmar_q35(GArray *table_data, BIOSLinker *linker) * IVRS table as specified in AMD IOMMU Specification v2.62, Section 5.2 * accessible here http://support.amd.com/TechDocs/48882_IOMMU.pdf */ +#define IOAPIC_SB_DEVID (uint64_t)PCI_BUILD_BDF(0, PCI_DEVFN(0x14, 0)) + static void build_amd_iommu(GArray *table_data, BIOSLinker *linker) { + int ivhd_table_len = 28; int iommu_start = table_data->len; AMDVIState *s = AMD_IOMMU_DEVICE(x86_iommu_get_default()); @@ -2491,8 +2494,16 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker) (1UL << 6) | /* PrefSup */ (1UL << 7), /* PPRSup */ 1); + + /* + * When interrupt remapping is supported, we add a special IVHD device + * for type IO-APIC. + */ + if (x86_iommu_get_default()->intr_supported) { + ivhd_table_len += 8; + } /* IVHD length */ - build_append_int_noprefix(table_data, 28, 2); + build_append_int_noprefix(table_data, ivhd_table_len, 2); /* DeviceID */ build_append_int_noprefix(table_data, s->devid, 2); /* Capability offset */ @@ -2516,6 +2527,21 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker) */ build_append_int_noprefix(table_data, 0x0000001, 4); + /* + * Add a special IVHD device type. + * Refer to spec - Table 95: IVHD device entry type codes + * + * Linux IOMMU driver checks for the special IVHD device (type IO-APIC). + * See Linux kernel commit 'c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059' + */ + if (x86_iommu_get_default()->intr_supported) { + build_append_int_noprefix(table_data, + (0x1ull << 56) | /* type IOAPIC */ + (IOAPIC_SB_DEVID << 40) | /* IOAPIC devid */ + 0x48, /* special device */ + 8); + } + build_header(linker, table_data, (void *)(table_data->data + iommu_start), "IVRS", table_data->len - iommu_start, 1, NULL, NULL); }