From patchwork Thu Dec 9 22:08:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 12668359 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 191A7C433FE for ; Thu, 9 Dec 2021 22:09:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232314AbhLIWMg (ORCPT ); Thu, 9 Dec 2021 17:12:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbhLIWMe (ORCPT ); Thu, 9 Dec 2021 17:12:34 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4600BC061746 for ; Thu, 9 Dec 2021 14:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=6T8H5SlZi4uUdKoCbrgDO6stZljqx7xoEBEiCfG7UWI=; b=CciiV4aJXjCUHa+0cePD85FEhI U9bgUiT8WbOi8acWFbkot4IWwgXOTXp3+SjFSvg9D+ZdgnIy3HBAddxtVtPGNUpOZO3FZRxbDOR1o YTlXxE6zqjNdpNyVNX9ZgNjArRlcEAxgaPQh0q3Nb5B31sOR3uLZRlTR4XfOHeIqDUP24mHMQoj/o 6F9VfvYmtqXoA7MBGrObhccuveuFog8Sv+LDkwmbOXxdeGOBu4FdYx67culwfyxRSUI4FpUBRwl7z MnWs7DETKjqWg98b+qIjX500QvWMOyXIU1M0JZj6A3XXXF7Q9AqSAbo+j3hZCFCOxeJqgIm5/UK4m Ep+ls07Q==; Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvRai-009loX-S9; Thu, 09 Dec 2021 22:08:41 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvRaj-0003t0-31; Thu, 09 Dec 2021 22:08:41 +0000 From: David Woodhouse To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Peter Xu , Jason Wang , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum , Marcelo Tosatti , kvm@vger.kernel.org Subject: [PATCH v2 3/4] intel_iommu: Only allow interrupt remapping to be enabled if it's supported Date: Thu, 9 Dec 2021 22:08:39 +0000 Message-Id: <20211209220840.14889-3-dwmw2@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211209220840.14889-1-dwmw2@infradead.org> References: <20211209220840.14889-1-dwmw2@infradead.org> MIME-Version: 1.0 Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: David Woodhouse We should probably check if we were meant to be exposing IR, before letting the guest turn the IRE bit on. Signed-off-by: David Woodhouse Reviewed-by: Peter Xu Acked-by: Jason Wang --- hw/i386/intel_iommu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 9a3cb2b789..bd288d45bb 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2197,6 +2197,7 @@ static void vtd_handle_gcmd_ire(IntelIOMMUState *s, bool en) /* Handle write to Global Command Register */ static void vtd_handle_gcmd_write(IntelIOMMUState *s) { + X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s); uint32_t status = vtd_get_long_raw(s, DMAR_GSTS_REG); uint32_t val = vtd_get_long_raw(s, DMAR_GCMD_REG); uint32_t changed = status ^ val; @@ -2218,7 +2219,8 @@ static void vtd_handle_gcmd_write(IntelIOMMUState *s) /* Set/update the interrupt remapping root-table pointer */ vtd_handle_gcmd_sirtp(s); } - if (changed & VTD_GCMD_IRE) { + if ((changed & VTD_GCMD_IRE) && + x86_iommu_ir_supported(x86_iommu)) { /* Interrupt remap enable/disable */ vtd_handle_gcmd_ire(s, val & VTD_GCMD_IRE); }