From patchwork Mon Nov 15 16:37:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555388 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=f05aauSI; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFN33s06z9sR4 for ; Tue, 16 Nov 2021 03:42:11 +1100 (AEDT) Received: from localhost ([::1]:44580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmf3Z-0000sP-BH for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:42:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmez5-00018i-R1 for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:37:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:55851) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmez3-00058c-Me for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:37:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994248; 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=1ROjPuUrj7hvJIatWsMC+cEH79scJrazKrFIFjUchYM=; b=f05aauSINGW0hqJU4124B7433pwESvPa6M6NQDbsD+vXrKmwXGZRctFJf/4RNgXdp6GXlY 6UlrQdjH6bk1oKUOSWL7cywn2H9TX+6fXFCOPiS6cTUb2oUSN/kFtjV9PCnyD5e8dScljq 2A7i3r1fr42euzThcUC5QpxtTV99pA8= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-161-ltOFkXTOMpCGbqIpvrNLZg-1; Mon, 15 Nov 2021 11:37:27 -0500 X-MC-Unique: ltOFkXTOMpCGbqIpvrNLZg-1 Received: by mail-ed1-f69.google.com with SMTP id f4-20020a50e084000000b003db585bc274so14480218edl.17 for ; Mon, 15 Nov 2021 08:37:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=1ROjPuUrj7hvJIatWsMC+cEH79scJrazKrFIFjUchYM=; b=Vpyr6ArrNgylaPRhTgom5GoLUv3VkhjMQ7YEIASLm+oE1TCbdth3G/GvnySy/6q2O/ 4OXGCN4UWh5kO1d7Cydj78ranNBX/plriNA+AmKnn0zvuPFw8TXiQNGhh6sm4Zf2Vb2t MfUdB0hlz4uwUbm21gDvcX7bn+t7fZVoVXurQ+qph2dv0sTdFTgRHmBXorjfhyDp8Jai 3FpU1Ghi6q6uTti0qja0K8jim3nJR06Q4F+4W1LAXBr7/tVOIgKZ4KlU/pMBMYjPXDex lPL+tdlsrllJ1U1q5ZIAYtBIcLXKnigQuFGWf+yYVerVhkrmTzze7PfHv8f9hlBPZ3Wd 48BA== X-Gm-Message-State: AOAM532F0meeIuqVMnqqQ0GSN1a2az38Dt3sfuvJQmjNBA0/QdE9djog qd7IZiSOaHo2XQ6aqO5QAaEZ3Adu6SEGHlzkQsE6i3JMjLYc1GVNLX9IkbS0IEU+ojZbBOpDdxC KKDLnK07s4arwAtqhkaJUZ8XD6AOrZPyoLrG03Oi1sNcBNjaIwbcPYqRSmaa1 X-Received: by 2002:a05:6402:1e8e:: with SMTP id f14mr39228edf.250.1636994245925; Mon, 15 Nov 2021 08:37:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/hGddhanJPICGPpvt61e8ncu29H1Fb5uaP99rPMw6dEiNDnstjeF9EeC3O/HJt6LAAtvgfQ== X-Received: by 2002:a05:6402:1e8e:: with SMTP id f14mr39172edf.250.1636994245645; Mon, 15 Nov 2021 08:37:25 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id z25sm6549486ejd.80.2021.11.15.08.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:37:25 -0800 (PST) Date: Mon, 15 Nov 2021 11:37:15 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 01/20] net/vhost-vdpa: fix memory leak in vhost_vdpa_get_max_queue_pairs() Message-ID: <20211115163607.177432-2-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Stefano Garzarella Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefano Garzarella Use g_autofree to ensure that `config` is freed when vhost_vdpa_get_max_queue_pairs() returns. Reported-by: Coverity (CID 1465228: RESOURCE_LEAK) Fixes: 402378407d ("vhost-vdpa: multiqueue support") Signed-off-by: Stefano Garzarella Message-Id: <20211102155157.241034-1-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé Acked-by: Jason Wang --- net/vhost-vdpa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 49ab322511..373b706b90 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -214,7 +214,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer, static int vhost_vdpa_get_max_queue_pairs(int fd, int *has_cvq, Error **errp) { unsigned long config_size = offsetof(struct vhost_vdpa_config, buf); - struct vhost_vdpa_config *config; + g_autofree struct vhost_vdpa_config *config = NULL; __virtio16 *max_queue_pairs; uint64_t features; int ret; From patchwork Mon Nov 15 16:37:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555391 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hNo/NKxH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFRq6FDSz9sR4 for ; Tue, 16 Nov 2021 03:45:27 +1100 (AEDT) Received: from localhost ([::1]:52590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmf6j-0006Es-Mx for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:45:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmezK-0001PI-Oc for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:37:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22118) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmezH-00059q-RH for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:37:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994263; 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=/UAC8cFjmevmjKiAFrG4ySzRdHBE4bsHOmnhcPVqLlc=; b=hNo/NKxH0HyiGj1LctUOBDF4nrKRwNKAwinkcJlzYXukw6lAPUvMgBj98fWSlfYiekUOXt b9KUyPo+NwW1m1ZINJ9K7nsLqrr1URpRgx6B4zjGgYTqhbguokaQuQWyq4hGK+egrKlEdZ +riDZN+rUwr/hhEyCpK5B8L7U2C57PA= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-378-qihW5Gp3NACG2sCIjmvrTg-1; Mon, 15 Nov 2021 11:37:41 -0500 X-MC-Unique: qihW5Gp3NACG2sCIjmvrTg-1 Received: by mail-ed1-f72.google.com with SMTP id q17-20020aa7da91000000b003e7c0641b9cso2909885eds.12 for ; Mon, 15 Nov 2021 08:37:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=/UAC8cFjmevmjKiAFrG4ySzRdHBE4bsHOmnhcPVqLlc=; b=ijnjoZCkwqW+RC+AYX0BlYSIlmHZzbT9pQ7mU4Q2hoS2TGqX4Cpb9Fc5Tkxam4WxBY yahYDJ0QgNFIFwQ0sxNZFryav5dGMrACkrh9/DwR2yFE8R/agm/BoRFnFcv8g9xNKI3F zzmkyXkqOyAj/kBUm445e0pDkMy7TBUiN8cbT4o1CzO8kzTClOWnljgkfuuV+HZugM3f DkI+6dNpOKEJjNFcQkzdKRAqm7KctZXeh73Apg1Z9TioXZEufU7wv5Cu7FMjqzhci2H/ YQjYUVc/xNBpwmMPtB/i5G6vF2cLZfx5GCAM1+Fi/OcYldzHScvLwQ0WgNVRJBTUT6T9 NOvA== X-Gm-Message-State: AOAM5302FbFCg3mXFpIMwcniDSQlHgABHbkceKPp+QScCoRgWSsUlxyV uVNhnddnxEoXQqVBM/AaQylnZ2u7YM0EvDVVDxk40V3RENU9ggvPgDh/hqBKgKEMdbe+fnc7pz/ 4nXczFFU41aDv2xzkw3Z5aQTKYX8mkg4oMY3+BVj2RlSYzb3UO72EikpjR+fi X-Received: by 2002:aa7:ca4f:: with SMTP id j15mr58348edt.178.1636994260367; Mon, 15 Nov 2021 08:37:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzniA2cpbt0IMK5WJx6QNAtOwRwd86q2E+XFtFyyID09hJbjGm2C6gz8Q8nvfcjBN/GDpYuyQ== X-Received: by 2002:aa7:ca4f:: with SMTP id j15mr58309edt.178.1636994260208; Mon, 15 Nov 2021 08:37:40 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id u16sm7704302edr.43.2021.11.15.08.37.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:37:39 -0800 (PST) Date: Mon, 15 Nov 2021 11:37:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 02/20] softmmu/qdev-monitor: fix use-after-free in qdev_set_id() Message-ID: <20211115163607.177432-3-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Peter Maydell , Daniel =?utf-8?b?UC4gQmVycmFuZ8Op?= , Eduardo Habkost , Markus Armbruster , Paolo Bonzini , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , Kevin Wolf , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefan Hajnoczi Reported by Coverity (CID 1465222). Fixes: 4a1d937796de0fecd8b22d7dbebf87f38e8282fd ("softmmu/qdev-monitor: add error handling in qdev_set_id") Cc: Damien Hedde Cc: Kevin Wolf Cc: Michael S. Tsirkin Signed-off-by: Stefan Hajnoczi Message-Id: <20211102163342.31162-1-stefanha@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Kevin Wolf Reviewed-by: Marc-André Lureau Reviewed-by: Damien Hedde Reviewed-by: Markus Armbruster --- softmmu/qdev-monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index f8b3a4cd82..588a62b88d 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -593,8 +593,8 @@ const char *qdev_set_id(DeviceState *dev, char *id, Error **errp) if (prop) { dev->id = id; } else { - g_free(id); error_setg(errp, "Duplicate device ID '%s'", id); + g_free(id); return NULL; } } else { From patchwork Mon Nov 15 16:37:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555402 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Zg5wRL8N; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFfP2v6wz9sR4 for ; Tue, 16 Nov 2021 03:54:37 +1100 (AEDT) Received: from localhost ([::1]:52038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmfFb-00084g-94 for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:54:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf1h-0006R6-4o for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:40:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:46528) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf1f-0005Qv-8b for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:40:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994410; 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=R01BxX4l5C5eaCov7FEv3t7wD4gp/yqC3ffLI+K8L7g=; b=Zg5wRL8Nmqcx9/zLqkWJvG4fKLH0RKidtHJvxEmD8zwcpVwWHj1WFcUaH9UbZqCiVJ3MZe FKNYneB/PcHWvqqPmBWF77mwMvCDU0ZCm72WJZCOieClEq/p7xO9ghr+eeGRi+4XAGhzBF WuOpXsw9hwM5IHZHYMR9obMMinRiqR4= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-529-RrbbeYIUPtOKDgnbNmq8Wg-1; Mon, 15 Nov 2021 11:37:47 -0500 X-MC-Unique: RrbbeYIUPtOKDgnbNmq8Wg-1 Received: by mail-ed1-f70.google.com with SMTP id b15-20020aa7c6cf000000b003e7cf0f73daso2197113eds.22 for ; Mon, 15 Nov 2021 08:37:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=R01BxX4l5C5eaCov7FEv3t7wD4gp/yqC3ffLI+K8L7g=; b=qr4kk5UapLATOrUdpne2lUTLI4zSFxZ2pVXi3X+4GOinyYIyZX+RRVOdgzFgeBovhV hV52QzEeKTsKP0gD90KE8IynBwiVqPqOVReacVPivQG3tkR3j7FRV61RrKJpcSAQnd81 q3BsT3+0cSYa3TdHw2cSWba00q6qZTt+vJ1+1CIWiLmoslEvhWMVhRMNY0rdC08mR+6L ZWFnvAXdUlR7vBCepOdUaSve0BF0e1jzkw/Dt9EGK1XcVo87I56rhdeBXSsl5F8bCdBc 1XcXDMMXRZY2NKn/L7a0AKFFKcLlAg3Pf4XysooRW5mTM9Ri1aJm+D1b1d772gBc06le w3zw== X-Gm-Message-State: AOAM531P6TAiUguCdys+tSS7ou1bljjMeoomg9DQG/IToIzV+SLLJIKe 1Kle2WMOJxjolttKM6K2PR3hb3PJbNy+V08eZiasa8kZH4bDqjo5klZKp2ro21H9uXbDtVzak2X RAHfX+Quz+cMmoYKyC/W+14BILN7E3PM5zuDli7eOe1/XajR4KHtLIRIy/u9Q X-Received: by 2002:a17:906:608:: with SMTP id s8mr320964ejb.405.1636994265822; Mon, 15 Nov 2021 08:37:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxiF0n5b+00BhpsJb9KilgdOrcFfAH8saZZW6AvLsqG442RZGW2VU3WgMydYM7dr20iP9QKfg== X-Received: by 2002:a17:906:608:: with SMTP id s8mr320937ejb.405.1636994265662; Mon, 15 Nov 2021 08:37:45 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id s3sm6739305ejm.49.2021.11.15.08.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:37:44 -0800 (PST) Date: Mon, 15 Nov 2021 11:37:40 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 03/20] vhost: Rename last_index to vq_index_end Message-ID: <20211115163607.177432-4-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Juan Quintela , Eugenio =?utf-8?b?UMOpcmV6?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eugenio Pérez The doc of this field pointed out that last_index is the last vq index. This is misleading, since it's actually one past the end of the vqs. Renaming and modifying comment. Signed-off-by: Eugenio Pérez Acked-by: Jason Wang Message-Id: <20211104085625.2054959-2-eperezma@redhat.com> Reviewed-by: Juan Quintela Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost.h | 4 ++-- hw/net/vhost_net.c | 4 ++-- hw/virtio/vhost-vdpa.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 3fa0b554ef..58a73e7b7a 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -74,8 +74,8 @@ struct vhost_dev { unsigned int nvqs; /* the first virtqueue which would be used by this vhost dev */ int vq_index; - /* the last vq index for the virtio device (not vhost) */ - int last_index; + /* one past the last vq index for the virtio device (not vhost) */ + int vq_index_end; /* if non-zero, minimum required value for max_queues */ int num_queues; uint64_t features; diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 0d888f29a6..29f2c4212f 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -232,10 +232,10 @@ fail: } static void vhost_net_set_vq_index(struct vhost_net *net, int vq_index, - int last_index) + int vq_index_end) { net->dev.vq_index = vq_index; - net->dev.last_index = last_index; + net->dev.vq_index_end = vq_index_end; } static int vhost_net_start_one(struct vhost_net *net, diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 0d8051426c..bcaf00e09f 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -645,7 +645,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started) vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); } - if (dev->vq_index + dev->nvqs != dev->last_index) { + if (dev->vq_index + dev->nvqs != dev->vq_index_end) { return 0; } From patchwork Mon Nov 15 16:37:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555381 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UhIEZSfz; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFJ52cWmz9sR4 for ; Tue, 16 Nov 2021 03:38:45 +1100 (AEDT) Received: from localhost ([::1]:33242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmf0E-0001aC-Sv for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:38:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmezU-0001Z5-Ml for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:37:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23305) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmezS-0005C2-U4 for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:37:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994274; 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=Hy/vWSY8IlvPxeCX7j4JnR+xb/lMTd0Fc3iOQKHkO6g=; b=UhIEZSfzHoBHffkao4pzMr+EG/rNCMXhFwsN8M7zaN1WnCiiFb6wXl5vQpkLVr2WOX5qPw +X/BR1aFrMrGeAWTxJ4JzNbbJM6pvvAOme5oaycHc++UQVl/LxyRLCZwg5oReGYE8jDj8l 5yJGVMNcc3N/u+zavfIMHaSt2XjFkwo= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-243-OZXEyNkSN867umvIpWybEA-1; Mon, 15 Nov 2021 11:37:52 -0500 X-MC-Unique: OZXEyNkSN867umvIpWybEA-1 Received: by mail-ed1-f69.google.com with SMTP id m17-20020aa7d351000000b003e7c0bc8523so2839650edr.1 for ; Mon, 15 Nov 2021 08:37:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Hy/vWSY8IlvPxeCX7j4JnR+xb/lMTd0Fc3iOQKHkO6g=; b=WD6bjf3Z9ooR1qRmdQKqj3ldqieXW96rBgp+vtWbwE0vzoO+fwCyo1qld70hxexzy5 D3YYT4e78GMmZd0/vYfxivOlbim+iyMsMMkaiMrOuGYO4k92ara/F8dtKgzLIktipRYF JjZmkCAFPneIxBK81HkrsV/tR2H8u4Qf2LhfavcUG7AOClLIbHwQnbFdqIQ5ozuRWCh1 aaYOW7tkCB9E3qIH2fiGQr0aNt3jaV4BjtlWjppQA/OMJzuozCz2IHAZpKt8iFeoy8rF hp4vyDqr5ZuRDoEG/WgN4nLA6iIXapFDAMH0lk0d/dg6sQ5nbNZABmOhqWGdktIyKb5H 73RA== X-Gm-Message-State: AOAM530ewcVQn3TC2iPozCeVu0Pgn7PqtH00/eN6VHvIyUOalBE3rxXs qEXRiMiZ/Ur5PuPofZ32Ot8vreObk9q4DTfEhGqVwe9jH0UKVxVruV7YnUontMXkTFw6SfMw/Br 5OZJHpiD/SbJFfVKX4qC+L5wGz++4h2f0fgAq0ttZpUgQfeVxh09r7T1JUtfH X-Received: by 2002:a17:906:b2c7:: with SMTP id cf7mr329155ejb.303.1636994270544; Mon, 15 Nov 2021 08:37:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFO6TuV/ifdBOkA9g4lR3KoFi+m65NuJgLmTN6TTFGzRmjP2UfnWKubqY7Wf3hq8ejgI1OUA== X-Received: by 2002:a17:906:b2c7:: with SMTP id cf7mr329111ejb.303.1636994270300; Mon, 15 Nov 2021 08:37:50 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id kx3sm2550405ejc.112.2021.11.15.08.37.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:37:49 -0800 (PST) Date: Mon, 15 Nov 2021 11:37:45 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 04/20] vhost: Fix last vq queue index of devices with no cvq Message-ID: <20211115163607.177432-5-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Juan Quintela , Eugenio =?utf-8?b?UMOpcmV6?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eugenio Pérez The -1 assumes that cvq device model is accounted in data_queue_pairs, if cvq does not exists, but it's actually the opposite: Devices with !cvq are ok but devices with cvq does not add the last queue to data_queue_pairs. This is not a problem to vhost-net, but it is to vhost-vdpa: * Devices with cvq gets initialized at last data vq device model, not at cvq one. * Devices with !cvq never gets initialized, since last_index is the first queue of the last device model. Because of that, the right change in last_index is to actually add the cvq, not to remove the missing one. This is not a problem to vhost-net, but it is to vhost-vdpa, which device model trust to reach the last index to finish starting the device. Also, as the previous commit, rename it to index_end. Tested with vp_vdpa with host's vhost=on and vhost=off, with ctrl_vq=on and ctrl_vq=off. Fixes: 049eb15b5fc9 ("vhost: record the last virtqueue index for the virtio device") Reviewed-by: Juan Quintela Signed-off-by: Eugenio Pérez Message-Id: <20211104085625.2054959-3-eperezma@redhat.com> Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/net/vhost_net.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 29f2c4212f..30379d2ca4 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -326,11 +326,11 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, VirtIONet *n = VIRTIO_NET(dev); int nvhosts = data_queue_pairs + cvq; struct vhost_net *net; - int r, e, i, last_index = data_queue_pairs * 2; + int r, e, i, index_end = data_queue_pairs * 2; NetClientState *peer; - if (!cvq) { - last_index -= 1; + if (cvq) { + index_end += 1; } if (!k->set_guest_notifiers) { @@ -347,7 +347,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, } net = get_vhost_net(peer); - vhost_net_set_vq_index(net, i * 2, last_index); + vhost_net_set_vq_index(net, i * 2, index_end); /* Suppress the masking guest notifiers on vhost user * because vhost user doesn't interrupt masking/unmasking From patchwork Mon Nov 15 16:37:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555385 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gcf+kcrq; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFLw0DFvz9sR4 for ; Tue, 16 Nov 2021 03:41:11 +1100 (AEDT) Received: from localhost ([::1]:41400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmf2b-000777-Km for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:41:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmezf-0001cE-LV for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmezd-0005CM-P5 for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994279; 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=FCwWAShbLLF34Yk6WLQ61NBEjpxVbqCjQ2ekK/tHKoY=; b=gcf+kcrqvqiV4MZ6CBPcRVH7lxMDUpe7ko5jI/aOeJblDUy4yt3/hNQ+qVPsXW8VGYULGy Yb4YEQ1TlnFWpeBC3VaJBBVFSUk5MkGBO4b5s+FMzqDAWrYawGaYg1/4oVYT6XlVFtMbts UK9US+v5b9ZC4SdLntDDvjj4dJBPC9Y= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-567-adZwQZmiM6uaLfHa1UBwWQ-1; Mon, 15 Nov 2021 11:37:57 -0500 X-MC-Unique: adZwQZmiM6uaLfHa1UBwWQ-1 Received: by mail-ed1-f70.google.com with SMTP id bx28-20020a0564020b5c00b003e7c42443dbso2542703edb.15 for ; Mon, 15 Nov 2021 08:37:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=FCwWAShbLLF34Yk6WLQ61NBEjpxVbqCjQ2ekK/tHKoY=; b=KnBQx4r/un434L4xc9NdqoIR+jWDxcfKAayT0l/vre/5G+sErcLTLCHC+oT9q1XvRg il2jYoo8fapdLLhJZKowWOM5Olbz+Mo19hTOaFMPk0NUinNE9q5ezVF1U6j5qE9ZmA3+ AXBQJtz9yFHL+hBm44C4T5+LexGDbqI9FxMr2RL3tRLdc30+lJQkDLpN4/mJ9puh/7// 0xy7mJcw/8qPIdutPOfXnM/o7DwcmnQCvVqNTLsn5TNkxj3sXBs87FUcnl1/jCPs4xfd KoOJFCGanZ5uaUocR03TT1Nc5rMHVTAiFbxaXp7Bx9vGAqKwZ26f1ZPvBkXVXwl+BG/F 6EXw== X-Gm-Message-State: AOAM5331TgL/5udqIOXKbw8CRTi9F4HLVdptnbudiZczs/bmk6tsXsTk tiNAIgjEgC43Q+mMfa25BVqAWM3JMf+PEedS+ta22LOmog+IZi7V+grGS0shvWs0IPXZgVnyzRA 9mU1+xqZGYkNMbjITf8wMhR8Py+MxjejnQ2oA0z5BYfIDyTIet6ETYpNONoci X-Received: by 2002:a17:906:5209:: with SMTP id g9mr361636ejm.145.1636994275599; Mon, 15 Nov 2021 08:37:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJx5ancvOD9dTU5uTlIRrPknkYR4ttpSyKCmmTboHNGKhVPcuGdNTR79FFBd7LJdZ6W/Q1TPZQ== X-Received: by 2002:a17:906:5209:: with SMTP id g9mr361603ejm.145.1636994275405; Mon, 15 Nov 2021 08:37:55 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id x19sm1349838edd.61.2021.11.15.08.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:37:54 -0800 (PST) Date: Mon, 15 Nov 2021 11:37:50 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 05/20] hw/mem/pc-dimm: Restrict NUMA-specific code to NUMA machines Message-ID: <20211115163607.177432-6-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Igor Mammedov Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé When trying to use the pc-dimm device on a non-NUMA machine, we get: $ qemu-system-arm -M none -cpu max -S \ -object memory-backend-file,id=mem1,size=1M,mem-path=/tmp/1m \ -device pc-dimm,id=dimm1,memdev=mem1 Segmentation fault (core dumped) (gdb) bt #0 pc_dimm_realize (dev=0x555556da3e90, errp=0x7fffffffcd10) at hw/mem/pc-dimm.c:184 #1 0x0000555555fe1f8f in device_set_realized (obj=0x555556da3e90, value=true, errp=0x7fffffffce18) at hw/core/qdev.c:531 #2 0x0000555555feb4a9 in property_set_bool (obj=0x555556da3e90, v=0x555556e54420, name=0x5555563c3c41 "realized", opaque=0x555556a704f0, errp=0x7fffffffce18) at qom/object.c:2257 To avoid that crash, restrict the pc-dimm NUMA check to machines supporting NUMA, and do not allow the use of 'node' property on non-NUMA machines. Suggested-by: Igor Mammedov Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20211106145016.611332-1-f4bug@amsat.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/pc-dimm.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index a3a2560301..48b913aba6 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -181,7 +181,21 @@ static void pc_dimm_realize(DeviceState *dev, Error **errp) PCDIMMDevice *dimm = PC_DIMM(dev); PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); MachineState *ms = MACHINE(qdev_get_machine()); - int nb_numa_nodes = ms->numa_state->num_nodes; + + if (ms->numa_state) { + int nb_numa_nodes = ms->numa_state->num_nodes; + + if (((nb_numa_nodes > 0) && (dimm->node >= nb_numa_nodes)) || + (!nb_numa_nodes && dimm->node)) { + error_setg(errp, "'DIMM property " PC_DIMM_NODE_PROP " has value %" + PRIu32 "' which exceeds the number of numa nodes: %d", + dimm->node, nb_numa_nodes ? nb_numa_nodes : 1); + return; + } + } else if (dimm->node > 0) { + error_setg(errp, "machine doesn't support NUMA"); + return; + } if (!dimm->hostmem) { error_setg(errp, "'" PC_DIMM_MEMDEV_PROP "' property is not set"); @@ -191,13 +205,6 @@ static void pc_dimm_realize(DeviceState *dev, Error **errp) object_get_canonical_path_component(OBJECT(dimm->hostmem))); return; } - if (((nb_numa_nodes > 0) && (dimm->node >= nb_numa_nodes)) || - (!nb_numa_nodes && dimm->node)) { - error_setg(errp, "'DIMM property " PC_DIMM_NODE_PROP " has value %" - PRIu32 "' which exceeds the number of numa nodes: %d", - dimm->node, nb_numa_nodes ? nb_numa_nodes : 1); - return; - } if (ddc->realize) { ddc->realize(dimm, errp); From patchwork Mon Nov 15 16:37:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555382 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hRjsoufx; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFJ83gb6z9sR4 for ; Tue, 16 Nov 2021 03:38:48 +1100 (AEDT) Received: from localhost ([::1]:33382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmf0I-0001fp-BT for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:38:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmezf-0001ce-Vn for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21315) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmezd-0005CQ-PH for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994284; 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=/FAcbaSW6GFOcfG2P5xertmYz+uafNHyYCjbb8h1fSg=; b=hRjsoufxhdHvxD3GbMT8S/VdVKlO0bkExq0qMMvzMEdoLYQe3pAXJN8qA8oBMPCFYtvc4i jiy6S7joyzag8SpR9H0mlhx9nDpAyYSNqHLzJhbG4oDne5UhGP8G6B+/Hd4X2LAsEnjvXD sub02ZPv7IhhjtHl0cids3nsNVqf3rI= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-59-K1bUsC8KM6WSUcEwK0WR-w-1; Mon, 15 Nov 2021 11:38:02 -0500 X-MC-Unique: K1bUsC8KM6WSUcEwK0WR-w-1 Received: by mail-ed1-f72.google.com with SMTP id a3-20020a05640213c300b003e7d12bb925so2096985edx.9 for ; Mon, 15 Nov 2021 08:38:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/FAcbaSW6GFOcfG2P5xertmYz+uafNHyYCjbb8h1fSg=; b=KDrNZLuHfdhn8FYKYY+NkWKa5WGzfdQuTK9DQ454SBg88pNeMBLg/718cBnI04qSoF qCkDNDgw/FxgyFa32XQA32Cms5y3Ac5mOPAd6xvWfVf3DZtgu3ClouAagYzkzoOvgAyM sX6/aF8IecIFRzlJD2lDBXTPghjklrUeYavtjTyJxGjV2Lbgn2udWJFKrFxy9aijQJ6i E3MgCInNLSzD24s8b6604UklD5q4qdyDDVE5p6VrcpPFEjOdclSpiL2vqVmPt4iJRxY2 vuW5pOTCTfU4Wj7U9vIq2CrMMeOdzuvE2kUgJFxjcP4OnhJ/MYT59J5eGV2FVmrby3uR oKxA== X-Gm-Message-State: AOAM530HBs7BgbdlUm4UKu4LkcLdLm+UzFvxi/ela8mIsigr2S1VgGGX h/1FWMHgT1zmmgmsUfJjgYSEbiBnZuWVFla1H7mohBuWD4ZKTel+5soEG4mUC74xtwDWK872/t8 +yIbbJh6AFmgzLUMRKaj9nBZ2JPL/SGIhbc1RdKXRY0xGQDXbaPGnBH+nVWSC X-Received: by 2002:a05:6402:3586:: with SMTP id y6mr25927edc.332.1636994281204; Mon, 15 Nov 2021 08:38:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJy9YO6sfLqUBP3kvqvyAv7KGFcRyDUKpr0ZltASU09I+o0bxq9hZiLdEgG0my0PC55ClkCeaw== X-Received: by 2002:a05:6402:3586:: with SMTP id y6mr25891edc.332.1636994281038; Mon, 15 Nov 2021 08:38:01 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id k9sm7701229edo.87.2021.11.15.08.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:38:00 -0800 (PST) Date: Mon, 15 Nov 2021 11:37:55 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 06/20] pcie: rename 'native-hotplug' to 'x-native-hotplug' Message-ID: <20211115163607.177432-7-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov Mark property as experimental/internal adding 'x-' prefix. Property was introduced in 6.1 and it should have provided ability to turn on native PCIE hotplug on port even when ACPI PCI hotplug is in use is user explicitly sets property on CLI. However that never worked since slot is wired to ACPI hotplug controller. Another non-intended usecase: disable native hotplug on slot when APCI based hotplug is disabled, which works but slot has 'hotplug' property for this taks. It should be relatively safe to rename it to experimental as no users should exist for it and given that the property is broken we don't really want to leave it around for much longer lest users start using it. Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha Message-Id: <20211112110857.3116853-2-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc_q35.c | 2 +- hw/pci/pcie_port.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 797e09500b..fc34b905ee 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -243,7 +243,7 @@ static void pc_q35_init(MachineState *machine) NULL); if (acpi_pcihp) { - object_register_sugar_prop(TYPE_PCIE_SLOT, "native-hotplug", + object_register_sugar_prop(TYPE_PCIE_SLOT, "x-native-hotplug", "false", true); } diff --git a/hw/pci/pcie_port.c b/hw/pci/pcie_port.c index da850e8dde..e95c1e5519 100644 --- a/hw/pci/pcie_port.c +++ b/hw/pci/pcie_port.c @@ -148,7 +148,7 @@ static Property pcie_slot_props[] = { DEFINE_PROP_UINT8("chassis", PCIESlot, chassis, 0), DEFINE_PROP_UINT16("slot", PCIESlot, slot, 0), DEFINE_PROP_BOOL("hotplug", PCIESlot, hotplug, true), - DEFINE_PROP_BOOL("native-hotplug", PCIESlot, native_hotplug, true), + DEFINE_PROP_BOOL("x-native-hotplug", PCIESlot, native_hotplug, true), DEFINE_PROP_END_OF_LIST() }; From patchwork Mon Nov 15 16:38:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555393 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EvTQ5ouW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFVG2w0Gz9sR4 for ; Tue, 16 Nov 2021 03:47:34 +1100 (AEDT) Received: from localhost ([::1]:59658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmf8m-0002b6-8J for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:47:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmezk-0001gj-SQ for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:30630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmezi-0005Cy-L2 for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994290; 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=y6C9J2NVK01b40eeKRTUlDWMs2jNYZycxWavDBC4bcI=; b=EvTQ5ouW6sx5Az9uau85ej4dKOIfrK+ozMHlFrrrGUSjn0G4ubtI41zxS6iplVLDKO+BMS LWwm8HgkU5dqL8MgqQfV+HAaO260fACeKMa7/Et5bHXBLFUilPHlfAbhrDrLIFSE93YhB3 w28sWaZd0casHfbJZnPahilMVTK4FkA= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-123-zQCPl7a_MpGGyWsux6gFQQ-1; Mon, 15 Nov 2021 11:38:08 -0500 X-MC-Unique: zQCPl7a_MpGGyWsux6gFQQ-1 Received: by mail-ed1-f69.google.com with SMTP id c1-20020aa7c741000000b003e7bf1da4bcso3255079eds.21 for ; Mon, 15 Nov 2021 08:38:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=y6C9J2NVK01b40eeKRTUlDWMs2jNYZycxWavDBC4bcI=; b=X8pmREksOo6YYKfiMIFWBBoEb2gL5NOyF97sMD1KQHJ9U3XGIZO3fRmwLFYKueiaJi RjAQYmRbTWF2q7NQ8GWx3maACoa+FJgYImfXKKDKSgjSrPZvNnyzGA3EbQbVASZRZPda KcOslS3KlLWJowDRJH6Ows6CWkXQvap7QL5CRr5YcP32Ym9DY0qHKgtAYQ97giZr7AA4 shpcfBjiqVokwIvAKrTPGWcho7d6pHyNUcmW2m9fOh3//XJk+HR5IwfKCMp2k48fvhnA KH9ntrz7A+evnQ7FkWkLS0Tlx2orNmALNxFuuhu1gitdlTMr6P1vdvMQ9k96FyUayOu3 0hzg== X-Gm-Message-State: AOAM530ogyAvX9t/7tcL6yJipG2wJtq4yst4QDMetVX4f4khFxtxgdfQ y2ZZh4oTkLFajwwJKt8no/XF5UzfnSX23XJHzwi9G0VdFRJBJU/bg6ft0Ad8h1TQvlNXaxL8sSm CaisPgMgDpgBzfBKisuHhbpEknzvVy889Cf4hbakmn4ngVaYVkPXLzrM4rTac X-Received: by 2002:a05:6402:190c:: with SMTP id e12mr31779341edz.309.1636994287243; Mon, 15 Nov 2021 08:38:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvoi0H5ZibPX/as6v4jJLGmJru0YsrPMeauF4+jTrl6X8AQsCU+H1gdBplEzv+43oBrcvy0g== X-Received: by 2002:a05:6402:190c:: with SMTP id e12mr31779301edz.309.1636994287047; Mon, 15 Nov 2021 08:38:07 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id v13sm6673186ejo.36.2021.11.15.08.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:38:06 -0800 (PST) Date: Mon, 15 Nov 2021 11:38:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 07/20] hw/acpi/ich9: Add compat prop to keep HPC bit set for 6.1 machine type Message-ID: <20211115163607.177432-8-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Julia Suvorova , Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Julia Suvorova To solve issues [1-2] the Hot Plug Capable bit in PCIe Slots will be turned on, while the switch to ACPI Hot-plug will be done in the DSDT table. Introducing 'x-keep-native-hpc' property disables the HPC bit only in 6.1 and as a result keeps the forced 'reserve-io' on pcie-root-ports in 6.1 too. [1] https://gitlab.com/qemu-project/qemu/-/issues/641 [2] https://bugzilla.redhat.com/show_bug.cgi?id=2006409 Signed-off-by: Julia Suvorova Signed-off-by: Igor Mammedov Message-Id: <20211112110857.3116853-3-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/ich9.h | 1 + hw/acpi/ich9.c | 18 ++++++++++++++++++ hw/i386/pc.c | 2 ++ hw/i386/pc_q35.c | 7 ++++++- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h index f04f1791bd..7ca92843c6 100644 --- a/include/hw/acpi/ich9.h +++ b/include/hw/acpi/ich9.h @@ -56,6 +56,7 @@ typedef struct ICH9LPCPMRegs { AcpiCpuHotplug gpe_cpu; CPUHotplugState cpuhp_state; + bool keep_pci_slot_hpc; bool use_acpi_hotplug_bridge; AcpiPciHpState acpi_pci_hotplug; MemHotplugState acpi_memory_hotplug; diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 1ee2ba2c50..ebe08ed831 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -419,6 +419,20 @@ static void ich9_pm_set_acpi_pci_hotplug(Object *obj, bool value, Error **errp) s->pm.use_acpi_hotplug_bridge = value; } +static bool ich9_pm_get_keep_pci_slot_hpc(Object *obj, Error **errp) +{ + ICH9LPCState *s = ICH9_LPC_DEVICE(obj); + + return s->pm.keep_pci_slot_hpc; +} + +static void ich9_pm_set_keep_pci_slot_hpc(Object *obj, bool value, Error **errp) +{ + ICH9LPCState *s = ICH9_LPC_DEVICE(obj); + + s->pm.keep_pci_slot_hpc = value; +} + void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm) { static const uint32_t gpe0_len = ICH9_PMIO_GPE0_LEN; @@ -428,6 +442,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm) pm->disable_s4 = 0; pm->s4_val = 2; pm->use_acpi_hotplug_bridge = true; + pm->keep_pci_slot_hpc = true; object_property_add_uint32_ptr(obj, ACPI_PM_PROP_PM_IO_BASE, &pm->pm_io_base, OBJ_PROP_FLAG_READ); @@ -454,6 +469,9 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm) object_property_add_bool(obj, ACPI_PM_PROP_ACPI_PCIHP_BRIDGE, ich9_pm_get_acpi_pci_hotplug, ich9_pm_set_acpi_pci_hotplug); + object_property_add_bool(obj, "x-keep-pci-slot-hpc", + ich9_pm_get_keep_pci_slot_hpc, + ich9_pm_set_keep_pci_slot_hpc); } void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2592a82148..a2ef40ecbc 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -98,6 +98,7 @@ GlobalProperty pc_compat_6_1[] = { { TYPE_X86_CPU, "hv-version-id-build", "0x1bbc" }, { TYPE_X86_CPU, "hv-version-id-major", "0x0006" }, { TYPE_X86_CPU, "hv-version-id-minor", "0x0001" }, + { "ICH9-LPC", "x-keep-pci-slot-hpc", "false" }, }; const size_t pc_compat_6_1_len = G_N_ELEMENTS(pc_compat_6_1); @@ -107,6 +108,7 @@ GlobalProperty pc_compat_6_0[] = { { "qemu64" "-" TYPE_X86_CPU, "stepping", "3" }, { TYPE_X86_CPU, "x-vendor-cpuid-only", "off" }, { "ICH9-LPC", ACPI_PM_PROP_ACPI_PCIHP_BRIDGE, "off" }, + { "ICH9-LPC", "x-keep-pci-slot-hpc", "true" }, }; const size_t pc_compat_6_0_len = G_N_ELEMENTS(pc_compat_6_0); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index fc34b905ee..e1e100316d 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -137,6 +137,7 @@ static void pc_q35_init(MachineState *machine) DriveInfo *hd[MAX_SATA_PORTS]; MachineClass *mc = MACHINE_GET_CLASS(machine); bool acpi_pcihp; + bool keep_pci_slot_hpc; /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory * and 256 Mbytes for PCI Express Enhanced Configuration Access Mapping @@ -242,7 +243,11 @@ static void pc_q35_init(MachineState *machine) ACPI_PM_PROP_ACPI_PCIHP_BRIDGE, NULL); - if (acpi_pcihp) { + keep_pci_slot_hpc = object_property_get_bool(OBJECT(lpc), + "x-keep-pci-slot-hpc", + NULL); + + if (!keep_pci_slot_hpc && acpi_pcihp) { object_register_sugar_prop(TYPE_PCIE_SLOT, "x-native-hotplug", "false", true); } From patchwork Mon Nov 15 16:38:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555383 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Y6Khm4Ip; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFJY6B46z9sR4 for ; Tue, 16 Nov 2021 03:39:09 +1100 (AEDT) Received: from localhost ([::1]:33836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmf0d-0001z1-N3 for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:39:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmezu-0001s8-16 for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38271) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmezs-0005Dd-6B for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994299; 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=7LKzhPmlwv3YmOh8UQfZKtlFJjRhICzQOr6bT4AaevY=; b=Y6Khm4IpK4wYQ/xOs45T9Z4tsFDCgaJYceWV7vkYB+Zxhgdhot4zw4KbVXdRsJ9RWeD6Ku 1XEPdIfYLfmy+VGVaThPkyLEW2zUYULVHiiLu8HVQSc/zJzT06Cg9Eg7e2Hxu8L02Fqcs6 15mTVafw38RGGW4dZzOg3dxXF+/vSvQ= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-373-da9gyuvcM7SnOE7GfsXuGw-1; Mon, 15 Nov 2021 11:38:18 -0500 X-MC-Unique: da9gyuvcM7SnOE7GfsXuGw-1 Received: by mail-ed1-f71.google.com with SMTP id c1-20020aa7c741000000b003e7bf1da4bcso3255469eds.21 for ; Mon, 15 Nov 2021 08:38:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7LKzhPmlwv3YmOh8UQfZKtlFJjRhICzQOr6bT4AaevY=; b=ZYC9SlyTreLUx3jiRhQfMfH+IjI8eYQygmHxnrTMPv4L/BttRFhgufKAXBC5SN9J7S MN+6+2HN5+1TXyi5D9S7Zn4YmNqjiGaKWJjmrAnDiC7yT9rw+jmEoSy177EGCNZO7UnX vfcyUGofdFsx5zOeCFXDhIS1Xwb6/g/j3pklCJpAVMhyXJdysFjxB2ISoRZPPePD/YJK azLrydjg1n+sKkkqxq+7K1zLvtn+Kv4Ed6OSkfIZdi39qoB5tjSITqQS++4nt4/X34Oj fBGeY8gpXip+yquIE2GlyfgdINmCfvv+Wc5lZQh4mhMGOU3C9OkRgMvLAp8GFAz5m6Xm 6hXA== X-Gm-Message-State: AOAM532zAsb767kl3bycP70I17g7f+XVy6gwMEulNpG9jnjsDic/tHdX waXoq0UvspjGwtXmP2RtVl0OklLEROBEmf8ntFly0LPrlx1q8hweqnPbGVUn5Y1MtcU9dP+s0VH 4ObHBBnx7QDEdXnhxRKVlUBpxKVNvdq8HI+aiBJCFstXcrRZ0VSTf816lO3/a X-Received: by 2002:a05:6402:510b:: with SMTP id m11mr57318288edd.215.1636994295228; Mon, 15 Nov 2021 08:38:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyeX++5K+rXXkVRoeBB6GQKwuwzFSgCLZ0SCIvhStyam1LSo2acxLV0Pj7R1F/l76jeW8m4Hg== X-Received: by 2002:a05:6402:510b:: with SMTP id m11mr57318004edd.215.1636994293569; Mon, 15 Nov 2021 08:38:13 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id lk22sm6906329ejb.83.2021.11.15.08.38.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:38:12 -0800 (PST) Date: Mon, 15 Nov 2021 11:38:07 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 08/20] bios-tables-test: Allow changes in DSDT ACPI tables Message-ID: <20211115163607.177432-9-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Julia Suvorova , Igor Mammedov Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Julia Suvorova Prepare for changing the _OSC method in q35 DSDT. Signed-off-by: Julia Suvorova Signed-off-by: Igor Mammedov Acked-by: Ani Sinha Message-Id: <20211112110857.3116853-4-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index dfb8523c8b..48e5634d4b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,17 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DSDT", +"tests/data/acpi/q35/DSDT.tis", +"tests/data/acpi/q35/DSDT.bridge", +"tests/data/acpi/q35/DSDT.mmio64", +"tests/data/acpi/q35/DSDT.ipmibt", +"tests/data/acpi/q35/DSDT.cphp", +"tests/data/acpi/q35/DSDT.memhp", +"tests/data/acpi/q35/DSDT.acpihmat", +"tests/data/acpi/q35/DSDT.numamem", +"tests/data/acpi/q35/DSDT.dimmpxm", +"tests/data/acpi/q35/DSDT.nohpet", +"tests/data/acpi/q35/DSDT.tis.tpm2", +"tests/data/acpi/q35/DSDT.tis.tpm12", +"tests/data/acpi/q35/DSDT.multi-bridge", +"tests/data/acpi/q35/DSDT.ivrs", +"tests/data/acpi/q35/DSDT.xapic", From patchwork Mon Nov 15 16:38:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555389 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CVSAkUP1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFQ76sMzz9sR4 for ; Tue, 16 Nov 2021 03:43:58 +1100 (AEDT) Received: from localhost ([::1]:49984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmf5G-0004Tg-OB for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:43:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmezw-00021h-AU for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30492) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmezu-0005Dp-JM for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994302; 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=LaY+8Sks35E+sW73i45j3BLIhjePFay5RJ/y5SCcbtU=; b=CVSAkUP172RoD4RCZ3IrfhVgLgwGBrOtYFJ+kh7vryPfVmHncJPYWbJr39wT9vXYrfSyYX GQYucJOH8/qTVJjft/Fcj2Q86M4VIoB5yX6jlRf8bsUuJpBpjTtMfjwcEevWXAs2FE66Ux DlzYILOHS/TnNOcPf8vNkAZKmerKvpE= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-350-ENARr8VdOrSwNZutjT4k9w-1; Mon, 15 Nov 2021 11:38:20 -0500 X-MC-Unique: ENARr8VdOrSwNZutjT4k9w-1 Received: by mail-ed1-f72.google.com with SMTP id v10-20020aa7d9ca000000b003e7bed57968so3291432eds.23 for ; Mon, 15 Nov 2021 08:38:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=LaY+8Sks35E+sW73i45j3BLIhjePFay5RJ/y5SCcbtU=; b=QX3NZij2Y6ahf2lt909tyZ0Sja2NrOHylO9gR8bqG7jtwe8GiXQ3H//7LM+l2UYWl8 +UjcPPvhGnMFxIRwNkT1xvopI8JJ/4+S7D0h37sdxznKisQphOTz3ULuMPJGX63oIuJD 5QjmnWRf74q4mY+uxdgEXNVXyLX6YRR0NSkFb5uUu9+BEdgoMnpLTYX9YExXnfK5rzk8 Hvem87lYv8DPM66L5Gup3ov7JYtCAWXIv+H3IdINM39SrfC7N+3Km/Seqb1HBie0WYz5 t+rBSnw6jXRywPXuEJg4zgYNkwLWQucRzZlk0XZSowOdICU0n3HbRw394e6GqGlNpCoj bfcA== X-Gm-Message-State: AOAM5332Ekhr+CV3uo40DqZMPYwefvYElspN4EFYIBAVsFkt6QGGjTF/ CJf3k93K1cE0532rDhyP6ymsp/I331OLIsK/UXfBXxfZL4Dk2gEN+4VBCTBrW4BE0Gm0rxo6BwU u9O8JUAeRJ/FDbfx3hTIvA5ekLl+HilH4bsql/lTOdv0rmz4Ap4mr+l3YfCNL X-Received: by 2002:a17:907:961d:: with SMTP id gb29mr449186ejc.102.1636994299162; Mon, 15 Nov 2021 08:38:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3bxXCwflMyz16wNlscAIvVSGznsA1DbOCzXZpeDxchjWBKbQubPYHeHwoLn4LtqYvHVb9cw== X-Received: by 2002:a17:907:961d:: with SMTP id gb29mr449142ejc.102.1636994298958; Mon, 15 Nov 2021 08:38:18 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id g21sm8285333edb.89.2021.11.15.08.38.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:38:18 -0800 (PST) Date: Mon, 15 Nov 2021 11:38:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 09/20] hw/i386/acpi-build: Deny control on PCIe Native Hot-plug in _OSC Message-ID: <20211115163607.177432-10-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Julia Suvorova , Richard Henderson , Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Julia Suvorova There are two ways to enable ACPI PCI Hot-plug: * Disable the Hot-plug Capable bit on PCIe slots. This was the first approach which led to regression [1-2], as I/O space for a port is allocated only when it is hot-pluggable, which is determined by HPC bit. * Leave the HPC bit on and disable PCIe Native Hot-plug in _OSC method. This removes the (future) ability of hot-plugging switches with PCIe Native hotplug since ACPI PCI Hot-plug only works with cold-plugged bridges. If the user wants to explicitely use this feature, they can disable ACPI PCI Hot-plug with: --global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off Change the bit in _OSC method so that the OS selects ACPI PCI Hot-plug instead of PCIe Native. [1] https://gitlab.com/qemu-project/qemu/-/issues/641 [2] https://bugzilla.redhat.com/show_bug.cgi?id=2006409 Signed-off-by: Julia Suvorova Signed-off-by: Igor Mammedov Message-Id: <20211112110857.3116853-5-imammedo@redhat.com> Reviewed-by: Ani Sinha Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index a3ad6abd33..a99c6e4fe3 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1337,7 +1337,7 @@ static void build_x86_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr) aml_append(table, scope); } -static Aml *build_q35_osc_method(void) +static Aml *build_q35_osc_method(bool enable_native_pcie_hotplug) { Aml *if_ctx; Aml *if_ctx2; @@ -1359,8 +1359,10 @@ static Aml *build_q35_osc_method(void) /* * Always allow native PME, AER (no dependencies) * Allow SHPC (PCI bridges can have SHPC controller) + * Disable PCIe Native Hot-plug if ACPI PCI Hot-plug is enabled. */ - aml_append(if_ctx, aml_and(a_ctrl, aml_int(0x1F), a_ctrl)); + aml_append(if_ctx, aml_and(a_ctrl, + aml_int(0x1E | (enable_native_pcie_hotplug ? 0x1 : 0x0)), a_ctrl)); if_ctx2 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(1)))); /* Unknown revision */ @@ -1449,7 +1451,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, aml_append(dev, aml_name_decl("_CID", aml_eisaid("PNP0A03"))); aml_append(dev, aml_name_decl("_ADR", aml_int(0))); aml_append(dev, aml_name_decl("_UID", aml_int(pcmc->pci_root_uid))); - aml_append(dev, build_q35_osc_method()); + aml_append(dev, build_q35_osc_method(!pm->pcihp_bridge_en)); aml_append(sb_scope, dev); if (mcfg_valid) { aml_append(sb_scope, build_q35_dram_controller(&mcfg)); @@ -1565,7 +1567,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, if (pci_bus_is_express(bus)) { aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08"))); aml_append(dev, aml_name_decl("_CID", aml_eisaid("PNP0A03"))); - aml_append(dev, build_q35_osc_method()); + + /* Expander bridges do not have ACPI PCI Hot-plug enabled */ + aml_append(dev, build_q35_osc_method(true)); } else { aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03"))); } From patchwork Mon Nov 15 16:38:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555386 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Kz6CAs+k; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFMD1fTHz9sR4 for ; Tue, 16 Nov 2021 03:41:28 +1100 (AEDT) Received: from localhost ([::1]:41874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmf2s-0007Q5-0y for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:41:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf05-0002VF-LK for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:33 -0500 Received: from usb-smtp-delivery-124.mimecast.com ([170.10.151.124]:20553 helo=us-smtp-delivery-124.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf02-0005EG-H3 for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994309; 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=WmFv7QwLptoIeFn8Ljm4ArUBy32oCI/xJ386N3kA1sA=; b=Kz6CAs+kdK0jowU8rVtnBbxW+zV0jCvROpia+yjwUxcNd7ayBpfgSgTYSOKQiEVvz9l1p1 TTkZT1yPDKaQd+tvRw+VvDI2haxcJGvQ/U96G5i9HOUaC4XpNX6CLp5q9DhGBAS/Cs/vGc HZ82EJ4Qen+wwjTTtAALgYvZe287qIU= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-2--bsVTBOKPLGxxx41yKFFQQ-1; Mon, 15 Nov 2021 11:38:26 -0500 X-MC-Unique: -bsVTBOKPLGxxx41yKFFQQ-1 Received: by mail-ed1-f69.google.com with SMTP id d11-20020a50cd4b000000b003da63711a8aso14472925edj.20 for ; Mon, 15 Nov 2021 08:38:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WmFv7QwLptoIeFn8Ljm4ArUBy32oCI/xJ386N3kA1sA=; b=Umu8U9rcWKOLi9s72rTFTTUCjBcnApFpbGB4O9L1vPfWW2wGpL05k3AEKFjs1auGz2 JRxwfjJhyMnOGrTZXHGmTmfRiKqlnw4V8L2sFZVAINUX/sZrJ0/MDTV/T/QEoxBvw77U ivUGGK5iisshoR4Oz9/5vQDHyclSw9jsUSSxX/lLAPKY0XsxZuARHNG6ceFUlxpaDY49 SsOJfeRg/8OQisrirxHD3FbA5GX9jwrHRNPUSYhv46LgR+tgdxdIcLYzYl2G8tygEOE4 ftBM0Q16eMfB8CrunihSUR5+RLkBlL8l1xJ8dRvM4XEbCuW2w9AwYaNIbvbjS5YiyU6F Fjlg== X-Gm-Message-State: AOAM5320z1HgR3KKurAm9YoKG6fSi6dMn3IKs7srVtOL+8FHz0raV8Yx gt/c4dhEiqK3U4blgNCmyTgqbJabfPuvMwVuXDOEfdDibnVHNxvuLmfj6c89lSfuB102i+U/0vo oaw1cYshTG1xhP3MXrvL+kvWXtqYL7JHQV8ZKjS8BbfIo5g+Iao7n6M9j5KZx X-Received: by 2002:a17:907:75d3:: with SMTP id jl19mr382220ejc.520.1636994303632; Mon, 15 Nov 2021 08:38:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyR3ioUs/ik9yXfePCutnkl0L+g19oZqZc7dN1svracNo0ZRUQVZCldt5pag6oPZjLrGqntrQ== X-Received: by 2002:a17:907:75d3:: with SMTP id jl19mr382175ejc.520.1636994303402; Mon, 15 Nov 2021 08:38:23 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id hz15sm6841769ejc.63.2021.11.15.08.38.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:38:22 -0800 (PST) Date: Mon, 15 Nov 2021 11:38:19 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 10/20] tests: bios-tables-test update expected blobs Message-ID: <20211115163607.177432-11-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.151.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.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Igor Mammedov Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov The changes are the result of 'hw/i386/acpi-build: Deny control on PCIe Native Hot-Plug in _OSC' which hides PCIE hotplug bit in host-bridge _OSC Method (_OSC, 4, NotSerialized) // _OSC: Operating System Capabilities { CreateDWordField (Arg3, Zero, CDW1) If ((Arg0 == ToUUID ("33db4d5b-1ff7-401c-9657-7441c03dd766") /* PCI Host Bridge Device */)) { CreateDWordField (Arg3, 0x04, CDW2) CreateDWordField (Arg3, 0x08, CDW3) Local0 = CDW3 /* \_SB_.PCI0._OSC.CDW3 */ - Local0 &= 0x1F + Local0 &= 0x1E Signed-off-by: Igor Mammedov Message-Id: <20211112110857.3116853-6-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 16 ---------------- tests/data/acpi/q35/DSDT | Bin 8289 -> 8289 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9614 -> 9614 bytes tests/data/acpi/q35/DSDT.bridge | Bin 11003 -> 11003 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8753 -> 8753 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9943 -> 9943 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 8364 -> 8364 bytes tests/data/acpi/q35/DSDT.ivrs | Bin 8306 -> 8306 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9648 -> 9648 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 9419 -> 9419 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 8583 -> 8583 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 8147 -> 8147 bytes tests/data/acpi/q35/DSDT.numamem | Bin 8295 -> 8295 bytes tests/data/acpi/q35/DSDT.tis.tpm12 | Bin 8894 -> 8894 bytes tests/data/acpi/q35/DSDT.tis.tpm2 | Bin 8894 -> 8894 bytes tests/data/acpi/q35/DSDT.xapic | Bin 35652 -> 35652 bytes 16 files changed, 16 deletions(-) diff --git a/tests/data/acpi/q35/DSDT b/tests/data/acpi/q35/DSDT index 281fc82c03b2562d2e6b7caec0d817b034a47138..c1965f6051ef2af81dd8412abe169d87845bb033 100644 GIT binary patch delta 24 gcmaFp@X&$FCDET<0BnZ{w*UYD delta 24 gcmaFp@X&$FCDET<0BnK?w*UYD diff --git a/tests/data/acpi/q35/DSDT.acpihmat b/tests/data/acpi/q35/DSDT.acpihmat index 8c1e05a11a328ec1cc6f86e36e52c28f41f9744e..f24d4874bff8d327a165ed7c36de507aea114edd 100644 GIT binary patch delta 24 fcmeD4?(^ny33dtTQ)OUa+&+=(3ZvY{`|DKzU@Hhn delta 24 fcmeD4?(^ny33dtTQ)OUa+%}Qx3ZwkS`|DKzU?vDi diff --git a/tests/data/acpi/q35/DSDT.bridge b/tests/data/acpi/q35/DSDT.bridge index 6f1464b6c712d7f33cb4b891b7ce76fe228f44c9..424d51bd1cb39ea73501ef7d0044ee52cec5bdac 100644 GIT binary patch delta 24 gcmewz`a6`%CDF$oF>WH)6-K#@_k$DxTWtqt delta 24 fcmdn!veAXhCDF$oF?J%?6-N1u_k$DxTWAMo diff --git a/tests/data/acpi/q35/DSDT.dimmpxm b/tests/data/acpi/q35/DSDT.dimmpxm index fe5820d93d057ef09a001662369b15afbc5b87e2..76e451e829ec4c245315f7eed8731aa1be45a747 100644 GIT binary patch delta 24 gcmccad)=4ICDD~$3R?@yKo0BrFHn*aa+ diff --git a/tests/data/acpi/q35/DSDT.memhp b/tests/data/acpi/q35/DSDT.memhp index 9bc11518fc57687ca789dc70793b48b29a0d74ed..4e9cb3dc6896bb79ccac0fe342a404549f6610e8 100644 GIT binary patch delta 24 gcmdnsy}_HyCD7Sg;8$f{S^uTTRaEr delta 24 fcmZp7Zg=K#33dr-S7cyd?48JUg;9Rv{S^uTTQ>*m diff --git a/tests/data/acpi/q35/DSDT.nohpet b/tests/data/acpi/q35/DSDT.nohpet index e8202e6ddfbe96071f32f1ec05758f650569943e..83d1aa00ac5686df479673fb0d7830f946e25dea 100644 GIT binary patch delta 24 gcmca?f7zbPCDn+a delta 24 gcmaFv@Z5pRCDn+a diff --git a/tests/data/acpi/q35/DSDT.tis.tpm12 b/tests/data/acpi/q35/DSDT.tis.tpm12 index c96b5277a14ae98174408d690d6e0246bd932623..0ebdf6fbd77967f1ab5d5337b7b1fed314cfaca8 100644 GIT binary patch delta 24 gcmdnzy3du%CDyjp@iVCN7s?mk^h31_s6r6S=N1%5A)#+64f6_X&Rh delta 26 icmX>yjp@iVCN7s?mk^h31_s9U6S=N1%5S`%+64f6@(F(c diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index 48e5634d4b..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,17 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/DSDT", -"tests/data/acpi/q35/DSDT.tis", -"tests/data/acpi/q35/DSDT.bridge", -"tests/data/acpi/q35/DSDT.mmio64", -"tests/data/acpi/q35/DSDT.ipmibt", -"tests/data/acpi/q35/DSDT.cphp", -"tests/data/acpi/q35/DSDT.memhp", -"tests/data/acpi/q35/DSDT.acpihmat", -"tests/data/acpi/q35/DSDT.numamem", -"tests/data/acpi/q35/DSDT.dimmpxm", -"tests/data/acpi/q35/DSDT.nohpet", -"tests/data/acpi/q35/DSDT.tis.tpm2", -"tests/data/acpi/q35/DSDT.tis.tpm12", -"tests/data/acpi/q35/DSDT.multi-bridge", -"tests/data/acpi/q35/DSDT.ivrs", -"tests/data/acpi/q35/DSDT.xapic", From patchwork Mon Nov 15 16:38:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555396 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=SoYJAl5d; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFXM3kSrz9sR4 for ; Tue, 16 Nov 2021 03:49:23 +1100 (AEDT) Received: from localhost ([::1]:37966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmfAX-0006yO-BM for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:49:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0B-0002m2-D9 for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf09-0005F3-T1 for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994317; 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=jRD2/IioiIoVIn6009mdQAigxmvDmmRgeeMF/xF2ruo=; b=SoYJAl5drpY8PBdy5RoVteMEs+jxVufJUUHoGk+51cEB1nAf+wiLFyNotqxmfjEle61Y4F RH/QnQ4w1E8wnukHykcF4xnJqg2c2OCs9Yv0ui4TlRDN9UoEoubTJ4sZHaeuZ6zzNCIXVe /njrdAY+dadH1+UMX6WCEIULQcb4JZU= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-F9bMm6UDMeWXcpKxF0hQfw-1; Mon, 15 Nov 2021 11:38:36 -0500 X-MC-Unique: F9bMm6UDMeWXcpKxF0hQfw-1 Received: by mail-ed1-f72.google.com with SMTP id b15-20020aa7c6cf000000b003e7cf0f73daso2199241eds.22 for ; Mon, 15 Nov 2021 08:38:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=jRD2/IioiIoVIn6009mdQAigxmvDmmRgeeMF/xF2ruo=; b=vB3Wua/9kIfoVvD/A8OMaQWollShc4fiiuMa9wfVkY80gtT7G3Y2cXSZSw0yrYehaM C+TdGzPGA2etTBXYWaQQpoXHOJ3qSdh44dhGjSGf5qemLDvrDdlh1TvSSISua+AD0dVq 01udkYkNzTWq6vnEDFQ7CRq0oTHy2GCnBTTl+wdDKFV7KURIORE4iJpuWgpHDWJ8zpKC FHP+sWynU3oYgiT42ItpR+w25x6JNzPjV/ajd4ZEy93EDQNRrDi+DalgcnKLNO28486a 3kwDHxIdrZlguX33mWiLD7TcvN8FcPLtVAuir4dmwMUq/8BjpQ2iRYgF52xr9TlS+wnl 4wjA== X-Gm-Message-State: AOAM532OIiF/AyjotywP72pJcBD2Qvi8WCCL+Z1H0PJQUBIzQmrha2II CAjEsUomHxIxHjbwsYr5nWI33h8aFm8U96W3IPEBjmAG5/b7wIrN/jElD9ye6coZxn269aJqRhn +hp91A7oli+Ja3Htk1tb2jfTNpDWP8Fml8VWcKvLWbMpZyo9b8oHAwjU7t0Qd X-Received: by 2002:a17:906:619:: with SMTP id s25mr339594ejb.237.1636994314464; Mon, 15 Nov 2021 08:38:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfFlS/X56Klrc+BMHdQG/ag3vPLt75Z8R9s1KnwmWXmCV7cZnTRKqhfx3lao8/d9AQSKrJCA== X-Received: by 2002:a17:906:619:: with SMTP id s25mr339542ejb.237.1636994314122; Mon, 15 Nov 2021 08:38:34 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id l11sm7881877edb.28.2021.11.15.08.38.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:38:33 -0800 (PST) Date: Mon, 15 Nov 2021 11:38:23 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 11/20] virtio: use virtio accessor to access packed descriptor flags Message-ID: <20211115163607.177432-12-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jason Wang We used to access packed descriptor flags via address_space_{write|read}_cached(). When we hit the cache, memcpy() is used which is not an atomic operation which may lead a wrong value is read or wrote. So this patch switches to use virito_{stw|lduw}_phys_cached() to make sure the aceess is atomic. Fixes: 86044b24e865f ("virtio: basic packed virtqueue support") Cc: qemu-stable@nongnu.org Signed-off-by: Jason Wang Message-Id: <20211111063854.29060-1-jasowang@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index cc69a9b881..939bcbfeb9 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -507,11 +507,9 @@ static void vring_packed_desc_read_flags(VirtIODevice *vdev, MemoryRegionCache *cache, int i) { - address_space_read_cached(cache, - i * sizeof(VRingPackedDesc) + - offsetof(VRingPackedDesc, flags), - flags, sizeof(*flags)); - virtio_tswap16s(vdev, flags); + hwaddr off = i * sizeof(VRingPackedDesc) + offsetof(VRingPackedDesc, flags); + + *flags = virtio_lduw_phys_cached(vdev, cache, off); } static void vring_packed_desc_read(VirtIODevice *vdev, @@ -564,8 +562,7 @@ static void vring_packed_desc_write_flags(VirtIODevice *vdev, { hwaddr off = i * sizeof(VRingPackedDesc) + offsetof(VRingPackedDesc, flags); - virtio_tswap16s(vdev, &desc->flags); - address_space_write_cached(cache, off, &desc->flags, sizeof(desc->flags)); + virtio_stw_phys_cached(vdev, cache, off, desc->flags); address_space_cache_invalidate(cache, off, sizeof(desc->flags)); } From patchwork Mon Nov 15 16:38:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555399 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TJaivcPy; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFb70tl5z9sR4 for ; Tue, 16 Nov 2021 03:51:47 +1100 (AEDT) Received: from localhost ([::1]:43026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmfCp-0001zp-Tr for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:51:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0F-00033V-Mx for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52938) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0D-0005Fj-S0 for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994321; 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=40DjtVawOkvSfGu4Q5CJerXc3MdyuapDarfgCyKOILc=; b=TJaivcPyrbVQQvHcpShvz+4tnzGJQn/g7LFBoYcqnAMkm1gU524QwaVjYErLz/2YVrWq/f dBXNaZQI68c4EOE0ObiEmgmkrDlMBFoqPjhXwu9HM2QbV4kjHyYV0ITMz/E7MXs2i4wEf0 3RdkPi9tjkuYXpo4o32CZIxz8pOfJQo= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-540-KprIiqXuOXSu-ne5H3obug-1; Mon, 15 Nov 2021 11:38:39 -0500 X-MC-Unique: KprIiqXuOXSu-ne5H3obug-1 Received: by mail-ed1-f71.google.com with SMTP id w13-20020a05640234cd00b003e2fde5ff8aso14469725edc.14 for ; Mon, 15 Nov 2021 08:38:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=40DjtVawOkvSfGu4Q5CJerXc3MdyuapDarfgCyKOILc=; b=0z5UUO1lMFszCvJl+wj7Bux8j6IDfPsQgxGX3Xaa5X26689yPBc//137A5EBwWy+s9 45yEDBagmpBv93A6W1VRX3ZGwQP5ndrhpe5AbHJZiJTVdpNTuWKKEzbwio/tUIOFMgff DEpzue/uMgdbjqifJ47efGt+Vgq3MQwJ0zh7x8jWmUurTy2yFKYI1jvABjdxeN7KIeXH SBrDI9naUQzbHUJRRjcdBAoIzVeE//TlpKI/zUVri6cXzptYUV+mEn3A16zGP7dHJP8X nMXrsJMxHEvMue3wLPWxf9Hemh1PKsuPFDouyw7ciVpaqE9+mhjNasD2H11+bujOshNj qqTw== X-Gm-Message-State: AOAM531c8S1ZpNV/j4b4mCWdpALhMtQsAU+xw41kouHgOoR/ip46NtVH qv1gWl/WzkbuZp0WC/kDBlr+vF5YRFctcJIm5fwRiALi5Em6hVDEN4vMK+QkbsIIClSZFCQ9Q9F AfcLlXd8sh8Tceje94Rk/RpjgdMQnNESQoKuHLRt8h/U7AG8dJZ9yFz32DZ4x X-Received: by 2002:a05:6402:2155:: with SMTP id bq21mr56414514edb.181.1636994317967; Mon, 15 Nov 2021 08:38:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5M+QVzE1CSmxBOJ6M7xiOp7SeBwT4kunxC7zwG0nttNwIvbI2YyJdUN2negWqQ/vZFruLCA== X-Received: by 2002:a05:6402:2155:: with SMTP id bq21mr56414462edb.181.1636994317688; Mon, 15 Nov 2021 08:38:37 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id dp16sm7220349ejc.34.2021.11.15.08.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:38:37 -0800 (PST) Date: Mon, 15 Nov 2021 11:38:34 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 12/20] virtio: use virtio accessor to access packed event Message-ID: <20211115163607.177432-13-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jason Wang We used to access packed descriptor event and off_wrap via address_space_{write|read}_cached(). When we hit the cache, memcpy() is used which is not atomic which may lead a wrong value to be read or wrote. This patch fixes this by switching to use virito_{stw|lduw}_phys_cached() to make sure the access is atomic. Fixes: 683f7665679c1 ("virtio: event suppression support for packed ring") Cc: qemu-stable@nongnu.org Signed-off-by: Jason Wang Message-Id: <20211111063854.29060-2-jasowang@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 939bcbfeb9..ea7c079fb0 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -247,13 +247,10 @@ static void vring_packed_event_read(VirtIODevice *vdev, hwaddr off_off = offsetof(VRingPackedDescEvent, off_wrap); hwaddr off_flags = offsetof(VRingPackedDescEvent, flags); - address_space_read_cached(cache, off_flags, &e->flags, - sizeof(e->flags)); + e->flags = virtio_lduw_phys_cached(vdev, cache, off_flags); /* Make sure flags is seen before off_wrap */ smp_rmb(); - address_space_read_cached(cache, off_off, &e->off_wrap, - sizeof(e->off_wrap)); - virtio_tswap16s(vdev, &e->off_wrap); + e->off_wrap = virtio_lduw_phys_cached(vdev, cache, off_off); virtio_tswap16s(vdev, &e->flags); } @@ -263,8 +260,7 @@ static void vring_packed_off_wrap_write(VirtIODevice *vdev, { hwaddr off = offsetof(VRingPackedDescEvent, off_wrap); - virtio_tswap16s(vdev, &off_wrap); - address_space_write_cached(cache, off, &off_wrap, sizeof(off_wrap)); + virtio_stw_phys_cached(vdev, cache, off, off_wrap); address_space_cache_invalidate(cache, off, sizeof(off_wrap)); } @@ -273,8 +269,7 @@ static void vring_packed_flags_write(VirtIODevice *vdev, { hwaddr off = offsetof(VRingPackedDescEvent, flags); - virtio_tswap16s(vdev, &flags); - address_space_write_cached(cache, off, &flags, sizeof(flags)); + virtio_stw_phys_cached(vdev, cache, off, flags); address_space_cache_invalidate(cache, off, sizeof(flags)); } From patchwork Mon Nov 15 16:38:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555390 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZTVvZNW5; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFQj0ZFRz9sR4 for ; Tue, 16 Nov 2021 03:44:29 +1100 (AEDT) Received: from localhost ([::1]:51272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmf5m-0005L6-DE for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:44:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0I-0003Ds-Hf for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45849) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0H-0005G5-3L for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994324; 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=Y05iFeqDcZmIQw96oojBdfWCBMxpMBgO3kDemc5FvLM=; b=ZTVvZNW54qv+rTwloBsPW6bhOPknL8qZYO82anCJZql6CFkbfDFcgneIU3CIKMKAyqrGTC RnsSSUSfidM41cVZD9U77us7SkCqVviKfHO9GPssU5CTE2eLl3cK0CIHHfCzIt6VPFQywC G+LDnNKxp5O2RCCPseUuzRGohPnkweA= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-485-5zph96HSN8il0DtEFA8cdA-1; Mon, 15 Nov 2021 11:38:43 -0500 X-MC-Unique: 5zph96HSN8il0DtEFA8cdA-1 Received: by mail-ed1-f71.google.com with SMTP id c1-20020aa7c741000000b003e7bf1da4bcso3256526eds.21 for ; Mon, 15 Nov 2021 08:38:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Y05iFeqDcZmIQw96oojBdfWCBMxpMBgO3kDemc5FvLM=; b=DABcHp+NWDJqod6e9v48yoOSyQ4C8uqUg/76Nod7P0qE2IP04C2IyxF7RwZV58ebpr QoWD5Mocvni4GIq4Fg/ey8u/O5OPYjnL3HSANXj89yRbRkyBpm/c3Q7r6l+okL26s0tT CSzP5rir0hcnXt237GsLgTJjizDfLL2gRpcwWfkFvK24FHi5b4DxPAvKMQeCvPtZKVzT WGQKH5FToLmeovJEwYOQVPPpgXdVkO/7MvLlUagjGO7Cl8OfDsjhSfXmjXWK/KkMUE9B oTw3HM7Gi4qwKqlr4BsH+MXc+kUhFtbXpKMHoNDqlnn3oAjFqholL2BZShXqZJkmOs/q yd2A== X-Gm-Message-State: AOAM532Fdbh8HgDtvXUcbiYt0Pcjs+c0WhIlBtS//Uf32Bcjh5Lvi+uR P/5oqd00U+7WATyBAn3onMj5irEJi6NcYGDseGeCY787dTX8Lm580Y4oRGFOaVosGXBXW/losbd UunkQMLLlpglHzIAMv5YOtHanrnhicPcIQx2QgHrBOAZrTyi/k4DAdduqTwMS X-Received: by 2002:aa7:cd5c:: with SMTP id v28mr106897edw.6.1636994322072; Mon, 15 Nov 2021 08:38:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEt4CYrSiztWCX/tzsaTrSvt+SQ3Grz7dYf5kGA/6jU+Gqgh3UqTjV6/7+NSOMLtI2chX6IA== X-Received: by 2002:aa7:cd5c:: with SMTP id v28mr106857edw.6.1636994321865; Mon, 15 Nov 2021 08:38:41 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id m22sm5349428eda.97.2021.11.15.08.38.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:38:41 -0800 (PST) Date: Mon, 15 Nov 2021 11:38:38 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 13/20] vdpa: Replace qemu_open_old by qemu_open at Message-ID: <20211115163607.177432-14-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Eugenio =?utf-8?b?UMOpcmV6?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eugenio Pérez There is no reason to keep using the old one, since we neither use the variadics arguments nor open it with O_DIRECT. Also, net_client_init1, the caller of net_init_vhost_vdpa, wants all net_client_init_fun to use Error API, so it's a good step in that direction. Signed-off-by: Eugenio Pérez Message-Id: <20211112193431.2379298-2-eperezma@redhat.com> Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 373b706b90..1a7250b980 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -261,7 +261,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA); opts = &netdev->u.vhost_vdpa; - vdpa_device_fd = qemu_open_old(opts->vhostdev, O_RDWR); + vdpa_device_fd = qemu_open(opts->vhostdev, O_RDWR, errp); if (vdpa_device_fd == -1) { return -errno; } From patchwork Mon Nov 15 16:38:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555392 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=D/uFWjhg; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFTg3lRNz9sR4 for ; Tue, 16 Nov 2021 03:47:03 +1100 (AEDT) Received: from localhost ([::1]:58272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmf8H-0001fo-Cq for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:47:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0N-0003Nx-P4 for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53172) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0L-0005GS-Cv for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994328; 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=TuamMpNTeUOPZaWH0fD/y6G0iKsFC/c1mwJN93yAuFU=; b=D/uFWjhgPsS4wk6x0euoks+zcnEI7EVDw5C8RbZGcelJB5EEV3a/9Vuab2sKqhQa6ZUqQC gGzGQJpycRZY9yXK5kIHSiWtUlK5eM7nM4jFZ7JYGsgu+lrX4geMWZky6fxkhiZyt9MD9/ JNZMyIBfiANzrFUQ9ggzvDabrcRCODM= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-521-1LfsDRNRPmS_oP1q6ib5oA-1; Mon, 15 Nov 2021 11:38:47 -0500 X-MC-Unique: 1LfsDRNRPmS_oP1q6ib5oA-1 Received: by mail-ed1-f71.google.com with SMTP id h18-20020a056402281200b003e2e9ea00edso14500034ede.16 for ; Mon, 15 Nov 2021 08:38:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=TuamMpNTeUOPZaWH0fD/y6G0iKsFC/c1mwJN93yAuFU=; b=J/5kuaI/yTZZXInDDHhHWJhMcH2PGAVy5zAefaLA8bBDsP1nVOVF9sYpT/D8FPEw4B NbNCj41PkyzfWmZeypwDmpVxV2c0vBuLTVovw/wo/YgNbt2XhsjagkJaUiDH7Bc8sc13 zd1I4TcD7AkLHLh6jizZIuD98oiSPKKwdmBVX1+TBV05wtC5Z1DkR6eE2ZkRe8/Wdl94 VSwt1HVcOkDhZce4hekSq/GRlTx08cqNaD4WuprAesIbJHfUYXDY+GOWmKy63tMcq2ES uqVoHS5n0B/CyfeC7F1X9MtWvGcdhvMrYqbnuWRP9Vt9Coh7OYQpyyVe6XLPGdtddxuj rbcQ== X-Gm-Message-State: AOAM532lpnWzOcfq92y3/JgVWfiIwqT60iVpSc2akhibps6nUeib7e/4 Oq9ItIaSNY4Gi19pKe+BL5A+mUSJU0GcPYsHXkdGwHhp+rpUeszGy0e2bMFUa5HtfF7CEvPlNzi TOfMeHyTfeZ9F0QBkW9ZEwKFMiU7hIekiEhoFUqm6F25o/SCceVEQSnYeXVDd X-Received: by 2002:a05:6402:1c84:: with SMTP id cy4mr29755edb.358.1636994325965; Mon, 15 Nov 2021 08:38:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJz37KprdFt6G4YjkKOMpluizX7VcFzM4FRRjKxlO/wQSUSRWAnN6pk5GM2SGRuDenMXiGxquw== X-Received: by 2002:a05:6402:1c84:: with SMTP id cy4mr29717edb.358.1636994325770; Mon, 15 Nov 2021 08:38:45 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id nd22sm6983693ejc.98.2021.11.15.08.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:38:45 -0800 (PST) Date: Mon, 15 Nov 2021 11:38:42 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 14/20] vdpa: Check for existence of opts.vhostdev Message-ID: <20211115163607.177432-15-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Eugenio =?utf-8?b?UMOpcmV6?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eugenio Pérez Since net_init_vhost_vdpa is trying to open it. Not specifying it in the command line crash qemu. Fixes: 7327813d17 ("vhost-vdpa: open device fd in net_init_vhost_vdpa()") Signed-off-by: Eugenio Pérez Message-Id: <20211112193431.2379298-3-eperezma@redhat.com> Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1a7250b980..2e3c22a8c7 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -260,6 +260,10 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA); opts = &netdev->u.vhost_vdpa; + if (!opts->vhostdev) { + error_setg(errp, "vdpa character device not specified with vhostdev"); + return -1; + } vdpa_device_fd = qemu_open(opts->vhostdev, O_RDWR, errp); if (vdpa_device_fd == -1) { From patchwork Mon Nov 15 16:38:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555394 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KaID4/BK; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFVR0C3hz9sR4 for ; Tue, 16 Nov 2021 03:47:43 +1100 (AEDT) Received: from localhost ([::1]:60392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmf8u-00034w-TI for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:47:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0S-0003XJ-1S for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44719) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0Q-0005I9-1I for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:38:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994333; 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=g++bwUMm88irLRB02LM9vDTYphSEUI2sCRSx57kjueo=; b=KaID4/BK2If2VwX3JNocG7d+GacEldqCW75MVIgimyu8JXVGledcG6xCU3Qy1dmKbla6DR zX3z9m26JrhjwcWGRBvUt72snoECrSAylZ0FMaFWABVoqkiWQx7pFwr2I9SIWyABqPdTQO 9JXsDgMqVL1pYPxf9i04ZwHk3Po/l10= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-154-xFH6HxUjP_Wbw_5n0vPvZA-1; Mon, 15 Nov 2021 11:38:52 -0500 X-MC-Unique: xFH6HxUjP_Wbw_5n0vPvZA-1 Received: by mail-ed1-f72.google.com with SMTP id a3-20020a05640213c300b003e7d12bb925so2099026edx.9 for ; Mon, 15 Nov 2021 08:38:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=g++bwUMm88irLRB02LM9vDTYphSEUI2sCRSx57kjueo=; b=Ahhr7nlCOaBaGGgz6v9QDDw67d6aPs6lSth6fZ8EoCRbsgAXfZuX1lAnnNu7s7YoFz JVIPxCgQA3AKb3S9n7kNvrAz/cLs21cxBJg4E+g/H4BS1BvT1pK2I7y9vve7O467ECE7 RMLFF9m00U45Vz7kn4mnii3pCoeIAz8bdqlyr96dZ7LeqB6nhoev8EVeFoXdXIG6Dxae cQxwgVaVJGz50YOm12WR3Cbfv+kKDUQH8okYBHn7+X7faTnk5l4A2XcQ25z6asCGpdZY BZ/ksXtsWytWD3Jw0ALEsuawVW7QT3qPsRJQWxiVyDw4sdtA7+ISZ8dZN2ssPaxmli5L mUEw== X-Gm-Message-State: AOAM53288jjlzBoLJ8cdAMJ40fkTJGiKmVnUu/KH6mDD5OP/i7dsfeKX fvP8EbC12nGU15WktDjwzeI+N5h/fFjpH5A5813SjK+e/++cBMiaSgeU80e1se/0LWn2ybR1KDS VZJVQ+ZWoSDd2fYqGp7GnX0etqUByHwQBvw3ytMeGZVvJuS5fLUzxyxtPiDM/ X-Received: by 2002:a17:907:1dd5:: with SMTP id og21mr364193ejc.233.1636994330434; Mon, 15 Nov 2021 08:38:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvY6oFQ88VFmJXUHFvzbhSE3Q68o6rjieDAwV8hECAMCiPb6BMQDFfpipW6TQrMUleHpSylQ== X-Received: by 2002:a17:907:1dd5:: with SMTP id og21mr364153ejc.233.1636994330173; Mon, 15 Nov 2021 08:38:50 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id yc16sm1943720ejb.122.2021.11.15.08.38.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:38:49 -0800 (PST) Date: Mon, 15 Nov 2021 11:38:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 15/20] pci: implement power state Message-ID: <20211115163607.177432-16-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Gerd Hoffmann This allows to power off pci devices. In "off" state the devices will not be visible. No pci config space access, no pci bar access, no dma. Default state is "on", so this patch (alone) should not change behavior. Use case: Allows hotplug controllers implement slot power. Hotplug controllers doing so should set the inital power state for devices in the ->plug callback. Signed-off-by: Gerd Hoffmann Message-Id: <20211111130859.1171890-2-kraxel@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 2 ++ hw/pci/pci.c | 25 +++++++++++++++++++++++-- hw/pci/pci_host.c | 6 ++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 5c4016b995..e7cdf2d5ec 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -268,6 +268,7 @@ typedef struct PCIReqIDCache PCIReqIDCache; struct PCIDevice { DeviceState qdev; bool partially_hotplugged; + bool has_power; /* PCI config space */ uint8_t *config; @@ -908,5 +909,6 @@ extern const VMStateDescription vmstate_pci_device; } MSIMessage pci_get_msi_message(PCIDevice *dev, int vector); +void pci_set_power(PCIDevice *pci_dev, bool state); #endif diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 4a84e478ce..e5993c1ef5 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1380,6 +1380,9 @@ static void pci_update_mappings(PCIDevice *d) continue; new_addr = pci_bar_address(d, i, r->type, r->size); + if (!d->has_power) { + new_addr = PCI_BAR_UNMAPPED; + } /* This bar isn't changed */ if (new_addr == r->addr) @@ -1464,8 +1467,8 @@ void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val_in, int if (range_covers_byte(addr, l, PCI_COMMAND)) { pci_update_irq_disabled(d, was_irq_disabled); memory_region_set_enabled(&d->bus_master_enable_region, - pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER); + (pci_get_word(d->config + PCI_COMMAND) + & PCI_COMMAND_MASTER) && d->has_power); } msi_write_config(d, addr, val_in, l); @@ -2182,6 +2185,8 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp) pci_qdev_unrealize(DEVICE(pci_dev)); return; } + + pci_set_power(pci_dev, true); } PCIDevice *pci_new_multifunction(int devfn, bool multifunction, @@ -2853,6 +2858,22 @@ MSIMessage pci_get_msi_message(PCIDevice *dev, int vector) return msg; } +void pci_set_power(PCIDevice *d, bool state) +{ + if (d->has_power == state) { + return; + } + + d->has_power = state; + pci_update_mappings(d); + memory_region_set_enabled(&d->bus_master_enable_region, + (pci_get_word(d->config + PCI_COMMAND) + & PCI_COMMAND_MASTER) && d->has_power); + if (!d->has_power) { + pci_device_reset(d); + } +} + static const TypeInfo pci_device_type_info = { .name = TYPE_PCI_DEVICE, .parent = TYPE_DEVICE, diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index cf02f0d6a5..7beafd40a8 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -74,7 +74,8 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uint32_t addr, /* non-zero functions are only exposed when function 0 is present, * allowing direct removal of unexposed functions. */ - if (pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) { + if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) || + !pci_dev->has_power) { return; } @@ -97,7 +98,8 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr, /* non-zero functions are only exposed when function 0 is present, * allowing direct removal of unexposed functions. */ - if (pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) { + if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) || + !pci_dev->has_power) { return ~0x0; } From patchwork Mon Nov 15 16:38:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555401 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IiK34ZbK; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFcz6Y7Hz9sR4 for ; Tue, 16 Nov 2021 03:53:23 +1100 (AEDT) Received: from localhost ([::1]:47496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmfEP-00052Q-FX for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:53:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0Y-0003Zh-QM for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:39:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0X-0005Ig-BV for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:39:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994340; 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=PBTLwx0PHeZdiY6CH6544AuYOzCiwI2d3fclfLXX6Uk=; b=IiK34ZbKQNTyI0d/z8IXeLtD6wseTnqJN/8vy1kFbzSVVSEXZLBH89M3Nr4Fz01uC5crkT fhELF6kIiU+/6D+H2KjtYM0rdtecaLOdG+WR5SgEp/RsfjbH8k9g4ldYmMTqioUP5TtpRE 5pIUZrrqIks8HGynaufbiueB2Kki4vI= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-233-lGwNEqk9PWqZIHLqAQ4Aqw-1; Mon, 15 Nov 2021 11:38:57 -0500 X-MC-Unique: lGwNEqk9PWqZIHLqAQ4Aqw-1 Received: by mail-ed1-f70.google.com with SMTP id v9-20020a50d849000000b003dcb31eabaaso14599413edj.13 for ; Mon, 15 Nov 2021 08:38:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PBTLwx0PHeZdiY6CH6544AuYOzCiwI2d3fclfLXX6Uk=; b=5Xzlj1AT1b6OicfpeYbCcYXT2ilze5QKxSydp+tluatNF03sitsnlLnOOQygNa4AXO UAZuwvVc9z2rvqVpiBHaJOgxIg4RAciy2He/53y1q7yudmpBf/kNhYExhE1JV0aeOEgu vmHG+0sAunQ8w0qYhz2Ch1cesIkDHZS91TSzXvOg5txdN20/L/VJGnkXowBdRwzeME3f NRwBBhsSiWd7o66OuAOOH/Kp+eXggO6MoXfeDPiOFvJ0nb9BJlNqLlKjxxHAWDkzA7ub jB4YqaZoLI+60ysQoTzAcSskL777+8BcwrGFxYobPC9X8/G4CeuGmzF/VaaNbiR0jsWE Cpew== X-Gm-Message-State: AOAM530+dfUZ3y5uPQlro2S9rIEh3D3ZQ0bWINETCk0W1ovmInGLYILe UHZh6lJQvs33ZEiPLQUmR1T+irkj+stQSK8JMYXdyO9p8ksox1M/0tHihg/cMJwCf/fOEfosR14 hs7hJ1veEWbr+veOROAkFULcOZN7DxeBpTwo/75j+2kqBsZnC4bLlQ+lGaLdl X-Received: by 2002:a05:6402:41a:: with SMTP id q26mr58873034edv.387.1636994336113; Mon, 15 Nov 2021 08:38:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJz31qq8/UPOH1DsalKos3c7zxAGveuEa2ELgA1mht3SLRoczilwzlMmGzLMnlNS/5Bu9pBRrg== X-Received: by 2002:a05:6402:41a:: with SMTP id q26mr58872996edv.387.1636994335920; Mon, 15 Nov 2021 08:38:55 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id u16sm7706666edr.43.2021.11.15.08.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:38:55 -0800 (PST) Date: Mon, 15 Nov 2021 11:38:51 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 16/20] pcie: implement slot power control for pcie root ports Message-ID: <20211115163607.177432-17-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Gerd Hoffmann With this patch hot-plugged pci devices will only be visible to the guest if the guests hotplug driver has enabled slot power. This should fix the hot-plug race which one can hit when hot-plugging a pci device at boot, while the guest is in the middle of the pci bus scan. Signed-off-by: Gerd Hoffmann Message-Id: <20211111130859.1171890-3-kraxel@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pcie.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 914a9bf3d1..13d11a57c7 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -366,6 +366,29 @@ static void hotplug_event_clear(PCIDevice *dev) } } +static void pcie_set_power_device(PCIBus *bus, PCIDevice *dev, void *opaque) +{ + bool *power = opaque; + + pci_set_power(dev, *power); +} + +static void pcie_cap_update_power(PCIDevice *hotplug_dev) +{ + uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; + PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(hotplug_dev)); + uint32_t sltcap = pci_get_long(exp_cap + PCI_EXP_SLTCAP); + uint16_t sltctl = pci_get_word(exp_cap + PCI_EXP_SLTCTL); + bool power = true; + + if (sltcap & PCI_EXP_SLTCAP_PCP) { + power = (sltctl & PCI_EXP_SLTCTL_PCC) == PCI_EXP_SLTCTL_PWR_ON; + } + + pci_for_each_device(sec_bus, pci_bus_num(sec_bus), + pcie_set_power_device, &power); +} + /* * A PCI Express Hot-Plug Event has occurred, so update slot status register * and notify OS of the event if necessary. @@ -434,6 +457,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, pci_word_test_and_set_mask(exp_cap + PCI_EXP_LNKSTA, PCI_EXP_LNKSTA_DLLLA); } + pcie_cap_update_power(hotplug_pdev); return; } @@ -451,6 +475,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, } pcie_cap_slot_event(hotplug_pdev, PCI_EXP_HP_EV_PDC | PCI_EXP_HP_EV_ABP); + pcie_cap_update_power(hotplug_pdev); } } @@ -625,6 +650,7 @@ void pcie_cap_slot_reset(PCIDevice *dev) PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_ABP); + pcie_cap_update_power(dev); hotplug_event_update_event_status(dev); } @@ -705,6 +731,7 @@ void pcie_cap_slot_write_config(PCIDevice *dev, pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA, PCI_EXP_SLTSTA_PDC); } + pcie_cap_update_power(dev); hotplug_event_notify(dev); @@ -731,6 +758,7 @@ int pcie_cap_slot_post_load(void *opaque, int version_id) { PCIDevice *dev = opaque; hotplug_event_update_event_status(dev); + pcie_cap_update_power(dev); return 0; } From patchwork Mon Nov 15 16:38:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555395 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LmQwUCX2; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFX05Nw8z9sR4 for ; Tue, 16 Nov 2021 03:49:03 +1100 (AEDT) Received: from localhost ([::1]:36850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmfAB-0006Dz-Qi for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:48:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0b-0003e1-H2 for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:39:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51303) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0a-0005It-1N for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:39:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994343; 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=NlgH4ZQ1sk94dkzayfKgJifhXqc9wwB8Ay+7c8m4Bko=; b=LmQwUCX2Av+VDXideT2wL4YXLpNJTw5VOtKLOCIMd4tqdx/Wx08sxqXQTC0TytP2ijcMCn Lyw/RIgeK80UukxC0G2LR4mxNal16vX1+gq9GI99brAAWGRuBQzeUcZoNeqLNlPpq8ttMB H8sW7n1dMXuSzJS3a+GmaVlKEXA88/k= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-585-rT0HDrnwMSmzO0fbMKUTwg-1; Mon, 15 Nov 2021 11:39:02 -0500 X-MC-Unique: rT0HDrnwMSmzO0fbMKUTwg-1 Received: by mail-ed1-f72.google.com with SMTP id v10-20020aa7d9ca000000b003e7bed57968so3293220eds.23 for ; Mon, 15 Nov 2021 08:39:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NlgH4ZQ1sk94dkzayfKgJifhXqc9wwB8Ay+7c8m4Bko=; b=VzaLC1FEyMti0tauELAxhO1fUszkpZ9Jrl2l61QQuOHln6Q37sWzAXVLNkgq0JKuLr OOrsZhLWmsPNtCJ94WuDRBTtWxm1aRbzNIqYFvUplWuyRKgEh106f/VpdPiwl1cFXAUn X/OYIprZ8IVMlSkLeCLxjIQIiodjCikwh1Ufg6S09DG77mWIgfjuc7WQtfoMIAD5lENl d1Ttrp2wX1JHiAU5BYl8uoqsx1gbVqqRZzYpiHsqzEoYu1UE8U/txrvnpmQZQYOr9auj Q4hNt7g5p9Pn0ou3FW4k7g5GGTln/5GOPualVX0KWrIRGpvuNRlwjFG2e5AD8NHINy8j gO+g== X-Gm-Message-State: AOAM530hpN11Lle8MtZdVjSVqPq0UT0AfHICqx1KFynUY0tPLS8TH77F XWhg3m967yUkPKOI3Iddp7JmVHNH74q0LeyX18S445nV5ZSHGeUhiBdV88OhlImEJ84QZY+s+vY hjkN9zKkTfIJgNcldr7Hn6xugbnA2wPU/2ijbtyj2uB/lxCdqyYMOTnpZG5qd X-Received: by 2002:a05:6402:278e:: with SMTP id b14mr32592ede.354.1636994340542; Mon, 15 Nov 2021 08:39:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwszcQIFyXnBSPIpoSRh4bGxSQ+oBpDXPMd7ymP0w6jtgd9wAVNUSh6lAMLqnG9izEdHdkilQ== X-Received: by 2002:a05:6402:278e:: with SMTP id b14mr32544ede.354.1636994340322; Mon, 15 Nov 2021 08:39:00 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id ch28sm2408929edb.72.2021.11.15.08.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:38:59 -0800 (PST) Date: Mon, 15 Nov 2021 11:38:56 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 17/20] pcie: add power indicator blink check Message-ID: <20211115163607.177432-18-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Gerd Hoffmann Refuse to push the attention button in case the guest is busy with some hotplug operation (as indicated by the power indicator blinking). Signed-off-by: Gerd Hoffmann Message-Id: <20211111130859.1171890-4-kraxel@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pcie.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 13d11a57c7..b92dbff118 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -506,6 +506,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, PCIDevice *hotplug_pdev = PCI_DEVICE(hotplug_dev); uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap; uint32_t sltcap = pci_get_word(exp_cap + PCI_EXP_SLTCAP); + uint16_t sltctl = pci_get_word(exp_cap + PCI_EXP_SLTCTL); /* Check if hot-unplug is disabled on the slot */ if ((sltcap & PCI_EXP_SLTCAP_HPC) == 0) { @@ -521,6 +522,12 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, return; } + if ((sltctl & PCI_EXP_SLTCTL_PIC) == PCI_EXP_SLTCTL_PWR_IND_BLINK) { + error_setg(errp, "Hot-unplug failed: " + "guest is busy (power indicator blinking)"); + return; + } + dev->pending_deleted_event = true; /* In case user cancel the operation of multi-function hot-add, From patchwork Mon Nov 15 16:39:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555387 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NuayXI9O; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFMc1jlRz9sR4 for ; Tue, 16 Nov 2021 03:41:48 +1100 (AEDT) Received: from localhost ([::1]:42406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmf3C-0007mN-2k for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:41:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0f-0003ru-Ot for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:39:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28814) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0d-0005JD-Tb for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:39:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994347; 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=J7h9UEgXNlCPSuADnaNZX+Ne/rmWtOMtPjje0QVsjLA=; b=NuayXI9O/gTdvI7dDzp7+hlSlLP1gQXGzJEovwAbgtZmeQ1zHuXw6GLnQuH1EzgjZeyjiy W3AWD3p6wzBEWgK0FpWbpRot5OWhtzNOx6lTV2hkuBZUDQ2CM4vmDAkk9OKZ36UYimc7lt 2msOnRaGoZ17SEypEWShW7+5IaAArIQ= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-454-F-hhEFVeMUerVkftjsFSig-1; Mon, 15 Nov 2021 11:39:05 -0500 X-MC-Unique: F-hhEFVeMUerVkftjsFSig-1 Received: by mail-ed1-f70.google.com with SMTP id g3-20020a056402424300b003e2981e1edbso14636324edb.3 for ; Mon, 15 Nov 2021 08:39:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=J7h9UEgXNlCPSuADnaNZX+Ne/rmWtOMtPjje0QVsjLA=; b=B32sPuI50G2gY7FCapuzTwr9UfHAsnzqoDpsQUnZ4r8ilw3sm7dvdDJjQSfP3yJIFZ PVqXWPwF/lqJ2LvAWBfY9INhP5LiPpj+0FQqURtMMtdQ+Hl/8bSClazZOBR+oCzaSwBf MBBg4z56cIatJUT878vCFhZgpi3s3HgX1zl60SXD/Dsk+NFpVlhhVd05Llakt2qhNRh7 +8/kMlZ0N7IRYQ+VprHyqAYF7Q/+cwBhK5NLABdC66zsinrQip21T12ja1cBdKTroheJ IZ5Jpd4jdnHs2lElNGBowupdZtV9/CznSNkqNsS8hzjWzT5nFZAz235rfOdLJK/Xq2wS OdKw== X-Gm-Message-State: AOAM533lmEKGZGt4xctq6au37qSdv3r0pBz4XYcNaeeo2XazFwZHHDxH 0qDcgJFbz4nmmrr3ay1hzyD9gkyJxxvAai2qtbAEohwlA/edBXyXrTxfNw1Y/QlUUuc+K1ZTBuu x3HEq31j/O0TXH5AEFtTCuwFsOIkSKVB7ELTYrWMFdoe3TTxMa9bQzo68vr7x X-Received: by 2002:a17:906:6547:: with SMTP id u7mr402541ejn.544.1636994344277; Mon, 15 Nov 2021 08:39:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwehhJOfen2ZwdC/xvmV2+lEdvCBW16yFX+wNRb4mwmoFuhRQHrVQMRVLMB9nh7tgTyB9gfUQ== X-Received: by 2002:a17:906:6547:: with SMTP id u7mr402498ejn.544.1636994344074; Mon, 15 Nov 2021 08:39:04 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id e4sm7090783ejs.13.2021.11.15.08.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:39:03 -0800 (PST) Date: Mon, 15 Nov 2021 11:39:00 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 18/20] pcie: factor out pcie_cap_slot_unplug() Message-ID: <20211115163607.177432-19-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Gerd Hoffmann No functional change. Signed-off-by: Gerd Hoffmann Message-Id: <20211111130859.1171890-5-kraxel@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pcie.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index b92dbff118..959bf074b2 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -497,6 +497,25 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) object_unparent(OBJECT(dev)); } +static void pcie_cap_slot_do_unplug(PCIDevice *dev) +{ + PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(dev)); + uint8_t *exp_cap = dev->config + dev->exp.exp_cap; + uint32_t lnkcap = pci_get_long(exp_cap + PCI_EXP_LNKCAP); + + pci_for_each_device_under_bus(sec_bus, pcie_unplug_device, NULL); + + pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA, + PCI_EXP_SLTSTA_PDS); + if (dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA || + (lnkcap & PCI_EXP_LNKCAP_DLLLARC)) { + pci_word_test_and_clear_mask(exp_cap + PCI_EXP_LNKSTA, + PCI_EXP_LNKSTA_DLLLA); + } + pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA, + PCI_EXP_SLTSTA_PDC); +} + void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -676,7 +695,6 @@ void pcie_cap_slot_write_config(PCIDevice *dev, uint32_t pos = dev->exp.exp_cap; uint8_t *exp_cap = dev->config + pos; uint16_t sltsta = pci_get_word(exp_cap + PCI_EXP_SLTSTA); - uint32_t lnkcap = pci_get_long(exp_cap + PCI_EXP_LNKCAP); if (ranges_overlap(addr, len, pos + PCI_EXP_SLTSTA, 2)) { /* @@ -726,17 +744,7 @@ void pcie_cap_slot_write_config(PCIDevice *dev, (val & PCI_EXP_SLTCTL_PIC_OFF) == PCI_EXP_SLTCTL_PIC_OFF && (!(old_slt_ctl & PCI_EXP_SLTCTL_PCC) || (old_slt_ctl & PCI_EXP_SLTCTL_PIC_OFF) != PCI_EXP_SLTCTL_PIC_OFF)) { - PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(dev)); - pci_for_each_device_under_bus(sec_bus, pcie_unplug_device, NULL); - pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA, - PCI_EXP_SLTSTA_PDS); - if (dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA || - (lnkcap & PCI_EXP_LNKCAP_DLLLARC)) { - pci_word_test_and_clear_mask(exp_cap + PCI_EXP_LNKSTA, - PCI_EXP_LNKSTA_DLLLA); - } - pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA, - PCI_EXP_SLTSTA_PDC); + pcie_cap_slot_do_unplug(dev); } pcie_cap_update_power(dev); From patchwork Mon Nov 15 16:39:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555398 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Xj/JTXbO; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFZq28JQz9sR4 for ; Tue, 16 Nov 2021 03:51:31 +1100 (AEDT) Received: from localhost ([::1]:42184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmfCb-0001LH-6K for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:51:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0k-000447-Dl for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:39:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40161) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0i-0005JS-Ua for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:39:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994352; 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=wpVmE++va9UHElfTtz5HyYu3V0KXTon88DKjQZxTj9s=; b=Xj/JTXbOjfHPJuWmIdA5zUyzVBn6rwpOcGD+RbYhAvhD4WkNEcIsvjv+gVlu2D10P2/c7C KeAEdaOwKYdK8RXkQoWdH3/Kf/hWQlwCzRxlnYcVSiZ9+B9+bSg+5JZfWL9YvaL1Jjvh5T ms10TwCURSljmc96WAEIKwsSvTA2s7Q= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-180-WCbxP5wKOEKpfYdT9SuKzA-1; Mon, 15 Nov 2021 11:39:10 -0500 X-MC-Unique: WCbxP5wKOEKpfYdT9SuKzA-1 Received: by mail-ed1-f70.google.com with SMTP id m17-20020aa7d351000000b003e7c0bc8523so2842881edr.1 for ; Mon, 15 Nov 2021 08:39:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wpVmE++va9UHElfTtz5HyYu3V0KXTon88DKjQZxTj9s=; b=Z0kTdXowIuCDR+GvYXznaHQLms8BR0D8KvT81obXCXhd3wsluPPOQI9TvNHwoOUMhB h4kt9sTIprMkBIhu9q1w+wr273cNNBSk/93Vm05Nq+SyOqQYt0K74K204djOtwu610/A XDVefv9yAcJRCwskp62gi7sSzjV2/r/H5I9OkKGSPZMgHcesLaV7KBAswOGlhGAdVZpy TUaAyc/TZQ5A/avElrYA1sxDUig+wupr0XakBey1w6DTgjFO4RjRYx6sSvCJ2szDiiyT Jg5NBKKesOgMyJkGN71g2nsZNEFsUjH5iPlGKa6MhFK/iMe06GrIG2jRAhsuAIY3zCde eoYg== X-Gm-Message-State: AOAM533X1qTCXsfUR2uz43UmiQlD32V4/6Yv0ZjksUxafSRRRtk0tHte 3jZQFV+5QXtLhpIXyJAsqbSzXzd4iQWbN6o7Or/pHDHI/q+RQyxBusagIcL7zl1gglg762B+vRT 0DXsSLs3w9GIzGsks708QDZuYEksr4C82BMO0M8svAuH5RfxaZdYZnrnJqYKn X-Received: by 2002:a17:907:3e11:: with SMTP id hp17mr345774ejc.243.1636994348895; Mon, 15 Nov 2021 08:39:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIqJZRXmuISsY8go2PIcXD+D8BjfhOponPND40vW08zHcDI9PkJ5N15pUDLm+/sSZqn7aYNg== X-Received: by 2002:a17:907:3e11:: with SMTP id hp17mr345733ejc.243.1636994348662; Mon, 15 Nov 2021 08:39:08 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id cy26sm6749916edb.7.2021.11.15.08.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:39:08 -0800 (PST) Date: Mon, 15 Nov 2021 11:39:04 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 19/20] pcie: fast unplug when slot power is off Message-ID: <20211115163607.177432-20-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Gerd Hoffmann In case the slot is powered off (and the power indicator turned off too) we can unplug right away, without round-trip to the guest. Also clear pending attention button press, there is nothing to care about any more. Signed-off-by: Gerd Hoffmann Message-Id: <20211111130859.1171890-6-kraxel@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pcie.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 959bf074b2..a930ac738a 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -560,6 +560,16 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, return; } + if (((sltctl & PCI_EXP_SLTCTL_PIC) == PCI_EXP_SLTCTL_PWR_IND_OFF) && + ((sltctl & PCI_EXP_SLTCTL_PCC) == PCI_EXP_SLTCTL_PWR_OFF)) { + /* slot is powered off -> unplug without round-trip to the guest */ + pcie_cap_slot_do_unplug(hotplug_pdev); + hotplug_event_notify(hotplug_pdev); + pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA, + PCI_EXP_SLTSTA_ABP); + return; + } + pcie_cap_slot_push_attention_button(hotplug_pdev); } From patchwork Mon Nov 15 16:39:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1555400 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZBTLgcrS; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HtFcl3y0Rz9sR4 for ; Tue, 16 Nov 2021 03:53:11 +1100 (AEDT) Received: from localhost ([::1]:46480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmfED-0004JL-EO for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2021 11:53:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0r-0004QJ-4e for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:39:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24967) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmf0p-0005Ju-DU for qemu-devel@nongnu.org; Mon, 15 Nov 2021 11:39:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636994358; 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=qDeMUO8cCwmSZf/Y30wJkd3TeMNmCM7Xml57tT+2eS8=; b=ZBTLgcrSnTO202aN6G60cwtDAFpXZArQEztEehKEz9MnudE97VzHZilDMlD+jlEWC0/h17 +pxUWwdU450DQrWJOQQ4GaAl66zQ9/JcgDsZFUWUtnfuft/ZXXPauRhU8GM+ulzuOMRmPD dZrDcXFwVAaIk8UYYmH8RIl+HRmwd8o= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-262-JUPsn30rMr2AqPsax2s4vQ-1; Mon, 15 Nov 2021 11:39:17 -0500 X-MC-Unique: JUPsn30rMr2AqPsax2s4vQ-1 Received: by mail-ed1-f69.google.com with SMTP id q17-20020aa7da91000000b003e7c0641b9cso2913975eds.12 for ; Mon, 15 Nov 2021 08:39:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=qDeMUO8cCwmSZf/Y30wJkd3TeMNmCM7Xml57tT+2eS8=; b=ZuqHW9JiBpklbZ06zvljxPVVANirTWqHRBK2cpLBqjw/ioaSaZAumV/kkcpfkpV2/O 6K06RmAvHREhGnX9A/hhbBP2sxBgzMsPFOKMNB1Ksu/mVQgnZ5SqJdFQI3cUqECBhhXv d4dUqRyLPZrd9YRqVz8N3bki3otW75s86y8+ReRm0KT+dWYKfZ8VYuZHCSHw85AV0uId 3wDa2tXdi+Sx0GONazs/fg3t54YpD8U23n+i3XpQ/mEe2sja20uHE2U25+08uOUb0/1k mBRF7Bp19gNrq6WmLzya7JriSdCg9UNxOj/X0Hu9w9787YoVKMaO2FJraOU2oNUIoSPt RScA== X-Gm-Message-State: AOAM531PnYsyse36KRmnZwJq97muQ8G4Nolrub6+bZA8KYacdPKRQoCP JF9pjInn/z1y4RBXQefH6Sr1MFZoUQ+4LZbsy+RQ1xyeoPsVCw1C1ye/Ug8DLjc3yOjqBaXE1uk r8kuBYkF4Q75N5CJqrU7+sCZmtBOIDn8O6b5rKw7z6g12ta2ZUdG2AoMpt8jq X-Received: by 2002:aa7:c9ce:: with SMTP id i14mr50426edt.300.1636994355880; Mon, 15 Nov 2021 08:39:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfGGQfFf7R51ncSaABNSQ6K6tjy1pOJXmHEz3v2ekhkWkSmNlc+qV2mkheIF9Zv8zDK6iFvw== X-Received: by 2002:aa7:c9ce:: with SMTP id i14mr50386edt.300.1636994355721; Mon, 15 Nov 2021 08:39:15 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:9a71:d0b:1947:b534:3230]) by smtp.gmail.com with ESMTPSA id hc16sm6979112ejc.12.2021.11.15.08.39.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:39:15 -0800 (PST) Date: Mon, 15 Nov 2021 11:39:09 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 20/20] pcie: expire pending delete Message-ID: <20211115163607.177432-21-mst@redhat.com> References: <20211115163607.177432-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211115163607.177432-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 client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Daniel =?utf-8?b?UC4gQmVycmFu?= =?utf-8?b?Z8Op?= , Eduardo Habkost , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Gerd Hoffmann Add an expire time for pending delete, once the time is over allow pressing the attention button again. This makes pcie hotplug behave more like acpi hotplug, where one can try sending an 'device_del' monitor command again in case the guest didn't respond to the first attempt. Signed-off-by: Gerd Hoffmann Message-Id: <20211111130859.1171890-7-kraxel@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/qdev-core.h | 1 + hw/pci/pcie.c | 2 ++ softmmu/qdev-monitor.c | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 72622bd337..20d3066595 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -181,6 +181,7 @@ struct DeviceState { char *canonical_path; bool realized; bool pending_deleted_event; + int64_t pending_deleted_expires_ms; QDict *opts; int hotplugged; bool allow_unplug_during_migration; diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index a930ac738a..c5ed266337 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -548,6 +548,8 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, } dev->pending_deleted_event = true; + dev->pending_deleted_expires_ms = + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 5000; /* 5 secs */ /* In case user cancel the operation of multi-function hot-add, * remove the function that is unexposed to guest individually, diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 588a62b88d..5925f1ae5f 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -943,7 +943,9 @@ void qmp_device_del(const char *id, Error **errp) { DeviceState *dev = find_device_state(id, errp); if (dev != NULL) { - if (dev->pending_deleted_event) { + if (dev->pending_deleted_event && + (dev->pending_deleted_expires_ms == 0 || + dev->pending_deleted_expires_ms > qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL))) { error_setg(errp, "Device %s is already in the " "process of unplug", id); return;