From patchwork Mon Sep 4 12:43:18 2023 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: 719974 Delivered-To: patch@linaro.org Received: by 2002:adf:d08b:0:b0:31d:da82:a3b4 with SMTP id y11csp1578437wrh; Mon, 4 Sep 2023 05:45:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmtO7vkArWIZjZNgWkFJwInonic83V11aEv7Wi+WY34zEqDYvbwh1CZuRZwN0T1fnYStBP X-Received: by 2002:a0c:8d47:0:b0:64f:59b8:cfd9 with SMTP id s7-20020a0c8d47000000b0064f59b8cfd9mr8510688qvb.18.1693831509012; Mon, 04 Sep 2023 05:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693831509; cv=none; d=google.com; s=arc-20160816; b=L7B6FLuhExq3cd1lfs2h+b/vPpj4/+uJMNg1KAHhOL4QbCGcu2GD5mFIUL1qEHnTw4 TBsCJPk5TOKHn4DeFKObd/41KvjMgtgTCi+zUE3X6C7NNNJUtnR+udEirIg6usNHvZFI ZPF6f1kw9g+9+tzsg3lVvEASVB2Pe1lt2QVQKP6koZTrKFgDAkdPQygEFojKs3VSfmwv WsEHYU4OkJH3yM1dT7P4CuepUX2LnbWgma4LOeG5JX1Hsw6m9juVsfprRcfcYJkNtN9L /sO2QfGxPrFBgc91KU9JKVv1O3Hn5P0bhfUZ2wqjNBXkJwCPppZy/XudqYnJKrwcHiTL iscQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=y1KRPJbXgs1nETBjJNmlr2PmeFCKIGRCFU9IErPdUTo=; fh=m4TnS6IVM8RAyKGmHewnHpn5Ht3JgQEDd8raoB7tRKE=; b=LVGIAuOHLpf1BiH/bK0cfYOXNrrZFmqin+DPT79QNqEsa1D9afv/r1KANXE1hShZ85 1lKu+q/jXEqFEYsf7N9ProCO/bOmwUWfEiCeNxkLx6Bj8RMTkDMdtDVqPXR4AT0SZh+7 cBpso2LLW9mCCqwJbKJwzS6wysP2cqIjzY1V42aorp1pGKKSIh4aH9Vm0lgMT7v2UV2V 8A46yWtJz4Fopcq+1ME3JX9a/1X55IvncjcX0RyRmixTPstJfwqdXsdXEu0GEqvz0c6Q yjKDfd8UAdqZaB4LEAEh7KLb5xj9So09M6lRMfWAYP/DxeYifZFSD+lNp4syGZaA2xLC u2Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PF/J7Sp+"; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s5-20020a0ce305000000b0064f4654d83bsi6219628qvl.419.2023.09.04.05.45.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Sep 2023 05:45:08 -0700 (PDT) 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="PF/J7Sp+"; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qd8wj-0002hP-VD; Mon, 04 Sep 2023 08:44:50 -0400 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 1qd8wB-0002BD-0D for qemu-devel@nongnu.org; Mon, 04 Sep 2023 08:44:16 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qd8w7-0004hR-2k for qemu-devel@nongnu.org; Mon, 04 Sep 2023 08:44:14 -0400 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5230a22cfd1so1969801a12.1 for ; Mon, 04 Sep 2023 05:44:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693831449; x=1694436249; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y1KRPJbXgs1nETBjJNmlr2PmeFCKIGRCFU9IErPdUTo=; b=PF/J7Sp+O9zlBr9zE9ws5fv2ICxnWGaVkVK+5CH0ZN3Dz551s2G4Su/82pgQcOoqlF jXM+303olIGV7R5bJTswxSGiMRmVt7eOq0VjJg12BtZqzpXYMfjO9TuUwwpBo0+WOK+P miNO8RNuV9pVkzmekniU8u2rIp/Rq7EMeCPad4+3O7yijGg+Dnh4KzQR1g1tFcyOMpFF faiPsq0Jafc3rL/zDfcj4I8EhDrn5jlbbpbjgfS3bq9kyYmtNEJWvVraeyEWpIVhMNij T2emOpYmWRy4BmP8nerdTBXFv7n/N/1j5kT1RKqgMohMJAENk1MSXKYkMZA7NAvyQ/lU 4AmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693831449; x=1694436249; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y1KRPJbXgs1nETBjJNmlr2PmeFCKIGRCFU9IErPdUTo=; b=Y2kq631CNe/YnQmoUOuNffltpYTVsHj+ZxLdcyGlFCQywTmxLmWRhoJNAYg2eJWJSa VGwt3l2Hirw4dXwTKf6lI0RgJGl6uV2WFZLKDVVnbYaQ/5Kp6XBSg1F4dK3L+789Gtp0 +jRTlXAXbYQyEcC1iTL0p3VO2juXkrCeOyYF8OzXDHMq+j8nCrFJplavVPJkkuNRgX3v fnUaP3ePPOmyCm7S8/eWgi3iXcPj7Gu5Mui3RTyUAtqkC6yd6HiG5z/ITkb3AXhgF06z saogign4G653iqsUtpCxnxGctI+Of9pXXY1yo2RgAouvyDphayLcK1Fv5kHMUfjSBbSq Z9XQ== X-Gm-Message-State: AOJu0YxQejGMflLUhvS0OlbJSzvOWI5UjEmrdtloc81Fw26berowpv9o B34x8qzWU5zQGg4dyYSRv9SY5MCkN3yGcEhKioo= X-Received: by 2002:a17:907:2c75:b0:9a1:d29c:6aa9 with SMTP id ib21-20020a1709072c7500b009a1d29c6aa9mr5782355ejc.11.1693831449576; Mon, 04 Sep 2023 05:44:09 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.227]) by smtp.gmail.com with ESMTPSA id lt14-20020a170906fa8e00b00977eec7b7e8sm6153822ejb.68.2023.09.04.05.44.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 04 Sep 2023 05:44:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Paolo Bonzini , Marcelo Tosatti , "Michael S. Tsirkin" , kvm@vger.kernel.org, =?utf-8?q?Phili?= =?utf-8?q?ppe_Mathieu-Daud=C3=A9?= , Daniel Henrique Barboza , Peter Xu , Jason Wang , Eduardo Habkost , Marcel Apfelbaum Subject: [PATCH 07/13] target/i386: Allow elision of kvm_enable_x2apic() Date: Mon, 4 Sep 2023 14:43:18 +0200 Message-ID: <20230904124325.79040-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230904124325.79040-1-philmd@linaro.org> References: <20230904124325.79040-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=philmd@linaro.org; helo=mail-ed1-x532.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 Call kvm_enabled() before kvm_enable_x2apic() to let the compiler elide its call. Suggested-by: Daniel Henrique Barboza Signed-off-by: Philippe Mathieu-Daudé --- hw/i386/intel_iommu.c | 2 +- hw/i386/x86.c | 2 +- target/i386/kvm/kvm-stub.c | 7 ------- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 3ca71df369..c9961ef752 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -4053,7 +4053,7 @@ static bool vtd_decide_config(IntelIOMMUState *s, Error **errp) error_setg(errp, "eim=on requires accel=kvm,kernel-irqchip=split"); return false; } - if (!kvm_enable_x2apic()) { + if (kvm_enabled() && !kvm_enable_x2apic()) { error_setg(errp, "eim=on requires support on the KVM side" "(X2APIC_API, first shipped in v4.7)"); return false; diff --git a/hw/i386/x86.c b/hw/i386/x86.c index a88a126123..d2920af792 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -136,7 +136,7 @@ void x86_cpus_init(X86MachineState *x86ms, int default_cpu_version) * With KVM's in-kernel lapic: only if X2APIC API is enabled. */ if (x86ms->apic_id_limit > 255 && !xen_enabled() && - (!kvm_irqchip_in_kernel() || !kvm_enable_x2apic())) { + kvm_enabled() && (!kvm_irqchip_in_kernel() || !kvm_enable_x2apic())) { error_report("current -smp configuration requires kernel " "irqchip and X2APIC API support."); exit(EXIT_FAILURE); diff --git a/target/i386/kvm/kvm-stub.c b/target/i386/kvm/kvm-stub.c index f985d9a1d3..62cccebee4 100644 --- a/target/i386/kvm/kvm-stub.c +++ b/target/i386/kvm/kvm-stub.c @@ -12,13 +12,6 @@ #include "qemu/osdep.h" #include "kvm_i386.h" -#ifndef __OPTIMIZE__ -bool kvm_enable_x2apic(void) -{ - return false; -} -#endif - bool kvm_hv_vpindex_settable(void) { return false;