From patchwork Fri Sep 21 14:25:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10610169 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 DEAE4112B for ; Fri, 21 Sep 2018 14:27:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDDF62DF96 for ; Fri, 21 Sep 2018 14:27:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1C192DFC3; Fri, 21 Sep 2018 14:27:13 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 507772DF96 for ; Fri, 21 Sep 2018 14:27:11 +0000 (UTC) Received: from localhost ([::1]:55907 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3MOk-0002hN-7k for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 10:27:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3MNK-0001bS-8Q for qemu-devel@nongnu.org; Fri, 21 Sep 2018 10:25:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3MNF-0001CN-7h for qemu-devel@nongnu.org; Fri, 21 Sep 2018 10:25:42 -0400 Received: from mail-bl2nam02on0053.outbound.protection.outlook.com ([104.47.38.53]:59296 helo=NAM02-BL2-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 1g3MNE-0001Ba-VR for qemu-devel@nongnu.org; Fri, 21 Sep 2018 10:25:37 -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=LfGGE5KNjMxoIeauFwEOFMjNQKNiihdkcbxqGk0iJ2Y=; b=Kx5B9BSvvZ7lDbDRzg1hfSzW/1EUoE1XNnM2YUu2K3DA7v6ZyA3YnKHFMQryBN1zIxnEdmQfjDwLVp05UXERcDZbbUZ3IHSr/GH6Ye2vo2BT3UT8HhThQNi9rBt8upjKsaR2XZxtdtUZrlNPZPpYZ3FN8DUwnaZNBPPut0m6ims= Received: from DM6PR12MB2682.namprd12.prod.outlook.com (20.176.116.31) by DM6PR12MB2618.namprd12.prod.outlook.com (20.176.116.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Fri, 21 Sep 2018 14:25:34 +0000 Received: from DM6PR12MB2682.namprd12.prod.outlook.com ([fe80::7c34:f2e8:a8a9:cab8]) by DM6PR12MB2682.namprd12.prod.outlook.com ([fe80::7c34:f2e8:a8a9:cab8%2]) with mapi id 15.20.1143.017; Fri, 21 Sep 2018 14:25:34 +0000 From: "Singh, Brijesh" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 0/9] x86_iommu/amd: add interrupt remap support Thread-Index: AQHUUbb12u9FTQ7sJUWVeWye4rogzQ== Date: Fri, 21 Sep 2018 14:25:34 +0000 Message-ID: <1537539920-30662-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: DM5PR21CA0008.namprd21.prod.outlook.com (2603:10b6:3:ac::18) 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; DM6PR12MB2618; 20:ic6PXpngZ0ykIP2wMQczsYlam8+WQitJ++MkJPl1L4zdDuWBFsDyj2hWYrUXEu9NqPRoZll2hdISO3dZPt7t2QuTJ95/wk0D6r5PsSJyMkrHkE65AwCfM+QHful6ZtnSk3yhZsQ9F62tFDuJsKEmO0axFlkhjNlIFQHvtY0IrN0r7OJlkiETM8llHZJngMDcBJEIZowsw24zJ8HA3O9Z/YKdQIkmcVBANXqOLPW/kK1d2ygXJW2PP5isknVIgnmz x-ms-office365-filtering-correlation-id: 16d24f0b-94f5-46a5-5d80-08d61fce1798 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:DM6PR12MB2618; x-ms-traffictypediagnostic: DM6PR12MB2618: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(767451399110)(265634631926514)(85827821059158); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3002001)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(201708071742011)(7699051); SRVR:DM6PR12MB2618; BCL:0; PCL:0; RULEID:; SRVR:DM6PR12MB2618; x-forefront-prvs: 0802ADD973 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(346002)(39860400002)(376002)(366004)(136003)(189003)(199004)(106356001)(7736002)(4326008)(2906002)(5660300001)(2900100001)(97736004)(6916009)(486006)(8676002)(2501003)(2616005)(6436002)(71200400001)(71190400001)(256004)(5640700003)(575784001)(6486002)(54906003)(86362001)(26005)(14444005)(6512007)(53936002)(52116002)(2351001)(8936002)(99286004)(316002)(36756003)(5250100002)(66066001)(6306002)(478600001)(186003)(305945005)(81156014)(105586002)(6116002)(68736007)(3846002)(14454004)(25786009)(6506007)(81166006)(386003)(476003)(39060400002)(102836004)(966005); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2618; H:DM6PR12MB2682.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: TEy+uxJuGq1TspSVd3mWRDHmz5s9VFi7v8Ez96ClydzM9xNXl6QjKmJMYA9gACIi+cPRteeleFmY9jQsPU1O3iMecKv6NQFIWN18QnlBOfllZwQIrz0e4LE/KVlUhDziXq8xLOM9pHEhEZfhwof7MjUavwjwtAujM3N/JomfpQR01RFfnn+I+04w0mwZzTauQ64O2gRrpZ1eK9AI+kcBO0A4h0lgend7Hx5Axfk2vVOuAEAyIvenbiDpgXekhKJrX4Dy256Frb4MxaOsiIIWEJChNFMDXftgRgj1UyLvb5Eb+8Ptr6PJ2U6+WTXITn0GvcXvLSsyZXO9CoiJJLoq7vY+tJc7APJrOAJkaeyoTXc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16d24f0b-94f5-46a5-5d80-08d61fce1798 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Sep 2018 14:25:34.6433 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2618 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.38.53 Subject: [Qemu-devel] [PATCH v3 0/9] x86_iommu/amd: add interrupt remap support 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 This series adds the interrupt remapping support for amd-iommu device. IOMMU spec is available at: https://support.amd.com/TechDocs/48882_IOMMU.pdf To enable the interrupt remap use below qemu cli # $QEMU \ -device amd-iommu,intremap=on I have tested FC-28 and Ubuntu 18.04 guest. Linux guest bootup log shows the interrupt remap supports: [root@localhost ~]# dmesg | grep -i AMD-Vi [ 0.001761] AMD-Vi: Using IVHD type 0x10 [ 0.003051] AMD-Vi: device: 00:03.0 cap: 0040 seg: 0 flags: d1 info 0000 [ 0.004007] AMD-Vi: mmio-addr: 00000000fed80000 [ 0.004874] AMD-Vi: DEV_ALL flags: 00 [ 0.006236] AMD-Vi: DEV_SPECIAL(IOAPIC[0]) devid: 00:14.0 [ 0.667943] AMD-Vi: Found IOMMU at 0000:00:03.0 cap 0x40 [ 0.668727] AMD-Vi: Extended features (0x29d3): [ 0.669874] AMD-Vi: Interrupt remapping enabled [ 0.671074] AMD-Vi: Lazy IO/TLB flushing enabled cat /proc/interrupts confirms that its using IR [root@localhost ~]# cat /proc/interrupts CPU0 0: 40 IR-IO-APIC 2-edge timer 1: 9 IR-IO-APIC 1-edge i8042 4: 1770 IR-IO-APIC 4-edge ttyS0 7: 0 IR-IO-APIC 7-edge parport0 8: 1 IR-IO-APIC 8-edge rtc0 9: 0 IR-IO-APIC 9-fasteoi acpi 12: 15 IR-IO-APIC 12-edge i8042 16: 0 IR-IO-APIC 16-fasteoi i801_smbus 24: 0 PCI-MSI 49152-edge AMD-Vi 25: 13070 IR-PCI-MSI 512000-edge ahci[0000:00:1f.2] 26: 86 IR-PCI-MSI 32768-edge enp0s2-rx-0 27: 139 IR-PCI-MSI 32769-edge enp0s2-tx-0 28: 1 IR-PCI-MSI 32770-edge enp0s2 NMI: 0 Non-maskable interrupts LOC: 26686 Local timer interrupts SPU: 0 Spurious interrupts ... ... Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: Tom Lendacky Cc: Suravee Suthikulpanit Cc: Peter Xu Changes since v2: - make the address space rename a separate patch - fix the V=1 check in patch 2 - add more comments in the patches - use amdvi_target_abort trace point where applicable - use error_report_once where applicable - do not cause exit() when configuration mismatch is detected, but log the error so that user knows about it. Changes since v1: - move vtd_generate_msi_message to common code - fix the dest_mode bit extraction - add more comments explaining why we add the special device - some minor cleanups based on Peter's feedbacks Brijesh Singh (9): x86_iommu: move the kernel-irqchip check in common code x86_iommu: move vtd_generate_msi_message in common file x86_iommu/amd: remove V=1 check from amdvi_validate_dte() x86_iommu/amd: make the address space naming consistent with intel-iommu x86_iommu/amd: Prepare for interrupt remap support x86_iommu/amd: Add interrupt remap support when VAPIC is not enabled i386: acpi: add IVHD device entry for IOAPIC x86_iommu/amd: Add interrupt remap support when VAPIC is enabled x86_iommu/amd: Enable Guest virtual APIC support hw/i386/acpi-build.c | 31 +++- hw/i386/amd_iommu.c | 413 +++++++++++++++++++++++++++++++++++++++++- hw/i386/amd_iommu.h | 96 +++++++++- hw/i386/intel_iommu.c | 39 +--- hw/i386/trace-events | 14 ++ hw/i386/x86-iommu.c | 33 ++++ include/hw/i386/intel_iommu.h | 59 ------ include/hw/i386/x86-iommu.h | 66 +++++++ 8 files changed, 642 insertions(+), 109 deletions(-)