From patchwork Mon Mar 14 14:25:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 12780275 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 0F1BBC433EF for ; Mon, 14 Mar 2022 14:26:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239001AbiCNO1T (ORCPT ); Mon, 14 Mar 2022 10:27:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234482AbiCNO1O (ORCPT ); Mon, 14 Mar 2022 10:27:14 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FB3F36E1B for ; Mon, 14 Mar 2022 07:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=sZZuFpI4exz793Oyalsxftvzu/Zwg8HQxGOOUixySZQ=; b=Ln4NI7HEM5jHy45UM4eaiWZTWr EANhaG4L3313pRC6xFJH/mkCzQeA3jfExVZQmFV+LwGqmra4ADF4igtOliSozFRVxyFGw6lYqPAJG GkmSBzEuli2zt8A7iF3tVj4e6GtdIB1nNCkjXOKbSvAlidLdeyX7+FwsUIysyBr9VfCK7TCmOvm6K p5m/lxbV1ZkCmorLLF1EpmtqAfZLdKlXlhnl1ZTCyUdW/ijvVTifKy4DrQw4szrOjEzCm1gSmbm6m WE6q997eCkntrb4ow0wxJVQlBVqbCzsR7BrD2DUD+wmQr2jhDCgAkwK256L+hJyayc4ADZ9aoc4Br XbFRhguA==; Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nTldp-000rjR-Bi; Mon, 14 Mar 2022 14:25:45 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nTldo-000dAa-La; Mon, 14 Mar 2022 14:25:44 +0000 From: David Woodhouse To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Peter Xu , Jason Wang , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcelo Tosatti , kvm@vger.kernel.org, Claudio Fontana , Igor Mammedov , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= Subject: [PATCH 3/4] intel_iommu: Only allow interrupt remapping to be enabled if it's supported Date: Mon, 14 Mar 2022 14:25:43 +0000 Message-Id: <20220314142544.150555-3-dwmw2@infradead.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220314142544.150555-1-dwmw2@infradead.org> References: <20220314142544.150555-1-dwmw2@infradead.org> MIME-Version: 1.0 Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by desiato.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 948c653e74..e32cb933bd 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2209,6 +2209,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; @@ -2230,7 +2231,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); }