From nobody Sat May 18 22:15:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1714013973; cv=none; d=zohomail.com; s=zohoarc; b=Tq8AYeQSnPhg3qZUop0qm/Fug5ZYsM06FnTO7zHvqd8fKvsGFBOGdD86YSl2zeNT4W/JVKAankV2Yu0GcM9j4vj/oB1Vt50sq8MwAj24yY7GyNxxSFO+5vCbxtPLE5NZT4HXaAmXje4OjDR6DcVcNc+ZAlsClRIX2iNKQMt3gGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1714013973; h=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=fFFGs4ykiTrN5yc01Jc8J4I6EzYhWwNAHc9/k27XxiQ=; b=elpx9AZ1ywi9wRKsbqmHAAUDlWYwO2W8qJtQe+wvEjlsVHYMxXHkCc/sYPhetFU4SfqvtFJ5Q87/g7nztf1bvJfbTtThaBBkYNcsaPiaDabycnQHyrj91doUqDZF051LmodZRM6pbnN1bIjG9ApvMwn4IIZ69E7FocnP9q4Nujo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 17140139733751012.6415610028308; Wed, 24 Apr 2024 19:59:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzpK2-0006jy-7M; Wed, 24 Apr 2024 22:58:54 -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 1rzpJw-0006jG-V5; Wed, 24 Apr 2024 22:58:49 -0400 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzpJt-00055o-Pm; Wed, 24 Apr 2024 22:58:48 -0400 Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 19:58:44 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa001.jf.intel.com with ESMTP; 24 Apr 2024 19:58:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714013926; x=1745549926; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UzWS39yvXKazwXHx6xonklzmLlk2yJapDzB+gzVW8+M=; b=Pl+Z+/MUrOccy8fms21/DOhx4gL+AwEtcAK/cwst26slv/rOScasT+Fx AS7gZ8qzDO2XOMpKEJlgqbKGfmjcOHl9fovjZ7Zub/RltJ8uBr39KfL6O dQCHNfnLzGLT9A5QF6Mn6XqLU1IYYpFZGRN1+3QQacWBStv79ZelFiuTp 2+6VqjkJ+CiygVaFgZUazpXQZcs/pe3PtFPeQxUTRc77Vmqh2yDHzNkwy GbQI7BAs2IJNyAFxrw8tiZ5WldxUNr0l6y9FNjsI/h8mhmLC45RZ9KF6N 9FbOCFRltoHBFiMN5ZwHQTxm7KWasxjvEsiq/hyug7IaIcQfM/1OBUtat w==; X-CSE-ConnectionGUID: WoD+nZARR2mvdMHrUnf7ZA== X-CSE-MsgGUID: VEfG/y5cTCegrXi0Mv4mSg== X-IronPort-AV: E=McAfee;i="6600,9927,11054"; a="9605640" X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="9605640" X-CSE-ConnectionGUID: DtCxYZWmQw+kAYNsZ+vd9Q== X-CSE-MsgGUID: jyoXAQWLRderQF3JIjyKtg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="62395656" From: Zhao Liu To: Thomas Huth , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Zhao Liu Subject: [PATCH v2 1/7] target/s390x/cpu_model: Make check_compatibility() return boolean Date: Thu, 25 Apr 2024 11:12:26 +0800 Message-Id: <20240425031232.1586401-2-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240425031232.1586401-1-zhao1.liu@intel.com> References: <20240425031232.1586401-1-zhao1.liu@intel.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=198.175.65.21; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.668, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @intel.com) X-ZM-MESSAGEID: 1714013976208100003 Content-Type: text/plain; charset="utf-8" As error.h suggested, the best practice for callee is to return something to indicate success / failure. With returned boolean, there's no need to check @err. Suggested-by: Thomas Huth Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- target/s390x/cpu_models.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 8ed3bb6a27b3..8cb47d905fb4 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -510,7 +510,7 @@ static void check_compat_model_failed(Error **errp, return; } =20 -static void check_compatibility(const S390CPUModel *max_model, +static bool check_compatibility(const S390CPUModel *max_model, const S390CPUModel *model, Error **errp) { ERRP_GUARD(); @@ -518,11 +518,11 @@ static void check_compatibility(const S390CPUModel *m= ax_model, =20 if (model->def->gen > max_model->def->gen) { check_compat_model_failed(errp, max_model, "Selected CPU generatio= n is too new"); - return; + return false; } else if (model->def->gen =3D=3D max_model->def->gen && model->def->ec_ga > max_model->def->ec_ga) { check_compat_model_failed(errp, max_model, "Selected CPU GA level = is too new"); - return; + return false; } =20 #ifndef CONFIG_USER_ONLY @@ -530,14 +530,14 @@ static void check_compatibility(const S390CPUModel *m= ax_model, error_setg(errp, "The unpack facility is not compatible with " "the --only-migratable option. You must remove either " "the 'unpack' facility or the --only-migratable option"= ); - return; + return false; } #endif =20 /* detect the missing features to properly report them */ bitmap_andnot(missing, model->features, max_model->features, S390_FEAT= _MAX); if (bitmap_empty(missing, S390_FEAT_MAX)) { - return; + return true; } =20 error_setg(errp, " "); @@ -546,6 +546,7 @@ static void check_compatibility(const S390CPUModel *max= _model, "available in the current configuration: "); error_append_hint(errp, "Consider a different accelerator, QEMU, or kernel v= ersion\n"); + return false; } =20 S390CPUModel *get_max_cpu_model(Error **errp) @@ -605,8 +606,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) cpu->model->cpu_ver =3D max_model->cpu_ver; =20 check_consistency(cpu->model); - check_compatibility(max_model, cpu->model, &err); - if (err) { + if (!check_compatibility(max_model, cpu->model, &err)) { error_propagate(errp, err); return; } --=20 2.34.1 From nobody Sat May 18 22:15:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1714014029; cv=none; d=zohomail.com; s=zohoarc; b=k1nWbtfJKKZ2H/FKjtDmDjd8DrVQQMwDBaGPtZDeAN/TYYN7AqLTA9zs9hO89D5IDtyA14EtDEhlgjcImgsDOg1aFErHKigl8cwySnOKtE/G8OV4qxbbGCcFkb9OqTGVeb9SkzJzXDAR16rjXUUOorvn/HTwaSxY1s5PwzDJJUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1714014029; h=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=vDwMZvylKs6yV7A0ioRmLW16NxWVqv1ip0rCM7eb9Z0=; b=eckZTem8ffwlQbvJ/M7phDXAOvn1+zF4LJ9ZyRtmXUNgIEfyS6wkZcxoGHnXRVyzXBQqTJ6JWNtKyAwuG2xNCEyDovaXg6kSSxegO68p8S2OfZfTF6iJFPFxKD2jCjlFBcexjBDuZBcVFp6ZwpwnBi/gOT6jD5Uoxa+4o3PxV2U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1714014029091320.1335093710269; Wed, 24 Apr 2024 20:00:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzpK7-0006mM-DD; Wed, 24 Apr 2024 22:58:59 -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 1rzpJy-0006ja-6T; Wed, 24 Apr 2024 22:58:50 -0400 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzpJw-00055w-1f; Wed, 24 Apr 2024 22:58:49 -0400 Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 19:58:47 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa001.jf.intel.com with ESMTP; 24 Apr 2024 19:58:44 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714013928; x=1745549928; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VhsAZz3GZDugXvCbTu1lmTbG6KqX61IfVZfRXKWJzJA=; b=Z4L4xyhTc3BTUigtqh1blhDdxUNYLLPlR3EZrv70MTkRIruPjHmEHPP6 ljKMq10TSpL6B8SrlgaysVHRy1TcctCwXn46wt3uV1qqVswquPqqkkYgS sX6LlkfLTvIWsD6bVy9+a3BgxfJ8HQHh3aHziY/+eWmpxSBFaML5qUHsr 5vIe0PY8oe34LFlGWeeH5mUxaLiGKBogyua/WyN+flblSUCpt54QUmwpK Zc2Xzg/10Gei2Aw4vANA+PqPk3Wa1Gkzy3i8IkgqWrbM9OaG/kjj14tTl E2E+C8kAup2/88BAHNlEUplTTKrlabxyeYq70Zndc+tPnFSkUdfVArD56 A==; X-CSE-ConnectionGUID: UHX/Rnk8TFW70tE15Gxv7Q== X-CSE-MsgGUID: 0x3epI2hRdmmoP7pBjQmaw== X-IronPort-AV: E=McAfee;i="6600,9927,11054"; a="9605645" X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="9605645" X-CSE-ConnectionGUID: zzlCY8FgSdaQP8FgQAEYww== X-CSE-MsgGUID: 6kUWRUHbRoyTvTSrFSDrkA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="62395668" From: Zhao Liu To: Thomas Huth , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Zhao Liu Subject: [PATCH v2 2/7] target/s390x/cpu_model: Drop local @err in s390_realize_cpu_model() Date: Thu, 25 Apr 2024 11:12:27 +0800 Message-Id: <20240425031232.1586401-3-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240425031232.1586401-1-zhao1.liu@intel.com> References: <20240425031232.1586401-1-zhao1.liu@intel.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=198.175.65.21; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.668, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @intel.com) X-ZM-MESSAGEID: 1714014030703100003 Content-Type: text/plain; charset="utf-8" Use @errp to fetch error information directly and drop the local variable @err. Suggested-by: Thomas Huth Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- target/s390x/cpu_models.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 8cb47d905fb4..052540a866ac 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -577,7 +577,6 @@ S390CPUModel *get_max_cpu_model(Error **errp) void s390_realize_cpu_model(CPUState *cs, Error **errp) { ERRP_GUARD(); - Error *err =3D NULL; S390CPUClass *xcc =3D S390_CPU_GET_CLASS(cs); S390CPU *cpu =3D S390_CPU(cs); const S390CPUModel *max_model; @@ -606,8 +605,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) cpu->model->cpu_ver =3D max_model->cpu_ver; =20 check_consistency(cpu->model); - if (!check_compatibility(max_model, cpu->model, &err)) { - error_propagate(errp, err); + if (!check_compatibility(max_model, cpu->model, errp)) { return; } =20 --=20 2.34.1 From nobody Sat May 18 22:15:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1714013985; cv=none; d=zohomail.com; s=zohoarc; b=bYRYU57+vk0BnkrTy/cDchgqMf6c8YX+1Xf5Furz/wAgAlrDH7xu6j6LJoHdUWirMrP8o/WOWH6F285Q/pnew+d5dT8AQMyUmWCOnO0xzg5uqZTlVLmybdz7f0L69+IKonQ1qt44foGmkI0xjQy3kd843N3povsOUCOP0KFxK4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1714013985; 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=+nzjerLpwsv7Q+GAsSqkKFSc+Z/ovhSWspBMcAf5j6E=; b=FEy3vXe1Rcuzh1gLEODzt+Kai8WHXsrIf+L7NG0Etr+llAS6kidS2/nHF3pslarxJeirUGjUepS0bnYRapy6Y102o0Snpet+zqrlhQI38KlDp/5rojly11+AvjRMbz5VarTgSFGrPQ9ULmjua6piTTExogsu/ystv7RTt0GWU8Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1714013985828797.8143018783522; Wed, 24 Apr 2024 19:59:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzpK9-0006ne-M6; Wed, 24 Apr 2024 22:59:01 -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 1rzpK0-0006jx-HN; Wed, 24 Apr 2024 22:58:52 -0400 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzpJy-00055w-UA; Wed, 24 Apr 2024 22:58:52 -0400 Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 19:58:50 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa001.jf.intel.com with ESMTP; 24 Apr 2024 19:58:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714013931; x=1745549931; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PJPFCA7BY25YZOOud8GjsPozRvVnyadtZVhQM8SLIwM=; b=becJzPYRLgmrO7zKjSd/KCojvGG9I8uztaPlWOQFb2KLJfhFVijpFQGM v4fo55jMWRiMwuJisD+dcYbymqgCFDuYzswTHCy8IdxNg2F9fUhBVxING vvim4ojhjqDWiePuUzN6K2rgDrlIHuldI0TKeCMvgC+2TVPSUX8LmcwSz WV9RbRPt85nNPJUUng5o042qPBttb1iy5l9wKcBfYqk5X1fOoOG2ONBtN Y6jkgEN3luiME4CtzJ1RAKTa66P+d5J5XNN78LuACQm1CydZ/43FrKeV9 0tKhv6x0ADHV8LoZbJDmsZ+UJZi9TtRsiQOlD/0QY1Q1r/DfYNr0dI+Qi w==; X-CSE-ConnectionGUID: rItFOClmTX+RY/8CGGSSVA== X-CSE-MsgGUID: jZDnOEcNTrORRb90f/HxLg== X-IronPort-AV: E=McAfee;i="6600,9927,11054"; a="9605653" X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="9605653" X-CSE-ConnectionGUID: F/aid7veQRill52Gdylhvw== X-CSE-MsgGUID: glA8qC35Qc6/uWVLMFd3NA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="62395684" From: Zhao Liu To: Thomas Huth , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Zhao Liu Subject: [PATCH v2 3/7] target/s390x: Remove KVM stubs in cpu_models.h Date: Thu, 25 Apr 2024 11:12:28 +0800 Message-Id: <20240425031232.1586401-4-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240425031232.1586401-1-zhao1.liu@intel.com> References: <20240425031232.1586401-1-zhao1.liu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=198.175.65.21; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.668, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @intel.com) X-ZM-MESSAGEID: 1714013986558100005 From: Philippe Mathieu-Daud=C3=A9 Since the calls are elided when KVM is not available, we can remove the stubs (which are never compiled). Inspired-by: Thomas Huth > Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Zhao Liu Signed-off-by: Zhao Liu --- target/s390x/cpu_models.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/target/s390x/cpu_models.h b/target/s390x/cpu_models.h index d7b89129891a..a89c2a15ab54 100644 --- a/target/s390x/cpu_models.h +++ b/target/s390x/cpu_models.h @@ -114,23 +114,8 @@ static inline uint64_t s390_cpuid_from_cpu_model(const= S390CPUModel *model) S390CPUDef const *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec= _ga, S390FeatBitmap features); =20 -#ifdef CONFIG_KVM bool kvm_s390_cpu_models_supported(void); void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp); void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp); -#else -static inline void kvm_s390_get_host_cpu_model(S390CPUModel *model, - Error **errp) -{ -} -static inline void kvm_s390_apply_cpu_model(const S390CPUModel *model, - Error **errp) -{ -} -static inline bool kvm_s390_cpu_models_supported(void) -{ - return false; -} -#endif =20 #endif /* TARGET_S390X_CPU_MODELS_H */ --=20 2.34.1 From nobody Sat May 18 22:15:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1714014082; cv=none; d=zohomail.com; s=zohoarc; b=YeV/0An301GrqRWk/nqSXq4ollot3VNns58X+kq5bsWsg0RTLxaJw/0QECmRtd4Gw39Qat3I4ht1HbZOiiSmu1mNo7KxXJfp0SSWx8fcVEMkeSNisMmegSwA1WUmXDyhTkLQTL8eM5flN10I8JFF36hp1NYbldO0d7wsGJRF50A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1714014082; h=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=VYG3r156Qgqf2NDuIpJQpejdU0efFEcodUIPalPCRmE=; b=AxuEHWwLnmFQ59n6scGc8/V9PlwaPTnC7OVZBO4A1qrGZTjfO1qnNrSoc8K62MRHFNl4FGgWhufuoXNlp2P7n4ZhiXdjEwTGpAQy+LRIrO5lTjSUJk+wmRNnuZcoiW3WwLAqKytW/BYvgDJK9NeIpNV6PqglVVkcBSaGk4G5Gu0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1714014082648474.5895267811451; Wed, 24 Apr 2024 20:01:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzpK6-0006m3-H4; Wed, 24 Apr 2024 22:58:58 -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 1rzpK3-0006kb-PK; Wed, 24 Apr 2024 22:58:55 -0400 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzpK2-00056p-1Z; Wed, 24 Apr 2024 22:58:55 -0400 Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 19:58:53 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa001.jf.intel.com with ESMTP; 24 Apr 2024 19:58:50 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714013934; x=1745549934; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Jxtgf1M3qa4QDchG9UoRAqtFphtYY47nm2E2h9u0rZg=; b=IZ4dBFyXwbXkwH/Ko/9w3nHSVWPi0y7YHOGZq8IhYkbEGAvMb9qxiM3p ZYnuCJ4OJcdv0/reMrtRc2F/DLoy1dqsNYTdvpVg1CeRfQVmoLkBnEkOF ZTfw2B7QvOqkHXy+BmDmRgI/qDuBm4ZySEYry0HxhfG3J5AQLLSGo7xwO gZqKmgWfTeT6Wy1FsKTIka0Yn2gZVNnSHS7LmB7DLZmT+pwYalaRPzerk iQIx3986KZS7dg9YZBTHzni4OZiWFtAKZgarIEzwwIlDfxFn9TPMyP+17 6Pu2mv5yZYBxqpAM23e7PbXy0rFHsCWIgSTrFJnlGXX2Be7H93LBtNEqA Q==; X-CSE-ConnectionGUID: EHuS73anQkaDNCjop7BU0Q== X-CSE-MsgGUID: 5dUv/oiDTQm48S+r/73etw== X-IronPort-AV: E=McAfee;i="6600,9927,11054"; a="9605659" X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="9605659" X-CSE-ConnectionGUID: 2D4+rdj2Rk2Ul8hZ6el77Q== X-CSE-MsgGUID: 3bn1xvccS+es8iX86Lrvzg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="62395695" From: Zhao Liu To: Thomas Huth , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Zhao Liu Subject: [PATCH v2 4/7] target/s390x/cpu_models: Make kvm_s390_get_host_cpu_model() return boolean Date: Thu, 25 Apr 2024 11:12:29 +0800 Message-Id: <20240425031232.1586401-5-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240425031232.1586401-1-zhao1.liu@intel.com> References: <20240425031232.1586401-1-zhao1.liu@intel.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=198.175.65.21; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.668, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @intel.com) X-ZM-MESSAGEID: 1714014082856100001 Content-Type: text/plain; charset="utf-8" As error.h suggested, the best practice for callee is to return something to indicate success / failure. So make kvm_s390_get_host_cpu_model() return boolean and check the returned boolean in get_max_cpu_model() instead of accessing @err. Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- target/s390x/cpu_models.c | 9 ++++----- target/s390x/cpu_models.h | 2 +- target/s390x/kvm/kvm.c | 13 +++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 052540a866ac..a0e4acb707d7 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -560,16 +560,15 @@ S390CPUModel *get_max_cpu_model(Error **errp) } =20 if (kvm_enabled()) { - kvm_s390_get_host_cpu_model(&max_model, &err); + if (!kvm_s390_get_host_cpu_model(&max_model, &err)) { + error_propagate(errp, err); + return NULL; + } } else { max_model.def =3D s390_find_cpu_def(QEMU_MAX_CPU_TYPE, QEMU_MAX_CP= U_GEN, QEMU_MAX_CPU_EC_GA, NULL); bitmap_copy(max_model.features, qemu_max_cpu_feat, S390_FEAT_MAX); } - if (err) { - error_propagate(errp, err); - return NULL; - } cached =3D true; return &max_model; } diff --git a/target/s390x/cpu_models.h b/target/s390x/cpu_models.h index a89c2a15ab54..c14aff6c10eb 100644 --- a/target/s390x/cpu_models.h +++ b/target/s390x/cpu_models.h @@ -115,7 +115,7 @@ S390CPUDef const *s390_find_cpu_def(uint16_t type, uint= 8_t gen, uint8_t ec_ga, S390FeatBitmap features); =20 bool kvm_s390_cpu_models_supported(void); -void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp); +bool kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp); void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp); =20 #endif /* TARGET_S390X_CPU_MODELS_H */ diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 4dcd757cdcc3..2c3e05cae3ad 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -2375,7 +2375,7 @@ bool kvm_s390_cpu_models_supported(void) KVM_S390_VM_CPU_MACHINE_SUBFUNC); } =20 -void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) +bool kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) { struct kvm_s390_vm_cpu_machine prop =3D {}; struct kvm_device_attr attr =3D { @@ -2390,14 +2390,14 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *mode= l, Error **errp) =20 if (!kvm_s390_cpu_models_supported()) { error_setg(errp, "KVM doesn't support CPU models"); - return; + return false; } =20 /* query the basic cpu model properties */ rc =3D kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attr); if (rc) { error_setg(errp, "KVM: Error querying host CPU model: %d", rc); - return; + return false; } =20 cpu_type =3D cpuid_type(prop.cpuid); @@ -2420,13 +2420,13 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *mode= l, Error **errp) rc =3D query_cpu_feat(model->features); if (rc) { error_setg(errp, "KVM: Error querying CPU features: %d", rc); - return; + return false; } /* get supported cpu subfunctions indicated via query / test bit */ rc =3D query_cpu_subfunc(model->features); if (rc) { error_setg(errp, "KVM: Error querying CPU subfunctions: %d", rc); - return; + return false; } =20 /* PTFF subfunctions might be indicated although kernel support missin= g */ @@ -2482,7 +2482,7 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model,= Error **errp) } if (!model->def) { error_setg(errp, "KVM: host CPU model could not be identified"); - return; + return false; } /* for now, we can only provide the AP feature with HW support */ if (ap_available()) { @@ -2506,6 +2506,7 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model,= Error **errp) /* strip of features that are not part of the maximum model */ bitmap_and(model->features, model->features, model->def->full_feat, S390_FEAT_MAX); + return true; } =20 static int configure_uv_feat_guest(const S390FeatBitmap features) --=20 2.34.1 From nobody Sat May 18 22:15:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1714014011; cv=none; d=zohomail.com; s=zohoarc; b=Oa1zIQUSAOXXIYjsarigkUhPlEXcomgJSYDVtoPh8hsdNtYHFU84bmLDM0lshjDJHSYl1Us1MpesSvRZezkJ/UIEg2W2Zy1rCkwh/G6diC7x4t2wAkp32Guk+7SWfeBqeitjm6NVs9fq1FAd7dYYTPPOLFi7l7OxnL+RrbCQEU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1714014011; h=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=3nhEDFNrl4eYvTgK8ecR95zsGtYrr0Zz0+WHv2RY8gk=; b=c2npLMLzjN2YN0NCxr6toIpMDawyGRu+8epvsJ1h2SgtbHcK5XAekKdu0dPv+zPvT6RHpvvhTGvEfCPROdZRKxttsNymZC9gaeN/+7I7M/+3Rchiz45LETum2Mw/1GWQg7UsyKo6BVcbPfsvC7pjzqRYyNakKFDI8upt0ZX8024= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1714014011870288.38149086218357; Wed, 24 Apr 2024 20:00:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzpKB-0006oC-1T; Wed, 24 Apr 2024 22:59:03 -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 1rzpK6-0006m7-IO; Wed, 24 Apr 2024 22:58:58 -0400 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzpK4-00056r-7p; Wed, 24 Apr 2024 22:58:57 -0400 Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 19:58:55 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa001.jf.intel.com with ESMTP; 24 Apr 2024 19:58:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714013937; x=1745549937; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uIA3FScaT/QajfQBBLkqnXQiTMjVrt19xThYfs85OUY=; b=KNo8jFjwQBmpOo7qJ8GzJoWPoRDEl0YfvrqbjWEM4yFzTkg+VPYZ+FI3 VQze0WCNO4Qkkg1oruAJD2TkyHnn36XkFKUa1yzAynYk/Aj/jVh4ZJFy5 +VqUj5GKeG7cj2EQdfBsm9a/kLv7YSN9g/qpnT6jObc9jmDB0mBrg+R7k HlyXyTodZIx5eI1FF45Crd4xegCnhu/W2lszxECuMiGk1UQMhvYMG7FAa WLGuAiZRH8Fd/DEP4GrPK1AtmhKVGAjb4psGQwz+6MGSUEcxkByffaXT5 xUVMm9lUQyz6GTxhr4/3tlmmkNe2RoErP/ZMhOavS7vOXES5PezjkTDTk Q==; X-CSE-ConnectionGUID: hDhse/ZrSJ+rxIDePN568g== X-CSE-MsgGUID: t50j6gsbQcemGxtnOydkCw== X-IronPort-AV: E=McAfee;i="6600,9927,11054"; a="9605671" X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="9605671" X-CSE-ConnectionGUID: jFHP8G1BRw23n7tv/Ys9ug== X-CSE-MsgGUID: 6vGgELU5QiqIFN9/ejOtCg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="62395703" From: Zhao Liu To: Thomas Huth , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Zhao Liu Subject: [PATCH v2 5/7] target/s390x/cpu_models: Drop local @err in get_max_cpu_model() Date: Thu, 25 Apr 2024 11:12:30 +0800 Message-Id: <20240425031232.1586401-6-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240425031232.1586401-1-zhao1.liu@intel.com> References: <20240425031232.1586401-1-zhao1.liu@intel.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=198.175.65.21; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.668, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @intel.com) X-ZM-MESSAGEID: 1714014012658100001 Content-Type: text/plain; charset="utf-8" Use @errp to fetch error information directly and drop the local variable @err. Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- target/s390x/cpu_models.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index a0e4acb707d7..aae452cfd3fc 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -551,7 +551,6 @@ static bool check_compatibility(const S390CPUModel *max= _model, =20 S390CPUModel *get_max_cpu_model(Error **errp) { - Error *err =3D NULL; static S390CPUModel max_model; static bool cached; =20 @@ -560,8 +559,7 @@ S390CPUModel *get_max_cpu_model(Error **errp) } =20 if (kvm_enabled()) { - if (!kvm_s390_get_host_cpu_model(&max_model, &err)) { - error_propagate(errp, err); + if (!kvm_s390_get_host_cpu_model(&max_model, errp)) { return NULL; } } else { --=20 2.34.1 From nobody Sat May 18 22:15:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1714013983; cv=none; d=zohomail.com; s=zohoarc; b=NcdQjozGa4795m0i8sl0u0IYnMD8uBnoy83RyhtXWOH8+puOzZ8rpLbSFZfqJIz+IYilkfkgV6MGyBDPpYtu7HhxjDXuJdNNydKcCGz9lfecePGdOK8990/XzSmkIW9qDVGoqHJu+y4Uq+xdVs1BpHOZ/zuLrCOBp20/P+cKbrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1714013983; h=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=J4MPSicV60nnhowNfy8r1VXC2qt4gZTSI18yYtbPveo=; b=Vqu3SU2az8s+Sd9JnAyabFoESGTwku+KKArbiwc/9u9bDelt+1I/2Yuwpbmp4U1gv2xmcWd+cUcSV//89EBDM32YhUgNww32eCw/K+OWjPh3ir6JL2cyFlKhvHzvgc5c0go9DfWnYAQLPBUZJNJ9rpKNLnrUOLNe/tRwgD4gWt4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1714013983595108.99218491051943; Wed, 24 Apr 2024 19:59:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzpKA-0006o8-LS; Wed, 24 Apr 2024 22:59:02 -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 1rzpK9-0006nd-7e; Wed, 24 Apr 2024 22:59:01 -0400 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzpK7-00056p-1C; Wed, 24 Apr 2024 22:59:00 -0400 Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 19:58:58 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa001.jf.intel.com with ESMTP; 24 Apr 2024 19:58:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714013939; x=1745549939; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e3Q+Y5fMB14WcsrZBnrBXX5kf/gMjWQSeAZQ0eh6Sn4=; b=VJN/clOxgI4C1mwZoPKb48ib1TuIfe6sHr+0g+6Q3Qt5IP9no5YoQW5L Ga5flecChpQP+KJxzSUmXMZs+WBIy9lYWCsuHowvTK/NLhIb2DmtkIF0j N4y6/Ga1HIdBIWvvBbyI+RZb+pS7wXVkZKPctpruUjMMbUCwg/ko/lSza HJdH2hpCOkxN3qnLvwdSAUbXdQA7Kbp/327o0Ii4mhUNpQLkh2nGbph7I fVjuHAHU5qnXQuWMhMNiyjAVNuAGSozvQX3QTFJQjkzXTsdHRQPG7J0bL R1nTGd2jfGC/AztF+KjTff4P48dk05AAzXDCujvG9+m8dlYhpMx9Os2UJ A==; X-CSE-ConnectionGUID: 0dxDiO87THSr5mheqpFILg== X-CSE-MsgGUID: bUNlFC/hT+CQdmBXtQi7Xg== X-IronPort-AV: E=McAfee;i="6600,9927,11054"; a="9605676" X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="9605676" X-CSE-ConnectionGUID: lwxtQvbXRH+zMZxhfd7zuw== X-CSE-MsgGUID: adUQ7ZllTseej1kEUkDZXA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="62395708" From: Zhao Liu To: Thomas Huth , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Zhao Liu Subject: [PATCH v2 6/7] target/s390x/cpu_models: Make kvm_s390_apply_cpu_model() return boolean Date: Thu, 25 Apr 2024 11:12:31 +0800 Message-Id: <20240425031232.1586401-7-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240425031232.1586401-1-zhao1.liu@intel.com> References: <20240425031232.1586401-1-zhao1.liu@intel.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=198.175.65.21; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.668, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @intel.com) X-ZM-MESSAGEID: 1714013984557100001 Content-Type: text/plain; charset="utf-8" As error.h suggested, the best practice for callee is to return something to indicate success / failure. So make kvm_s390_apply_cpu_model() return boolean and check the returned boolean in apply_cpu_model() instead of accessing @err. Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- target/s390x/cpu_models.h | 2 +- target/s390x/cpu_models_sysemu.c | 3 +-- target/s390x/kvm/kvm.c | 15 ++++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/target/s390x/cpu_models.h b/target/s390x/cpu_models.h index c14aff6c10eb..71d4bc2dd4a2 100644 --- a/target/s390x/cpu_models.h +++ b/target/s390x/cpu_models.h @@ -116,6 +116,6 @@ S390CPUDef const *s390_find_cpu_def(uint16_t type, uint= 8_t gen, uint8_t ec_ga, =20 bool kvm_s390_cpu_models_supported(void); bool kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp); -void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp); +bool kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp); =20 #endif /* TARGET_S390X_CPU_MODELS_H */ diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sys= emu.c index 2d99218069cb..bf855c659d5e 100644 --- a/target/s390x/cpu_models_sysemu.c +++ b/target/s390x/cpu_models_sysemu.c @@ -405,8 +405,7 @@ void apply_cpu_model(const S390CPUModel *model, Error *= *errp) } =20 if (kvm_enabled()) { - kvm_s390_apply_cpu_model(model, &err); - if (err) { + if (!kvm_s390_apply_cpu_model(model, &err)) { error_propagate(errp, err); return; } diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 2c3e05cae3ad..1b494ecc2076 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -2543,7 +2543,7 @@ static void kvm_s390_configure_apie(bool interpret) } } =20 -void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp) +bool kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp) { struct kvm_s390_vm_cpu_processor prop =3D { .fac_list =3D { 0 }, @@ -2560,11 +2560,11 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *m= odel, Error **errp) if (kvm_s390_cmma_available()) { kvm_s390_enable_cmma(); } - return; + return true; } if (!kvm_s390_cpu_models_supported()) { error_setg(errp, "KVM doesn't support CPU models"); - return; + return false; } prop.cpuid =3D s390_cpuid_from_cpu_model(model); prop.ibc =3D s390_ibc_from_cpu_model(model); @@ -2574,19 +2574,19 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *m= odel, Error **errp) rc =3D kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); if (rc) { error_setg(errp, "KVM: Error configuring the CPU model: %d", rc); - return; + return false; } /* configure cpu features indicated e.g. via SCLP */ rc =3D configure_cpu_feat(model->features); if (rc) { error_setg(errp, "KVM: Error configuring CPU features: %d", rc); - return; + return false; } /* configure cpu subfunctions indicated via query / test bit */ rc =3D configure_cpu_subfunc(model->features); if (rc) { error_setg(errp, "KVM: Error configuring CPU subfunctions: %d", rc= ); - return; + return false; } /* enable CMM via CMMA */ if (test_bit(S390_FEAT_CMM, model->features)) { @@ -2601,8 +2601,9 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *mod= el, Error **errp) rc =3D configure_uv_feat_guest(model->features); if (rc) { error_setg(errp, "KVM: Error configuring CPU UV features %d", rc); - return; + return false; } + return true; } =20 void kvm_s390_restart_interrupt(S390CPU *cpu) --=20 2.34.1 From nobody Sat May 18 22:15:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1714014071; cv=none; d=zohomail.com; s=zohoarc; b=VRllS45nxJ8SjFk288sylPGNK/opFMekqtLlJMKO1HHa5/8kTpqgLb4W+fV7JAy6Up+k3r0rTok7j1t48agXWDTLJFXx55h4zHGHnlLq3fII04P8vQ/IwarLLHBnpBzuIp5CjXJ/7+w/qCiR1X6NmeMVFDWs6p4kK3UWq058R68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1714014071; h=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=CQhVPLIEf1iYzgF1onHxvo8kr5IDapOd2Tme6SCYLPs=; b=TkXuAWIhYg088F2oaaO6EMkbW6/vtTDUZVuOJ+dmz/5nxn6V1XgoCGAV2CQwshuABytv7tnFGoVTj2VMc3edDWDv2uAnAMEmNwT2pO2dxekc8LLfzO5T2W6YJI52v6aI25iXnWJaj2Z0iOoxjJnKzw8V37w3G/tL5go3eYsa5FU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 17140140719271012.6491837940182; Wed, 24 Apr 2024 20:01:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzpKE-0006pH-4m; Wed, 24 Apr 2024 22:59:06 -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 1rzpKB-0006oX-O3; Wed, 24 Apr 2024 22:59:03 -0400 Received: from mgamail.intel.com ([198.175.65.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzpK9-00056r-Uq; Wed, 24 Apr 2024 22:59:03 -0400 Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 19:59:01 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orviesa001.jf.intel.com with ESMTP; 24 Apr 2024 19:58:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714013942; x=1745549942; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e6dWcRslgN31Ixzu7lX4pSShuZhqx1IOMDBdHBsvI1s=; b=JmIcghzRpIu9Zzv463rTWjJV4jTVBX3hyW05NqNyC/ri5f2NV3rxZ9ZB TGdBCsXpKlBx0vz/F0WBsKgISIzS/dxzrQMzk3DpOk1qaw7FS15cykLkr aHTwi6bQAQbQ/muzUjgTfqd7boaEqoQr1GONgmdNpf6IzPFBDF7sBoHMm XwlW8vk2KxkefG+KVapWd68fFjON6u7veN3ur5ysXpqUjPCyDi5EvUxOF adJyGfCoI3INThCjL+iM3L9/oHc3eFwmrpMN0SjEiIbhhNc3Pb9e0f10t vNnPb113GJYDjMy4JgLqXoS0DMTMlrbWul1HycdOljuaHXxt8XhjnG29R w==; X-CSE-ConnectionGUID: 2tc3/r70S/ChhA+M40CpSg== X-CSE-MsgGUID: Tb5f8RNpT8+P+Lntstpm6g== X-IronPort-AV: E=McAfee;i="6600,9927,11054"; a="9605680" X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="9605680" X-CSE-ConnectionGUID: l7G0jNmSTwi5Z/YFaUnDuQ== X-CSE-MsgGUID: laHNVvLhQVSWNWpylqWM/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="62395713" From: Zhao Liu To: Thomas Huth , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Halil Pasic , Christian Borntraeger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Zhao Liu Subject: [PATCH v2 7/7] target/s390x/cpu_models_sysemu: Drop local @err in apply_cpu_model() Date: Thu, 25 Apr 2024 11:12:32 +0800 Message-Id: <20240425031232.1586401-8-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240425031232.1586401-1-zhao1.liu@intel.com> References: <20240425031232.1586401-1-zhao1.liu@intel.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=198.175.65.21; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.668, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @intel.com) X-ZM-MESSAGEID: 1714014072801100001 Content-Type: text/plain; charset="utf-8" Use @errp to fetch error information directly and drop the local variable @err. Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth --- target/s390x/cpu_models_sysemu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sys= emu.c index bf855c659d5e..15be729c3d48 100644 --- a/target/s390x/cpu_models_sysemu.c +++ b/target/s390x/cpu_models_sysemu.c @@ -389,7 +389,6 @@ CpuModelBaselineInfo *qmp_query_cpu_model_baseline(CpuM= odelInfo *infoa, =20 void apply_cpu_model(const S390CPUModel *model, Error **errp) { - Error *err =3D NULL; static S390CPUModel applied_model; static bool applied; =20 @@ -405,8 +404,7 @@ void apply_cpu_model(const S390CPUModel *model, Error *= *errp) } =20 if (kvm_enabled()) { - if (!kvm_s390_apply_cpu_model(model, &err)) { - error_propagate(errp, err); + if (!kvm_s390_apply_cpu_model(model, errp)) { return; } } --=20 2.34.1