From nobody Fri May 3 18:26:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664208785; cv=none; d=zohomail.com; s=zohoarc; b=e69atZX5beBk8WzidD3ttIAGcGUNjdgVgaMMGqISMS+NbKbAmISNLZczU3GY6AJECnPYEiW5m66UtWNx/Dts859dnidzoVvC+l4hXe88RdDpSqzshBYlOlY4aoru4bGmbE5vtT4758HG2VB7gbV7vJr9i5n24qaQEfm787gdafg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664208785; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=mhS7W3FV1a+DTf4wDHj/bKnvPsjSmpUGk1yVvpgdWVc=; b=e/qxE6CH08O3TjRy09Z5Wde0Nu3zJad7XcfHLZA5ir46uY3zh57+6u/a/0BynoWpJPjOMZPXhL83EyzcXQzI0nKqVraZ8p93Kl0EIcVpgQVGdKmVONAACilC15n2hd0IiQHm9mcKXwOJ4JIg2+2IVgeA4B/Ijf/Zxjj//iGR7Pw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166420878525225.050265112679995; Mon, 26 Sep 2022 09:13:05 -0700 (PDT) Received: from localhost ([::1]:35836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocqj9-00054r-2z for importer@patchew.org; Mon, 26 Sep 2022 12:13:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocq5f-0007eW-9B for qemu-devel@nongnu.org; Mon, 26 Sep 2022 11:32:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31274) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocq5b-000656-Il for qemu-devel@nongnu.org; Mon, 26 Sep 2022 11:32:12 -0400 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-529-a3e0ufdPOGe7BCZppIis3w-1; Mon, 26 Sep 2022 11:32:09 -0400 Received: by mail-qk1-f197.google.com with SMTP id k2-20020a05620a414200b006ceec443c8bso5229579qko.14 for ; Mon, 26 Sep 2022 08:32:09 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id t14-20020a05620a450e00b006cbcdc6efedsm12216341qkp.41.2022.09.26.08.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 08:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664206330; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mhS7W3FV1a+DTf4wDHj/bKnvPsjSmpUGk1yVvpgdWVc=; b=ew8XN6OmKn1OKlv6XpucH8WEO1HckunL5olkUGbZFAV7CLtKLjmRVbvILd0wvgACxMxgFs 8xrCUPnWoMJDBxhC8RmFr0Zb2THfP8pksT/N1UvEchyStJjzuARL6r+ChRzFFPWbFSSCRW iohm0FTEUs1WcUzzifN3xgqQsqcJzzQ= X-MC-Unique: a3e0ufdPOGe7BCZppIis3w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=mhS7W3FV1a+DTf4wDHj/bKnvPsjSmpUGk1yVvpgdWVc=; b=s5xiBlSocXp9fMs15dLnXxdjbkrLhSU9mzOEo9VuWieorzEs+pOw7vW4aqlzjsd88c gHz0W1r2iJaZ6G0C1M/qQiZ+9oNQQUARq4jy1Nei7BOX+qMY3AzPz0y7uEiQwtNcquO7 lTIGvKGebhdlFWF/kP9RRghponHZyqfuPZ+9Ne6PngMPgFfBMmDSLG6sCi8ynuFJ1oDR Yve6KkRrcUtYSc/yx/I435bKfuH2bPaumoIgl+K6kBCgZ5M+dJ18m8JjpcSuAT3v5Dag J9v4egF6t/uAGWJzMftPOMpkuXBoXyBni7kN0l12xKrjORomZGfvkynnL7XWP3EYIypU MYRQ== X-Gm-Message-State: ACrzQf3feXjjx2cClJyloVy1Igk1i/44NElGGjtKzVMPxzKF2P4C+ddB gi3RRwnZ4tOBA/bauyQ0a1KdTEGQJbT+m+oqZrcwqtRsjRNYB6Hl6YxTzh7Dqb505pl7rdrZc3s +wXh2MMtdzne4UMOcfqJMMml8GAc3rzgdv+jX8N6oxhy51EIdNFvDHCaILxZXKlVx X-Received: by 2002:a05:620a:25c8:b0:6ae:ba71:ea7d with SMTP id y8-20020a05620a25c800b006aeba71ea7dmr14752747qko.547.1664206328369; Mon, 26 Sep 2022 08:32:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6CDCvS/m2u/1Ipc3ccgxSlwBekcLMWqg+OMw07bVRfd1zZd3TxutalIb5ljwPdqdhDCjfMgg== X-Received: by 2002:a05:620a:25c8:b0:6ae:ba71:ea7d with SMTP id y8-20020a05620a25c800b006aeba71ea7dmr14752712qko.547.1664206328050; Mon, 26 Sep 2022 08:32:08 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Igor Mammedov , peterx@redhat.com, "Michael S . Tsirkin" , Paolo Bonzini , Jason Wang , David Woodhouse , Claudio Fontana Subject: [PATCH v2] Revert "intel_iommu: Fix irqchip / X2APIC configuration checks" Date: Mon, 26 Sep 2022 11:32:06 -0400 Message-Id: <20220926153206.10881-1-peterx@redhat.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664208786676100001 Content-Type: text/plain; charset="utf-8" It's true that when vcpus<=3D255 we don't require the length of 32bit APIC IDs. However here since we already have EIM=3DON it means the hypervisor will declare the VM as x2apic supported (e.g. VT-d ECAP register will have EIM bit 4 set), so the guest should assume the APIC IDs are 32bits width even if vcpus<=3D255. In short, commit 77250171bdc breaks any simple cmdli= ne that wants to boot a VM with >=3D9 but <=3D255 vcpus with: -device intel-iommu,intremap=3Don For anyone who does not want to enable x2apic, we can use eim=3Doff in the intel-iommu parameters to skip enabling KVM x2apic. This partly reverts commit 77250171bdc02aee106083fd2a068147befa1a38, while keeping the valid bit on checking split irqchip, but revert the other chang= e. One thing to mention is that this patch may break migration compatibility of such VM, however that's probably the best thing we can do, because the old behavior was simply wrong and not working for >8 vcpus. For <=3D8 vcpu= s, there could be a light guest ABI change (by enabling KVM x2apic after this patch), but logically it shouldn't affect the migration from working. Also, this is not the 1st commit to change x2apic behavior. Igor provided a full history of how this evolved for the past few years: https://lore.kernel.org/qemu-devel/20220922154617.57d1a1fb@redhat.com/ Relevant commits for reference: fb506e701e ("intel_iommu: reject broken EIM", 2016-10-17) c1bb5418e3 ("target/i386: Support up to 32768 CPUs without IRQ remapping"= , 2020-12-10) 77250171bd ("intel_iommu: Fix irqchip / X2APIC configuration checks", 202= 2-05-16) dc89f32d92 ("target/i386: Fix sanity check on max APIC ID / X2APIC enable= ment", 2022-05-16) We may want to have this for stable too (mostly for 7.1.0 only). Adding a fixes tag. Cc: David Woodhouse Cc: Claudio Fontana Cc: Igor Mammedov Fixes: 77250171bd ("intel_iommu: Fix irqchip / X2APIC configuration checks") Signed-off-by: Peter Xu Reviewed-by: Igor Mammedov --- v2: - Added some more information into commit message [Igor] --- hw/i386/intel_iommu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 05d53a1aa9..6524c2ee32 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3818,6 +3818,11 @@ static bool vtd_decide_config(IntelIOMMUState *s, Er= ror **errp) error_setg(errp, "eim=3Don requires accel=3Dkvm,kernel-irqchip= =3Dsplit"); return false; } + if (!kvm_enable_x2apic()) { + error_setg(errp, "eim=3Don requires support on the KVM side" + "(X2APIC_API, first shipped in v4.7)"); + return false; + } } =20 /* Currently only address widths supported are 39 and 48 bits */ --=20 2.37.3