From patchwork Fri Nov 29 15:58:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 846148 Delivered-To: patch@linaro.org Received: by 2002:adf:f2c4:0:b0:382:43a8:7b94 with SMTP id d4csp970825wrp; Fri, 29 Nov 2024 07:59:03 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXuhiTa/c5jw8e7GITHEiGHfVonJP+c1jyyvltdTaYEea+G+z9hScWq2yVfr0/6W5x9rPqhVQ==@linaro.org X-Google-Smtp-Source: AGHT+IEuQz9+ipslzZDYuwWhow6nz6BSzD0tjubQh5R1n8i1ckPN5usQunpIKwHukqxS+fBI/Z6j X-Received: by 2002:a05:620a:4103:b0:7b1:5763:4ba2 with SMTP id af79cd13be357-7b67c43d015mr1493090885a.40.1732895943318; Fri, 29 Nov 2024 07:59:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732895943; cv=none; d=google.com; s=arc-20240605; b=alxxeN/VrTfEMglJpOMFoVHBnrYiDOUWXNEY5i2zCZS1FcPVJQTRcmfmso/KvxFysq cBbDqSPkXgKP+ZTsY6DJqJ5YI2ypL1+EEADUGqhDhG/c3l2vBu4wYewFsglnxQ81dTKR T6DhrxSHyWnaLA5BUGETms0kBnYbRo4ii5tmaYlRrgNNsZAYgIEHAMV5TM93/IKZDXFY a8fLDzTXY0RxPKQ0jnm2FRqx9YaWjwCjRC0IJt/gNIVuDOOQdh89vK86WKmTD45SHUVy bnNyQtlblgybiQhbk4ILxL/TT+q0OjTdN12XU+MBETy51nfRb1/qUXHf6WIm/KfBSs1A HUvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=OGL4vfV/tJS7xDopWomqNJ0/AN5OESAhWRytdgc3oY8=; fh=rCFQwgjuIJDenwZSdTrRbUQM+ZrKuwSFIi49wxLrb58=; b=K7WMK3J6Bo1bxbm003FX+hjTsCIjxLGLsqHfuQg3wPn26/vbxIsgAZ+Iw6uUAM8ptx 6x/zrY8mqyzsXoAAO0ONMJFU4ApSMqe+aPkcs2cR33AE1Ax0PQv/0PEAA7eM7a+d7VKt whbJ3hiuPMvoMQibYQLApqvTCHdZCcboOTLbfPRT5/Ne60hRhn0WOeMLkM92Ki8lp8nY uSV+eEUZNhRqOjPdzXJGmioDyVODQO0v6WnSXTAddCFZ8uoOi4G2b89+c462bVCLabva hVUYDnIlD9XdlmLYGnta4XG4/8WPuhKRafKYM2j34eDDivxXA5B9JFMU4EiurttWIWYl H5ug==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tdAfgfzl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b684923dbesi591268885a.42.2024.11.29.07.59.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Nov 2024 07:59:03 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tdAfgfzl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tH3Nj-0006Wg-79; Fri, 29 Nov 2024 10:58:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tH3Nh-0006WF-Gc for qemu-devel@nongnu.org; Fri, 29 Nov 2024 10:58:09 -0500 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tH3Nf-0006MT-SU for qemu-devel@nongnu.org; Fri, 29 Nov 2024 10:58:09 -0500 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-5cfd2978f95so3397848a12.0 for ; Fri, 29 Nov 2024 07:58:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732895886; x=1733500686; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OGL4vfV/tJS7xDopWomqNJ0/AN5OESAhWRytdgc3oY8=; b=tdAfgfzlD1W+nZfBvxF5GB5IkLboYuNoPdV/NaujAZwWE7gZkwycMtzoGCRmAv3UzB itQD3xmnwILtyvQ0pJi8BwKU65aq31MWacKyXNNvIXLLjXYyVzcxjQNbSps6gTPCyvbB 6Lh4IcE08LgTg33koN95nzddYcq8S/fdQ3Y3pq1k+Nr3wa0VBpBCw/Kn7KAmxQ2dWGuC DVo8bfuQjdhUh81tuv3Ep7PbOwKW2szG0MOVzk9MNJn7DitX2aW0DwjKJCnYwaDA2nZv 2SJ3gQgkyIE80/0YzmNerA9i+aIdbrofol+H5n7zPQa39E2HJnU5LFRaVew8tjuxTIat epuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732895886; x=1733500686; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OGL4vfV/tJS7xDopWomqNJ0/AN5OESAhWRytdgc3oY8=; b=JjGG7+o3WBZX1x2UBxdVs1YF4LPaV/7WaVoLMaswUI6RSUM/Gq4hf5l6QzweJVvrkz eRhyMCiHmdyhmHTuO0QnWWqSh4wjSQUYWE1ND174GCpBy+qO5QIv1c8hOSYHzKqMXjME pIA5tun/uyXsdwkyTYZSVMuHnxLs3RNUkXYtrGDBpPa7fYciqNxNvrNddBfdVxqrgYlc 5x5K4wPmyDaR8KeYuJuoMMPbJUY3qgErp3SJAl6fiol60fnQtcwNb0624gQG3fnV/pN5 MQHCeKMiFm14iQZLGJskkAnWQABfwiVG8/LRLmshWaZemxkP9WRGGn1T5UNE8xqugMTI 3ViQ== X-Gm-Message-State: AOJu0YxX/y8vuU7AKjxLjtukoMgoxzN/bW/1XLSz0HHuR8MEEfM9OpTR 85Q6yagTIFgKFsfZL+OBaPG5vJ6mmDKIG01wbMJDhnBLRo5a7efo4WQP5gMvWNfW1b4RPieFAIs a X-Gm-Gg: ASbGncsHB0ArGNCu+Q6f6KS7GnOl1TRAqHDMjdjM1AOnsGWbHGgYrSYVe/t8xcp/+H0 TLVhMrsJGsRs3nS364PM/Bu9Zx72JDlwM5YLSO+GSn4nqFXtf8l5i+5g7ZkFRVCcSAIwhP6Vhtn FT9qfVADMt/TSkRnQeFdf98poLRhTl9jOvStci8qWkIOIyB5Qbkg987wxC0ck3ajqI2+TV8fN82 SeOpfzAOCz4c3IZmo9mGXT/Kh4q/barfTy3K1LrR7ZkIOf9ZUhAer7QktKK X-Received: by 2002:a17:906:18a1:b0:a9a:6b4c:9d2c with SMTP id a640c23a62f3a-aa58107884fmr1065535366b.59.1732895885773; Fri, 29 Nov 2024 07:58:05 -0800 (PST) Received: from m1x-phil.lan ([176.176.147.124]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa59990a79bsm186683166b.151.2024.11.29.07.58.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 29 Nov 2024 07:58:05 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Vasant.Hegde@amd.com, Santosh Shukla , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Eduardo Habkost , Marcel Apfelbaum , Sairaj Kodilkar , Daniel Hoffman , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-10.0 v2] hw/i386/amd_iommu: Simplify non-KVM checks on XTSup feature Date: Fri, 29 Nov 2024 16:58:02 +0100 Message-ID: <20241129155802.35534-1-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=philmd@linaro.org; helo=mail-ed1-x52d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Generic code wanting to access KVM specific methods should do so being protected by the 'kvm_enabled()' helper. Doing so avoid link failures when optimization is disabled (using --enable-debug), see for example commits c04cfb4596a ("hw/i386: fix short-circuit logic with non-optimizing builds") and 0266aef8cd6 ("amd_iommu: Fix kvm_enable_x2apic link error with clang in non-KVM builds"). XTSup feature depends on KVM, so protect the whole block checking the XTSup feature with a check on whether KVM is enabled. Since x86_cpus_init() already checks APIC ID > 255 imply kernel support for irqchip and X2APIC, remove the confuse and unlikely reachable "AMD IOMMU xtsup=on requires support on the KVM side" message. Fix a type in "configuration" in error message. Signed-off-by: Philippe Mathieu-Daudé --- v2: Rebased on merged 0266aef8cd6 ("amd_iommu: Fix kvm_enable_x2apic link error with clang in non-KVM builds"). Supersedes: <20241129114113.33215-1-philmd@linaro.org> --- hw/i386/amd_iommu.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index af0f4da1f69..39b6d6ef295 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1652,17 +1652,10 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp) memory_region_add_subregion_overlap(&s->mr_sys, AMDVI_INT_ADDR_FIRST, &s->mr_ir, 1); - /* AMD IOMMU with x2APIC mode requires xtsup=on */ - if (x86ms->apic_id_limit > 255 && !s->xtsup) { - error_report("AMD IOMMU with x2APIC confguration requires xtsup=on"); + if (kvm_enabled() && x86ms->apic_id_limit > 255 && !s->xtsup) { + error_report("AMD IOMMU with x2APIC configuration requires xtsup=on"); exit(EXIT_FAILURE); } - if (s->xtsup) { - if (kvm_irqchip_is_split() && !kvm_enable_x2apic()) { - error_report("AMD IOMMU xtsup=on requires support on the KVM side"); - exit(EXIT_FAILURE); - } - } pci_setup_iommu(bus, &amdvi_iommu_ops, s); amdvi_init(s);