From nobody Sun Nov 24 09:30:21 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=1726058269; cv=none; d=zohomail.com; s=zohoarc; b=bSW6BFSMHRKXy0h2Pmx/fyZ684VqiQSVGjPjiJnXuNwRYFlSPwOW71/cGGl/RoG/IhLeDVbLQTMjSFRPuCo4FSNznuDDEmVX0C8qPWdYDkF7QfZ5USzg4dYwM1Ech2/nnXetJhT5z8PEZJK6o6IQFMQlGiDOFwRxFDQie3BssxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726058269; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xtYCdte9dWd9oGT6jGVa2VRP3oHQUflr0u1OJvVB2MA=; b=TAouQvwEJeWHCe4vUNOhc3bv5OdGw/miSYQF9nrZ40UKmgM4cAUWp68A84SXT35SB5DYc26RugK/naxkjcYvVrDaeZPnanbWF9NtCj0XXIiQI9w/0h4Cwt5AHm3E25/i1nJhKEjoZ2GZMms9uJ565vtTX28NSSYZpRcNbtXPyFw= 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 1726058269913160.38325694508103; Wed, 11 Sep 2024 05:37:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soMY1-000650-2F; Wed, 11 Sep 2024 08:34:13 -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 1soMXy-0005mh-KU for qemu-devel@nongnu.org; Wed, 11 Sep 2024 08:34:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1soMXw-00013V-Fe for qemu-devel@nongnu.org; Wed, 11 Sep 2024 08:34:10 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-107-Wz8Rcq_KPZ-vB-UsiYMfHQ-1; Wed, 11 Sep 2024 08:34:06 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-374b9617ab0so2863216f8f.3 for ; Wed, 11 Sep 2024 05:34:06 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956d35b9sm11476718f8f.70.2024.09.11.05.34.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 05:34:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726058047; 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: in-reply-to:in-reply-to:references:references; bh=xtYCdte9dWd9oGT6jGVa2VRP3oHQUflr0u1OJvVB2MA=; b=gFtsPBnO0IJ+0Xzyo0Op987NZbZfQuzdC3AYd8fHfgbLaMIbe4MSrZoT0DzcBLu6e31YR4 eI16369PiTewo5XQW2pFYgmiTW8XGRaRHUgVw748HU3Zmrk02LoW40Ec8EEkmjpW6GC+uc 0hKmpCjBCbm6Ocfekg9CxfKa8uHR2zM= X-MC-Unique: Wz8Rcq_KPZ-vB-UsiYMfHQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726058045; x=1726662845; 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=xtYCdte9dWd9oGT6jGVa2VRP3oHQUflr0u1OJvVB2MA=; b=EMWfj5453TfceR7FqnzMGLvHtDveZJ+O2g6XYRq6jAytjCGxOsOUBgyaWMRfGrIHip QvqD2Mcqt5MffhMUKg8aCLT195OHS/10F/pLvZPxlmwT5++pKStq2XECHAzgqDv26Dcz lrK8tD4+5kS1/6yuW8kBKiWHP20MIY/omdxCI6sufzPs2KmIBHbpGkbc6AsWWmwSXkZF YVB08pz8I7TGUewLLDrE52hRcB5343q+jzlTLC4a+1O3FkuQBjWnaKhhVYtPR+AaS8xQ m+cZw5ha5gCijJC2o1HSKdlNhdLy2SMmBa+n1mPuDf2eaNS1xF/9RV6F+mpHx9VGIgot 0Ong== X-Gm-Message-State: AOJu0Yxevt1BqPXTBjzJbL/WRQZtb9DLzmIQfzUBV7no4QLJ8aSFIJBq WE373ObNVlMhn4k0zETJ9E4Yoe9EPJHHJo7rbgRDuNH2wK138CJewamGSge0T71pk7TQccrBx3p c7Up3i7lf2rBVcPLPb89/OoYiLmUAMkqYLXDEQsP3EoukJIRxd6wCQQtKRI7TgGuKgmalOutm7d uDfc2q71rIC75Jo1LIlnGtJg2KmK53aHaEQDMYTLU= X-Received: by 2002:a5d:4991:0:b0:368:5bb4:169b with SMTP id ffacd0b85a97d-378926858b2mr7941981f8f.4.1726058044579; Wed, 11 Sep 2024 05:34:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNafR3vo7C/29BOJu4tasZKxMizFSJ9u+6mePFyBtocHZYI8Q8jgAoAWHtyi+3mSLgGSQK9w== X-Received: by 2002:a5d:4991:0:b0:368:5bb4:169b with SMTP id ffacd0b85a97d-378926858b2mr7941958f8f.4.1726058044030; Wed, 11 Sep 2024 05:34:04 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Ani Sinha Subject: [PULL 07/17] kvm/i386: fix return values of is_host_cpu_intel() Date: Wed, 11 Sep 2024 14:33:32 +0200 Message-ID: <20240911123342.339482-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911123342.339482-1-pbonzini@redhat.com> References: <20240911123342.339482-1-pbonzini@redhat.com> 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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1726058272025116600 Content-Type: text/plain; charset="utf-8" From: Ani Sinha is_host_cpu_intel() should return TRUE if the host cpu in Intel based, othe= rwise it should return FALSE. Currently, it returns zero (FALSE) when the host CPU is INTEL and non-zero otherwise. Fix the function so that it agrees more wi= th the semantics. Adjust the calling logic accordingly. RAPL needs Intel host = cpus. If the host CPU is not Intel baseed, we should report error. Signed-off-by: Ani Sinha Link: https://lore.kernel.org/r/20240903080004.33746-1-anisinha@redhat.com [While touching the code remove too many spaces from the second part of the error. - Paolo] Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 6 +++--- target/i386/kvm/vmsr_energy.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index d95013a2ce6..7c491378026 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2906,9 +2906,9 @@ static int kvm_msr_energy_thread_init(KVMState *s, Ma= chineState *ms) * 1. Host cpu must be Intel cpu * 2. RAPL must be enabled on the Host */ - if (is_host_cpu_intel()) { - error_report("The RAPL feature can only be enabled on hosts\ - with Intel CPU models"); + if (!is_host_cpu_intel()) { + error_report("The RAPL feature can only be enabled on hosts " + "with Intel CPU models"); ret =3D 1; goto out; } diff --git a/target/i386/kvm/vmsr_energy.c b/target/i386/kvm/vmsr_energy.c index 7e064c5aef3..31508d4e77a 100644 --- a/target/i386/kvm/vmsr_energy.c +++ b/target/i386/kvm/vmsr_energy.c @@ -34,7 +34,7 @@ bool is_host_cpu_intel(void) =20 host_cpu_vendor_fms(vendor, &family, &model, &stepping); =20 - return strcmp(vendor, CPUID_VENDOR_INTEL); + return g_str_equal(vendor, CPUID_VENDOR_INTEL); } =20 int is_rapl_enabled(void) --=20 2.46.0