From nobody Sat May 4 09:49:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617300441; cv=none; d=zohomail.com; s=zohoarc; b=DWfo6f8I1PYx8xHv0W8xJa8sk9bvb2rMnWVunrULCQRpi5ftX7WvU3M5IQeuzF/o2B1lE/26w0F4ggMhjcJKw1hZLiT3COgf25NEflx7aiwyzvuqHTBgEV0PWTIg1qsTc1Wuoo2DP9p4gHv1RCWR7WRhGknfSKSrrg6lIt46vK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617300441; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=G31uNypBJwdGB42YcMOaMNC4SaJrMSHozBk1bd66u7c=; b=gYl757dXEQc3VR9KkeVouT9TvrLWnAq/+NtTKrDOj1P5WiMA9AbUWbuKKdtnHighoO+1WAYQ/c9orpoH+VJfSlrX54PmfYmRtTf/OxLgh2L0zTJ5jWndyLNLZ4P1av00xq9TwXzPx/eH5xlYCmiSolfz/8n21MGQRDigVCpI+BA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617300441758717.1519015429186; Thu, 1 Apr 2021 11:07:21 -0700 (PDT) Received: from localhost ([::1]:46838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lS1iy-0004wy-Lo for importer@patchew.org; Thu, 01 Apr 2021 14:07:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1er-0003Bj-VE for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1ek-0005ry-Hi for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:03 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-GgqOUB_cNaaBt2RMUGH7sA-1; Thu, 01 Apr 2021 14:02:55 -0400 Received: by mail-wm1-f69.google.com with SMTP id k132so1594586wma.1 for ; Thu, 01 Apr 2021 11:02:55 -0700 (PDT) Received: from redhat.com ([2a10:800e:f0d3:0:b69b:9fb8:3947:5636]) by smtp.gmail.com with ESMTPSA id h9sm9226071wmb.35.2021.04.01.11.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 11:02:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617300177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=G31uNypBJwdGB42YcMOaMNC4SaJrMSHozBk1bd66u7c=; b=APat1eS00o60fY0sUG5WDMJsMF3a/cxAEq6DPPYINDUKlFzSsdf1TG7MrFr8stv79ZO8x9 JxT+/xnsDMlQ9XV0WzyZrLKhwnu0vsyv+yOWsGWseCTBz6FoDfGIU3U9vuTnVPHNClDlau 4IygdoPPJfhTR5XFsiHw9CTFMy7rB44= X-MC-Unique: GgqOUB_cNaaBt2RMUGH7sA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=G31uNypBJwdGB42YcMOaMNC4SaJrMSHozBk1bd66u7c=; b=JlVMcpW/gA900i4hzWDyMQJPjgg7v1wMluRf+0/GHTBpGDur3BCsQlJn50AuFfVYaG SHnZIBS910CkQGp1lRBMMxgnkKFFC3JDqrGU/Mq4nv7X0Z78zWA7oRfz9H5/Q9qvqSoV frVBHnimnnbyH9U1FYCvte/jkYCARU9m3urvhMGf2/fqwfX0TYbMkwdZSB/kkwiS5bGs jakUx8pHoqRL7qwAuVtWb593USMM/0MPC+2DDJNfeX6GJMkbXa4HB6f6jLW8rGKnui0t mNmH+f0vreMQB+CMBMH6qJX6Jx1iC4FecRba7rXAaOPgtSSK7lK1sYaLI63ttWLp/VRb Duhg== X-Gm-Message-State: AOAM531GPpi3J/OZdziZGEW1e6YAtPA6ww0vQEAcnva0BlJUeXVnBvjp pCKTB3XKG8wJs4btekcXoLGuId97TEOpLdSB4if7ZGqCnkE3xElN/qK4kY6eOdVnad97gE5QgmZ bOZP85GEQj1acN2q8xkVYkfgiDfYk6dMoRLfNe9Cf6TqFO61DGL6eK1hCfz9c X-Received: by 2002:a5d:6a4c:: with SMTP id t12mr10961496wrw.289.1617300174262; Thu, 01 Apr 2021 11:02:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztEqL0FjHv0Y+Cf3DLfhcZ7nUdOk6TdL/fa3Vkt0p6TS1sMssxFFkWX6XkW+verJKOhSB5hw== X-Received: by 2002:a5d:6a4c:: with SMTP id t12mr10961464wrw.289.1617300174073; Thu, 01 Apr 2021 11:02:54 -0700 (PDT) Date: Thu, 1 Apr 2021 14:02:52 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 1/9] vhost-user-blk: use different event handlers on initialization Message-ID: <20210401180235.226321-2-mst@redhat.com> References: <20210401180235.226321-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210401180235.226321-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Max Reitz , Denis Plotnikov , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Denis Plotnikov It is useful to use different connect/disconnect event handlers on device initialization and operation as seen from the further commit fixing a bug on device initialization. This patch refactors the code to make use of them: we don't rely any more on the VM state for choosing how to cleanup the device, instead we explicitly use the proper event handler depending on whether the device has been initialized. Signed-off-by: Denis Plotnikov Reviewed-by: Raphael Norwitz Message-Id: <20210325151217.262793-2-den-plotnikov@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/block/vhost-user-blk.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index b870a50e6b..1af95ec6aa 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -362,7 +362,18 @@ static void vhost_user_blk_disconnect(DeviceState *dev) vhost_dev_cleanup(&s->dev); } =20 -static void vhost_user_blk_event(void *opaque, QEMUChrEvent event); +static void vhost_user_blk_event(void *opaque, QEMUChrEvent event, + bool realized); + +static void vhost_user_blk_event_realize(void *opaque, QEMUChrEvent event) +{ + vhost_user_blk_event(opaque, event, false); +} + +static void vhost_user_blk_event_oper(void *opaque, QEMUChrEvent event) +{ + vhost_user_blk_event(opaque, event, true); +} =20 static void vhost_user_blk_chr_closed_bh(void *opaque) { @@ -371,11 +382,12 @@ static void vhost_user_blk_chr_closed_bh(void *opaque) VHostUserBlk *s =3D VHOST_USER_BLK(vdev); =20 vhost_user_blk_disconnect(dev); - qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, vhost_user_blk_event, - NULL, opaque, NULL, true); + qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, + vhost_user_blk_event_oper, NULL, opaque, NULL, true); } =20 -static void vhost_user_blk_event(void *opaque, QEMUChrEvent event) +static void vhost_user_blk_event(void *opaque, QEMUChrEvent event, + bool realized) { DeviceState *dev =3D opaque; VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -406,7 +418,7 @@ static void vhost_user_blk_event(void *opaque, QEMUChrE= vent event) * TODO: maybe it is a good idea to make the same fix * for other vhost-user devices. */ - if (runstate_is_running()) { + if (realized) { AioContext *ctx =3D qemu_get_current_aio_context(); =20 qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, NULL, NULL, @@ -473,8 +485,9 @@ static void vhost_user_blk_device_realize(DeviceState *= dev, Error **errp) s->vhost_vqs =3D g_new0(struct vhost_virtqueue, s->num_queues); s->connected =3D false; =20 - qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, vhost_user_blk_even= t, - NULL, (void *)dev, NULL, true); + qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, + vhost_user_blk_event_realize, NULL, (void *)d= ev, + NULL, true); =20 reconnect: if (qemu_chr_fe_wait_connected(&s->chardev, &err) < 0) { @@ -494,6 +507,10 @@ reconnect: goto reconnect; } =20 + /* we're fully initialized, now we can operate, so change the handler = */ + qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, + vhost_user_blk_event_oper, NULL, (void *)dev, + NULL, true); return; =20 virtio_err: --=20 MST From nobody Sat May 4 09:49:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617300441; cv=none; d=zohomail.com; s=zohoarc; b=dlVaxmrofQgaJGte8A1zFQF7DFXW5xC8eObveUFlVXrkmlVr5EBy8qOanhjoBLfnqNefPasflB6uAIv7wdqzofdX+VNrPE1GMfoEXQqNOYQ3WOrfxTeHMKBFdcfh4WU9PMCjXXyOxY89TL0BJ0Kw9H0TMfE+F7QSEXkd1f/3cCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617300441; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h65aMxnNkYxHbHEHjKmqfyD+Jd/8b7KZUucec9Sz/nI=; b=VjLlm1CovpIJQrUFqe1PWdjfygAUp5U/OdWsrQ4x/lqGCCGaosNkqUaou3lp4VhDcvqduN3v/mO7HBpqWj5zdMRSvr/u+2/AJlSsnXIiFk+sUgzloFNMxV4659ArdFRZia9Z90WOAUAgQxlsHqSrscDXnG/OhH54ogfIc6Ab4bk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617300441798877.4140241526744; Thu, 1 Apr 2021 11:07:21 -0700 (PDT) Received: from localhost ([::1]:46766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lS1iy-0004vV-Bp for importer@patchew.org; Thu, 01 Apr 2021 14:07:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1ew-0003CL-4T for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1er-0005un-Nn for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:09 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-245-7FWMNU_kPsmjminnAZP6ew-1; Thu, 01 Apr 2021 14:02:59 -0400 Received: by mail-wr1-f71.google.com with SMTP id n16so3133700wro.1 for ; Thu, 01 Apr 2021 11:02:59 -0700 (PDT) Received: from redhat.com ([2a10:800e:f0d3:0:b69b:9fb8:3947:5636]) by smtp.gmail.com with ESMTPSA id u9sm8389352wmq.30.2021.04.01.11.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 11:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617300182; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=h65aMxnNkYxHbHEHjKmqfyD+Jd/8b7KZUucec9Sz/nI=; b=HxfWBX2wneP/zgtBNmHCCgIWtpAepxbYOCO0A9cQKvmJnzo/9mYONjnPjf4cxliK3x03F/ eEGRK/vH7Ws8IEQ5igeLnXwwH2DwiUux7T2PTsjM3r3N9615fTMtdACLuhMukT721P3Hi4 EaO7aNauCeWbsUFzpp4gmCjJzzZTlTc= X-MC-Unique: 7FWMNU_kPsmjminnAZP6ew-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=h65aMxnNkYxHbHEHjKmqfyD+Jd/8b7KZUucec9Sz/nI=; b=A1lS8J9TrZ4zbCdWDjsxvDCthG8UpzrupasAC1gvJKLQmlI04vZQQ8+RiqN88nUJIn fsOnjX7l0mIEcfEEuOYpaNYuqH8lXxWuQgP6+Gu1DnOscx9Q8SNVf21WnNUP1k8n6RoT B85fvdqyR/5WQRfJBXqve6Oruxf1Y9J5onpyj3eHPaVKho4J4QDOrxLErNzQb3vwdjiY 48m7pmC9qNUQ4/Jq0VaPCkzel/0b0by6Av2L2WzBde45fYICIMRkOsVXj8oglXvDbjYQ hJjR14X1bmwC56f8clThCnNUDSKt0gpKU+UCtjbMTHvMg0Mjgq/282kVR6WWpBz09At5 o27w== X-Gm-Message-State: AOAM533csETjaMGbJkDDjjoLoJRD3OX9uwp6qJcpH6uZvTo9h8fO8wN3 TRlVFeIMdUIyEBR3fMpt8vkuL7SmFDmfYNfL+cHHhIOTh8cv9/yqL47yJ+sHTWFHvEUJKwBA+tC CVtq0ZhleGJsi355J6+YLEugtSndWW6Np1Y1Kqt4S7R/uoTIMk/M3YO5OQFD1 X-Received: by 2002:a1c:6241:: with SMTP id w62mr9195115wmb.79.1617300177875; Thu, 01 Apr 2021 11:02:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYzXeNCl9liCe54HbxD5jXdKA0VYL/ZhUdp0P7KfuqfjSXopdm4aFNF+4NZWZrkpmveQ6BsQ== X-Received: by 2002:a1c:6241:: with SMTP id w62mr9194999wmb.79.1617300176373; Thu, 01 Apr 2021 11:02:56 -0700 (PDT) Date: Thu, 1 Apr 2021 14:02:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 2/9] vhost-user-blk: perform immediate cleanup if disconnect on initialization Message-ID: <20210401180235.226321-3-mst@redhat.com> References: <20210401180235.226321-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210401180235.226321-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Max Reitz , Denis Plotnikov , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Denis Plotnikov Commit 4bcad76f4c39 ("vhost-user-blk: delay vhost_user_blk_disconnect") introduced postponing vhost_dev cleanup aiming to eliminate qemu aborts because of connection problems with vhost-blk daemon. However, it introdues a new problem. Now, any communication errors during execution of vhost_dev_init() called by vhost_user_blk_device_realiz= e() lead to qemu abort on assert in vhost_dev_get_config(). This happens because vhost_user_blk_disconnect() is postponed but it should have dropped s->connected flag by the time vhost_user_blk_device_realize() performs a new connection opening. On the connection opening, vhost_dev initialization in vhost_user_blk_connect() relies on s->connection flag and if it's not dropped, it skips vhost_dev initialization and returns with success. Then, vhost_user_blk_device_realize()'s execution flow goes to vhost_dev_get_config() where it's aborted on the assert. To fix the problem this patch adds immediate cleanup on device initialization(in vhost_user_blk_device_realize()) using different event handlers for initialization and operation introduced in the previous patch. On initialization (in vhost_user_blk_device_realize()) we fully control the initialization process. At that point, nobody can use the device since it isn't initialized and we don't need to postpone any cleanups, so we can do cleaup right away when there is a communication problem with the vhost-blk daemon. On operation we leave it as is, since the disconnect may happen when the device is in use, so the device users may want to use vhost_dev's data to do rollback before vhost_dev is re-initialized (e.g. in vhost_dev_set_lo= g()). Signed-off-by: Denis Plotnikov Reviewed-by: Raphael Norwitz Message-Id: <20210325151217.262793-3-den-plotnikov@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/block/vhost-user-blk.c | 48 +++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 1af95ec6aa..4e215f71f1 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -402,38 +402,38 @@ static void vhost_user_blk_event(void *opaque, QEMUCh= rEvent event, break; case CHR_EVENT_CLOSED: /* - * A close event may happen during a read/write, but vhost - * code assumes the vhost_dev remains setup, so delay the - * stop & clear. There are two possible paths to hit this - * disconnect event: - * 1. When VM is in the RUN_STATE_PRELAUNCH state. The - * vhost_user_blk_device_realize() is a caller. - * 2. In tha main loop phase after VM start. - * - * For p2 the disconnect event will be delayed. We can't - * do the same for p1, because we are not running the loop - * at this moment. So just skip this step and perform - * disconnect in the caller function. - * - * TODO: maybe it is a good idea to make the same fix - * for other vhost-user devices. + * Closing the connection should happen differently on device + * initialization and operation stages. + * On initalization, we want to re-start vhost_dev initialization + * from the very beginning right away when the connection is close= d, + * so we clean up vhost_dev on each connection closing. + * On operation, we want to postpone vhost_dev cleanup to let the + * other code perform its own cleanup sequence using vhost_dev data + * (e.g. vhost_dev_set_log). */ if (realized) { + /* + * A close event may happen during a read/write, but vhost + * code assumes the vhost_dev remains setup, so delay the + * stop & clear. + */ AioContext *ctx =3D qemu_get_current_aio_context(); =20 qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, NULL, NULL, NULL, NULL, false); aio_bh_schedule_oneshot(ctx, vhost_user_blk_chr_closed_bh, opa= que); - } =20 - /* - * Move vhost device to the stopped state. The vhost-user device - * will be clean up and disconnected in BH. This can be useful in - * the vhost migration code. If disconnect was caught there is an - * option for the general vhost code to get the dev state without - * knowing its type (in this case vhost-user). - */ - s->dev.started =3D false; + /* + * Move vhost device to the stopped state. The vhost-user devi= ce + * will be clean up and disconnected in BH. This can be useful= in + * the vhost migration code. If disconnect was caught there is= an + * option for the general vhost code to get the dev state with= out + * knowing its type (in this case vhost-user). + */ + s->dev.started =3D false; + } else { + vhost_user_blk_disconnect(dev); + } break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: --=20 MST From nobody Sat May 4 09:49:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617300679; cv=none; d=zohomail.com; s=zohoarc; b=jM0dQv+2Gg27XCKIrOmQtbOIsiq9MzkU2oXToK9Jzel817Wj02lOcH/nI5UJLTP+DMdv4y3HoaGOPX527SGEXBQeRw9hIV4Urpb3rZSuzqJAdMMXXOxa+wwIbbEn4d+1yCBNC8wkW8pruVU2uxCAJ5x9VtEgV2pPPYPZxon74jM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617300679; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6V9hNvZy38Q/75ynvyJjF+U219yJmq8sKjsSeS+YHDU=; b=Vw7xVKU0yMzxnBfrUcMpXC3s7qM5LiFTesW6nozevaw1/KPbmyMQJX1hTsveRNayB7S9KeYD7Iao+MW7Bo806C1md3aIQs79f1h/wU78v7vsEwa7RHnluYJUHEOebl3oVML4mrfYFmgmLruqXWY8dpRTGBm70CsX7pi66G5tYto= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617300679867731.8528031400026; Thu, 1 Apr 2021 11:11:19 -0700 (PDT) Received: from localhost ([::1]:54794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lS1mn-0008RR-4M for importer@patchew.org; Thu, 01 Apr 2021 14:11:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1ez-0003ED-7m for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59008) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1er-0005vH-No for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:12 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-562-taudAFxyNISkotHW0vu81g-1; Thu, 01 Apr 2021 14:03:01 -0400 Received: by mail-wm1-f70.google.com with SMTP id v5so1588312wml.9 for ; Thu, 01 Apr 2021 11:03:01 -0700 (PDT) Received: from redhat.com ([2a10:800e:f0d3:0:b69b:9fb8:3947:5636]) by smtp.gmail.com with ESMTPSA id s21sm9267910wmc.10.2021.04.01.11.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 11:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617300183; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6V9hNvZy38Q/75ynvyJjF+U219yJmq8sKjsSeS+YHDU=; b=IuucxJiOzFt7sXmYtmGMpFWcW3kzc8AizmKCBx7ebybHLflJkQ0zm0wKLWLucRaRgpbZBe VlDMiAvaYal1+njNGDCIIo8tIT/vtkamAwGXkqtjRUzO93oWYM5+gJ/8MeGtGYaWmJqUMJ eJS08cyQnXyhD+5fkbH6DZM3nKRk1dw= X-MC-Unique: taudAFxyNISkotHW0vu81g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6V9hNvZy38Q/75ynvyJjF+U219yJmq8sKjsSeS+YHDU=; b=DFofO01z/vhZ1WY/Q1JvLiJmcWp9LXpmi2DO1XIy/+CgXVgkt2dpeXeNFZhIwMUV4Q 8xstz5KioQ/6D+z4Md6QnAKQwQxl6VST/dE8ZAYmEikcGI46SAycB5V1lvo5pabJl6rX kOZQxJ95pEJQOES2TyxMdo4EMNDpkuQpBoEEv0c4V13ZSdm69eFXdqPoykRknV3+T9Hp QV002CbztsvBdufHSJC/ZayIAEtF+FyGqhOVmMku7lG2AmqVKMmTUTyxNBCqBTVJxKxp CU2Zld4enM8Ng0bNtnbMF/5c/NkzXoWv/CMr5SlhMMpsQET8orNSdrucNHBH7I6xazSP 4YYA== X-Gm-Message-State: AOAM533lIHTTZYkDf+bcJx2cgRGCaVhwGUJzSza7Jq8Pf4NtQYzBEOSu ZSW96EvDa1sge2KVOzlN1N7p8FqYm7xFRuyJci7s4tWHxYXyxspLWJGMHRXg04kAN/POw7r6Hmc tzAkqQ1Vcbw8xx4ugpG8pZpZPNt3OpKaTmadJ8g8zvZzolIZdZQ43SQYtlKxU X-Received: by 2002:a7b:c0c7:: with SMTP id s7mr9338624wmh.5.1617300180184; Thu, 01 Apr 2021 11:03:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGDBTpzGaYBTu0by4GaZcXKuLZ8Pj6n4vcRTyYzt4n5I1qknP9ryrHv1wEz31aGN3UiZaxyw== X-Received: by 2002:a7b:c0c7:: with SMTP id s7mr9338606wmh.5.1617300179999; Thu, 01 Apr 2021 11:02:59 -0700 (PDT) Date: Thu, 1 Apr 2021 14:02:57 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 3/9] vhost-user-blk: add immediate cleanup on shutdown Message-ID: <20210401180235.226321-4-mst@redhat.com> References: <20210401180235.226321-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210401180235.226321-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Max Reitz , Denis Plotnikov , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Denis Plotnikov Qemu crashes on shutdown if the chardev used by vhost-user-blk has been finalized before the vhost-user-blk. This happens with char-socket chardev operating in the listening mode (serv= er). The char-socket chardev emits "close" event at the end of finalizing when its internal data is destroyed. This calls vhost-user-blk event handler which in turn tries to manipulate with destroyed chardev by setting an empty event handler for vhost-user-blk cleanup postponing. This patch separates the shutdown case from the cleanup postponing removing the need to set an event handler. Signed-off-by: Denis Plotnikov Message-Id: <20210325151217.262793-4-den-plotnikov@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/block/vhost-user-blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 4e215f71f1..0b5b9d44cd 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -411,7 +411,7 @@ static void vhost_user_blk_event(void *opaque, QEMUChrE= vent event, * other code perform its own cleanup sequence using vhost_dev data * (e.g. vhost_dev_set_log). */ - if (realized) { + if (realized && !runstate_check(RUN_STATE_SHUTDOWN)) { /* * A close event may happen during a read/write, but vhost * code assumes the vhost_dev remains setup, so delay the --=20 MST From nobody Sat May 4 09:49:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617300669; cv=none; d=zohomail.com; s=zohoarc; b=A2rC2/gTnylhkBbH64oyZDqA0NnHKuPHNyRbAd+Ch9vgQSCcfAOLcYNzq9yPO4cwHT51gqdHhngaY16RFsqu86zgLe5QEELbtFqKH/7dpqiVDFORhyTIjrRIHyimTUL1LZgCPPj2KuMP9DDOgRQ6lM5PvjjxFmYDwC3kvr77sis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617300669; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FSnptZrRbQSuaqOya/Yrl1bJW+NQWsKSQuzTI2/BKT0=; b=B4xyHakWHgC980ovPbN3uoLgZNa8oSInFxHbsutN7mafjspVhmOS3UIEFO43rVw4uoS6iVs3R3kEI6iYxIz4/cjf4y5m184nLyepAwXS3DJCsjMGs1T3Z2nzPijApMtGsOQklAFypDthp9qi1cRPRzMsBNIJ4rJq3AqdtH6IF08= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617300669509758.1021218377248; Thu, 1 Apr 2021 11:11:09 -0700 (PDT) Received: from localhost ([::1]:54384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lS1me-0008Gt-Dk for importer@patchew.org; Thu, 01 Apr 2021 14:11:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1ey-0003DQ-LH for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45702) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1et-0005vQ-TT for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:12 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-515-6cNtEhoeNuS8bxtHXROB7w-1; Thu, 01 Apr 2021 14:03:03 -0400 Received: by mail-wr1-f72.google.com with SMTP id x9so3098884wro.9 for ; Thu, 01 Apr 2021 11:03:03 -0700 (PDT) Received: from redhat.com ([2a10:800e:f0d3:0:b69b:9fb8:3947:5636]) by smtp.gmail.com with ESMTPSA id g5sm10872896wrq.30.2021.04.01.11.03.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 11:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617300185; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FSnptZrRbQSuaqOya/Yrl1bJW+NQWsKSQuzTI2/BKT0=; b=DNPyYaUaqucFrFHgbCbNj3dZTU0fZMtXhn4EdeDwNhsnCbfUOwJtyZ59LPiqb3A2tBS1pe GmJdLa9AbQaMB77ZYl3toIpb6kzwxKrkst4UY+MEYU5cL+FKCutXhKNmHrs9hxPZ+u7Ne0 BxOm1zidpbsXWiI8Wkog//6NPHcQH/c= X-MC-Unique: 6cNtEhoeNuS8bxtHXROB7w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FSnptZrRbQSuaqOya/Yrl1bJW+NQWsKSQuzTI2/BKT0=; b=gvfNFuERgkALq/2i7IteqKHaxd8lTTfvow1f0Gt4rPYqawWLKVjad5k0sbRtLC3G6U PYmRnxOac0YfW42P/z8baPM1qc2zLipYmf+2VIJOVBz/jNNqECxKkhyY9/ULQMzK2l8j /wBkMkxFOD3QWsnN9gngI4a76I/ximQamsHf6ZsRpFdZ0V4rVSdajJkyVoOUmSrGogd0 VbNg1eggP4vkn0FEDZTotuxvlhRzrXaFUzn6gYVHENOAU+fz1eIGToUA8Tl2UsCsaVA4 t3S4ggRl28F7tvIOmTnl4GDMRj+MpjynLTNg3Zyyq2HYTppU6IJworw3zTNJMYS9nHQG hMOw== X-Gm-Message-State: AOAM531P8x+6SEi4WhzCrx3smekjzVNlIjhX+xwPJWovHX59flG5ta5c q85/DSX0/7fE+PALEGKjwlBLn1vvnv9HckgQm9RA5YnrcYfYBvFEAgzgMmr6hgQ0ktvGxdj8taY qexY70VXrvb6cv32wIYDTqZEcd3Mr/19eHsvA7/4KecD4Ef7UtA98OWKC4V5b X-Received: by 2002:adf:fd48:: with SMTP id h8mr11283892wrs.229.1617300182322; Thu, 01 Apr 2021 11:03:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6XFfyOhC9K3KkvbT7mpNGSqnm4SJuwQizz08NIEYTrlTG6/ypcvuDzybvkFaxnVE7pRLJRw== X-Received: by 2002:adf:fd48:: with SMTP id h8mr11283870wrs.229.1617300182157; Thu, 01 Apr 2021 11:03:02 -0700 (PDT) Date: Thu, 1 Apr 2021 14:03:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 4/9] virtio-pci: add check for vdev in virtio_pci_isr_read Message-ID: <20210401180235.226321-5-mst@redhat.com> References: <20210401180235.226321-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210401180235.226321-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Yuri Benditovich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Yuri Benditovich https://bugzilla.redhat.com/show_bug.cgi?id=3D1743098 This commit completes the solution of segfault in hot unplug flow (by commit ccec7e9603f446fe75c6c563ba335c00cfda6a06). Added missing check for vdev in virtio_pci_isr_read. Typical stack of crash: virtio_pci_isr_read ../hw/virtio/virtio-pci.c:1365 with proxy-vdev =3D 0 memory_region_read_accessor at ../softmmu/memory.c:442 access_with_adjusted_size at ../softmmu/memory.c:552 memory_region_dispatch_read1 at ../softmmu/memory.c:1420 memory_region_dispatch_read at ../softmmu/memory.c:1449 flatview_read_continue at ../softmmu/physmem.c:2822 flatview_read at ../softmmu/physmem.c:2862 address_space_read_full at ../softmmu/physmem.c:2875 Signed-off-by: Yuri Benditovich Message-Id: <20210315115937.14286-2-yuri.benditovich@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 883045a223..4a3dcee771 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1364,9 +1364,14 @@ static uint64_t virtio_pci_isr_read(void *opaque, hw= addr addr, { VirtIOPCIProxy *proxy =3D opaque; VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); - uint64_t val =3D qatomic_xchg(&vdev->isr, 0); - pci_irq_deassert(&proxy->pci_dev); + uint64_t val; =20 + if (vdev =3D=3D NULL) { + return 0; + } + + val =3D qatomic_xchg(&vdev->isr, 0); + pci_irq_deassert(&proxy->pci_dev); return val; } =20 --=20 MST From nobody Sat May 4 09:49:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617300673; cv=none; d=zohomail.com; s=zohoarc; b=l4VmoblSbGxdEkMKLFEne0S9aw7zKR48zDgc/g8DMuPwDqBTB1ZAZ1fJcQyNjvg98MRS+Ytdhb8KtDvVN9HoMsAZ4wtPIUejiKHG4ZznB61gdC9WdA+/q90cT/mAec5FAsOy2NuPbdsWH6Z54RjSagV7RDfm7SBfQ0bi8SZcxGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617300673; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ez/MMpFKibI09ROEX070H6IVA/s8veikIBmthUwRu2A=; b=dgQbzB8GwxlOcld5spAWpH+L/PI5tHazSK/yTZERtiG17IFkFcZHqh28nIzjeVGOPnveZ6kPVw6UtyVJvtZ58mETcbWvAMq7Gk28RqKPSyQb0/s59PjbmLWAVlvUndsKmW1gKyX9CdHZ+2iCKUXlgaI4O3Sd5PnRgIGvrODyjEc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617300673200222.13630933312766; Thu, 1 Apr 2021 11:11:13 -0700 (PDT) Received: from localhost ([::1]:54708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lS1mi-0008PZ-4s for importer@patchew.org; Thu, 01 Apr 2021 14:11:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1ez-0003Eu-IZ for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34824) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1ev-0005wo-RU for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:13 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-446-a2LRCMlTN0mFZDGeqd8WyA-1; Thu, 01 Apr 2021 14:03:06 -0400 Received: by mail-wm1-f69.google.com with SMTP id a65so1031634wmh.1 for ; Thu, 01 Apr 2021 11:03:05 -0700 (PDT) Received: from redhat.com ([2a10:800e:f0d3:0:b69b:9fb8:3947:5636]) by smtp.gmail.com with ESMTPSA id h62sm11192013wmf.37.2021.04.01.11.03.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 11:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617300188; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ez/MMpFKibI09ROEX070H6IVA/s8veikIBmthUwRu2A=; b=BPGDykdRj/N/UAAn6gJS25eXXv9VXYvrRClwLxm/P48rjQ3ImZR3OwkRX3NzfbJ4YwmL5G 8h5EMqIMCMnT4xDB4qQPP6GjiaZnz1ZrKB490jng7hvaFu3eK/MOUdODpwM8l0nce8sDev WA8BckFKlMR8zEmASSefsvJ0wRYGh/Q= X-MC-Unique: a2LRCMlTN0mFZDGeqd8WyA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ez/MMpFKibI09ROEX070H6IVA/s8veikIBmthUwRu2A=; b=mF38wJ0BMrxou48ePwS/9yN9T4mWxtKGaHHavaZJldhaxX4+3H00CX/jbduVU3nyPG 1wyhwmQ/c3ae1XQZ4oMBhjgf9hON0O1/f8tR/1AyHKuTbjptxIJkOssDvgSoTOJtu9qc zx7jJ25J1sml1xCYsWrICgb3DYCyNIO/LJ84nZTbAhRsMDoABLjSOGa4BsYOOglFA/t4 wk/U0CkV+taQTulFsaucKwtZbU3Bl2m+RXnAZ9dpTX+WzajlV44zudgyvL9c7L4UOEse tZm9pdSEp26lzEuTgRAEhp96NbbcP7a7SM4YQGVVyix6acSbaS2pRkfQKehvfWlHdyQb 1h5g== X-Gm-Message-State: AOAM533LFjs5riHSoHaHdqi4fTGZdCzhYaPyE/PtGQlta4r2IbOiYMxs vzkz7BZUfvSxqrm6I/PDT2yliGJzZ+jkcBMJcF2PkeX9v7aNIDeclHSHFsuWrDLolDSjEmiyhb3 aiCGtnL4Nc6aLJMgfmSxKghMit4RvCuuY3kFRhz24JtmFQoL/nMCKZdwVqj6m X-Received: by 2002:a05:600c:b50:: with SMTP id k16mr9355731wmr.149.1617300184765; Thu, 01 Apr 2021 11:03:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+TMroJzZdImKKKBNgjXCHNqXYk8fl6/HbHvibVntSvAgOW4J0lc5+hAFAMxVpGl+X7KfiLw== X-Received: by 2002:a05:600c:b50:: with SMTP id k16mr9355715wmr.149.1617300184531; Thu, 01 Apr 2021 11:03:04 -0700 (PDT) Date: Thu, 1 Apr 2021 14:03:02 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 5/9] virtio-pci: remove explicit initialization of val Message-ID: <20210401180235.226321-6-mst@redhat.com> References: <20210401180235.226321-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210401180235.226321-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Yuri Benditovich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Yuri Benditovich The value is assigned later in this procedure. Signed-off-by: Yuri Benditovich Message-Id: <20210315115937.14286-3-yuri.benditovich@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 4a3dcee771..c1b67cf6fc 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1385,10 +1385,10 @@ static uint64_t virtio_pci_device_read(void *opaque= , hwaddr addr, { VirtIOPCIProxy *proxy =3D opaque; VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); - uint64_t val =3D 0; + uint64_t val; =20 if (vdev =3D=3D NULL) { - return val; + return 0; } =20 switch (size) { @@ -1401,6 +1401,9 @@ static uint64_t virtio_pci_device_read(void *opaque, = hwaddr addr, case 4: val =3D virtio_config_modern_readl(vdev, addr); break; + default: + val =3D 0; + break; } return val; } --=20 MST From nobody Sat May 4 09:49:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617301035; cv=none; d=zohomail.com; s=zohoarc; b=Ujp7QrUr5r3VpvJcapAjIfIAm9A0arjA7IFU5zf9rHj6yneh73S7qrm+JtnzTL46ZUZZbexJCb5P2NCiW6fWMzf1Ww8h4ln1OMyImNkx/pokwYke1Fc7XA1Q9g27aKc26CuDvCyT+Rc8uwn8KNiQEAhJ5G9WxRc0sB53picJZIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617301035; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Cc1ejjyRsgD3Z98rDH9YyBq+JCXKSN4A99erroM1Vog=; b=cSfeSx0a9AQEVXImMrVSOCzNKQOxH54PaP6OgfxSjGxI2AM+wzIrRDxDLEVoQ/YZt5gmi5CfOwpPDZ4B7qmGvtsVtdT2woj2cKtOht4lKPvzdxeBUIAUov1eJJX4MkHEde4TAlEvF2+naG+iaHJkc7IbdGUPcPGG1zHJ5DLIZ7Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617301035055416.74111855626904; Thu, 1 Apr 2021 11:17:15 -0700 (PDT) Received: from localhost ([::1]:35108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lS1sX-0003rM-Sc for importer@patchew.org; Thu, 01 Apr 2021 14:17:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1f4-0003PG-SA for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29120) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1ey-0005xy-OX for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:18 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-489-K9JG0v4pN56_6LuYuJDjIg-1; Thu, 01 Apr 2021 14:03:09 -0400 Received: by mail-wr1-f70.google.com with SMTP id s10so3130696wre.0 for ; Thu, 01 Apr 2021 11:03:08 -0700 (PDT) Received: from redhat.com ([2a10:800e:f0d3:0:b69b:9fb8:3947:5636]) by smtp.gmail.com with ESMTPSA id n1sm13964745wro.36.2021.04.01.11.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 11:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617300192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Cc1ejjyRsgD3Z98rDH9YyBq+JCXKSN4A99erroM1Vog=; b=O9VObFiLRrWoUM/CrlkrTS6k1nY1Nd5QqyzCpAeaQX9YvckNqqcX1I2gryakJm2624kJFY R/Sg6FlsHqBpAIJc7z/WSQzHqZHBtTFgAi6uFZb/wR8s7gQ8l9HHEh0JcS9mFqKMiuOFMX CVmTKfqc3BeDZnFd84nxpcowg8/1SzQ= X-MC-Unique: K9JG0v4pN56_6LuYuJDjIg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Cc1ejjyRsgD3Z98rDH9YyBq+JCXKSN4A99erroM1Vog=; b=fp0ypw8Z6nm8ePktFDOnaDetlweQ11vKrdKcDLdF8wHb0kUmllDH09Xlb8TP78A7KX Ee3s4xutY/vaQ1fNYQBoWKC1tuN5FaJeAeaNh2IzbNs/hFd694vFj04Y3+uUMvy2WjMa kJPOrEKMHeulwwAup1QNXxTdBrsLk2zKt4hUu5bCyuv3hIhJ46H8ptpFmbgAPzDg/kPy kxckrN8v/Z476mFjtAFzh4Jq8y2XZ9WdDu9ctrZ6ldRnO4+zJqQB/WhRQrvP/mXfAvVL fcsSmEc2ziETCQcAE/3nqBSRdKtlMJ8a+LQXGwvzDoB2K1bLwDPfLgofOzbElVVnhmoi dS6Q== X-Gm-Message-State: AOAM530BbpkH18iRSdo4INVdpc/wPY9toi5VJL0i1QCC8F7q8t30e4wK jwsc5fKZ8wgXjUL30q3GEbMV8NjC3tCfHG13FKXhmXLqC7HlHM4UFywXPPU0VAUMZGj6N+qYhX4 EI40MmgaBHiCOf1RnI4nSFvhEGflhRC/BjSwQchvkSi+zr+S5bWr5j24VGA1i X-Received: by 2002:a1c:5f54:: with SMTP id t81mr9275804wmb.84.1617300187202; Thu, 01 Apr 2021 11:03:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy35eNu/CZLDeYF58L+vfZzFv0LE3SsTu/U5aXJT2A2X3o60QQPADSV9TvkNY8GjtJsAVcNEw== X-Received: by 2002:a1c:5f54:: with SMTP id t81mr9275782wmb.84.1617300187009; Thu, 01 Apr 2021 11:03:07 -0700 (PDT) Date: Thu, 1 Apr 2021 14:03:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 6/9] acpi/piix4: reinitialize acpi PM device on reset Message-ID: <20210401180235.226321-7-mst@redhat.com> References: <20210401180235.226321-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210401180235.226321-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Isaku Yamahata , Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Reinoud Zandijk , Igor Mammedov , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Isaku Yamahata Commit 6be8cf56bc8b made sure that SCI is enabled in PM1.CNT on reset in acpi_only mode by modifying acpi_pm1_cnt_reset() and that worked for q35 as expected. The function was introduced by commit eaba51c573a (acpi, acpi_piix, vt82c686: factor out PM1_CNT logic) that forgot to actually call it at piix4 reset time and as result SCI_EN wasn't set as was expected by 6be8cf56bc8b in acpi_only mode. So Windows crashes when it notices that SCI_EN is not set and FADT is not providing information about how to enable it anymore. Reproducer: qemu-system-x86_64 -enable-kvm -M pc-i440fx-6.0,smm=3Doff -cdrom any_win= dows_10x64.iso Fix it by calling acpi_pm1_cnt_reset() at piix4 reset time. Occasionally this patch adds reset acpi PM related registers on piix4 reset time and de-assert sci. piix4_pm_realize() initializes acpi pm tmr, evt, cnt and gpe. Reset them on device reset. pm_reset() in ich9.c correctly calls corresponding reset functions. Fixes: 6be8cf56bc8b (acpi/core: always set SCI_EN when SMM isn't supported) Reported-by: Reinoud Zandijk Co-developed-by: Igor Mammedov Signed-off-by: Igor Mammedov Signed-off-by: Isaku Yamahata Message-Id: <8a5bbd19727045ec863523830078dd4ca63f6a9a.1616532563.git.isaku.= yamahata@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/piix4.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 6056d51667..8f8b0e95e5 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -326,6 +326,13 @@ static void piix4_pm_reset(DeviceState *dev) /* Mark SMM as already inited (until KVM supports SMM). */ pci_conf[0x5B] =3D 0x02; } + + acpi_pm1_evt_reset(&s->ar); + acpi_pm1_cnt_reset(&s->ar); + acpi_pm_tmr_reset(&s->ar); + acpi_gpe_reset(&s->ar); + acpi_update_sci(&s->ar, s->irq); + pm_io_space_update(s); acpi_pcihp_reset(&s->acpi_pci_hotplug, !s->use_acpi_root_pci_hotplug); } --=20 MST From nobody Sat May 4 09:49:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617301019; cv=none; d=zohomail.com; s=zohoarc; b=Cl+G7DLz8waTvKruDCQM9xdpKfY8p6YFOixACG0SPCcfu3OjcvARyE3l0DP0sonhl9K3y9iVHL9KFPu3SG8WgjuNakQtbU2IgjMV9L5qCj83mY0OxTb9Us4EyxVt5fHIMEfrFIBPOUpcGpdE9GtsUFKKv9Q51ce5/d/LV603xHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617301019; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XZxETA9xkUI8DHODBhav7aR/O/iVcPfZSSiEn8GIYWg=; b=k00+Ql1tJnSdh3RkgkgHv7NQSAVOQlOnZ3QKGYfOxQWykOtG1Cyz3HyLl6VBj8+4sEjcX8cL0cubT025ZuvdGOllCwyCpjaQFOaPdre75OqiHX7mQgHFBuexZaZwAxJrh0yQ5SxnJHpbdEbd1ujJn17008nMPJxF12LBfQ54i0I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617301019489852.2785562232117; Thu, 1 Apr 2021 11:16:59 -0700 (PDT) Received: from localhost ([::1]:34732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lS1sI-0003h2-EH for importer@patchew.org; Thu, 01 Apr 2021 14:16:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1f5-0003QL-Jo for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60534) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1f1-000604-Vr for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:19 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-230-kkDSjYLDMGyDjW_X73ZVXQ-1; Thu, 01 Apr 2021 14:03:11 -0400 Received: by mail-wr1-f70.google.com with SMTP id e10so3095574wru.13 for ; Thu, 01 Apr 2021 11:03:11 -0700 (PDT) Received: from redhat.com ([2a10:800e:f0d3:0:b69b:9fb8:3947:5636]) by smtp.gmail.com with ESMTPSA id m9sm11272840wro.52.2021.04.01.11.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 11:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617300195; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XZxETA9xkUI8DHODBhav7aR/O/iVcPfZSSiEn8GIYWg=; b=FJ1ym/SiY7qpu+IeJhzLLBPbdNQ2kaWnAau9gea30OVt8ITUMqiIdncN1z7SWhlYrX0c69 /PaWtI5FeYPAlsE4H1auSPY2pMEim276z99U6rVzjeTeETgcrtV0zA9+D+QJhF1qBRYQSf taeDzj2HLMyTn7lffAhuLSxdSSnqtEc= X-MC-Unique: kkDSjYLDMGyDjW_X73ZVXQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=XZxETA9xkUI8DHODBhav7aR/O/iVcPfZSSiEn8GIYWg=; b=VugOHNID1PPxURU4Cn8qS9Y6I+PfiemrrJRGnf32PJvV7BIOVrwpsdaTACwyPJBmlw iNCiRvhBtEbSJnQfVFsoPiEoIF1oeJP8OWctCnvOaBzsrBN7ZYKPScMWiZ1cl9OOQtiT 8Dztyos4hhvqwhmZe/jwrLlGStXIfvm0GEfcjAmqvgRGbVPHatnpYCMJ/AV92q4ZY2sq vRCVtAReM9GtOKWLWsWjIEnIHen2rfCta7Cpyg2wJLQVK8dMZyEVwxMCrysn0z/8Pw0I v8v7P6kn6Y7LXNGO+6yndiB+jpeQUqocbBanVXR5PGJYPVrLuDt+aYSY5Rq3S9P4CKRY /92w== X-Gm-Message-State: AOAM532LXU7UmpvswATTCfzhRS7LYZ0/paKASZ3b550H9P0+k1g9kcHQ 7mEzk4h0ihqmMMWjjrBrW412y40mXAWET3WbXPB4Vwof3ajJ1VwAh9z+it7MXLEPGquRCad40c0 8sWd7+fK74FipSfcQ02HypFocEFHdpYA7FRti9US3CBW4MRNdPgBW7Ec02thh X-Received: by 2002:a5d:4fca:: with SMTP id h10mr11577267wrw.70.1617300190366; Thu, 01 Apr 2021 11:03:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxu7trJFGO0P/GheHrc9mpZGvXsP04ONlfeXadPMaqkyowx/882HFtyVuEFbfX9A7W089qQuA== X-Received: by 2002:a5d:4fca:: with SMTP id h10mr11577246wrw.70.1617300190192; Thu, 01 Apr 2021 11:03:10 -0700 (PDT) Date: Thu, 1 Apr 2021 14:03:07 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 7/9] vt82c686.c: don't raise SCI when PCI_INTERRUPT_PIN isn't setup Message-ID: <20210401180235.226321-8-mst@redhat.com> References: <20210401180235.226321-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210401180235.226321-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Isaku Yamahata , Peter Maydell , Huacai Chen , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Isaku Yamahata Without this patch, the following patch will triger clan runtime sanitizer warnings as follows. This patch proactively works around it. I leave a correct fix to v582c686.c maintainerfix as I'm not sure about fuloong2e device model. > MALLOC_PERTURB_=3D${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))} > QTEST_QEMU_IMG=3D./qemu-img > G_TEST_DBUS_DAEMON=3D/home/petmay01/linaro/qemu-for-merges/tests/dbus-vms= tate-daemon.sh > QTEST_QEMU_BINARY=3D./qemu-system-mips64el tests/qtest/qom-test --tap -k > PASS 1 qtest-mips64el/qom-test /mips64el/qom/loongson3-virt > PASS 2 qtest-mips64el/qom-test /mips64el/qom/none > PASS 3 qtest-mips64el/qom-test /mips64el/qom/magnum > PASS 4 qtest-mips64el/qom-test /mips64el/qom/mipssim > PASS 5 qtest-mips64el/qom-test /mips64el/qom/malta > ../../hw/pci/pci.c:252:30: runtime error: shift exponent -1 is negative > PASS 6 qtest-mips64el/qom-test /mips64el/qom/fuloong2e > PASS 7 qtest-mips64el/qom-test /mips64el/qom/boston > PASS 8 qtest-mips64el/qom-test /mips64el/qom/pica61 > > and similarly for eg > > MALLOC_PERTURB_=3D${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))} > QTEST_QEMU_IMG=3D./qemu-img > G_TEST_DBUS_DAEMON=3D/home/petmay01/linaro/qemu-for-merges/tests/dbus-vms= tate-daemon.sh > QTEST_QEMU_BINARY=3D./qemu-system-mips64el tests/qtest/endianness-test > --tap -k > ../../hw/pci/pci.c:252:30: runtime error: shift exponent -1 is negative > PASS 1 qtest-mips64el/endianness-test /mips64el/endianness/fuloong2e > ../../hw/pci/pci.c:252:30: runtime error: shift exponent -1 is negative > PASS 2 qtest-mips64el/endianness-test /mips64el/endianness/split/fuloong2e > ../../hw/pci/pci.c:252:30: runtime error: shift exponent -1 is negative > PASS 3 qtest-mips64el/endianness-test /mips64el/endianness/combine/fuloon= g2e Cc: BALATON Zoltan Cc: Huacai Chen Cc: "Philippe Mathieu-Daud=C3=A9" Cc: Jiaxun Yang Reported-by: Peter Maydell Signed-off-by: Isaku Yamahata Message-Id: <62a5fc69e453fb848bfd4794bae1852a75af73c5.1616532563.git.isaku.= yamahata@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/isa/vt82c686.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 05d084f698..f0fb309f12 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -144,7 +144,18 @@ static void pm_update_sci(ViaPMState *s) ACPI_BITMASK_POWER_BUTTON_ENABLE | ACPI_BITMASK_GLOBAL_LOCK_ENABLE | ACPI_BITMASK_TIMER_ENABLE)) !=3D 0); - pci_set_irq(&s->dev, sci_level); + if (pci_get_byte(s->dev.config + PCI_INTERRUPT_PIN)) { + /* + * FIXME: + * Fix device model that realizes this PM device and remove + * this work around. + * The device model should wire SCI and setup + * PCI_INTERRUPT_PIN properly. + * If PIN# =3D 0(interrupt pin isn't used), don't raise SCI as + * work around. + */ + pci_set_irq(&s->dev, sci_level); + } /* schedule a timer interruption if needed */ acpi_pm_tmr_update(&s->ar, (s->ar.pm1.evt.en & ACPI_BITMASK_TIMER_ENAB= LE) && !(pmsts & ACPI_BITMASK_TIMER_STATUS)); --=20 MST From nobody Sat May 4 09:49:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617300449; cv=none; d=zohomail.com; s=zohoarc; b=hEB3mrfqqyG6UyV87wpSEVEO2jUh7Yv8QA7UFLdB3SzTfzqSeODpEr6LkIGAfpPLxeoi8cjE2EnQU6HuuRwDrL8SHeQ4BykVWWmUM7McPfVYxCz9w7IfnJq5LWFJJPGOyrDqDbS7hAWDFL7ZqcTLaB210+x8zGdniDUZqWaKMoA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617300449; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RKCnnXenvH7r51iGFAf4L/sGjea+/dMJumwisHEHz1c=; b=f3NR98UO6Eni198f4lxkmHN0Um2cH119zCgAif0Yu6PClrkt2+6G8gMfyYbQl/imQbCPH5ONQRNNZDlB2OQVTcaDl+6NjPkz7sTqxHbIt4x9keYLtDLbjTW5EIxNfal8UohsJgnVY6e4/jf4uoKkV58V662UsFImaQmjFgfEFN8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617300449917311.3851292757223; Thu, 1 Apr 2021 11:07:29 -0700 (PDT) Received: from localhost ([::1]:47550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lS1j6-0005N3-N6 for importer@patchew.org; Thu, 01 Apr 2021 14:07:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1f7-0003SB-5k for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42984) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1f4-00062X-H4 for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:20 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-467-iACARY8hMnSEds49KZuSYg-1; Thu, 01 Apr 2021 14:03:15 -0400 Received: by mail-wr1-f71.google.com with SMTP id h30so3127864wrh.10 for ; Thu, 01 Apr 2021 11:03:15 -0700 (PDT) Received: from redhat.com ([2a10:800e:f0d3:0:b69b:9fb8:3947:5636]) by smtp.gmail.com with ESMTPSA id s21sm9268676wmc.10.2021.04.01.11.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 11:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617300197; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RKCnnXenvH7r51iGFAf4L/sGjea+/dMJumwisHEHz1c=; b=J9yULXYKiJY6Ro/5jLFcXwp4dlvCHU0DKZhJiwS75i5gbs5sae29da7X73js034b+XO/he qL1A5FVTDcBzVsPnRFnZjszic2zPvfSE/bv+IGq3nbiNtn5rKGZ83djg/2wVrVkSSbMTFx mhV/2eEpCoX40TLqazdsb/nTraB7sFs= X-MC-Unique: iACARY8hMnSEds49KZuSYg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=RKCnnXenvH7r51iGFAf4L/sGjea+/dMJumwisHEHz1c=; b=g9p7lXqjnuowntMYlWiPDbIwUOE6qsyz4VXq4izf1DEI6G6KWqaFyzKj8BdSXkldQy Nm42k8w54X7iTIoGZABGV/CwemhbThUpBkE3wNHvQGV0UbTkhSo89E06jd7HrdZXKqjY GWv+Gy1fzmydxFK4MfCM/abOK2VLOea/haZmg3c7aE2BA/MVZymF4ShN/FMeHLUdxFik WyZFYnfF3lrhp7dMkjW+t95DlswFD3Su3biEEnRtbt4WxX43j/RiptA1kvPsEzehCiQ6 h3c+IMPeZvsz5j2zYRkv9om3ZB0ksw/3Wcf978upgm3uS429t6JWCiIZLLzHTr4VHNQr kB8w== X-Gm-Message-State: AOAM532F/ZlFeA/oJYFHpF1eNBFkvEru1+OEnjoWubsJZaNvBz9nFfvZ gi3GGA86V1Fbvm4JIce2Gn8tC35YB2/SViBAVaMrTO1EhnoLLhoY2X8EhewSs13OxGzdLrIfcZE IJsxTV3+tgwmunVbjug5/GYpP/pY81O7R3hYnlDQC1RE6Jm/JuQF2VKuf82qQ X-Received: by 2002:a1c:2587:: with SMTP id l129mr9133710wml.135.1617300193454; Thu, 01 Apr 2021 11:03:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfh/ntQVUb1h3F73wyfToudKz5dPGvmGRHgyIns6SPAeTK5uOcsbTueRRU5WGEKp7GEGVQ2A== X-Received: by 2002:a1c:2587:: with SMTP id l129mr9133683wml.135.1617300193234; Thu, 01 Apr 2021 11:03:13 -0700 (PDT) Date: Thu, 1 Apr 2021 14:03:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 8/9] isa/v582c686: Reinitialize ACPI PM device on reset Message-ID: <20210401180235.226321-9-mst@redhat.com> References: <20210401180235.226321-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210401180235.226321-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Isaku Yamahata , Peter Maydell , Huacai Chen , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Isaku Yamahata Commit 6be8cf56bc8b made sure that SCI is enabled in PM1.CNT on reset in acpi_only mode by modifying acpi_pm1_cnt_reset() and that worked for q35 as expected. This patch adds reset ACPI PM related registers on vt82c686 reset time and de-assert sci. via_pm_realize() initializes acpi pm tmr, evt, cnt and gpe. Reset them on device reset. Cc: BALATON Zoltan Cc: Huacai Chen Cc: "Philippe Mathieu-Daud=C3=A9" Cc: Jiaxun Yang Signed-off-by: Isaku Yamahata Message-Id: <0a3fe998525552860919a690ce83dab8f663ab99.1616532563.git.isaku.= yamahata@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/isa/vt82c686.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index f0fb309f12..98325bb32b 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -178,6 +178,11 @@ static void via_pm_reset(DeviceState *d) /* SMBus IO base */ pci_set_long(s->dev.config + 0x90, 1); =20 + acpi_pm1_evt_reset(&s->ar); + acpi_pm1_cnt_reset(&s->ar); + acpi_pm_tmr_reset(&s->ar); + pm_update_sci(s); + pm_io_space_update(s); smb_io_space_update(s); } --=20 MST From nobody Sat May 4 09:49:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617301307; cv=none; d=zohomail.com; s=zohoarc; b=T+80od/qKcZUAsRqGD64AhXTPMAU1qrYqjJdLmgVl/NamW64oaocnXluEPAOaMT1Pb29ULOJtBdY4+oNLYUZ//+4rAb07Biku0AZLYtbpQjOKmVgKwG5dLOqP596FhYN1AeT0xb2vuJBMZkUFEobs1wcc6ynIr0Ak35vOhZ1d6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617301307; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=16gIw2Sth3p3xmGxKGQ0PWspsKIzRyKL0QxExkz02Q8=; b=BtSajLJGzdfEWjt3WTHVPCorJYRNMLqCatAvhKk5TKKzO+mwkm+ZZ+eO+a+bApRkvvqGd0i+jocutbLrkT5DT55D/eq+6p5/i3PPZ2NsfOVPqsONaIZDPPY0ye2q7bXMnd2IH/gJ+yCm49Kg8AkfaoKinskrGXy5yahl4mOjX8s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617301307961592.2344748726834; Thu, 1 Apr 2021 11:21:47 -0700 (PDT) Received: from localhost ([::1]:41988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lS1ww-0006ol-Uh for importer@patchew.org; Thu, 01 Apr 2021 14:21:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1f9-0003WC-SP for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56603) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lS1f6-000643-SP for qemu-devel@nongnu.org; Thu, 01 Apr 2021 14:03:23 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-142-rXmqYfs6OCy_KCb-d8HATg-1; Thu, 01 Apr 2021 14:03:17 -0400 Received: by mail-wr1-f70.google.com with SMTP id z17so3116503wrv.23 for ; Thu, 01 Apr 2021 11:03:16 -0700 (PDT) Received: from redhat.com ([2a10:800e:f0d3:0:b69b:9fb8:3947:5636]) by smtp.gmail.com with ESMTPSA id z2sm14070735wrm.0.2021.04.01.11.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 11:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617300199; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=16gIw2Sth3p3xmGxKGQ0PWspsKIzRyKL0QxExkz02Q8=; b=hu5Wy7jRQcq5wCnVqXMyQCckdcM+6Vp08DliunlSwViZxSQPABC7hNMzCOcMORizi4BIKE aIS9bKYxCiY++OWtryk9S9aAAZpOTPBJOvui7/t/57eGgLzi50UmQU/HZ9yTuKevjFZ7Iw Ul8qpXq/Gk5pW9oZ13cPR9WX9r3WZY4= X-MC-Unique: rXmqYfs6OCy_KCb-d8HATg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=16gIw2Sth3p3xmGxKGQ0PWspsKIzRyKL0QxExkz02Q8=; b=bmSDKYc/8BiljSTH4Od/7yEmOj/EMf9S8Fn+nKPw18mAQTQPw4vgwj3XGL8A+bp/Hq CRALvB2xyZWOAGt8fM+VV7/YiE6tplgEX4cV83lkyEuB4yT96jB0YqiLVD9mRd2659R9 BzQbq9QZH/hoLJvgP0Q2liRCBIH2/7aoTohA4MRwByfMEr28f2fhePBYZgrqETtNZbfC UHL0087l6+sXyB4Vook4jE709ef2rc8gwsYvqpygAyYvy4N+6PU6xNmBIOo+AFCQxBkW 0JezB20MlmWJns7fukaNOZjVpeYNX2+T/c8Vr4hW1isvdIVHk5T2C3tc2zfa/0GI2V1W VNwg== X-Gm-Message-State: AOAM530CKw3JAiCkMuC97CE594k53NlnyqGs3yhK5zAiO99LgNA4kKO8 ooFR6QReJ/OqlnhdrVb1MXVKIYoDM6fdEkfapQvk9q6DjZUFj+q2Lt1XBNBJzOmZkAsl946Cf9C Mis+2ybZRn/U/ZgqPeEK9lnmAqFLwL+QR2u1cVSgym6WHYQQ/O1oD4kKSTqts X-Received: by 2002:adf:f351:: with SMTP id e17mr10991353wrp.416.1617300195459; Thu, 01 Apr 2021 11:03:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbHLR5i0vzyV0X0RcBPYrV7PbiSg0PNOv90hUw/Xu3WBMQ4yOy2jJvCEHRg3P6gUOXIcSNRA== X-Received: by 2002:adf:f351:: with SMTP id e17mr10991339wrp.416.1617300195313; Thu, 01 Apr 2021 11:03:15 -0700 (PDT) Date: Thu, 1 Apr 2021 14:03:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 9/9] pci: sprinkle assert in PCI pin number Message-ID: <20210401180235.226321-10-mst@redhat.com> References: <20210401180235.226321-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210401180235.226321-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Isaku Yamahata , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Isaku Yamahata If a device model (a) doesn't set the value to a correct interrupt number and then (b) triggers an interrupt for itself, it's device model bug. Add assert on interrupt pin number to catch this kind of bug more obviously. Suggested-by: Peter Maydell Signed-off-by: Isaku Yamahata Message-Id: <9cf8ac3b17e162daac0971d7be32deb6a33ae6ec.1616532563.git.isaku.= yamahata@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index ac9a24889c..8f35e13a0c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1450,6 +1450,8 @@ static void pci_irq_handler(void *opaque, int irq_num= , int level) PCIDevice *pci_dev =3D opaque; int change; =20 + assert(0 <=3D irq_num && irq_num < PCI_NUM_PINS); + assert(level =3D=3D 0 || level =3D=3D 1); change =3D level - pci_irq_state(pci_dev, irq_num); if (!change) return; @@ -1469,6 +1471,7 @@ static inline int pci_intx(PCIDevice *pci_dev) qemu_irq pci_allocate_irq(PCIDevice *pci_dev) { int intx =3D pci_intx(pci_dev); + assert(0 <=3D intx && intx < PCI_NUM_PINS); =20 return qemu_allocate_irq(pci_irq_handler, pci_dev, intx); } --=20 MST