From patchwork Fri Sep 14 18:26:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10601139 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 A7A7314BD for ; Fri, 14 Sep 2018 18:28:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94C952BAB9 for ; Fri, 14 Sep 2018 18:28:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 873712BAC8; Fri, 14 Sep 2018 18:28:41 +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=BAD_ENC_HEADER,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 060632BAB9 for ; Fri, 14 Sep 2018 18:28:40 +0000 (UTC) Received: from localhost ([::1]:52871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0spb-0000gt-E8 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Sep 2018 14:28:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35586) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0soS-0008Ll-FP for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0soP-0003Xt-Pe for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:28 -0400 Received: from mail-co1nam04on0607.outbound.protection.outlook.com ([2a01:111:f400:fe4d::607]:5920 helo=NAM04-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 1g0soP-0003Ug-Hd for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:25 -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=LQUJDfkZUE4PDXVKOHe1LKJJ9xtO26SGiqpTarVEa68=; b=UN3yL28XVOfEslTaUolW89Mxh9KfdVqeUyRqMPUxcnFuLMVWMEhTyTqX4un8zsbd5DPa9VjGW7btQXhUk0fXZAA+SunN222bjOqjpRT9pBMw9bQ/M5aIK2leSrg/KgnLwPvR9FZ55fvOA2ItiLmVAvU3znUtr6PWUJF6ZBkqdXE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from sbrijesh-desktop.amd.com (165.204.77.1) by DM6PR12MB2684.namprd12.prod.outlook.com (2603:10b6:5:4a::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Fri, 14 Sep 2018 18:27:21 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Fri, 14 Sep 2018 13:26:56 -0500 Message-Id: <1536949623-23564-2-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536949623-23564-1-git-send-email-brijesh.singh@amd.com> References: <1536949623-23564-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BYAPR01CA0001.prod.exchangelabs.com (2603:10b6:a02:80::14) To DM6PR12MB2684.namprd12.prod.outlook.com (2603:10b6:5:4a::33) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2525229d-c406-4f3f-2e1f-08d61a6fb69e X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DM6PR12MB2684; X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 3:12+euh3oNZngUvAMz4C78rZlSsGj83gPvJ2a1TVgHbtnB9pZPdlh9bfspApk3XSDaf5geWXX8UB2EnEisv4yz8mEOoul/m/9R8fHQjD/knHVXAgeJ5hlrNNigglWeb2vxhH/S2Dee+olyJy7FrRIjiMdaubyjMn/zmdurkvnQB6xq0OYsr7FGfEKRAfPuMLDajmrcbgGpjFjUGEp14f2XTVpqmBlc3tXzosr+OVWQ5x9iXwXq1oWscRowwdaz3yv; 25:b/evaRHY2vRAn3Cf8RmJx2CJokfTUuc3X0S9boFeFJvkEGLDRnvTRUhk7D5s3CgCDxvw3Dt9Tlas5+oMQJQdoZXzLxB7CJJ4q8ZB+WIuFuidPFcHcAZls7aOsMdtfZQJDMOsLBFhwqkUcnulULbl8s+hJfZRPBRdtJSKWv0UCNAPesWx+EIS7TUR9P33h/MWxYRshoy+14pmScsK5ikPDoxtNQmNxhW3cOYPjIEjDtkFt748T2JR5arzuYiqOsrgZTBBS4v5XLlJCVI2/uLaGTbikCfdR+1EQ0lwEN9VbO/WMZ50uVjqI5UG/M4D4t+9bhdzHUWHLyJqe9PV3JZ11w==; 31:U53NLVtctF4Jkfvsc4d1A9LRzJtN5GphHjUYw+beOMybq8dctgj7xDPrsNbThBwpAqhp5HMWj/Pf2LXfOuK81GA99C8j9WagtbctW/EnaLuDS/OQ5WvyTNH8g3pxBANtru1iq/vp3IcGilTJbVUdTU8BrIvzlwwnGaBcaGGm7eZGlZEDYlcSF+ms6BTd2R9CLaO/MtzXAVoic/xRAaMg8LxCDm7APg0Ap4ubsX0yRbQ= X-MS-TrafficTypeDiagnostic: DM6PR12MB2684: X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 20:LzP42XEiAqx4PzXIwTBXly9qblsJhdyCvCQkJc7uwK9D5YbEdeghcgvKChDF0OospXLXaqpfQQsYYIbGXEc3QfoOIKATRbj/Tn5VwowP1qRehK8KgtFC+YYa4jwOcEaT5ahPyJVuhSGAdOahGGsL1GoeHde3bbSU6bP9fBz2qsIItCycmDc/yR3h+3Rv2iwzjBzoUNo9cO8yZHm9/gg5GaFkZq4oNcx/8HiA4P5o5Uskk4AJ1xAIiSaV/92n+kIlZXVsy0oCawkiTbVFIsew7HxzF8Fg6EX4/+7xDAolLq0Qo1Eh9hg3jUmzIz6iuaVmzZnu3amc1GfWhKPkIUZViftXOZkJmWSjQwbZ1JuY7rqpFBSGQtn0hk40QdNBZHFCu2y8o90v97WpQzMF+N3dS65E5RGB0LXUKdymC+YrgD3cxkzBWnFIK8OEUOWi/7zAPX6sTTbb8AzwrL1zi6FBoOr7JA5KX6c4SxADB6MzRhk6K5fkbOatrc3oK40bb+tF; 4:QWeTu0mhJmENU5A7UsQdKXBXNvFraMvKLzX7zAJ1qPRuQttnO5w6ZZ9GAhYVHsm2IrCIgG4e3f7bLP2CKR4ceCDtgNnl94C0LYGsr4Yk5oOGt76Me4dnhiCSOstTgla+l6capw5opuyOPdauoKkD0JBrt7DY7rTIQeYc/sgmqDhf/vtAi7DH4EF+vXps8IfSB7AGiRek7R5blyIGZw+z/OtmNtTLhRoOrf4WpJs5Cu9vy+di73y0BbR+jc51XUB9auVZRWJf7TSmK2Qu9XOW8MC3EJyNYaM/bKKo2RkAyCzZcPUv336Zv0O+FvubQB4rARMqkNWvOXbmSHTD4gTeEy15eldLRzpXiG4cWIgu7rk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158)(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699050); SRVR:DM6PR12MB2684; BCL:0; PCL:0; RULEID:; SRVR:DM6PR12MB2684; X-Forefront-PRVS: 07954CC105 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(346002)(376002)(366004)(189003)(199004)(50466002)(66066001)(48376002)(2906002)(25786009)(446003)(16586007)(6486002)(76176011)(39060400002)(7736002)(68736007)(51416003)(7696005)(305945005)(316002)(6666003)(6916009)(47776003)(53936002)(52116002)(386003)(956004)(486006)(11346002)(5660300001)(54906003)(2616005)(8676002)(478600001)(36756003)(476003)(186003)(44832011)(105586002)(2361001)(3846002)(106356001)(26005)(81166006)(81156014)(8936002)(2351001)(53416004)(16526019)(50226002)(4326008)(97736004)(6116002)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2684; H:sbrijesh-desktop.amd.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-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR12MB2684; 23:NPAqEisg22rkvZqpdPdgxw1M9gtJjmTPmFpOT1Uar?= nyesdeRqjFTQM54MnffRdHvNkv7JH1G3vsa43XzB4R8olT7m8YsAY7gBU7I3ggznn7/in+sQZPS+7sjSbFZmY+/b3Kcv+SoWrsjNgHKHbFflI8HQxSDihZNCaoPGl9Vbh8R1ciarpxpe193SvJ8Nfn2gVSGS0rk2uU0n8bHgmDRj/dYAGR0hoYDqmWnqN69xcbIumY0KAhevsl6rSrUp2aKADI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p3NoGwo+It70r6cHBDKrOGslPlzLvaIO9Wqs448AmM5x9IE8un2fyHPx6cOr8AiQj9/3nAE1aLgvf3xtW6//VE4vt7+Jr9UqpD335AGdAlCYNHcaxTSTuoWB6ffA3PWhNRaj/8dGMP3Uu4sg6Z1PlVGjgvpZ3jgWbNYh+CEx4Dp1A2myiHM+MQVI4Ijl06uXD1/bgDJg1aToT0 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 20:XEJ1aBwSqzpa1QLLRCP7a6JNbTXy3tTDlNyr/wzsaCKQIvIvlDiM008LGSWb52kXuah5jgzgfj9h72fVKWRbcGCK7ZSNHUlFkKNw5YQHsknHgzKaELmIyGYyAIrNOsgeJAjqSC/11HbCzwTA0HyU0g/Mrfn70E55+QIfGr/j+FqE1azyySRWm/y7tXbM0WZs/sFjY1O7V+B02uUwp55fHmE+7Vgc6ghcLfA8d6aB6iWAliEicHoznXpeT/VK4y9I X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2018 18:27:21.5367 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2525229d-c406-4f3f-2e1f-08d61a6fb69e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2684 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe4d::607 Subject: [Qemu-devel] [PATCH v2 1/8] x86_iommu: move the kernel-irqchip check in common code 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: Tom Lendacky , Brijesh Singh , Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , Suravee Suthikulpanit , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Interrupt remapping needs kernel-irqchip={off|split} on both Intel and AMD platforms. Move the check in common place. Signed-off-by: Brijesh Singh Reviewed-by: Peter Xu Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: Tom Lendacky Cc: Suravee Suthikulpanit Reviewed-by: Eduardo Habkost --- hw/i386/intel_iommu.c | 7 ------- hw/i386/x86-iommu.c | 9 +++++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 3dfada1..84dbc20 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3248,13 +3248,6 @@ static bool vtd_decide_config(IntelIOMMUState *s, Error **errp) { X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s); - /* Currently Intel IOMMU IR only support "kernel-irqchip={off|split}" */ - if (x86_iommu->intr_supported && kvm_irqchip_in_kernel() && - !kvm_irqchip_is_split()) { - error_setg(errp, "Intel Interrupt Remapping cannot work with " - "kernel-irqchip=on, please use 'split|off'."); - return false; - } if (s->intr_eim == ON_OFF_AUTO_ON && !x86_iommu->intr_supported) { error_setg(errp, "eim=on cannot be selected without intremap=on"); return false; diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c index 8a01a2d..7440cb8 100644 --- a/hw/i386/x86-iommu.c +++ b/hw/i386/x86-iommu.c @@ -25,6 +25,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "trace.h" +#include "sysemu/kvm.h" void x86_iommu_iec_register_notifier(X86IOMMUState *iommu, iec_notify_fn fn, void *data) @@ -94,6 +95,14 @@ static void x86_iommu_realize(DeviceState *dev, Error **errp) return; } + /* Both Intel and AMD IOMMU IR only support "kernel-irqchip={off|split}" */ + if (x86_iommu->intr_supported && kvm_irqchip_in_kernel() && + !kvm_irqchip_is_split()) { + error_setg(errp, "Interrupt Remapping cannot work with " + "kernel-irqchip=on, please use 'split|off'."); + return; + } + if (x86_class->realize) { x86_class->realize(dev, errp); } From patchwork Fri Sep 14 18:26:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10601141 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 6F81214BD for ; Fri, 14 Sep 2018 18:28:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C5072BAB9 for ; Fri, 14 Sep 2018 18:28:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 509F32BABD; Fri, 14 Sep 2018 18:28:48 +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=BAD_ENC_HEADER,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 7C2642BAB9 for ; Fri, 14 Sep 2018 18:28:47 +0000 (UTC) Received: from localhost ([::1]:52872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0spi-0000na-MK for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Sep 2018 14:28:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0soV-0008MT-DX for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0soS-0003eY-4M for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:31 -0400 Received: from mail-eopbgr690075.outbound.protection.outlook.com ([40.107.69.75]:22016 helo=NAM04-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 1g0soR-0003bD-Ng for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:28 -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=W85Y2DY3fv3pTExcL7kGPeNXu6ZR6qEYTwmvuI8xzEM=; b=toEi2v7YugeAl8p4GT2ic4b+XNO7Q7MObLaJWLhL9VulOveHq66ciSo4KqaZjEewSbFMB9jK8P4CYI225wT7whC3eMLf6sS0lj4zjwttlVwrJQCouEVaGkdh6R3w+dyMmb7IMg0fzsPex0R9W/QDwn7pzAhVQAgdHLsrbX/YCVA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from sbrijesh-desktop.amd.com (165.204.77.1) by DM6PR12MB2684.namprd12.prod.outlook.com (2603:10b6:5:4a::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Fri, 14 Sep 2018 18:27:23 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Fri, 14 Sep 2018 13:26:57 -0500 Message-Id: <1536949623-23564-3-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536949623-23564-1-git-send-email-brijesh.singh@amd.com> References: <1536949623-23564-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BYAPR01CA0001.prod.exchangelabs.com (2603:10b6:a02:80::14) To DM6PR12MB2684.namprd12.prod.outlook.com (2603:10b6:5:4a::33) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fffc278d-1471-492b-e9df-08d61a6fb78d X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DM6PR12MB2684; X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 3:gG0V+NpvOcSSpDRf3UczkIdS0kZfPKKbNSPUtEMNTE1/mmMEZaHj3Abm1jhRZmKdQFV2a5fc8MqGKMEMBs5XTuYtu+6U2ASsS+eOsVNPXV7wAy5NjTspvizkw6pKB9Xbpqb1JzDBgbHEriUVR9TE4USGSi7VlNmpn5IsjBKMeejnwjb9FfdnLrC969cBoJnBqPG6elj6oeMTZbTUtFTOMU4+vprrx3LyZ7XkUQ5VLuqxPKqLGU/j58zUR9Y7ZB+3; 25:hDomCm14tsLClbawdUPRSgvaa8Q5klf2Gvstz06cLVQOTa80kyGLGvC8vsoVvWniGOkqnCudwOgbWOTAFnYbZ3CENALa5VB9OFDSvxzDbInGLQ9mYQGnZ72HT15vQWEEponjMohXxjLkDxF0sj8yv2SGYF0dtzw13tkrmaerwp9FIsPeZsmIzTbqWrA8iAXCMI8npuQWhsmIcDDErI/DM+L85blbBWTj2b7mRXnCLLf42eloCzz1kcXLBrg0u2DvdGqF//JxpHMXmG5p2TTfcwmHfPLbXlBK0kdzijILm9K8JXRISqnxtQNkHHByxySkYF5DaqisIYCWR08IGkNQMQ==; 31:Hi6yEYynrZeFBwypf6nhaNw2t7XUsMkaK9Qvgoj3A5nBNuSDMqdhhlFlqWVuTPav6a4rHJstaF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jdt5EyAQKcym+pbpc4Rgh2/k= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158)(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699050); SRVR:DM6PR12MB2684; BCL:0; PCL:0; RULEID:; SRVR:DM6PR12MB2684; X-Forefront-PRVS: 07954CC105 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(346002)(376002)(366004)(189003)(199004)(50466002)(66066001)(48376002)(2906002)(25786009)(446003)(16586007)(6486002)(76176011)(39060400002)(7736002)(68736007)(51416003)(7696005)(305945005)(316002)(6666003)(6916009)(47776003)(53936002)(52116002)(386003)(956004)(486006)(11346002)(5660300001)(54906003)(2616005)(8676002)(478600001)(36756003)(476003)(186003)(44832011)(105586002)(2361001)(3846002)(106356001)(26005)(81166006)(81156014)(8936002)(2351001)(53416004)(16526019)(50226002)(4326008)(97736004)(6116002)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2684; H:sbrijesh-desktop.amd.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-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR12MB2684; 23:tYE/0vEhMQjwIy4O6mIdPKuoIyT2AGPAC12UqOmo3?= Etjnpxr+8U9TEuZ8dQ7QnAf4vrVdsxrtuioRxOIkgOQou0/2+FtHwYWyeqJeTs+8/ThwdUhNK5wtqc3deS8PbfTf8DZ+sg6DFs8pUlDP3RprV+TKPjQWAT0bj9zlLzT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szxPrD11YOfMgkIh2MYPGZkgEG96sKqzAd4I9 X-Microsoft-Antispam-Message-Info: P2QdiRDvMFAH1fgqJZxJXznMHvlMufwpJI74Eeolqy+gEB9FnM0Izpl5RmtY2bJpIbf1zh8uOdCczGbtGrFHVbWykdkYHrqbgdJP2gSh05r2RrUkc4HsbFLsZ9oPl6RZ/gp7wlQnAsSPY2nTk5119mee5U/kfhHfoxGQbsp5BhRwt8iIDxQB6lzvNEpQ26FEtJu4u6kLwuikmS/CKusaMYvl3n8dFQIOyJhrixbduiZRpGDl7+NjVUlj5smLd/mrLnBo90xQPNiWFSW5aUUhqeNl/oDTi4w2v1h4yQ1+bazQBivYu0KquRj6jcBgBz8hG78VjxkQRheEbA0caU0IpGA282X0ch4soExO974H/dU= X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 6:pSRLpWEUT6d9XO3YqSNzW8VrPG4D0JKpQ24l2azqkSFIIgC2B3tTPz/hOhWPfPRT5WDyrqkMvc2DjkdVmYaIgkFW9xhIFdmW4UTBVXQnFpssekrduni/L5eL7g/0rNlKzxbjTBKF+w+nEJX5LUn/frkrwq1Y37ynh/51LSTMWHzbnr/ffGGisb25unXXdYoU7gMq/ekeHVu83Rm8om2jGlbMacJS64NCoeyMPmuRF84gRM4/bfAjjkX490upNPzjtQiqGxb/66/4dCkFJq21hweqfyrV8plKSM4eFaCqhMWP1ThhnkJH/+66+21B+IjI5mfyl/J1aV1cOwUVnRitWONfH4wigTZm8SNvMNLABHrP4t918g5KQ0WCnp6l4KJcs2D1KeQXVGxUGPrFHuunhyBfcojaZNmwXJNP4WPVxC+SXZrJB+CPyUjdGzyu/KAtTO+opuIOk7NazTqzqTvnFg==; 5:8aTJ7ce+M30vJMri1NyrkokuxICigKn5akD+qXxNMJzc5itMtRZK4XynwIyzLoZaT3WMSMvi+LO5MU9BAQcwD1paiwdlNKvD28kEJ1qinmpuF6AvVBfXkomDHwnWBHRf/Zh3YL/iCs1c/MeV+7G4odkMWuetbnndpSZ2ibYT0ZU=; 7:nfe5pllU8G76l8ZAxSDkaWg+m7YNToXfcdwuugKNXj0jfpsIMvbQpA4i6lEdkvR7mMBUASfr2r+9CeXsHFOZxEaLDLvVWUGST39MuqR9uhpCV2tYJoEV4e5orLTnHp2Qq1tKgQrvYWfCKoGZYNdvtPuLpYauWwFHQYxRd3d54T7cbL7CNmq+rLOc6GxBjqrZzg38lpXyUaz5O87t6qLd4nm0q1NM+goPPTNQeWMtITBQu5deNh7ZOkYHdPUM/s4+ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 20:+N7VprQued7Jz8IqmE3SCq27tF/Hrawmh+td3zVrpdHpzY2n2wpOw+RXLdkQRtZipFJtNpAL3m0fIGyDhccEVkMtfsb7Zn0/9wV3hhTZaTTFRnLncaJLk9WYzx0Rrz83UZpOkKMkjokzHJ5pFBL4U/iVJtVXF2EIDf4BFBXqR1Ccc2XzbEfmIdHH8lTOyCqdD34SJYCMVrBO+rvjJ1Ei/uboFycz+cFioa5RxFHInd5EMyaM4cFz8u1WJXOKbJFB X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2018 18:27:23.0918 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fffc278d-1471-492b-e9df-08d61a6fb78d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2684 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.75 Subject: [Qemu-devel] [PATCH v2 2/8] x86_iommu: move vtd_generate_msi_message in common file 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: Tom Lendacky , Brijesh Singh , Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , Suravee Suthikulpanit , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The vtd_generate_msi_message() in intel-iommu is used to construct a MSI Message from IRQ. A similar function will be needed when we add interrupt remapping support in amd-iommu. Moving the function in common file to avoid the code duplication. Rename it to x86_iommu_irq_to_msi_message(). There is no logic changes in the code flow. Signed-off-by: Brijesh Singh Suggested-by: Peter Xu Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: Tom Lendacky Cc: Suravee Suthikulpanit Reviewed-by: Eduardo Habkost --- hw/i386/intel_iommu.c | 32 +++------------------ hw/i386/x86-iommu.c | 24 ++++++++++++++++ include/hw/i386/intel_iommu.h | 59 -------------------------------------- include/hw/i386/x86-iommu.h | 66 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 87 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 84dbc20..014418b 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2701,7 +2701,7 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index, /* Fetch IRQ information of specific IR index */ static int vtd_remap_irq_get(IntelIOMMUState *iommu, uint16_t index, - VTDIrq *irq, uint16_t sid) + X86IOMMUIrq *irq, uint16_t sid) { VTD_IR_TableEntry irte = {}; int ret = 0; @@ -2730,30 +2730,6 @@ static int vtd_remap_irq_get(IntelIOMMUState *iommu, uint16_t index, return 0; } -/* Generate one MSI message from VTDIrq info */ -static void vtd_generate_msi_message(VTDIrq *irq, MSIMessage *msg_out) -{ - VTD_MSIMessage msg = {}; - - /* Generate address bits */ - msg.dest_mode = irq->dest_mode; - msg.redir_hint = irq->redir_hint; - msg.dest = irq->dest; - msg.__addr_hi = irq->dest & 0xffffff00; - msg.__addr_head = cpu_to_le32(0xfee); - /* Keep this from original MSI address bits */ - msg.__not_used = irq->msi_addr_last_bits; - - /* Generate data bits */ - msg.vector = irq->vector; - msg.delivery_mode = irq->delivery_mode; - msg.level = 1; - msg.trigger_mode = irq->trigger_mode; - - msg_out->address = msg.msi_addr; - msg_out->data = msg.msi_data; -} - /* Interrupt remapping for MSI/MSI-X entry */ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu, MSIMessage *origin, @@ -2763,7 +2739,7 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu, int ret = 0; VTD_IR_MSIAddress addr; uint16_t index; - VTDIrq irq = {}; + X86IOMMUIrq irq = {}; assert(origin && translated); @@ -2842,8 +2818,8 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu, */ irq.msi_addr_last_bits = addr.addr.__not_care; - /* Translate VTDIrq to MSI message */ - vtd_generate_msi_message(&irq, translated); + /* Translate X86IOMMUIrq to MSI message */ + x86_iommu_irq_to_msi_message(&irq, translated); out: trace_vtd_ir_remap_msi(origin->address, origin->data, diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c index 7440cb8..abc3c03 100644 --- a/hw/i386/x86-iommu.c +++ b/hw/i386/x86-iommu.c @@ -53,6 +53,30 @@ void x86_iommu_iec_notify_all(X86IOMMUState *iommu, bool global, } } +/* Generate one MSI message from VTDIrq info */ +void x86_iommu_irq_to_msi_message(X86IOMMUIrq *irq, MSIMessage *msg_out) +{ + X86IOMMU_MSIMessage msg = {}; + + /* Generate address bits */ + msg.dest_mode = irq->dest_mode; + msg.redir_hint = irq->redir_hint; + msg.dest = irq->dest; + msg.__addr_hi = irq->dest & 0xffffff00; + msg.__addr_head = cpu_to_le32(0xfee); + /* Keep this from original MSI address bits */ + msg.__not_used = irq->msi_addr_last_bits; + + /* Generate data bits */ + msg.vector = irq->vector; + msg.delivery_mode = irq->delivery_mode; + msg.level = 1; + msg.trigger_mode = irq->trigger_mode; + + msg_out->address = msg.msi_addr; + msg_out->data = msg.msi_data; +} + /* Default X86 IOMMU device */ static X86IOMMUState *x86_iommu_default = NULL; diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index fbfedcb..ed4e758 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -66,8 +66,6 @@ typedef struct VTDIOTLBEntry VTDIOTLBEntry; typedef struct VTDBus VTDBus; typedef union VTD_IR_TableEntry VTD_IR_TableEntry; typedef union VTD_IR_MSIAddress VTD_IR_MSIAddress; -typedef struct VTDIrq VTDIrq; -typedef struct VTD_MSIMessage VTD_MSIMessage; /* Context-Entry */ struct VTDContextEntry { @@ -197,63 +195,6 @@ union VTD_IR_MSIAddress { uint32_t data; }; -/* Generic IRQ entry information */ -struct VTDIrq { - /* Used by both IOAPIC/MSI interrupt remapping */ - uint8_t trigger_mode; - uint8_t vector; - uint8_t delivery_mode; - uint32_t dest; - uint8_t dest_mode; - - /* only used by MSI interrupt remapping */ - uint8_t redir_hint; - uint8_t msi_addr_last_bits; -}; - -struct VTD_MSIMessage { - union { - struct { -#ifdef HOST_WORDS_BIGENDIAN - uint32_t __addr_head:12; /* 0xfee */ - uint32_t dest:8; - uint32_t __reserved:8; - uint32_t redir_hint:1; - uint32_t dest_mode:1; - uint32_t __not_used:2; -#else - uint32_t __not_used:2; - uint32_t dest_mode:1; - uint32_t redir_hint:1; - uint32_t __reserved:8; - uint32_t dest:8; - uint32_t __addr_head:12; /* 0xfee */ -#endif - uint32_t __addr_hi; - } QEMU_PACKED; - uint64_t msi_addr; - }; - union { - struct { -#ifdef HOST_WORDS_BIGENDIAN - uint16_t trigger_mode:1; - uint16_t level:1; - uint16_t __resved:3; - uint16_t delivery_mode:3; - uint16_t vector:8; -#else - uint16_t vector:8; - uint16_t delivery_mode:3; - uint16_t __resved:3; - uint16_t level:1; - uint16_t trigger_mode:1; -#endif - uint16_t __resved1; - } QEMU_PACKED; - uint32_t msi_data; - }; -}; - /* When IR is enabled, all MSI/MSI-X data bits should be zero */ #define VTD_IR_MSI_DATA (0) diff --git a/include/hw/i386/x86-iommu.h b/include/hw/i386/x86-iommu.h index 7c71fc7..2b22a57 100644 --- a/include/hw/i386/x86-iommu.h +++ b/include/hw/i386/x86-iommu.h @@ -22,6 +22,7 @@ #include "hw/sysbus.h" #include "hw/pci/pci.h" +#include "hw/pci/msi.h" #define TYPE_X86_IOMMU_DEVICE ("x86-iommu") #define X86_IOMMU_DEVICE(obj) \ @@ -35,6 +36,8 @@ typedef struct X86IOMMUState X86IOMMUState; typedef struct X86IOMMUClass X86IOMMUClass; +typedef struct X86IOMMUIrq X86IOMMUIrq; +typedef struct X86IOMMU_MSIMessage X86IOMMU_MSIMessage; typedef enum IommuType { TYPE_INTEL, @@ -78,6 +81,63 @@ struct X86IOMMUState { QLIST_HEAD(, IEC_Notifier) iec_notifiers; /* IEC notify list */ }; +/* Generic IRQ entry information when interrupt remapping is enabled */ +struct X86IOMMUIrq { + /* Used by both IOAPIC/MSI interrupt remapping */ + uint8_t trigger_mode; + uint8_t vector; + uint8_t delivery_mode; + uint32_t dest; + uint8_t dest_mode; + + /* only used by MSI interrupt remapping */ + uint8_t redir_hint; + uint8_t msi_addr_last_bits; +}; + +struct X86IOMMU_MSIMessage { + union { + struct { +#ifdef HOST_WORDS_BIGENDIAN + uint32_t __addr_head:12; /* 0xfee */ + uint32_t dest:8; + uint32_t __reserved:8; + uint32_t redir_hint:1; + uint32_t dest_mode:1; + uint32_t __not_used:2; +#else + uint32_t __not_used:2; + uint32_t dest_mode:1; + uint32_t redir_hint:1; + uint32_t __reserved:8; + uint32_t dest:8; + uint32_t __addr_head:12; /* 0xfee */ +#endif + uint32_t __addr_hi; + } QEMU_PACKED; + uint64_t msi_addr; + }; + union { + struct { +#ifdef HOST_WORDS_BIGENDIAN + uint16_t trigger_mode:1; + uint16_t level:1; + uint16_t __resved:3; + uint16_t delivery_mode:3; + uint16_t vector:8; +#else + uint16_t vector:8; + uint16_t delivery_mode:3; + uint16_t __resved:3; + uint16_t level:1; + uint16_t trigger_mode:1; +#endif + uint16_t __resved1; + } QEMU_PACKED; + uint32_t msi_data; + }; +}; + /** * x86_iommu_get_default - get default IOMMU device * @return: pointer to default IOMMU device @@ -110,4 +170,10 @@ void x86_iommu_iec_register_notifier(X86IOMMUState *iommu, void x86_iommu_iec_notify_all(X86IOMMUState *iommu, bool global, uint32_t index, uint32_t mask); +/** + * x86_iommu_irq_to_msi_message - Populate one MSIMessage from X86IOMMUIrq + * @X86IOMMUIrq: The IRQ information + * @out: Output MSI message + */ +void x86_iommu_irq_to_msi_message(X86IOMMUIrq *irq, MSIMessage *out); #endif From patchwork Fri Sep 14 18:26:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10601149 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 193F814BD for ; Fri, 14 Sep 2018 18:33:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0566B2B700 for ; Fri, 14 Sep 2018 18:33:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED9AB2B733; Fri, 14 Sep 2018 18:33:11 +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=BAD_ENC_HEADER,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 444832B701 for ; Fri, 14 Sep 2018 18:33:11 +0000 (UTC) Received: from localhost ([::1]:52891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0sty-0003h3-8R for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Sep 2018 14:33:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0soV-0008MS-DW for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0soS-0003ew-Kk for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:31 -0400 Received: from mail-eopbgr690075.outbound.protection.outlook.com ([40.107.69.75]:22016 helo=NAM04-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 1g0soS-0003bD-C8 for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:28 -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=1Sk/esyBt66bDnbvUHoVqnQWmQ9mf7dTFePI/xwnSEY=; b=VUg5GbSoW42p2C7V0gnEQ4E+Que9VYSRF0dX6qK6I4ne4npY1a7fXF29VbT8CBrim53PctEwY5m3fjRirQ/QiV8SvM4Ypzmboimu+6CLL5LOobI5KPJvBq+61efJSoa5lhMbCeOfTKTAAwpugOXiwha8ngb92VIK4lZINXmb32w= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from sbrijesh-desktop.amd.com (165.204.77.1) by DM6PR12MB2684.namprd12.prod.outlook.com (2603:10b6:5:4a::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Fri, 14 Sep 2018 18:27:25 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Fri, 14 Sep 2018 13:26:58 -0500 Message-Id: <1536949623-23564-4-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536949623-23564-1-git-send-email-brijesh.singh@amd.com> References: <1536949623-23564-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BYAPR01CA0001.prod.exchangelabs.com (2603:10b6:a02:80::14) To DM6PR12MB2684.namprd12.prod.outlook.com (2603:10b6:5:4a::33) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8c27b150-04c5-4e6e-5f67-08d61a6fb8df X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DM6PR12MB2684; X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 3:qfSNVfbr1HtlZ1fRqlFXQlGFEFMmnrnjxLdqVT6+3NhLAS+eRxpwVj7D+V2MKnW3alNDBhB+4ZLqaLb7zH7xD2LK/6HPlunw67JA4PqfrkbM9KO7p8T3J4HrmjLaBn7+TTNoSzYfDgQQqXBH8qu+dwLU2oqx4qx2+ADDDePNDtW7+QAHhQPOckBLXktkxnvNBqZ60BAIlypFH+tkJ8LkrIQOrVLt8YYdJh0lX7cNs3S0NnGHHQFuZ+WQvzhk/smL; 25:d+UVfhVTcLWJmyvaz+195l6XzFnxEHgj7jMK2zIvTPvyT9HYrPy2iXh6o4xgwhWYd5DVwCXgNmnvHzddRYeQ36UrUyw2aDIWvizGLpORuG93jTGq717Ft31spkkhQnPcKoiCtnUHgglmLAxQqZFqefSqlEmcWfPoIi2FD/sLZtQ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bhpv50r36/e+Kw3El6PUZLRjyONKkgGJX+YegwW7zRCeM4Vn3UJTVH2K04uFBaFCd1r+N2vDjikmqbleZX/5LHcFfo+l44xVmf/HgQEefIv0Zil2pNfpUxEiJeu8dmMxLKs6ZOCv3y7OGDEI6lbQez7gb+BPCG+361pf0W9Qspwm9lFRvPR+UNSUb5zD5lzO3LZ9Ksf7yrL8PKNM70meaik/G+7rYUessLARpGbVe60PS0OMXoUEJ+ez53OyMDk26InYLcWLNBYNQsiew2YEk4iUoQ5aw8iZG40YNKI/p6gng0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158)(767451399110)(163750095850); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699050); SRVR:DM6PR12MB2684; BCL:0; PCL:0; RULEID:; SRVR:DM6PR12MB2684; X-Forefront-PRVS: 07954CC105 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(346002)(376002)(366004)(189003)(199004)(50466002)(66066001)(48376002)(2906002)(25786009)(446003)(16586007)(6486002)(76176011)(39060400002)(7736002)(68736007)(51416003)(7696005)(305945005)(316002)(6666003)(6916009)(47776003)(53936002)(52116002)(386003)(956004)(486006)(11346002)(5660300001)(54906003)(2616005)(8676002)(478600001)(36756003)(476003)(186003)(44832011)(105586002)(2361001)(3846002)(106356001)(26005)(81166006)(14444005)(81156014)(8936002)(2351001)(53416004)(16526019)(50226002)(4326008)(97736004)(6116002)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2684; H:sbrijesh-desktop.amd.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-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR12MB2684; 23:Y1dpCOFPQJR33UggafXM+QdSaTfnfFDmpEeiFW489?= sW47zSRbhxGK7E5srp9cwy/g/9oaGVef0IJO5dtQElFtm5f4weH32yrEc2Cuj/S5phs6UHRp6fyKtviTdl05RWXFz03DAcWeBZbQ90EMxmO/zwzZJo74ohyq4EoFSnJa0eXZ2TRiW5d41c0QjFdLzA65abThTYR9DaXLGup2Hfg6ax5qPCxcykmm7gRl0KOCsHM+FznBNCJGP7IoDMAA3xRKhqBKlh25SyETXso+mJLVQdcphINlkI4M7JW0RJJQjygzrBXGLUB6SJGdxC0341kGv3jdtLhUjNnTI3/ZQt1xYW8Zu9EU/b83s8QkJ8e3PDot1bkBxdYoBkIEkz7y8KwdT+Z3SbDW1TcFqkpPro1GE2c70KcFdak/BEFchxg0QJeuUJVJfTVeVSYpFtYYzuhuHXm3aSYvNzCh73/XjuuQZoIJLOZXLdH9mwIRV83a8wCPofcK/DYGqkYBKp0zGRXSur+nQ7yvG/vzwnOU8SEHFvWDPXXw/iOuj04lPYm64gk+0WETZAyAw+HkqOZt4LcMpjUM4kf0wHdGY7bVAoZJSLPeXCveWdBdUzQPcTgl18kvU/zYJZWI7F5hkj1BDpJBiEYNSwhftwbg/gDGadh93sGHq0rQ9DMMYpCg0iymwwNEW5G3XauSEyyncNme5dH6hNvWMY9IBmDaCcQy/SY48k3q3r+ED2yT6yFCDbUk3R58wNSCLRkuREi01kY/iuX4p4tYU4svR9VHUxtS19eua8BNwyEhU/wmC9JvCS5yo+edqP90iALNlTt13PVWjenS0PdCjCvZMDIPcG0KDpsG0qlsPgBaBoPU6o3AAG7L9MEfR3hdioOiHmUVvx8sxGhEA9V2M1zj6dCjIKhHZmkZmQuql+LF2jYQFroJ2/TuNctvwgtZoBBG68FjvmQUjfF2t5BXKNiQhSFRr9wQ0M1gxD6kFqWLSy3UPb31YRGEs0s0pOdwxxk6oietUbAzNnoK47MBsq7BTF36125BB/gr5LZIhNbpzxAyGuD0/MO83uCVBsToaCo00OoJVAbh9fFSLNZJSFrPhtZExb7CGhzCWaQrbpshrU099ivbQH4nTu43/5J8Q0+GZdjNMSDUdWRwTgNmDqKE2CmybFRYl9Mye1BlLXQMqobfbnTTvx0dwo4aZZYR6ThVlDwfQmXmvTmc26buaYqg6NFmsTnGMit5eJyiDgUJqPnNSfFouwsZgf/yj6X16SvA1ZPDLARtfTUtYIe4lNqspmmAGWAVe2dIQ== X-Microsoft-Antispam-Message-Info: J7TKquvnMSm1BSOhfx9g8ShaG9nHwpfMMle6mTco/YiXQrTu8fRqcdMsbS8pNHrquJCi0nMeptIcDiu6wh9UpPf7OmaQ63sy2wZQXAhS/mktW6EIDLnkRqS8TZDlex/AN8r0u4TRLPfMv3m/hBZJFxkraE2HkdMlPcaXZ8ev7BPheafGD7jY/na/mdpWq1Sm9FikeTobxw7QY/k7HHjVm65Knvh58ShermI1WLtPv75wo7XKsR/AxSwE5bWelF3mov3frRWiOZAVaYqlfVPWN+/o5+V702RyNWIdsOh/T8PVX2qNrF+Zk+1BqiKk6tAp0rE62hGtIhkt37SemP/yJnXrAStH+S2aZkUfJw8UMs0= X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 6:sAV34aR2SCI4scDpumnUOoGo9MUtHni9RKyjOtz/svRCBokhomQrHh6U26OFfztcocCv0Muan/oKLPR81KFg8dYxvAY2VljbJVAqzSVX3TaonnlOQSu34nzLNa29cMKVJE27lp03aLc13rJebkXAmgJjR7CVo8ZkTa1zOwIVQnxX+i723Mo3IZM76+DdNDV/jRf2of72QVE2unVaq3BRmrUPyotdp+dla/m6Lpeuc+4u2VaLjrurTvc9enn4er9d+q5zjtwCASMTUmi7ssEoFsZzKyV1aIzfTWmsRmMUnJ9A5mmp05w9xI3weISHWGHqO18m3yBLhBGi+2JV6//b8aH+KR7XmyrZyygBq0BU7r0lP6WqE9zX1gS7f03ArpnX+lMMHk8JqmdAlMfQEvrFvACgsCzAW2T6q+kxA38K90m7psU1goMGa3mlV79s6r8Ig2fYrwobk7fTiBaOL6Es2Q==; 5:kHx9440ygPaYfFiGiKP8oPfVtq5xbysgIFtKJygdCU6a0Cvee/9l6yPfoiSP/EcVj5w5eYFt9YrMwap+W5a1zT41YYedZIUc/lLCRd77dUQu3b5swq1qxdh7b2EemHU5R0iGliDb0bbE2td5FfwFNDC9PYsTghkRe8kuJxFqA0w=; 7:uQi2HcIrTpPieA/l82er9z4PP+Qc7DOdgPShtqUe6MaDTx/Z3rG3iMFEVXfA3yFD1ZRDJFXu0WetgFXyVIAF2tGy2hod+u0UK8R/xU+KXoXDNZL5xuZMrHiljA0APr+bw5Dc8z9LOtGFwAQHTV2OHw0bp3PITo1GvjXkkO6+VV6amGJiQTPoaNa1VOt2Ggi8+GVWZd74Pk5KX6tBZE9g6n6wmiyIYYPQcvzJfAyzM76b6lgSxMOfYlQ2nPXKg2ox SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 20:wZWe2Y4LaV3ZBfeKUbsXjpSftJJlz7c63LO3C5Ukvv5VTBjU4WBZKEuTC/+QonNbUp/xtLfLviL5GoX2rzCXgS2JQWF8jU07XZu/VCa+tOygk1MOAQ1Qvyggc/fqN4ssLOSwI6uTyJeS9gJLbBNePkiLz+xAZ7S95GzKWvLw1kj/WVRqIv3JyOTZtjiEpkNpZCvTrGI677J8G2z+mNynUWTA7OuhBGac0wtAKfs/kdHfYDj685x7Np71E8PejpE/ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2018 18:27:25.2723 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c27b150-04c5-4e6e-5f67-08d61a6fb8df X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2684 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.75 Subject: [Qemu-devel] [PATCH v2 3/8] x86_iommu/amd: remove V=1 check from amdvi_validate_dte() 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: Tom Lendacky , Brijesh Singh , Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , Suravee Suthikulpanit , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, the amdvi_validate_dte() assumes that a valid DTE will always have V=1. This is not true. The V=1 means that bit[127:1] are valid. A valid DTE can have IV=1 and V=0 (i.e pt=off, intremap=on). Remove the V=1 check from amdvi_validate_dte(), make the caller responsible to check for V or IV bits. Signed-off-by: Brijesh Singh Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: Tom Lendacky Cc: Suravee Suthikulpanit --- hw/i386/amd_iommu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 1fd669f..225825e 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -807,7 +807,7 @@ static inline uint64_t amdvi_get_perms(uint64_t entry) AMDVI_DEV_PERM_SHIFT; } -/* a valid entry should have V = 1 and reserved bits honoured */ +/* validate that reserved bits are honoured */ static bool amdvi_validate_dte(AMDVIState *s, uint16_t devid, uint64_t *dte) { @@ -820,7 +820,7 @@ static bool amdvi_validate_dte(AMDVIState *s, uint16_t devid, return false; } - return dte[0] & AMDVI_DEV_VALID; + return true; } /* get a device table entry given the devid */ @@ -967,7 +967,8 @@ static void amdvi_do_translate(AMDVIAddressSpace *as, hwaddr addr, } /* devices with V = 0 are not translated */ - if (!amdvi_get_dte(s, devid, entry)) { + if (!amdvi_get_dte(s, devid, entry) && + !(entry[0] & AMDVI_DEV_VALID)) { goto out; } From patchwork Fri Sep 14 18:26:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10601147 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 366C915E8 for ; Fri, 14 Sep 2018 18:32:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 203A82BAE0 for ; Fri, 14 Sep 2018 18:32:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 129732BAE4; Fri, 14 Sep 2018 18:32:00 +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=BAD_ENC_HEADER,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 120302BAE0 for ; Fri, 14 Sep 2018 18:31:59 +0000 (UTC) Received: from localhost ([::1]:52887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0sso-0002nT-Bm for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Sep 2018 14:31:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0soY-0008Oy-Pm for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0soV-0003hb-Gr for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:34 -0400 Received: from mail-eopbgr690086.outbound.protection.outlook.com ([40.107.69.86]:22784 helo=NAM04-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 1g0soV-0003fI-3c for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:31 -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=QEA38b9LOc6C6g4uM1q+iQuWsfR1YsxZh48GWa5ScLg=; b=mV2LrOXDppSg/HSxu0judtgWzjn40DkFa7AxOCrOsWOUz91yNjXr/9PY7kHlvqEP8ev590BwugS2daTAOHVvvyAmqe8NOBNNIza+kCUzUH7zz+YelZyZUFdFLinwJdfWD7lP2rLcBR+imjVexgNA8hTAJ1y3Hz00q6he+3Q36U8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from sbrijesh-desktop.amd.com (165.204.77.1) by DM6PR12MB2684.namprd12.prod.outlook.com (2603:10b6:5:4a::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Fri, 14 Sep 2018 18:27:26 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Fri, 14 Sep 2018 13:26:59 -0500 Message-Id: <1536949623-23564-5-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536949623-23564-1-git-send-email-brijesh.singh@amd.com> References: <1536949623-23564-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BYAPR01CA0001.prod.exchangelabs.com (2603:10b6:a02:80::14) To DM6PR12MB2684.namprd12.prod.outlook.com (2603:10b6:5:4a::33) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5424ebd1-ede1-46f3-b783-08d61a6fb9cf X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DM6PR12MB2684; X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 3:t7YWPr0ByM/ye/Wn563cdqM1knG8SRFWH85Pu+79qVWpAzNJkUkfwkfAdcjWI0MSpeqiTQE6b7vvW7JCOUmr+NfD1jaxC3yGo67TCmt6jj2NG/iDkQupHH0M0GJGX0uB6u5XhedC2NfHqhIdo5x1b+01xuRHeQO6Ldr/EkuYsnnWy/pIhfRxeimqxd0+twzU7ikEKzphF+HH0TJ0FTaihjS+VVBX9CcdS1ZHqpbo7NTHC51vU1n9g53j1qihlStf; 25:K+DRkGNWS7koobya3FMef50n0C1vmrVGJbxF8yXJNw9FkLP/fNcR4JMAUifj5ksjkrrzQx2XpiLxg7J34TSKxFoA2QfjLBCGKInwLE0TkiNqQLRdPtE0rJYuwM3l898pfZyVQSfWT9WffVMbfa1b2uzDH+hXNCaVPAjWAv8Lt5rnME4blTj72ymkwopNXDPMAxDCCPFDw/iLbkhpBTH6HeR1hEWFkvQb2iAH2ERwuaeFfyQy7UQ+bBDNI/zg17VgRALo7La1Vxqz5D2fpLxxQRdGj8bptHysQmODKOqMFU5d1NJOTauVsifpLWB5wlMEi3gYQzy9HNUA+yNkzJbLmw==; 31:SmhjO4mnXS9L6hqyFn9t0vCNfiXuP/W+mi5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WDlA0jFaKmZPs2ue3NeLJxmOZ3R2nchEpgqIW4pMBXW+De58sz2c0uFo18iDeb8/av17mpvksWmUCI02UM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158)(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699050); SRVR:DM6PR12MB2684; BCL:0; PCL:0; RULEID:; SRVR:DM6PR12MB2684; X-Forefront-PRVS: 07954CC105 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(346002)(376002)(366004)(189003)(199004)(50466002)(66066001)(48376002)(2906002)(25786009)(446003)(16586007)(6486002)(76176011)(39060400002)(7736002)(68736007)(51416003)(7696005)(305945005)(316002)(6666003)(6916009)(47776003)(53936002)(52116002)(386003)(956004)(486006)(11346002)(5660300001)(54906003)(2616005)(8676002)(478600001)(36756003)(476003)(186003)(44832011)(105586002)(2361001)(3846002)(106356001)(26005)(81166006)(14444005)(81156014)(8936002)(2351001)(53416004)(16526019)(50226002)(4326008)(97736004)(6116002)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2684; H:sbrijesh-desktop.amd.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-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR12MB2684; 23:j3pUikE+HddJNstQ0FkcPT+CxtcPvzqMBU16gftzK?= r70XcP0Zhd7HXUp8jkFVDjtvvdK7KdykdAnWTWPmj+B0vt2ICRAE9RT8fyQJ4iJNGH4y6f/czW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aiJUXDwYMKIVISGn9JheaPLqmGsrmsXkZkPfBoJBn97HK+ZGrZDEUDwzfGBek4aXmiJ8GR5Mo2mk01qg=; 7:/pMlW6HFlMnwfVUoK4lModGgHtmR1CFNY2Od3Nj54GiJlsO64Zq1X3H3+OseNOemEvpfpTDCCqrecRABS3JLeUzorD5dUIkpQxk2XD+Qz2Ns50M5QjYgdKqINjEPXXTVyLUE9tvKD79YZzsoKESIDj2moVFuajBgf9CUNlJ1OASGtnhlhiIUBiUL2WvbNXmVyk19vMA6i/OEzDBEEpK53kxjXvkPWGmlSZVTFHj7yEZqbVR+Xz+ZgHFPm7YdI3jM SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 20:viv1CuDSczL6qExmhR5+VKaVhQ2uB+h1YxnyMHv9oMk8NZWVgW4IgG6f4L4untouZpZQPBCoIDnSB2oUYjFqvJFZydlQ9k0VH5gHZrn02ks08DJ/xRStMuV3Gf16CAElllaSlFYMdEpKXQr9SkWi0fLRWhkzDPo4GS6FdHuMQIJTvDAJEjUpjWNh75hJORK/uhhomC0wJOPgLULL3iwi5axJhuqeGFcS1eEzsG5Whl2ZVV8ghb1a3F4wT9Dnljle X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2018 18:27:26.9015 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5424ebd1-ede1-46f3-b783-08d61a6fb9cf X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2684 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.86 Subject: [Qemu-devel] [PATCH v2 4/8] x86_iommu/amd: Prepare for 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: Tom Lendacky , Brijesh Singh , Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , Suravee Suthikulpanit , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Register the interrupt remapping callback and read/write ops for the amd-iommu-ir memory region. amd-iommu-ir is set to higher priority to ensure that this region won't be masked out by other memory regions. While at it, add a overlapping amd-iommu region with higher priority and update address space name to include the devfn. Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: Tom Lendacky Cc: Suravee Suthikulpanit Signed-off-by: Brijesh Singh --- hw/i386/amd_iommu.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++++--- hw/i386/amd_iommu.h | 17 ++++++- hw/i386/trace-events | 5 ++ 3 files changed, 154 insertions(+), 8 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 225825e..b15962b 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -26,6 +26,7 @@ #include "amd_iommu.h" #include "qapi/error.h" #include "qemu/error-report.h" +#include "hw/i386/apic_internal.h" #include "trace.h" /* used AMD-Vi MMIO registers */ @@ -56,6 +57,7 @@ struct AMDVIAddressSpace { uint8_t devfn; /* device function */ AMDVIState *iommu_state; /* AMDVI - one per machine */ IOMMUMemoryRegion iommu; /* Device's address translation region */ + MemoryRegion root; /* AMDVI Root memory map region */ MemoryRegion iommu_ir; /* Device's interrupt remapping region */ AddressSpace as; /* device's corresponding address space */ }; @@ -1027,10 +1029,104 @@ static IOMMUTLBEntry amdvi_translate(IOMMUMemoryRegion *iommu, hwaddr addr, return ret; } +/* Interrupt remapping for MSI/MSI-X entry */ +static int amdvi_int_remap_msi(AMDVIState *iommu, + MSIMessage *origin, + MSIMessage *translated, + uint16_t sid) +{ + assert(origin && translated); + + trace_amdvi_ir_remap_msi_req(origin->address, origin->data, sid); + + if (!iommu || !iommu->intr_enabled) { + memcpy(translated, origin, sizeof(*origin)); + goto out; + } + + if (origin->address & AMDVI_MSI_ADDR_HI_MASK) { + trace_amdvi_err("MSI address high 32 bits non-zero when " + "Interrupt Remapping enabled."); + return -AMDVI_IR_ERR; + } + + if ((origin->address & AMDVI_MSI_ADDR_LO_MASK) != APIC_DEFAULT_ADDRESS) { + trace_amdvi_err("MSI is not from IOAPIC."); + return -AMDVI_IR_ERR; + } + +out: + trace_amdvi_ir_remap_msi(origin->address, origin->data, + translated->address, translated->data); + return 0; +} + +static int amdvi_int_remap(X86IOMMUState *iommu, + MSIMessage *origin, + MSIMessage *translated, + uint16_t sid) +{ + return amdvi_int_remap_msi(AMD_IOMMU_DEVICE(iommu), origin, + translated, sid); +} + +static MemTxResult amdvi_mem_ir_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + int ret; + MSIMessage from = { 0, 0 }, to = { 0, 0 }; + uint16_t sid = AMDVI_IOAPIC_SB_DEVID; + + from.address = (uint64_t) addr + AMDVI_INT_ADDR_FIRST; + from.data = (uint32_t) value; + + trace_amdvi_mem_ir_write_req(addr, value, size); + + if (!attrs.unspecified) { + /* We have explicit Source ID */ + sid = attrs.requester_id; + } + + ret = amdvi_int_remap_msi(opaque, &from, &to, sid); + if (ret < 0) { + /* TODO: report error */ + /* Drop the interrupt */ + return MEMTX_ERROR; + } + + apic_get_class()->send_msi(&to); + + trace_amdvi_mem_ir_write(to.address, to.data); + return MEMTX_OK; +} + +static MemTxResult amdvi_mem_ir_read(void *opaque, hwaddr addr, + uint64_t *data, unsigned size, + MemTxAttrs attrs) +{ + return MEMTX_OK; +} + +static const MemoryRegionOps amdvi_ir_ops = { + .read_with_attrs = amdvi_mem_ir_read, + .write_with_attrs = amdvi_mem_ir_write, + .endianness = DEVICE_LITTLE_ENDIAN, + .impl = { + .min_access_size = 4, + .max_access_size = 4, + }, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + } +}; + static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) { + char name[128]; AMDVIState *s = opaque; - AMDVIAddressSpace **iommu_as; + AMDVIAddressSpace **iommu_as, *amdvi_dev_as; int bus_num = pci_bus_num(bus); iommu_as = s->address_spaces[bus_num]; @@ -1043,19 +1139,46 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) /* set up AMD-Vi region */ if (!iommu_as[devfn]) { + snprintf(name, sizeof(name), "amd_iommu_devfn_%d", devfn); + iommu_as[devfn] = g_malloc0(sizeof(AMDVIAddressSpace)); iommu_as[devfn]->bus_num = (uint8_t)bus_num; iommu_as[devfn]->devfn = (uint8_t)devfn; iommu_as[devfn]->iommu_state = s; - memory_region_init_iommu(&iommu_as[devfn]->iommu, - sizeof(iommu_as[devfn]->iommu), + amdvi_dev_as = iommu_as[devfn]; + + /* + * Memory region relationships looks like (Address range shows + * only lower 32 bits to make it short in length...): + * + * |-----------------+-------------------+----------| + * | Name | Address range | Priority | + * |-----------------+-------------------+----------+ + * | amdvi_root | 00000000-ffffffff | 0 | + * | amdvi_iommu | 00000000-ffffffff | 1 | + * | amdvi_iommu_ir | fee00000-feefffff | 64 | + * |-----------------+-------------------+----------| + */ + memory_region_init_iommu(&amdvi_dev_as->iommu, + sizeof(amdvi_dev_as->iommu), TYPE_AMD_IOMMU_MEMORY_REGION, OBJECT(s), "amd-iommu", UINT64_MAX); - address_space_init(&iommu_as[devfn]->as, - MEMORY_REGION(&iommu_as[devfn]->iommu), - "amd-iommu"); + memory_region_init(&amdvi_dev_as->root, OBJECT(s), + "amdvi_root", UINT64_MAX); + address_space_init(&amdvi_dev_as->as, &amdvi_dev_as->root, name); + memory_region_init_io(&amdvi_dev_as->iommu_ir, OBJECT(s), + &amdvi_ir_ops, s, "amd-iommu-ir", + AMDVI_INT_ADDR_SIZE); + memory_region_add_subregion_overlap(&amdvi_dev_as->root, + AMDVI_INT_ADDR_FIRST, + &amdvi_dev_as->iommu_ir, + 64); + memory_region_add_subregion_overlap(&amdvi_dev_as->root, 0, + MEMORY_REGION(&amdvi_dev_as->iommu), + 1); + } return &iommu_as[devfn]->as; } @@ -1173,6 +1296,10 @@ static void amdvi_realize(DeviceState *dev, Error **err) return; } + /* Pseudo address space under root PCI bus. */ + pcms->ioapic_as = amdvi_host_dma_iommu(bus, s, AMDVI_IOAPIC_SB_DEVID); + s->intr_enabled = x86_iommu->intr_supported; + /* set up MMIO */ memory_region_init_io(&s->mmio, OBJECT(s), &mmio_mem_ops, s, "amdvi-mmio", AMDVI_MMIO_SIZE); @@ -1206,6 +1333,7 @@ static void amdvi_class_init(ObjectClass *klass, void* data) dc->vmsd = &vmstate_amdvi; dc->hotpluggable = false; dc_class->realize = amdvi_realize; + dc_class->int_remap = amdvi_int_remap; /* Supported by the pc-q35-* machine types */ dc->user_creatable = true; } diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 8740305..71ff3c1 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -206,8 +206,18 @@ #define AMDVI_COMMAND_SIZE 16 -#define AMDVI_INT_ADDR_FIRST 0xfee00000 -#define AMDVI_INT_ADDR_LAST 0xfeefffff +#define AMDVI_INT_ADDR_FIRST 0xfee00000 +#define AMDVI_INT_ADDR_LAST 0xfeefffff +#define AMDVI_INT_ADDR_SIZE (AMDVI_INT_ADDR_LAST - AMDVI_INT_ADDR_FIRST + 1) +#define AMDVI_MSI_ADDR_HI_MASK (0xffffffff00000000ULL) +#define AMDVI_MSI_ADDR_LO_MASK (0x00000000ffffffffULL) + +/* SB IOAPIC is always on this device in AMD systems */ +#define AMDVI_IOAPIC_SB_DEVID PCI_BUILD_BDF(0, PCI_DEVFN(0x14, 0)) + +/* Interrupt remapping errors */ +#define AMDVI_IR_ERR 0x1 + #define TYPE_AMD_IOMMU_DEVICE "amd-iommu" #define AMD_IOMMU_DEVICE(obj)\ @@ -278,6 +288,9 @@ typedef struct AMDVIState { /* IOTLB */ GHashTable *iotlb; + + /* Interrupt remapping */ + bool intr_enabled; } AMDVIState; #endif diff --git a/hw/i386/trace-events b/hw/i386/trace-events index 9e6fc4d..41d533c 100644 --- a/hw/i386/trace-events +++ b/hw/i386/trace-events @@ -101,6 +101,11 @@ amdvi_mode_invalid(uint8_t level, uint64_t addr)"error: translation level 0x%"PR amdvi_page_fault(uint64_t addr) "error: page fault accessing guest physical address 0x%"PRIx64 amdvi_iotlb_hit(uint8_t bus, uint8_t slot, uint8_t func, uint64_t addr, uint64_t txaddr) "hit iotlb devid %02x:%02x.%x gpa 0x%"PRIx64" hpa 0x%"PRIx64 amdvi_translation_result(uint8_t bus, uint8_t slot, uint8_t func, uint64_t addr, uint64_t txaddr) "devid: %02x:%02x.%x gpa 0x%"PRIx64" hpa 0x%"PRIx64 +amdvi_mem_ir_write_req(uint64_t addr, uint64_t val, uint32_t size) "addr 0x%"PRIx64" data 0x%"PRIx64" size 0x%"PRIx32 +amdvi_mem_ir_write(uint64_t addr, uint64_t val) "addr 0x%"PRIx64" data 0x%"PRIx64 +amdvi_ir_remap_msi_req(uint64_t addr, uint64_t data, uint8_t devid) "addr 0x%"PRIx64" data 0x%"PRIx64" devid 0x%"PRIx8 +amdvi_ir_remap_msi(uint64_t addr, uint64_t data, uint64_t addr2, uint64_t data2) "(addr 0x%"PRIx64", data 0x%"PRIx64") -> (addr 0x%"PRIx64", data 0x%"PRIx64")" +amdvi_err(const char *str) "%s" # hw/i386/vmport.c vmport_register(unsigned char command, void *func, void *opaque) "command: 0x%02x func: %p opaque: %p" From patchwork Fri Sep 14 18:27: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: 10601151 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 B9ACF14BD for ; Fri, 14 Sep 2018 18:34:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A589F2BAFB for ; Fri, 14 Sep 2018 18:34:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9996E2BB00; Fri, 14 Sep 2018 18:34:31 +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=BAD_ENC_HEADER,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 B73C62BAFB for ; Fri, 14 Sep 2018 18:34:30 +0000 (UTC) Received: from localhost ([::1]:52898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0svF-0004IQ-NF for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Sep 2018 14:34:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0soY-0008P0-QQ for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0soW-0003iS-06 for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:34 -0400 Received: from mail-eopbgr690086.outbound.protection.outlook.com ([40.107.69.86]:22784 helo=NAM04-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 1g0soV-0003fI-OT for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:31 -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=jcqhKYHTzXz8P1+bDLFY7eNhD5t8+xBKPT8S7d67RF4=; b=VBeD5zxuIlYwDEpUGkeymYHvPBgenFvo+oi6zdTR7R2h/TyLq99GIwx7YTSE7uPf2TT44JXY8k1CVKAlR1IOF7hhjQOhSIlpwNOzIeybDfNPrtGGMxFNPzxTdhYx1MtnkS9OtVFg1kg13dCqsnITIV2Kaba8LOp6CeYxIDaMOgw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from sbrijesh-desktop.amd.com (165.204.77.1) by DM6PR12MB2684.namprd12.prod.outlook.com (2603:10b6:5:4a::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Fri, 14 Sep 2018 18:27:28 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Fri, 14 Sep 2018 13:27:00 -0500 Message-Id: <1536949623-23564-6-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536949623-23564-1-git-send-email-brijesh.singh@amd.com> References: <1536949623-23564-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BYAPR01CA0001.prod.exchangelabs.com (2603:10b6:a02:80::14) To DM6PR12MB2684.namprd12.prod.outlook.com (2603:10b6:5:4a::33) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eeb691ff-703c-4e45-a6ab-08d61a6fbacd X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DM6PR12MB2684; X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 3:uONkOseDH/uUaYeHJEYwXYeYBWD+m9j2PZIyVt0yqGzFEXsR28d6br+kH81ctjiOX6tyllSMnLSs7Id0BgTC+XJkqtwHIflOZZr22pSsEy4xiHILzQLFlSXpDJjjz14lcUsGbLS57OppvP2Ysv4d7l7tceYBLraO0SHp/AYgVnTYkYqwIRtzNJqmcrC42Pnda3/YJ/CQG4QaOEFp8pddSogvIu39RZpLbu2HymqNcixreEO0N3Vt5Do2d4f1Zr56; 25:F/HZp0a0wqH0sLtPHQIm+GCYn6A7LcGwDY/UgOjgG0qZJkOm47LUplqIkjsr4vvOSQ2yVQ6P29Y98WVGYI0nwguEV+ZP0eVEFg6noFrg6JoOaBAjVVdo4u5paU1UUKLduNg+bA2u2p+TFv2adCDXX4Q7O+7VXkp+nFQ5djthCVaA6pyKEVnqbKtbMe78RrihPUdHUDwrhR9nlRi76kmd+hpUwRgB7UCjdB+xDJPUJfLb3jB4/sVx48QJoh11TeDTBB3DGQPFXDJqsJw1aBUfB6SOes5JICn4wNnIQq5Dd+OLlL/RjVlmg4xPhIsdUve7xicVaQQ8xwXdmQmKv+3pXQ==; 31:ccyEri8V51RN8KPYqIPd8p3HojKV1aakQsWXVNdDrnPjdqyMRiVCxzCzusTInpTNDNxK2lAK4R5cNG1+J2DVMuSOu45nrgoIhropmxMTDiivG8ECTqH6aXOznujpEi8mmY4HUsrI8o8J6yX0ZaRg+mGTT8rQ25lD6hLfqBs4CL1kOUy/deRe2qKgsq1J0FWMJ6ZMUydrQrIgrIpM40I8GpXh8LY72w0FFG6gJQPWH4o= X-MS-TrafficTypeDiagnostic: DM6PR12MB2684: X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 20:RmxhhFz3njgBMqwlzfPWu1F5XUs5bGLAMYCnHLJWj6xn79+JVjHvVjABb3JtESbALw037L3yxznqw2tTVBq/vOcdJa1Ft9MzDKx2a6zFjm9/yfjAFY41qRbudxBdYVNS6OqyWqBUJokCcNCUFaEyne+HgjHC6Ah+EvmuQEUGFNZ6Nh/ZomERbNW/1vBUOiFjr/KQcTY8+LgRYQ7qhcuvLmmsCV24YKJBlnjkVdDQWlhamB7XsEp0JFQ7nop6pn4AUdnN0dDfmUPR5FMdJnvckFZkXyYVQ3iRNgb2qh4MS8Vm0/FExSjZm3YdbYkKCNUjrWJq3SKtqYxmAneXFUGxwPbtza4bif6CagubdehYCX35yJcxnedeV+pnbFgF8WLkuTlKS+pXq8+mydfQEZX96CWeM/FxU5QTtatrhBHpubd86+4Cp0WqzIjTl6AQ/CjiG0poJYm4z9ShuLUmNZmukLMUdbryLfwF2z5SCM3DDQgkYCajzaanYkTGK41DXYJd; 4:Orm+OCW/BqwcljClmKLXIBm6F3pu5eW8MB3BHJipDt7VoLbDS3BvzIiH9YeabSp5tsDNfr1WPbe4aSdT3Yy4kLdKX36TxZ/S+r3Y5bLHu46kdnMd14tBWl+TuTLA3f0jgmk88cZf3+2QYqkBM7RsMLp1z8/RC7bflfG8xA5zxnPjMdoIrHo/QCguUTNgQmCeQ956vEpsEcLmWQEo1m+Ym5MA4ve4XYad/qy8OGbQjNQA4ZVPN7IdmyEynNn9zqEkCLUuacQ1KokgtkcNcAfKwykMQ5RS6j0RlVhQuA1JLy67Q+SYfUgLH0p8bD1HHW0skBPhUiUUbbUHnPZ5mR395SefSnVBnYhsN4aJPUZfiHk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158)(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699050); SRVR:DM6PR12MB2684; BCL:0; PCL:0; RULEID:; SRVR:DM6PR12MB2684; X-Forefront-PRVS: 07954CC105 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(346002)(376002)(366004)(189003)(199004)(50466002)(66066001)(48376002)(2906002)(25786009)(446003)(16586007)(6486002)(76176011)(39060400002)(7736002)(68736007)(51416003)(7696005)(305945005)(316002)(6666003)(6916009)(47776003)(53936002)(52116002)(386003)(956004)(486006)(11346002)(5660300001)(54906003)(2616005)(8676002)(478600001)(36756003)(476003)(186003)(44832011)(105586002)(2361001)(3846002)(106356001)(26005)(81166006)(14444005)(81156014)(8936002)(2351001)(53416004)(16526019)(50226002)(4326008)(97736004)(6116002)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2684; H:sbrijesh-desktop.amd.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-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR12MB2684; 23:qW6TvdJaVmOrHRLNg5NN2SiMbDYr31fvbA8+bU1tS?= JbFdTMfJf8MfbB1OAAWjJMubPFMDzpU6O6Ws8JqNyG8SinCwtp+eXfuJw/pp9hL6JHSPYc9/wGYIaX/eV0DxPPci2eu8Ni9uHbUwTOXSHAPgzD+d7kUNxDSdYj1OXzKWA/DV3S4cWhBIQ89gkA8BkFcqpH4iAH+O/BIpApstyVRdRMUhpe+UU51fRJqfzXVkDwHlZhLhmQYgrxg8tyYY9ahXcjP7PjF4lAe+pc0UYTM7DDvoKax9prr/QngHHSD7RqI/O0oKsurez7iz3MVpWvbIp/7fDlT/4iN8/XydQwiGWXlcXMHE8nDG2dpAulwYmIYSyi3nGg0AugErPmA6EBJ2QBxVLsVcNS7NWsbhogl8PbcVtoReIYiqG/KPuI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zvO5MYeEOHKGECdf6deVxtZKjDh0URG032kHXmqJZqY537Qo3q3 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 20:P6xjzW1ZjkNtxopsvhWIWx9HFw65FM4qt6N17w3oTaeRHSKqNVw1pS6/JRhuCQSHARxen5RGtmjrjU+pVOjngvaxAxVQuSx/rCDlFHDgCUIfgG8V3KMluFNrzBFGX7DVx24wqhV3bxNWdYWRoQxnCuTfULgrWFOK9cYEnprHQz8/OZ7ieaoUVFEN233rEmobs1aOnZYb0RE7S0JzFYEkL4ESHANyoRAW/+kHGs6o/B+H+KGIdBGXMYSErcPeBcp0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2018 18:27:28.5096 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eeb691ff-703c-4e45-a6ab-08d61a6fbacd X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2684 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.86 Subject: [Qemu-devel] [PATCH v2 5/8] x86_iommu/amd: Add interrupt remap support when VAPIC is not enabled 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: Tom Lendacky , Brijesh Singh , Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , Suravee Suthikulpanit , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Emulate the interrupt remapping support when guest virtual APIC is not enabled. For more info Refer: AMD IOMMU spec Rev 3.0 - section 2.2.5.1 When VAPIC is not enabled, it uses interrupt remapping as defined in Table 20 and Figure 15 from IOMMU spec. Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: Tom Lendacky Cc: Suravee Suthikulpanit Signed-off-by: Brijesh Singh --- hw/i386/amd_iommu.c | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++- hw/i386/amd_iommu.h | 46 ++++++++++++- hw/i386/trace-events | 7 ++ 3 files changed, 240 insertions(+), 2 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index b15962b..9c8e4de 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -28,6 +28,8 @@ #include "qemu/error-report.h" #include "hw/i386/apic_internal.h" #include "trace.h" +#include "cpu.h" +#include "hw/i386/apic-msidef.h" /* used AMD-Vi MMIO registers */ const char *amdvi_mmio_low[] = { @@ -1029,17 +1031,144 @@ static IOMMUTLBEntry amdvi_translate(IOMMUMemoryRegion *iommu, hwaddr addr, return ret; } +static int amdvi_get_irte(AMDVIState *s, MSIMessage *origin, uint64_t *dte, + union irte *irte, uint16_t devid) +{ + uint64_t irte_root, offset; + + irte_root = dte[2] & AMDVI_IR_PHYS_ADDR_MASK; + offset = (origin->data & AMDVI_IRTE_OFFSET) << 2; + + trace_amdvi_ir_irte(irte_root, offset); + + if (dma_memory_read(&address_space_memory, irte_root + offset, + irte, sizeof(*irte))) { + trace_amdvi_ir_err("failed to get irte"); + return -AMDVI_IR_GET_IRTE; + } + + trace_amdvi_ir_irte_val(irte->val); + + return 0; +} + +static int amdvi_int_remap_legacy(AMDVIState *iommu, + MSIMessage *origin, + MSIMessage *translated, + uint64_t *dte, + X86IOMMUIrq *irq, + uint16_t sid) +{ + int ret; + union irte irte; + + /* get interrupt remapping table */ + ret = amdvi_get_irte(iommu, origin, dte, &irte, sid); + if (ret < 0) { + return ret; + } + + if (!irte.fields.valid) { + trace_amdvi_ir_target_abort("RemapEn is disabled"); + return -AMDVI_IR_TARGET_ABORT; + } + + if (irte.fields.guest_mode) { + trace_amdvi_ir_target_abort("guest mode is not zero"); + return -AMDVI_IR_TARGET_ABORT; + } + + if (irte.fields.int_type > AMDVI_IOAPIC_INT_TYPE_ARBITRATED) { + trace_amdvi_ir_target_abort("reserved int_type"); + return -AMDVI_IR_TARGET_ABORT; + } + + irq->delivery_mode = irte.fields.int_type; + irq->vector = irte.fields.vector; + irq->dest_mode = irte.fields.dm; + irq->redir_hint = irte.fields.rq_eoi; + irq->dest = irte.fields.destination; + + return 0; +} + +static int __amdvi_int_remap_msi(AMDVIState *iommu, + MSIMessage *origin, + MSIMessage *translated, + uint64_t *dte, + X86IOMMUIrq *irq, + uint16_t sid) +{ + uint8_t int_ctl; + + int_ctl = (dte[2] >> AMDVI_IR_INTCTL_SHIFT) & 3; + trace_amdvi_ir_intctl(int_ctl); + + switch (int_ctl) { + case AMDVI_IR_INTCTL_PASS: + memcpy(translated, origin, sizeof(*origin)); + return 0; + case AMDVI_IR_INTCTL_REMAP: + break; + case AMDVI_IR_INTCTL_ABORT: + trace_amdvi_ir_target_abort("int_ctl abort"); + return -AMDVI_IR_TARGET_ABORT; + default: + trace_amdvi_ir_target_abort("int_ctl reserved"); + return -AMDVI_IR_TARGET_ABORT; + } + + return amdvi_int_remap_legacy(iommu, origin, translated, dte, irq, sid); +} + +static bool amdvi_validate_int_reamp(AMDVIState *s, uint64_t *dte) +{ + /* Check if IR is enabled in DTE */ + if (!(dte[2] & AMDVI_IR_REMAP_ENABLE)) { + return false; + } + + /* validate that we are configure with intremap=on */ + if (!s->intr_enabled) { + error_report("Interrupt remapping is enabled in the guest but " + "not in the host. Use intremap=on to enable interrupt " + "remapping in amd-iommu."); + exit(1); + } + + return true; +} + /* Interrupt remapping for MSI/MSI-X entry */ static int amdvi_int_remap_msi(AMDVIState *iommu, MSIMessage *origin, MSIMessage *translated, uint16_t sid) { + int ret = 0; + uint64_t pass = 0; + uint64_t dte[4] = { 0 }; + X86IOMMUIrq irq = { 0 }; + uint8_t dest_mode, delivery_mode; + assert(origin && translated); + /* + * When IOMMU is enabled, interrupt remap request will come either from + * IO-APIC or PCI device. If interrupt is from PCI device then it will + * have a valid requester id but if the interrupt is from IO-APIC + * then requester id will be invalid. + */ + if (sid == X86_IOMMU_SID_INVALID) { + sid = AMDVI_IOAPIC_SB_DEVID; + } + trace_amdvi_ir_remap_msi_req(origin->address, origin->data, sid); - if (!iommu || !iommu->intr_enabled) { + /* verify that interrupt remapping is enabled before going further. */ + if (!iommu || + !amdvi_get_dte(iommu, sid, dte) || + !amdvi_validate_int_reamp(iommu, dte)) { memcpy(translated, origin, sizeof(*origin)); goto out; } @@ -1055,10 +1184,68 @@ static int amdvi_int_remap_msi(AMDVIState *iommu, return -AMDVI_IR_ERR; } + delivery_mode = (origin->data >> MSI_DATA_DELIVERY_MODE_SHIFT) & 7; + + switch (delivery_mode) { + case AMDVI_IOAPIC_INT_TYPE_FIXED: + case AMDVI_IOAPIC_INT_TYPE_ARBITRATED: + trace_amdvi_ir_delivery_mode("fixed/arbitrated"); + ret = __amdvi_int_remap_msi(iommu, origin, translated, dte, &irq, sid); + if (ret < 0) { + goto remap_fail; + } else { + /* Translate IRQ to MSI messages */ + x86_iommu_irq_to_msi_message(&irq, translated); + goto out; + } + break; + case AMDVI_IOAPIC_INT_TYPE_SMI: + error_report("SMI is not supported!"); + ret = -AMDVI_IR_ERR; + case AMDVI_IOAPIC_INT_TYPE_NMI: + pass = dte[3] & AMDVI_DEV_NMI_PASS_MASK; + trace_amdvi_ir_delivery_mode("nmi"); + break; + case AMDVI_IOAPIC_INT_TYPE_INIT: + pass = dte[3] & AMDVI_DEV_INT_PASS_MASK; + trace_amdvi_ir_delivery_mode("init"); + break; + case AMDVI_IOAPIC_INT_TYPE_EINT: + pass = dte[3] & AMDVI_DEV_EINT_PASS_MASK; + trace_amdvi_ir_delivery_mode("eint"); + break; + default: + trace_amdvi_ir_delivery_mode("unsupported delivery_mode"); + ret = -AMDVI_IR_ERR; + break; + } + + if (ret < 0) { + goto remap_fail; + } + + /* dest_mode 1 is valid for fixed and arbitrated interrupts only */ + dest_mode = (origin->address >> MSI_ADDR_DEST_MODE_SHIFT) & 1; + if (dest_mode) { + trace_amdvi_ir_err("invalid dest_mode"); + goto remap_fail; + } + + if (pass) { + memcpy(translated, origin, sizeof(*origin)); + } else { + /* pass through is not enabled */ + trace_amdvi_ir_err("passthrough is not enabled"); + goto remap_fail; + } + out: trace_amdvi_ir_remap_msi(origin->address, origin->data, translated->address, translated->data); return 0; + +remap_fail: + return -AMDVI_IR_TARGET_ABORT; } static int amdvi_int_remap(X86IOMMUState *iommu, diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 71ff3c1..bd27cd2 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -217,7 +217,51 @@ /* Interrupt remapping errors */ #define AMDVI_IR_ERR 0x1 - +#define AMDVI_IR_GET_IRTE 0x2 +#define AMDVI_IR_TARGET_ABORT 0x3 + +/* Interrupt remapping */ +#define AMDVI_IR_REMAP_ENABLE 1ULL +#define AMDVI_IR_INTCTL_SHIFT 60 +#define AMDVI_IR_INTCTL_ABORT 0 +#define AMDVI_IR_INTCTL_PASS 1 +#define AMDVI_IR_INTCTL_REMAP 2 + +#define AMDVI_IR_PHYS_ADDR_MASK (((1ULL << 45) - 1) << 6) + +/* MSI data 10:0 bits (section 2.2.5.1 Fig 14) */ +#define AMDVI_IRTE_OFFSET 0x7ff + +/* Delivery mode of MSI data (same as IOAPIC deilver mode encoding) */ +#define AMDVI_IOAPIC_INT_TYPE_FIXED 0x0 +#define AMDVI_IOAPIC_INT_TYPE_ARBITRATED 0x1 +#define AMDVI_IOAPIC_INT_TYPE_SMI 0x2 +#define AMDVI_IOAPIC_INT_TYPE_NMI 0x4 +#define AMDVI_IOAPIC_INT_TYPE_INIT 0x5 +#define AMDVI_IOAPIC_INT_TYPE_EINT 0x7 + +/* Pass through interrupt */ +#define AMDVI_DEV_INT_PASS_MASK (1UL << 56) +#define AMDVI_DEV_EINT_PASS_MASK (1UL << 57) +#define AMDVI_DEV_NMI_PASS_MASK (1UL << 58) +#define AMDVI_DEV_LINT0_PASS_MASK (1UL << 62) +#define AMDVI_DEV_LINT1_PASS_MASK (1UL << 63) + +/* Interrupt remapping table fields (Guest VAPIC not enabled) */ +union irte { + uint32_t val; + struct { + uint32_t valid:1, + no_fault:1, + int_type:3, + rq_eoi:1, + dm:1, + guest_mode:1, + destination:8, + vector:8, + rsvd:8; + } fields; +}; #define TYPE_AMD_IOMMU_DEVICE "amd-iommu" #define AMD_IOMMU_DEVICE(obj)\ diff --git a/hw/i386/trace-events b/hw/i386/trace-events index 41d533c..98150c9 100644 --- a/hw/i386/trace-events +++ b/hw/i386/trace-events @@ -106,6 +106,13 @@ amdvi_mem_ir_write(uint64_t addr, uint64_t val) "addr 0x%"PRIx64" data 0x%"PRIx6 amdvi_ir_remap_msi_req(uint64_t addr, uint64_t data, uint8_t devid) "addr 0x%"PRIx64" data 0x%"PRIx64" devid 0x%"PRIx8 amdvi_ir_remap_msi(uint64_t addr, uint64_t data, uint64_t addr2, uint64_t data2) "(addr 0x%"PRIx64", data 0x%"PRIx64") -> (addr 0x%"PRIx64", data 0x%"PRIx64")" amdvi_err(const char *str) "%s" +amdvi_ir_irte(uint64_t addr, uint64_t data) "addr 0x%"PRIx64" offset 0x%"PRIx64 +amdvi_ir_irte_val(uint32_t data) "data 0x%"PRIx32 +amdvi_ir_err(const char *str) "%s" +amdvi_ir_intctl(uint8_t val) "int_ctl 0x%"PRIx8 +amdvi_ir_target_abort(const char *str) "%s" +amdvi_ir_delivery_mode(const char *str) "%s" +amdvi_ir_generate_msi_message(uint8_t vector, uint8_t delivery_mode, uint8_t dest_mode, uint8_t dest, uint8_t rh) "vector %d delivery-mode %d dest-mode %d dest-id %d rh %d" # hw/i386/vmport.c vmport_register(unsigned char command, void *func, void *opaque) "command: 0x%02x func: %p opaque: %p" From patchwork Fri Sep 14 18:27:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10601153 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 EF51814BD for ; Fri, 14 Sep 2018 18:36:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA4682BAFB for ; Fri, 14 Sep 2018 18:36:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB9DF2BB01; Fri, 14 Sep 2018 18:36:14 +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=BAD_ENC_HEADER,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 4E6972BAFB for ; Fri, 14 Sep 2018 18:36:14 +0000 (UTC) Received: from localhost ([::1]:52911 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0swv-0005O5-KJ for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Sep 2018 14:36:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0sob-0008RG-QW for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0soY-0003jX-GW for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:37 -0400 Received: from mail-eopbgr690078.outbound.protection.outlook.com ([40.107.69.78]:6062 helo=NAM04-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 1g0soY-0003it-5t for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:34 -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=KHS+kQZb8b/UljuhQE5VBDdMqEpB1onjd/06AEtkCiI=; b=Zx1XJXuJKjEHkIqr06qG4TCDY6QsovYehYXPgmEJAaL6puAxPOjEIToBbzUJWTFh1eNBRmXdEHa1DYQ3qaX/v/AGUy0OKpZTamScw/hMuF0Y0aoOiV+LxrvE3NYCO0j28O32FZ8F8d7HY39ii3TGygBmGtoKF6xfFIAM0akpN/E= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from sbrijesh-desktop.amd.com (165.204.77.1) by DM6PR12MB2684.namprd12.prod.outlook.com (2603:10b6:5:4a::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Fri, 14 Sep 2018 18:27:30 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Fri, 14 Sep 2018 13:27:01 -0500 Message-Id: <1536949623-23564-7-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536949623-23564-1-git-send-email-brijesh.singh@amd.com> References: <1536949623-23564-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BYAPR01CA0001.prod.exchangelabs.com (2603:10b6:a02:80::14) To DM6PR12MB2684.namprd12.prod.outlook.com (2603:10b6:5:4a::33) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4f4f9ecd-cbe0-4e52-1e35-08d61a6fbbc2 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DM6PR12MB2684; X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 3:2pC730viTexV3g7dBqxqS2FA8qTJ/cRki5oHKH840BuV1XRsfbbLqmYadfLP52r/hxucmP5h2fmvS2Waz88MP8xV8PFeg4Q35hLN/aYk5tF7fi1MWrMhWFzNtu/DuFvWa06dAY77uNbGBI/0iiG4scdBYHii21j/AyfXTXHWmWTqW8wVE8c1o97xns3/VGYNRRMysd0Gd8bCT7Rgwj4BVE0mQydD7NiX8cmRUTMaQh+8Gid0BJPUgQpdbLZdBgu4; 25:z/fQQevWdGT5q5str+KXMc1JtRemrzNF09L2f8loSjK0CKYd22RvkxP+8ZlntsZkqXZnp6yMDJddU28QrVgq1wkr7tuLBez/e4gowJMy/MuniDWQNV8LU7GLai8lKmqYeqJCJZgyI/Deksrj4KzKz/LhN6gbJu+3JNSQ0oZb4vgb1spK0N1iMTmo5sII9az54yKSvgV1X8C4BdeL67SuGSBBdoaYvx5S4+osnG/afQfNHxPwWWK+eyFMrVKjvI0pcTN7gChqyRHAfEYxU3YENMWjR1wnfJA0dDFI8NQTQ02n3qANjJWWfYfFMVOoHPPsGySEUC5/WF67ftGkAZktYg==; 31:4KVgQANfCr7de18PtlglimccSiirGWntskdytSmVYRy53+7FqQgVZymds4zM/Bnv94bfsC3JHakv5eblzn/Dvakf+qlfu346YPjrTPKz2hfEWjiRsUeO9pHoo6WzwzpFbUj3t3aEJ3aGFqmieClpY5F5F7PBW0C7BR1ngpnvusmLrl2L6autHHnuqxS4ZAKf4BCXrX8HA8+7/fOMLovTwKOmzu7/ivUCJAQK0OCyAYo= X-MS-TrafficTypeDiagnostic: DM6PR12MB2684: X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 20:30LGIYj0F7PkDo/W8GF++MSSDIXK/7N/Y4VDBa5pIVMaw6roB0IfBMy2oAaUCBfkjSIL84pQx4kfPGvF8CBymRGdf/DeYjk+PXsHm2rTrDGBpwF2W7wCk5DAJc0VGaJD/k/laXbb7wYkbg/t/Jjq9A1Bbn5ZlerO9yHC9codKMGM7ItgJu4OSipnozFVO6mzs+dPIRRM3LeleUfld/Jz86U4BhilPRePDqangeNaMdFvwjZwmV6Qz7o1LE5BfxPAmQcN/mOg9U1DZaNBLkorc57SkC3hPDXvxMNvyaZ3qz5jcEQmK7TLHSE84Fa6h3CZkNNc8h7k4b1XOqpC2TeYIPqGU7BKsvTdzU3ExWvOhElLXtz6Za9oqPE02MycxlHiAtesq4Ffrn14jSeryi+OqhoabUmVhafS6vqDMBut5Wngg0FO8bvlpcafKB8OpJo79UnbvQ2gO3/kjIAMhAr8og39ig61yTTIkogdKDE8+m01u/twhuAHC831HGXoaX1i; 4:9ZXx76+KwwdUBdSVWR4cU0msRM7wgT908GMkeR4lI35QKkULGPlTL5Dd7OH5auTcyCfr4E7Mf4zQOlZDxBfzdB2MTzJS1SCGURXruelrFiyrFBMk76IG09JHyNNuKoGy0F1bB+ewPvAzF+3RL/bKFf/aNLxtH0CaAiICvUWXP5Knql/WvBmM+thJJ+9Hj7VdGe8BPLWpmvmAQL1Pj7LbzG8yq5TUjr4f7TIyQCNivOWfwQID2xLpkPYG7nJLmKIFkuqhnDRoF53l5TKjCvUyT3jnqRLzPAHjq+S68pVvKmjPUBkAqNQrJtZn7y5lufBo31pU7ffmevBd5xvDaV6peE/oJxYBj9stKYW19RLZPrA= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158)(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699050); SRVR:DM6PR12MB2684; BCL:0; PCL:0; RULEID:; SRVR:DM6PR12MB2684; X-Forefront-PRVS: 07954CC105 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(396003)(136003)(39860400002)(346002)(376002)(366004)(189003)(199004)(50466002)(66066001)(48376002)(6306002)(2906002)(25786009)(446003)(16586007)(6486002)(76176011)(39060400002)(7736002)(68736007)(51416003)(7696005)(305945005)(316002)(6666003)(966005)(6916009)(47776003)(53936002)(52116002)(386003)(956004)(486006)(11346002)(5660300001)(54906003)(2616005)(8676002)(478600001)(36756003)(476003)(186003)(44832011)(105586002)(2361001)(3846002)(106356001)(26005)(81166006)(14444005)(81156014)(8936002)(2351001)(53416004)(16526019)(50226002)(4326008)(97736004)(6116002)(86362001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2684; H:sbrijesh-desktop.amd.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-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR12MB2684; 23:1zxPOMGZke28cQVSQmgpbD0DGJ3U9Su+Y5QZ2phRY?= 3NREF9bx88ZSxjgJt+rzukxyeg2dMPSUz+suhsmSxkkaRHGREvek/MvTRerDCgyTmkYaR1r4RfAGxSn4KCtdMfLr1wRqOSB6SO/IQ4+T2OwuBLKrcFkmcf44e7ImximOEiFw5EUauVJYeZDorEQKa5FMB67pynoho9p3BqIKDU+xMNSWC6gjYe2sdO/M18Y2aTfufLlUrF4C2uN8aP+8qUbQY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YlvZkKc3txOWD8l3pQTJzEl/1inYdQ3EwqYyfNyuh6s50FI4zdeeh0C8IPNVnY1cX1S/s=; 7:F9VPw36g6+Luq4pzDaE/jymW2aU4o1HWP/uGnOmsPPMY11yB/9glQetMrem/QwC2RB86eZLgW6noIjwO/uu9R6zzkAYWNyGz+XUwvKwceDpgoOaaPjrgPZNmWd3PDq/wWZ8KkJUaW3YI7PSc+E5c6rMEhehFykNeA4GgcNcG3GOi+xoS/5/+X+gM+XXwgzrDueFyZ9TeaYBROC37QoLU0o9d6yDKLwJlbn0e9utezqBFTvlBFfvGvr9wDS7uWiRG SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 20:MMXyf9Snu0cfcvOZoGERP6aDlj+KlJTnnLMnk3YAMJ7zujKweXXDsBLY0dExYbOBl76pviMPPa+pCRSjsdvrrxroMP8n7R09HXFLGs2PnFiW5qR5+SND50iXSjzf2RADZhJS3LkTak0lcIPYwsjLYMDPDcdW0MPvTKcWl7msp0oMj/3TeIcEyRlk4gIBcxr39fCqaXMqonDQVgMJYFg3t1VvEhguZwhsiMke+rQ9LXS8LL4+ywjHsy/lWxQpr/tx X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2018 18:27:30.1428 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4f4f9ecd-cbe0-4e52-1e35-08d61a6fbbc2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2684 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.69.78 Subject: [Qemu-devel] [PATCH v2 6/8] 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: Tom Lendacky , Brijesh Singh , Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , Suravee Suthikulpanit , 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: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: Tom Lendacky Cc: Suravee Suthikulpanit --- hw/i386/acpi-build.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index e1ee8ae..0a19e25 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2516,9 +2516,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()); @@ -2540,8 +2543,16 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker) (1UL << 6) | /* PrefSup */ (1UL << 7), /* PPRSup */ 1); + + /* + * When interrupt remapping is enabled, we add a special IVHD device + * for type IO-APIC. + */ + if (s->intr_enabled) { + 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 */ @@ -2565,6 +2576,22 @@ 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 + * + * When interrupt remapping is enabled Linux IOMMU driver checks for + * the special IVHD device (type IO-APIC). + * See Linux kernel commit 'c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059' + */ + if (s->intr_enabled) { + 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); } From patchwork Fri Sep 14 18:27:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10601143 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 5BE4C1750 for ; Fri, 14 Sep 2018 18:29:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A4072BABD for ; Fri, 14 Sep 2018 18:29:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DCEC2BAC8; Fri, 14 Sep 2018 18:29:00 +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=BAD_ENC_HEADER,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 BDBD32BAD3 for ; Fri, 14 Sep 2018 18:28:59 +0000 (UTC) Received: from localhost ([::1]:52873 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0spv-0000us-2r for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Sep 2018 14:28:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0sof-0008UA-2U for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0sob-0003n6-Ie for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27:41 -0400 Received: from mail-bn3nam01on0044.outbound.protection.outlook.com ([104.47.33.44]:18854 helo=NAM01-BN3-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 1g0sob-0003m5-C8 for qemu-devel@nongnu.org; Fri, 14 Sep 2018 14:27: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=pcr4pJ7L/JjxSJ5HJ1kJ+uNXmkHqT4c9RPSKdAmTATA=; b=gC2W0YSBXDLFgZg6PUIwla5SjimDeeirREWYWetJlveI6TeVxPJCMewa7Y4LLLsCJZuNGdpyzTaVoXQYBe5LlVXZt4RwwDwy4Uv0jdKIxTQUAGx9D5ZK3vVf8pSKo89JjnZhOzsMd5qA7BeSGWMGP1X235pzA6v061yIBr77GAo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from sbrijesh-desktop.amd.com (165.204.77.1) by DM6PR12MB2684.namprd12.prod.outlook.com (2603:10b6:5:4a::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.16; Fri, 14 Sep 2018 18:27:33 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Fri, 14 Sep 2018 13:27:03 -0500 Message-Id: <1536949623-23564-9-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536949623-23564-1-git-send-email-brijesh.singh@amd.com> References: <1536949623-23564-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BYAPR01CA0001.prod.exchangelabs.com (2603:10b6:a02:80::14) To DM6PR12MB2684.namprd12.prod.outlook.com (2603:10b6:5:4a::33) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dff4c30d-98e6-410d-d199-08d61a6fbdbf X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DM6PR12MB2684; X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 3:jl4nzHkjGw3F2ovyPOY79vr6T2SPir0NFQwwrRGNUNwHsCfBAkL8mBua/nh/5CbdUtCcYHS4b5vDzlTuY/0oqpZCSOZ5aKvGsIuBqe+cAKytZJn+scA3Zn6otEosgUI9M8HjHYfz+wN+PCP7lI160bxWXJM+t5voLL8Wn8z3BvfoNBvjzaLFJKgm3XyvS6M63Os7oPQJgZlPWKQ3OrUqCqXPmt1QxHNRAD3cRUfpBXm8dzweiiEADls2wvRfd6e0; 25:Om7byMaBMjmcyBBXu/ey+SmUkxoeC2zpKC6dO306xejPDRSs9XcjiKd6/uM1IJfB3WPYK4JM8TzXxevLdx3QI9ijuPlbFJHkLc3vjZIQv1AcgzdIeuf4VHysJSaB4aE24h+keQy1olNYA9nMMGb1BcdSkAJUU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lL+CIjhulTd3jqCDxE7FdRSYuX7Fapr3hrFoI7ihEVEwKaG4SrVRkX3RrsWgXnnZ5Iuz+oLyHsTqsHef+UWbCbk4221YGp8sHAysRtpfwwUo/fZtC4RqKQ86M1CCVyL/te9hrIo12HD41av1rNo3BVe4aEGdLkuz1/wOI/fEoqDFwrXBwsJ36B0ifqWl6/E+swX+EoCLDVRrhPdM/7iTw1yOBJAme3394M7u/W52ca5q+c4tP6cOC1dfbsFcOw4oxZIAUA/LmdVPDc6g3jWsBiUug1J2XAGH37mJfcQaHNOLvx4aCWFHCVXsuV46wcCAtc7/zybRdi X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158)(767451399110)(211171220733660); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699050); SRVR:DM6PR12MB2684; BCL:0; PCL:0; RULEID:; SRVR:DM6PR12MB2684; X-Forefront-PRVS: 07954CC105 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(346002)(376002)(366004)(189003)(199004)(50466002)(66066001)(48376002)(2906002)(25786009)(446003)(16586007)(6486002)(76176011)(39060400002)(7736002)(68736007)(51416003)(7696005)(305945005)(316002)(6666003)(6916009)(47776003)(53936002)(52116002)(386003)(956004)(486006)(11346002)(5660300001)(54906003)(2616005)(8676002)(478600001)(36756003)(476003)(186003)(44832011)(105586002)(2361001)(3846002)(106356001)(26005)(81166006)(81156014)(8936002)(2351001)(53416004)(16526019)(50226002)(4326008)(97736004)(6116002)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2684; H:sbrijesh-desktop.amd.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-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR12MB2684; 23:bvfZ/12i1DdLfe3au6b1Uudp5yfyqK2cZDeKyEHnM?= llpAS3AqtvnAmpoeVjvk50h7Bq7NgiBjI/miZBUyAkPGwSXdPXr3u1A8fmN2pKBR3l5LUI6mDwdZLQA/W4EmUKioGt+wSRZr3rjipK8nJE+flFeZUP+G9u+3agQactguRPN0P/089rVXsJaGreVts9u2nxs1ydZTsl2pP1/si3fZXXY652C9pl1RTLipRiUkgBpdXSPxQrSALhih/4KCVUkeNvsNwWWGX9njWyyGSuZ2BScR69tsrYfuWM//9R0NmKzE6VIz4eqb6Qy21PBQlzj9y6kLkrGWuOAge9/7YXZlTUP2G2eJVKH13VDlaAtSz6x8Y7dikfaPEovTz46OUEcKupDj1VJsz7CSLnO4netHfpTY/VmYWjXZs5AiWk3DzQJciKvGu37yFQ1NYbXiSyWfl3EdtZu1qZu76JSRSDtr97nIxzDzALKqxF+lVwmar7kSQ/VxA400tCshxi0pNzJBytoI18CD871v5dHamRmXJiTj47QEtfm0WrZqHLud930uH6+ofKc1J2SFvvzRpRI6mvopNqA1+oFRbc7umJZfjVT22t6Q9lSphN1G9qrXTqhkHdh5EcXE0VodTwm9foXd7PNM7J9ctqjFcFPOChFFVqeWTzv0Tw0bAoZUr5sxua0vlRLM9s9/v5tQnQLZklp+ICSm+6hnhqgy9REUqHzJ6ir6Wz+Je5A9Hkz608APoymkrgAYcFQxYf7DsViy/9PHtt7yfd7Bu7NHt/yeZcG6wnKSmkeFaUC1rcpfhVLDpVPFyTT3eintKPWqzv0TlyKPbiiJOcmABViIcntT4tukyN85pCOeycm35kDfCZwqdLFiuzmWR7FOShPvNZ7i/aTrVbL9eNY4XAKbBkfhUTUWpH0qazGJuV/UOhG5eoapVoRPXyCjR5uAaHONCl//+1WTW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eG2iPXNGv1R6wiCyIN/n90x6o/tlMskahAWv4jTuP9Pw07wLCDL3jYqBttt77UuKhQgpQhxWRVd0LuQJWxwrzjiGsAU9NtYDwEEx4P44Zy4X6hyAiWCgs2OV/yxNlPX2mZ/i9uLFcA==; 5:QEC1woYcp8lsFag0lfXxgE5xoMagt1PKriSpArAjHv5JNrQbpigJg+vejBlFgKzED1HLuvwoENzWVfjz88SinguV2znriZa8a9S9IaRhO/rrgkm7nJBP/I5qcsrxg+GyF/YL85h+bM2wVAteySTKwvJTNVmSMfJnI71yEdGzrpI=; 7:9/1sOEllZKsTIDo4JWDURLqTP2kxV9j5tNZt8RV6cpVOdbU/+YwDHacNvj1FRDZXbM+dJj51KVpge7e7fNljZWXxj36Oqg09xwBgsjKpC4lQYx8r7dT5BYY4YMdAeC1bYLwBuekJ6v1JSKy/4aDj2loSbTuS9xoMhta9yUvguwsOv5rht8ra1wMHDyFwfQsuS0LEkuvB784JaX8fa8Jm/MW9ps1gs6jUOtoLfd/ja4XNZTTXD0/bIdtmOaMG3PTl SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2684; 20:9MPGKi1wfsMbc/0BhQwsh2AFTwgCAbCvQt+QsGZjlt4qvDqoxwm+7BbUaTgc8KTM0i8sj6ya9pJSALfK/n3zwPhhxbO1c++hfiPGElw3RZ5dmWKGOl0fgW4zcSggdAyTdxq3unINE9OCHJNi62F15mTSkplwiaIiLJ2fHG2Ze3wOFVc14FyrBW75Szd8fmUCso5pQR9q3S+QNQ8Q3O9xA39fPp5+Ej61RS05fj9sy3wBlWCehf7xTRcbDQiuvBaK X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2018 18:27:33.3701 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dff4c30d-98e6-410d-d199-08d61a6fbdbf X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2684 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.33.44 Subject: [Qemu-devel] [PATCH v2 8/8] x86_iommu/amd: Enable Guest virtual APIC 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: Tom Lendacky , Brijesh Singh , Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , Suravee Suthikulpanit , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Now that amd-iommu support interrupt remapping, enable the GASup in IVRS table and GASup in extended feature register to indicate that IOMMU support guest virtual APIC mode. GASup provides option to guest OS to make use of 128-bit IRTE. Note that the GAMSup is set to zero to indicate that amd-iommu does not support guest virtual APIC mode (aka AVIC) which would be used for the nested VMs. See Table 21 from IOMMU spec for interrupt virtualization controls Signed-off-by: Brijesh Singh Reviewed-by: Peter Xu Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: Tom Lendacky Cc: Suravee Suthikulpanit --- hw/i386/acpi-build.c | 3 ++- hw/i386/amd_iommu.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 0a19e25..41f523a 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2567,7 +2567,8 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker) build_append_int_noprefix(table_data, (48UL << 30) | /* HATS */ (48UL << 28) | /* GATS */ - (1UL << 2), /* GTSup */ + (1UL << 2) | /* GTSup */ + (1UL << 6), /* GASup */ 4); /* * Type 1 device entry reporting all devices diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 6579469..1ac920e 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -177,7 +177,7 @@ /* extended feature support */ #define AMDVI_EXT_FEATURES (AMDVI_FEATURE_PREFETCH | AMDVI_FEATURE_PPR | \ AMDVI_FEATURE_IA | AMDVI_FEATURE_GT | AMDVI_FEATURE_HE | \ - AMDVI_GATS_MODE | AMDVI_HATS_MODE) + AMDVI_GATS_MODE | AMDVI_HATS_MODE | AMDVI_FEATURE_GA) /* capabilities header */ #define AMDVI_CAPAB_FEATURES (AMDVI_CAPAB_FLAT_EXT | \