From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757003867342.17869387167127; Fri, 12 Jan 2018 03:36:43 -0800 (PST) Received: from localhost ([::1]:35204 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxdY-0002zF-J6 for importer@patchew.org; Fri, 12 Jan 2018 06:36:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYU-00079P-Nl for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYQ-0004A4-NM for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:26 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:35234) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYQ-00047a-H0 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:22 -0500 Received: by mail-wm0-x243.google.com with SMTP id r78so11276327wme.0 for ; Fri, 12 Jan 2018 03:31:22 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=cfZ041KDoK43zcz57ci9uOlH/7EpQw1DEpFOjhZ5ag0=; b=EYcemm1n1AIu4KCwgEaU9fBWDeBRgXt+fYRP7CklsnGdlO22h41l3ki6qSX2H1umfm AWR4sYPiel4TgNzOjK7g4SMdScGovPqOAt7Z69WrsKBIGD6BPJotRVFra6dLHNzdvdjS UuusYi8obqQ/GDON2MgnzdPCC45Gxs87VBrOmxB+tmvnGAA2FRPnBFp/TgQOI9hsB32m NHO6gAjChrx+GzZyF0AFb2tQaG/OoNjZlIs33Rvd9rtzj7Vlvnw2DH5xV/oZP+6XGqPU EKB43RSWb5aARfQyB72gLNWREK/xOsptM7NSO/1uGxGho0mNYfqCyl+bIbRNzoZ+LR5+ gwcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=cfZ041KDoK43zcz57ci9uOlH/7EpQw1DEpFOjhZ5ag0=; b=IBcrubeoVQSw24sfttiwOLEUkzgjClPoVXnDIt3CJKhmSejiXzS3J3PzTEtM6oWz1d exy02MWHjMCtoKX3q4E563UD885gU29bCsp55632CyDsaZuBmNF7DHi0aXktB0ZzjCdW Gj3Kkt6PELclU4EdZ4gHvG7MxsHg2FJ6CEr1E9vMVhiZv8WScZsN3abgOEOnC00bn5IX a9X37WdCcfPnPn5hzRdQOlYhxNaNo7bg4OKjBxSiaTZZmK16h1F9JJ54/JZgn7Z7tfxr Jsv3djQx8ioZGCIqJzs12nk2aAJ6DeEhf6tGZKY+C38uqDxrbzhXy/LtS+UfBAzFHERU UiHQ== X-Gm-Message-State: AKwxytfNvpiGjfs3PEe6TSyfH6xxlT5/32MQlWGqyLWZBl6JjjgKI9N5 GdQZz3KacydKMDC+KNFWaFjdAL3i X-Google-Smtp-Source: ACJfBosHKA8suoUFdEhfd7JXVYpuWieJM41RlTh2ZnMnr9YP9uf7E/YtAq9XZ+1GfdGdulPwJIpkVg== X-Received: by 10.28.236.10 with SMTP id k10mr4143672wmh.33.1515756681110; Fri, 12 Jan 2018 03:31:21 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:25 +0100 Message-Id: <1515756676-3860-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 01/52] scsi-generic: Add share-rw option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng Add the property to the device model, then parse it by calling blkconf_apply_backend_options(). In addition to blk_set_perm(), the called function also handles error options and wce. For error options we've already checked that the default values are used, for wce we don't have the option either so it is always the default (true). In other words there is no change of behavior in these regards. Signed-off-by: Fam Zheng Message-Id: <20171205151553.7834-1-famz@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-generic.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index bd0d9ff..ba70c0d 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -482,6 +482,7 @@ static void scsi_generic_realize(SCSIDevice *s, Error *= *errp) int rc; int sg_version; struct sg_scsi_id scsiid; + Error *local_err =3D NULL; =20 if (!s->conf.blk) { error_setg(errp, "drive property not set"); @@ -515,6 +516,13 @@ static void scsi_generic_realize(SCSIDevice *s, Error = **errp) error_setg(errp, "SG_GET_SCSI_ID ioctl failed"); return; } + blkconf_apply_backend_options(&s->conf, + blk_is_read_only(s->conf.blk), + true, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } =20 /* define device state */ s->type =3D scsiid.scsi_type; @@ -565,6 +573,7 @@ static SCSIRequest *scsi_new_request(SCSIDevice *d, uin= t32_t tag, uint32_t lun, =20 static Property scsi_generic_properties[] =3D { DEFINE_PROP_DRIVE("drive", SCSIDevice, conf.blk), + DEFINE_PROP_BOOL("share-rw", SCSIDevice, conf.share_rw, false), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515756830609238.04456809958185; Fri, 12 Jan 2018 03:33:50 -0800 (PST) Received: from localhost ([::1]:35182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxak-0000JF-75 for importer@patchew.org; Fri, 12 Jan 2018 06:33:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYU-00079O-Ml for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYR-0004E6-Nd for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:26 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:36418) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYR-0004Ah-Hd for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:23 -0500 Received: by mail-wm0-x242.google.com with SMTP id b76so11240651wmg.1 for ; Fri, 12 Jan 2018 03:31:23 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=Jt0Xhb4SuzYe0b5ia2LvO8eJ8oboIxs2Kr861nHZqow=; b=VeTNIjq168b7uHrgtA9af+hSib0uqdAfzUUfJI8hrHU1jfx25JLxR5Ge1bD0VBZ67k 4wkK6jVXQM+ziSiZgeXW4GizrcOmhLRkSJzmXAgKYuPdV6l/Ljn5LLlSoxsR72dBPeEt RnfnQmq2UW1IS2iqGMOJxnkCrYPnImZ/viBzwwkmkX+eupHv8w2Is2uE8beRhYrO5KUC soIOj2lEod2PAk8MaMq43PHadTxI0kCiwMmQ6dG7Xu90cCWmk0VQpKvHEUDBYWnoLDQ6 E+FpdHTzYaORY2RwRuDP8UB4wUN4XlM8kTpQwXD+LQ7TffM/Vhq68wsOGUCb998KFPy1 txPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=Jt0Xhb4SuzYe0b5ia2LvO8eJ8oboIxs2Kr861nHZqow=; b=Kp6ntGNHvonvf19WlZLYNeuLU9XQzKYpUXWeE1L4xC/bL4u0a2g43os06Zzh0e/WL4 tudwUUBvi8yGGwWgorrMy9usTu7QM8Az2blt7ftTHOu+ROLE+b/ylovGvEhGmI2Irpf+ lxMFs+kS83KZhxJEA6+LWCIFktAgT5sOvp0OPP2R4391a4wP1KXziChH47CNWJJ74CQF yog92SnQ8SPj6EOXSJeko25zorI2S+ROPihXvVtOAa2nxIArqZK5R3VZo4mwwUmOdPi+ +GOp/rYn7WJ/P/UIkLrns1xGTVc7f0U4rVxTIQGmciflCUWDbD7ZUJZl4mnSO60cRJRQ 2+Zg== X-Gm-Message-State: AKwxytfjzw4P7kN4h5iXRANtopgn5fq8h3TxBt4MvePHt4A84UbK2IJ1 9CRpJQDiSf6JZjLO/RVXUk2/wFk5 X-Google-Smtp-Source: ACJfBotH6pheHygNDAzOXazpv7hss2fzfvQW6spl4kbDKpcRSlHUb8A9ZHkQzRSJeu7MIqQMqYyW4Q== X-Received: by 10.28.224.137 with SMTP id x131mr4093285wmg.60.1515756682161; Fri, 12 Jan 2018 03:31:22 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:26 +0100 Message-Id: <1515756676-3860-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 02/52] scsi: fix scsi_convert_sense crash when in_buf == NULL && in_len == 0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" scsi_disk_emulate_command passes in_buf =3D=3D NULL when sent a REQUEST SENSE command. Check for in_len =3D=3D 0 before dereferencing in_buf. Fixes: f68d98b21fa74155dc7c1fd212474379ac3c7531 Reported-by: Roman Kagan Tested-by: Roman Kagan Signed-off-by: Paolo Bonzini --- scsi/utils.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scsi/utils.c b/scsi/utils.c index ddae650..8738522 100644 --- a/scsi/utils.c +++ b/scsi/utils.c @@ -322,18 +322,18 @@ int scsi_convert_sense(uint8_t *in_buf, int in_len, SCSISense sense; bool fixed_in; =20 + if (in_len =3D=3D 0) { + return scsi_build_sense_buf(buf, len, SENSE_CODE(NO_SENSE), fixed); + } + fixed_in =3D (in_buf[0] & 2) =3D=3D 0; - if (in_len && fixed =3D=3D fixed_in) { + if (fixed =3D=3D fixed_in) { memcpy(buf, in_buf, MIN(len, in_len)); return MIN(len, in_len); - } - - if (in_len =3D=3D 0) { - sense =3D SENSE_CODE(NO_SENSE); } else { sense =3D scsi_parse_sense_buf(in_buf, in_len); + return scsi_build_sense_buf(buf, len, sense, fixed); } - return scsi_build_sense_buf(buf, len, sense, fixed); } =20 int scsi_sense_to_errno(int key, int asc, int ascq) --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515756831607766.0108685771313; Fri, 12 Jan 2018 03:33:51 -0800 (PST) Received: from localhost ([::1]:35184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxal-0000KU-Aw for importer@patchew.org; Fri, 12 Jan 2018 06:33:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYU-00079Q-OD for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYS-0004Gp-Q7 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:26 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:42352) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYS-0004F2-Je for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:24 -0500 Received: by mail-wm0-x241.google.com with SMTP id b141so11523629wme.1 for ; Fri, 12 Jan 2018 03:31:24 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=WuIGzw7hBamMo8s4pHysTbueWGCHrcegxv2oW6BJiuA=; b=SR5N6uZ1DI8mLo6Jljw+9cxs+/CzVR9JxFfL4ZggwU+5Rdh/nkUYHCrZrZ9mBhy+sI PEZisNHSNm82FdZ4lVf6wYCY/abxXG6gxV6WCluvoxuuV7K+bPXH1winK3M2w+3SpNED XPfQ/f0JmiQb36WtoBW+JSBr3yx0fE4X3IicgFkfOmk9McyP3i6BM5BL1CABSY9TKyjp /AHK/PERTUnnSDbdhUpZvBVYCKFmQJ3CyFnawwIht9FX/Xfm34OE+UkcmuXUL+rP4P6A 6Oy0wpsvUIuge2dEW4H3kPiuWUxmkVIGPTwzD391Xvayz5BumYRFkjEVJ7ZyuOn/dC+f rL3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=WuIGzw7hBamMo8s4pHysTbueWGCHrcegxv2oW6BJiuA=; b=tf25kSUXADKyzvBT1gi5B1my9v3LTyhrwI+pvdDT1sUYuLiUyL1xxBck/wxiKmJ9cH q1bM4GtZAKHOAtTwWMMc2Mbj+48qhA6a9zbykpKyANeBEYb7NstWNNkBE/HmBA14riFh jxlNHTnstEJUEb6htotcHVE9thRhQVfWrUtKKKpt+p7F4AKyPxX6CKspyD7dB0EJv5Fg 5Be0uE6Bhx/FesqdZkHU/zBY3Q9jakhUFF4LsY6oo4cc1G6pAel0FpGKiKgOszW5OLTN XMtz2EE+kdBpDNRHSMl8vvq8ALphYK/Gija7vdHQXgfTp8MhpOZljuFJmYj78FsFKgmD nZag== X-Gm-Message-State: AKwxytdt+HU/cDWCjLcQLBNzwzNfRQqpBIOi1Rio6Y45/YgWjHkSQ9B3 lYkqJgEG+tQVd8b185Pp/DOO0FfZ X-Google-Smtp-Source: ACJfBotsnUtHPWLK4Cv/uvdSZAX5mMut66NH2hR3z3NpDiur3jpUfbPBvkJx+Krw/gds3CiYNTN9wQ== X-Received: by 10.28.84.14 with SMTP id i14mr268534wmb.30.1515756683186; Fri, 12 Jan 2018 03:31:23 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:27 +0100 Message-Id: <1515756676-3860-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 03/52] pc: fail memory hot-plug/unplug with -no-acpi and Q35 machine type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Haozhong Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Haozhong Zhang When -no-acpi option is used with Q35 machine type, no guest ACPI is built, but the ACPI device is still created, so only checking the presence of ACPI device before memory plug/unplug is not enough in such cases. Check whether ACPI is disabled globally in addition and fail memory plug/unplug if it's disabled. Signed-off-by: Haozhong Zhang Message-Id: <20171222015120.31730-1-haozhong.zhang@intel.com> Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 3fcf318..55686bf 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1695,9 +1695,14 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev, align =3D memory_region_get_alignment(mr); } =20 - if (!pcms->acpi_dev) { + /* + * When -no-acpi is used with Q35 machine type, no ACPI is built, + * but pcms->acpi_dev is still created. Check !acpi_enabled in + * addition to cover this case. + */ + if (!pcms->acpi_dev || !acpi_enabled) { error_setg(&local_err, - "memory hotplug is not enabled: missing acpi device"); + "memory hotplug is not enabled: missing acpi device or = acpi disabled"); goto out; } =20 @@ -1729,9 +1734,14 @@ static void pc_dimm_unplug_request(HotplugHandler *h= otplug_dev, Error *local_err =3D NULL; PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); =20 - if (!pcms->acpi_dev) { + /* + * When -no-acpi is used with Q35 machine type, no ACPI is built, + * but pcms->acpi_dev is still created. Check !acpi_enabled in + * addition to cover this case. + */ + if (!pcms->acpi_dev || !acpi_enabled) { error_setg(&local_err, - "memory hotplug is not enabled: missing acpi device"); + "memory hotplug is not enabled: missing acpi device or = acpi disabled"); goto out; } =20 --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15157570073578.966242094171434; Fri, 12 Jan 2018 03:36:47 -0800 (PST) Received: from localhost ([::1]:35205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxdb-00032U-9A for importer@patchew.org; Fri, 12 Jan 2018 06:36:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYW-00079y-1y for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYU-0004K1-2R for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:28 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:39723) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYT-0004Hj-T8 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:26 -0500 Received: by mail-wm0-x242.google.com with SMTP id i11so11126408wmf.4 for ; Fri, 12 Jan 2018 03:31:25 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=40EbTwWkmyPkQVppTjvj5YXrmDerAnz3eL4HXzRdsus=; b=LKd31zbPSI4AKE23Bz9wqCW1HsJzD0tok8znYADTUSWEo4gdjHudc8lDFLt4DftpJn JYOGPX9TGXc3yzd/fiIkAqi4CCoW3ioq4CdFpyvBL/3wvBJ8EcOphDY8lcPdL8gP0kxP 2ylCetoDJobPnN2eOp0icWGSrWjPtbJejGi06xs9oQ4yo5mvqFz0QEVAP0UCFwlm60x1 jID5CZr5V51ORYR4e+52j1FTpcotODZpQLFCZ/N/hgV8/7r2VEkAm+Z85dhOPRyhf/mz 4nB+1BeANc55Mro2N4GqNFiFtsGeJ2HM2SH30vFfwHIWjVr70c5PvtPfwey79ne73Cq8 NC6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=40EbTwWkmyPkQVppTjvj5YXrmDerAnz3eL4HXzRdsus=; b=Qipx+heqUL5mPXvlr5JJDIHlLJAQ6NgmaE5PHZnH4Q/Mf7wKECoXqxqyJg94CjYNI7 vkad1PgbaLzYMOHdgDr3K5hA2Q3DfpclkVx8QnESgOJ7gT2DBO/SgUJ1u2zI018H3Il+ VrFmN0sQyiwyYG2BoOR9So6WVVyT5m/My+RaXQvIfuuO7WuV/KQGtxMKxHPyaBK5sEcK abHozuzuDteLrT0fTD+VXh3biU7r82+ck4iI3uh618sBfY+rtwhCK1IuRSom8b0kx72u 7namtv6dst38De08Bly2ISm/T9/fQHYVZf3R/9KFqiPXx6/6mIW15EAaZjjgu32izz9D MGNg== X-Gm-Message-State: AKwxyteOy/P+ttHTLLqODi3kmRG93oUnAokp6D0HaRlZkMuzTjAXjLsb lVhgTpy3xsTe96soinX8bVN5ptbG X-Google-Smtp-Source: ACJfBov/e4lfgg10vmovu6vjNnSxEwwP22sGcXlePcQMpvriLM0yc1BfmbcP3ShAuiip6fOYlWbhhg== X-Received: by 10.28.93.69 with SMTP id r66mr3979460wmb.24.1515756684547; Fri, 12 Jan 2018 03:31:24 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:28 +0100 Message-Id: <1515756676-3860-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 04/52] hpet: recover timer offset correctly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maria Klimushenkova , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Maria Klimushenkova HPET saves its state by calculating the current time and recovers timer offset using this calculated value. But these calculations include divisions and multiplications. Therefore the timer state cannot be recovered precise enough. This patch introduces saving of the original value of the offset to preserve the determinism of the timer. Signed-off-by: Maria Klimushenkova Signed-off-by: Pavel Dovgalyuk Message-Id: <20171220100205.16625.84632.stgit@pasha-VirtualBox> Signed-off-by: Paolo Bonzini --- hw/timer/hpet.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 577371b..4904a60 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -70,6 +70,7 @@ typedef struct HPETState { =20 MemoryRegion iomem; uint64_t hpet_offset; + bool hpet_offset_loaded; qemu_irq irqs[HPET_NUM_IRQ_ROUTES]; uint32_t flags; uint8_t rtc_irq_level; @@ -221,7 +222,9 @@ static int hpet_pre_save(void *opaque) HPETState *s =3D opaque; =20 /* save current counter value */ - s->hpet_counter =3D hpet_get_ticks(s); + if (hpet_enabled(s)) { + s->hpet_counter =3D hpet_get_ticks(s); + } =20 return 0; } @@ -232,6 +235,8 @@ static int hpet_pre_load(void *opaque) =20 /* version 1 only supports 3, later versions will load the actual valu= e */ s->num_timers =3D HPET_MIN_TIMERS; + /* for checking whether the hpet_offset section is loaded */ + s->hpet_offset_loaded =3D false; return 0; } =20 @@ -252,7 +257,10 @@ static int hpet_post_load(void *opaque, int version_id) HPETState *s =3D opaque; =20 /* Recalculate the offset between the main counter and guest time */ - s->hpet_offset =3D ticks_to_ns(s->hpet_counter) - qemu_clock_get_ns(QE= MU_CLOCK_VIRTUAL); + if (!s->hpet_offset_loaded) { + s->hpet_offset =3D ticks_to_ns(s->hpet_counter) + - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + } =20 /* Push number of timers into capability returned via HPET_ID */ s->capability &=3D ~HPET_ID_NUM_TIM_MASK; @@ -267,6 +275,14 @@ static int hpet_post_load(void *opaque, int version_id) return 0; } =20 +static int hpet_offset_post_load(void *opaque, int version_id) +{ + HPETState *s =3D opaque; + + s->hpet_offset_loaded =3D true; + return 0; +} + static bool hpet_rtc_irq_level_needed(void *opaque) { HPETState *s =3D opaque; @@ -285,6 +301,17 @@ static const VMStateDescription vmstate_hpet_rtc_irq_l= evel =3D { } }; =20 +static const VMStateDescription vmstate_hpet_offset =3D { + .name =3D "hpet/offset", + .version_id =3D 1, + .minimum_version_id =3D 1, + .post_load =3D hpet_offset_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(hpet_offset, HPETState), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_hpet_timer =3D { .name =3D "hpet_timer", .version_id =3D 1, @@ -320,6 +347,7 @@ static const VMStateDescription vmstate_hpet =3D { }, .subsections =3D (const VMStateDescription*[]) { &vmstate_hpet_rtc_irq_level, + &vmstate_hpet_offset, NULL } }; --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757180708190.2062572647194; Fri, 12 Jan 2018 03:39:40 -0800 (PST) Received: from localhost ([::1]:35225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxgL-0005T0-18 for importer@patchew.org; Fri, 12 Jan 2018 06:39:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYW-0007Ad-Nr for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYV-0004Nt-EU for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:28 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:33738) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYV-0004Lk-3x for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:27 -0500 Received: by mail-wm0-x242.google.com with SMTP id x4so1968733wmc.0 for ; Fri, 12 Jan 2018 03:31:27 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=dJpVhCyBEhB4PzFsnZCeRSMC+Jtbthdz5umfkprMfgQ=; b=Fk++0JsMHvXbNBIw8CyLc/7PMYk6zYvjX6Hly1UbfVc6k42cCMuTo2fn+fly2SPnBU pladKavP4YuUfF//Ztp/ZIJz2JJWJs4S8hUmnGggY3zQ3V2DgSL089IkJTvSKI1vJudD n40tHlCx3fcO9ZO5Q6TPjGHpQQENvvXdxjhktVR08OTqeTqgAFoUTKRIUJRFoY9WYXFy aHgpJQxTH5crMpGm8/Y+76Sqe3vnhJ9GqAZBXWDl0GFufP/ea4M7JVuCIatjo7mR++lD DCFkV/V4h6o+tEk7Fyw9UOtGAngERA0I5b3B1k+JGXW8ux3LkHZqJifM7gqj0+SkyrON 2dxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=dJpVhCyBEhB4PzFsnZCeRSMC+Jtbthdz5umfkprMfgQ=; b=Op/spRSa0F4rFiaKsg7oTOiHhU71g40XCfMrn8UQHWzm4P5RETjNCtyPGEpxra2jm5 UC+DDJdIymGLJzScM40Ay57jT/Nj4i5kDqnnbwijVz7pW03w7sLJizadm2qf12Ew5+NK KX0aL3VyVG89wRS3Na2RBoOUZTm+NTJpywzXMfekR36pDYuF3U50Wc2kBuVnDJEyKzs7 ymNxaR1seG+2CTRbjfd0spWAZHdcYHSXvOXk1ulPW6Aii/dLitJH/WPBIjj65QRqz226 zJTnAUE5LJ5nnPR0XFQj8ONimNmIhC8htaXcVCkbV/5LLPfAGLBFkHMz91mkL9go5VrZ fw1w== X-Gm-Message-State: AKwxytcakaUUiC28TKWXd4PgXlYsrdFMdHny7KetkZ1ZseXZIf9l6CKJ 6x/nZAHi6EHTJEkTai1gxvUr+IcG X-Google-Smtp-Source: ACJfBoupYda4V5AVtqqfetMfpVHi1MSM8+ax+v3iSskzk7Z9zmRPSbKY9vwZOVw9kTAAykCSIAmodA== X-Received: by 10.28.202.22 with SMTP id a22mr433778wmg.87.1515756685719; Fri, 12 Jan 2018 03:31:25 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:29 +0100 Message-Id: <1515756676-3860-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 05/52] i386/cpu/kvm: look at PMU's CPUID before setting MSRs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Dakinevich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jan Dakinevich Certain PMU-related MSRs are not supported for CPUs with PMU architecture below version 2. KVM rejects any access to them (see intel_is_valid_msr_idx routine in KVM), and QEMU fails on the following assertion: kvm_put_msrs: Assertion `ret =3D=3D cpu->kvm_msr_buf->nmsrs' failed. QEMU also could fail if KVM exposes less fixed counters then 3. It could happen if host system run inside another hypervisor, which is tweaking PMU-related CPUID. To prevent possible fail, number of fixed counters now is obtained in the same way as number of GP counters. Reviewed-by: Roman Kagan Signed-off-by: Jan Dakinevich Message-Id: <1514383466-7257-1-git-send-email-jan.dakinevich@virtuozzo.com> Signed-off-by: Paolo Bonzini --- target/i386/kvm.c | 80 +++++++++++++++++++++++++++++++++------------------= ---- 1 file changed, 48 insertions(+), 32 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 6f69e2f..d23127c 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -92,8 +92,9 @@ static bool has_msr_hv_stimer; static bool has_msr_hv_frequencies; static bool has_msr_xss; =20 -static bool has_msr_architectural_pmu; -static uint32_t num_architectural_pmu_counters; +static uint32_t has_architectural_pmu_version; +static uint32_t num_architectural_pmu_gp_counters; +static uint32_t num_architectural_pmu_fixed_counters; =20 static int has_xsave; static int has_xcrs; @@ -872,19 +873,28 @@ int kvm_arch_init_vcpu(CPUState *cs) } =20 if (limit >=3D 0x0a) { - uint32_t ver; + uint32_t eax, edx; =20 - cpu_x86_cpuid(env, 0x0a, 0, &ver, &unused, &unused, &unused); - if ((ver & 0xff) > 0) { - has_msr_architectural_pmu =3D true; - num_architectural_pmu_counters =3D (ver & 0xff00) >> 8; + cpu_x86_cpuid(env, 0x0a, 0, &eax, &unused, &unused, &edx); + + has_architectural_pmu_version =3D eax & 0xff; + if (has_architectural_pmu_version > 0) { + num_architectural_pmu_gp_counters =3D (eax & 0xff00) >> 8; =20 /* Shouldn't be more than 32, since that's the number of bits * available in EBX to tell us _which_ counters are available. * Play it safe. */ - if (num_architectural_pmu_counters > MAX_GP_COUNTERS) { - num_architectural_pmu_counters =3D MAX_GP_COUNTERS; + if (num_architectural_pmu_gp_counters > MAX_GP_COUNTERS) { + num_architectural_pmu_gp_counters =3D MAX_GP_COUNTERS; + } + + if (has_architectural_pmu_version > 1) { + num_architectural_pmu_fixed_counters =3D edx & 0x1f; + + if (num_architectural_pmu_fixed_counters > MAX_FIXED_COUNT= ERS) { + num_architectural_pmu_fixed_counters =3D MAX_FIXED_COU= NTERS; + } } } } @@ -1650,32 +1660,36 @@ static int kvm_put_msrs(X86CPU *cpu, int level) if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_STEAL_TIME)) { kvm_msr_entry_add(cpu, MSR_KVM_STEAL_TIME, env->steal_time_msr= ); } - if (has_msr_architectural_pmu) { - /* Stop the counter. */ - kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR_CTRL, 0); - kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL, 0); + if (has_architectural_pmu_version > 0) { + if (has_architectural_pmu_version > 1) { + /* Stop the counter. */ + kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR_CTRL, 0); + kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL, 0); + } =20 /* Set the counter values. */ - for (i =3D 0; i < MAX_FIXED_COUNTERS; i++) { + for (i =3D 0; i < num_architectural_pmu_fixed_counters; i++) { kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR0 + i, env->msr_fixed_counters[i]); } - for (i =3D 0; i < num_architectural_pmu_counters; i++) { + for (i =3D 0; i < num_architectural_pmu_gp_counters; i++) { kvm_msr_entry_add(cpu, MSR_P6_PERFCTR0 + i, env->msr_gp_counters[i]); kvm_msr_entry_add(cpu, MSR_P6_EVNTSEL0 + i, env->msr_gp_evtsel[i]); } - kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_STATUS, - env->msr_global_status); - kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_OVF_CTRL, - env->msr_global_ovf_ctrl); - - /* Now start the PMU. */ - kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR_CTRL, - env->msr_fixed_ctr_ctrl); - kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL, - env->msr_global_ctrl); + if (has_architectural_pmu_version > 1) { + kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_STATUS, + env->msr_global_status); + kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_OVF_CTRL, + env->msr_global_ovf_ctrl); + + /* Now start the PMU. */ + kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR_CTRL, + env->msr_fixed_ctr_ctrl); + kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL, + env->msr_global_ctrl); + } } /* * Hyper-V partition-wide MSRs: to avoid clearing them on cpu hot-= add, @@ -2030,15 +2044,17 @@ static int kvm_get_msrs(X86CPU *cpu) if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_STEAL_TIME)) { kvm_msr_entry_add(cpu, MSR_KVM_STEAL_TIME, 0); } - if (has_msr_architectural_pmu) { - kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR_CTRL, 0); - kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL, 0); - kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_STATUS, 0); - kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_OVF_CTRL, 0); - for (i =3D 0; i < MAX_FIXED_COUNTERS; i++) { + if (has_architectural_pmu_version > 0) { + if (has_architectural_pmu_version > 1) { + kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR_CTRL, 0); + kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL, 0); + kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_STATUS, 0); + kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_OVF_CTRL, 0); + } + for (i =3D 0; i < num_architectural_pmu_fixed_counters; i++) { kvm_msr_entry_add(cpu, MSR_CORE_PERF_FIXED_CTR0 + i, 0); } - for (i =3D 0; i < num_architectural_pmu_counters; i++) { + for (i =3D 0; i < num_architectural_pmu_gp_counters; i++) { kvm_msr_entry_add(cpu, MSR_P6_PERFCTR0 + i, 0); kvm_msr_entry_add(cpu, MSR_P6_EVNTSEL0 + i, 0); } --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515756830607387.3923996506934; Fri, 12 Jan 2018 03:33:50 -0800 (PST) Received: from localhost ([::1]:35183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxak-0000Jh-Ao for importer@patchew.org; Fri, 12 Jan 2018 06:33:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYX-0007As-3M for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYW-0004Q5-A3 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:29 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:40524) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYW-0004OD-4A for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:28 -0500 Received: by mail-wm0-x243.google.com with SMTP id v123so2001713wmd.5 for ; Fri, 12 Jan 2018 03:31:28 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0hr/1+ObD2E84v1XF9jjsh1Rk3PiJjjpJ2tXPz31Nrg=; b=SbtBOUH46rc+ifGHJSg0xiUPeyM1U03UywQIXKgywDnhIA5SW1H2fVSBdohzeh4/Vf lIE0Ztm4QGP1MUr3T0XftSNFjjkgJoxBronHfjAtgjMpiN4QqXp0jR7Lpke+pMoxnPA3 UFb695vVli8iliZOq3zFj7W2M6il3PFl6PIFRQGmwzLGgfZPtZ7ZdU3LdGpylh/qC6KL 4v0iyOUxif20kkdjU6PHmSnr/Pv1IA1jhqaVWsv8VzMcWD51izuyvuK6No/+wE2K+xi9 r/wM4qj7tXkQo5QkjitDi9G4zzd+JS0FMLcYI2/skZ852IF2R9QkLIabQPaRLcgMy6D+ 2tmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=0hr/1+ObD2E84v1XF9jjsh1Rk3PiJjjpJ2tXPz31Nrg=; b=QPtJBiRQfGd0KmTM0zxIa25J+Ch8Tw7ZgW330cfoNHdSo9s+d06bllu3ehUB8Z+dvI /qUohB9tlyiORKiBRb+Bxi7sBgRpW6yL1JBMxhjWpUBHBQrJBe/DENteYk8FnigFw1IY bIFa8EgcpPmdywKhX2rsd4jLBe7LmLs6rI93fZKs4REFlasK8QJeBodTdczdgWi4aQ1U zFJd6Xg8GHb+hPEoRzTcsaoDnXcYKWATO+dV00PWX4HURr0xnvz3PYIWzCO6v/oeD9Ai HHJvuvGRiaeZG1qPdtIEhWdv3Qup8mQIqtXLX7p0gwkbGWqA6POed6GssShPUJ8pdKSM kXzQ== X-Gm-Message-State: AKwxytcv0i3zFYIB/IHQE3Kwhc71SEyj4ayquGLnHTdi4s9v/spmhwmN 8ByfcNOhENAhcvV4tJbtX7WlEc4Z X-Google-Smtp-Source: ACJfBot/wslFfKoYUTLNxwJdMWroaqhVoSiHgrO3ShO90exfT7qk5maR1UnXvYMNjfPv+9qaVss8MQ== X-Received: by 10.28.232.12 with SMTP id f12mr3891827wmh.24.1515756686743; Fri, 12 Jan 2018 03:31:26 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:30 +0100 Message-Id: <1515756676-3860-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 06/52] chardev: use backend chr context when watch for fe X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_6 Z_629925259 SPT_0 From: Peter Xu In commit 6bbb6c0644 ("chardev: use per-dev context for io_add_watch_poll", 2017-09-22) all the chardev watches are converted to use per-chardev gcontext to support chardev to be run outside default main thread. However that's still missing one call from the frontend code. Touch that up. Reviewed-by: Stefan Hajnoczi Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Peter Xu Message-Id: <20180104141835.17987-2-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- chardev/char-fe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chardev/char-fe.c b/chardev/char-fe.c index ee6d596..c611b3f 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -356,7 +356,7 @@ guint qemu_chr_fe_add_watch(CharBackend *be, GIOConditi= on cond, } =20 g_source_set_callback(src, (GSourceFunc)func, user_data, NULL); - tag =3D g_source_attach(src, NULL); + tag =3D g_source_attach(src, s->gcontext); g_source_unref(src); =20 return tag; --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757006123430.39563230004853; Fri, 12 Jan 2018 03:36:46 -0800 (PST) Received: from localhost ([::1]:35207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxdd-00033C-9U for importer@patchew.org; Fri, 12 Jan 2018 06:36:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYY-0007Bo-AK for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYX-0004T5-Cg for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:30 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:34094) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYX-0004Qx-6X for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:29 -0500 Received: by mail-wm0-x242.google.com with SMTP id 81so1969289wmb.1 for ; Fri, 12 Jan 2018 03:31:29 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=XG1iRGuONMkY3+sT4JC6ibJ6XHtgTrqDRFZGOQkLmI0=; b=VBvrbgszzQ5oQZq7EKnfc26h78bKJyZf7kcohFhifgf2MWEzfy5wS997K9vh14PX3L t6u5z5f7Yb8or0fIcZ5Or+vZw88Zze7RyVx7wZyuaeULCqNzmFjC4i3mWx/8bJpQyGzR slZ8d/QtRc9ZNwhrThvouymstBN7oF8ExFwGgrUNEmSMt2d1grk47j+zY17cKOGJpnLN kBI5QKSKAG/4Q7YgsBlN6ogRp/1I+AURFnS4qovtI6Wb7KWV9OjbWpY4+zkMX+5DH9Fm 5Dg6Z0qvC7ZuoyMDQgwMSv2H5UVfGt7s2J5HVy/eYLQxlwznju8whl3ceLL54pyS5U0v oPBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=XG1iRGuONMkY3+sT4JC6ibJ6XHtgTrqDRFZGOQkLmI0=; b=Tc0HqDiI4LS6yo84uj89F4r2zb51qPqExJKt+oZbXOfoicxiXzDIkbtvS/KHZPPzsu 3kcUJp7+dcT/XfychkiuzEp6UydVKEAjqm4i/xvmTlbBtFyrkWpnHXzLD4vQ9QitS4/r aMyub0GJqtmIkPVsCCfS2kiLSpd89Qtxp5OEWFuK1vD6rGjilDtV9gtvm914YfFU8dby vaYkLkNHCD3p/t44BnoTTowx395G/HjWAxkkU73VglAg4j8495FPVj31UipJZ1bYy0IO 329O62VVVFhdaJNiHWXwHE7xR7fnUBfRUuFTcdW2+VHqIY3wjgD6hsXuGuTliALDFFQS r1KQ== X-Gm-Message-State: AKwxytf9Wm0Ovd9lXCOBl5+QYRqUpNdZG8QEGOOlX/vAHgE/IFLEWCE7 n2Oi0F+gtPfssX93J3f4U8FShojE X-Google-Smtp-Source: ACJfBoukL0T4M/ae+YBb1Or9FI1P/8imXKO0QuGey6fK2ghrfbOX2S0dzUR8gazgPlT9d+qo/HvBFg== X-Received: by 10.28.249.12 with SMTP id x12mr3387807wmh.122.1515756687893; Fri, 12 Jan 2018 03:31:27 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:31 +0100 Message-Id: <1515756676-3860-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 07/52] chardev: let g_idle_add() be with chardev gcontext X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu The idle task will be attached to main gcontext even if the chardev backend is running in another gcontext. Fix the only caller by extending the g_idle_add() logic into the more powerful g_source_attach(). It's basically g_idle_add_full() implementation, but with the chardev's gcontext passed in. Signed-off-by: Peter Xu Message-Id: <20180104141835.17987-3-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- chardev/char-pty.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/chardev/char-pty.c b/chardev/char-pty.c index 761ae6d..8248e36 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -43,7 +43,7 @@ typedef struct { /* Protected by the Chardev chr_write_lock. */ int connected; guint timer_tag; - guint open_tag; + GSource *open_source; } PtyChardev; =20 #define PTY_CHARDEV(obj) OBJECT_CHECK(PtyChardev, (obj), TYPE_CHARDEV_PTY) @@ -58,7 +58,7 @@ static gboolean pty_chr_timer(gpointer opaque) =20 qemu_mutex_lock(&chr->chr_write_lock); s->timer_tag =3D 0; - s->open_tag =3D 0; + s->open_source =3D NULL; if (!s->connected) { /* Next poll ... */ pty_chr_update_read_handler_locked(chr); @@ -183,7 +183,7 @@ static gboolean qemu_chr_be_generic_open_func(gpointer = opaque) Chardev *chr =3D CHARDEV(opaque); PtyChardev *s =3D PTY_CHARDEV(opaque); =20 - s->open_tag =3D 0; + s->open_source =3D NULL; qemu_chr_be_event(chr, CHR_EVENT_OPENED); return FALSE; } @@ -194,9 +194,10 @@ static void pty_chr_state(Chardev *chr, int connected) PtyChardev *s =3D PTY_CHARDEV(chr); =20 if (!connected) { - if (s->open_tag) { - g_source_remove(s->open_tag); - s->open_tag =3D 0; + if (s->open_source) { + g_source_destroy(s->open_source); + g_source_unref(s->open_source); + s->open_source =3D NULL; } remove_fd_in_watch(chr); s->connected =3D 0; @@ -210,9 +211,13 @@ static void pty_chr_state(Chardev *chr, int connected) s->timer_tag =3D 0; } if (!s->connected) { - g_assert(s->open_tag =3D=3D 0); + g_assert(s->open_source =3D=3D NULL); + s->open_source =3D g_idle_source_new(); s->connected =3D 1; - s->open_tag =3D g_idle_add(qemu_chr_be_generic_open_func, chr); + g_source_set_callback(s->open_source, + qemu_chr_be_generic_open_func, + chr, NULL); + g_source_attach(s->open_source, chr->gcontext); } if (!chr->gsource) { chr->gsource =3D io_add_watch_poll(chr, s->ioc, --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757174052386.07002510516077; Fri, 12 Jan 2018 03:39:34 -0800 (PST) Received: from localhost ([::1]:35224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxgL-0005Sp-5q for importer@patchew.org; Fri, 12 Jan 2018 06:39:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYa-0007Dx-CL for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYY-0004WR-Q0 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:32 -0500 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:44846) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYY-0004Uh-Fg for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:30 -0500 Received: by mail-wm0-x230.google.com with SMTP id t8so11395251wmc.3 for ; Fri, 12 Jan 2018 03:31:30 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=VLgTLoylah5KKBVNRF08fX3f9h+cvrDLmyOUeqxeE5U=; b=WXthh3Bzr2QmFZ2GJHcL76bV5c/jgUIvQYrySLzlsB0hJQy1FsLHTZfuwOae3MlQZQ Ob2CGGDKC7idxw/jGBYzehxXt71rbdwp/3VdNjJ2HSLfrkCV7UtPSpCvh8Uyf2XoMJYd 0m+HuNkRh912JZkxGpvNxxFkAhMFKWEejpvOXtEBkDP0NPktQZRcPSxJ/tBofmQI+Lr9 yD66nyfpCiyJHu4U7jLKepGe7KW9rSBzqv3hlEPZIXwJNBPzG5nru9PteuyEWpL3iMh0 x8Gc6ZY4FdiratJjb7Iyb8CZ6WhdjsUx3RJ1cHuxFcqWKYEKVKroC852zXmNJLck5UNS E7kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=VLgTLoylah5KKBVNRF08fX3f9h+cvrDLmyOUeqxeE5U=; b=nRbqUANStQiHrODYfMJQolog7xakaFmAHt9Co9+9AcPLPoROjbAPsm0DV/pvjMlaa9 xo8AIK5yd9gw1yRdMOk9bKbLgL0WyFXUw+9nLO0E+ZxD3FwZLuMG5Z+MXLfZsi759dAy fwvSBX1BgyGo5skzKvGXzoUDO8M5xyZPyTpaUpKM3J8vPV65ajGoz2z9bWnI7z+lN6hY nLtvqlto3pZa7D/VFTodl8pZzWitx7/c4AUvL0cUXQ+4PGzCC22/sazJqPYTZAO0Nz0k pW0SJxtL7iN5n6fW/9wAforJv00+9wc04d6bcw9u6r+2Bd7yDKi2EeYMD0PbMk/xJvGT ExPw== X-Gm-Message-State: AKwxytf6H36dvV2WjNJynR2XbsoqN90JoDCBpu5Lxi6WgpX/J41DvTao rtdqBfR6zsbdtjv8ANjRuRmL+1Yl X-Google-Smtp-Source: ACJfBou5B6mHrDHzjSTLi8LmtBBr8LtyztPUkZeoitlUbGwiiO1tKpemPnf1q4okRH9X+HxFQVrzIA== X-Received: by 10.28.35.200 with SMTP id j191mr4191782wmj.146.1515756688963; Fri, 12 Jan 2018 03:31:28 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:32 +0100 Message-Id: <1515756676-3860-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::230 Subject: [Qemu-devel] [PULL 08/52] chardev: introduce qemu_chr_timeout_add_ms() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu It's a replacement of g_timeout_add[_seconds]() for chardevs. Chardevs now can have dedicated gcontext, we should always bind chardev tasks onto those gcontext rather than the default main context. Since there are quite a few of g_timeout_add[_seconds]() callers, a new function qemu_chr_timeout_add_ms() is introduced. One thing to mention is that, terminal3270 is still always running on main gcontext. However let's convert that as well since it's still part of chardev codes and in case one day we'll miss that when we move it out of main gcontext too. Also, convert all the timers from GSource tags into GSource pointers. Gsource tag IDs and g_source_remove()s can only work with default gcontext, while now these GSources can logically be attached to other contexts. So let's use explicit g_source_destroy() plus another g_source_unref() to remove a timer. Note: when in the timer handler, we don't need the g_source_destroy() any more since that'll be done automatically if the timer handler returns false (and that's what all the current handlers do). Yet another note: in pty_chr_rearm_timer() we take special care for ms=3D1000. This patch merged the two cases into one. Signed-off-by: Peter Xu Message-Id: <20180104141835.17987-4-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- chardev/char-pty.c | 43 +++++++++++++++++++------------------------ chardev/char-socket.c | 28 ++++++++++++++++++---------- chardev/char.c | 18 ++++++++++++++++++ hw/char/terminal3270.c | 28 ++++++++++++++++------------ include/chardev/char.h | 3 +++ 5 files changed, 74 insertions(+), 46 deletions(-) diff --git a/chardev/char-pty.c b/chardev/char-pty.c index 8248e36..89315e6 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -42,7 +42,7 @@ typedef struct { =20 /* Protected by the Chardev chr_write_lock. */ int connected; - guint timer_tag; + GSource *timer_src; GSource *open_source; } PtyChardev; =20 @@ -57,7 +57,8 @@ static gboolean pty_chr_timer(gpointer opaque) PtyChardev *s =3D PTY_CHARDEV(opaque); =20 qemu_mutex_lock(&chr->chr_write_lock); - s->timer_tag =3D 0; + s->timer_src =3D NULL; + g_source_unref(s->open_source); s->open_source =3D NULL; if (!s->connected) { /* Next poll ... */ @@ -67,25 +68,25 @@ static gboolean pty_chr_timer(gpointer opaque) return FALSE; } =20 +static void pty_chr_timer_cancel(PtyChardev *s) +{ + if (s->timer_src) { + g_source_destroy(s->timer_src); + g_source_unref(s->timer_src); + s->timer_src =3D NULL; + } +} + /* Called with chr_write_lock held. */ static void pty_chr_rearm_timer(Chardev *chr, int ms) { PtyChardev *s =3D PTY_CHARDEV(chr); char *name; =20 - if (s->timer_tag) { - g_source_remove(s->timer_tag); - s->timer_tag =3D 0; - } - - if (ms =3D=3D 1000) { - name =3D g_strdup_printf("pty-timer-secs-%s", chr->label); - s->timer_tag =3D g_timeout_add_seconds(1, pty_chr_timer, chr); - } else { - name =3D g_strdup_printf("pty-timer-ms-%s", chr->label); - s->timer_tag =3D g_timeout_add(ms, pty_chr_timer, chr); - } - g_source_set_name_by_id(s->timer_tag, name); + pty_chr_timer_cancel(s); + name =3D g_strdup_printf("pty-timer-%s", chr->label); + s->timer_src =3D qemu_chr_timeout_add_ms(chr, ms, pty_chr_timer, chr); + g_source_set_name(s->timer_src, name); g_free(name); } =20 @@ -206,10 +207,7 @@ static void pty_chr_state(Chardev *chr, int connected) * the virtual device linked to our pty. */ pty_chr_rearm_timer(chr, 1000); } else { - if (s->timer_tag) { - g_source_remove(s->timer_tag); - s->timer_tag =3D 0; - } + pty_chr_timer_cancel(s); if (!s->connected) { g_assert(s->open_source =3D=3D NULL); s->open_source =3D g_idle_source_new(); @@ -236,10 +234,7 @@ static void char_pty_finalize(Object *obj) qemu_mutex_lock(&chr->chr_write_lock); pty_chr_state(chr, 0); object_unref(OBJECT(s->ioc)); - if (s->timer_tag) { - g_source_remove(s->timer_tag); - s->timer_tag =3D 0; - } + pty_chr_timer_cancel(s); qemu_mutex_unlock(&chr->chr_write_lock); qemu_chr_be_event(chr, CHR_EVENT_CLOSED); } @@ -272,7 +267,7 @@ static void char_pty_open(Chardev *chr, name =3D g_strdup_printf("chardev-pty-%s", chr->label); qio_channel_set_name(QIO_CHANNEL(s->ioc), name); g_free(name); - s->timer_tag =3D 0; + s->timer_src =3D NULL; *be_opened =3D false; } =20 diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 630a7f2..77cdf48 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -57,7 +57,7 @@ typedef struct { bool is_telnet; bool is_tn3270; =20 - guint reconnect_timer; + GSource *reconnect_timer; int64_t reconnect_time; bool connect_err_reported; } SocketChardev; @@ -67,16 +67,27 @@ typedef struct { =20 static gboolean socket_reconnect_timeout(gpointer opaque); =20 +static void tcp_chr_reconn_timer_cancel(SocketChardev *s) +{ + if (s->reconnect_timer) { + g_source_destroy(s->reconnect_timer); + g_source_unref(s->reconnect_timer); + s->reconnect_timer =3D NULL; + } +} + static void qemu_chr_socket_restart_timer(Chardev *chr) { SocketChardev *s =3D SOCKET_CHARDEV(chr); char *name; =20 assert(s->connected =3D=3D 0); - s->reconnect_timer =3D g_timeout_add_seconds(s->reconnect_time, - socket_reconnect_timeout, c= hr); name =3D g_strdup_printf("chardev-socket-reconnect-%s", chr->label); - g_source_set_name_by_id(s->reconnect_timer, name); + s->reconnect_timer =3D qemu_chr_timeout_add_ms(chr, + s->reconnect_time * 1000, + socket_reconnect_timeout, + chr); + g_source_set_name(s->reconnect_timer, name); g_free(name); } =20 @@ -781,11 +792,7 @@ static void char_socket_finalize(Object *obj) SocketChardev *s =3D SOCKET_CHARDEV(obj); =20 tcp_chr_free_connection(chr); - - if (s->reconnect_timer) { - g_source_remove(s->reconnect_timer); - s->reconnect_timer =3D 0; - } + tcp_chr_reconn_timer_cancel(s); qapi_free_SocketAddress(s->addr); if (s->listener) { qio_net_listener_set_client_func(s->listener, NULL, NULL, NULL); @@ -824,7 +831,8 @@ static gboolean socket_reconnect_timeout(gpointer opaqu= e) SocketChardev *s =3D SOCKET_CHARDEV(opaque); QIOChannelSocket *sioc; =20 - s->reconnect_timer =3D 0; + g_source_unref(s->reconnect_timer); + s->reconnect_timer =3D NULL; =20 if (chr->be_open) { return false; diff --git a/chardev/char.c b/chardev/char.c index 8c3765e..3e14de1 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -1084,6 +1084,24 @@ void qmp_chardev_send_break(const char *id, Error **= errp) qemu_chr_be_event(chr, CHR_EVENT_BREAK); } =20 +/* + * Add a timeout callback for the chardev (in milliseconds), return + * the GSource object created. Please use this to add timeout hook for + * chardev instead of g_timeout_add() and g_timeout_add_seconds(), to + * make sure the gcontext that the task bound to is correct. + */ +GSource *qemu_chr_timeout_add_ms(Chardev *chr, guint ms, + GSourceFunc func, void *private) +{ + GSource *source =3D g_timeout_source_new(ms); + + assert(func); + g_source_set_callback(source, func, private, NULL); + g_source_attach(source, chr->gcontext); + + return source; +} + void qemu_chr_cleanup(void) { object_unparent(get_chardevs_root()); diff --git a/hw/char/terminal3270.c b/hw/char/terminal3270.c index a109ce5..e9c45e5 100644 --- a/hw/char/terminal3270.c +++ b/hw/char/terminal3270.c @@ -31,7 +31,7 @@ typedef struct Terminal3270 { uint8_t outv[OUTPUT_BUFFER_SIZE]; int in_len; bool handshake_done; - guint timer_tag; + GSource *timer_src; } Terminal3270; =20 #define TYPE_TERMINAL_3270 "x-terminal3270" @@ -45,6 +45,15 @@ static int terminal_can_read(void *opaque) return INPUT_BUFFER_SIZE - t->in_len; } =20 +static void terminal_timer_cancel(Terminal3270 *t) +{ + if (t->timer_src) { + g_source_destroy(t->timer_src); + g_source_unref(t->timer_src); + t->timer_src =3D NULL; + } +} + /* * Protocol handshake done, * signal guest by an unsolicited DE irq. @@ -90,12 +99,9 @@ static void terminal_read(void *opaque, const uint8_t *b= uf, int size) =20 assert(size <=3D (INPUT_BUFFER_SIZE - t->in_len)); =20 - if (t->timer_tag) { - g_source_remove(t->timer_tag); - t->timer_tag =3D 0; - } - t->timer_tag =3D g_timeout_add_seconds(600, send_timing_mark_cb, t); - + terminal_timer_cancel(t); + t->timer_src =3D qemu_chr_timeout_add_ms(t->chr.chr, 600 * 1000, + send_timing_mark_cb, t); memcpy(&t->inv[t->in_len], buf, size); t->in_len +=3D size; if (t->in_len < 2) { @@ -145,10 +151,7 @@ static void chr_event(void *opaque, int event) /* Ensure the initial status correct, always reset them. */ t->in_len =3D 0; t->handshake_done =3D false; - if (t->timer_tag) { - g_source_remove(t->timer_tag); - t->timer_tag =3D 0; - } + terminal_timer_cancel(t); =20 switch (event) { case CHR_EVENT_OPENED: @@ -157,7 +160,8 @@ static void chr_event(void *opaque, int event) * char-socket.c. Once qemu receives the terminal-type of the * client, mark handshake done and trigger everything rolling agai= n. */ - t->timer_tag =3D g_timeout_add_seconds(600, send_timing_mark_cb, t= ); + t->timer_src =3D qemu_chr_timeout_add_ms(t->chr.chr, 600 * 1000, + send_timing_mark_cb, t); break; case CHR_EVENT_CLOSED: sch->curr_status.scsw.dstat =3D SCSW_DSTAT_DEVICE_END; diff --git a/include/chardev/char.h b/include/chardev/char.h index 778d610..d8941fc 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -256,6 +256,9 @@ Chardev *qemu_chardev_new(const char *id, const char *t= ypename, =20 extern int term_escape_char; =20 +GSource *qemu_chr_timeout_add_ms(Chardev *chr, guint ms, + GSourceFunc func, void *private); + /* console.c */ void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **er= rp); =20 --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757341369730.2406024702658; Fri, 12 Jan 2018 03:42:21 -0800 (PST) Received: from localhost ([::1]:35244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxj0-0007vz-M9 for importer@patchew.org; Fri, 12 Jan 2018 06:42:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYa-0007E7-Hg for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYZ-0004Ys-M8 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:32 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:43317) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYZ-0004Wg-Fj for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:31 -0500 Received: by mail-wm0-x241.google.com with SMTP id g1so11397110wmg.2 for ; Fri, 12 Jan 2018 03:31:31 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EmIODxz0suFHBgq71lVGPgrOIwnITsuBrEuho8JqZZY=; b=hfvdFHSLRSUYiX5QJKTmZl5vlq/8dQI3Z3Un6UYAvhOWbeDCv6fProldguuKJUZt0e SXVfpWjmbvZM2vIwIIX3zz031qwPxsOizCB77jqrlHzUc/5eE2wgOXKz1IQbIX1feAwa pwzX4ncKd3OKwt2nLf2P/EHofctEE+pGv3dNtcuYtooh4XQd/fKf3SJqo2zBvy+04D29 z5P5Yyto0L8k2FG1UeYm704ThYLaFuj62TnANHdMorapSBI7JWGNo+RKlIN9rufC2heA n/HVXgacSjpMbsMO+lz+wsfq0yp6q1aT/eBfJO9PQL3zOrQxf4/vcY/HB4ddAwX9s8bi xj3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=EmIODxz0suFHBgq71lVGPgrOIwnITsuBrEuho8JqZZY=; b=AYtDcCB9ocQ6S9uVbAdoUqVSPU87mDdpBGklVb0kaTXn32bxG1Ml+RM7pudE9Gu51Z lTu7K95568OwDt23tXMRMCfWi9Jffw+rpJZorD6BxV4ipSy7sQjScQkZtoJMtS78qo6x wXwYe3sUiS3qxz5ralxQNSs0dYDE/2ztxFJWWzbxt/Pm7DqOf/KmhR4chTrzCvcEgqg0 neZXAmvMKsQIZvqOck93LC2SRyZb5RMSnaZLPHMIJxy7i2VrFiytYF/SsV3w0bijPjhD f7yZjPUclWmekMLrmSEbh8wYXl1kesuTM+6jzpXs5KdmxL3bSE8T7qgoyY7U/EKFOjtT Vosw== X-Gm-Message-State: AKwxytfIe4aBXinQloVO5l2h+mdNDpX04xR1xJl2sWHWKeHTjU+9+Ed3 hkMAzaUoLovGZ2TIypenpAcIm5S5 X-Google-Smtp-Source: ACJfBovyh7T1a6N2kTjKMWQHvQGsNRjjp491bZPbi1s3ndx/F+tYS29at0SLhYP3akhKJvZP87fDZA== X-Received: by 10.28.234.142 with SMTP id g14mr3535331wmi.31.1515756690020; Fri, 12 Jan 2018 03:31:30 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:33 +0100 Message-Id: <1515756676-3860-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 09/52] build-sys: fix qemu-ga -pthread linking X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau When linking qemu-ga under some configuration (when gthread-2.0.pc doesn't have -pthread, as happening atm with meson build), you may have this linking issue: /usr/bin/ld: libqemuutil.a(qemu-thread-posix.o): undefined reference to sym= bol 'pthread_setname_np@@GLIBC_2.12' /usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command = line Make sure qemu-ga links with the pthread library, by adding correct flags to libs_qga. This is really a QEMU bug, because it's QEMU code that's using pthread functions, and so we must explicitly link against pthreads. The bug was just masked by the fact that often some pkg-config or another for one of our dependencies will add -pthread to the link line anyway. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Peter Maydell Message-Id: <20180104160523.22995-2-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 89bd662..ac392d2 100755 --- a/configure +++ b/configure @@ -3464,6 +3464,7 @@ else done if test "$found" =3D "no"; then LIBS=3D"$pthread_lib $LIBS" + libs_qga=3D"$pthread_lib $libs_qga" fi PTHREAD_LIB=3D"$pthread_lib" break --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757693527879.7204745451965; Fri, 12 Jan 2018 03:48:13 -0800 (PST) Received: from localhost ([::1]:35283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxoc-0004bV-Ik for importer@patchew.org; Fri, 12 Jan 2018 06:48:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYf-0007Jk-Ke for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYa-0004b2-Ox for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:37 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:43319) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYa-0004Ze-Hb for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:32 -0500 Received: by mail-wm0-x243.google.com with SMTP id g1so11397216wmg.2 for ; Fri, 12 Jan 2018 03:31:32 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=26yhqltwacDNtrdKsUgfU0Ul6cvcxAhQPfhQiAO+Zfs=; b=D84vqI9jBZr+u1mgFRY6h6m08bBKnxkxdGebO/VD1I+QsnhB3bXwnFPO97c6FPPIl7 5VTH/VV8CksN/10d5KFPQSzWCrpryeVdgkYScr8JpYiphI7xITS/zy1Ee0SR1c7dSXt0 rjbbD5uxTK5p+ZDZGXaN5zIknFKmbOVq0Ipcb9V8em448QV3okTVhEXSzByetQ30SqOv mL6WFEJSweIJwZfLhogdjPOYGrGkHSG5+zZLZg5HsuNZDU0qjiErlnGHDUwGeDUNBy9n CVetcrhfSpy5YMYjJDkyiCYEMBjzgxyUFR0GQzeycypV5Q0xnKEFLaHIaxDVK/LpSla6 DisA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=26yhqltwacDNtrdKsUgfU0Ul6cvcxAhQPfhQiAO+Zfs=; b=RrvVuxj3m4gnVpnM+EXC8TCh2bF/+LM09sq3IIS7S3BS5zSlNEfsIv4rCHjCCxc0f1 qbvAUad5Uapy9GrItNzMLOf+mYuLId6P/rPVBC8j1l2iRawmO5U0P+qyyhX/N6jl6//d CJ0qr/eiD5WCkcOEpnJas0FqHRrUbMQzEBeOmFHd+Y3OEhvT3h4fMzxVQDU825NjsVFU bcIKyDuIW3azbLjYtz7sS+V5UuTnBLP1XZ7JM2LmiVeRTagW6Hx/VpdibNlaq+cZk+kb /XFQZIbwHJAd86KkjeGta/ZQAHk5zOtYE3yBzuCN/CCSdPXI3raJvca//jrTavQ2yTeu uowQ== X-Gm-Message-State: AKwxyteBuFWtx5sObCYsizbDneG7MCHHEEAc1diU2znRCQG94x4LgaBD 5KWXKzPU4SSD4cPQdSCRgmb3OGd2 X-Google-Smtp-Source: ACJfBos2s7CeNEKf77gS7egxFbezdhm28F+Rm3NpCI+Evfv2Lh9XfrEfow0/94+K0u3/Hz22CFoRbA== X-Received: by 10.28.230.151 with SMTP id e23mr3496219wmi.11.1515756691263; Fri, 12 Jan 2018 03:31:31 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:34 +0100 Message-Id: <1515756676-3860-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 10/52] build-sys: silence make by default or V=0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Move generic make flags in MAKEFLAGS (SUBDIR_MAKEFLAGS is more qemu specifi= c). Use --quiet to silence make 'is up to date' message. Signed-off-by: Marc-Andr=C3=A9 Lureau Tested-by: Eric Blake Reviewed-by: Paolo Bonzini Message-Id: <20180104160523.22995-3-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- Makefile | 2 +- rules.mak | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d86ecd2..1671db3 100644 --- a/Makefile +++ b/Makefile @@ -277,7 +277,7 @@ else DOCS=3D endif =20 -SUBDIR_MAKEFLAGS=3D$(if $(V),,--no-print-directory) BUILD_DIR=3D$(BUILD_DI= R) +SUBDIR_MAKEFLAGS=3DBUILD_DIR=3D$(BUILD_DIR) SUBDIR_DEVICES_MAK=3D$(patsubst %, %/config-devices.mak, $(TARGET_DIRS)) SUBDIR_DEVICES_MAK_DEP=3D$(patsubst %, %-config-devices.mak.d, $(TARGET_DI= RS)) =20 diff --git a/rules.mak b/rules.mak index 6e94333..5fb4951 100644 --- a/rules.mak +++ b/rules.mak @@ -131,6 +131,8 @@ modules: # If called with only a single argument, will print nothing in quiet mode. quiet-command =3D $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1= , @$1)) =20 +MAKEFLAGS +=3D $(if $(V),,--no-print-directory --quiet) + # cc-option # Usage: CFLAGS+=3D$(call cc-option, -falign-functions=3D0, -malign-functi= ons=3D0) =20 --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515758054473726.3575332387827; Fri, 12 Jan 2018 03:54:14 -0800 (PST) Received: from localhost ([::1]:35322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxuX-00025b-Aj for importer@patchew.org; Fri, 12 Jan 2018 06:54:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYf-0007Jl-Kf for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYb-0004e7-TZ for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:37 -0500 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:40320) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYb-0004bg-M3 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:33 -0500 Received: by mail-wm0-x231.google.com with SMTP id v123so2002244wmd.5 for ; Fri, 12 Jan 2018 03:31:33 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Iy1cEWNYc+gmCs5bFDOFahinbIYkv7uox2nZzAulF+I=; b=o6+C7dnlR1PeHfmN4tYdRdlvqwRR9yX7/ycxJfluxX3XDHG/5bjbReYN+DsouIBgSC 9FYenjbSSwTXhBTMNC61JrbENb2LkPPjnlpKY/86Ox56yzjA5a4ZfJ6lBwfIv6LNPi9/ jj83q9v7MU/89/fghh1Gu5nCafgm4I9v5T83Ncgq6TqRpu8n8sMPhfZDE9aT6j+SBduT C+pW8ivKg8A3EO/jTsyyzfWEJQ5/vwVij1rP0NGT1AeDBhEf1Hzd1T3Hx8PdYl5B1+v4 mMkEYPviuna7Gg1eOrRpt3yL/sg9rvE9YOr0hgMeTOzKjTLkRbvAnGMmQFN/jZrVczGN heoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Iy1cEWNYc+gmCs5bFDOFahinbIYkv7uox2nZzAulF+I=; b=i1jcrq9nrD87/t6/kgrQlp8QMr9JYNxmou1zr4WNb15UERFccPnvnS9oMxz8lmFVEM uOU+FBZGF+ccmgDJRE9umG1w7TiDOgQ45lTnbUKGhgLS0XZHWgISipBCKoIt9gbaITHw q1ZA770/g1t3YwhycSloE6i5uJ4+lpu5PPJpT5ZQfwLoNrdEHxOYlvsrDvujaJYBwzh+ q055yqNz38RMiDXdS9zJ50uH27uUbl0T0xjMSN8CtLglopsQoboTilxHEU6uiaM5ImNm 1OEoLPXk/3pNXr6KPNG5jIMVLAy3iV8Lq/x6h8D/reig4iAlu0hm6bBvHxP28AkmZL/6 9w6w== X-Gm-Message-State: AKwxytcLxN8dod/3v30zHhlk/b18Fye1fBHu3yIDA8mQ+Wlo/ieb67J9 1tkxZyYR/QIRwl1ZFOEXjz9weCg3 X-Google-Smtp-Source: ACJfBovCRRUYT9nTLvG4B95lLIs9vYlFTR+IxhuZF0rPNoZKTZN/e+0+2QsBKWVWj7II4yiWd4nzvg== X-Received: by 10.28.135.142 with SMTP id j136mr3478354wmd.132.1515756692297; Fri, 12 Jan 2018 03:31:32 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:35 +0100 Message-Id: <1515756676-3860-12-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::231 Subject: [Qemu-devel] [PULL 11/52] build-sys: add a rule to print a variable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau $ make print-CFLAGS CFLAGS=3D-fsanitize=3Daddress -Og -g Trick from various sources: https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in= -makefile https://www.cmcrossroads.com/article/printing-value-makefile-variable Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake Message-Id: <20180104160523.22995-4-marcandre.lureau@redhat.com> Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- Makefile | 5 ++++- docs/devel/build-system.txt | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1671db3..f26ef1b 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,12 @@ SRC_PATH=3D. =20 UNCHECKED_GOALS :=3D %clean TAGS cscope ctags dist \ html info pdf txt \ - help check-help \ + help check-help print-% \ docker docker-% vm-test vm-build-% =20 +print-%: + @echo '$*=3D$($*)' + # All following code might depend on configuration variables ifneq ($(wildcard config-host.mak),) # Put the all: rule here so that config-host.mak can contain dependencies. diff --git a/docs/devel/build-system.txt b/docs/devel/build-system.txt index 386ef36..52501f2 100644 --- a/docs/devel/build-system.txt +++ b/docs/devel/build-system.txt @@ -510,3 +510,16 @@ default-configs/$TARGET-NAME file as input. This is the entrypoint used when make recurses to build a single system or userspace emulator target. It is merely a symlink back to the Makefile.target in the top level. + + +Useful make targets +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +- help + + Print a help message for the most common build targets. + +- print-VAR + + Print the value of the variable VAR. Useful for debugging the build + system. --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757180953804.6122560740397; Fri, 12 Jan 2018 03:39:40 -0800 (PST) Received: from localhost ([::1]:35227 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxgS-0005XI-1V for importer@patchew.org; Fri, 12 Jan 2018 06:39:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYf-0007Jp-L7 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYc-0004hT-St for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:37 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33739) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYc-0004fO-NQ for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:34 -0500 Received: by mail-wm0-x241.google.com with SMTP id x4so1969194wmc.0 for ; Fri, 12 Jan 2018 03:31:34 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6FxTiEZHAGfdxH4Ed9r2oPeSBGLUg5UIf0+kvgPpgG0=; b=XMOALxeUHQ8dEpP6ZqBjreFgDb1vu8K1WDLw9cAHpLvn4+h5G50t8MZZ6AIcjjauCp ++AYCNMIVf40yVH+yZP0mt32V/O9AHJUr05kNIwgMw6WyQJkSnYR44Q9H3tHMm09Qk09 ZHpfcCw1rfi96nvOvQY36evIhBhr099QSw5zFg5dyveXByzs0Di7HiuCe0J15g+peHFg EnhKKzuoXkcFhQtp0wUxTHGc/pKMM5qrHFQz0U4zxe4on31BxaEm/28k7a2fH7Vr9iII ck6rMC+gkOMVbQILflFmnGa7Lh1T6StiE4T7SuQo8C7ODoDOSAdp4IdhZ06ozaCyg/zj sGoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=6FxTiEZHAGfdxH4Ed9r2oPeSBGLUg5UIf0+kvgPpgG0=; b=PWYKmxEaNrHpsUtiuf5MhlNj7hgSiq9Hd/N/Vke5UnT+eqptNqmAxLBo6wILyLQ76c b6aYBNpMEL930NJVetTUF1VNDzzTC5G4FZWKn7ANYJlTsrEXlBRtQjuhL6Vg0zltkOw2 v0Ek0OM8hzs3ctAWkBlh5ZjAo88ZnmmRabA5VRzTWXmMfgirf5Qxwwot1OM47i0QNW7r JV71bzQk6Ufe1lwJy+MuoPzRvAqeZPcNTVNNvzHfkFa9LGpV0NAvBdrG8Hx9Tj+stQmY r6L9zfBJK4ZXr5xslG+HlwJQBe4rqBB3rDkJe1CoFEw0K/r/97PyBfPryGb8zw/bI/Nc u0Ww== X-Gm-Message-State: AKwxytdSghOZ1iM040ZuJoyvz/TOf8m4LdsrAc6gVlXXRdPIUIHidpVQ APgC+UznbpgRFT8R5M03Z7VMRyoi X-Google-Smtp-Source: ACJfBosfdZfVF38o2055wPNErFTbRcPemKwrQkzo9teRgFaIONVGA132AV/WCQHcGpPf17UUIGMttQ== X-Received: by 10.28.105.193 with SMTP id z62mr3542081wmh.77.1515756693416; Fri, 12 Jan 2018 03:31:33 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:36 +0100 Message-Id: <1515756676-3860-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 12/52] build-sys: compile with -Og or -O1 when --enable-debug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau When --enable-debug is turned on, configure doesn't set -O level, and uses default compiler -O0 level, which is slow. Instead, use -Og if supported by the compiler (optimize debugging experience), or -O1 (keeps code somewhat debuggable and works around compiler bugs). Unfortunately, gcc has many false-positive maybe-uninitialized errors with Og and O1 (f27 gcc 7.2.1 20170915): /home/elmarco/src/qemu/hw/ipmi/isa_ipmi_kcs.c: In function =E2=80=98ipmi_kc= s_ioport_read=E2=80=99: /home/elmarco/src/qemu/hw/ipmi/isa_ipmi_kcs.c:279:12: error: =E2=80=98ret= =E2=80=99 may be used uninitialized in this function [-Werror=3Dmaybe-unini= tialized] return ret; ^~~ cc1: all warnings being treated as errors make: *** [/home/elmarco/src/qemu/rules.mak:66: hw/ipmi/isa_ipmi_kcs.o] Err= or 1 make: *** Waiting for unfinished jobs.... /home/elmarco/src/qemu/hw/ide/ahci.c: In function =E2=80=98ahci_populate_sg= list=E2=80=99: /home/elmarco/src/qemu/hw/ide/ahci.c:903:58: error: =E2=80=98tbl_entry_size= =E2=80=99 may be used uninitialized in this function [-Werror=3Dmaybe-unini= tialized] if ((off_idx =3D=3D -1) || (off_pos < 0) || (off_pos > tbl_entry_s= ize)) { ~~~~~~~~~^~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make: *** [/home/elmarco/src/qemu/rules.mak:66: hw/ide/ahci.o] Error 1 /home/elmarco/src/qemu/hw/display/qxl.c: In function =E2=80=98qxl_add_memsl= ot=E2=80=99: /home/elmarco/src/qemu/hw/display/qxl.c:1397:52: error: =E2=80=98pci_start= =E2=80=99 may be used uninitialized in this function [-Werror=3Dmaybe-unini= tialized] memslot.virt_end =3D virt_start + (guest_end - pci_start); ~~~~~~~~~~~~~^~~~~~~~~~~~ /home/elmarco/src/qemu/hw/display/qxl.c:1389:9: error: =E2=80=98pci_region= =E2=80=99 may be used uninitialized in this function [-Werror=3Dmaybe-unini= tialized] qxl_set_guest_bug(d, "%s: pci_region =3D %d", __func__, pci_region= ); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors There seems to be a long list of related bugs in upstream GCC, some of them are being fixed very recently: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D24639 For now, let's workaround it by using Wno-maybe-uninitialized (gcc-only). Suggested-by: Paolo Bonzini Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180104160523.22995-5-marcandre.lureau@redhat.com> Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- configure | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/configure b/configure index ac392d2..6f1b7cd 100755 --- a/configure +++ b/configure @@ -5194,8 +5194,19 @@ if test "$gcov" =3D "yes" ; then LDFLAGS=3D"-fprofile-arcs -ftest-coverage $LDFLAGS" elif test "$fortify_source" =3D "yes" ; then CFLAGS=3D"-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3D2 $CFLAGS" -elif test "$debug" =3D "no"; then - CFLAGS=3D"-O2 $CFLAGS" +elif test "$debug" =3D "yes"; then + if compile_prog "-Og" ""; then + CFLAGS=3D"-Og $CFLAGS" + elif compile_prog "-O1" ""; then + CFLAGS=3D"-O1 $CFLAGS" + fi + # Workaround GCC false-positive Wuninitialized bugs with Og or O1: + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D24639 + if cc_has_warning_flag "-Wno-maybe-uninitialized"; then + CFLAGS=3D"-Wno-maybe-uninitialized $CFLAGS" + fi +else + CFLAGS=3D"-O2 $CFLAGS" fi =20 ########################################## --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757507022256.3071216006165; Fri, 12 Jan 2018 03:45:07 -0800 (PST) Received: from localhost ([::1]:35263 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxli-00020I-3r for importer@patchew.org; Fri, 12 Jan 2018 06:45:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYf-0007Jo-L0 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYd-0004k6-Sz for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:37 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:38872) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYd-0004iM-MJ for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:35 -0500 Received: by mail-wm0-x241.google.com with SMTP id 141so11109268wme.3 for ; Fri, 12 Jan 2018 03:31:35 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u/qkyEupL6h0Y4NtT4cWnsw/c+XzLQrEVxiesaNYQF4=; b=Z9AIHmtqPnivWMzfwM9dx3CEgvai34loCOBo1fO+JI5OsacWEIErvEMFWTb7waOz50 sED/jQfrytIhOpSGB0YkbZ+fNZ7PdEA8IY9LB0bIc9/kpTC8j5Le9LlZbTkogAy8cmBZ mQDgXA1yf+ve1J6+w9iFGhdo3t8K0YLOSCFJJpJd9WprfxjxW7sLIUWvo4yKGOiRN6GC BGV5NV1fOE7dfutsYOVV1b0WcOhgy6wEN3OhK4hhaREvRKl0vwinCXtav/kzWh8q3fbT hzl7Rwd6AghCttNvW219cCCr/xEiY83z+etBLOuyX140H2+mqhHfqrjfUJTCyTNnEXBW XUCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=u/qkyEupL6h0Y4NtT4cWnsw/c+XzLQrEVxiesaNYQF4=; b=BgfxcO6/s7zsxrP7lTkBhdWH5xemgHtSz5P7HwOKHwhqkBlmbZnwFhG0qAXbF90JBE 9P+sZIr8T8GPVjcOgZ8n3v6dANpu3/YHIpjizvcN1+jZPfrEzJyuHpZqOyoUCp7U434/ hNMTLil63451xC4a71XwRwepjeLn+0TPANBCixA0rJku195204km6p6ESREL4vCjuMcz ozNoSJFZathtStii5xmt7bGS8rM6HVnOoJE5KmfrqYrNoXRO7sr1nnJ6tXBPtoNAP+gX fI1IBob3hpeXfbQd1+7BbxHedkAnSrJ4b0GRjVzwlDVfLkFA7J4uN9CofCzBYpn/DmUt t9fg== X-Gm-Message-State: AKwxytdfaEJqZY197ZQh1k7HrNGmGAQqA76Y8h4fFjPxPAX5oAEv7omC 1ClcgHCgzkokiXeifbZjFur2iOOO X-Google-Smtp-Source: ACJfBovH8nxnM0AMyek3OaT60LNBhXIRHYe5MRyA5V5VGwoVn1rNw+z++bw1NZ3NHM36SNKD0FqCCg== X-Received: by 10.28.203.142 with SMTP id b136mr4146486wmg.127.1515756694378; Fri, 12 Jan 2018 03:31:34 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:37 +0100 Message-Id: <1515756676-3860-14-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 13/52] tests/docker: add some sanitizers to fedora dockerfile X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Build fedora image with ASAN/UBSan support. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180104160523.22995-6-marcandre.lureau@redhat.com> Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- tests/docker/dockerfiles/fedora.docker | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/docker/dockerfiles/fedora.docker b/tests/docker/dockerfi= les/fedora.docker index 4b26c3a..32de731 100644 --- a/tests/docker/dockerfiles/fedora.docker +++ b/tests/docker/dockerfiles/fedora.docker @@ -3,7 +3,7 @@ ENV PACKAGES \ ccache gettext git tar PyYAML sparse flex bison python2 bzip2 hostname= \ glib2-devel pixman-devel zlib-devel SDL-devel libfdt-devel \ gcc gcc-c++ clang make perl which bc findutils libaio-devel \ - nettle-devel \ + nettle-devel libasan libubsan \ mingw32-pixman mingw32-glib2 mingw32-gmp mingw32-SDL mingw32-pkg-confi= g \ mingw32-gtk2 mingw32-gtk3 mingw32-gnutls mingw32-nettle mingw32-libtas= n1 \ mingw32-libjpeg-turbo mingw32-libpng mingw32-curl mingw32-libssh2 \ @@ -15,4 +15,4 @@ ENV PACKAGES \ =20 RUN dnf install -y $PACKAGES RUN rpm -q $PACKAGES | sort > /packages.txt -ENV FEATURES mingw clang pyyaml +ENV FEATURES mingw clang pyyaml asan --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757883140129.48456205542698; Fri, 12 Jan 2018 03:51:23 -0800 (PST) Received: from localhost ([::1]:35304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxrg-0007s4-Np for importer@patchew.org; Fri, 12 Jan 2018 06:51:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYh-0007KO-CB for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYf-0004mT-BC for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:39 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:40633) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYf-0004lI-4L for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:37 -0500 Received: by mail-wr0-x243.google.com with SMTP id 100so5028046wrb.7 for ; Fri, 12 Jan 2018 03:31:37 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/GJp4oucjpCmBnwvIqua8KMXlL7dFqV8UIOpQt0jQTc=; b=JzcVq3lRc+YE3JKV+e6ebpGp0ev1TTli2DrzgSEiAvauQ53/dM4vdEIhZlWf1RvkYZ FisEJ30br+BDzKKNxsA8zDd9kx+5z3nzyQcrfC2/3BoDS7/7hPPT9gpzxfb3nwMafZMq 7nDX8kWlHynQGSzW537JLaa/2TLCWnXWMT5bE8a/1+3GnYrf/9kObdTl/ptO4yCqiFAg 8ol+8kd4AUWpEfDpsm9hzjE0wt7VR00GDjqo0bInim+kktROYRruZC/tHnwhlu3T+Ipy UpsAPo4P04DD6kB6kUeBZ7b+0QCNyvxNGzitQf63auEwDCGmXnLIay4PoqSyaaI35wBs a8VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=/GJp4oucjpCmBnwvIqua8KMXlL7dFqV8UIOpQt0jQTc=; b=HSyOurhVppcXj0jG5Jk3zcQgKBGpcqDaJhHpIc+yWSYRPbJzZ4PfFeApOt8bVtJoN/ tt1T0wyIpGhL3YM7I2A+HysE5JEWfa8tAhzvkoTs0iH3VP8R7BclXLAFv5NT55SUj5K1 Gm9AJXqyIqVNuyH99ztpe5HaODhFA+22oGdB+xup0P54OY8CMku2FYnb6p2lCPNhGRHY jm9w2LnQfPbG7wxXFjasXeHi95Y7CVV7GzaChydNfg9K117e4obCAomBRlQj0DhDUws0 PjyrUW27ohmitsM8Yl2sK+NmXnGG8qaaJoE6w4ln1SDg7u/KHyUhom9Td10y+09Ww3E7 O9ig== X-Gm-Message-State: AKGB3mITLRmL2AuLaC9y5H+mYnQtXkwMEjDh1jX/92IfAqDwQet1+Dr0 Ydff+wE1rT7WpNTvbgbYZtcg9TLE X-Google-Smtp-Source: ACJfBovIp7mVjI8KAJ90IdL/n9B1is3qYQ9ceqmHkbJfjLA0rJ6GSWrHOuUvJp+ZTB3+MdrxWmXnfA== X-Received: by 10.223.142.200 with SMTP id q66mr15241975wrb.267.1515756695718; Fri, 12 Jan 2018 03:31:35 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:38 +0100 Message-Id: <1515756676-3860-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 14/52] tests/docker: add test-debug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Add a new test with --enable-debug using clang/asan/ubsan, remove --enable-debug from test-clang & test-mingw. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180104160523.22995-7-marcandre.lureau@redhat.com> Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- tests/docker/test-clang | 2 +- tests/docker/test-debug | 26 ++++++++++++++++++++++++++ tests/docker/test-mingw | 2 -- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100755 tests/docker/test-debug diff --git a/tests/docker/test-clang b/tests/docker/test-clang index 1eb61a3..e90a793 100755 --- a/tests/docker/test-clang +++ b/tests/docker/test-clang @@ -17,7 +17,7 @@ requires clang =20 cd "$BUILD_DIR" =20 -OPTS=3D"--enable-debug --cxx=3Dclang++ --cc=3Dclang --host-cc=3Dclang" +OPTS=3D"--cxx=3Dclang++ --cc=3Dclang --host-cc=3Dclang" # -fsanitize=3Dundefined is broken on Fedora 23, skip it for now # See also: https://bugzilla.redhat.com/show_bug.cgi?id=3D1263834 #OPTS=3D"$OPTS --extra-cflags=3D-fsanitize=3Dundefined \ diff --git a/tests/docker/test-debug b/tests/docker/test-debug new file mode 100755 index 0000000..d020b06 --- /dev/null +++ b/tests/docker/test-debug @@ -0,0 +1,26 @@ +#!/bin/bash -e +# +# Compile and check with clang & --enable-debug. +# +# Copyright (c) 2016-2018 Red Hat Inc. +# +# Authors: +# Fam Zheng +# Marc-Andr=C3=A9 Lureau +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +. common.rc + +requires clang asan + +cd "$BUILD_DIR" + +OPTS=3D"--cxx=3Dclang++ --cc=3Dclang --host-cc=3Dclang" +OPTS=3D"--enable-debug $OPTS" + +build_qemu $OPTS +make $MAKEFLAGS check +install_qemu diff --git a/tests/docker/test-mingw b/tests/docker/test-mingw index 39a1da4..503a6bc 100755 --- a/tests/docker/test-mingw +++ b/tests/docker/test-mingw @@ -22,7 +22,6 @@ for prefix in x86_64-w64-mingw32- i686-w64-mingw32-; do TARGET_LIST=3D${TARGET_LIST:-$DEF_TARGET_LIST} \ build_qemu --cross-prefix=3D$prefix \ --enable-trace-backends=3Dsimple \ - --enable-debug \ --enable-gnutls \ --enable-nettle \ --enable-curl \ @@ -35,4 +34,3 @@ for prefix in x86_64-w64-mingw32- i686-w64-mingw32-; do make clean =20 done - --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151575750779844.78555789326015; Fri, 12 Jan 2018 03:45:07 -0800 (PST) Received: from localhost ([::1]:35260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxld-0001vF-NX for importer@patchew.org; Fri, 12 Jan 2018 06:45:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYh-0007KN-4T for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYg-0004ot-By for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:39 -0500 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:38253) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYg-0004n5-6F for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:38 -0500 Received: by mail-wr0-x22d.google.com with SMTP id x1so857320wrb.5 for ; Fri, 12 Jan 2018 03:31:38 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WfgCfn8JMYH5WUWobgr721WcOZePAQ0aKDb1byldnMA=; b=fVUX35QOfdza+JzBMLBuhmfTxBzcDjvWJl3J/YacoxoxNwRuONR3z24ZZuoxgP7jTz IGTnJasDjPyYHrWN5T/nqXrQs0S258v5ZI4oK0s/XCUU8GbIcm2AF1j3JmunuwUlpyEU OFubJk+Zx1SCdNnHc+7aAV+UG1Owl3OyrvAP8z7shuOJspOcYb94Nszv5GjsOGJw9F9p 8iuIXEMlxSNLN/N/rYB6+4uzWz4bOZQ1wLnFHZ2backcQwOcVWjxpiqy7T3pR3iPA1lY U1lE2BpRJeVrg6gEQDG/BozGRHhgkhM91onh4R+9rDuFqRWXeV3y3L/RdROhiqagNbKd 24aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=WfgCfn8JMYH5WUWobgr721WcOZePAQ0aKDb1byldnMA=; b=eiqTH2AURJdL0fRMe3WS2TR3MLSHHKbdZ8IHZ5F6meDFFB67ZzFqILVl4MeeBwvqvY p/SHLOJmjAi7DfZd5o/M/+u4DKg8p6LeE2z5K2dJiD1E2wYYO0bVBHQqIUhm7O+wak4w vp337LJUQgBzCa99lNNODRVlaRroBNsU0w1tMonUtkQxc+5pZrX4CSPU+HN7lZicPYl2 1ul9WQg9HwMM7yfoj3TKhvb2M7DpF9yzMgjpbtr4+dPdA4mG3biQKtnEsI0yXk4qA5xS uM6ckq7nkw6zuh6GrcCgnr+iVIKbFaP1uWwLYRmK82wBrO/GWmDHcEBmJjqt3MAF96lS qR2w== X-Gm-Message-State: AKGB3mLRW0Ta+OoW8wpjOzsYKsvag4GqYRaFV2IR3BG+yXGvcd9nQB7J StKh4Mw9elIdQdyy9BAgSZjbraOf X-Google-Smtp-Source: ACJfBovl4VTPa2CYJkHpSBenYFka02deyOtT599XfyngyeH59CK6PUNnBOSWxt4Ry/iudMKlfFE4ww== X-Received: by 10.223.181.2 with SMTP id a2mr24085847wrd.90.1515756696739; Fri, 12 Jan 2018 03:31:36 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:39 +0100 Message-Id: <1515756676-3860-16-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22d Subject: [Qemu-devel] [PULL 15/52] build-sys: add some sanitizers when --enable-debug if possible X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Enable ASAN/UBSan by default if the compiler supports it. Typical slowdown introduced by AddressSanitizer is 2x. UBSan shouldn't have much impact on runtime cost. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180104160523.22995-8-marcandre.lureau@redhat.com> Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- configure | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/configure b/configure index 6f1b7cd..d033286 100755 --- a/configure +++ b/configure @@ -5195,6 +5195,13 @@ if test "$gcov" =3D "yes" ; then elif test "$fortify_source" =3D "yes" ; then CFLAGS=3D"-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3D2 $CFLAGS" elif test "$debug" =3D "yes"; then + write_c_skeleton; + if compile_prog "-fsanitize=3Daddress" ""; then + CFLAGS=3D"-fsanitize=3Daddress $CFLAGS" + fi + if compile_prog "-fsanitize=3Dundefined" ""; then + CFLAGS=3D"-fsanitize=3Dundefined $CFLAGS" + fi if compile_prog "-Og" ""; then CFLAGS=3D"-Og $CFLAGS" elif compile_prog "-O1" ""; then --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757345280233.1469353434021; Fri, 12 Jan 2018 03:42:25 -0800 (PST) Received: from localhost ([::1]:35247 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxj6-000823-D9 for importer@patchew.org; Fri, 12 Jan 2018 06:42:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYi-0007KQ-PQ for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYh-0004tJ-Na for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:40 -0500 Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]:33737) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYh-0004qw-Hw for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:39 -0500 Received: by mail-wr0-x22c.google.com with SMTP id p6so5052667wrd.0 for ; Fri, 12 Jan 2018 03:31:39 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S+xkSZFNh4eCpIZgQMtOIwb3cDhYPsie+l+9N5N/pcg=; b=BcX7A6diDf2OfLhSSH2txiausRDeqm9ZeubdvdQUWVyMTOdoLxA/tom/Q0wotGign5 mTC2hiRVPY/3JMfJzndoySxuOouxrKHJpDeTvL0kihF3UuWyYC6TTEYbMMUtQl2KzEBZ tV7mWFa+l1M/WVqWQDtSRnph1AsWx9bykRSoUwU9Q/jwJTPdfK+T1/otyfee6FLfIImS BHrgTs1+AXK5iywknwfm39KZsEKrTs6h6FRxmheEYMFMRoCXfyN0MDI4dxiFAnede/e0 VfHwjEInpNuSfOFXme8uoZkmt+tMq+bAvYaP71AUW++E8x3GE8e/rHO5J0d1U0YcBJt7 Ourw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=S+xkSZFNh4eCpIZgQMtOIwb3cDhYPsie+l+9N5N/pcg=; b=AolmfltY6RzZEx1zItqGMz5+fmy6aB7VL4T9ZS7/eo5KDktwuTwhuYmLZfcoWDBINi jPZQDhAB/yMlmno6cTbPIEP8gODFuDKtkBdGEPYUEiHIUaBPVLOVlPo8rydElreeaWbv vb+vQ/6TrWe5ddQjWlfJA31PB0jcvUISTtrExz+7t6uSrPER7Uex7tjam4bgT0hGDD1+ TGtM/YNi08FxtGufHqeR7A1UpwVlApKriDm4tVRixoR9EdHtpsY/mV+KV1EIzf3b88XM 2/gleVm3rN7VceJj5cbzXnsCoWmE4rItJPkGCA2IlaSggENRoMEw6bbSKV5I0DsR8n8O 60xw== X-Gm-Message-State: AKGB3mKcjyin//hAHTwkgBR0gDq6XWHeagEtcB/mJtKEFMaiTf9RUdW+ LHfb3ok6o3CdT06rdKyCAgI4MANw X-Google-Smtp-Source: ACJfBosQK+/hU1L6wlrXaDxfvLT5k3098PPDAzV5fLi38KKXRMW5Obg2rE82XVHNPPfH1hsAiQ52XA== X-Received: by 10.223.163.66 with SMTP id d2mr21955703wrb.18.1515756698215; Fri, 12 Jan 2018 03:31:38 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:40 +0100 Message-Id: <1515756676-3860-17-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22c Subject: [Qemu-devel] [PULL 16/52] tests: fix check-qobject leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau /public/qobject_is_equal_conversion: OK =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D14396=3D=3DERROR: LeakSanitizer: detected memory leaks Direct leak of 56 byte(s) in 1 object(s) allocated from: #0 0x7f07682c5850 in malloc (/lib64/libasan.so.4+0xde850) #1 0x7f0767d12f0c in g_malloc ../glib/gmem.c:94 #2 0x7f0767d131cf in g_malloc_n ../glib/gmem.c:331 #3 0x562bd767371f in do_test_equality /home/elmarco/src/qq/tests/check-= qobject.c:49 #4 0x562bd7674a35 in qobject_is_equal_dict_test /home/elmarco/src/qq/te= sts/check-qobject.c:267 #5 0x7f0767d37b04 in test_case_run ../glib/gtestutils.c:2237 #6 0x7f0767d37ec4 in g_test_run_suite_internal ../glib/gtestutils.c:2321 #7 0x7f0767d37f6d in g_test_run_suite_internal ../glib/gtestutils.c:2333 #8 0x7f0767d38184 in g_test_run_suite ../glib/gtestutils.c:2408 #9 0x7f0767d36e0d in g_test_run ../glib/gtestutils.c:1674 #10 0x562bd7674e75 in main /home/elmarco/src/qq/tests/check-qobject.c:3= 27 #11 0x7f0766009039 in __libc_start_main (/lib64/libc.so.6+0x21039) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20180104160523.22995-9-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- tests/check-qobject.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/check-qobject.c b/tests/check-qobject.c index 03e9175..710f9e6 100644 --- a/tests/check-qobject.c +++ b/tests/check-qobject.c @@ -59,6 +59,8 @@ static void do_test_equality(bool expected, int _, ...) g_assert(qobject_is_equal(args[i], args[j]) =3D=3D expected); } } + + g_free(args); } =20 #define check_equal(...) \ --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757762470890.1157766085182; Fri, 12 Jan 2018 03:49:22 -0800 (PST) Received: from localhost ([::1]:35286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxpn-0005na-Km for importer@patchew.org; Fri, 12 Jan 2018 06:49:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYj-0007LM-Kg for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYi-0004vT-Ot for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:41 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:41217) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYi-0004u6-Ir for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:40 -0500 Received: by mail-wr0-x242.google.com with SMTP id o7so5029124wro.8 for ; Fri, 12 Jan 2018 03:31:40 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/FffNR7MadkBT344kEFDcnFeTguXtSH7Wp8n7QEsck0=; b=UimOd9VAucMtBf2xt287kBhDWp1qKPG16/kldoKuDRqf2ZeztJOQX3V0SryZLKTLuh fqTgKSYb0zpn6NLuclHzMDhA8wh1s3lzk5UQWjYz2d2GR1uXylpmwbA8NbLOBCBh0pq6 eM7FzhqrMwl/YqZ6P4mocyCOAdYvkz30cSWWU2rdnjjm2ucGoYoNYGNQccKrlY7I6RIU z8dZa+uoWCCniapd1Z6ZV6mOqTTuaH28h7C4P8w5YbuhnMoQT7muq8eW1NBETA7jk8FW yjwAZLzKh8FrJ5YPc55UVZMJP3JNGftT9lKEtznzmBJlyvKLJ6Gn2e9ALdm7riQ7Kus+ t4mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=/FffNR7MadkBT344kEFDcnFeTguXtSH7Wp8n7QEsck0=; b=FRx7VAyUhUopgYrkPDC3DxRxEYrqCKp8vChUGnYqbun9+ihZT8+AFyGYsjg/cYRequ aQu3TygaEZuCg0EqeRfV+fqnBi/gPZhpAr3wuVMQ/85JsDyY4Dep19c4KaXYSeuPh931 uNzeukpdgWoimixj4hKM4ytSptjRVhFsDeecXNX53S4zjsAXtWn6vc0IfnX/cR6X9GQx jH4kewu1GVf/ebswZfH3VWSnZUeXpuwgwje5lQDR95VcGUBbL8icW+4OriKWgXi3GYCW vRqhUcUR7KCgQiwS/lpXRtSzkJTkT/5lvPLYBtxc7YVee4kqE6lBuwhirzd3Q76685aR eehQ== X-Gm-Message-State: AKwxytcUoCK5KDSVe2EaV+6kJxokXcLzJpbU0C/aDNZJc43n0mhyOY1C x5DE+tnFsrKw0I6mZYO+p8HKy0Ag X-Google-Smtp-Source: ACJfBovEdnnz36VP6/YF//O0e1w8FIawupeaL6+LVsYMiMBeXAQD0ShK9uotvFc72DENYMWjwJJLGg== X-Received: by 10.223.134.58 with SMTP id 55mr4293831wrv.262.1515756699219; Fri, 12 Jan 2018 03:31:39 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:41 +0100 Message-Id: <1515756676-3860-18-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 17/52] vl: fix direct firmware directories leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Note that data_dir[] will now point to allocated strings. Fixes: Direct leak of 16 byte(s) in 1 object(s) allocated from: #0 0x7f1448181850 in malloc (/lib64/libasan.so.4+0xde850) #1 0x7f1446ed8f0c in g_malloc ../glib/gmem.c:94 #2 0x7f1446ed91cf in g_malloc_n ../glib/gmem.c:331 #3 0x7f1446ef739a in g_strsplit ../glib/gstrfuncs.c:2364 #4 0x55cf276439d7 in main /home/elmarco/src/qq/vl.c:4311 #5 0x7f143dfad039 in __libc_start_main (/lib64/libc.so.6+0x21039) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake Message-Id: <20180104160523.22995-10-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- vl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vl.c b/vl.c index 444b750..3599485 100644 --- a/vl.c +++ b/vl.c @@ -2318,7 +2318,7 @@ static void qemu_add_data_dir(const char *path) return; /* duplicate */ } } - data_dir[data_dir_idx++] =3D path; + data_dir[data_dir_idx++] =3D g_strdup(path); } =20 static inline bool nonempty_str(const char *str) @@ -3078,7 +3078,7 @@ int main(int argc, char **argv, char **envp) Error *main_loop_err =3D NULL; Error *err =3D NULL; bool list_data_dirs =3D false; - char **dirs; + char *dir, **dirs; typedef struct BlockdevOptions_queue { BlockdevOptions *bdo; Location loc; @@ -4181,9 +4181,12 @@ int main(int argc, char **argv, char **envp) for (i =3D 0; dirs[i] !=3D NULL; i++) { qemu_add_data_dir(dirs[i]); } + g_strfreev(dirs); =20 /* try to find datadir relative to the executable path */ - qemu_add_data_dir(os_find_datadir()); + dir =3D os_find_datadir(); + qemu_add_data_dir(dir); + g_free(dir); =20 /* add the datadir specified when building */ qemu_add_data_dir(CONFIG_QEMU_DATADIR); --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757950439608.1707599321353; Fri, 12 Jan 2018 03:52:30 -0800 (PST) Received: from localhost ([::1]:35308 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxsp-0000Rj-K1 for importer@patchew.org; Fri, 12 Jan 2018 06:52:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYl-0007NV-3g for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYj-0004zn-Vu for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:43 -0500 Received: from mail-wr0-x22d.google.com ([2a00:1450:400c:c0c::22d]:33968) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYj-0004xK-PX for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:41 -0500 Received: by mail-wr0-x22d.google.com with SMTP id 36so5057314wrh.1 for ; Fri, 12 Jan 2018 03:31:41 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W6UqB45VB4pdS4GGw3lFfIWVeAM1VlptPJ23S8G3/7Y=; b=iyNcH4pwYJxcJzAUqLqT2DDsrQPS+UTkFhFWqEa+4CokUi4Y/am5U/MoTHv7HKQafD /5ne2dV0+0DD9t8e0XlLdp9h/lkIbiBSwe/xgOT+cnWkbP34TiFImnnIoSKh2nF5CzO1 PB4fRuMCA54zkoulPm3rXQkNDu4eJNy5l0XGTIOw0zXdrHkbcB1337KOXElyyuG8ko+S zwuf7ep87fjMJ1h2F01g0K9FdjvRON/IJBplzeSzPw50uoI3qq5nLgLEiP/XnSnYmJP6 ynst3Xs1ljNBeSBXr9iUsX7UAleTGcglPguEDH5I+Vtzdd3TSLFpei9+UCrQj6x685WN T08w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=W6UqB45VB4pdS4GGw3lFfIWVeAM1VlptPJ23S8G3/7Y=; b=NZgLfZ9Gow+5waEvsJg7X1Hu/jNYq60z4VGzEQMBV5qrul5zysKOwS01oHMlVJPbNR NyuoUhu+mEtlJaUq/n75G29dTc4KAaP9RP7j9DynYxg0DRNmKySCS3/EErFcTejlnk/u JOHrmASlpPPRuYIyXJJplSBSkiGQ+ybWIl2Rncj3jeYLlunv71AgBRhSjycJMSF+RafY fQGzNqllv22L8zQ5lwKqHbg2LswXzER4kXKiQ9580qqms72wSAlKo6IhSR99m7Fvz9If u15d9yDeW+r6kmgrF5DiDfT2WsnrevuwaiuqdEhXXJon3ZobOz+QFK5GM2GdQuPkUvz5 buaw== X-Gm-Message-State: AKGB3mJwreGRUtDdttgIMMxOPZLqK4/nbB/etKjjdl6blHT6ewYHvabr hXQtWVWXSrnc+PxbotYyA8eHFoSy X-Google-Smtp-Source: ACJfBou1lNWRECZjZyWe02x7wth6xnCDY1es7b5iQEKxEs65OWaIJQM49ZspzF/w8vK7UYxgz0U8Ig== X-Received: by 10.223.169.38 with SMTP id u35mr19148184wrc.57.1515756700419; Fri, 12 Jan 2018 03:31:40 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:42 +0100 Message-Id: <1515756676-3860-19-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22d Subject: [Qemu-devel] [PULL 18/52] readline: add a free function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Fixes leaks such as: Direct leak of 2 byte(s) in 1 object(s) allocated from: #0 0x7eff58beb850 in malloc (/lib64/libasan.so.4+0xde850) #1 0x7eff57942f0c in g_malloc ../glib/gmem.c:94 #2 0x7eff579431cf in g_malloc_n ../glib/gmem.c:331 #3 0x7eff5795f6eb in g_strdup ../glib/gstrfuncs.c:363 #4 0x55db720f1d46 in readline_hist_add /home/elmarco/src/qq/util/readli= ne.c:258 #5 0x55db720f2d34 in readline_handle_byte /home/elmarco/src/qq/util/rea= dline.c:387 #6 0x55db71539d00 in monitor_read /home/elmarco/src/qq/monitor.c:3896 #7 0x55db71f9be35 in qemu_chr_be_write_impl /home/elmarco/src/qq/charde= v/char.c:167 #8 0x55db71f9bed3 in qemu_chr_be_write /home/elmarco/src/qq/chardev/cha= r.c:179 #9 0x55db71fa013c in fd_chr_read /home/elmarco/src/qq/chardev/char-fd.c= :66 #10 0x55db71fe18a8 in qio_channel_fd_source_dispatch /home/elmarco/src/= qq/io/channel-watch.c:84 #11 0x7eff5793a90b in g_main_dispatch ../glib/gmain.c:3182 #12 0x7eff5793b7ac in g_main_context_dispatch ../glib/gmain.c:3847 #13 0x55db720af3bd in glib_pollfds_poll /home/elmarco/src/qq/util/main-= loop.c:214 #14 0x55db720af505 in os_host_main_loop_wait /home/elmarco/src/qq/util/= main-loop.c:261 #15 0x55db720af6d6 in main_loop_wait /home/elmarco/src/qq/util/main-loo= p.c:515 #16 0x55db7184e0de in main_loop /home/elmarco/src/qq/vl.c:1995 #17 0x55db7185e956 in main /home/elmarco/src/qq/vl.c:4914 #18 0x7eff4ea17039 in __libc_start_main (/lib64/libc.so.6+0x21039) (while at it, use g_new0(ReadLineState), it's a bit easier to read) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20180104160523.22995-11-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- include/qemu/readline.h | 1 + monitor.c | 2 +- util/readline.c | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/qemu/readline.h b/include/qemu/readline.h index c08cf74..e812583 100644 --- a/include/qemu/readline.h +++ b/include/qemu/readline.h @@ -59,5 +59,6 @@ ReadLineState *readline_init(ReadLinePrintfFunc *printf_f= unc, ReadLineFlushFunc *flush_func, void *opaque, ReadLineCompletionFunc *completion_finder); +void readline_free(ReadLineState *rs); =20 #endif /* READLINE_H */ diff --git a/monitor.c b/monitor.c index d682eee..b9da5e2 100644 --- a/monitor.c +++ b/monitor.c @@ -583,7 +583,7 @@ static void monitor_data_destroy(Monitor *mon) if (monitor_is_qmp(mon)) { json_message_parser_destroy(&mon->qmp.parser); } - g_free(mon->rs); + readline_free(mon->rs); QDECREF(mon->outbuf); qemu_mutex_destroy(&mon->out_lock); } diff --git a/util/readline.c b/util/readline.c index bbdee79..24ec839 100644 --- a/util/readline.c +++ b/util/readline.c @@ -500,12 +500,28 @@ const char *readline_get_history(ReadLineState *rs, u= nsigned int index) return rs->history[index]; } =20 +void readline_free(ReadLineState *rs) +{ + int i; + + if (!rs) { + return; + } + for (i =3D 0; i < READLINE_MAX_CMDS; i++) { + g_free(rs->history[i]); + } + for (i =3D 0; i < READLINE_MAX_COMPLETIONS; i++) { + g_free(rs->completions[i]); + } + g_free(rs); +} + ReadLineState *readline_init(ReadLinePrintfFunc *printf_func, ReadLineFlushFunc *flush_func, void *opaque, ReadLineCompletionFunc *completion_finder) { - ReadLineState *rs =3D g_malloc0(sizeof(*rs)); + ReadLineState *rs =3D g_new0(ReadLineState, 1); =20 rs->hist_entry =3D -1; rs->opaque =3D opaque; --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757345541679.3362845317757; Fri, 12 Jan 2018 03:42:25 -0800 (PST) Received: from localhost ([::1]:35246 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxj4-0007zF-Kz for importer@patchew.org; Fri, 12 Jan 2018 06:42:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYl-0007O1-KR for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYk-00053i-SP for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:43 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:34928) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYk-00050H-My for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:42 -0500 Received: by mail-wr0-x243.google.com with SMTP id g38so1842415wrd.2 for ; Fri, 12 Jan 2018 03:31:42 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rz4SJ9g5edYJJhxBRiJ+nXbAHi2H1DsaGTsAjHPPY5g=; b=rWvfY4y/RGYSmAjazud3Ny9RGdZ5t/B6p2LQNaDE+ymh+jh2L2RdlrgTT06t+W9B29 cPrzfm1joyMhrv09cJ8cMbmEW2VuF0cyWEb0pjh/dx6UlVkotHcx7UcsV5WfT69yscd6 cIOPSaJlOYVB0dt3nPFa9z14A0C2l4MxiTtqQ2fGujkOw7+26zl6+1AizSPOAey3xUI8 BtzzYbHhIIusjmkkAvwdQmhdUqYq8Z9uq4NdUGiQOb6aTpau90zGZSC5kdIsg/1nkPYi f8bdyJdm/h09yuSgojbHH4MA5VJoNJeVHEpCOTI3tLfzKHVde/FkOnMMNYzI6wJPIZpx 1zsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Rz4SJ9g5edYJJhxBRiJ+nXbAHi2H1DsaGTsAjHPPY5g=; b=pWRLtTkdtcY+Os/w877/elfuAvASZj9714PenhHKJEfFq7su0S2jXwbug+eGH3Ki8V gWcrMC5yCZ4e3ucvkKAMp2dJVV6ZXmTOjITq/4x8MUE3maeEWfBb14v9YKq2fflSb0n0 hKF4dzEW+xYdw7ccaNyj7vT5Hmiz2WV8nv+ID7ay33vNQw20UGc2YkN+lN+NGrdzhw15 L77vUW9cIUcZMRb+F64ghUnsw59KgcbUNfb1tx1n2qYcZTF34JwGM5u8G2pn35sq5R4Z 5WUcOlF8NFDHgFlDD9ghLzwMNmGSRGizSsBmNLl45uZu7ve5ljUhzSlArZCdnHta7kme HcmQ== X-Gm-Message-State: AKwxyteLofZWDrymdwPwPns8uyDiYn5905SdYEl//COSiXlAY3uX0Y5P 2OZtbzX3XMjFQPfQHX4i3yF9qkV4 X-Google-Smtp-Source: ACJfBovu/ROR1+ujEDeLsfH+QQUEscc4fH3wgdXkhnGjHbkmf/ahJ2vL+q7IeGjspnB7wIvv/L/Y8A== X-Received: by 10.223.177.207 with SMTP id r15mr919920wra.32.1515756701428; Fri, 12 Jan 2018 03:31:41 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:43 +0100 Message-Id: <1515756676-3860-20-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 19/52] tests: fix migration-test leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Direct leak of 12 byte(s) in 2 object(s) allocated from: #0 0x7f50d403c850 in malloc (/lib64/libasan.so.4+0xde850) #1 0x7f50d1ddf98f in vasprintf (/lib64/libc.so.6+0x8098f) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20180104160523.22995-12-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- tests/migration-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index be598d3..799e24e 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -358,13 +358,14 @@ static void migrate_check_parameter(QTestState *who, = const char *parameter, const char *value) { QDict *rsp, *rsp_return; - const char *result; + char *result; =20 rsp =3D wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); rsp_return =3D qdict_get_qdict(rsp, "return"); result =3D g_strdup_printf("%" PRId64, qdict_get_try_int(rsp_return, parameter, -1)= ); g_assert_cmpstr(result, =3D=3D, value); + g_free(result); QDECREF(rsp); } =20 --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15157575115865.412184760769151; Fri, 12 Jan 2018 03:45:11 -0800 (PST) Received: from localhost ([::1]:35262 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxli-0001y0-2n for importer@patchew.org; Fri, 12 Jan 2018 06:45:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYq-0007TI-8b for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYm-00058a-BH for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:48 -0500 Received: from mail-wr0-x22f.google.com ([2a00:1450:400c:c0c::22f]:38255) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYm-00054s-1T for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:44 -0500 Received: by mail-wr0-x22f.google.com with SMTP id x1so857527wrb.5 for ; Fri, 12 Jan 2018 03:31:43 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NuiElajSzgeXVDt9AMv7McYSNQMQBvK/T6lpjB9QZKo=; b=uTPxM7Drz33cCdqOfghWt54s0+2ua3qUiNWWYrNefQWFrwcG2ZvKLL2qr6xbM18UII coIA3+AkEm7wc9bNKrlccu+Bvg+1DfTAViI5rrN3ltlYTBQPwRItQf8IDAffKt7Ye7py bNgAS/Z4Wq/10zHTU1dx8b86uGIxjpUAIqd49yZE14NgaR82jV3dUW+9vvXONQgUjrLa uFgJr4TQon3nRrjqxkocanez66oU+slghL2oFCcCKZWg66j9/b6EOD7V6iB6LjDWH91g swwka6cxkbTDBOt9OBqwpCKSeYl9jiqdzDU7VCBTpOzZ46wwfAByT4OMIcA5AMRphAZa abvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=NuiElajSzgeXVDt9AMv7McYSNQMQBvK/T6lpjB9QZKo=; b=AVXMuS8uUhFyPQznBKozGZqkmvee9qmjaztKAxjqdisIFwChwvKhGFGWbqJpEJi8Fb xAPUF18MU3czmDGrW/s9mmLHH2OjFK7tUSduat6W3114lQqkpMsWQDxcbjSb2JwVPgKb IaPeNXfKSdsz7v+0FyFfYCQ37oFmc0qBsnbT0Aq5ElogVSSAn4Y2d2kc74zKQGxL09+Y S2aMTudMy8UF3TYiWoSAZWdl88qieyft9Nney0EhyORfYgzn/aCrZLCoo32GCR3ac95A 7TzDH2igdmY49CsJ4k8aHtC5bZtM27Ik0swxSAhvsumA1f9frEcb9aQphO7k1JvYfcuo G76A== X-Gm-Message-State: AKwxytc7ijhPT/K1nnWHvd5IhacTrVeYhrp3u9wzi5DPQKVDcoT8T6lb XB0R6zVhnBAJKwLuItvNDsJLbj4n X-Google-Smtp-Source: ACJfBoub2lVA7rRqGhqLITk6o3/JfOkcNamn+BFxHki+qG5lcThf3o7KRH8213/kaQ+V70Uvnq7bzw== X-Received: by 10.223.163.205 with SMTP id m13mr5214395wrb.174.1515756702497; Fri, 12 Jan 2018 03:31:42 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:44 +0100 Message-Id: <1515756676-3860-21-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22f Subject: [Qemu-devel] [PULL 20/52] crypto: fix stack-buffer-overflow error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau ASAN complains about: =3D=3D8856=3D=3DERROR: AddressSanitizer: stack-buffer-overflow on address 0= x7ffd8a1fe168 at pc 0x561136cb4451 bp 0x7ffd8a1fe130 sp 0x7ffd8a1fd8e0 READ of size 16 at 0x7ffd8a1fe168 thread T0 #0 0x561136cb4450 in __asan_memcpy (/home/elmarco/src/qq/build/tests/te= st-crypto-ivgen+0x110450) #1 0x561136d2a6a7 in qcrypto_ivgen_essiv_calculate /home/elmarco/src/qq= /crypto/ivgen-essiv.c:83:5 #2 0x561136d29af8 in qcrypto_ivgen_calculate /home/elmarco/src/qq/crypt= o/ivgen.c:72:12 #3 0x561136d07c8e in test_ivgen /home/elmarco/src/qq/tests/test-crypto-= ivgen.c:148:5 #4 0x7f77772c3b04 in test_case_run /home/elmarco/src/gnome/glib/builddi= r/../glib/gtestutils.c:2237 #5 0x7f77772c3ec4 in g_test_run_suite_internal /home/elmarco/src/gnome/= glib/builddir/../glib/gtestutils.c:2321 #6 0x7f77772c3f6d in g_test_run_suite_internal /home/elmarco/src/gnome/= glib/builddir/../glib/gtestutils.c:2333 #7 0x7f77772c3f6d in g_test_run_suite_internal /home/elmarco/src/gnome/= glib/builddir/../glib/gtestutils.c:2333 #8 0x7f77772c3f6d in g_test_run_suite_internal /home/elmarco/src/gnome/= glib/builddir/../glib/gtestutils.c:2333 #9 0x7f77772c4184 in g_test_run_suite /home/elmarco/src/gnome/glib/buil= ddir/../glib/gtestutils.c:2408 #10 0x7f77772c2e0d in g_test_run /home/elmarco/src/gnome/glib/builddir/= ../glib/gtestutils.c:1674 #11 0x561136d0799b in main /home/elmarco/src/qq/tests/test-crypto-ivgen= .c:173:12 #12 0x7f77756e6039 in __libc_start_main (/lib64/libc.so.6+0x21039) #13 0x561136c13d89 in _start (/home/elmarco/src/qq/build/tests/test-cry= pto-ivgen+0x6fd89) Address 0x7ffd8a1fe168 is located in stack of thread T0 at offset 40 in fra= me #0 0x561136d2a40f in qcrypto_ivgen_essiv_calculate /home/elmarco/src/qq= /crypto/ivgen-essiv.c:76 This frame has 1 object(s): [32, 40) 'sector.addr' <=3D=3D Memory access at offset 40 overflows thi= s variable HINT: this may be a false positive if your program uses some custom stack u= nwind mechanism or swapcontext (longjmp and C++ exceptions *are* supported) SUMMARY: AddressSanitizer: stack-buffer-overflow (/home/elmarco/src/qq/buil= d/tests/test-crypto-ivgen+0x110450) in __asan_memcpy Shadow bytes around the buggy address: 0x100031437bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437be0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437bf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =3D>0x100031437c20: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00[f3]f3 f3 0x100031437c30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437c40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437c50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437c60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437c70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb It looks like the rest of the code copes with ndata being larger than sizeof(sector), so limit the memcpy() range. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrange Message-Id: <20180104160523.22995-13-marcandre.lureau@redhat.com> Tested-by: Thomas Huth Reviewed-by: Thomas Huth Signed-off-by: Paolo Bonzini --- crypto/ivgen-essiv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/ivgen-essiv.c b/crypto/ivgen-essiv.c index cba20bd..ad4d926 100644 --- a/crypto/ivgen-essiv.c +++ b/crypto/ivgen-essiv.c @@ -79,7 +79,7 @@ static int qcrypto_ivgen_essiv_calculate(QCryptoIVGen *iv= gen, uint8_t *data =3D g_new(uint8_t, ndata); =20 sector =3D cpu_to_le64(sector); - memcpy(data, (uint8_t *)§or, ndata); + memcpy(data, (uint8_t *)§or, MIN(sizeof(sector), ndata)); if (sizeof(sector) < ndata) { memset(data + sizeof(sector), 0, ndata - sizeof(sector)); } --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515758125172142.80474582944487; Fri, 12 Jan 2018 03:55:25 -0800 (PST) Received: from localhost ([::1]:35325 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxve-00031j-BC for importer@patchew.org; Fri, 12 Jan 2018 06:55:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYq-0007TF-7i for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYn-0005CT-Fy for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:48 -0500 Received: from mail-wr0-x236.google.com ([2a00:1450:400c:c0c::236]:42455) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYn-00059o-9t for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:45 -0500 Received: by mail-wr0-x236.google.com with SMTP id e41so4697471wre.9 for ; Fri, 12 Jan 2018 03:31:45 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u/XEinF2UPj6vJ+xaHPulxx9JcoWOEooHQwRQ8Cr5DU=; b=IqUx3WrLe/3j1LT+IMm+imDHpFOWDjY92/UqrgtsV9eiMdvXJH5FIGA6ttwvvJDY/K ds0z1/JAEe1B+pRDWUu8Dvx522RATPdITG24pvkOZyNh2JKkQJQ/RGlxCJ5It+5x+A9Z 2J3aNsY88W2ACZ+42O4AgAqBilLc2YWV5C3AdkM6UotifQ7F4X6mkoKgPRP12itdmdLZ AeHpZJmBcRPUTzoG/wXEVffGej/CT/AjYHyHXL9hp90rmFGgYnLLDoAi3LyLvFNEUfoz EKs645iZ8y8/5X5AGbBy3mbTHWP0uZl3reoHf+UjO4zZsVPIxYDLBibduLuds0bPblUU assw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=u/XEinF2UPj6vJ+xaHPulxx9JcoWOEooHQwRQ8Cr5DU=; b=ieS49HhzO6XmChKY04ACypkaD/wWtTjbRO+PxllQVjwbtOmnUiWTjeghMyzTC/rHtj nY+LQBRdFTg4rs9Z+NAQu5IrNUo7uLoJkW97V3g7xlv6hZn9464qobsicV0R8bwBhQsN q548Rkd7f4p2Yvzyz8XLrIegS2qGLHyGe3ajLlMV3dJFq7ddUpGWof8cYTeexDX8iD36 uWmuLm/mF6hXoE+Zpho0wBJF/Bu3sXHcWUyxXZZoGBLPGmwYp+3EDTOhNhj5JwkFQLWK NDiAjXhegrkGXahHcbUw6pA54cDTgUcTDIMnpa3/nVM3UZNS1JUMUf2KFY/r7C4tkw0Q bNLw== X-Gm-Message-State: AKwxytfC7GWLmPSwKVcIeEuhYo1WWyccylZLN0Ays2FZW+aUMsXcB7fO MIaJI+he+ojtbfzwWXP/ICvt75X8 X-Google-Smtp-Source: ACJfBotxSP7Kt4utg34naY3kcMlK+QNSQPu/IWuntCN4lWmlLeUSlph4cGJifwx5+0YCL/EHW9ZLbA== X-Received: by 10.223.172.6 with SMTP id v6mr8182359wrc.269.1515756703884; Fri, 12 Jan 2018 03:31:43 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:45 +0100 Message-Id: <1515756676-3860-22-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::236 Subject: [Qemu-devel] [PULL 21/52] qemu-config: fix leak in query-command-line-options X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Direct leak of 160 byte(s) in 4 object(s) allocated from: #0 0x55ed7678cda8 in calloc (/home/elmarco/src/qq/build/x86_64-softmmu/= qemu-system-x86_64+0x797da8) #1 0x7f3f5e725f75 in g_malloc0 /home/elmarco/src/gnome/glib/builddir/..= /glib/gmem.c:124 #2 0x55ed778aa3a7 in query_option_descs /home/elmarco/src/qq/util/qemu-= config.c:60:16 #3 0x55ed778aa307 in get_drive_infolist /home/elmarco/src/qq/util/qemu-= config.c:140:19 #4 0x55ed778a9f40 in qmp_query_command_line_options /home/elmarco/src/q= q/util/qemu-config.c:254:36 #5 0x55ed76d4868c in qmp_marshal_query_command_line_options /home/elmar= co/src/qq/build/qmp-marshal.c:3078:14 #6 0x55ed77855dd5 in do_qmp_dispatch /home/elmarco/src/qq/qapi/qmp-disp= atch.c:104:5 #7 0x55ed778558cc in qmp_dispatch /home/elmarco/src/qq/qapi/qmp-dispatc= h.c:131:11 #8 0x55ed768b592f in handle_qmp_command /home/elmarco/src/qq/monitor.c:= 3840:11 #9 0x55ed7786ccfe in json_message_process_token /home/elmarco/src/qq/qo= bject/json-streamer.c:105:5 #10 0x55ed778fe37c in json_lexer_feed_char /home/elmarco/src/qq/qobject= /json-lexer.c:323:13 #11 0x55ed778fdde6 in json_lexer_feed /home/elmarco/src/qq/qobject/json= -lexer.c:373:15 #12 0x55ed7786cd83 in json_message_parser_feed /home/elmarco/src/qq/qob= ject/json-streamer.c:124:12 #13 0x55ed768b559e in monitor_qmp_read /home/elmarco/src/qq/monitor.c:3= 882:5 #14 0x55ed77714f29 in qemu_chr_be_write_impl /home/elmarco/src/qq/chard= ev/char.c:167:9 #15 0x55ed77714fde in qemu_chr_be_write /home/elmarco/src/qq/chardev/ch= ar.c:179:9 #16 0x55ed7772ffad in tcp_chr_read /home/elmarco/src/qq/chardev/char-so= cket.c:440:13 #17 0x55ed7777113b in qio_channel_fd_source_dispatch /home/elmarco/src/= qq/io/channel-watch.c:84:12 #18 0x7f3f5e71d90b in g_main_dispatch /home/elmarco/src/gnome/glib/buil= ddir/../glib/gmain.c:3182 #19 0x7f3f5e71e7ac in g_main_context_dispatch /home/elmarco/src/gnome/g= lib/builddir/../glib/gmain.c:3847 #20 0x55ed77886ffc in glib_pollfds_poll /home/elmarco/src/qq/util/main-= loop.c:214:9 #21 0x55ed778865fd in os_host_main_loop_wait /home/elmarco/src/qq/util/= main-loop.c:261:5 #22 0x55ed77886222 in main_loop_wait /home/elmarco/src/qq/util/main-loo= p.c:515:11 #23 0x55ed76d2a4df in main_loop /home/elmarco/src/qq/vl.c:1995:9 #24 0x55ed76d1cb4a in main /home/elmarco/src/qq/vl.c:4914:5 #25 0x7f3f555f6039 in __libc_start_main (/lib64/libc.so.6+0x21039) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake Message-Id: <20180104160523.22995-14-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- util/qemu-config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/qemu-config.c b/util/qemu-config.c index 99b0e46..029fec5 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -105,7 +105,8 @@ static void cleanup_infolist(CommandLineParameterInfoLi= st *head) if (!strcmp(pre_entry->value->name, cur->next->value->name)) { del_entry =3D cur->next; cur->next =3D cur->next->next; - g_free(del_entry); + del_entry->next =3D NULL; + qapi_free_CommandLineParameterInfoList(del_entry); break; } pre_entry =3D pre_entry->next; --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757183926661.4869550507258; Fri, 12 Jan 2018 03:39:43 -0800 (PST) Received: from localhost ([::1]:35226 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxgO-0005VK-DH for importer@patchew.org; Fri, 12 Jan 2018 06:39:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYs-0007Vq-E2 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYo-0005GZ-L2 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:50 -0500 Received: from mail-wr0-x230.google.com ([2a00:1450:400c:c0c::230]:37310) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYo-0005DW-EN for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:46 -0500 Received: by mail-wr0-x230.google.com with SMTP id f8so5036628wre.4 for ; Fri, 12 Jan 2018 03:31:46 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7z5QXVDNJQVx6GdUCWuSTf1rtutT+mrE5s7hfNyC0o4=; b=c2bcGcfou4+QuUiB+mPYElxPXIRHvC0IweY3Bb1vCRb42Fh8oE84aU/6WU6yJpZjtY lQwDOqc+KZN5cjazECcyJvoV/xwqv07+WQrRX4upltm42graMnSjPEl2Nd/EguMEOcZY C2i1Qv2mz+ZY1oLxcido6SZ8ZbWHxDDpbhR6P4zUTxIwmdtK/P0dLBXOTJvuHEkFX1kF zVYU9jvL4UpSJuDM1kMDsMPEDKEl0yDMpaouB3T5C7Z2y7vWP92nMUcg60J1ZS8cNll8 4B3kNljHa4XEOCmFBW/IbTwYEaEHSiAFsL4LFqtPqS31wQRK2HTBOOW0byhgcF6Cbvhn Xw9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=7z5QXVDNJQVx6GdUCWuSTf1rtutT+mrE5s7hfNyC0o4=; b=QcXMQ/0dnlNLhrCi/UCj3taGEfboYImGKUM0iJbzmXWKjRrcT47vez1n1rYISubidm ce7YbNVG1YM1WsfMYNniBRSaJxRA3pmE/Rdr4de1uryAfm8zypI9lpDzp8JUjDI4bAg5 GpQWmBT2Tii2NBbqCOUnTgKVmHA1RIP0K0p6Gb8V0wwFWIiqcWW1+F6MAsSwRmCZ1YIS 7aOnvAvBBYkVzhEMXG4Ot10V0yZbcYzFd/2dYulUsgdGWOCH49lF6er0JbG9K/u25LGg Go5joNgHxPOLGfu9U1YKqkNMF/Od41UiyJZbRLXlU4tlOeiWXp2ienvQCxn5szFaUG5J tAWg== X-Gm-Message-State: AKwxytdICtd+Z88mRXahd7HqOMP9P7oIon5H7xwJ1nMaPXcP3CZ1S2AN OAYlFQZkSgvJ+mhLtnAPIrPEwy3Y X-Google-Smtp-Source: ACJfBov13euRth3CQWObJpWjvjotG+GDtQVER2cixqnHlY1SdR+KbeSJdyUfp937C5K9B4XIZd3WXw== X-Received: by 10.223.130.196 with SMTP id 62mr10647915wrc.145.1515756705068; Fri, 12 Jan 2018 03:31:45 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:46 +0100 Message-Id: <1515756676-3860-23-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::230 Subject: [Qemu-devel] [PULL 22/52] tests: fix qmp-test leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Direct leak of 913 byte(s) in 43 object(s) allocated from: #0 0x55880a15df60 in __interceptor_malloc (/home/elmarco/src/qq/build/t= ests/qmp-test+0x110f60) #1 0x7f3f20fd098f in _IO_vasprintf (/lib64/libc.so.6+0x8098f) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20180104160523.22995-15-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- tests/qmp-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qmp-test.c b/tests/qmp-test.c index c5a5c10..36feb22 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -271,7 +271,7 @@ static void add_query_tests(QmpSchema *schema) { SchemaInfoList *tail; SchemaInfo *si, *arg_type, *ret_type; - const char *test_name; + char *test_name; =20 /* Test the query-like commands */ for (tail =3D schema->list; tail; tail =3D tail->next) { @@ -297,6 +297,7 @@ static void add_query_tests(QmpSchema *schema) =20 test_name =3D g_strdup_printf("qmp/%s", si->name); qtest_add_data_func(test_name, si->name, test_query); + g_free(test_name); } } =20 --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151575700735532.38994851498626; Fri, 12 Jan 2018 03:36:47 -0800 (PST) Received: from localhost ([::1]:35206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxdc-000336-Ep for importer@patchew.org; Fri, 12 Jan 2018 06:36:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYr-0007UW-77 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYp-0005LI-TH for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:49 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:39730) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYp-0005IC-KP for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:47 -0500 Received: by mail-wm0-x243.google.com with SMTP id i11so11128319wmf.4 for ; Fri, 12 Jan 2018 03:31:47 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9HikPBVOBjwTvS6oBMcnTIAWg7wrsRV29uTyCorniQ8=; b=svNE8HTpoiVsYISbGfGovsLtS+eHDWLMh2dNMOMeQx77wxr2lGOps38NvQpJIay7fK h0d9ZzDsN1MUWGWze6tkRZAWpoEriVYjOuQ2x/iLCcrAqzFprJWa9NkWpM4NNbjt4L9d KN2ji7AbA7B365Fl1vMqhzwtPcHPqZRzKkip3mP1f6Fkea0twjnGmjTzlJy2lxxQoXaH eJ7QccvhQKe2FEMJAHcjXu5/yvNxvUtZOVVwkobLy1SJx7I+wWwP2uUP8rpP8ho+AVWL TIYtwQXf7oQotNipW7+vKhBiCX5Td6Lk/6xvImIGAavriEwapivoogC7AOpVmfyRRsaq bKwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=9HikPBVOBjwTvS6oBMcnTIAWg7wrsRV29uTyCorniQ8=; b=aBxJBQFw9+XqUTR0/afChRz6lE5Xv7LwehKknYV+z3CGjg1ZLHUp+kEFChZrikF6eZ VHhn7BBrEMowhILWVvq3jwzpG+i3waL4HLdCjYiB/y/K0vMjJxKHpYbO23OmJs8H6Kf6 cQI2TX6h5fTgQrzv72/ZfPJekwExos/gCkF/YvWgOW8P1vO6FkC+RoOZfNITb7KuZ0kl sCLypgH0sUsuzuVPBrpwxhVzmepRFBoZVhlVpuhV249ZuEW6idMVgUPQxsV4lfmLUyPE 0i0as7aT/sEa1DpoRS+IfSoNkA/r9gAkPj34oNUx2a7nlRjHWNap54VEDqS01P+qLf36 DqhQ== X-Gm-Message-State: AKwxyteVipxlUwfeinwTlLusLq/H8bS/k3LEm28Tyss7B250KRHx9odx fztMVTQ9mM8k9fIXvo24lBZ9PmGe X-Google-Smtp-Source: ACJfBotZOg4dvEQUxUf4nSc/p0GX5NqVRLuTwxO1dDer4ctiBBziVzOHZEkXgpjwAuiWd6HSagfIFw== X-Received: by 10.28.236.10 with SMTP id k10mr4144886wmh.33.1515756706278; Fri, 12 Jan 2018 03:31:46 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:47 +0100 Message-Id: <1515756676-3860-24-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 23/52] ucontext: annotate coroutine stack for ASAN X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau It helps ASAN to detect more leaks on coroutine stacks, as found in the following patch. A similar work would need to be done for sigaltstack & windows fibers to have similar coverage. Since ucontext is preferred, I didn't bother checking the other coroutine implementations for now. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi Message-Id: <20180104160523.22995-16-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- .travis.yml | 3 ++- configure | 15 +++++++++++++++ include/qemu/compiler.h | 4 ++++ util/coroutine-ucontext.c | 48 +++++++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f583839..f2291e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,12 +13,13 @@ addons: - libattr1-dev - libbrlapi-dev - libcap-ng-dev + - libgcc-6-dev - libgnutls-dev - libgtk-3-dev - libiscsi-dev - liblttng-ust-dev - - libnfs-dev - libncurses5-dev + - libnfs-dev - libnss3-dev - libpixman-1-dev - libpng12-dev diff --git a/configure b/configure index d033286..c785dab 100755 --- a/configure +++ b/configure @@ -5186,6 +5186,13 @@ if compile_prog "" "" ; then fi =20 ########################################## +# check for asan header +have_asan_iface_h=3Dyes +if ! check_include "sanitizer/asan_interface.h" ; then + have_asan_iface_h=3Dno +fi + +########################################## # End of CC checks # After here, no more $cc or $ld runs =20 @@ -5198,6 +5205,10 @@ elif test "$debug" =3D "yes"; then write_c_skeleton; if compile_prog "-fsanitize=3Daddress" ""; then CFLAGS=3D"-fsanitize=3Daddress $CFLAGS" + if test "$have_asan_iface_h" =3D "no" ; then + print_error "ASAN build enabled, but ASAN header missing." \ + "Without code annotation, the report may be inferior= ." + fi fi if compile_prog "-fsanitize=3Dundefined" ""; then CFLAGS=3D"-fsanitize=3Dundefined $CFLAGS" @@ -6320,6 +6331,10 @@ if test "$have_utmpx" =3D "yes" ; then echo "HAVE_UTMPX=3Dy" >> $config_host_mak fi =20 +if test "$have_asan_iface_h" =3D "yes" ; then + echo "HAVE_ASAN_IFACE_H=3Dy" >> $config_host_mak +fi + if test "$ivshmem" =3D "yes" ; then echo "CONFIG_IVSHMEM=3Dy" >> $config_host_mak fi diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 340e5fd..5fcc4f7 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -111,4 +111,8 @@ #define GCC_FMT_ATTR(n, m) #endif =20 +#ifndef __has_feature +#define __has_feature(x) 0 /* compatibility with non-clang compilers */ +#endif + #endif /* COMPILER_H */ diff --git a/util/coroutine-ucontext.c b/util/coroutine-ucontext.c index 6621f3f..e53147f 100644 --- a/util/coroutine-ucontext.c +++ b/util/coroutine-ucontext.c @@ -31,6 +31,13 @@ #include #endif =20 +#if defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer) +#ifdef HAVE_ASAN_IFACE_H +#define CONFIG_ASAN 1 +#include +#endif +#endif + typedef struct { Coroutine base; void *stack; @@ -59,11 +66,37 @@ union cc_arg { int i[2]; }; =20 +static void finish_switch_fiber(void *fake_stack_save) +{ +#ifdef CONFIG_ASAN + const void *bottom_old; + size_t size_old; + + __sanitizer_finish_switch_fiber(fake_stack_save, &bottom_old, &size_ol= d); + + if (!leader.stack) { + leader.stack =3D (void *)bottom_old; + leader.stack_size =3D size_old; + } +#endif +} + +static void start_switch_fiber(void **fake_stack_save, + const void *bottom, size_t size) +{ +#ifdef CONFIG_ASAN + __sanitizer_start_switch_fiber(fake_stack_save, bottom, size); +#endif +} + static void coroutine_trampoline(int i0, int i1) { union cc_arg arg; CoroutineUContext *self; Coroutine *co; + void *fake_stack_save =3D NULL; + + finish_switch_fiber(NULL); =20 arg.i[0] =3D i0; arg.i[1] =3D i1; @@ -72,9 +105,13 @@ static void coroutine_trampoline(int i0, int i1) =20 /* Initialize longjmp environment and switch back the caller */ if (!sigsetjmp(self->env, 0)) { + start_switch_fiber(&fake_stack_save, + leader.stack, leader.stack_size); siglongjmp(*(sigjmp_buf *)co->entry_arg, 1); } =20 + finish_switch_fiber(fake_stack_save); + while (true) { co->entry(co->entry_arg); qemu_coroutine_switch(co, co->caller, COROUTINE_TERMINATE); @@ -87,6 +124,7 @@ Coroutine *qemu_coroutine_new(void) ucontext_t old_uc, uc; sigjmp_buf old_env; union cc_arg arg =3D {0}; + void *fake_stack_save =3D NULL; =20 /* The ucontext functions preserve signal masks which incurs a * system call overhead. sigsetjmp(buf, 0)/siglongjmp() does not @@ -122,8 +160,12 @@ Coroutine *qemu_coroutine_new(void) =20 /* swapcontext() in, siglongjmp() back out */ if (!sigsetjmp(old_env, 0)) { + start_switch_fiber(&fake_stack_save, co->stack, co->stack_size); swapcontext(&old_uc, &uc); } + + finish_switch_fiber(fake_stack_save); + return &co->base; } =20 @@ -169,13 +211,19 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to= _, CoroutineUContext *from =3D DO_UPCAST(CoroutineUContext, base, from_); CoroutineUContext *to =3D DO_UPCAST(CoroutineUContext, base, to_); int ret; + void *fake_stack_save =3D NULL; =20 current =3D to_; =20 ret =3D sigsetjmp(from->env, 0); if (ret =3D=3D 0) { + start_switch_fiber(action =3D=3D COROUTINE_TERMINATE ? + NULL : &fake_stack_save, to->stack, to->stack_s= ize); siglongjmp(to->env, action); } + + finish_switch_fiber(fake_stack_save); + return ret; } =20 --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757692799996.3564847536337; Fri, 12 Jan 2018 03:48:12 -0800 (PST) Received: from localhost ([::1]:35284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxoh-0004hB-V8 for importer@patchew.org; Fri, 12 Jan 2018 06:48:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYr-0007V0-NW for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYq-0005Nf-RB for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:49 -0500 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]:41544) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYq-0005Lg-L7 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:48 -0500 Received: by mail-wr0-x22e.google.com with SMTP id o7so5029389wro.8 for ; Fri, 12 Jan 2018 03:31:48 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vOMFsB1fKlCZyX/LQoK1dmFDpEjJGdrnUWOa+sk5HGw=; b=uAbMdrb7te3oMC/n5HVa4JkLQ2DcNOF7iBtYRY9nGaYoFWB2nJu3kFjwIDv4NpCODg HlhxbJmtbDm0Znr7ywl9irUXEt5oVc8ksdY/WiKz+Q4hPQmfHsmxbLRjhkPnhmNsDtJ1 qEvq2C1udMJxj+QOnLcG7Zpeoap/lAOZKzTWBqNpx6ZV7d/yifIcty63ciAfFBNWk37w U4MbYlNgfeGsHGUTLffvj8Ws/EszXKJfjy57FCELOCylU0jKo0Xkxt05j4oqVIH8gw9R h3Eyd0gVM/EzGimTvWhWEmwQolxtqzykd052jI0Mvro88IjfuNtYOkxEoHSUbMtu/FQF F1oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=vOMFsB1fKlCZyX/LQoK1dmFDpEjJGdrnUWOa+sk5HGw=; b=s8wMRLaxes1doiggVLMxhbHO05PJp3L82CyR99HdtVwoA646xNSwfHL3VsnNhdPkN6 xAax1ffUolfiDnrsGkOqe4SNe0UiZLsTHGRodvVv496n+e7LAqmxTVZ6Wo16P8b0iIHT oFsVPZB53WnlnuPAeXIR1N5RXIhZQL6zsFRFFBKrj+tLKKGsD2AhBK0y1U4Ax/VhiTmm 7cTLEvNG2Sp8xtt+7xUb3eJqOi2b4M2NTSYQ/IbEpf8uJuxyu6R4ALzGkDCmKHT7I+ed FJIpKVDwP//66Wsuw/l0Y5OPv9B0Pbr9ePJHbq1LKikqwB/bCp6BZ9KQg2bzevtF/L1T BRiQ== X-Gm-Message-State: AKwxytcCBen8MJq/pYRkJlsDJvnUq4apcijkNJZDVFYWTT6EZFVkqdV1 HQLKzAMy1Fop2zLhDXBEkMbWuKch X-Google-Smtp-Source: ACJfBotojmbg7Kl7UhfGm/H+g6lWZru+Ej7tspR0pGDg7CVS9F3RlSTdr+q9wZ7PtmYxhaGDBFRT2Q== X-Received: by 10.223.161.198 with SMTP id v6mr967930wrv.65.1515756707255; Fri, 12 Jan 2018 03:31:47 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:48 +0100 Message-Id: <1515756676-3860-25-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22e Subject: [Qemu-devel] [PULL 24/52] tests: fix coroutine leak in /basic/entered X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau The coroutine is not finished by the time the test ends, resulting in ASAN warning: =3D=3D7005=3D=3DERROR: LeakSanitizer: detected memory leaks Direct leak of 312 byte(s) in 1 object(s) allocated from: #0 0x7fd35290fa38 in __interceptor_calloc (/lib64/libasan.so.4+0xdea38) #1 0x7fd3506c5f75 in g_malloc0 ../glib/gmem.c:124 #2 0x55994af03e47 in qemu_coroutine_new /home/elmarco/src/qemu/util/cor= outine-ucontext.c:144 #3 0x55994aefed99 in qemu_coroutine_create /home/elmarco/src/qemu/util/= qemu-coroutine.c:76 #4 0x55994ac1eb50 in verify_entered_step_1 /home/elmarco/src/qemu/tests= /test-coroutine.c:80 #5 0x55994af03c75 in coroutine_trampoline /home/elmarco/src/qemu/util/c= oroutine-ucontext.c:119 #6 0x7fd34ec02bef (/lib64/libc.so.6+0x50bef) Do not yield() to let the coroutine terminate. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Hajnoczi Message-Id: <20180104160523.22995-17-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- tests/test-coroutine.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test-coroutine.c b/tests/test-coroutine.c index abd97c2..76c6461 100644 --- a/tests/test-coroutine.c +++ b/tests/test-coroutine.c @@ -67,7 +67,6 @@ static void coroutine_fn verify_entered_step_2(void *opaq= ue) /* Once more to check it still works after yielding */ g_assert(qemu_coroutine_entered(caller)); g_assert(qemu_coroutine_entered(qemu_coroutine_self())); - qemu_coroutine_yield(); } =20 static void coroutine_fn verify_entered_step_1(void *opaque) --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757341390448.0338195947703; Fri, 12 Jan 2018 03:42:21 -0800 (PST) Received: from localhost ([::1]:35245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxj2-0007xd-CP for importer@patchew.org; Fri, 12 Jan 2018 06:42:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYs-0007XQ-Vi for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYs-0005Qw-4J for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:50 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:38108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYr-0005Ol-UJ for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:50 -0500 Received: by mail-wr0-x241.google.com with SMTP id x1so857787wrb.5 for ; Fri, 12 Jan 2018 03:31:49 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eP8gLKdjr9LJG1Q7q7ujTcqRzIXaqHbCyeQ33t1MCeE=; b=nhtqGFdKjd2+AWYfUWzU4M6PTxzEzXCfCAeDRtaJud/HxWAX+eUtelFor6gCNGImAF VvYUiXAXoteZyb6SCHAmpchW0/KYTIUakKA007RZKMFNPvMMAOXG2mx85WvrXBLnQq3U on9slNbxzy6EkISpdMCmVJlcAes3CbsljOS1wXkEnTKUdl3uAIA5s4+sTdMoKbsjsYRI GMlw9OE5ZMFHu+74Dw7MpMfhMaFgqcGvuDLCZ7zdP9Q3xJcHoOkFWl2CFM4PM5LvW5b2 VgdvDPi6mUBYmyiGvf2M6JCmE6nfRgEYceGgDsEoPehtA1Tak7M5gL+Ud25SjKWHQmyI RKjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=eP8gLKdjr9LJG1Q7q7ujTcqRzIXaqHbCyeQ33t1MCeE=; b=Jhdr7ayqS/Lw1lyvYKQik0HTFgNhAjrO97FrcoAT9NW1Puq491NlQoU78iUVSX++9a GO2V40a1MSD38uWT/ewZswGk49TCXoSQrJhUpg0WiBcx5fmKAKGWONQMSVz2pE93Pxp7 8XRz7s16MptITd/Wepud65ZznNIkVxU1gN4cUIZgIwZR9WNkqscSm9jj1GQyud33NSx2 zsn4VFGyzddDXArVgqFHDlcDy7CAl096jQh5RcktHXXGLzg+hc5UBI+I66/vX8El5LEx 4iWIISj5FEhDctWnlkqFeaxcec67wYGEVDUsbFnBvR23bwnROT4/GFbijNE98V1u5h9V UsFw== X-Gm-Message-State: AKGB3mK7WLRU3m3H/THkYnqj+TfI+eG7Iqf6lb1xa4wrrk+w+MD4cSv8 f9NM7PfEEFjq7btpSG77CrYfVUiL X-Google-Smtp-Source: ACJfBou+sGe3Bp+w9+v5yxYuaOvEYvME0Ai3f59GM40jo3efPdNpacFFTVoIrjd+T5lN3pWGUYExnw== X-Received: by 10.223.160.139 with SMTP id m11mr22577329wrm.119.1515756708530; Fri, 12 Jan 2018 03:31:48 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:49 +0100 Message-Id: <1515756676-3860-26-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 25/52] mips: fix potential fopen(NULL,...) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Spotted thanks to ASAN. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180104160523.22995-18-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- hw/nvram/ds1225y.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/nvram/ds1225y.c b/hw/nvram/ds1225y.c index 57d5ab2..ad7345f 100644 --- a/hw/nvram/ds1225y.c +++ b/hw/nvram/ds1225y.c @@ -80,7 +80,7 @@ static int nvram_post_load(void *opaque, int version_id) } =20 /* Write back nvram contents */ - s->file =3D fopen(s->filename, "wb"); + s->file =3D s->filename ? fopen(s->filename, "wb") : NULL; if (s->file) { /* Write back contents, as 'wb' mode cleaned the file */ if (fwrite(s->contents, s->chip_size, 1, s->file) !=3D 1) { @@ -126,7 +126,7 @@ static int nvram_sysbus_initfn(SysBusDevice *dev) sysbus_init_mmio(dev, &s->iomem); =20 /* Read current file */ - file =3D fopen(s->filename, "rb"); + file =3D s->filename ? fopen(s->filename, "rb") : NULL; if (file) { /* Read nvram contents */ if (fread(s->contents, s->chip_size, 1, file) !=3D 1) { --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515758234114795.5665607206967; Fri, 12 Jan 2018 03:57:14 -0800 (PST) Received: from localhost ([::1]:35412 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxxI-0004aq-Vb for importer@patchew.org; Fri, 12 Jan 2018 06:57:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYu-0007a1-E2 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYt-0005Tx-8A for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:52 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:38878) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYs-0005Rb-Vm for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:51 -0500 Received: by mail-wm0-x242.google.com with SMTP id 141so11110806wme.3 for ; Fri, 12 Jan 2018 03:31:50 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SBiUxsRwJdIfaKAt9vXbp84X/Umzm/STps26F2h9u9M=; b=hvEe9GnCHkylWLQFb7K2akH1lXqbsQepWj7iVr3pEoGMxQKFxgr6gnrucDz5YgWnoR 7l+O/WHrw6mcixN18tgsCPPnLbLKzecKWZepW38WiXH4GfFwx1oiUeMhSlIkZZypQ9kq ACqTvHHqkHk9CVB7owyr+mR2VDWj3e5c0sdsgG5iZM0GhYaxR/J1zfRDSDfvMRg9kFjN s3+enebWMadgiUEhClpuQnvlR4X3nvvXsBjjRfzeFqizvNwLyOgWh6xeX7gh8xPNXzc5 XEZNTHPP73yl8Lm7ykO/rph4ZNa4+wH6Napdl7+fN0tCp85Ut6ShpDDmFNlaD4UQZI27 mbOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=SBiUxsRwJdIfaKAt9vXbp84X/Umzm/STps26F2h9u9M=; b=KCIyM5fi1oMbfIatgPJyvo5mqEx3y6Mp8PBtJv8MvyNxeu/dnMeT/wxUuq+aNoAW0N cRn74iyg0eZeyH5TD+Ny/h5iHDJ5oICuaW9hyEmtgkf1qB2j/qdV88866GXKFMRLxJ+t QTmhoTVQ5VcrnkHE/93RSHtD2t1OiNtPh+YfsE3JJNZTHh14UjAowApnDLQA5hgPqpNT NoGheL8h2l/lPqLrJNYgYzWBDF+hk4NmOmXbs29/VByqSvs+GmDW1BDRj9RK1XpjX4KA YeVPB1sxyUJ/460FKLSHjC8LnCSx0pi/duKbAHWoqzrWHpYQp8z499y29ZpDHm2JBbTq j+XA== X-Gm-Message-State: AKwxytfcQgSTVSjLbHwfdShgjq4q3b3XSsXWT91IeKxaJfG1DrWldUE/ Y8fXJMaNvN3CfIGqK1QDgzLrou9H X-Google-Smtp-Source: ACJfBosKdbOOgkT1fwA9ZtGFSkjJzLoqPkOSMnOYqk13AGaQ3VpvDhwpz4m0lj7UAe9pWv2qj+RmkQ== X-Received: by 10.28.7.2 with SMTP id 2mr3645586wmh.9.1515756709617; Fri, 12 Jan 2018 03:31:49 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:50 +0100 Message-Id: <1515756676-3860-27-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 26/52] disas/s390: fix global-buffer-overflow X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Spotted thanks to ASAN: =3D=3D25226=3D=3DERROR: AddressSanitizer: global-buffer-overflow on address= 0x556715a1f120 at pc 0x556714b6f6b1 bp 0x7ffcdfac1360 sp 0x7ffcdfac1350 READ of size 1 at 0x556715a1f120 thread T0 #0 0x556714b6f6b0 in init_disasm /home/elmarco/src/qemu/disas/s390.c:219 #1 0x556714b6fa6a in print_insn_s390 /home/elmarco/src/qemu/disas/s390.= c:294 #2 0x55671484d031 in monitor_disas /home/elmarco/src/qemu/disas.c:635 #3 0x556714862ec0 in memory_dump /home/elmarco/src/qemu/monitor.c:1324 #4 0x55671486342a in hmp_memory_dump /home/elmarco/src/qemu/monitor.c:1= 418 #5 0x5567148670be in handle_hmp_command /home/elmarco/src/qemu/monitor.= c:3109 #6 0x5567148674ed in qmp_human_monitor_command /home/elmarco/src/qemu/m= onitor.c:613 #7 0x556714b00918 in qmp_marshal_human_monitor_command /home/elmarco/sr= c/qemu/build/qmp-marshal.c:1704 #8 0x556715138a3e in do_qmp_dispatch /home/elmarco/src/qemu/qapi/qmp-di= spatch.c:104 #9 0x556715138f83 in qmp_dispatch /home/elmarco/src/qemu/qapi/qmp-dispa= tch.c:131 #10 0x55671485cf88 in handle_qmp_command /home/elmarco/src/qemu/monitor= .c:3839 #11 0x55671514e80b in json_message_process_token /home/elmarco/src/qemu= /qobject/json-streamer.c:105 #12 0x5567151bf2dc in json_lexer_feed_char /home/elmarco/src/qemu/qobje= ct/json-lexer.c:323 #13 0x5567151bf827 in json_lexer_feed /home/elmarco/src/qemu/qobject/js= on-lexer.c:373 #14 0x55671514ee62 in json_message_parser_feed /home/elmarco/src/qemu/q= object/json-streamer.c:124 #15 0x556714854b1f in monitor_qmp_read /home/elmarco/src/qemu/monitor.c= :3881 #16 0x556715045440 in qemu_chr_be_write_impl /home/elmarco/src/qemu/cha= rdev/char.c:172 #17 0x556715047184 in qemu_chr_be_write /home/elmarco/src/qemu/chardev/= char.c:184 #18 0x55671505a8e6 in tcp_chr_read /home/elmarco/src/qemu/chardev/char-= socket.c:440 #19 0x5567150943c3 in qio_channel_fd_source_dispatch /home/elmarco/src/= qemu/io/channel-watch.c:84 #20 0x7fb90292b90b in g_main_dispatch ../glib/gmain.c:3182 #21 0x7fb90292c7ac in g_main_context_dispatch ../glib/gmain.c:3847 #22 0x556715162eca in glib_pollfds_poll /home/elmarco/src/qemu/util/mai= n-loop.c:214 #23 0x556715163001 in os_host_main_loop_wait /home/elmarco/src/qemu/uti= l/main-loop.c:261 #24 0x5567151631fa in main_loop_wait /home/elmarco/src/qemu/util/main-l= oop.c:515 #25 0x556714ad6d3b in main_loop /home/elmarco/src/qemu/vl.c:1950 #26 0x556714ade329 in main /home/elmarco/src/qemu/vl.c:4865 #27 0x7fb8fe5c9009 in __libc_start_main (/lib64/libc.so.6+0x21009) #28 0x5567147af4d9 in _start (/home/elmarco/src/qemu/build/s390x-softmm= u/qemu-system-s390x+0xf674d9) 0x556715a1f120 is located 32 bytes to the left of global variable 'char_hci= _type_info' defined in '/home/elmarco/src/qemu/hw/bt/hci-csr.c:493:23' (0x5= 56715a1f140) of size 104 0x556715a1f120 is located 8 bytes to the right of global variable 's390_opc= odes' defined in '/home/elmarco/src/qemu/disas/s390.c:860:33' (0x556715a152= 80) of size 40600 This fix is based on Andreas Arnez upstream commit: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;a=3Dcommitdiff;h= =3D9ace48f3d7d80ce09c5df60cccb433470410b11b 2014-08-19 Andreas Arnez * s390-dis.c (init_disasm): Simplify initialization of opc_index[]. This also fixes an access after the last element of s390_opcodes[]. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180104160523.22995-19-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- disas/s390.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/disas/s390.c b/disas/s390.c index 1f167d2..6393860 100644 --- a/disas/s390.c +++ b/disas/s390.c @@ -207,18 +207,14 @@ static int opc_index[256]; static void init_disasm (struct disassemble_info *info) { - const struct s390_opcode *opcode; - const struct s390_opcode *opcode_end; + int i; =20 memset (opc_index, 0, sizeof (opc_index)); - opcode_end =3D s390_opcodes + s390_num_opcodes; - for (opcode =3D s390_opcodes; opcode < opcode_end; opcode++) - { - opc_index[(int) opcode->opcode[0]] =3D opcode - s390_opcodes; - while ((opcode < opcode_end) && - (opcode[1].opcode[0] =3D=3D opcode->opcode[0])) - opcode++; - } + + /* Reverse order, such that each opc_index ends up pointing to the + first matching entry instead of the last. */ + for (i =3D s390_num_opcodes; i--; ) + opc_index[s390_opcodes[i].opcode[0]] =3D i; =20 #ifdef QEMU_DISABLE switch (info->mach) --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515758394328637.612284063041; Fri, 12 Jan 2018 03:59:54 -0800 (PST) Received: from localhost ([::1]:35711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZy01-0007Ag-4R for importer@patchew.org; Fri, 12 Jan 2018 06:59:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYv-0007bF-Gy for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYu-0005XL-Jh for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:53 -0500 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:37314) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYu-0005V2-Du; Fri, 12 Jan 2018 06:31:52 -0500 Received: by mail-wr0-x234.google.com with SMTP id f8so5036920wre.4; Fri, 12 Jan 2018 03:31:52 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=LSNvDu74sxJsyHLRNAulAQUtE4ZuBiDoYdLAd5X14v4=; b=kSJPCxOqTeQta1QZdviYDN8yKKzifpvN8zv5HmUHkdejFuPbOkzKa2pEn+vlDSYVT6 VMSmX47D4L74geFfEzc6wX+5S9t3wLBLOGR0WwexhX5259YdZpz5PLG62auUuY49Q7+q vIOrNoUQVO2ngtiliWRb2Dd12XFZijFhTy0v8UPXZt80ro//CMn3mEfk3qFrUid2cb4B lAIdLLmQ7rgGk4lmfS69d8/Ta74kUAUi0SaJOmgzV9XjCHi8Ay57+XN6on7BxBHznIwu 1GQCFkrFeFtXWz7YeFSf/9h1Kw4gSzCiB8YfLNh1BfOZj1P3b9CFL+tG+GthsH95kDMy fi2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=LSNvDu74sxJsyHLRNAulAQUtE4ZuBiDoYdLAd5X14v4=; b=jRTqqjtoTGpI0YeggN6HwQKKhIlFBiamMfxVHGLKT0HfeW7KYUfo7h4AaJ7kMeQRVa 2JdBwGPPczS0u/iLckGf3FiHsLhTt1Okz2i2ZPxNAEp0teK/ijyEhFfFwxjDzRMQVVPb nUCQQzBttyxvViOvXkl9+/WokGr+XeQBhy5l5Ep2k5oyWamD6BbvSkmWHl0UH2ghe3oG f3uJmFA3NO5FhNIPH8fig9i6tgHIWW3B18w9GrdJkqDtdaRsRgBMbBnBfRIDu8zeoJrX j1SgFs0f6d3p4qYH16AFE/XMTRR4D72HEwxiZRhhPCqxqaTApV1a2+zMbxPZByMu/Mqw xdRQ== X-Gm-Message-State: AKGB3mLCnVqnxTdcT4uyX5aQljIdyeAeppeM6n4SzlgAWNPLrrzMJdOH 6RS7d/zms4uUMi1h0xAkPNtnfKJU X-Google-Smtp-Source: ACJfBos6IdcxOMnTWjAbGE1PVRfKYsM/DVrDVp8nIaeQS0Kci7/uK6Fa+4NFEXBX3v0rgoZ8eiSvtA== X-Received: by 10.223.134.219 with SMTP id 27mr24701334wry.227.1515756710980; Fri, 12 Jan 2018 03:31:50 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:51 +0100 Message-Id: <1515756676-3860-28-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::234 Subject: [Qemu-devel] [PULL 27/52] scsi-disk: release AioContext in unaligned WRITE SAME case X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-stable@nongnu.org, Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi scsi_write_same_complete() can retry the write if the request was unaligned. Make sure to release the AioContext when that code path is taken! This patch fixes a hang when QEMU terminates after an unaligned WRITE SAME request has been processed with dataplane. The hang occurs because iothread_stop_all() cannot acquire the AioContext lock that was leaked by the IOThread in scsi_write_same_complete(). Fixes: b9e413dd37 ("block: explicitly acquire aiocontext in aio callbacks t= hat need it"). Cc: Paolo Bonzini Cc: qemu-stable@nongnu.org Reported-by: Cong Li Signed-off-by: Stefan Hajnoczi Message-Id: <20180104142502.15175-1-stefanha@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-disk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index e58833a..49d2559 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1755,6 +1755,7 @@ static void scsi_write_same_complete(void *opaque, in= t ret) data->sector << BDRV_SECTOR_BITS, &data->qiov, 0, scsi_write_same_complete, data); + aio_context_release(blk_get_aio_context(s->qdev.conf.blk)); return; } =20 --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515758295803925.2313444811216; Fri, 12 Jan 2018 03:58:15 -0800 (PST) Received: from localhost ([::1]:35415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxyR-0005Zt-0c for importer@patchew.org; Fri, 12 Jan 2018 06:58:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxYw-0007cZ-HI for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYv-0005Zj-Kl for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:54 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:33809) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYv-0005Y3-Em for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:53 -0500 Received: by mail-wr0-x242.google.com with SMTP id 36so5057758wrh.1 for ; Fri, 12 Jan 2018 03:31:53 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=3cqPMVQhriQlpv0DYIbVIjn6P4YBjaOcF2TMiOsuOa8=; b=hFkHttUtj2na5a07ASMJ7xgBi39yxwkVAwKppFCwSWO96naVOMaE+p6mjWPhRzFs7c OtzBWR8wUGSLZv59cw1HeOXbTvzgfaNsaUs0UPZ6szid9l3EwUh0zdli0/aECFKFZ1oA 1SKxReJsrJJibjceYo+c/akATq8MbWMeJCjEIB/F84gcbBlLV3YvJvqKilIcv5xDKhlR gBvHvFUKXCMWx0hVXbSzwMORqpQxq+MipQiLOUwTCHlE87bX0d9ueDY5ENHnorC8WKxH 7tK+509fjZoVuiy9++5uRxkLba4V512c4DWgFwCdXjh3Bf/rZS/K683gYpHxkUSpT1aZ skRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=3cqPMVQhriQlpv0DYIbVIjn6P4YBjaOcF2TMiOsuOa8=; b=SQDw1O7rWpaM6QpLbKSjvo5QtCD4NCedeDiXR7KYM3+WP9Iuc6hEOeAdJScWN0PAFH ZhiLlZ72TU8SK2lnz0fFgXl4Skfw8PPZj2uJ1qTUFuh4KsRRhrNnjrzcC381vOS2OSrI yLh/6TnAJnvikr7TZCLFXV50edg7VPzta4Hi696RxrjZduVigE5gfVSgFm798sBs9SxT RFZoDVm/WabtR5DBBl6mr9HSCAcvQmnhn7x6v/MiNQAXHtbUWLlnyvyXTM9ukFKAQMQU lvqW4RPTgUaaBYs4vwuWccXGslSUsRefrSzJBqrEXzJMqrNgV31VMpRbYDfjKBps9YT4 vZ/g== X-Gm-Message-State: AKwxytdsb+RT2Ajg4RptxCa71ux+6U8OPM00mFWt+B1tH2T1UV9yox81 ihu5fqDzK2bFHMHUuN/61wgK4Hzw X-Google-Smtp-Source: ACJfBouq6iBG/QY9pPJEtOWmVSQ3Os5HdcJV/o/AbJx/y+2WyActQeKP3YBfv6C79hkANx1k3c2pkQ== X-Received: by 10.223.135.59 with SMTP id a56mr5309935wra.121.1515756712057; Fri, 12 Jan 2018 03:31:52 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:52 +0100 Message-Id: <1515756676-3860-29-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 28/52] tests/boot-serial-test: Add tests for microblaze boards X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth This adds two simple TCG + UART tests for the microblaze boards, one in big endian mode, and one in little endian mode. Signed-off-by: Thomas Huth Message-Id: <1512031988-32490-5-git-send-email-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- tests/Makefile.include | 2 ++ tests/boot-serial-test.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/tests/Makefile.include b/tests/Makefile.include index 39a4b53..561e14b 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -300,6 +300,8 @@ check-qtest-alpha-y =3D tests/boot-serial-test$(EXESUF) =20 check-qtest-m68k-y =3D tests/boot-serial-test$(EXESUF) =20 +check-qtest-microblaze-y =3D tests/boot-serial-test$(EXESUF) + check-qtest-mips-y =3D tests/endianness-test$(EXESUF) =20 check-qtest-mips64-y =3D tests/endianness-test$(EXESUF) diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index dd3828c..a39273a 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -24,6 +24,22 @@ static const uint8_t kernel_mcf5208[] =3D { 0x60, 0xfa /* bra.s loop */ }; =20 +static const uint8_t kernel_pls3adsp1800[] =3D { + 0xb0, 0x00, 0x84, 0x00, /* imm 0x8400 */ + 0x30, 0x60, 0x00, 0x04, /* addik r3,r0,4 */ + 0x30, 0x80, 0x00, 0x54, /* addik r4,r0,'T' */ + 0xf0, 0x83, 0x00, 0x00, /* sbi r4,r3,0 */ + 0xb8, 0x00, 0xff, 0xfc /* bri -4 loop */ +}; + +static const uint8_t kernel_plml605[] =3D { + 0xe0, 0x83, 0x00, 0xb0, /* imm 0x83e0 */ + 0x00, 0x10, 0x60, 0x30, /* addik r3,r0,0x1000 */ + 0x54, 0x00, 0x80, 0x30, /* addik r4,r0,'T' */ + 0x00, 0x00, 0x83, 0xf0, /* sbi r4,r3,0 */ + 0xfc, 0xff, 0x00, 0xb8 /* bri -4 loop */ +}; + typedef struct testdef { const char *arch; /* Target architecture */ const char *machine; /* Name of the machine */ @@ -50,6 +66,10 @@ static testdef_t tests[] =3D { { "s390x", "s390-ccw-virtio", "-nodefaults -device sclpconsole,chardev=3Dserial0", "virtio device"= }, { "m68k", "mcf5208evb", "", "TT", sizeof(kernel_mcf5208), kernel_mcf52= 08 }, + { "microblaze", "petalogix-s3adsp1800", "", "TT", + sizeof(kernel_pls3adsp1800), kernel_pls3adsp1800 }, + { "microblazeel", "petalogix-ml605", "", "TT", + sizeof(kernel_plml605), kernel_plml605 }, =20 { NULL } }; --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757508602264.04351484042184; Fri, 12 Jan 2018 03:45:08 -0800 (PST) Received: from localhost ([::1]:35261 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxle-0001vs-Pj for importer@patchew.org; Fri, 12 Jan 2018 06:45:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZ1-0007gP-Hx for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYw-0005cF-LP for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:59 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:34930) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYw-0005aj-FQ for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:54 -0500 Received: by mail-wr0-x243.google.com with SMTP id g38so1842885wrd.2 for ; Fri, 12 Jan 2018 03:31:54 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=PZfiwIiSh1KkFowaK0k3EI9yqZNgRVDZv7AYwSizY1k=; b=L5jBRMQwhFMf6FwRO7g5rfkK42B0fdS4vvjUcTmC3lmFEoPhXWjAsy7oqB7zUW+aXc XtKmNarnmN+Wa4wA+Bw6Vg6eN+ewFFS9HKS4c70PxHZEQtPACLluECNXPgJ/Rqgy7qZC gS50a8rz1SbosLQgek2JX8W6ROlSA4t7iHbpqKtrTI7Z3ERXXv17Kd/LeFEUG/Yi1bQP AnN/tEKYMJbmRxwsbRrWf49TSMc1D9s/rTwhR+Xih3j6Y+sDtvqCEyZY7MYIsz/PWCTd 74STFAuEBRQgyr352hUOPUV3yKI0K85R/9aJi906aptFxa+pog9K5eGSghDDr+/orQdx Q10A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=PZfiwIiSh1KkFowaK0k3EI9yqZNgRVDZv7AYwSizY1k=; b=Vm7js6MwEBDURRJwJivF6BcjkfYCrvGctqBTyUuI8mpS6n0D3ZNvR2Ny7WsxDwjMKm D5WvnEQa9CODSueMndJn/R69UFTgZ8kNodV1LKHz3SUMFuowuP2lUGtdNDMFcZGBT0y6 efMIuR12qiNqyk0t4xZEtCj1jbIuR2qIHvuMVheZFNQFFLlNLECrtpGMtzuvWs2X8AwF Ww7YI+NPVelDoXFj/G2nAHciqh3fchgkRYsRv/elZEWFuCP/LlHN63qS9frpXgd+ijr1 A+LDF7u0i9d/vWwlEORmc2DN3cmVL+U43ypMvHNN27qPdNoTlGgL1leNaThyj1hVwoGg y5qQ== X-Gm-Message-State: AKGB3mJwRUQNEyVEDnzegLHLvyms75xkUqRY5hXeNmOXhB9bmAC5FGX8 PS+LugRgXVDNWzNeB5bC+fbIA8Ix X-Google-Smtp-Source: ACJfBot2DDdac8aOYptoIN/dpcFT9f1VxxU7pbZB0did+4eLq9Tsy/QeFUBwxvIplrkafyR81IsHlA== X-Received: by 10.223.176.17 with SMTP id f17mr16265750wra.178.1515756713141; Fri, 12 Jan 2018 03:31:53 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:53 +0100 Message-Id: <1515756676-3860-30-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 29/52] tests/boot-serial-test: Add a test for the moxiesim machine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth Now that moxiesim supports the -bios parameter, we can check this machine in the boot-serial tester, too, by supplying a mini bios that only writes 'T' characters to the UART. Signed-off-by: Thomas Huth Message-Id: <1512031988-32490-7-git-send-email-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- tests/Makefile.include | 2 ++ tests/boot-serial-test.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/tests/Makefile.include b/tests/Makefile.include index 561e14b..13d6684 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -308,6 +308,8 @@ check-qtest-mips64-y =3D tests/endianness-test$(EXESUF) =20 check-qtest-mips64el-y =3D tests/endianness-test$(EXESUF) =20 +check-qtest-moxie-y =3D tests/boot-serial-test$(EXESUF) + check-qtest-ppc-y =3D tests/endianness-test$(EXESUF) check-qtest-ppc-y +=3D tests/boot-order-test$(EXESUF) check-qtest-ppc-y +=3D tests/prom-env-test$(EXESUF) diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index a39273a..1deddb8 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -40,6 +40,13 @@ static const uint8_t kernel_plml605[] =3D { 0xfc, 0xff, 0x00, 0xb8 /* bri -4 loop */ }; =20 +static const uint8_t bios_moxiesim[] =3D { + 0x20, 0x10, 0x00, 0x00, 0x03, 0xf8, /* ldi.s r1,0x3f8 */ + 0x1b, 0x20, 0x00, 0x00, 0x00, 0x54, /* ldi.b r2,'T' */ + 0x1e, 0x12, /* st.b r1,r2 */ + 0x1a, 0x00, 0x00, 0x00, 0x10, 0x00 /* jmpa 0x1000 */ +}; + typedef struct testdef { const char *arch; /* Target architecture */ const char *machine; /* Name of the machine */ @@ -70,6 +77,7 @@ static testdef_t tests[] =3D { sizeof(kernel_pls3adsp1800), kernel_pls3adsp1800 }, { "microblazeel", "petalogix-ml605", "", "TT", sizeof(kernel_plml605), kernel_plml605 }, + { "moxie", "moxiesim", "", "TT", sizeof(bios_moxiesim), 0, bios_moxies= im }, =20 { NULL } }; --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515758935262395.7256508495923; Fri, 12 Jan 2018 04:08:55 -0800 (PST) Received: from localhost ([::1]:36215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZy8g-0006an-EI for importer@patchew.org; Fri, 12 Jan 2018 07:08:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZ1-0007gO-HW for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYx-0005ei-QL for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:59 -0500 Received: from mail-wr0-x235.google.com ([2a00:1450:400c:c0c::235]:38262) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYx-0005dB-Ja for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:55 -0500 Received: by mail-wr0-x235.google.com with SMTP id x1so858040wrb.5 for ; Fri, 12 Jan 2018 03:31:55 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=juki5wSZBaaw015g+n5tBk3iXQBc1Up1GEZH+gcOqZI=; b=YaZY557oolYZ34LeJKe7qeUGwLgq7h7ys5ialmssBcb8HGlJ7oLEObb+MBJIYhSxdv mBcbMftAGEOHLaixvVyaaQoxbOyjvCEzqX06BWoDck7uOKZSPc/9FzsdgfBr/4PnG9cC Ctnw4w9nHeveiDnjfXUhAl0JsBQNpEOvVGu+DgePV2ODvnHaeY3Jg2G+LXBjTu3IgBPF UB5etIvV5hsF4MU+D8xm9mxKgQeFnCh9hqFgRp/8mQMTY/+Ss0w2HY0wiwnKkxwZTqgz CAJzwEFlOA81Jei/wF3EEyBuoWe138tX72NnDPHUA5Q/ViInKLdSdepNd25KHV8NF5xr eMNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=juki5wSZBaaw015g+n5tBk3iXQBc1Up1GEZH+gcOqZI=; b=mPpRFvMpw6L7qv+/vDHbg2iDDhol3v2zckVXToOrT509k9/Je89UXgmquDegb08RWi JDhfZa7NOH7YqMMzYMJvekzIT4VEZo9W2+AtY4G3/m8StqINvuVv/FWCYeIQoJKddTs6 5n1Lhky5mFfOW8AgDX+NzT8T8JJANl0ez57xNwJNAH3rNx2zzRvOfwx6HMLZslVFX0Nk mgTMeUiCXXxA1nCkcm1L9ZxJd2FGtehg79jizoCGlH93vYLseU6dpyJHGFYGQA9dMhyo JRB6Dk8bZ5NQyNy0dXWOCm/Do7vEKC2yWur/pQS+7f71hYj/sEkFQciVDb2/qKI4Cgcq YRLA== X-Gm-Message-State: AKGB3mKf0fmACC6lMkHp+7VqynDx2TswAIZWIxjaR0p+PQ2/ZVFzklZ6 lcXE6LqM2Pp/mygnjAX0E5OCcEd4 X-Google-Smtp-Source: ACJfBova5TuLqyuQng4plOgmc7WVY3yBLLr34YX9zM97qb9cS6SxGbK6cyumFEEFD6lEIxwUPdc4kA== X-Received: by 10.223.181.2 with SMTP id a2mr24086772wrd.90.1515756714190; Fri, 12 Jan 2018 03:31:54 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:54 +0100 Message-Id: <1515756676-3860-31-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::235 Subject: [Qemu-devel] [PULL 30/52] tests/boot-serial-test: Add support for the raspi2 machine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth The raspi2 machine supports loading firmware images, so we can easily load a small test sequence as raw binary blob here to test the UART. Signed-off-by: Thomas Huth Message-Id: <1512031988-32490-8-git-send-email-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- tests/Makefile.include | 1 + tests/boot-serial-test.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/tests/Makefile.include b/tests/Makefile.include index 13d6684..8883274 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -362,6 +362,7 @@ check-qtest-arm-y +=3D tests/virtio-blk-test$(EXESUF) gcov-files-arm-y +=3D arm-softmmu/hw/block/virtio-blk.c check-qtest-arm-y +=3D tests/test-arm-mptimer$(EXESUF) gcov-files-arm-y +=3D hw/timer/arm_mptimer.c +check-qtest-arm-y +=3D tests/boot-serial-test$(EXESUF) =20 check-qtest-aarch64-y =3D tests/numa-test$(EXESUF) =20 diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index 1deddb8..663b78b 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -47,6 +47,14 @@ static const uint8_t bios_moxiesim[] =3D { 0x1a, 0x00, 0x00, 0x00, 0x10, 0x00 /* jmpa 0x1000 */ }; =20 +static const uint8_t bios_raspi2[] =3D { + 0x08, 0x30, 0x9f, 0xe5, /* ldr r3,[pc,#8] Get bas= e */ + 0x54, 0x20, 0xa0, 0xe3, /* mov r2,#'T' */ + 0x00, 0x20, 0xc3, 0xe5, /* strb r2,[r3] */ + 0xfb, 0xff, 0xff, 0xea, /* b loop */ + 0x00, 0x10, 0x20, 0x3f, /* 0x3f201000 =3D UART0 base a= ddr */ +}; + typedef struct testdef { const char *arch; /* Target architecture */ const char *machine; /* Name of the machine */ @@ -78,6 +86,7 @@ static testdef_t tests[] =3D { { "microblazeel", "petalogix-ml605", "", "TT", sizeof(kernel_plml605), kernel_plml605 }, { "moxie", "moxiesim", "", "TT", sizeof(bios_moxiesim), 0, bios_moxies= im }, + { "arm", "raspi2", "", "TT", sizeof(bios_raspi2), 0, bios_raspi2 }, =20 { NULL } }; --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515758775859793.6775935089781; Fri, 12 Jan 2018 04:06:15 -0800 (PST) Received: from localhost ([::1]:36048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZy6A-00042P-RP for importer@patchew.org; Fri, 12 Jan 2018 07:06:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZ1-0007gQ-IR for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxYz-0005gp-26 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:59 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:43283) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYy-0005fL-Ot for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:57 -0500 Received: by mail-wr0-x244.google.com with SMTP id s13so5020237wra.10 for ; Fri, 12 Jan 2018 03:31:56 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=gmhfB6yzg5GntisSVkW64/ZyayuGnz211dAfY7NHsPI=; b=bKAfC6U6CVtJalgUh7s13U+Qf5ephWpMl7IdRMirx9DtE7AINiFCgHn6pEiFc8Vy2d /RvbkxO+Il0uPCiNx1MFuUpCt9xlMZy3m1dqlY8ixvq0WIDQQAb38quCyCYN6vnQeusD y1bAW8VQwLQYhFxRbshdwRltBFnpE2ZzjIXEwV6CHgEsrPxcO5RLqOo1rXWgqkWAnIem hzrtlLFXuLiAXeYsbZsP4n0JW62ZA5bOJ1t4etT2CkkXUBjLtVVR4babSnH2pIRDqHfE C0dPDjat8OjpskdImhoJ0SPk1BMXo5W2ufqDfm/tUZmpeaUGAJxtqHkYvQ267FK4DNcQ KFiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=gmhfB6yzg5GntisSVkW64/ZyayuGnz211dAfY7NHsPI=; b=DqBrVXJhwbLdAnjOAn+w+d5FnOfAw6dezQTssmDnBKhug2QiJoJJm7qe6MVq3Ieye9 JUEqX/XyflrJgg5h1c4pVy/RO005MCxPDIN9kKVuiCaTVYkEicBOkufHcsJgLQwt3/Sk kljjYxk1VtHpEUPLiKaLoIgsPN6xlWJQUtAmj7DoCVSnI5hZFRSXiQ6EDn0sVxlZTg7x tTWMnKw4lJDINjb1k7e0JOpyVLScmIrACHePL3r4CeqqVRZB7o82PNA1sFIiO9lfUgwK pdWVRsY9jkMqKYkW4+BlJxe651Np4dyiKRNpGieugNO/W+Bfw4zKavIROkoB+RphwO9z AULA== X-Gm-Message-State: AKwxytcRSCOB7EJWUvvo8gD1nqcdjWB0oA4P0GO/ogLo7WYrjnDSf8Oy dJHu25aZqyIBH8nUTSEDAJvyoLjO X-Google-Smtp-Source: ACJfBov919hAppBNLNZxDcof1cl+K2ER4VxOpq4m17/i3YXX51dkJboim0seks9UrXnONrXSeZHK/Q== X-Received: by 10.223.134.58 with SMTP id 55mr4294630wrv.262.1515756715318; Fri, 12 Jan 2018 03:31:55 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:55 +0100 Message-Id: <1515756676-3860-32-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PULL 31/52] target/i386: move hflags update code to a function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tao Wu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Tao Wu We will share the same code for hax/kvm. Signed-off-by: Tao Wu Message-Id: <20180110195056.85403-1-lepton@google.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 42 ++++++++++++++++++++++++++++++++++++++++++ target/i386/cpu.h | 2 ++ target/i386/kvm.c | 40 +--------------------------------------- 3 files changed, 45 insertions(+), 39 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 3818d72..ad8196b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4147,6 +4147,48 @@ static void x86_disas_set_info(CPUState *cs, disasse= mble_info *info) info->cap_insn_split =3D 8; } =20 +void x86_update_hflags(CPUX86State *env) +{ + uint32_t hflags; +#define HFLAG_COPY_MASK \ + ~( HF_CPL_MASK | HF_PE_MASK | HF_MP_MASK | HF_EM_MASK | \ + HF_TS_MASK | HF_TF_MASK | HF_VM_MASK | HF_IOPL_MASK | \ + HF_OSFXSR_MASK | HF_LMA_MASK | HF_CS32_MASK | \ + HF_SS32_MASK | HF_CS64_MASK | HF_ADDSEG_MASK) + + hflags =3D env->hflags & HFLAG_COPY_MASK; + hflags |=3D (env->segs[R_SS].flags >> DESC_DPL_SHIFT) & HF_CPL_MASK; + hflags |=3D (env->cr[0] & CR0_PE_MASK) << (HF_PE_SHIFT - CR0_PE_SHIFT); + hflags |=3D (env->cr[0] << (HF_MP_SHIFT - CR0_MP_SHIFT)) & + (HF_MP_MASK | HF_EM_MASK | HF_TS_MASK); + hflags |=3D (env->eflags & (HF_TF_MASK | HF_VM_MASK | HF_IOPL_MASK)); + + if (env->cr[4] & CR4_OSFXSR_MASK) { + hflags |=3D HF_OSFXSR_MASK; + } + + if (env->efer & MSR_EFER_LMA) { + hflags |=3D HF_LMA_MASK; + } + + if ((hflags & HF_LMA_MASK) && (env->segs[R_CS].flags & DESC_L_MASK)) { + hflags |=3D HF_CS32_MASK | HF_SS32_MASK | HF_CS64_MASK; + } else { + hflags |=3D (env->segs[R_CS].flags & DESC_B_MASK) >> + (DESC_B_SHIFT - HF_CS32_SHIFT); + hflags |=3D (env->segs[R_SS].flags & DESC_B_MASK) >> + (DESC_B_SHIFT - HF_SS32_SHIFT); + if (!(env->cr[0] & CR0_PE_MASK) || (env->eflags & VM_MASK) || + !(hflags & HF_CS32_MASK)) { + hflags |=3D HF_ADDSEG_MASK; + } else { + hflags |=3D ((env->segs[R_DS].base | env->segs[R_ES].base | + env->segs[R_SS].base) !=3D 0) << HF_ADDSEG_SHIFT; + } + } + env->hflags =3D hflags; +} + static Property x86_cpu_properties[] =3D { #ifdef CONFIG_USER_ONLY /* apic_id =3D 0 by default for *-user, see commit 9886e834 */ diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 62c4742..f64e5ed 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1778,4 +1778,6 @@ bool cpu_is_bsp(X86CPU *cpu); =20 void x86_cpu_xrstor_all_areas(X86CPU *cpu, const X86XSaveArea *buf); void x86_cpu_xsave_all_areas(X86CPU *cpu, X86XSaveArea *buf); +void x86_update_hflags(CPUX86State* env); + #endif /* I386_CPU_H */ diff --git a/target/i386/kvm.c b/target/i386/kvm.c index d23127c..825aea5 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1891,7 +1891,6 @@ static int kvm_get_sregs(X86CPU *cpu) { CPUX86State *env =3D &cpu->env; struct kvm_sregs sregs; - uint32_t hflags; int bit, i, ret; =20 ret =3D kvm_vcpu_ioctl(CPU(cpu), KVM_GET_SREGS, &sregs); @@ -1933,44 +1932,7 @@ static int kvm_get_sregs(X86CPU *cpu) env->efer =3D sregs.efer; =20 /* changes to apic base and cr8/tpr are read back via kvm_arch_post_ru= n */ - -#define HFLAG_COPY_MASK \ - ~( HF_CPL_MASK | HF_PE_MASK | HF_MP_MASK | HF_EM_MASK | \ - HF_TS_MASK | HF_TF_MASK | HF_VM_MASK | HF_IOPL_MASK | \ - HF_OSFXSR_MASK | HF_LMA_MASK | HF_CS32_MASK | \ - HF_SS32_MASK | HF_CS64_MASK | HF_ADDSEG_MASK) - - hflags =3D env->hflags & HFLAG_COPY_MASK; - hflags |=3D (env->segs[R_SS].flags >> DESC_DPL_SHIFT) & HF_CPL_MASK; - hflags |=3D (env->cr[0] & CR0_PE_MASK) << (HF_PE_SHIFT - CR0_PE_SHIFT); - hflags |=3D (env->cr[0] << (HF_MP_SHIFT - CR0_MP_SHIFT)) & - (HF_MP_MASK | HF_EM_MASK | HF_TS_MASK); - hflags |=3D (env->eflags & (HF_TF_MASK | HF_VM_MASK | HF_IOPL_MASK)); - - if (env->cr[4] & CR4_OSFXSR_MASK) { - hflags |=3D HF_OSFXSR_MASK; - } - - if (env->efer & MSR_EFER_LMA) { - hflags |=3D HF_LMA_MASK; - } - - if ((hflags & HF_LMA_MASK) && (env->segs[R_CS].flags & DESC_L_MASK)) { - hflags |=3D HF_CS32_MASK | HF_SS32_MASK | HF_CS64_MASK; - } else { - hflags |=3D (env->segs[R_CS].flags & DESC_B_MASK) >> - (DESC_B_SHIFT - HF_CS32_SHIFT); - hflags |=3D (env->segs[R_SS].flags & DESC_B_MASK) >> - (DESC_B_SHIFT - HF_SS32_SHIFT); - if (!(env->cr[0] & CR0_PE_MASK) || (env->eflags & VM_MASK) || - !(hflags & HF_CS32_MASK)) { - hflags |=3D HF_ADDSEG_MASK; - } else { - hflags |=3D ((env->segs[R_DS].base | env->segs[R_ES].base | - env->segs[R_SS].base) !=3D 0) << HF_ADDSEG_SHIFT; - } - } - env->hflags =3D hflags; + x86_update_hflags(env); =20 return 0; } --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515758590845545.2700348945648; Fri, 12 Jan 2018 04:03:10 -0800 (PST) Received: from localhost ([::1]:35956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZy37-0001PI-Fc for importer@patchew.org; Fri, 12 Jan 2018 07:03:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZ1-0007gM-HP for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZ0-0005i5-4n for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:59 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:38109) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxYz-0005gz-UJ for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:58 -0500 Received: by mail-wr0-x241.google.com with SMTP id x1so858141wrb.5 for ; Fri, 12 Jan 2018 03:31:57 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=KuQ/1c7HfPLUFPX79rOY37ztyIuqIfjWjePSU8W73O0=; b=L3X38EdiYLzWxp9AscYp5dbOYYMkXi0WtWNa4IE+3wT5Zd+Lufv5rnvySwyPzElCZ3 GmVjsZ9wNrSGJvFDhvWfhgA9ATUTVbfD+sn2VscByUuakAjHnDGxaAC4w9N352oeu0o4 SBeObGtDpvWT+kuEcPRtwdrHeUT5BVGiaDKQSgXIrXKCOSrPdMhyK38JYHY1UDrkama7 0hfupMiFY24cIaxxo+FV5tKJWZRvwIDnAeU2cmiSgXg21mvdUkV6sS6QoPrwgadCp8IT q26EfLwBdLuGkyWsZPPR/5GdOlhJNlheIqsy1AyBqfw14nloTo64lSIi2KYs1qMFwyF0 /MWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=KuQ/1c7HfPLUFPX79rOY37ztyIuqIfjWjePSU8W73O0=; b=PTOh5NtVL2YQpQUZNTIvnuoUO8dIEK2alATVxdbhaQya84o5p6Zk9eFPbzMyZSYXyM osk6rLn2fGQDDoeKaNMYpG+453eAY6P1a17GSY6raj/hyt7Y0eOlHDh1ob2Yar3GX1TN JlgxuKuJtfftkLdRgHqjvuELVOPchiJi2Kl4I6RJwupThOPxoRufaUwnFG07p/fJxCLu Q863wotPONKGuveWa6FGKx/9U1xwssvTibKlQiVQk638B8pJh9VnGSN0opsDfe+cSJZD O7xk1BCPpcCWwJV/Ry3J+NcyVw1bfpTbPxSbnW0je2SWKt4xrb9QUJl58ee0Yt3u51nN Ublw== X-Gm-Message-State: AKwxytebMLRj7L4jxTm44nsE3hLHAWWGSrpThuUP3TGAWsJ7dWFEuAn9 CRJNgaEhCxLk/tGwMKBf/Mt8LqTe X-Google-Smtp-Source: ACJfBot4ceYM+ZIqQ3U/I77nSUptMo+mov1AIIBv7ByLKLGq3gNapx4gs5MIqSjBUCz+eGGMdl3VZA== X-Received: by 10.223.151.195 with SMTP id t3mr3704272wrb.274.1515756716422; Fri, 12 Jan 2018 03:31:56 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:56 +0100 Message-Id: <1515756676-3860-33-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 32/52] target/i386: hax: change to use x86_update_hflags X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tao Wu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Tao Wu Change to use x86_update_hflags instead of keeping another copy at hax side. This also fix bug like HF_CPL_MASK should be SS.DPL, not CS.DPL. Signed-off-by: Tao Wu Message-Id: <20180110195056.85403-2-lepton@google.com> Signed-off-by: Paolo Bonzini --- target/i386/hax-all.c | 52 +----------------------------------------------= ---- 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/target/i386/hax-all.c b/target/i386/hax-all.c index 3ce6950..07df73e 100644 --- a/target/i386/hax-all.c +++ b/target/i386/hax-all.c @@ -782,56 +782,6 @@ static int hax_set_segments(CPUArchState *env, struct = vcpu_state_t *sregs) return 0; } =20 -/* - * After get the state from the kernel module, some - * qemu emulator state need be updated also - */ -static int hax_setup_qemu_emulator(CPUArchState *env) -{ - -#define HFLAG_COPY_MASK (~( \ - HF_CPL_MASK | HF_PE_MASK | HF_MP_MASK | HF_EM_MASK | \ - HF_TS_MASK | HF_TF_MASK | HF_VM_MASK | HF_IOPL_MASK | \ - HF_OSFXSR_MASK | HF_LMA_MASK | HF_CS32_MASK | \ - HF_SS32_MASK | HF_CS64_MASK | HF_ADDSEG_MASK)) - - uint32_t hflags; - - hflags =3D (env->segs[R_CS].flags >> DESC_DPL_SHIFT) & HF_CPL_MASK; - hflags |=3D (env->cr[0] & CR0_PE_MASK) << (HF_PE_SHIFT - CR0_PE_SHIFT); - hflags |=3D (env->cr[0] << (HF_MP_SHIFT - CR0_MP_SHIFT)) & - (HF_MP_MASK | HF_EM_MASK | HF_TS_MASK); - hflags |=3D (env->eflags & (HF_TF_MASK | HF_VM_MASK | HF_IOPL_MASK)); - hflags |=3D (env->cr[4] & CR4_OSFXSR_MASK) << - (HF_OSFXSR_SHIFT - CR4_OSFXSR_SHIFT); - - if (env->efer & MSR_EFER_LMA) { - hflags |=3D HF_LMA_MASK; - } - - if ((hflags & HF_LMA_MASK) && (env->segs[R_CS].flags & DESC_L_MASK)) { - hflags |=3D HF_CS32_MASK | HF_SS32_MASK | HF_CS64_MASK; - } else { - hflags |=3D (env->segs[R_CS].flags & DESC_B_MASK) >> - (DESC_B_SHIFT - HF_CS32_SHIFT); - hflags |=3D (env->segs[R_SS].flags & DESC_B_MASK) >> - (DESC_B_SHIFT - HF_SS32_SHIFT); - if (!(env->cr[0] & CR0_PE_MASK) || - (env->eflags & VM_MASK) || !(hflags & HF_CS32_MASK)) { - hflags |=3D HF_ADDSEG_MASK; - } else { - hflags |=3D ((env->segs[R_DS].base | - env->segs[R_ES].base | - env->segs[R_SS].base) !=3D 0) << HF_ADDSEG_SHIFT; - } - } - - hflags &=3D ~HF_SMM_MASK; - - env->hflags =3D (env->hflags & HFLAG_COPY_MASK) | hflags; - return 0; -} - static int hax_sync_vcpu_register(CPUArchState *env, int set) { struct vcpu_state_t regs; @@ -888,7 +838,7 @@ static int hax_sync_vcpu_register(CPUArchState *env, in= t set) } } if (!set) { - hax_setup_qemu_emulator(env); + x86_update_hflags(env); } return 0; } --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515759065817198.61497131088902; Fri, 12 Jan 2018 04:11:05 -0800 (PST) Received: from localhost ([::1]:36280 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZyAr-0000Rm-2I for importer@patchew.org; Fri, 12 Jan 2018 07:11:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZ2-0007hA-D9 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZ1-0005jZ-CQ for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:00 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:42800) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZ1-0005if-50 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:31:59 -0500 Received: by mail-wr0-x242.google.com with SMTP id e41so4698068wre.9 for ; Fri, 12 Jan 2018 03:31:59 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=8Iwdh02lxAuXCra5iQtGrzdFxaBXGGrboF8XSt4xjYE=; b=WvAxB04M0ZWtpzlJGSXms7JBYgGEULswQLlcE2go6dWXerchKBY45wjsra9xE4nV40 OzRZSHVZJNWrqbx4BUIL7ZGJWuCRbN/t22RvaHrrTXu+LHVnNwOMAM/gJ6a2LX7VWV17 Osqm5wp5RaFYpv8+BO9RBagm/MQdymHoIwjRZu2JguYCZkShUh8lIT03HBU9dEdd2HTq FpDJsfbuZff0ZHwmpGjiGnHvoYlbeqv1nuc47/ExSBUrTLnPchbGSdXT0zYh0/SUANgg COYdK7rvWUkFtZIMCYBVHPUaaI6SM1tarVcceznFfPHQAGo8XyHSXMPyG8iuIo3vqGNv RXSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=8Iwdh02lxAuXCra5iQtGrzdFxaBXGGrboF8XSt4xjYE=; b=VZ17wu9kSN/Bxa66LVLk09W+iIxHUF6wAGOw4LC1bMZpG5z0MoGwzeYV9NxEpy92cq I1NI/7im79gmdXQNaToA7bO59a5UK9ZAWmMHwRjamWCE5XeZFchrEZnvvbF+z4eFzoO2 6juptbsm1HCh9JAc8K3LvFFxfSKNGasDxfvufurDKgxeMXl9/8F+pOvSo69g0sl1c8cW Oyk0N6912Bvm/4lRBoAAWJAjZxgO5ErkLJt0VNnpJyEsg29TXsXmsXKo7jTB7chIXR6V IOOU2BbHtkXDwdxlMERpljEw9s2HFj1PKToHOYfCL3SthtvF6NHPuPjpLI8N5dUbDopA XVqw== X-Gm-Message-State: AKwxytfXg07XMgHPD46ZkPUBHPSnbfXd5knZcYAdrE5rWbUCxUzKFoqG L02W0614t3Z9I4Qeb+hJamct54r5 X-Google-Smtp-Source: ACJfBotAhAa6A5cUur4NoufmLb+MwE+7r+WgymmxCpj3bkrdNepFuhw+sfPRT9OKKCHCfwZmoWZJAQ== X-Received: by 10.223.145.9 with SMTP id j9mr4859298wrj.128.1515756717845; Fri, 12 Jan 2018 03:31:57 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:57 +0100 Message-Id: <1515756676-3860-34-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 33/52] target/i386: hax: Move x86_update_hflags. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tao Wu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Tao Wu x86_update_hflags reference env->efer which is updated in hax_get_msrs, so it has to be called after hax_get_msrs. This fix the bug that sometimes dump_state show 32 bits regs even in 64 bits mode. Signed-off-by: Tao Wu Message-Id: <20180110195056.85403-3-lepton@google.com> Signed-off-by: Paolo Bonzini --- target/i386/hax-all.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target/i386/hax-all.c b/target/i386/hax-all.c index 07df73e..934ec4a 100644 --- a/target/i386/hax-all.c +++ b/target/i386/hax-all.c @@ -837,9 +837,6 @@ static int hax_sync_vcpu_register(CPUArchState *env, in= t set) return -1; } } - if (!set) { - x86_update_hflags(env); - } return 0; } =20 @@ -1020,6 +1017,7 @@ static int hax_arch_get_registers(CPUArchState *env) return ret; } =20 + x86_update_hflags(env); return 0; } =20 --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515759250946603.8549973490442; Fri, 12 Jan 2018 04:14:10 -0800 (PST) Received: from localhost ([::1]:36450 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZyDq-0003wR-2s for importer@patchew.org; Fri, 12 Jan 2018 07:14:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZ3-0007iK-CM for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZ2-0005kv-FE for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:01 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:36144) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZ2-0005kH-8I for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:00 -0500 Received: by mail-wr0-x241.google.com with SMTP id d9so5042457wre.3 for ; Fri, 12 Jan 2018 03:32:00 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=13d/MZ8SeICCPDu/nrYW0AmsWfWBQL7gRaJrUKchWSM=; b=FNY0H6bMSjYmZOtWj9MTk3lN7ZC1MR79P4Ls1eLugjqyNTR3wEsEl+86ZTf+RwDn6h OvJHo4T1GxsGhvG+HmdWts7KmRfdcM40/E0vdhkCUwgArX2BE+9ARvERtIfKxDYzBEKd e/hI2yjiXghMGnVNxB6oTTNzIz//n9Oq1jhL/QbrwUC+X4a9V3uvsoFadd0kkgoa/WBv Nbu/kMjWcwTOerTw3TiE13WC49fVjRXLzEZ/N95WVmlTx9UgbBQwpVUeobGwECHeqW/B k+Fe2BIwy+r3S9BWC9I5TT9Skd5/VtDRPIb8gFT5IjQ3H5ncp0EU8mRfYPNwXELBy2k5 Cl4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=13d/MZ8SeICCPDu/nrYW0AmsWfWBQL7gRaJrUKchWSM=; b=HH6b9CrN9qcf76WrO8hhIDxCU9Lizh4Kf67j6DENjpEWSzzXPyHa1ZS0uH9JlQ/dAt txXnUmAwUfpENIkFWVk4CdHx/ym7WIXpYXx+TkqwmvGacqu4WlRb2670pmFv7e0pMOnj AEvwTtkI7hbsI4Lh+09ZvCEbLjNo49HeauVZNWhIvphs7SjLQFux6rSBItTzdyDSqZNM t3+b73OPJNsNnregGOrBzNnsaMgVmLlMie253pven+8KbQiFd+d+s7qLM29UiWJwClWD CPps5a87hA55ccep4U1Vw+3MPqG8TJfAYXmiaZToOUirPX3fueiogtT4igPGqtAZ0WfQ ES3w== X-Gm-Message-State: AKwxytf8FBqa7mGNODIyOEMxCt/bbmObn3ix9Pafuuf6TXISusJcBkiN Wch4QS1LResp77AH0ZRVxRXJOOXm X-Google-Smtp-Source: ACJfBouk05e7p9TOVqsOidkSYtp2yXaY5DajxxR4bhsZa9sFyMUbkbfsAA+WjCRqbXiWhjKRrlOvfA== X-Received: by 10.223.188.77 with SMTP id a13mr2642376wrh.161.1515756718961; Fri, 12 Jan 2018 03:31:58 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:58 +0100 Message-Id: <1515756676-3860-35-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 34/52] target-i386: update hflags on Hypervisor.framework X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This ensures that x86_cpu_dump_state shows registers with the correct size. Signed-off-by: Paolo Bonzini --- target/i386/hvf/x86hvf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c index 71c0515..7803e09 100644 --- a/target/i386/hvf/x86hvf.c +++ b/target/i386/hvf/x86hvf.c @@ -297,7 +297,6 @@ int hvf_get_registers(CPUState *cpu_state) X86CPU *x86cpu =3D X86_CPU(cpu_state); CPUX86State *env =3D &x86cpu->env; =20 - env->regs[R_EAX] =3D rreg(cpu_state->hvf_fd, HV_X86_RAX); env->regs[R_EBX] =3D rreg(cpu_state->hvf_fd, HV_X86_RBX); env->regs[R_ECX] =3D rreg(cpu_state->hvf_fd, HV_X86_RCX); @@ -333,6 +332,7 @@ int hvf_get_registers(CPUState *cpu_state) env->dr[6] =3D rreg(cpu_state->hvf_fd, HV_X86_DR6); env->dr[7] =3D rreg(cpu_state->hvf_fd, HV_X86_DR7); =20 + x86_update_hflags(env); return 0; } =20 --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515759404389842.4149297397564; Fri, 12 Jan 2018 04:16:44 -0800 (PST) Received: from localhost ([::1]:36503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZyGB-00062d-5y for importer@patchew.org; Fri, 12 Jan 2018 07:16:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZ4-0007ja-KV for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZ3-0005m8-Ka for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:02 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:37003) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZ3-0005lV-DS for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:01 -0500 Received: by mail-wr0-x241.google.com with SMTP id f8so5037331wre.4 for ; Fri, 12 Jan 2018 03:32:01 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.31.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:31:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8uK7m+aJMARg3nM8RYFYCYedyXZ6erON3h2snC7pldM=; b=Gu6WeHjIKfSmDdb6oRzZdNG0zr6iEeEwyXbmc8jEfSzcFo0D+zNEUdzLezD3OSbVsk P6zONynhs3/y5mYRlUgb/2U8Uyvdgx0rQqSAz4RNdvHe3xmOwtUllEb54WULPyBMW1ps zJUkMoEA4KgASR0OeJrjPNrRumpLSaTKrw9E25UyBwbwAqkfimzF1u/Gy1U7fMQ10URH HC2qnTuQH/A7j+6jnPiGATtn+zRJVRi5Fgc27Tqu9tp3ZCfybvu7SoDrobPUCOm1X0fb eGB1SSdtrrwxN4o6G2/r9xo0OTmhHnZGAHp7PYDVLrp0nUsgvQ6FMWlyh816qWq3HBLN aJ8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=8uK7m+aJMARg3nM8RYFYCYedyXZ6erON3h2snC7pldM=; b=OGS1klkty4Qdu/V1rt+NgWg3qzKgf1pi330eJu+bihD/GJ9c5ppSmQ51ofzVQdWZDG 8M2df9xq/zVuUXnexk5gGfI0B9BQnLZGNyHB4FwSRH4+wZ7Utd1v9U97XuzBgsh6X0hP /fAyUrwhyyC4PvGhQ0gSkwJl2yRtzyv/ulpFNhO+N9/eEI98iL64GqGY0wY6n3GbLvM8 ycW6FxnUVTFGt7z3yBkMjVU3x3e86Hgvga0SEjiZsnS24GAapT1oJ0mYNxEqGvTJ6Id2 C5dLlWdZt6X/WTWd0weTtfUJdmfuQauyVnq3jnPbJyM9KqkQMjFSRmL6BRksgF6YyEte ulvg== X-Gm-Message-State: AKGB3mIC9esHTZSsjB2a/hIzgXD+nf02TJRsXg6pQqahbNE0fJaZiKCu Vt33ZdPhXf3dar42EZ7WrIxwVr6v X-Google-Smtp-Source: ACJfBouVSaoQNrlfqy2MSB1FiKEZ6wu0diN8e5a9wgjP0QMzd4pUUUiU2U9qx8kHpw8pZYWCRamt8A== X-Received: by 10.223.183.23 with SMTP id l23mr14776005wre.33.1515756720039; Fri, 12 Jan 2018 03:32:00 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:30:59 +0100 Message-Id: <1515756676-3860-36-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 35/52] scripts/qemu-gdb: add simple tcg lock status helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Alex Benn=C3=A9e Add a simple helper to dump lock state. Signed-off-by: Alex Benn=C3=A9e Signed-off-by: Paolo Bonzini --- scripts/qemu-gdb.py | 3 ++- scripts/qemugdb/tcg.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 scripts/qemugdb/tcg.py diff --git a/scripts/qemu-gdb.py b/scripts/qemu-gdb.py index b3f8e04..d58213e 100644 --- a/scripts/qemu-gdb.py +++ b/scripts/qemu-gdb.py @@ -26,7 +26,7 @@ import os, sys =20 sys.path.append(os.path.dirname(__file__)) =20 -from qemugdb import aio, mtree, coroutine +from qemugdb import aio, mtree, coroutine, tcg =20 class QemuCommand(gdb.Command): '''Prefix for QEMU debug support commands''' @@ -38,6 +38,7 @@ QemuCommand() coroutine.CoroutineCommand() mtree.MtreeCommand() aio.HandlersCommand() +tcg.TCGLockStatusCommand() =20 coroutine.CoroutineSPFunction() coroutine.CoroutinePCFunction() diff --git a/scripts/qemugdb/tcg.py b/scripts/qemugdb/tcg.py new file mode 100644 index 0000000..88d042e --- /dev/null +++ b/scripts/qemugdb/tcg.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# GDB debugging support, TCG status +# +# Copyright 2016 Linaro Ltd +# +# Authors: +# Alex Benn=C3=83=C2=A9e +# +# This work is licensed under the terms of the GNU GPL, version 2. See +# the COPYING file in the top-level directory. +# +# Contributions after 2012-01-13 are licensed under the terms of the +# GNU GPL, version 2 or (at your option) any later version. + +# 'qemu tcg-lock-status' -- display the TCG lock status across threads + +import gdb + +class TCGLockStatusCommand(gdb.Command): + '''Display TCG Execution Status''' + def __init__(self): + gdb.Command.__init__(self, 'qemu tcg-lock-status', gdb.COMMAND_DAT= A, + gdb.COMPLETE_NONE) + + def invoke(self, arg, from_tty): + gdb.write("Thread, BQL (iothread_mutex), Replay, Blocked?\n") + for thread in gdb.inferiors()[0].threads(): + thread.switch() + + iothread =3D gdb.parse_and_eval("iothread_locked") + replay =3D gdb.parse_and_eval("replay_locked") + + frame =3D gdb.selected_frame() + if frame.name() =3D=3D "__lll_lock_wait": + frame.older().select() + mutex =3D gdb.parse_and_eval("mutex") + owner =3D gdb.parse_and_eval("mutex->__data.__owner") + blocked =3D ("__lll_lock_wait waiting on %s from %d" % + (mutex, owner)) + else: + blocked =3D "not blocked" + + gdb.write("%d/%d, %s, %s, %s\n" % (thread.num, thread.ptid[1], + iothread, replay, blocked)) --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515758474040677.9942454848656; Fri, 12 Jan 2018 04:01:14 -0800 (PST) Received: from localhost ([::1]:35719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZy1J-0008HA-5v for importer@patchew.org; Fri, 12 Jan 2018 07:01:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZ5-0007ky-Mm for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZ4-0005mc-L6 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:03 -0500 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:33976) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZ4-0005mL-Db for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:02 -0500 Received: by mail-wr0-x234.google.com with SMTP id 36so5058150wrh.1 for ; Fri, 12 Jan 2018 03:32:02 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IZajmzx9rYLPKOH9/4/XmxvTKJQx6xsNJtYxUYRx2LM=; b=R8sdTAroFYJtMmPIxzGXa4EM7D7FMbpvhcS7IJ/62hZnYsCHYtqUTs+8Aw6EGTmVTY 2Bwx68Q4V5bxKWgGPWIGV4UrlcpiFpytIGS+2nRDVQwJOb3+HOeAFlh3lyidshW9YOoz HfGGlUtJcJH9iAwY1h4xke+pWMhQXeH7FczHb6Xa2T76I7KKH6XhexUsJtyjdBzYpuzd 9gpgUiykDDMi53WBQwZps1cHSPSYMrqlQni/cuYYuWwy3H+QPsEcGUD/+CYbO4DhFIuJ bHGRO5SA6sqb+TSLcE4rvN0MS48Qh5VpgLl8J5SMP6gR5rbAs7MMWX/qBT3jWn2r8IzK fxgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=IZajmzx9rYLPKOH9/4/XmxvTKJQx6xsNJtYxUYRx2LM=; b=ALgCNYc74XNsrsSMYTfY8jHMpEU3Xx0laV2U3UNZG14af3oKSx8tQ6xMIKhmdryBco oZSeXUrAeEALHN5ukW0pAmNLJUjMEJ/lkDnodqIeQwA8wkJXTKPDzgbVxLbVJaTdPc/L GLuNl5pNoDoR2URdTk0rLvgQ/HNQQ+MRog3jfh/1p6+v2w5HMMvj9ttLUjg97plrYaBQ NnostZJ9uKpx706TftTT/TEXvkvSz66x8dUwswys0zoY/1lqRSlu2+1UbRGrlPslCu9h N4ha2Xy2wXeZIQ3z/IZ6r7SuuekQydhbdOpYvLxBD6lXibDafpdnFc7Ks8Uo+mmHt6HR mVjw== X-Gm-Message-State: AKGB3mJUq9ipPxvxd66HlZCBbuZHPS1x4tZmt6U74H6IocWuY7f45j75 w4IkF8859jmu1F7RpHHUbfUqOdZv X-Google-Smtp-Source: ACJfBovWff31cN2fUPl5RKGd5dYkzbCf/NaHPCr8/ABxVrbP3Pbm9HLgxAES3sEXI7oKMc2nuLb+mQ== X-Received: by 10.223.160.139 with SMTP id m11mr22577963wrm.119.1515756721089; Fri, 12 Jan 2018 03:32:01 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:00 +0100 Message-Id: <1515756676-3860-37-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::234 Subject: [Qemu-devel] [PULL 36/52] scripts/qemu-gdb/timers.py: new helper to dump timer state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Alex Benn=C3=A9e This introduces the qemu-gdb command "qemu timers" which will dump the state of the main timers in the system. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- scripts/qemu-gdb.py | 3 ++- scripts/qemugdb/timers.py | 54 +++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 scripts/qemugdb/timers.py diff --git a/scripts/qemu-gdb.py b/scripts/qemu-gdb.py index d58213e..690827e 100644 --- a/scripts/qemu-gdb.py +++ b/scripts/qemu-gdb.py @@ -26,7 +26,7 @@ import os, sys =20 sys.path.append(os.path.dirname(__file__)) =20 -from qemugdb import aio, mtree, coroutine, tcg +from qemugdb import aio, mtree, coroutine, tcg, timers =20 class QemuCommand(gdb.Command): '''Prefix for QEMU debug support commands''' @@ -39,6 +39,7 @@ coroutine.CoroutineCommand() mtree.MtreeCommand() aio.HandlersCommand() tcg.TCGLockStatusCommand() +timers.TimersCommand() =20 coroutine.CoroutineSPFunction() coroutine.CoroutinePCFunction() diff --git a/scripts/qemugdb/timers.py b/scripts/qemugdb/timers.py new file mode 100644 index 0000000..98ab7c6 --- /dev/null +++ b/scripts/qemugdb/timers.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +# GDB debugging support +# +# Copyright 2017 Linaro Ltd +# +# Author: Alex Benn=C3=83=C2=A9e +# +# This work is licensed under the terms of the GNU GPL, version 2. See +# the COPYING file in the top-level directory. + +# 'qemu timers' -- display the current timerlists + +import gdb + +class TimersCommand(gdb.Command): + '''Display the current QEMU timers''' + + def __init__(self): + 'Register the class as a gdb command' + gdb.Command.__init__(self, 'qemu timers', gdb.COMMAND_DATA, + gdb.COMPLETE_NONE) + + def dump_timers(self, timer): + "Follow a timer and recursively dump each one in the list." + # timer should be of type QemuTimer + gdb.write(" timer %s/%s (cb:%s,opq:%s)\n" % ( + timer['expire_time'], + timer['scale'], + timer['cb'], + timer['opaque'])) + + if int(timer['next']) > 0: + self.dump_timers(timer['next']) + + + def process_timerlist(self, tlist, ttype): + gdb.write("Processing %s timers\n" % (ttype)) + gdb.write(" clock %s is enabled:%s, last:%s\n" % ( + tlist['clock']['type'], + tlist['clock']['enabled'], + tlist['clock']['last'])) + if int(tlist['active_timers']) > 0: + self.dump_timers(tlist['active_timers']) + + + def invoke(self, arg, from_tty): + 'Run the command' + main_timers =3D gdb.parse_and_eval("main_loop_tlg") + + # This will break if QEMUClockType in timer.h is redfined + self.process_timerlist(main_timers['tl'][0], "Realtime") + self.process_timerlist(main_timers['tl'][1], "Virtual") + self.process_timerlist(main_timers['tl'][2], "Host") + self.process_timerlist(main_timers['tl'][3], "Virtual RT") --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515758674199197.69390852070762; Fri, 12 Jan 2018 04:04:34 -0800 (PST) Received: from localhost ([::1]:35982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZy4U-0002Xj-Nj for importer@patchew.org; Fri, 12 Jan 2018 07:04:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZA-0007oT-Dp for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZ6-0005o4-3F for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:08 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:33012) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZ5-0005n7-Q0 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:04 -0500 Received: by mail-wr0-x244.google.com with SMTP id p6so5053646wrd.0 for ; Fri, 12 Jan 2018 03:32:03 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=2eVEPGGd0p1cc+W9ih7Iyu213y0WXBSfJ07Qj6gqueo=; b=PbAQ4folBBq+SITMc/0+sZP1axw8DFDz3E8i1vIDbbKvTF1hcxykNiNPCPXW9ZADuV akIFHYLfgYfNW5P+cZk/BlKg0U61Uoy8UcC2KYUSE3lsm65g/NhtBmq4hooDCvDenTdb 9oSJNGWNWMhPXz9PUo2yJWljiTd15cuwnY16zyb+X8XrBq3Iv1KcV0n88ybO5gqVGPz9 kGqyKnAHTKYIszDjlf05vRO2MDx8J5DpHDEp7K/Na9qj/PzhQIlKnb/d51627q0s9sYw t3Y4Egxchc++QdznUvpKO0g7B1rjOoT/C4B+RablZvDWfW8GjYSgrXFuCDkUwONE1Q3+ LpJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=2eVEPGGd0p1cc+W9ih7Iyu213y0WXBSfJ07Qj6gqueo=; b=nPwP7hR7P8RqugTUpna9OgnJxSx0EV4n7T3Na3utzI8MuDo756NL9GVMAn3D1hpc16 Tqkrw2edq3WTLYoIkoYDcvsLHD6wL4XdwZigZVI24wDVN0YysacC6wttc8PV7daJLMFq MzRAWcKItAN2ZcD5pEFSouL1zagLnqdN9iXFd/RP8+9uvBt7cthSWjaSlGx99+exFmSP H1biPSP0m1HH1c5bvgqxsoQfNVvXsnrLl8fk8Ns366UozBnfvR2ru7+dXsbsEJn5WKUu TJdDvg1qBgyjEQfuVMnPerrDGTxsQuS4hyUEK7XXyZweyXCFXpOK5T5CbqDYCObERSwD FOJg== X-Gm-Message-State: AKGB3mLtenzl2LC6EdLvjgAJBdPGxf1J9HF6mwX4mnUHoIL0EU9FTaCt v3Vlkcf8j0zVn57imPBy+NPBV/fZ X-Google-Smtp-Source: ACJfBotqUzo2oJ5ySKcg5B776GiO0Fl12/7vdQl4hO95GMi9KlIpbDEgkRgoUH0C3xbdRojzfzEvbg== X-Received: by 10.223.134.219 with SMTP id 27mr24701933wry.227.1515756722392; Fri, 12 Jan 2018 03:32:02 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:01 +0100 Message-Id: <1515756676-3860-38-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PULL 37/52] icount: fixed saving/restoring of icount warp timers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pavel Dovgalyuk This patch adds saving and restoring of the icount warp timers in the vmstate. It is needed because there timers affect the virtual clock value. Therefore determinism of the execution in icount record/replay mode depends on determinism of the timers. Signed-off-by: Pavel Dovgalyuk Acked-by: Paolo Bonzini Signed-off-by: Paolo Bonzini Signed-off-by: Pavel Dovgalyuk --- cpus.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++-----------= ---- 1 file changed, 66 insertions(+), 19 deletions(-) diff --git a/cpus.c b/cpus.c index e8139de..f992537 100644 --- a/cpus.c +++ b/cpus.c @@ -120,16 +120,11 @@ static bool all_cpu_threads_idle(void) /* Protected by TimersState seqlock */ =20 static bool icount_sleep =3D true; -static int64_t vm_clock_warp_start =3D -1; /* Conversion factor from emulated instructions to virtual clock ticks. */ static int icount_time_shift; /* Arbitrarily pick 1MIPS as the minimum allowable speed. */ #define MAX_ICOUNT_SHIFT 10 =20 -static QEMUTimer *icount_rt_timer; -static QEMUTimer *icount_vm_timer; -static QEMUTimer *icount_warp_timer; - typedef struct TimersState { /* Protected by BQL. */ int64_t cpu_ticks_prev; @@ -147,6 +142,11 @@ typedef struct TimersState { int64_t qemu_icount_bias; /* Only written by TCG thread */ int64_t qemu_icount; + /* for adjusting icount */ + int64_t vm_clock_warp_start; + QEMUTimer *icount_rt_timer; + QEMUTimer *icount_vm_timer; + QEMUTimer *icount_warp_timer; } TimersState; =20 static TimersState timers_state; @@ -432,14 +432,14 @@ static void icount_adjust(void) =20 static void icount_adjust_rt(void *opaque) { - timer_mod(icount_rt_timer, + timer_mod(timers_state.icount_rt_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL_RT) + 1000); icount_adjust(); } =20 static void icount_adjust_vm(void *opaque) { - timer_mod(icount_vm_timer, + timer_mod(timers_state.icount_vm_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + NANOSECONDS_PER_SECOND / 10); icount_adjust(); @@ -460,7 +460,7 @@ static void icount_warp_rt(void) */ do { seq =3D seqlock_read_begin(&timers_state.vm_clock_seqlock); - warp_start =3D vm_clock_warp_start; + warp_start =3D timers_state.vm_clock_warp_start; } while (seqlock_read_retry(&timers_state.vm_clock_seqlock, seq)); =20 if (warp_start =3D=3D -1) { @@ -473,7 +473,7 @@ static void icount_warp_rt(void) cpu_get_clock_locked()); int64_t warp_delta; =20 - warp_delta =3D clock - vm_clock_warp_start; + warp_delta =3D clock - timers_state.vm_clock_warp_start; if (use_icount =3D=3D 2) { /* * In adaptive mode, do not let QEMU_CLOCK_VIRTUAL run too @@ -485,7 +485,7 @@ static void icount_warp_rt(void) } timers_state.qemu_icount_bias +=3D warp_delta; } - vm_clock_warp_start =3D -1; + timers_state.vm_clock_warp_start =3D -1; seqlock_write_end(&timers_state.vm_clock_seqlock); =20 if (qemu_clock_expired(QEMU_CLOCK_VIRTUAL)) { @@ -594,11 +594,13 @@ void qemu_start_warp_timer(void) * every 100ms. */ seqlock_write_begin(&timers_state.vm_clock_seqlock); - if (vm_clock_warp_start =3D=3D -1 || vm_clock_warp_start > clo= ck) { - vm_clock_warp_start =3D clock; + if (timers_state.vm_clock_warp_start =3D=3D -1 + || timers_state.vm_clock_warp_start > clock) { + timers_state.vm_clock_warp_start =3D clock; } seqlock_write_end(&timers_state.vm_clock_seqlock); - timer_mod_anticipate(icount_warp_timer, clock + deadline); + timer_mod_anticipate(timers_state.icount_warp_timer, + clock + deadline); } } else if (deadline =3D=3D 0) { qemu_clock_notify(QEMU_CLOCK_VIRTUAL); @@ -623,7 +625,7 @@ static void qemu_account_warp_timer(void) return; } =20 - timer_del(icount_warp_timer); + timer_del(timers_state.icount_warp_timer); icount_warp_rt(); } =20 @@ -632,6 +634,45 @@ static bool icount_state_needed(void *opaque) return use_icount; } =20 +static bool warp_timer_state_needed(void *opaque) +{ + TimersState *s =3D opaque; + return s->icount_warp_timer !=3D NULL; +} + +static bool adjust_timers_state_needed(void *opaque) +{ + TimersState *s =3D opaque; + return s->icount_rt_timer !=3D NULL; +} + +/* + * Subsection for warp timer migration is optional, because may not be cre= ated + */ +static const VMStateDescription icount_vmstate_warp_timer =3D { + .name =3D "timer/icount/warp_timer", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D warp_timer_state_needed, + .fields =3D (VMStateField[]) { + VMSTATE_INT64(vm_clock_warp_start, TimersState), + VMSTATE_TIMER_PTR(icount_warp_timer, TimersState), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription icount_vmstate_adjust_timers =3D { + .name =3D "timer/icount/timers", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D adjust_timers_state_needed, + .fields =3D (VMStateField[]) { + VMSTATE_TIMER_PTR(icount_rt_timer, TimersState), + VMSTATE_TIMER_PTR(icount_vm_timer, TimersState), + VMSTATE_END_OF_LIST() + } +}; + /* * This is a subsection for icount migration. */ @@ -644,6 +685,11 @@ static const VMStateDescription icount_vmstate_timers = =3D { VMSTATE_INT64(qemu_icount_bias, TimersState), VMSTATE_INT64(qemu_icount, TimersState), VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription*[]) { + &icount_vmstate_warp_timer, + &icount_vmstate_adjust_timers, + NULL } }; =20 @@ -754,7 +800,7 @@ void configure_icount(QemuOpts *opts, Error **errp) =20 icount_sleep =3D qemu_opt_get_bool(opts, "sleep", true); if (icount_sleep) { - icount_warp_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL_RT, + timers_state.icount_warp_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL= _RT, icount_timer_cb, NULL); } =20 @@ -788,13 +834,14 @@ void configure_icount(QemuOpts *opts, Error **errp) the virtual time trigger catches emulated time passing too fast. Realtime triggers occur even when idle, so use them less frequently than VM triggers. */ - icount_rt_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL_RT, + timers_state.vm_clock_warp_start =3D -1; + timers_state.icount_rt_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL_RT, icount_adjust_rt, NULL); - timer_mod(icount_rt_timer, + timer_mod(timers_state.icount_rt_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL_RT) + 1000); - icount_vm_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, + timers_state.icount_vm_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, icount_adjust_vm, NULL); - timer_mod(icount_vm_timer, + timer_mod(timers_state.icount_vm_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + NANOSECONDS_PER_SECOND / 10); } --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757887612929.4148180688819; Fri, 12 Jan 2018 03:51:27 -0800 (PST) Received: from localhost ([::1]:35305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxrq-00080Y-M0 for importer@patchew.org; Fri, 12 Jan 2018 06:51:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZC-0007rr-2m for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZ7-0005pC-2W for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:10 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:33811) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZ6-0005o9-PE for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:05 -0500 Received: by mail-wr0-x244.google.com with SMTP id 36so5058251wrh.1 for ; Fri, 12 Jan 2018 03:32:04 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=AiIYpC9+gYEeIHWxrtYjt1/UbVT75EBiilTokgZjCOs=; b=Bz9NUWLbMqMeE5iA9av2IoMRabUpmxds79+RC54qluj9CJdFFh0HqyIV6nNUTmk9iM 7hNq4DnRRbKHDueJS9cDJ2jxsJxp6kd17PjKMV5olIlEf/88lYqDlxTVHJFWVYcC50Ag /fpdl+GwdssaZ1tcQ3J52aNMEGjoR9+dcxCeJV+X6wpjBkmTn5/DhCyD9c52qnlG1qAy CMsCH4n2ul+rCXzFUH+Jexhmd+zooTOuv+TSUZCwiv3+MrHv662UNcrY6/ZdlH5esF+6 uMedbyeYf5PMkY4IhwJ1Z6yOP96jZXFJrt41vxZOdE//LXEfAk3zbWFzHnmn179Ehr3a 5VCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=AiIYpC9+gYEeIHWxrtYjt1/UbVT75EBiilTokgZjCOs=; b=bNbhTjgIs8nh+AsRai/uBF7D7IfSMKI/poU9qZ+V5a7vRusBhla5aG9HtnCR6uBb7D A1O+DEWn4Luwnfvu3xUsuj5DAQYDmFU3MLbhLO66VxlKlPEYwZfGZOmHDAR4eaRR+oNY JUCJJWXHnQXEPcMObLAuMyO0U8yXTPqQAD2T27yJG0V5KpBJlhvgrr9IlJ26R5qXQErH CwT3XltYBbUPW7XmcxBNRMCwZoV73W2Cjrxcp91YH0/+UItBprUx/oA+1t2vJ+z/FpWM 8GuygpO3JsPR3vJ1udypGd14GY/ucZhVBSwkfj3B/KjK0xwopgQBnFKiQB5cTpJOe8Xo bLKg== X-Gm-Message-State: AKGB3mJho89azY94cGXNKllJtyqIol12StpFuX94lYh9222cBc89WABz nQz5I9AdAYguLxc8S0p4rkycoM2k X-Google-Smtp-Source: ACJfBovqt55u6HbB9iVk6m8zGEXZ+clXZ84GrWBEuRuKewu+ej/QmulMQAbgCs0rRiBzBPXG0h4B0w== X-Received: by 10.223.176.173 with SMTP id i42mr21183568wra.47.1515756723409; Fri, 12 Jan 2018 03:32:03 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:02 +0100 Message-Id: <1515756676-3860-39-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PULL 38/52] cpus: unify qemu_*_wait_io_event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Except for round-robin TCG, every other accelerator is using more or less the same code around qemu_wait_io_event_common. The exception is HAX, which also has to eat the dummy APC that is queued by qemu_cpu_kick_thread. We can add the SleepEx call to qemu_wait_io_event under "if (!tcg_enabled())", since that is the condition that is used in qemu_cpu_kick_thread, and unify the function for KVM, HAX, HVF and multi-threaded TCG. Single-threaded TCG code can also be simplified since it is only used in the round-robin, sleep-if-all-CPUs-idle case. Signed-off-by: Paolo Bonzini --- cpus.c | 49 +++++++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/cpus.c b/cpus.c index f992537..2cb0af9 100644 --- a/cpus.c +++ b/cpus.c @@ -909,7 +909,8 @@ static void kick_tcg_thread(void *opaque) =20 static void start_tcg_kick_timer(void) { - if (!mttcg_enabled && !tcg_kick_vcpu_timer && CPU_NEXT(first_cpu)) { + assert(!mttcg_enabled); + if (!tcg_kick_vcpu_timer && CPU_NEXT(first_cpu)) { tcg_kick_vcpu_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, kick_tcg_thread, NULL); timer_mod(tcg_kick_vcpu_timer, qemu_tcg_next_kick()); @@ -918,6 +919,7 @@ static void start_tcg_kick_timer(void) =20 static void stop_tcg_kick_timer(void) { + assert(!mttcg_enabled); if (tcg_kick_vcpu_timer) { timer_del(tcg_kick_vcpu_timer); tcg_kick_vcpu_timer =3D NULL; @@ -1137,18 +1139,9 @@ static void qemu_wait_io_event_common(CPUState *cpu) process_queued_cpu_work(cpu); } =20 -static bool qemu_tcg_should_sleep(CPUState *cpu) +static void qemu_tcg_rr_wait_io_event(CPUState *cpu) { - if (mttcg_enabled) { - return cpu_thread_is_idle(cpu); - } else { - return all_cpu_threads_idle(); - } -} - -static void qemu_tcg_wait_io_event(CPUState *cpu) -{ - while (qemu_tcg_should_sleep(cpu)) { + while (all_cpu_threads_idle()) { stop_tcg_kick_timer(); qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex); } @@ -1158,20 +1151,18 @@ static void qemu_tcg_wait_io_event(CPUState *cpu) qemu_wait_io_event_common(cpu); } =20 -static void qemu_kvm_wait_io_event(CPUState *cpu) +static void qemu_wait_io_event(CPUState *cpu) { while (cpu_thread_is_idle(cpu)) { qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex); } =20 - qemu_wait_io_event_common(cpu); -} - -static void qemu_hvf_wait_io_event(CPUState *cpu) -{ - while (cpu_thread_is_idle(cpu)) { - qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex); +#ifdef _WIN32 + /* Eat dummy APC queued by qemu_cpu_kick_thread. */ + if (!tcg_enabled()) { + SleepEx(0, TRUE); } +#endif qemu_wait_io_event_common(cpu); } =20 @@ -1207,7 +1198,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg) cpu_handle_guest_debug(cpu); } } - qemu_kvm_wait_io_event(cpu); + qemu_wait_io_event(cpu); } while (!cpu->unplug || cpu_can_run(cpu)); =20 qemu_kvm_destroy_vcpu(cpu); @@ -1253,7 +1244,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) exit(1); } qemu_mutex_lock_iothread(); - qemu_wait_io_event_common(cpu); + qemu_wait_io_event(cpu); } =20 return NULL; @@ -1470,7 +1461,7 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg) atomic_mb_set(&cpu->exit_request, 0); } =20 - qemu_tcg_wait_io_event(cpu ? cpu : QTAILQ_FIRST(&cpus)); + qemu_tcg_rr_wait_io_event(cpu ? cpu : QTAILQ_FIRST(&cpus)); deal_with_unplugged_cpus(); } =20 @@ -1501,13 +1492,7 @@ static void *qemu_hax_cpu_thread_fn(void *arg) } } =20 - while (cpu_thread_is_idle(cpu)) { - qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex); - } -#ifdef _WIN32 - SleepEx(0, TRUE); -#endif - qemu_wait_io_event_common(cpu); + qemu_wait_io_event(cpu); } return NULL; } @@ -1544,7 +1529,7 @@ static void *qemu_hvf_cpu_thread_fn(void *arg) cpu_handle_guest_debug(cpu); } } - qemu_hvf_wait_io_event(cpu); + qemu_wait_io_event(cpu); } while (!cpu->unplug || cpu_can_run(cpu)); =20 hvf_vcpu_destroy(cpu); @@ -1623,7 +1608,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) } =20 atomic_mb_set(&cpu->exit_request, 0); - qemu_tcg_wait_io_event(cpu); + qemu_wait_io_event(cpu); } =20 return NULL; --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515759123390518.3677931662024; Fri, 12 Jan 2018 04:12:03 -0800 (PST) Received: from localhost ([::1]:36316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZyBm-00024R-Hp for importer@patchew.org; Fri, 12 Jan 2018 07:12:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZC-0007rw-4W for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZ8-0005qO-2z for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:10 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:34931) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZ7-0005pb-TD for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:06 -0500 Received: by mail-wr0-x241.google.com with SMTP id g38so1843348wrd.2 for ; Fri, 12 Jan 2018 03:32:05 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Wn0nyPG/IWRdwKUgHr3FwdOO8lei4vduytZDfGiCjCI=; b=fc0ydkGVH21folKPJqLRDn4DdNAfRq+1KfcIdaaUzIrPF75StUqMhCUWLqAZliR2HG mzAfPDSrMDR0lvck0h26dC7TaDXnelTv6W0bQufOY3H3hOJUwN1K/Jvh87fR6hN4VHx6 KvfykxmBoe8yfFlh9Ju84+4/5XmhJlFUAiT1gCAO+uM7goDqLOPndPpmxEz24J3nFwlk SmgWdKeQNMGa9K2gQWJqS4NXPDzvAWsjp6t1t5781LWbxdNtGGmGbl2Kb2rhALFiInzP a6FKE0dfN+SxXUU6fYQ6vy4vGgX5p+8CIGfFE9pc6eXtkgAPlDlUHcS+UxJOOpCSdDQJ KwrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Wn0nyPG/IWRdwKUgHr3FwdOO8lei4vduytZDfGiCjCI=; b=HHwdUPAgzTEckPc2Uz+wLHpKo/urxCHOChczVSfjgNAqKOV8k/PfryvKqFpKa1BBY/ d7TP0IkeY1tHUC9JXuTGd4AA5WV8JQbIqyklTvsHKFqxBtJvxydTw47IZgontcmco0Iz /uXcwE8aNlvWvAIoi9gyBIQ94PEBtgdYhWopyYb3aMDjgpX9UG6oac3HbMpwEKqQGQak XNobVTCzEQXRcQghOhY/ODQa1wMJ7AMyXqLQoVZQbFmh3R7vtNbQyZG7rJC+KVgzu/F2 zP4twGN+sXNzuD61A9t1iBC+M74d2HDEPhnSa3vkEnBzRxPq2hPCa3Y1UvU30ZrvjqO8 Vx7g== X-Gm-Message-State: AKGB3mL8E2zu+ZSxsmL5m1xT6u9Jh0XhwMF4pO7yM7B6VNJvs35Dka/x 2Y7XrDXYWgHKKrs8xjDSa3Cr2v+U X-Google-Smtp-Source: ACJfBou4oL2FKz8HuNP8YOQP/o58upMsMGXI998YS4tqUOxU+e4sIzy2I4pqfCOy2XoBghv0pKWRcA== X-Received: by 10.223.176.17 with SMTP id f17mr16266328wra.178.1515756724582; Fri, 12 Jan 2018 03:32:04 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:03 +0100 Message-Id: <1515756676-3860-40-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 39/52] irq: fix memory leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linzhecheng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: linzhecheng entry is moved from list but is not freed. Signed-off-by: linzhecheng Message-Id: <20171225024704.19540-1-linzhecheng@huawei.com> Signed-off-by: Paolo Bonzini --- target/i386/kvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 825aea5..4912f4d 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -3470,6 +3470,7 @@ int kvm_arch_release_virq_post(int virq) if (entry->virq =3D=3D virq) { trace_kvm_x86_remove_msi_route(virq); QLIST_REMOVE(entry, list); + g_free(entry); break; } } --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515759550236367.46555132387493; Fri, 12 Jan 2018 04:19:10 -0800 (PST) Received: from localhost ([::1]:36604 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZyIf-0008D7-5D for importer@patchew.org; Fri, 12 Jan 2018 07:19:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZC-0007rt-3k for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZ9-0005rF-70 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:10 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:42801) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZ9-0005qr-02 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:07 -0500 Received: by mail-wr0-x242.google.com with SMTP id e41so4698395wre.9 for ; Fri, 12 Jan 2018 03:32:06 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=RiK3qZBbW+2OFHwPu12KyhpX4+dLD1fHntp4Gc1Ok3Q=; b=oOmGjVS+VNJLnmAfERrjKt18F6pkAD3QMXrgiZPdGrRMmQQ7r+znL8pvPJKDFPXYOh L38qm0ylZZNgTGsuAtv8SoHKYPPZYgih38oX89279VPFELK0cIzt9GhK87KRnm/Eqduo uCyZHNIvgV7QXvR/fVvOUAbodcCG3ITnWpZgomimGlKbGC+wBL1/mdLDWtf53y5/fa1D Kdjy/ru5kK9RugnLfLScIetrlt+4wZFpCaUjZi3CyBxt1bIFOhj1iJ5DPNQKm6Goju1z sOUpNFIcWsFGzTi6uqVJ9lEMHAoCLD9Kxj1lhd1ofUukDqWGR4LZRjOYzcKbv4euqqGX SBOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=RiK3qZBbW+2OFHwPu12KyhpX4+dLD1fHntp4Gc1Ok3Q=; b=Fv+W9iXVtEbKoLwvJXXEkzloLHobBVal6WIXux3IG0dx/zMtqBrpxb5kRkiVDvlaFD rEQTcF5QQfPbxuJpWHSmJ28S5aIeI22F9XsD3S6lmvaU1zYe6qFqKRZiIyl5rLMjmD6g yAEaahFAYOnrz5AJmzHI49Sfz1KJjvZFA8bsHJdoAviMafqRN+97+CAHJL1NbbwVyrvS 9wwPo+OMfvry8JEWR+Ee8LXzwQiLCj/8Ke0bi1VjB3NDbGwLiyzjVlTcZmX38RE8NrCx TFnROoxOO335XGCPRJLjjPlWPjknUnrXWeJEDb5lyGvPhm7GmW+eIb3rpwIa/HWEB3f1 ZzoQ== X-Gm-Message-State: AKGB3mITXxz3BZZW4zp0v7uAweLcYGHpQvWR11bU/Lz88/ArAYIfdw9z EJ4LrN2dRLqtcHXfRWRz7jHUD9QX X-Google-Smtp-Source: ACJfBovyfSD4aFNeWn0mW4MIjABDGRO0uFiqGyWskyHf8u0Gt3bNYiAbPcuh+JfVQxi0WjR6K4ZxXA== X-Received: by 10.223.171.147 with SMTP id s19mr24484061wrc.204.1515756725660; Fri, 12 Jan 2018 03:32:05 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:04 +0100 Message-Id: <1515756676-3860-41-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 40/52] net: Drop unusual use of do { } while (0); X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake For a couple of macros in pcnet.c, we have to provide a new scope to avoid compiler warnings about declarations in the middle of a switch statement that aren't in a sub-scope. But use of 'do { ... } while (0);' merely to provide that new scope is arcane overkill, compared to just using '{ ... }'. Signed-off-by: Eric Blake Reviewed-by: Thomas Huth Message-Id: <20171201232433.25193-2-eblake@redhat.com> Signed-off-by: Paolo Bonzini --- hw/net/pcnet.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c index 39d5d93..606b05c 100644 --- a/hw/net/pcnet.c +++ b/hw/net/pcnet.c @@ -456,32 +456,32 @@ static inline void pcnet_rmd_store(PCNetState *s, str= uct pcnet_RMD *rmd, #define CHECK_RMD(ADDR,RES) do { \ switch (BCR_SWSTYLE(s)) { \ case 0x00: \ - do { \ + { \ uint16_t rda[4]; \ s->phys_mem_read(s->dma_opaque, (ADDR), \ (void *)&rda[0], sizeof(rda), 0); \ (RES) |=3D (rda[2] & 0xf000)!=3D0xf000; \ (RES) |=3D (rda[3] & 0xf000)!=3D0x0000; \ - } while (0); \ + } \ break; \ case 0x01: \ case 0x02: \ - do { \ + { \ uint32_t rda[4]; \ s->phys_mem_read(s->dma_opaque, (ADDR), \ (void *)&rda[0], sizeof(rda), 0); \ (RES) |=3D (rda[1] & 0x0000f000L)!=3D0x0000f000L; \ (RES) |=3D (rda[2] & 0x0000f000L)!=3D0x00000000L; \ - } while (0); \ + } \ break; \ case 0x03: \ - do { \ + { \ uint32_t rda[4]; \ s->phys_mem_read(s->dma_opaque, (ADDR), \ (void *)&rda[0], sizeof(rda), 0); \ (RES) |=3D (rda[0] & 0x0000f000L)!=3D0x00000000L; \ (RES) |=3D (rda[1] & 0x0000f000L)!=3D0x0000f000L; \ - } while (0); \ + } \ break; \ } \ } while (0) @@ -489,22 +489,22 @@ static inline void pcnet_rmd_store(PCNetState *s, str= uct pcnet_RMD *rmd, #define CHECK_TMD(ADDR,RES) do { \ switch (BCR_SWSTYLE(s)) { \ case 0x00: \ - do { \ + { \ uint16_t xda[4]; \ s->phys_mem_read(s->dma_opaque, (ADDR), \ (void *)&xda[0], sizeof(xda), 0); \ (RES) |=3D (xda[2] & 0xf000)!=3D0xf000; \ - } while (0); \ + } \ break; \ case 0x01: \ case 0x02: \ case 0x03: \ - do { \ + { \ uint32_t xda[4]; \ s->phys_mem_read(s->dma_opaque, (ADDR), \ (void *)&xda[0], sizeof(xda), 0); \ (RES) |=3D (xda[1] & 0x0000f000L)!=3D0x0000f000L; \ - } while (0); \ + } \ break; \ } \ } while (0) --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757713152953.6467187867709; Fri, 12 Jan 2018 03:48:33 -0800 (PST) Received: from localhost ([::1]:35285 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxp2-00050R-9j for importer@patchew.org; Fri, 12 Jan 2018 06:48:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZC-0007ry-5E for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZA-0005sQ-GO for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:10 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:33013) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZA-0005rp-6j for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:08 -0500 Received: by mail-wr0-x244.google.com with SMTP id p6so5053842wrd.0 for ; Fri, 12 Jan 2018 03:32:08 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7FZQSpHu7gpQS6jYSje83NC3gFPycX/6oFCr51PyUKs=; b=BW8ZV3z/AQVnm7agQm57fcUDvW1m0NVjD7L2ZlUoHb1e9Nys4rTv8IM7nv6FKcTVOU hPHr2bXxOGEklo1vOnuU3nqQpcNN2QgnDtnTCm3oOzDssLontADXHRDcWZVn1rWyqv/C vYiwOxz/Hb0egk+9Mhbbub1QxvQ0F1AyGztlPMs6RyaKCi/IUjORRslhCb01lkHpgsg/ jiGYDK9hTrXdY5A8kwVDaKvakQGmvA+8S4SE1f/85Os4bqcV+kJrQer+waymEcPvJ1Sj 9ErhCJpcth0ICLkqQr3642POfY2Q88zhvBzcDlNeKk0jcildIYY6Mjm/kcnSXT0sAsDe WC2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=7FZQSpHu7gpQS6jYSje83NC3gFPycX/6oFCr51PyUKs=; b=T3DiWu7Cxmg4Y1fcZMrCBPIW6ZYKbzDsceRCliPoi05PgAIATPgRPbu6VIL3H4BG4m sCZp5OfU7q4hwgmT8MJKj+fXPTz7TqEod9HDUj6gzsXD6H/QUwwANlqUt0Nb+OCYEn/4 VN/mJesVMdOidGLIc797AsbMRnDwPNKvq3qaJFEjvpR/1pfZyyhi9115J+YyumyD9QFj uiy4FP0NKpID2OgW+zrl22sbciLVvAXybqs1nv0+JjB/7zDxaR9w2sPNe/nsORXQgZwy ZkS52tjiH3eb+NkpRGnxL/F0/vs5Q1MBXOV3MP/u8yoM4WQapxUE87jkdN+FtZi/+GTj wH6Q== X-Gm-Message-State: AKGB3mI/6qA8C11kcNRp6an0tQVVzw/Zx8F5BrVW2PWnVlfLHSvnna2+ DN6KoUU6w0aTRfikSyiwwccYTiRl X-Google-Smtp-Source: ACJfBovQryZklzdxxF8Xe8+cZKb/LBHX6NgZP4+hsQn1JZQ7H9kkmbH646ip5IdMXJRXyxkk7645Mw== X-Received: by 10.223.163.66 with SMTP id d2mr21957120wrb.18.1515756726892; Fri, 12 Jan 2018 03:32:06 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:05 +0100 Message-Id: <1515756676-3860-42-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PULL 41/52] mips: Tweak location of ';' in macros X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Eric Blake It is more typical to provide the ';' by the caller of a macro than to embed it in the macro itself; this is because syntax highlight engines can get confused if a macro is called without a semicolon before the closing '}'. Signed-off-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20171201232433.25193-3-eblake@redhat.com> Signed-off-by: Paolo Bonzini --- target/mips/msa_helper.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/target/mips/msa_helper.c b/target/mips/msa_helper.c index f167a42..8fb7a36 100644 --- a/target/mips/msa_helper.c +++ b/target/mips/msa_helper.c @@ -682,13 +682,13 @@ static inline int64_t msa_mod_u_df(uint32_t df, int64= _t arg1, int64_t arg2) do { \ e =3D SIGNED_EVEN(a, df); \ o =3D SIGNED_ODD(a, df); \ - } while (0); + } while (0) =20 #define UNSIGNED_EXTRACT(e, o, a, df) \ do { \ e =3D UNSIGNED_EVEN(a, df); \ o =3D UNSIGNED_ODD(a, df); \ - } while (0); + } while (0) =20 static inline int64_t msa_dotp_s_df(uint32_t df, int64_t arg1, int64_t arg= 2) { @@ -1120,9 +1120,11 @@ void helper_msa_splat_df(CPUMIPSState *env, uint32_t= df, uint32_t wd, #define MSA_LOOP_COND_D MSA_LOOP_COND(DF_DOUBLE) =20 #define MSA_LOOP(DF) \ + do { \ for (i =3D 0; i < (MSA_LOOP_COND_ ## DF) ; i++) { \ - MSA_DO_ ## DF \ - } + MSA_DO_ ## DF; \ + } \ + } while (0) =20 #define MSA_FN_DF(FUNC) \ void helper_msa_##FUNC(CPUMIPSState *env, uint32_t df, uint32_t wd, \ @@ -1135,17 +1137,17 @@ void helper_msa_##FUNC(CPUMIPSState *env, uint32_t = df, uint32_t wd, \ uint32_t i; \ switch (df) { \ case DF_BYTE: \ - MSA_LOOP_B \ + MSA_LOOP_B; \ break; \ case DF_HALF: \ - MSA_LOOP_H \ + MSA_LOOP_H; \ break; \ case DF_WORD: \ - MSA_LOOP_W \ + MSA_LOOP_W; \ break; \ case DF_DOUBLE: \ - MSA_LOOP_D \ - break; \ + MSA_LOOP_D; \ + break; \ default: \ assert(0); \ } \ @@ -1168,7 +1170,7 @@ void helper_msa_##FUNC(CPUMIPSState *env, uint32_t df= , uint32_t wd, \ do { \ R##DF(pwx, i) =3D pwt->DF[2*i]; \ L##DF(pwx, i) =3D pws->DF[2*i]; \ - } while (0); + } while (0) MSA_FN_DF(pckev_df) #undef MSA_DO =20 @@ -1176,7 +1178,7 @@ MSA_FN_DF(pckev_df) do { \ R##DF(pwx, i) =3D pwt->DF[2*i+1]; \ L##DF(pwx, i) =3D pws->DF[2*i+1]; \ - } while (0); + } while (0) MSA_FN_DF(pckod_df) #undef MSA_DO =20 @@ -1184,7 +1186,7 @@ MSA_FN_DF(pckod_df) do { \ pwx->DF[2*i] =3D L##DF(pwt, i); \ pwx->DF[2*i+1] =3D L##DF(pws, i); \ - } while (0); + } while (0) MSA_FN_DF(ilvl_df) #undef MSA_DO =20 @@ -1192,7 +1194,7 @@ MSA_FN_DF(ilvl_df) do { \ pwx->DF[2*i] =3D R##DF(pwt, i); \ pwx->DF[2*i+1] =3D R##DF(pws, i); \ - } while (0); + } while (0) MSA_FN_DF(ilvr_df) #undef MSA_DO =20 @@ -1200,7 +1202,7 @@ MSA_FN_DF(ilvr_df) do { \ pwx->DF[2*i] =3D pwt->DF[2*i]; \ pwx->DF[2*i+1] =3D pws->DF[2*i]; \ - } while (0); + } while (0) MSA_FN_DF(ilvev_df) #undef MSA_DO =20 @@ -1208,7 +1210,7 @@ MSA_FN_DF(ilvev_df) do { \ pwx->DF[2*i] =3D pwt->DF[2*i+1]; \ pwx->DF[2*i+1] =3D pws->DF[2*i+1]; \ - } while (0); + } while (0) MSA_FN_DF(ilvod_df) #undef MSA_DO #undef MSA_LOOP_COND @@ -1222,7 +1224,7 @@ MSA_FN_DF(ilvod_df) uint32_t k =3D (pwd->DF[i] & 0x3f) % (2 * n); = \ pwx->DF[i] =3D = \ (pwd->DF[i] & 0xc0) ? 0 : k < n ? pwt->DF[k] : pws->DF[k - n];= \ - } while (0); + } while (0) MSA_FN_DF(vshf_df) #undef MSA_DO #undef MSA_LOOP_COND --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515758855218862.6299012964729; Fri, 12 Jan 2018 04:07:35 -0800 (PST) Received: from localhost ([::1]:36073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZy7S-0005E5-Ec for importer@patchew.org; Fri, 12 Jan 2018 07:07:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41992) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZC-0007sF-DW for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZB-0005tf-IO for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:10 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:44058) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZB-0005sq-CD for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:09 -0500 Received: by mail-wr0-x241.google.com with SMTP id w50so5008340wrc.11 for ; Fri, 12 Jan 2018 03:32:09 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XpGusnd7R7MpGFIgZ/wEWOlLdX5OgpIFI/U/fl4T5P0=; b=D/s6rzPe6vbj8HooxT0tfkAYwBDnQKJEls4gira1nJjIAVIoGOifKALk9y0dhwJJxZ N4qugdlMlkfiCt9i7amFBiS6mIlNZX5R6w5etcJtCrOtR0q8qhLkTriwXRDu1xZAnMbK t0QTwuCwXj/AW2ZeImDNznqy+Yeh/mvyyr6ANDfQkcWLAyNINRfV9SXnMBGTIvWiU8fN 5dEHvQo1H+FSE5vdFZLb5CGadWHZ+KKn5dLEAWO8B5ujQ4TrAvYR8iHUZczfDdirSefP QGTU8su6vs5DHPwGHvYwiAByNax2z+XhwkigRtFY9906I63SCE1Y/tJMVJYzt1bGUiBh RY5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=XpGusnd7R7MpGFIgZ/wEWOlLdX5OgpIFI/U/fl4T5P0=; b=Zj35+kS3QeLJcvuZaE1u+euDbVns9IFYCDU51XnGOZ4TGj7zgLPFqOH/XXfQ03DA9H 39avWnn708v1GLNDz0AjW5YjTlXQ4aK+U1NARlWjONknAsuaC8CwuC4Zt2kWe0DFBZ3D 6FsYhi7mD+6X8MA5wC1xqm3Yf8i6LqK0mWr2QWE3T4w+eVbp7Q3vHNefXqhsYXok9DdI goLmvALNmVPHwyx32JZgkzIDxGG+NxzCmKV0WNzrz24m+k5wiI7tOhrVvZ+s0IF678O1 HDXC6uJgWX4smsK2kxP6cv1fzT8fXjHfF6t2SdbuU22yzswcbtPOL43bDe0vFVf7FnAK sg3g== X-Gm-Message-State: AKwxytclsPYOzevzz8xrU106yqB/bvrlPGyPZY3TKrWCpbuhHeukAk60 6xy9ecXsRRhos+u3OZGJD3x/LP6v X-Google-Smtp-Source: ACJfBoszOVgOmmAQifHFmYccA0ZDnW6S7nxaUulPSIwCHmRDmUKMPZlmE6RYMc5ZJOO2H4wHf1HTag== X-Received: by 10.223.134.58 with SMTP id 55mr4295242wrv.262.1515756728068; Fri, 12 Jan 2018 03:32:08 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:06 +0100 Message-Id: <1515756676-3860-43-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 42/52] chardev: Use goto/label instead of do/break/while(0) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Eric Blake Use of a do/while(0) control flow in order to permit an early break is an unusual paradigm, and triggers a false positive with a planned future syntax check against 'while (0);'. Rewrite the code to use a goto instead. This patch temporarily keeps an extra level of indentation to highlight the change; the next patch cleans it up. Signed-off-by: Eric Blake Message-Id: <20171201232433.25193-4-eblake@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- chardev/char-serial.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/chardev/char-serial.c b/chardev/char-serial.c index 2f8f838..10162f9 100644 --- a/chardev/char-serial.c +++ b/chardev/char-serial.c @@ -64,9 +64,14 @@ static void tty_serial_init(int fd, int speed, #endif tcgetattr(fd, &tty); =20 -#define check_speed(val) if (speed <=3D val) { spd =3D B##val; break; } +#define check_speed(val) \ + if (speed <=3D val) { \ + spd =3D B##val; \ + goto done; \ + } + speed =3D speed * 10 / 11; - do { + { check_speed(50); check_speed(75); check_speed(110); @@ -125,8 +130,10 @@ static void tty_serial_init(int fd, int speed, check_speed(4000000); #endif spd =3D B115200; - } while (0); + } =20 +#undef check_speed + done: cfsetispeed(&tty, spd); cfsetospeed(&tty, spd); =20 --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515757907259267.14343770804646; Fri, 12 Jan 2018 03:51:47 -0800 (PST) Received: from localhost ([::1]:35306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxs8-0008HE-JM for importer@patchew.org; Fri, 12 Jan 2018 06:51:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZD-0007sj-AV for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZC-0005ux-HY for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:11 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:34932) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZC-0005tl-Az for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:10 -0500 Received: by mail-wr0-x242.google.com with SMTP id g38so1843549wrd.2 for ; Fri, 12 Jan 2018 03:32:10 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kXhOCEIQ7g8vCzHPIZYLXGSy5ed/YtVfytN4lUOHWN0=; b=R1bfwZ2Mgkz9fM3ZozKNaAVtYU0MBzZd6UEa9s3/B12A1ROXudn8B9HT8uGrII0PjM LHJOXANrbFyjS7CyeT2r1kTUOlTkJUenxu+AjnMT6onqcdaOIRDYam1ym3xTQpnkXDjR WTD1zpJ0B2nVIDOauDfS/3mA0pxrrYywB7gEJ5mtT1ZM7LNKGcfUy+Fm6x6cllPSJ7yo GbK2/b0kEgnupGW7nFZcX0/YUSoL3eJD5niQ5mZTb8MPCKFESgMvLcIx+8GFHwaAoL2s zcjv0lua5oYUl5Xv7RgChB3WoLCfBaf1xcQhcR31MsHZOs95GeRTD2FPmYvuum7JJplI zNmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=kXhOCEIQ7g8vCzHPIZYLXGSy5ed/YtVfytN4lUOHWN0=; b=GlTr1x2hY9oHt3yRqXc4ATLNN15KRtoJR8aSqLkqatfNQlTNfc9pkequF+FX+8aZV+ 0zaDTnQgEtJotLk2jQBDNQMeNbQJoPM+ACBR8XzlA0FidGRo0zQzExw8WnacnGN/MT0y +RBfH2AEuT/tmpA/Yqj6v7f6aN+I5qoT/PTDOLjNHqFm3UhghsQH2+ZwAj+lsacxuLoF tgfyCKh8SgIhehunD0rAJOSnMu5B6VuVMHuZ6rBnHrv4GTYTdMkuveEYZZ5JA2uTdet4 vLnpxUEpfyU7bPV/knhhxzZOllwCaQ/TF8oRZW+iDcvdvgvn8lpvzljb8XgItyPJVst5 vNbQ== X-Gm-Message-State: AKwxytf3ArWwjXQaZsr/KP91z2t0Zmaow8nHVxq3zjav9YXRAz2Igc6q CXDkrTmO1ztI37trHmf/JdtJ3pVq X-Google-Smtp-Source: ACJfBov7CQEfHNPj8+pEnJukfG9zK9mP+Xh0KUCEFiLosGPKeX3nYoQ2q7PQrZXrjQWR5rRVFa8HGQ== X-Received: by 10.223.177.207 with SMTP id r15mr921327wra.32.1515756729014; Fri, 12 Jan 2018 03:32:09 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:07 +0100 Message-Id: <1515756676-3860-44-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 43/52] chardev: Clean up previous patch indentation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Eric Blake The previous patch left in an extra scope layer for ease of review; time to remove it. No semantic change. Signed-off-by: Eric Blake Message-Id: <20171201232433.25193-5-eblake@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- chardev/char-serial.c | 66 +++++++++++++++++++++++++----------------------= ---- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/chardev/char-serial.c b/chardev/char-serial.c index 10162f9..93392c5 100644 --- a/chardev/char-serial.c +++ b/chardev/char-serial.c @@ -71,66 +71,64 @@ static void tty_serial_init(int fd, int speed, } =20 speed =3D speed * 10 / 11; - { - check_speed(50); - check_speed(75); - check_speed(110); - check_speed(134); - check_speed(150); - check_speed(200); - check_speed(300); - check_speed(600); - check_speed(1200); - check_speed(1800); - check_speed(2400); - check_speed(4800); - check_speed(9600); - check_speed(19200); - check_speed(38400); - /* Non-Posix values follow. They may be unsupported on some system= s. */ - check_speed(57600); - check_speed(115200); + check_speed(50); + check_speed(75); + check_speed(110); + check_speed(134); + check_speed(150); + check_speed(200); + check_speed(300); + check_speed(600); + check_speed(1200); + check_speed(1800); + check_speed(2400); + check_speed(4800); + check_speed(9600); + check_speed(19200); + check_speed(38400); + /* Non-Posix values follow. They may be unsupported on some systems. */ + check_speed(57600); + check_speed(115200); #ifdef B230400 - check_speed(230400); + check_speed(230400); #endif #ifdef B460800 - check_speed(460800); + check_speed(460800); #endif #ifdef B500000 - check_speed(500000); + check_speed(500000); #endif #ifdef B576000 - check_speed(576000); + check_speed(576000); #endif #ifdef B921600 - check_speed(921600); + check_speed(921600); #endif #ifdef B1000000 - check_speed(1000000); + check_speed(1000000); #endif #ifdef B1152000 - check_speed(1152000); + check_speed(1152000); #endif #ifdef B1500000 - check_speed(1500000); + check_speed(1500000); #endif #ifdef B2000000 - check_speed(2000000); + check_speed(2000000); #endif #ifdef B2500000 - check_speed(2500000); + check_speed(2500000); #endif #ifdef B3000000 - check_speed(3000000); + check_speed(3000000); #endif #ifdef B3500000 - check_speed(3500000); + check_speed(3500000); #endif #ifdef B4000000 - check_speed(4000000); + check_speed(4000000); #endif - spd =3D B115200; - } + spd =3D B115200; =20 #undef check_speed done: --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15157589933741003.0168513851507; Fri, 12 Jan 2018 04:09:53 -0800 (PST) Received: from localhost ([::1]:36247 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZy9b-0007V1-JJ for importer@patchew.org; Fri, 12 Jan 2018 07:09:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZE-0007uD-Tb for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZD-0005w2-Lp for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:12 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:33809) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZD-0005vD-FV for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:11 -0500 Received: by mail-wr0-x241.google.com with SMTP id 36so5058561wrh.1 for ; Fri, 12 Jan 2018 03:32:11 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=T67IVZkHvup8WLIuFuILxNiMmQ9HflxMCrOAoRB/8xI=; b=UqIE+5S/39U4wjsJWi9MvKaK+qs0HtZpMaM6ViEkjg415XC9yhJ5dsDanq25r68Tp0 EGY6qo78pREQdSPvdKPogmq0h62aRRMoeNYOgogqo8pR+a3OqhB8NfUXZAXVmIJhhbJx eRto3SWS/pXWxkq4bO+uTmILTEsfCI4LDJZP3z6cdlyWutBgHu/C+QVySHR15kspf74g mP/1kvPG/OQsQPzVK+wpUJkZLJNK+vH95SfBmZxd4UDl7KUeMRinBM3bQksEP4BYKdGd g9BiT3n5S7KUO52/CN5/f7PLWoBlgySh9QamuePSApT5QI4WUBUGXog4OcwmA/mThuR8 QUdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=T67IVZkHvup8WLIuFuILxNiMmQ9HflxMCrOAoRB/8xI=; b=VOS2xQKa+562zxFjwcpI52KMw1s2D6YE2lXrfnhACcOQX/CDUndmCJHtRbWCQHU5BW wHJDiVqWOoiSi1ooVYCAXow9z8q1Ane+M89UGoDP+ppwFfgs6c5XjYBBKsV6jTGqtgvu 86Uusqkl7mZ0lXHiTFMqyva0DjonAxWAMoYf/J6+/AA2b3luMQVBLmB8uYoY+Ii/kRyW /rV8LyYhodUXIsG1Pttj9c7ltlB6Qv/PtGIfeHH8CC9zHKJm/nOraInwizurtmazyNZr lsbr3PKKFyo+M+Y5sQgMEjrF0pf4lYtRYs22LgsKOOUPdmcz6dL7nY03SS9qv7Eq73Ur DiCA== X-Gm-Message-State: AKwxytctkgfQ6GZDYUVKed/LoLgOuL9YQSYIKDOPTvftTyyRp0QDDC4c qOb3rGhrCEL3ShWnRfZ6dTTAPNVQ X-Google-Smtp-Source: ACJfBosAt9x2oHRvOh4uWHH1x/cXODYwr7ZiUd2czDOmH8zJw7aYCN0T7O+2mNIedWjTy+UAiDz/PA== X-Received: by 10.223.172.6 with SMTP id v6mr8183690wrc.269.1515756730131; Fri, 12 Jan 2018 03:32:10 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:08 +0100 Message-Id: <1515756676-3860-45-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 44/52] tests: Avoid 'do/while(false); ' in vhost-user-bridge X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Use of a do/while(0) loop as a way to allow break statements in the middle of execute-once code is unusual. More typical is the use of goto for early exits, with a label at the end of the execute-once code, rather than nesting code in a scope; however, the comment at the end of the existing code makes this alternative a bit unpractical. So, to avoid false positives from a future syntax check about 'while (false);', and to keep the loop form (in case someone ever does add DONTWAIT support, where they can just as easily manipulate the initial loop condition or add an if around the final 'break'), I opted to use the form of a while(1) loop (the break as an early exit is more idiomatic there), coupled with a final break preserving the original comment. Signed-off-by: Eric Blake Message-Id: <20171201232433.25193-6-eblake@redhat.com> Signed-off-by: Paolo Bonzini --- tests/vhost-user-bridge.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c index d820033..e0605a5 100644 --- a/tests/vhost-user-bridge.c +++ b/tests/vhost-user-bridge.c @@ -283,7 +283,7 @@ vubr_backend_recv_cb(int sock, void *ctx) return; } =20 - do { + while (1) { struct iovec *sg; ssize_t ret, total =3D 0; unsigned int num; @@ -343,7 +343,9 @@ vubr_backend_recv_cb(int sock, void *ctx) =20 free(elem); elem =3D NULL; - } while (false); /* could loop if DONTWAIT worked? */ + + break; /* could loop if DONTWAIT worked? */ + } =20 if (mhdr_cnt) { mhdr.num_buffers =3D i; --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515758080976842.8153238827391; Fri, 12 Jan 2018 03:54:40 -0800 (PST) Received: from localhost ([::1]:35324 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxux-0002TX-VI for importer@patchew.org; Fri, 12 Jan 2018 06:54:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZH-0007wY-ND for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZF-0005yL-D3 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:15 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:37007) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZF-0005x4-1e for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:13 -0500 Received: by mail-wr0-x244.google.com with SMTP id f8so5037836wre.4 for ; Fri, 12 Jan 2018 03:32:12 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ParUKnpmOv9Q1UAM/B8Q6+EPSUg4T85+y74Kzu4YZRM=; b=fMQMKONW4UyRv5azcHFkN24hxl95i6zpN+wm1QPaupe1i6mYIcsKtfk4KSheoTH7/y hH/tuMbECR1+lGYH/OpIbushWxoKcgIdVZnG99IGES6CYLDRAusDfxPOXcbqmVW3ygIc YXjYwPoI2CLcFGd90e+9BMNXDp1NgdMphCk+2smDmMfUrgKLtzjpZZ5aYmSCXQ+WSWZf WediJJs8SQ6S7f3RN65rdtMjTXqaOg/dHrw9p/ZaArWtSzq3QZN3YlpR781AZFPruJzj AEuqwc9yZ3fTsWYkKFEtQ4XmnIHdoSNsuQNOlMpJyYi5An5HIz7Ty9QsNJeNv5MjuGzl 8lSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ParUKnpmOv9Q1UAM/B8Q6+EPSUg4T85+y74Kzu4YZRM=; b=bKtrXfqZZ5F19/Q9N56N1xxDiayqeYTEn7MSntexIdO6yJ7fM+ZU8uHgJccAUKAlzT OM5oH63BDyrKk58o63tuSm3yuJ5Dg1F1uyUtSct0RSqclhhvz4HVmQL9ACsAu3Ph5OAr igpKgYabdSZjsyqE5MZbLkhW064WAQCsZ3+/FK4OdtKZsSqpvANfETAxGoHbpY9FTVGf cLC539mpChLFNrBY+VgYwoxaEeYDSOqw14nAdHBdUbiiTbPEuQdAIAidfwXwTDa/2LcO usLcVdWUOGNNG5qQ/LHbz9Q4P7h/lqxGBIAVV6ZKlA9jg8P/sr+D9UCOklcJgKMtGztJ JeCA== X-Gm-Message-State: AKwxytdWqCQtln7YVO27DWvywWEvcWtNiegKsBnDMqcr6XGsgyF8+TQ8 rheRJZp55IRBRrmZZlOYHHKAFipz X-Google-Smtp-Source: ACJfBouAbnLDqKz9KglqwpX6WxzfdWUQ3vM8nLgBkrjp9/5yELDFI1fluNtsK4sBkI7Y/5XmNkSRXA== X-Received: by 10.223.130.196 with SMTP id 62mr10649274wrc.145.1515756731410; Fri, 12 Jan 2018 03:32:11 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:09 +0100 Message-Id: <1515756676-3860-46-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PULL 45/52] maint: Fix macros with broken 'do/while(0); ' usage X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake The point of writing a macro embedded in a 'do { ... } while (0)' loop (particularly if the macro has multiple statements or would otherwise end with an 'if' statement) is so that the macro can be used as a drop-in statement with the caller supplying the trailing ';'. Although our coding style frowns on brace-less 'if': if (cond) statement; else something else; that is the classic case where failure to use do/while(0) wrapping would cause the 'else' to pair with any embedded 'if' in the macro rather than the intended outer 'if'. But conversely, if the macro includes an embedded ';', then the same brace-less coding style would now have two statements, making the 'else' a syntax error rather than pairing with the outer 'if'. Thus, even though our coding style with required braces is not impacted, ending a macro with ';' makes our code harder to port to projects that use brace-less styles. The change should have no semantic impact. I was not able to fully compile-test all of the changes (as some of them are examples of the ugly bit-rotting debug print statements that are completely elided by default, and I didn't want to recompile with the necessary -D witnesses - cleaning those up is left as a bite-sized task for another day); I did, however, audit that for all files touched, all callers of the changed macros DID supply a trailing ';' at the callsite, and did not appear to be used as part of a brace-less conditional. Found mechanically via: $ git grep -B1 'while (0);' | grep -A1 \\\\ Signed-off-by: Eric Blake Acked-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Acked-by: Dr. David Alan Gilbert Message-Id: <20171201232433.25193-7-eblake@redhat.com> Reviewed-by: Juan Quintela Signed-off-by: Paolo Bonzini --- audio/paaudio.c | 4 ++-- hw/adc/stm32f2xx_adc.c | 2 +- hw/block/m25p80.c | 2 +- hw/char/cadence_uart.c | 2 +- hw/char/stm32f2xx_usart.c | 2 +- hw/display/cg3.c | 2 +- hw/display/dpcd.c | 2 +- hw/display/xlnx_dp.c | 2 +- hw/dma/pl330.c | 2 +- hw/dma/xlnx-zynq-devcfg.c | 2 +- hw/dma/xlnx_dpdma.c | 2 +- hw/i2c/i2c-ddc.c | 2 +- hw/misc/auxbus.c | 2 +- hw/misc/macio/mac_dbdma.c | 4 ++-- hw/misc/mmio_interface.c | 2 +- hw/misc/stm32f2xx_syscfg.c | 2 +- hw/misc/zynq_slcr.c | 2 +- hw/net/cadence_gem.c | 2 +- hw/ssi/mss-spi.c | 2 +- hw/ssi/stm32f2xx_spi.c | 2 +- hw/ssi/xilinx_spi.c | 2 +- hw/ssi/xilinx_spips.c | 2 +- hw/timer/a9gtimer.c | 2 +- hw/timer/cadence_ttc.c | 2 +- hw/timer/mss-timer.c | 2 +- hw/timer/stm32f2xx_timer.c | 2 +- hw/tpm/tpm_passthrough.c | 2 +- hw/tpm/tpm_tis.c | 2 +- migration/rdma.c | 2 +- target/arm/translate-a64.c | 2 +- target/s390x/kvm.c | 2 +- tests/acpi-utils.h | 8 ++++---- tests/tcg/test-mmap.c | 2 +- ui/sdl_zoom_template.h | 8 ++++---- 34 files changed, 42 insertions(+), 42 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 65beb6f..2a35e6f 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -89,7 +89,7 @@ static inline int PA_STREAM_IS_GOOD(pa_stream_state_t x) } \ goto label; \ } \ - } while (0); + } while (0) =20 #define CHECK_DEAD_GOTO(c, stream, rerror, label) \ do { \ @@ -107,7 +107,7 @@ static inline int PA_STREAM_IS_GOOD(pa_stream_state_t x) } \ goto label; \ } \ - } while (0); + } while (0) =20 static int qpa_simple_read (PAVoiceIn *p, void *data, size_t length, int *= rerror) { diff --git a/hw/adc/stm32f2xx_adc.c b/hw/adc/stm32f2xx_adc.c index 90fe9de..13f31ad 100644 --- a/hw/adc/stm32f2xx_adc.c +++ b/hw/adc/stm32f2xx_adc.c @@ -37,7 +37,7 @@ if (STM_ADC_ERR_DEBUG >=3D lvl) { \ qemu_log("%s: " fmt, __func__, ## args); \ } \ -} while (0); +} while (0) =20 #define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args) =20 diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index ea14216..b49c8e9 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -40,7 +40,7 @@ fprintf(stderr, ": %s: ", __func__); \ fprintf(stderr, ## __VA_ARGS__); \ } \ -} while (0); +} while (0) =20 /* Fields for FlashPartInfo->flags */ =20 diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 6143494..fbdbd46 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -33,7 +33,7 @@ #define DB_PRINT(...) do { \ fprintf(stderr, ": %s: ", __func__); \ fprintf(stderr, ## __VA_ARGS__); \ - } while (0); + } while (0) #else #define DB_PRINT(...) #endif diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c index 268e435..07b462d 100644 --- a/hw/char/stm32f2xx_usart.c +++ b/hw/char/stm32f2xx_usart.c @@ -34,7 +34,7 @@ if (STM_USART_ERR_DEBUG >=3D lvl) { \ qemu_log("%s: " fmt, __func__, ## args); \ } \ -} while (0); +} while (0) =20 #define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args) =20 diff --git a/hw/display/cg3.c b/hw/display/cg3.c index e069c44..cafd9f4 100644 --- a/hw/display/cg3.c +++ b/hw/display/cg3.c @@ -63,7 +63,7 @@ if (DEBUG_CG3) { \ printf("CG3: " fmt , ## __VA_ARGS__); \ } \ -} while (0); +} while (0) =20 #define TYPE_CG3 "cgthree" #define CG3(obj) OBJECT_CHECK(CG3State, (obj), TYPE_CG3) diff --git a/hw/display/dpcd.c b/hw/display/dpcd.c index ce92ff6..943002b 100644 --- a/hw/display/dpcd.c +++ b/hw/display/dpcd.c @@ -39,7 +39,7 @@ if (DEBUG_DPCD) { = \ qemu_log("dpcd: " fmt, ## __VA_ARGS__); = \ } = \ -} while (0); +} while (0) =20 #define DPCD_READABLE_AREA 0x600 =20 diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c index 561f828..ead4e1a 100644 --- a/hw/display/xlnx_dp.c +++ b/hw/display/xlnx_dp.c @@ -34,7 +34,7 @@ if (DEBUG_DP) { = \ qemu_log("xlnx_dp: " fmt , ## __VA_ARGS__); = \ } = \ -} while (0); +} while (0) =20 /* * Register offset for DP. diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c index 32cf839..d071049 100644 --- a/hw/dma/pl330.c +++ b/hw/dma/pl330.c @@ -29,7 +29,7 @@ if (PL330_ERR_DEBUG >=3D lvl) {\ fprintf(stderr, "PL330: %s:" fmt, __func__, ## args);\ } \ -} while (0); +} while (0) =20 #define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args) =20 diff --git a/hw/dma/xlnx-zynq-devcfg.c b/hw/dma/xlnx-zynq-devcfg.c index 3b10523..12bb2e3 100644 --- a/hw/dma/xlnx-zynq-devcfg.c +++ b/hw/dma/xlnx-zynq-devcfg.c @@ -43,7 +43,7 @@ if (XLNX_ZYNQ_DEVCFG_ERR_DEBUG) { \ qemu_log("%s: " fmt, __func__, ## args); \ } \ -} while (0); +} while (0) =20 REG32(CTRL, 0x00) FIELD(CTRL, FORCE_RST, 31, 1) /* Not supported, wr ignor= ed */ diff --git a/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c index 8ceb21d..077c7da 100644 --- a/hw/dma/xlnx_dpdma.c +++ b/hw/dma/xlnx_dpdma.c @@ -34,7 +34,7 @@ if (DEBUG_DPDMA) { = \ qemu_log("xlnx_dpdma: " fmt , ## __VA_ARGS__); = \ } = \ -} while (0); +} while (0) =20 /* * Registers offset for DPDMA. diff --git a/hw/i2c/i2c-ddc.c b/hw/i2c/i2c-ddc.c index 6b92e95..199dac9 100644 --- a/hw/i2c/i2c-ddc.c +++ b/hw/i2c/i2c-ddc.c @@ -30,7 +30,7 @@ if (DEBUG_I2CDDC) { = \ qemu_log("i2c-ddc: " fmt , ## __VA_ARGS__); = \ } = \ -} while (0); +} while (0) =20 /* Structure defining a monitor's characteristics in a * readable format: this should be passed to build_edid_blob() diff --git a/hw/misc/auxbus.c b/hw/misc/auxbus.c index 1182745..b4cacd6 100644 --- a/hw/misc/auxbus.c +++ b/hw/misc/auxbus.c @@ -40,7 +40,7 @@ if (DEBUG_AUX) { = \ qemu_log("aux: " fmt , ## __VA_ARGS__); = \ } = \ -} while (0); +} while (0) =20 #define TYPE_AUXTOI2C "aux-to-i2c-bridge" #define AUXTOI2C(obj) OBJECT_CHECK(AUXTOI2CState, (obj), TYPE_AUXTOI2C) diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c index 0eddf2e..1b2a69b 100644 --- a/hw/misc/macio/mac_dbdma.c +++ b/hw/misc/macio/mac_dbdma.c @@ -52,7 +52,7 @@ if (DEBUG_DBDMA) { \ printf("DBDMA: " fmt , ## __VA_ARGS__); \ } \ -} while (0); +} while (0) =20 #define DBDMA_DPRINTFCH(ch, fmt, ...) do { \ if (DEBUG_DBDMA) { \ @@ -60,7 +60,7 @@ printf("DBDMA[%02x]: " fmt , (ch)->channel, ## __VA_ARGS__); \ } \ } \ -} while (0); +} while (0) =20 /* */ diff --git a/hw/misc/mmio_interface.c b/hw/misc/mmio_interface.c index 894e980..3b0e203 100644 --- a/hw/misc/mmio_interface.c +++ b/hw/misc/mmio_interface.c @@ -39,7 +39,7 @@ static uint64_t mmio_interface_counter; if (DEBUG_MMIO_INTERFACE) { = \ qemu_log("mmio_interface: 0x%" PRIX64 ": " fmt, s->id, ## __VA_ARG= S__);\ } = \ -} while (0); +} while (0) =20 static void mmio_interface_init(Object *obj) { diff --git a/hw/misc/stm32f2xx_syscfg.c b/hw/misc/stm32f2xx_syscfg.c index 7c45833..7f10195 100644 --- a/hw/misc/stm32f2xx_syscfg.c +++ b/hw/misc/stm32f2xx_syscfg.c @@ -34,7 +34,7 @@ if (STM_SYSCFG_ERR_DEBUG >=3D lvl) { \ qemu_log("%s: " fmt, __func__, ## args); \ } \ -} while (0); +} while (0) =20 #define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args) =20 diff --git a/hw/misc/zynq_slcr.c b/hw/misc/zynq_slcr.c index 44304d4..d6bdd02 100644 --- a/hw/misc/zynq_slcr.c +++ b/hw/misc/zynq_slcr.c @@ -30,7 +30,7 @@ fprintf(stderr, ": %s: ", __func__); \ fprintf(stderr, ## __VA_ARGS__); \ } \ - } while (0); + } while (0) =20 #define XILINX_LOCK_KEY 0x767b #define XILINX_UNLOCK_KEY 0xdf0d diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index 3943187..0fa4b0d 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -34,7 +34,7 @@ #define DB_PRINT(...) do { \ fprintf(stderr, ": %s: ", __func__); \ fprintf(stderr, ## __VA_ARGS__); \ - } while (0); + } while (0) #else #define DB_PRINT(...) #endif diff --git a/hw/ssi/mss-spi.c b/hw/ssi/mss-spi.c index d60daba..185e1a3 100644 --- a/hw/ssi/mss-spi.c +++ b/hw/ssi/mss-spi.c @@ -35,7 +35,7 @@ if (MSS_SPI_ERR_DEBUG >=3D lvl) { \ qemu_log("%s: " fmt "\n", __func__, ## args); \ } \ -} while (0); +} while (0) =20 #define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args) =20 diff --git a/hw/ssi/stm32f2xx_spi.c b/hw/ssi/stm32f2xx_spi.c index 26a1b4d..69514da 100644 --- a/hw/ssi/stm32f2xx_spi.c +++ b/hw/ssi/stm32f2xx_spi.c @@ -35,7 +35,7 @@ if (STM_SPI_ERR_DEBUG >=3D lvl) { \ qemu_log("%s: " fmt, __func__, ## args); \ } \ -} while (0); +} while (0) =20 #define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args) =20 diff --git a/hw/ssi/xilinx_spi.c b/hw/ssi/xilinx_spi.c index 33482f0..83585bc 100644 --- a/hw/ssi/xilinx_spi.c +++ b/hw/ssi/xilinx_spi.c @@ -36,7 +36,7 @@ #define DB_PRINT(...) do { \ fprintf(stderr, ": %s: ", __func__); \ fprintf(stderr, ## __VA_ARGS__); \ - } while (0); + } while (0) #else #define DB_PRINT(...) #endif diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c index d8187fa..85c5d0c 100644 --- a/hw/ssi/xilinx_spips.c +++ b/hw/ssi/xilinx_spips.c @@ -43,7 +43,7 @@ fprintf(stderr, ": %s: ", __func__); \ fprintf(stderr, ## __VA_ARGS__); \ } \ -} while (0); +} while (0) =20 /* config register */ #define R_CONFIG (0x00 / 4) diff --git a/hw/timer/a9gtimer.c b/hw/timer/a9gtimer.c index ce1dc63..96d534d 100644 --- a/hw/timer/a9gtimer.c +++ b/hw/timer/a9gtimer.c @@ -37,7 +37,7 @@ fprintf(stderr, ": %s: ", __func__); \ fprintf(stderr, ## __VA_ARGS__); \ } \ -} while (0); +} while (0) =20 #define DB_PRINT(...) DB_PRINT_L(0, ## __VA_ARGS__) =20 diff --git a/hw/timer/cadence_ttc.c b/hw/timer/cadence_ttc.c index 5e65fdb..1005640 100644 --- a/hw/timer/cadence_ttc.c +++ b/hw/timer/cadence_ttc.c @@ -24,7 +24,7 @@ #define DB_PRINT(...) do { \ fprintf(stderr, ": %s: ", __func__); \ fprintf(stderr, ## __VA_ARGS__); \ - } while (0); + } while (0) #else #define DB_PRINT(...) #endif diff --git a/hw/timer/mss-timer.c b/hw/timer/mss-timer.c index 60f1213..4f81457 100644 --- a/hw/timer/mss-timer.c +++ b/hw/timer/mss-timer.c @@ -36,7 +36,7 @@ if (MSS_TIMER_ERR_DEBUG >=3D lvl) { \ qemu_log("%s: " fmt "\n", __func__, ## args); \ } \ -} while (0); +} while (0) =20 #define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args) =20 diff --git a/hw/timer/stm32f2xx_timer.c b/hw/timer/stm32f2xx_timer.c index e5f5e14..58fc7b1 100644 --- a/hw/timer/stm32f2xx_timer.c +++ b/hw/timer/stm32f2xx_timer.c @@ -34,7 +34,7 @@ if (STM_TIMER_ERR_DEBUG >=3D lvl) { \ qemu_log("%s: " fmt, __func__, ## args); \ } \ -} while (0); +} while (0) =20 #define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args) =20 diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index 149fae6..29142f3 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -38,7 +38,7 @@ if (DEBUG_TPM) { \ fprintf(stderr, fmt, ## __VA_ARGS__); \ } \ -} while (0); +} while (0) =20 #define TYPE_TPM_PASSTHROUGH "tpm-passthrough" #define TPM_PASSTHROUGH(obj) \ diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 561384c..8b5eb01 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -90,7 +90,7 @@ typedef struct TPMState { if (DEBUG_TIS) { \ printf(fmt, ## __VA_ARGS__); \ } \ -} while (0); +} while (0) =20 /* tis registers */ #define TPM_TIS_REG_ACCESS 0x00 diff --git a/migration/rdma.c b/migration/rdma.c index ca56594..9d5a424 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -88,7 +88,7 @@ static uint32_t known_capabilities =3D RDMA_CAPABILITY_PI= N_ALL; } \ return rdma->error_state; \ } \ - } while (0); + } while (0) =20 /* * A work request ID is 64-bits and we split up these bits diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index ba94f7d..cba5587 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -400,7 +400,7 @@ static void unallocated_encoding(DisasContext *s) "at pc=3D%016" PRIx64 "\n", = \ __FILE__, __LINE__, insn, s->pc - 4); \ unallocated_encoding(s); \ - } while (0); + } while (0) =20 static void init_tmp_a64_array(DisasContext *s) { diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 9b8b59f..6a18a41 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -58,7 +58,7 @@ if (DEBUG_KVM) { \ fprintf(stderr, fmt, ## __VA_ARGS__); \ } \ -} while (0); +} while (0) =20 #define kvm_vm_check_mem_attr(s, attr) \ kvm_vm_check_attr(s, KVM_S390_VM_MEM_CTRL, attr) diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h index d5ca5b6..ac52abd 100644 --- a/tests/acpi-utils.h +++ b/tests/acpi-utils.h @@ -32,7 +32,7 @@ typedef struct { do { \ memread(addr, &field, sizeof(field)); \ addr +=3D sizeof(field); \ - } while (0); + } while (0) =20 #define ACPI_READ_ARRAY_PTR(arr, length, addr) \ do { \ @@ -40,7 +40,7 @@ typedef struct { for (idx =3D 0; idx < length; ++idx) { \ ACPI_READ_FIELD(arr[idx], addr); \ } \ - } while (0); + } while (0) =20 #define ACPI_READ_ARRAY(arr, addr) \ ACPI_READ_ARRAY_PTR(arr, sizeof(arr) / sizeof(arr[0]), addr) @@ -56,7 +56,7 @@ typedef struct { ACPI_READ_FIELD((table)->oem_revision, addr); \ ACPI_READ_ARRAY((table)->asl_compiler_id, addr); \ ACPI_READ_FIELD((table)->asl_compiler_revision, addr); \ - } while (0); + } while (0) =20 #define ACPI_ASSERT_CMP(actual, expected) do { \ char ACPI_ASSERT_CMP_str[5] =3D {}; \ @@ -77,7 +77,7 @@ typedef struct { ACPI_READ_FIELD((field).bit_offset, addr); \ ACPI_READ_FIELD((field).access_width, addr); \ ACPI_READ_FIELD((field).address, addr); \ - } while (0); + } while (0) =20 =20 uint8_t acpi_calc_checksum(const uint8_t *data, int len); diff --git a/tests/tcg/test-mmap.c b/tests/tcg/test-mmap.c index 3982fa2..cdefadf 100644 --- a/tests/tcg/test-mmap.c +++ b/tests/tcg/test-mmap.c @@ -39,7 +39,7 @@ do = \ fprintf (stderr, "FAILED at %s:%d\n", __FILE__, __LINE__); \ exit (EXIT_FAILURE); \ } \ -} while (0); +} while (0) =20 unsigned char *dummybuf; static unsigned int pagesize; diff --git a/ui/sdl_zoom_template.h b/ui/sdl_zoom_template.h index 3bb508b..6a424ad 100644 --- a/ui/sdl_zoom_template.h +++ b/ui/sdl_zoom_template.h @@ -34,22 +34,22 @@ #define setRed(r, pcolor) do { \ *pcolor =3D ((*pcolor) & (~(dpf->Rmask))) + \ (((r) & (dpf->Rmask >> dpf->Rshift)) << dpf->Rshift); \ -} while (0); +} while (0) =20 #define setGreen(g, pcolor) do { \ *pcolor =3D ((*pcolor) & (~(dpf->Gmask))) + \ (((g) & (dpf->Gmask >> dpf->Gshift)) << dpf->Gshift); \ -} while (0); +} while (0) =20 #define setBlue(b, pcolor) do { \ *pcolor =3D ((*pcolor) & (~(dpf->Bmask))) + \ (((b) & (dpf->Bmask >> dpf->Bshift)) << dpf->Bshift); \ -} while (0); +} while (0) =20 #define setAlpha(a, pcolor) do { \ *pcolor =3D ((*pcolor) & (~(dpf->Amask))) + \ (((a) & (dpf->Amask >> dpf->Ashift)) << dpf->Ashift); \ -} while (0); +} while (0) =20 static void glue(sdl_zoom_rgb, BPP)(SDL_Surface *src, SDL_Surface *dst, in= t smooth, SDL_Rect *dst_rect) --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515758059809864.0389399568566; Fri, 12 Jan 2018 03:54:19 -0800 (PST) Received: from localhost ([::1]:35323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxuc-0002AX-Ph for importer@patchew.org; Fri, 12 Jan 2018 06:54:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZH-0007w8-8d for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZG-00060J-HD for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:15 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:42373) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZG-0005z8-BH for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:14 -0500 Received: by mail-wm0-x242.google.com with SMTP id b141so11528484wme.1 for ; Fri, 12 Jan 2018 03:32:14 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=3cg63NDUmgBpGpBxxApA/29oZGAjDVw5iBbPXqLg6Tc=; b=M1Nf3q8/7EMHMfXuIhPsBT3jel0SSieUbGRzo+1aVclU0PwGlWvAikTZ49mjUrNsA3 7oDKufezbtOH3jT0bL6igaPZ/AqqUAX19b4YDZ8wl+xRPhR+cYQURZyEC0mYOuAXRPOw N+rBC/EDad5SfWrbPS1dbOLGM0ZEbbzdwA8zhnFAja+ke5TmeWGBdERr+1z69SvyMnQw eMx0jXCMjtiFAMCh1dPnZAYn4hsxH6uvcDjb+9eNhRqt1mGfH3snQCUXoFLBCaz4mFlF wy2/Uvb+QTtgKIEY1LGNGcSwgTFfX3Dgq0TWpigw+nHVRsBvQfA+/uirC3SPsP7AGZdP M3VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=3cg63NDUmgBpGpBxxApA/29oZGAjDVw5iBbPXqLg6Tc=; b=IEjLxns/Z/lLxHwMcV3sMGBt+iVDOpA8mkWrip6MxLs5nSxcq7KSXw44nqYlGxg7Pz 0GQRVDA6LIaiA+K1hSWrHPSdz3sC9ejtXNgqgyzWbVRUl09ggO0fsKqOiEEg4cWHP0Z7 SE3WU53ldxrkLy1dBn19UzblUeByPiUy0VvDmSq2lb+hPNZ0++YkUcEXPiFTdVLw/IFG XFRhoEXQw+2PGMKZo+JE8L1yWCKg86XbyBNTGMksIMfPjy7g+EIkGrMniRrbCWBRA42K oWYA/zQOON2OMpu5JXuEyGqJZwzrz2S4SK9UBfkwfr1Pdjf7DrQJ9k6UwdzfL7I0XB8y ZdZg== X-Gm-Message-State: AKwxytfDA3I7wuP10olk4FsVDGhpQ86oMV49cyKeD/je7WY9E5CmaHSV sAi+kjXodo7pPi+tlYrLY/eQsHM/ X-Google-Smtp-Source: ACJfBot04QXNSVK6fPm22HhFuVzuQ1HhJf39oaWWvl9jNoI+CauTYFUv9lNGoZ3/Ksyd6lONtjrAMg== X-Received: by 10.28.84.14 with SMTP id i14mr270803wmb.30.1515756733014; Fri, 12 Jan 2018 03:32:13 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:10 +0100 Message-Id: <1515756676-3860-47-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 46/52] checkpatch: Enforce proper do/while (0) style X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Use of a loop construct for code that is not intended to repeat does not make much idiomatic sense, except in one place: it is a common usage in macros in order to wrap arbitrary code with single-statement semantics. But when used in a macro, it is more typical for the caller to supply the trailing ';' when calling the macro. Although qemu coding style frowns on bare: if (cond) statement1; else statement2; where extra semicolons actually cause syntax errors, we still want our macro styles to be easily copied to other projects. Thus, declare it an error if we encounter any form of 'while (0)' with a semicolon in the same line. Signed-off-by: Eric Blake Message-Id: <20171201232433.25193-8-eblake@redhat.com> Signed-off-by: Paolo Bonzini --- scripts/checkpatch.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3dc27d9..accba24 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1622,6 +1622,11 @@ sub process { } } =20 +# 'do ... while (0/false)' only makes sense in macros, without trailing ';' + if ($line =3D~ /while\s*\((0|false)\);/) { + ERROR("suspicious ; after while (0)\n" . $herecurr); + } + # Check relative indent for conditionals and blocks. if ($line =3D~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ &= & $line !~ /\}\s*while\s*/) { my ($s, $c) =3D ($stat, $cond); --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515759723269116.59220525587341; Fri, 12 Jan 2018 04:22:03 -0800 (PST) Received: from localhost ([::1]:36724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZyLI-0002Ao-ST for importer@patchew.org; Fri, 12 Jan 2018 07:21:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZI-0007xO-IW for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZH-00061Z-NT for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:16 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:36147) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZH-00060u-Gg for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:15 -0500 Received: by mail-wr0-x243.google.com with SMTP id d9so5043041wre.3 for ; Fri, 12 Jan 2018 03:32:15 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=qYWXZqmOnjr9kRe2Z16W/eCWt4E2/uIIod4+4Q08MO4=; b=RSPe93TXaz1bmb0vRU8TqQtq0Zmp0CmE5ObR1GrR7E+IVSc3R7kFuSqOQqQE9a4FHR vWLYm+iwTjEHhptt+1s8w9tqqa70ILBaJLPIzl3iyn08IZ6gWrwEu8Y/OoJ6eaonxUUo tHip908voZP3w6rOJqSTmJbTQ/8LC1anhYe39GT8dvix2Guq+UoMTSGgnmoPAM/BH5pX Xn3TtO2GnaJdXicOcwgCnD2GIFY5DJVkzM1CFPySLsyrgDgUJLum7UCdw1QnPaHuORmX vMgXku6ItvZwzOhboOBDfoS59k9WJIKRKSCaDFwvIpbriovG7Ae6/Dm1UW+b98435y7Y 4jmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=qYWXZqmOnjr9kRe2Z16W/eCWt4E2/uIIod4+4Q08MO4=; b=Jv7pDKMNGq0FnuovOHiH566XThX702N0mVvH0mR1DT1ho4SvSMdVRP37gLJJ04N1br k/PQ2Td1Xt8Zm9ymg63EZzCL3B46YLKPMmlFDeeX5GAkzbMI87Ik6Q07/3F8zz+fw7Et x7f5P00viMKa5Fave59Q/9UQLGmwuaUc6ezjGhGrBdJvvOcfb/XcecPo4gamGL/ZXjFt iHz/lN3hyTsGZSXxcPz4N+/BI75V6GFHbBk9cvCeAeF6jlwI8bOGf0b6J5kM5sFAo6v4 EOTAytz7JjDkwAkMMPK1mZMMuhVzrppFRHUXkLbWJB7AblkNraFk3qmtminbuV8Ks/uE dhew== X-Gm-Message-State: AKGB3mKkBXyU8fbjfAHfkGCfLycdTXQVAnkWYoK8as3ihcV5HhqCD92u J/GrtbEPf5KdILGrJqclrz6VIkyZ X-Google-Smtp-Source: ACJfBots6vUAGIa9JqZDpmbWXeX/2X3eEST5r9hDpSvxpUuLwsIJeBNhGc+voIsucL9TXJBf43oCRA== X-Received: by 10.223.146.69 with SMTP id 63mr15235934wrj.22.1515756734166; Fri, 12 Jan 2018 03:32:14 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:11 +0100 Message-Id: <1515756676-3860-48-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 47/52] find_ram_offset: Add comments and tracing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Add some comments so I can understand the various nested loops. Add some tracing so I can see what they're doing. Signed-off-by: Dr. David Alan Gilbert Message-Id: <20180105170138.23357-2-dgilbert@redhat.com> Signed-off-by: Paolo Bonzini --- exec.c | 29 ++++++++++++++++++++++------- trace-events | 4 ++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/exec.c b/exec.c index 4722e52..5e2fb55 100644 --- a/exec.c +++ b/exec.c @@ -1660,7 +1660,10 @@ static void *file_ram_alloc(RAMBlock *block, } #endif =20 -/* Called with the ramlist lock held. */ +/* Allocate space within the ram_addr_t space that governs the + * dirty bitmaps. + * Called with the ramlist lock held. + */ static ram_addr_t find_ram_offset(ram_addr_t size) { RAMBlock *block, *next_block; @@ -1673,19 +1676,29 @@ static ram_addr_t find_ram_offset(ram_addr_t size) } =20 RAMBLOCK_FOREACH(block) { - ram_addr_t end, next =3D RAM_ADDR_MAX; + ram_addr_t candidate, next =3D RAM_ADDR_MAX; =20 - end =3D block->offset + block->max_length; + candidate =3D block->offset + block->max_length; =20 + /* Search for the closest following block + * and find the gap. + */ RAMBLOCK_FOREACH(next_block) { - if (next_block->offset >=3D end) { + if (next_block->offset >=3D candidate) { next =3D MIN(next, next_block->offset); } } - if (next - end >=3D size && next - end < mingap) { - offset =3D end; - mingap =3D next - end; + + /* If it fits remember our place and remember the size + * of gap, but keep going so that we might find a smaller + * gap to fill so avoiding fragmentation. + */ + if (next - candidate >=3D size && next - candidate < mingap) { + offset =3D candidate; + mingap =3D next - candidate; } + + trace_find_ram_offset_loop(size, candidate, offset, next, mingap); } =20 if (offset =3D=3D RAM_ADDR_MAX) { @@ -1694,6 +1707,8 @@ static ram_addr_t find_ram_offset(ram_addr_t size) abort(); } =20 + trace_find_ram_offset(size, offset); + return offset; } =20 diff --git a/trace-events b/trace-events index 3695959..ec95e67 100644 --- a/trace-events +++ b/trace-events @@ -55,6 +55,10 @@ dma_complete(void *dbs, int ret, void *cb) "dbs=3D%p ret= =3D%d cb=3D%p" dma_blk_cb(void *dbs, int ret) "dbs=3D%p ret=3D%d" dma_map_wait(void *dbs) "dbs=3D%p" =20 +# # exec.c +find_ram_offset(uint64_t size, uint64_t offset) "size: 0x%" PRIx64 " @ 0x%= " PRIx64 +find_ram_offset_loop(uint64_t size, uint64_t candidate, uint64_t offset, u= int64_t next, uint64_t mingap) "trying size: 0x%" PRIx64 " @ 0x%" PRIx64 ",= offset: 0x%" PRIx64" next: 0x%" PRIx64 " mingap: 0x%" PRIx64 + # memory.c memory_region_ops_read(int cpu_index, void *mr, uint64_t addr, uint64_t va= lue, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64" size %= u" memory_region_ops_write(int cpu_index, void *mr, uint64_t addr, uint64_t v= alue, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64" size = %u" --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151575940438948.09484097465554; Fri, 12 Jan 2018 04:16:44 -0800 (PST) Received: from localhost ([::1]:36508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZyGG-00067a-Mi for importer@patchew.org; Fri, 12 Jan 2018 07:16:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZN-00082u-Lt for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZI-00062p-Ny for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:21 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:43338) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZI-00061q-IS for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:16 -0500 Received: by mail-wm0-x241.google.com with SMTP id g1so11401468wmg.2 for ; Fri, 12 Jan 2018 03:32:16 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=7VMu0VBZcgpewAsa8ffCUDPhjUklniJbNv3OMPwXEMQ=; b=daQeNk34J57NBH5vZVs83XDisXAq3PKveukH3F+n24U8xNaKn2uquRCp3XvL8lxPPe g+W+pOPRKR6lXo6F9DjxSs8k14gc6vr3cr6gjXlKsU/vCp2Eu3JaI1dC5mZHiRtwlR+k aec3mF+M458JGPJHN+jL+v8gxz3zQ2bJZ1z+dRdCg7Tr9i5QYDMM0ge8CccZsBmnNR41 vv+wtfjZbLzQM5H7QzAdverZy4/ignAHU+dFKQFEgx/UtxSp25Bm5M3UAvR7Jr+Hci9/ qekoC09SF+wvMvasTLpIAFHrBsX9Wh4MbFE+1aLMWwEuYftI9dOHvIBQ3JS3kE2qIu3I G9vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=7VMu0VBZcgpewAsa8ffCUDPhjUklniJbNv3OMPwXEMQ=; b=WH3Q3m4FEBbBZf5F4t2TQ5EGo8Qkd9zzuTM/Kb7hbRY4MI0HHMp2vaLehsPURNzQm3 A18f0FQxjTLC8cZ6i5VNtMjcFiPLlWC4px2HZzLgxJHkUZc5BXoqeyETJRvcCdqtBGyB WVUW3MozETCYWRP4qu1ALw+1XEndbUUDfdc8MEJRpflVFDjGDtKBq2iMc7Nmz7Ag214B TaVIEwT0A9vysVcvyaigdFMt5AH+SJGxQQyrsGtFrqNr/Kk/5zwFcJjl8zABnnOe9O9y oOUQ+gN7Va8Yc2FH7x38mzqf5eB7k67Yy/OnD8hLejDkFYWZL3PftmGgrN4haPh0R38p 2OTg== X-Gm-Message-State: AKwxytdvMIG5djZH9fLQalpXEszc/9E6HdGy4j+H3EU8NQmLjCY/pqZj aBqIkeshx9UWwN4KWy6RCSIczmr3 X-Google-Smtp-Source: ACJfBouQ3ixHeEOOFlpDch1OLP/zasOZopLLWbiSH+HrVGYzC0G/FR3zYC7hAL2VoaZh2YSgjQWKCA== X-Received: by 10.28.182.86 with SMTP id g83mr3727092wmf.75.1515756735229; Fri, 12 Jan 2018 03:32:15 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:12 +0100 Message-Id: <1515756676-3860-49-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 48/52] find_ram_offset: Align ram_addr_t allocation on long boundaries X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" The dirty bitmaps are built from 'long's and there is fast-path code for synchronising the case where the RAMBlock is aligned to the start of a long boundary. Align the allocation to this boundary to cause the fast path to be used. Offsets before change: 11398@1515169675.018566:find_ram_offset size: 0x1e0000 @ 0x8000000 11398@1515169675.020064:find_ram_offset size: 0x20000 @ 0x81e0000 11398@1515169675.020244:find_ram_offset size: 0x20000 @ 0x8200000 11398@1515169675.024343:find_ram_offset size: 0x1000000 @ 0x8220000 11398@1515169675.025154:find_ram_offset size: 0x10000 @ 0x9220000 11398@1515169675.027682:find_ram_offset size: 0x40000 @ 0x9230000 11398@1515169675.032921:find_ram_offset size: 0x200000 @ 0x9270000 11398@1515169675.033307:find_ram_offset size: 0x1000 @ 0x9470000 11398@1515169675.033601:find_ram_offset size: 0x1000 @ 0x9471000 after change: 10923@1515169108.818245:find_ram_offset size: 0x1e0000 @ 0x8000000 10923@1515169108.819410:find_ram_offset size: 0x20000 @ 0x8200000 10923@1515169108.819587:find_ram_offset size: 0x20000 @ 0x8240000 10923@1515169108.823708:find_ram_offset size: 0x1000000 @ 0x8280000 10923@1515169108.824503:find_ram_offset size: 0x10000 @ 0x9280000 10923@1515169108.827093:find_ram_offset size: 0x40000 @ 0x92c0000 10923@1515169108.833045:find_ram_offset size: 0x200000 @ 0x9300000 10923@1515169108.833504:find_ram_offset size: 0x1000 @ 0x9500000 10923@1515169108.833787:find_ram_offset size: 0x1000 @ 0x9540000 Suggested-by: Paolo Bonzini Signed-off-by: Dr. David Alan Gilbert Message-Id: <20180105170138.23357-3-dgilbert@redhat.com> Signed-off-by: Paolo Bonzini --- exec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exec.c b/exec.c index 5e2fb55..9f4f450 100644 --- a/exec.c +++ b/exec.c @@ -1678,7 +1678,11 @@ static ram_addr_t find_ram_offset(ram_addr_t size) RAMBLOCK_FOREACH(block) { ram_addr_t candidate, next =3D RAM_ADDR_MAX; =20 + /* Align blocks to start on a 'long' in the bitmap + * which makes the bitmap sync'ing take the fast path. + */ candidate =3D block->offset + block->max_length; + candidate =3D ROUND_UP(candidate, BITS_PER_LONG << TARGET_PAGE_BIT= S); =20 /* Search for the closest following block * and find the gap. --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515759259512719.959596070769; Fri, 12 Jan 2018 04:14:19 -0800 (PST) Received: from localhost ([::1]:36451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZyDy-00041Q-JJ for importer@patchew.org; Fri, 12 Jan 2018 07:14:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZN-00082t-LQ for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZK-00063f-09 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:21 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:44059) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZJ-000636-Pz for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:17 -0500 Received: by mail-wr0-x241.google.com with SMTP id w50so5008647wrc.11 for ; Fri, 12 Jan 2018 03:32:17 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=033LkzDn7bO2+4XP5OOr0CJLAPcCHZ4nUls9z7Z3jVw=; b=mzCL/kNh2fPIKDj8EgOD/vNBTtInCvUcT18lEShbyjLbGdzWDQZHr/WErwlMJ5Qls+ nVOUL8E4+Ky9Er0eqS2SKzBvLQ0Ss3Hh5LlBQ+ofATIFV+oXpvIb4uHECx6ZNn2CQhtQ GlpbZubSZeBwCTyEHr5BUDCVWR5yhY0vN5lhE4uM+TlIlf2OwOT4W3s4guMYSHmzqrnV FfOWPLEgTa9Hss6VkUoEJAN1dH95J1EeaFdB1uRc7LzMQ52+sHoqChWU7v0L/t1n90Jo xPwmkO/sxp1j/utd3tIbwImATq/bCBH8MoDknEFXyZkrYCEQMLRQWhFI3uU0PDWps0Nl UF1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=033LkzDn7bO2+4XP5OOr0CJLAPcCHZ4nUls9z7Z3jVw=; b=oYSt9qCP8KDcY9Dgh0/vHbumCHsmhSqrXvtqCIJ0w0VH3lv11cz8KsL97fOsy3ywKT aT2LCZsHXdG8fK6fSd81pfI3jx8cf06l+bFCfE/oQkg5SLzJvuq53hMRdr4Ctk3FONGl KFoKznPNmyBkEI2VS9isNTqz8WWJm2tqn2crF3+6ekevkgQkRaVkq0I2IqkTclcW4RaZ c9efOZYAA5WZ6iRlxCZAOSv2gL8K8kTuFCHDoHihNPa6GVzAjPn8mU4845XZqNBGHMW8 kNZN7QsrL2YS2RvyEM/9F3+wIQzBclQAXumAe5l2D+buUlt7YVwSFTVMCjogSJFdPM5F 6Oxw== X-Gm-Message-State: AKwxyteDvU337Up/gN4FQomQ8snXF5UatdZTsmXJsnv1C3dukMIXP7/e ZZtW+4L0huufaPW+I92hn9tzksD5 X-Google-Smtp-Source: ACJfBotuoXMmND1iF1ypZLMLAaEDvp0NMsSp/Scd4/0E0A7/e/k2CJCc/8XEgqXCeTr5CAqv0COcZw== X-Received: by 10.223.185.124 with SMTP id b57mr10501089wrg.13.1515756736371; Fri, 12 Jan 2018 03:32:16 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:13 +0100 Message-Id: <1515756676-3860-50-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 49/52] block/iscsi: fix initialization of iTask in iscsi_co_get_block_status X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Lieven Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Lieven in case of unaligned requests or on a target that does not support block provisioning we leave iTask uninitialized and check iTask.task for NULL later. Fixes: e38bc23454ef763deb4405ebdee6a1081aa00bc8 Signed-off-by: Peter Lieven Reviewed-by: Eric Blake Message-Id: <1515425247-21730-1-git-send-email-pl@kamp.de> Signed-off-by: Paolo Bonzini --- block/iscsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/iscsi.c b/block/iscsi.c index 5c0a9e5..6a1c537 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -658,6 +658,8 @@ static int64_t coroutine_fn iscsi_co_get_block_status(B= lockDriverState *bs, uint64_t lba; int64_t ret; =20 + iscsi_co_init_iscsitask(iscsilun, &iTask); + if (!is_sector_request_lun_aligned(sector_num, nb_sectors, iscsilun)) { ret =3D -EINVAL; goto out; @@ -675,7 +677,6 @@ static int64_t coroutine_fn iscsi_co_get_block_status(B= lockDriverState *bs, =20 lba =3D sector_qemu2lun(sector_num, iscsilun); =20 - iscsi_co_init_iscsitask(iscsilun, &iTask); qemu_mutex_lock(&iscsilun->mutex); retry: if (iscsi_get_lba_status_task(iscsilun->iscsi, iscsilun->lun, --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515759622778372.99362070238885; Fri, 12 Jan 2018 04:20:22 -0800 (PST) Received: from localhost ([::1]:36615 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZyJq-0000hK-0b for importer@patchew.org; Fri, 12 Jan 2018 07:20:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42150) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZO-00084N-SC for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZL-00064B-48 for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:22 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:38111) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZK-00063u-UP for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:19 -0500 Received: by mail-wr0-x241.google.com with SMTP id x1so859036wrb.5 for ; Fri, 12 Jan 2018 03:32:18 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=C8+zokiy5iXF1tSoWLEySm0x0c0xHd/vJQau14WkiL0=; b=YP6sUeF/erD9dgY9RoQ/hISmu/W+/NdibjyCCq8OLGGy8uY2Cn46KPPRZleTAJH15a D9xsSkx45DNdVp334b/aoycpzs4QEy4OBRFrU7puz6sd6EOvxb8qoFuw4NYx3KggMi4k ptIro4hczPoS+mvGhTN7ikn5zToaNYDpGZJuEpr7skqY3aIkdS8o5L71k5R6ayMImEfH zCrZrCzV51+hjoBIa2Qu73Kq2XKOvU5uOPYo4I8tZa1SPRIa4bAjIa8M9pt8AIr/gRp0 GpyE/6XCEydPC3oLcwuCvg7os2pINgcYroZq4btyObtawWJXVC8VvdDa9mFAMPeHVTaz crBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=C8+zokiy5iXF1tSoWLEySm0x0c0xHd/vJQau14WkiL0=; b=hjAJgsCZEhe8vI24ZdhwVB5mWyLzWWHC/07/mn8WfOR32mvCHFC5S2OCGeYTQjtyXr jgMCIto/8TVoMAG50GoM1Km2LR2iN7oIEePSELxlkduBcRseO/uKqW5SDXcSkud1zbJi Zy9oNQIiG+7VvUnF3z9UiIsiXpBL0qtT+LhdHBOZ10YXmFhG+TmhHDpu+H01fBMp1yAf OZptZPxmEdkRzriWcSWacI2rWh0irErYs2V/bj/tLPtDnVIi2ptg1KJKZdd/yvXBASBI zn4S6DWMioaE+LGxTgAbv4PsvE9DgfdKrtwLUB6HZqrhJf7tnbMePPz5XTXZ2dZNSTtD SXkA== X-Gm-Message-State: AKwxytf21zMvqKR31UqGAiGSr1OwY2GgHa5OkxqWHSoBbz8hpsCw7/1/ BYdnNw9xXf8Lsl2TnhxQzc3rou2M X-Google-Smtp-Source: ACJfBouFvY0hh+61a9ehTC140VgmrnQiezwVJfShYEyd2m/kMCpa5vKXIu+ksrIlYbvrgcVdwfVJPA== X-Received: by 10.223.176.103 with SMTP id g36mr7715451wra.129.1515756737658; Fri, 12 Jan 2018 03:32:17 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:14 +0100 Message-Id: <1515756676-3860-51-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 50/52] cpu: flush TB cache when loading VMState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maria Klimushenkova , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pavel Dovgalyuk Flushing TB cache is required because TBs key in the cache may match different code which existed in the previous state. Signed-off-by: Pavel Dovgalyuk Signed-off-by: Maria Klimushenkova Message-Id: <20180110134846.12940.99993.stgit@pasha-VirtualBox> [Add comment suggested by Peter Maydell. - Paolo] Signed-off-by: Paolo Bonzini Signed-off-by: Pavel Dovgalyuk --- exec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/exec.c b/exec.c index 9f4f450..d28fc0c 100644 --- a/exec.c +++ b/exec.c @@ -623,6 +623,13 @@ static int cpu_common_post_load(void *opaque, int vers= ion_id) cpu->interrupt_request &=3D ~0x01; tlb_flush(cpu); =20 + /* loadvm has just updated the content of RAM, bypassing the + * usual mechanisms that ensure we flush TBs for writes to + * memory we've translated code from. So we must flush all TBs, + * which will now be stale. + */ + tb_flush(cpu); + return 0; } =20 --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515759778383428.75568564663376; Fri, 12 Jan 2018 04:22:58 -0800 (PST) Received: from localhost ([::1]:36738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZyML-00033A-Dj for importer@patchew.org; Fri, 12 Jan 2018 07:22:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZO-00084P-TR for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZN-00065g-Ll for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:22 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:43283) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZN-00065E-Db for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:21 -0500 Received: by mail-wr0-x241.google.com with SMTP id s13so5021218wra.10 for ; Fri, 12 Jan 2018 03:32:21 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ji3zYJr0a36HKOJ9HE/PLOaJVocmgHMoxyHaRzyhj0g=; b=rhqLYj1cRJEItEnNNOVAAuT5VcjaKVYkwdJlXeL0NhYnm6/Y9KyxsE3z2+PTcwOgk2 ugdBioU3tC32RbhhvjRhn7+tQ6+bSiKMPWjn4oUmOWZJXRyYX1vlva9Irks9d67Npql+ D3m+itQIG+TNk5Bz37UwJVLfEt+RQm/nyEnyoAVGIjQnIkM5nPfVh2e26BKRq0ZsdQhD WJEVN2Ar0ASQiVLUxeirJxMgss1GsgyOlkeCeOsB/5CF2QXlkK8tHVA4x2wF3+4a6P9O teozDUTVvrLcG3SKlXNEOTmbruv50D18FKSe6D7NK6BSaaFh+A82oWNft2hL05NF2Le+ sizQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ji3zYJr0a36HKOJ9HE/PLOaJVocmgHMoxyHaRzyhj0g=; b=h13gTVJ/oE/4NHlIDZXaUFCXm0Cvz1PElZ1lWZzBufE3f5uHz9h5VcWAT9Ja85e06D CDZSpA5JfckM+Ye8t+hq6l82KB4iVyr+VZ0gNHKp7M4YcYbG+jxbFACMQUHrsdZxofjO q/O9KqsI82iN+u9CNoQK03lC6BWmfIV1SStcyTBOK2uRxrzGtUYtXt0+tueKyVQWZlbp 3roEkbi5WT7bG8Hz9Vb4G+yB4PfLpNj8zxKEcPlNkdPpLx0dNfAmw3HNxkzjfdeqLyCX 56PEGpAVsP68rCwWXGXFvzD6bE6pGqF9jM2C2I/wjCwIFY0OiTNkP/75r1m28VmbrDsa WHfg== X-Gm-Message-State: AKwxytcwqFXQo7fHMcRq67dCAbOpa24GG8NHfBMBQVb/TCxDIHd/TNFV 1jsy4YPr5X/C05WYDDnFO//X+SLd X-Google-Smtp-Source: ACJfBovq1pHLq63WBYO4QZxXgjIQY5xqaf7tCGKFrWATOUG3M/JH1LjGfD0O+mln01wOk6NrqX6TKQ== X-Received: by 10.223.161.198 with SMTP id v6mr969686wrv.65.1515756740032; Fri, 12 Jan 2018 03:32:20 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:15 +0100 Message-Id: <1515756676-3860-52-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 51/52] util/qemu-thread-*: add qemu_lock, locked and unlock trace events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Alex Benn=C3=A9e Signed-off-by: Alex Benn=C3=A9e Signed-off-by: Paolo Bonzini --- include/qemu/thread.h | 39 +++++++++++++++++++++++++++++++++++---- util/qemu-thread-posix.c | 21 ++++++++++++--------- util/qemu-thread-win32.c | 20 +++++++++++--------- util/trace-events | 7 ++++--- 4 files changed, 62 insertions(+), 25 deletions(-) diff --git a/include/qemu/thread.h b/include/qemu/thread.h index 9910f49..9af4e94 100644 --- a/include/qemu/thread.h +++ b/include/qemu/thread.h @@ -22,9 +22,31 @@ typedef struct QemuThread QemuThread; =20 void qemu_mutex_init(QemuMutex *mutex); void qemu_mutex_destroy(QemuMutex *mutex); -void qemu_mutex_lock(QemuMutex *mutex); -int qemu_mutex_trylock(QemuMutex *mutex); -void qemu_mutex_unlock(QemuMutex *mutex); +int qemu_mutex_trylock_impl(QemuMutex *mutex, const char *file, const int = line); +void qemu_mutex_lock_impl(QemuMutex *mutex, const char *file, const int li= ne); +void qemu_mutex_unlock_impl(QemuMutex *mutex, const char *file, const int = line); + +#define qemu_mutex_lock(mutex) \ + qemu_mutex_lock_impl(mutex, __FILE__, __LINE__) +#define qemu_mutex_trylock(mutex) \ + qemu_mutex_trylock_impl(mutex, __FILE__, __LINE__) +#define qemu_mutex_unlock(mutex) \ + qemu_mutex_unlock_impl(mutex, __FILE__, __LINE__) + +static inline void (qemu_mutex_lock)(QemuMutex *mutex) +{ + qemu_mutex_lock(mutex); +} + +static inline int (qemu_mutex_trylock)(QemuMutex *mutex) +{ + return qemu_mutex_trylock(mutex); +} + +static inline void (qemu_mutex_unlock)(QemuMutex *mutex) +{ + qemu_mutex_unlock(mutex); +} =20 /* Prototypes for other functions are in thread-posix.h/thread-win32.h. */ void qemu_rec_mutex_init(QemuRecMutex *mutex); @@ -39,7 +61,16 @@ void qemu_cond_destroy(QemuCond *cond); */ void qemu_cond_signal(QemuCond *cond); void qemu_cond_broadcast(QemuCond *cond); -void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex); +void qemu_cond_wait_impl(QemuCond *cond, QemuMutex *mutex, + const char *file, const int line); + +#define qemu_cond_wait(cond, mutex) \ + qemu_cond_wait_impl(cond, mutex, __FILE__, __LINE__) + +static inline void (qemu_cond_wait)(QemuCond *cond, QemuMutex *mutex) +{ + qemu_cond_wait(cond, mutex); +} =20 void qemu_sem_init(QemuSemaphore *sem, int init); void qemu_sem_post(QemuSemaphore *sem); diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index 959a570..b789cf3 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -57,26 +57,28 @@ void qemu_mutex_destroy(QemuMutex *mutex) error_exit(err, __func__); } =20 -void qemu_mutex_lock(QemuMutex *mutex) +void qemu_mutex_lock_impl(QemuMutex *mutex, const char *file, const int li= ne) { int err; =20 assert(mutex->initialized); + trace_qemu_mutex_lock(mutex, file, line); + err =3D pthread_mutex_lock(&mutex->lock); if (err) error_exit(err, __func__); =20 - trace_qemu_mutex_locked(mutex); + trace_qemu_mutex_locked(mutex, file, line); } =20 -int qemu_mutex_trylock(QemuMutex *mutex) +int qemu_mutex_trylock_impl(QemuMutex *mutex, const char *file, const int = line) { int err; =20 assert(mutex->initialized); err =3D pthread_mutex_trylock(&mutex->lock); if (err =3D=3D 0) { - trace_qemu_mutex_locked(mutex); + trace_qemu_mutex_locked(mutex, file, line); return 0; } if (err !=3D EBUSY) { @@ -85,15 +87,16 @@ int qemu_mutex_trylock(QemuMutex *mutex) return -EBUSY; } =20 -void qemu_mutex_unlock(QemuMutex *mutex) +void qemu_mutex_unlock_impl(QemuMutex *mutex, const char *file, const int = line) { int err; =20 assert(mutex->initialized); - trace_qemu_mutex_unlocked(mutex); err =3D pthread_mutex_unlock(&mutex->lock); if (err) error_exit(err, __func__); + + trace_qemu_mutex_unlock(mutex, file, line); } =20 void qemu_rec_mutex_init(QemuRecMutex *mutex) @@ -152,14 +155,14 @@ void qemu_cond_broadcast(QemuCond *cond) error_exit(err, __func__); } =20 -void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex) +void qemu_cond_wait_impl(QemuCond *cond, QemuMutex *mutex, const char *fil= e, const int line) { int err; =20 assert(cond->initialized); - trace_qemu_mutex_unlocked(mutex); + trace_qemu_mutex_unlock(mutex, file, line); err =3D pthread_cond_wait(&cond->cond, &mutex->lock); - trace_qemu_mutex_locked(mutex); + trace_qemu_mutex_locked(mutex, file, line); if (err) error_exit(err, __func__); } diff --git a/util/qemu-thread-win32.c b/util/qemu-thread-win32.c index 94f3491..ab60c0d 100644 --- a/util/qemu-thread-win32.c +++ b/util/qemu-thread-win32.c @@ -56,30 +56,32 @@ void qemu_mutex_destroy(QemuMutex *mutex) InitializeSRWLock(&mutex->lock); } =20 -void qemu_mutex_lock(QemuMutex *mutex) +void qemu_mutex_lock_impl(QemuMutex *mutex, const char *file, const int li= ne) { assert(mutex->initialized); + trace_qemu_mutex_lock(mutex, file, line); + AcquireSRWLockExclusive(&mutex->lock); - trace_qemu_mutex_locked(mutex); + trace_qemu_mutex_locked(mutex, file, line); } =20 -int qemu_mutex_trylock(QemuMutex *mutex) +int qemu_mutex_trylock_impl(QemuMutex *mutex, const char *file, const int = line) { int owned; =20 assert(mutex->initialized); owned =3D TryAcquireSRWLockExclusive(&mutex->lock); if (owned) { - trace_qemu_mutex_locked(mutex); + trace_qemu_mutex_locked(mutex, file, line); return 0; } return -EBUSY; } =20 -void qemu_mutex_unlock(QemuMutex *mutex) +void qemu_mutex_unlock_impl(QemuMutex *mutex, const char *file, const int = line) { assert(mutex->initialized); - trace_qemu_mutex_unlocked(mutex); + trace_qemu_mutex_unlock(mutex, file, line); ReleaseSRWLockExclusive(&mutex->lock); } =20 @@ -140,12 +142,12 @@ void qemu_cond_broadcast(QemuCond *cond) WakeAllConditionVariable(&cond->var); } =20 -void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex) +void qemu_cond_wait_impl(QemuCond *cond, QemuMutex *mutex, const char *fil= e, const int line) { assert(cond->initialized); - trace_qemu_mutex_unlocked(mutex); + trace_qemu_mutex_unlock(mutex, file, line); SleepConditionVariableSRW(&cond->var, &mutex->lock, INFINITE, 0); - trace_qemu_mutex_locked(mutex); + trace_qemu_mutex_locked(mutex, file, line); } =20 void qemu_sem_init(QemuSemaphore *sem, int init) diff --git a/util/trace-events b/util/trace-events index 025499f..515e625 100644 --- a/util/trace-events +++ b/util/trace-events @@ -56,6 +56,7 @@ lockcnt_futex_wait(const void *lockcnt, int val) "lockcnt= %p waiting on %d" lockcnt_futex_wait_resume(const void *lockcnt, int new) "lockcnt %p after = wait: %d" lockcnt_futex_wake(const void *lockcnt) "lockcnt %p waking up one waiter" =20 -# util/qemu-thread-posix.c -qemu_mutex_locked(void *lock) "locked mutex %p" -qemu_mutex_unlocked(void *lock) "unlocked mutex %p" +# util/qemu-thread.c +qemu_mutex_lock(void *mutex, const char *file, const int line) "waiting on= mutex %p (%s:%d)" +qemu_mutex_locked(void *mutex, const char *file, const int line) "taken mu= tex %p (%s:%d)" +qemu_mutex_unlock(void *mutex, const char *file, const int line) "released= mutex %p (%s:%d)" --=20 1.8.3.1 From nobody Sat May 4 04:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515759855633837.6557593857502; Fri, 12 Jan 2018 04:24:15 -0800 (PST) Received: from localhost ([::1]:36863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZyNY-0004MD-HO for importer@patchew.org; Fri, 12 Jan 2018 07:24:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZxZP-000855-Kv for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZxZO-00066R-Kq for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:23 -0500 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:41786) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZxZO-00065r-CN for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:32:22 -0500 Received: by mail-wm0-x22e.google.com with SMTP id g75so11524094wme.0 for ; Fri, 12 Jan 2018 03:32:22 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id l8sm2732271wmg.46.2018.01.12.03.32.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 03:32:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M0ZMFLJUiCrUyWZeCMLargX01+hYB4hFZwDirfHBgGc=; b=Hu4qz35WmvxrEVWbzhnSNYc9X4sVjecxETQ8I5sdCAhTiqwvjsOTJYlndlVXzemNm1 u4E08uMqB/VMQyypKXXwNK8PfVKk0Moj7xk2hx2QEonowNvLv8SRU4w2eb8jHwhrzAjr x3ecyaOPnqtWxbZN0f5KGglSsE8JCjOeCXIWy3NSQJshEH/jn2R+WMzkEP7fWRZMb109 q8WcJnpy750mPRN5QAx7OyIXfKgl+iHpoS/f6XW29yk4T8azfkd1zfFcpEKtPbkO8CbW GcwqZ3oMF74gjknI17sdNOzV7bOsxV5gxH4wCTkeGnOnXi0aLUxrpGo2Qnhdnum/uEko +YYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=M0ZMFLJUiCrUyWZeCMLargX01+hYB4hFZwDirfHBgGc=; b=JsAjQrtMxEBQFXBwvh2PTNRr5zj3bbExMsej3M1DkfhZ53WqI86fmK1t0skeDWO67T Mia0lM2e0KbiugHOI1uCwi3QuY20tZwALiRnh0Q521hQ7Xug/w+02Dh2RF6P7r/uZKXQ kbxRhbH5NLcR7uyskBy/Y0aKpC2CblnaqFcdqdnS5X/B10y5CIC+3BDkZpfrPM60hTUu Nl2Wk95drN/zb19PYk006cjF9rr1NE9UsQn+vbchk5SWnoIuykEElb5qlRcSQNURjefM anVyS+9HQOJMYbde/57E0noh8Q5NDltuufU3t/oh5hyn6JAfaxYH6gdmI35p81eOWKLD Wv5A== X-Gm-Message-State: AKwxytdvLuwvtOMmU4+LO7PTsayFHSmYb2qthj7/6MJRk5WZdHpMuWfG 7pRVEtdQ+TwbwLxyh6Iyx8hyV6c4 X-Google-Smtp-Source: ACJfBotWFasO3i7sf5Vnrda/w8wlwnBGvTOx1EhGXIbbHpYygrud5ucxsHTUYItp6MZxGjcEn1RjgA== X-Received: by 10.28.35.200 with SMTP id j191mr4194322wmj.146.1515756740980; Fri, 12 Jan 2018 03:32:20 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 12:31:16 +0100 Message-Id: <1515756676-3860-53-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> References: <1515756676-3860-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22e Subject: [Qemu-devel] [PULL 52/52] scripts/analyse-locks-simpletrace.py: script to analyse lock times X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Alex Benn=C3=A9e This script allows analysis of mutex acquisition and hold times based on a trace file. Given a trace control file of: qemu_mutex_lock qemu_mutex_locked qemu_mutex_unlock And running with: $QEMU $QEMU_ARGS -trace events=3D./lock-trace You can analyse the results with: ./scripts/analyse-locks-simpletrace.py trace-events-all ./trace-21812 Signed-off-by: Alex Benn=C3=A9e Signed-off-by: Paolo Bonzini --- scripts/analyse-locks-simpletrace.py | 99 ++++++++++++++++++++++++++++++++= ++++ 1 file changed, 99 insertions(+) create mode 100755 scripts/analyse-locks-simpletrace.py diff --git a/scripts/analyse-locks-simpletrace.py b/scripts/analyse-locks-s= impletrace.py new file mode 100755 index 0000000..a69ed5c --- /dev/null +++ b/scripts/analyse-locks-simpletrace.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Analyse lock events and +# +# Author: Alex Benn=C3=83=C2=A9e +# + +import os +import simpletrace +import argparse +import numpy as np + +class MutexAnalyser(simpletrace.Analyzer): + "A simpletrace Analyser for checking locks." + + def __init__(self): + self.locks =3D 0 + self.locked =3D 0 + self.unlocks =3D 0 + self.mutex_records =3D {} + + def _get_mutex(self, mutex): + if not mutex in self.mutex_records: + self.mutex_records[mutex] =3D {"locks": 0, + "lock_time": 0, + "acquire_times": [], + "locked": 0, + "locked_time": 0, + "held_times": [], + "unlocked": 0} + + return self.mutex_records[mutex] + + def qemu_mutex_lock(self, timestamp, mutex, filename, line): + self.locks +=3D 1 + rec =3D self._get_mutex(mutex) + rec["locks"] +=3D 1 + rec["lock_time"] =3D timestamp[0] + rec["lock_loc"] =3D (filename, line) + + def qemu_mutex_locked(self, timestamp, mutex, filename, line): + self.locked +=3D 1 + rec =3D self._get_mutex(mutex) + rec["locked"] +=3D 1 + rec["locked_time"] =3D timestamp[0] + acquire_time =3D rec["locked_time"] - rec["lock_time"] + rec["locked_loc"] =3D (filename, line) + rec["acquire_times"].append(acquire_time) + + def qemu_mutex_unlock(self, timestamp, mutex, filename, line): + self.unlocks +=3D 1 + rec =3D self._get_mutex(mutex) + rec["unlocked"] +=3D 1 + held_time =3D timestamp[0] - rec["locked_time"] + rec["held_times"].append(held_time) + rec["unlock_loc"] =3D (filename, line) + + +def get_args(): + "Grab options" + parser =3D argparse.ArgumentParser() + parser.add_argument("--output", "-o", type=3Dstr, help=3D"Render plot = to file") + parser.add_argument("events", type=3Dstr, help=3D'trace file read from= ') + parser.add_argument("tracefile", type=3Dstr, help=3D'trace file read f= rom') + return parser.parse_args() + +if __name__ =3D=3D '__main__': + args =3D get_args() + + # Gather data from the trace + analyser =3D MutexAnalyser() + simpletrace.process(args.events, args.tracefile, analyser) + + print ("Total locks: %d, locked: %d, unlocked: %d" % + (analyser.locks, analyser.locked, analyser.unlocks)) + + # Now dump the individual lock stats + for key, val in sorted(analyser.mutex_records.iteritems(), + key=3Dlambda (k,v): v["locks"]): + print ("Lock: %#x locks: %d, locked: %d, unlocked: %d" % + (key, val["locks"], val["locked"], val["unlocked"])) + + acquire_times =3D np.array(val["acquire_times"]) + if len(acquire_times) > 0: + print (" Acquire Time: min:%d median:%d avg:%.2f max:%d" % + (acquire_times.min(), np.median(acquire_times), + acquire_times.mean(), acquire_times.max())) + + held_times =3D np.array(val["held_times"]) + if len(held_times) > 0: + print (" Held Time: min:%d median:%d avg:%.2f max:%d" % + (held_times.min(), np.median(held_times), + held_times.mean(), held_times.max())) + + # Check if any locks still held + if val["locks"] > val["locked"]: + print (" LOCK HELD (%s:%s)" % (val["locked_loc"])) + print (" BLOCKED (%s:%s)" % (val["lock_loc"])) --=20 1.8.3.1