From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578414897; cv=none; d=zohomail.com; s=zohoarc; b=h7xEcZSauj+q5vInJFQb+/EviiT51XNjCf3SB8IswYon04WO608EgnY+l8Anz/6/pLgQxa3XjYN1hbdqjNa2vAqdERTx4DFplDa3IBZ8yv4qxW0KkYfljcBEdlv5wC8BUO1L0pZjXJHhFLxDoQYLXlklA14KR1XaZwXxJb2ZVFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578414897; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ky3AoPDK1Dl90THjFQNp/2P2m3Le5A8fcjpKsYSUby0=; b=Ol1Tn1uLTbutC4sk4pLgbLmEEDztJDRaQD/S91iByDF5pwEnS2w8YWM1T33SP5tnnuxK2Jh5Pdse6GGh5yDVaQA3niCdlTRD+LAkTt4UXYhb4Tq3ApYz7MBtlHlGzEj0MC3Wg3ZdBK41qYC4ua1fm01GLXGWvNePC+m5HiyBUhE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157841489741522.567666472014935; Tue, 7 Jan 2020 08:34:57 -0800 (PST) Received: from localhost ([::1]:52740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorol-00036r-N2 for importer@patchew.org; Tue, 07 Jan 2020 11:34:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45810) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorjm-0006KI-77 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:29:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorjl-0004XD-6E for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:29:46 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:41016 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorjl-0004Wq-2Y for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:29:45 -0500 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-8-llQ_2URYOzy6uzCwXl8Yug-1; Tue, 07 Jan 2020 11:29:41 -0500 Received: by mail-qk1-f199.google.com with SMTP id f22so137173qka.10 for ; Tue, 07 Jan 2020 08:29:41 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id k14sm34585qki.66.2020.01.07.08.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:29:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414584; 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=Ky3AoPDK1Dl90THjFQNp/2P2m3Le5A8fcjpKsYSUby0=; b=fJEl2Xe9Ib7uFfmiokp4KHemk60vM2VyacNmXmH54r718HU2kr+viZsqWc5oelrZbSk9gG /Qgc+53Fxm/dnFs5sT72SNlTQLi5KReKAEuEaQeC2KrGHB9VW6F4KBBpjnAbSWNOuakZbd cBFICAXAi5XJyZvzjWLUN6ANZAtjS30= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=S797ekb1koe77yVikHhjJoQQO+mcOVBkg02x1T+LNQw=; b=iDKl0cRUrCzRN4ainmFxCqiHbxboxdOBCwoyRtue2t4NJDyRwX9OLsZAc+LuvkTMTK YjW0HrDj5+6tU0tY7cheAwHP0X+CWj5KRsxwJstPmj0/TK71AkxIpizEmVLE1uzbeJur 4mX5eJXk5LidWW8ISkyM0XBSbwGRnaA23FAryWzlyfxk7M/vLNRA+cT4UdaCllf+9erV l375LWsgqKnECyn/zMgI83vJVQqz7KRFqrvOzZ63uprNLcs2rZcFKM3uOnUJdDJvgdz0 XObQnOc234fsUKNYb4hvbFlRx7NiJ+8pRoTgHLYXry9G2c3uR1+0gyi2Fok/WeajJazp G10A== X-Gm-Message-State: APjAAAUAk1WGs/ym99z+OiFPk5o23pseC51zDEkDaMqy9LiMW/MsazRQ khEF7EcHtSTuUIiMacP2u4dUrFx4l8kwzUHVa8hZQtYuxcEJo6pL4mBAplW2krp5+5rs/nqWqp0 0QBhKoZ7oc2iPeto= X-Received: by 2002:aed:3fb7:: with SMTP id s52mr79810973qth.311.1578414580714; Tue, 07 Jan 2020 08:29:40 -0800 (PST) X-Google-Smtp-Source: APXvYqwBASJc7+GSyeLhPK1jDxVtCqoIoPn5+Nf3z6SRS2r7n+a3n0rxMCEKINFN+2AFYKpI0OFtrg== X-Received: by 2002:aed:3fb7:: with SMTP id s52mr79810955qth.311.1578414580543; Tue, 07 Jan 2020 08:29:40 -0800 (PST) Date: Tue, 7 Jan 2020 11:29:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 01/32] virtio: add ability to delete vq through a pointer Message-ID: <20200107162850.411448-2-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: llQ_2URYOzy6uzCwXl8Yug-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Devices tend to maintain vq pointers, allow deleting them trough a vq point= er. Signed-off-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand Reviewed-by: David Hildenbrand --- include/hw/virtio/virtio.h | 2 ++ hw/virtio/virtio.c | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index c32a815303..e18756d50d 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -183,6 +183,8 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int que= ue_size, =20 void virtio_del_queue(VirtIODevice *vdev, int n); =20 +void virtio_delete_queue(VirtQueue *vq); + void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem, unsigned int len); void virtqueue_flush(VirtQueue *vq, unsigned int count); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 04716b5f6c..31dd140990 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2330,17 +2330,22 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int= queue_size, return &vdev->vq[i]; } =20 +void virtio_delete_queue(VirtQueue *vq) +{ + vq->vring.num =3D 0; + vq->vring.num_default =3D 0; + vq->handle_output =3D NULL; + vq->handle_aio_output =3D NULL; + g_free(vq->used_elems); +} + void virtio_del_queue(VirtIODevice *vdev, int n) { if (n < 0 || n >=3D VIRTIO_QUEUE_MAX) { abort(); } =20 - vdev->vq[n].vring.num =3D 0; - vdev->vq[n].vring.num_default =3D 0; - vdev->vq[n].handle_output =3D NULL; - vdev->vq[n].handle_aio_output =3D NULL; - g_free(vdev->vq[n].used_elems); + virtio_delete_queue(&vdev->vq[n]); } =20 static void virtio_set_isr(VirtIODevice *vdev, int value) --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578414722; cv=none; d=zohomail.com; s=zohoarc; b=b+pK2YF8ajYoAVoMTAXjSnH5pPxTDxeME8c1Xt1KBxnh71mt4FrK2IjsTQNW6EZPAwsjz/INxOh87MSfW3Zo6PVOc5hHUv4s8xO1fr+YJrOIcQnuiMfvFCQo5fii14HXGT4YylS/biftyala8yfP5/MdcGdgu09Dng9MNWM5k4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578414722; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KTcB6zAIaRzY9EwvftE6Rtrz5u5tIha89kZ+phnxUYk=; b=eC7iVjmqqMYk8xrqUFf4zgzK68KH0naxMQt+rVXQuI3C3UzXsGjQ4Pj8/wjbZgF44f0iUF8Hdv0lhnPVhQ1u81cvyR2SEWBwUvP2bpkVkfmi6Eio44bfxL9sgq90k8SwUmVgqpQHwRUnMj/6DBmxAdg1LZQvLNnr4WuRC2C6VVo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578414722611234.16461468889656; Tue, 7 Jan 2020 08:32:02 -0800 (PST) Received: from localhost ([::1]:52680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorlw-00088r-IX for importer@patchew.org; Tue, 07 Jan 2020 11:32:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45842) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorjn-0006Kw-TN for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:29:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorjm-0004YD-OH for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:29:47 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23581 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorjm-0004Xt-KU for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:29:46 -0500 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-144-sCws1RBqOmazZkPmqduoOA-1; Tue, 07 Jan 2020 11:29:45 -0500 Received: by mail-qk1-f198.google.com with SMTP id w64so153844qka.3 for ; Tue, 07 Jan 2020 08:29:45 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id 186sm28282qkm.93.2020.01.07.08.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:29:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414586; 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=KTcB6zAIaRzY9EwvftE6Rtrz5u5tIha89kZ+phnxUYk=; b=aLH6yqmhXA+rsKdVorVxJX6xOiXsinlRcOl0LWnHtOG04QscReJ9cQlduFapBVtDsilhP+ iP5UL3nrO4RjSuA3YlsOoFvaOMK9eerHHSQYB7rSlt8rzh9xUzjHhxg6bN/BHHt048n7Rm yGMniqMzB7SthBJ7ATxlCp7zzV1BWq8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=RMQMUHnYVnq2AcC/aQn0pR+4gejts1KmX+FDMoG77/0=; b=pXfSFhkSEYkQesjqG8otoUiMaTQ02W1YwWrY6V0q6RTLiU9TBGVsF9gDfVKNjaa3za h9Q6IC2+GLL2Y6/wSd9yD/fmz2Z6BdQDs3sGpcySMHEcQlV9pX1TqUOk+P4I4Gu791fg 4XdbgK2uPfKdzpqFvmowqHmr8yR2sISvL5iS22qt4nIYm9BXtZNISiu2v6fxJHWM/Msm g/Lrc7sHO7ueSk+JMVgY6McdSozerfywO60r2KZuHzQi9yPDJuzbjTp0Gk2hicIYopNj q715cXj6+4YPibsNOp/40UPRSrLj8SIxV76vG21HUnu10GliUhOhuoawyX4Gxcvm436m 8SjQ== X-Gm-Message-State: APjAAAXpWyZByVGcRcJcwCHYNMFnVrbE/X4epRvqPL/OMHKMawWgg88c 1wsh2PCFYfAnKXLkRw5oDXtedB/621fZc6laWBJploe11C8V7AydsQymUC9IToxSV2IZ4WIIg9N yb8XehAqyoRpkThc= X-Received: by 2002:ac8:1766:: with SMTP id u35mr80426406qtk.34.1578414584467; Tue, 07 Jan 2020 08:29:44 -0800 (PST) X-Google-Smtp-Source: APXvYqwpu20Q96viw+KTbkp9/oJeiz9H+3pGEgPGQi3UEek0PauOmbeq7aw4Ldb/gkZSoSAsSb+JUQ== X-Received: by 2002:ac8:1766:: with SMTP id u35mr80426396qtk.34.1578414584307; Tue, 07 Jan 2020 08:29:44 -0800 (PST) Date: Tue, 7 Jan 2020 11:29:41 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 02/32] virtio: make virtio_delete_queue idempotent Message-ID: <20200107162850.411448-3-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: sCws1RBqOmazZkPmqduoOA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Pan Nengyuan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Let's make sure calling this twice is harmless - no known instances, but seems safer. Suggested-by: Pan Nengyuan Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 31dd140990..6de3cfdc2c 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2337,6 +2337,7 @@ void virtio_delete_queue(VirtQueue *vq) vq->handle_output =3D NULL; vq->handle_aio_output =3D NULL; g_free(vq->used_elems); + vq->used_elems =3D NULL; } =20 void virtio_del_queue(VirtIODevice *vdev, int n) --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578414946; cv=none; d=zohomail.com; s=zohoarc; b=JssGxXwUsTocQFBW8BSURbk7y/GLU2Kd1a9g+vkCS1/+GLShe+cHlKd9K8TAS5kp3P9LWIkDii+cd+3k7nvRQxiGsFcEoquVjsIbFqf4OJ5o0diAOogggGGYVxBmn/8ii7yZZwkzfM/ohPPHgZnlf/rHm46hqd8LLPAbArzzTvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578414946; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y+1AiFYA4jwJXgwLDoVnwKQ62HQ9au7D6spvhTUBGU8=; b=Kyblx7HG+0s9ZPLhTBXpjW7wnQqbrrNe6bGlbBxt+qgw9rgh7fwb4uPbdy5NSDizHWEfDte+RitCbLtwXglkdtTaHmtk5Yapi9arPgLhqDfbvyl2HPYLs3t4jc9ymTBlLk9JBB2PSXGcFx2mfdS1MJzECw4E//BRMfeqtgS8r2A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578414945975375.4768881609623; Tue, 7 Jan 2020 08:35:45 -0800 (PST) Received: from localhost ([::1]:52746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorpX-0003yL-3v for importer@patchew.org; Tue, 07 Jan 2020 11:35:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45932) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorjv-0006Y3-7k for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:29:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorjt-0004cj-RH for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:29:55 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:55129 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorjt-0004c6-O0 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:29:53 -0500 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-379-jF4ZBLVaPjqj0fc5k-b1cg-1; Tue, 07 Jan 2020 11:29:49 -0500 Received: by mail-qv1-f70.google.com with SMTP id e10so226902qvq.18 for ; Tue, 07 Jan 2020 08:29:49 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id u55sm114881qtc.28.2020.01.07.08.29.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:29:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414592; 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=Y+1AiFYA4jwJXgwLDoVnwKQ62HQ9au7D6spvhTUBGU8=; b=fmMkOHkaSK0wl/Pn15EFL6dCIT/86BPzow2YlVajkQ0CGeEsxAzRK5i1Tn3tRPQbs83PAy O2VoJ8tiF6xxh6hnZmYTIY5ehYBKfvPiZBMUMv1vcQtx0IGz0ZqXmTW3LTCPzZiKoq9gyD FLWn6fysayVNB2KTviI5oJsD2m4vztE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1upHWGgN+kA2iqb9NZ9XxvQ8bHfo9CqfdVL2Jr4HnRY=; b=mHjhYzR55opKLECBbQjqt9gA9SK8PrZZ4ZW2cLexEIQg7XiGZ+adowClXpqihSsCMx L1eEuZAtHjIP4tsx2FTOcD3/KknL+lWuiUTsCvWq0qCMN0ohaBPHFz1KJMpV2FK4OzV0 Qwhu8RFSxJrV0BXUmJx/fvaa9S+oA4IS2lN4Bpwey/jH67K3f/uJXyb3iaq1lpD4MMa6 M8c3ahkn737KYR5hyK6U271muLmO7nqk/P4ftBzAEvHHgjvjlRrRtfSqBPzk2hnzG86c r/SCxWf6GXOwslVl6k/BAWtjqbiKQ3MuA3WMq8AED7CzMSWbDAoI8Ni7srZP+B0TmCsF HFoA== X-Gm-Message-State: APjAAAVelDRpNoDirxNLh1Xn90RIGnxPRFMVmlwKu2SZPfGauXZwbjuP mdUyncOokSjUW50R3gPE+jf95H3Tfds/3nFHJAPpMYsxH/zzbyzinq7XlxKE64MAr4o29gZC7qX KdXNzFCvpdrlHzpU= X-Received: by 2002:a37:a02:: with SMTP id 2mr106849qkk.111.1578414588600; Tue, 07 Jan 2020 08:29:48 -0800 (PST) X-Google-Smtp-Source: APXvYqyqvQTo5HQ1VRAX3+nhHtgXoybUt2XZ5MfPBYpojY7FXmRoLOeiAbshDGQ4NeYsAg5b47pq+w== X-Received: by 2002:a37:a02:: with SMTP id 2mr106832qkk.111.1578414588397; Tue, 07 Jan 2020 08:29:48 -0800 (PST) Date: Tue, 7 Jan 2020 11:29:44 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 03/32] virtio-balloon: fix memory leak while attach virtio-balloon device Message-ID: <20200107162850.411448-4-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: jF4ZBLVaPjqj0fc5k-b1cg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Pan Nengyuan , Euler Robot Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Pan Nengyuan ivq/dvq/svq/free_page_vq is forgot to cleanup in virtio_balloon_device_unrealize, the memory leak stack is as follow: Direct leak of 14336 byte(s) in 2 object(s) allocated from: #0 0x7f99fd9d8560 in calloc (/usr/lib64/libasan.so.3+0xc7560) #1 0x7f99fcb20015 in g_malloc0 (/usr/lib64/libglib-2.0.so.0+0x50015) #2 0x557d90638437 in virtio_add_queue hw/virtio/virtio.c:2327 #3 0x557d9064401d in virtio_balloon_device_realize hw/virtio/virtio-bal= loon.c:793 #4 0x557d906356f7 in virtio_device_realize hw/virtio/virtio.c:3504 #5 0x557d9073f081 in device_set_realized hw/core/qdev.c:876 #6 0x557d908b1f4d in property_set_bool qom/object.c:2080 #7 0x557d908b655e in object_property_set_qobject qom/qom-qobject.c:26 Reported-by: Euler Robot Signed-off-by: Pan Nengyuan Message-Id: <1575444716-17632-2-git-send-email-pannengyuan@huawei.com> Signed-off-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand Reviewed-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand --- hw/virtio/virtio-balloon.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 40b04f5180..57f3b9f22d 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -831,6 +831,13 @@ static void virtio_balloon_device_unrealize(DeviceStat= e *dev, Error **errp) } balloon_stats_destroy_timer(s); qemu_remove_balloon_handler(s); + + virtio_delete_queue(s->ivq); + virtio_delete_queue(s->dvq); + virtio_delete_queue(s->svq); + if (s->free_page_vq) { + virtio_delete_queue(s->free_page_vq); + } virtio_cleanup(vdev); } =20 --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578414741; cv=none; d=zohomail.com; s=zohoarc; b=LE8YuAw0mlXuLEa61mcId7J039Pf0/hdnay+i9qkWYO1K+3RoJbAV3Zz6jyM0E5rnwxRyCKhHn5/++MLgRr47Gy9iQr6gd8dWG/zdBLc1PLHUtqVjRuiLZWzEZidvfEEQ1qeWTD7tde0AqqP4mI9gSKWHT2EB6UAxDmVfIftqCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578414741; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Nm5rBDcoCplmlWRAfpJUTX03Lt2BWA14BTGdBKMUPBs=; b=TAN1oUsNkw8G339Vnr4TL8U3ykfVHwMlZbYp4qdIvf2TPvLTzyOMX5VuIkmiJsQ8hNQ3QINsEApK/+r6OtiPvab6uXn2Xkyz9vMliT7VkjK2Bt7qNvqX7obPBPq9cmV/OKmyUDa0wazs7LFRJPKFHFbUXj4Ar1f6kLNCSXgGkmo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578414741833760.5107767929511; Tue, 7 Jan 2020 08:32:21 -0800 (PST) Received: from localhost ([::1]:52694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iormG-000064-7E for importer@patchew.org; Tue, 07 Jan 2020 11:32:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45971) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorjx-0006bT-8z for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:29:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorjv-0004eT-UZ for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:29:57 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:60183 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorjv-0004e4-Qd for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:29:55 -0500 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-221-M8BApqhDPRiqYhOBDwRenA-1; Tue, 07 Jan 2020 11:29:54 -0500 Received: by mail-qt1-f200.google.com with SMTP id c8so102969qte.22 for ; Tue, 07 Jan 2020 08:29:53 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id l49sm115569qtk.7.2020.01.07.08.29.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:29:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414595; 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=Nm5rBDcoCplmlWRAfpJUTX03Lt2BWA14BTGdBKMUPBs=; b=TVse+DvPP1lxY5mdfUaNN4AgHXU0go0jqTtfCbAYbpije+Dh2Y3d0nkMbxUZ4JhTYwHb8y VAuk4mKnsp2aZpDtXLn1Y20JUXRRNFL8NPHOlVz5GpCQmyfxlGOHYS9aRTtyLE7nkr/fYt 6CfSyNWIGYVmDozukmQs7p8Nu+EL++o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=SV/3gkt55AkXiObd4ttRVZfM0Ouiap0tkA8DR2mthfg=; b=PY1NKvDnK5azM9eq7OL2VyYH3a1D8Ix5Gm/TAsed8Lj/MOvL0vXEhhUq5JqlqvLQW5 X0ebiemkHJP0q0Jy+vVIt9i1uNsq1CHEaxYTJ8+au1TJ8za6R0tj//az7y997x44dkt1 gN9LS7zOYyC91Omq3m8oTnBC0l233Luh0eD5pK5d2wJn6UDlpWksQn7kMzCCqUZXbg+t DefhzRrvJ7GCVAqEoM4rrmfuBonoK5gocOfriKs2CNk3FNhRGFVDaxMYd4FyKYY+T+uX Ab7tN/LYrp+ZYciSbbeDNJa4O7/XIyHa98IB65wF+4YzTKaU/GAoE4Kb7lAdEcevKn1H l7NA== X-Gm-Message-State: APjAAAXJB/ndmCyecEzYBx9tyPkbzLgq2EoIPCo7/r+4PDYYIq0fLafl adXWlXnaF9J3Iv3hL+73MEZb5R4Kl8k7gebtcPIg78TT9+0zkrTPUMEwCnw2zn2S8ueJmhtEfgs Cl1+jntr6SeTzdCQ= X-Received: by 2002:ae9:e204:: with SMTP id c4mr104969qkc.191.1578414593235; Tue, 07 Jan 2020 08:29:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzzGafIqGXWMFtMi5y/B7HlJaWT7iqZxsL3O5cyqPsyf3xHCxf/upu110K+8VtcO50lbASzzQ== X-Received: by 2002:ae9:e204:: with SMTP id c4mr104950qkc.191.1578414593003; Tue, 07 Jan 2020 08:29:53 -0800 (PST) Date: Tue, 7 Jan 2020 11:29:48 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 04/32] virtio-serial-bus: fix memory leak while attach virtio-serial-bus Message-ID: <20200107162850.411448-5-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: M8BApqhDPRiqYhOBDwRenA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Amit Shah , Pan Nengyuan , Paolo Bonzini , Euler Robot , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Pan Nengyuan ivqs/ovqs/c_ivq/c_ovq is forgot to cleanup in virtio_serial_device_unrealize, the memory leak stack is as bellow: Direct leak of 1290240 byte(s) in 180 object(s) allocated from: #0 0x7fc9bfc27560 in calloc (/usr/lib64/libasan.so.3+0xc7560) #1 0x7fc9bed6f015 in g_malloc0 (/usr/lib64/libglib-2.0.so.0+0x50015) #2 0x5650e02b83e7 in virtio_add_queue hw/virtio/virtio.c:2327 #3 0x5650e02847b5 in virtio_serial_device_realize hw/char/virtio-serial= -bus.c:1089 #4 0x5650e02b56a7 in virtio_device_realize hw/virtio/virtio.c:3504 #5 0x5650e03bf031 in device_set_realized hw/core/qdev.c:876 #6 0x5650e0531efd in property_set_bool qom/object.c:2080 #7 0x5650e053650e in object_property_set_qobject qom/qom-qobject.c:26 #8 0x5650e0533e14 in object_property_set_bool qom/object.c:1338 #9 0x5650e04c0e37 in virtio_pci_realize hw/virtio/virtio-pci.c:1801 Reported-by: Euler Robot Signed-off-by: Pan Nengyuan Cc: Laurent Vivier Cc: Amit Shah Cc: "Marc-Andr=C3=A9 Lureau" Cc: Paolo Bonzini Message-Id: <1575444716-17632-3-git-send-email-pannengyuan@huawei.com> Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- hw/char/virtio-serial-bus.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 33259042a9..e1cbce3ba3 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -1126,9 +1126,17 @@ static void virtio_serial_device_unrealize(DeviceSta= te *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOSerial *vser =3D VIRTIO_SERIAL(dev); + int i; =20 QLIST_REMOVE(vser, next); =20 + virtio_delete_queue(vser->c_ivq); + virtio_delete_queue(vser->c_ovq); + for (i =3D 0; i < vser->bus.max_nr_ports; i++) { + virtio_delete_queue(vser->ivqs[i]); + virtio_delete_queue(vser->ovqs[i]); + } + g_free(vser->ivqs); g_free(vser->ovqs); g_free(vser->ports_map); --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578414744; cv=none; d=zohomail.com; s=zohoarc; b=m9tJbt39xWihIGoqMgBfv3HaHUAXVLvSSFN7D/t8+7RX+cvHSpUUsSmRhXA8K2SoRUJoXF6JYPZ2nH8bDIInUHc5G96xpLNi5eZc0awGU2hiMFHzQt7sMTqSTUhwcdJQzccL/3S0sWlAGmVFbEdBCWmfROFuQ3auSN8DlmmQj64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578414744; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=K9epneyHKkAEq5gGDVE/gbeFue8BzwP7OkBM6QzY9Yk=; b=FFVFB3o8TnaUHJTObm8nluTUbbSvKAGK+KXFtMDa4ADwLRqwiQKWC6EQwX8TY3Sj9cbVfmuTQ1kFegZgJv2mNBr1FQ2Ar9wAa4Tj6EisGcXc+J8fQQTO9qEcNNa+NrU9jExHxSTBfpbkgKG+HAQMarxYUGXd8XmLw1X9tX9FrvA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578414744091510.9171808981714; Tue, 7 Jan 2020 08:32:24 -0800 (PST) Received: from localhost ([::1]:52700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iormI-0000AY-Jj for importer@patchew.org; Tue, 07 Jan 2020 11:32:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46008) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iork1-0006f6-CU for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iork0-0004hP-1l for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:01 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:25397 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorjz-0004gc-Mr for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:29:59 -0500 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-209-kTdlcqhcOpq2PbMxC8IyZQ-1; Tue, 07 Jan 2020 11:29:57 -0500 Received: by mail-qk1-f198.google.com with SMTP id m13so140796qka.9 for ; Tue, 07 Jan 2020 08:29:57 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id h1sm108315qte.42.2020.01.07.08.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:29:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414598; 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=K9epneyHKkAEq5gGDVE/gbeFue8BzwP7OkBM6QzY9Yk=; b=Hopuq36kIYXfxrhB5y2zH6PKJzOIe4MxDSqytjAwwDyjMmizHs3G87k/pqEhvNGSMXmlwo gpoSXGktrF8e1vIqTaBhWhouqvkl4nfG6M7iuCdg2q9e6jwRat4alJtGdmDJKVIymzT5gO 6iBo+9Tk4aUpfSU8mMdMcp+RYuTD3vI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=iiaP0RxMw50Y4u2HruPOoUKc+xP0ZRMmYrMUAAr8Wgg=; b=Xlw4ICsSQ8nlets+uF0/oO7RjkbR8QkR8uDd0nKpDY96sv/smhIunL7cvsEtkeMRI0 7f+EYClmlQiA2dfoGIxxFwknW4TWu8QceJCtkO2eTxFpg7QEmCaCdpEg7L1AFKfPLT3W its84S1Li+hJIbVkl/vxn8ZanrmBAoltFA8YDcQOaVmk4aMTnLpP0UdvjnVtyO6u41b/ xRZugquyQZXiPL6j3FBTGAr9y0d+naffkE2IWcdGQl3AQKEYd4Vm66hwpPI+bXQ/OgbP 8elkgeIsF6mtQjgwJMEdLFUjMUx/FCU3knmom7Ca/pf+zvbwR2n/aGMufJ4wmaK7tvWz i5Tg== X-Gm-Message-State: APjAAAV7uvMNemMlq9iSnkgMMWwmykw4Wb1eXIo5PF50I782ml5aQt76 EK9aB5X3trznS9b4wKkdf8JKuAb2J1lf+bPbddXpIIft16RKna6v9OKTQ7bdjvwLzW7AUK8ePtO yI7pQlTuI89aO/gE= X-Received: by 2002:ae9:e714:: with SMTP id m20mr82668qka.403.1578414597070; Tue, 07 Jan 2020 08:29:57 -0800 (PST) X-Google-Smtp-Source: APXvYqzDWDMiFTydcHlMfSpLOjjQ6uZn4k7sj1O9kBGGqK54fuatvIVtNP/tWSsrtOZBqxgRbfscoA== X-Received: by 2002:ae9:e714:: with SMTP id m20mr82656qka.403.1578414596867; Tue, 07 Jan 2020 08:29:56 -0800 (PST) Date: Tue, 7 Jan 2020 11:29:53 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 05/32] virtio-input: convert to new virtio_delete_queue Message-ID: <20200107162850.411448-6-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: kTdlcqhcOpq2PbMxC8IyZQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Seems cleaner than using VQ index values. Signed-off-by: Michael S. Tsirkin --- hw/input/virtio-input.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c index ec54e46ad6..9c013afddb 100644 --- a/hw/input/virtio-input.c +++ b/hw/input/virtio-input.c @@ -280,6 +280,7 @@ static void virtio_input_device_unrealize(DeviceState *= dev, Error **errp) { VirtIOInputClass *vic =3D VIRTIO_INPUT_GET_CLASS(dev); VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VirtIOInput *vinput =3D VIRTIO_INPUT(dev); Error *local_err =3D NULL; =20 if (vic->unrealize) { @@ -289,8 +290,8 @@ static void virtio_input_device_unrealize(DeviceState *= dev, Error **errp) return; } } - virtio_del_queue(vdev, 0); - virtio_del_queue(vdev, 1); + virtio_delete_queue(vinput->evt); + virtio_delete_queue(vinput->sts); virtio_cleanup(vdev); } =20 --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578414969; cv=none; d=zohomail.com; s=zohoarc; b=fS1LLAAentSbC52/0HxO3nHK2Mfp0LDFc9wY+NYTzehVw2W1ORuZDCua2fEGISzqnWtl75qrU4Ts4EGfHmXYMFgx14FLyzqzMkEWpTLdSMteAtGliKZoLTrG4sAP7FMMLjVMXavwWFxPTAdFDqQIUUWnLrWBRNT703YrODGOodU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578414969; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8li2Tk9kJtAQIFMop0/eFLC5J5NJiOvfkc+z767fYRk=; b=CveuPrAtO5rV4Qa5G4NTrVZEj4Y0//1FJVRJrvN6wAXpjwfjpzFqfbMTV24opxFyh0wyt2XLpEFwzWPft+C33U4yeQYq1luZp6BAZFYVSClpPLZI20ypluyLMq4YgU5Xvkt3chnszejRL9oVx5Bfdc/DdfQQZeuaC0dGC1eE79s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15784149691761010.3986828452275; Tue, 7 Jan 2020 08:36:09 -0800 (PST) Received: from localhost ([::1]:52750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorpv-0004QW-T3 for importer@patchew.org; Tue, 07 Jan 2020 11:36:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46099) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iork7-0006ll-33 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iork5-0004oO-P1 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:06 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:44329 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iork5-0004n8-La for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:05 -0500 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-117-jNf8x8eXPM6aGBn2PTOMVA-1; Tue, 07 Jan 2020 11:30:03 -0500 Received: by mail-qt1-f197.google.com with SMTP id 38so119402qty.15 for ; Tue, 07 Jan 2020 08:30:03 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id 24sm42544qka.32.2020.01.07.08.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:30:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414605; 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=8li2Tk9kJtAQIFMop0/eFLC5J5NJiOvfkc+z767fYRk=; b=IqqDcswQ5LJekmJzKD7SmznLQGFMNd7mdc5hAiQ+EEb+15+foFuJp5Zt9YQIKcDfrYyK9A zBR3YcfSaaQF7tksvM4o8e16Zm+Dm0UO6Z2EkAYHPvO1RqvV48q8Y46lqP8rxibLc8hd1y wnTTfaNGFGZbr0ELb1LyFMUTl0EQFpk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8e5zVSr3EGK6wfLcmhM6md/VpcFIAiAuGM2x/CJ8sg4=; b=Us5eidCCa4iATM9YZk0TWXpk9rj0QiyagTT+b8l2dSOG4Ss0BcBU3IMZ78purgorUR lL0MSGlKJanl4Nr82pUrIu56IaNORIIY0uZJJMYM+qNtFaMhwYvSOnwYZAGcZE/8Gc1q biSroE5inl9xdw5FQDjLgWJoeEZXMFKlVPRcZ6zxJeiTTTZ8aO9y1840hzE3BYfbhIPM dRSCkyulxt1ovwdcBW0tSLl+iXjEPmzr/Fof9Ws/r4lHL47gieEDWAHLLj7up11wrl6T tIQOVEMfbvI0QLNuC3BDR3b+4N2aAKoHJw7wazdK0qmgzrFGfEr3gi/AG4yIelB4OAi4 ewvQ== X-Gm-Message-State: APjAAAVbVW3Wjsx1nFMZCJVAEcyFkAwbTqHCA7y1qGe2vBwngsb/XZih W1nr0ihMuWMT/Gh9vSylZsK7LHu+tOgD20fdKMckY3U0avwJyCca3O/MA66EFzaBxhaZY3tP3bT zvfrsqx6YyRIPeNk= X-Received: by 2002:ac8:5205:: with SMTP id r5mr80592118qtn.230.1578414601888; Tue, 07 Jan 2020 08:30:01 -0800 (PST) X-Google-Smtp-Source: APXvYqy7denVb6FnL6CyNmr9HRL88W34YZ1uYt5Vk1Ih+YlmixmJuBsw9l4fVUIU3dt2p0mRkh0kJA== X-Received: by 2002:ac8:5205:: with SMTP id r5mr80592084qtn.230.1578414601445; Tue, 07 Jan 2020 08:30:01 -0800 (PST) Date: Tue, 7 Jan 2020 11:29:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 06/32] intel_iommu: fix bug to read DMAR_RTADDR_REG Message-ID: <20200107162850.411448-7-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: jNf8x8eXPM6aGBn2PTOMVA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Yi Sun , Eduardo Habkost , Peter Xu , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Yi Sun Should directly read DMAR_RTADDR_REG but not using 's->root'. Because 's->root' is modified in 'vtd_root_table_setup()' so that the first 12 bits are omitted. This causes the guest iommu debugfs cannot show pasid tables. Signed-off-by: Yi Sun Message-Id: <20191205095439.29114-1-yi.y.sun@linux.intel.com> Signed-off-by: Michael S. Tsirkin Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 43c94b993b..ee06993675 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2610,16 +2610,15 @@ static uint64_t vtd_mem_read(void *opaque, hwaddr a= ddr, unsigned size) switch (addr) { /* Root Table Address Register, 64-bit */ case DMAR_RTADDR_REG: + val =3D vtd_get_quad_raw(s, DMAR_RTADDR_REG); if (size =3D=3D 4) { - val =3D s->root & ((1ULL << 32) - 1); - } else { - val =3D s->root; + val =3D val & ((1ULL << 32) - 1); } break; =20 case DMAR_RTADDR_REG_HI: assert(size =3D=3D 4); - val =3D s->root >> 32; + val =3D vtd_get_quad_raw(s, DMAR_RTADDR_REG) >> 32; break; =20 /* Invalidation Queue Address Register, 64-bit */ --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415149; cv=none; d=zohomail.com; s=zohoarc; b=ixXmvzuvhRhzrSXxXbOt3SqYHYaQO0dGYH4gFmaCiCcewde+jgGtYm2ILAxMHw/5Yc0R+ljU5pp7q9ghYJGIq8nq22SgjJbFMsgNSkN5H4hcAvzTqjX98CTxzuk6Y72k9PFEXs/9R+YYU8ixUefmi2z0MsALWiv2QgepzgHe/GQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415149; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OMvJhEP2LlmkkK5OqUcX3Hea5Sokrq83L2n0JELoweI=; b=UVvXztXeHD+QP7BZd90l7v+RZKcU0e0twtgG+V/WA95CHrop8IitCbhcNnV5dSz+keYjoyBklwFBhADqL3JJQSODPozaWc8nnqdpRbOZfR0+0Wr7lrG+kFwqLXYYyiq+QR6cH8mEnhfatPXb4EZbHJus0osAf+4OJ8XHaO1Nodc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578415149852653.4403481725461; Tue, 7 Jan 2020 08:39:09 -0800 (PST) Received: from localhost ([::1]:52806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorsq-00008F-3D for importer@patchew.org; Tue, 07 Jan 2020 11:39:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46164) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorkC-0006si-0m for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iork8-0004qt-Ft for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:11 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:22782 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iork8-0004qf-CH for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:08 -0500 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-vfW3MQemN3uN2eDAm30wwQ-1; Tue, 07 Jan 2020 11:30:06 -0500 Received: by mail-qv1-f69.google.com with SMTP id e14so249326qvr.6 for ; Tue, 07 Jan 2020 08:30:06 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id m27sm114800qta.21.2020.01.07.08.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:30:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414607; 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=OMvJhEP2LlmkkK5OqUcX3Hea5Sokrq83L2n0JELoweI=; b=HwXjVYKtTxLKB5jypIKQvNLq1YNAKCl3PQyIxWyGx3QkC9+NATHKfdcA7zBXM252BBhyZA Ijpt10Rj4oKRvPw/xCFxHzixbG4o5QF0ettpobmUsamNv34LwEpW+DVrVVpqEyUeRXIxOg 5Ta3EiPu8wHoPd36WmHLBM2adar2K7g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MZOXCGQ//jaCo4R+sHDCJUpSHTnIinHqd1QfSjM9oh0=; b=f7Kcec5mhR8raQHwY0h5bSqhzaq0rCj+Mb5iC0EqGQkOG75ZRZKtc0+Y5HX6wKbOjr /UNvnMx+tbqGml8PBo8a+eW0KdN4PxtEXGlCdIU48poUPxhDMeE9Xtiid1E6jU9gZjYF meuS2zBjUs7YXfA278bZnyrWUQD9aDDp/jURiiJHXsYGTCaXlyKfRwznXZTaJsBFd5Ez upt+VdL1ONm5SAyzfttah3XQLnrpLcdsIZFlC/kEO34sjS8tHrSsDfxXUNM29LrONrni 9VISSc5pb/y5Cg+q0FeWRB6yrAfB/c6lmWg0JPWYRA3agNVy2AjbhdpGWaWqxfLEehIV JiwQ== X-Gm-Message-State: APjAAAVd35dLuYmellueABBxd7XlDltvzEJ0hdqRCL84ULyKKdlvXE5Y BCDbYnrTWXjnA+4kYS/sFn75M94wtC+q8h+YDb0qwr5ZiM0ZjKPAjF1ly2gpQODmKU4+/oGiZoT zjwVeRqnjy6DcP+k= X-Received: by 2002:a05:620a:133a:: with SMTP id p26mr100179qkj.233.1578414605924; Tue, 07 Jan 2020 08:30:05 -0800 (PST) X-Google-Smtp-Source: APXvYqxGsVoKBcSWCFdgfIIfI28zOC1QlKjZXWrsT0GxD3tkpfdtTmTPTGVDXV9d+iLi46gFCwFs6w== X-Received: by 2002:a05:620a:133a:: with SMTP id p26mr100152qkj.233.1578414605662; Tue, 07 Jan 2020 08:30:05 -0800 (PST) Date: Tue, 7 Jan 2020 11:30:02 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 07/32] virtio: update queue size on guest write Message-ID: <20200107162850.411448-8-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: vfW3MQemN3uN2eDAm30wwQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Denis Plotnikov , Roman Kagan , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Some guests read back queue size after writing it. Update the size immediatly upon write otherwise they get confused. In particular this is the case for seabios. Reported-by: Roman Kagan Suggested-by: Denis Plotnikov Cc: qemu-stable@nongnu.org Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index c6b47a9c73..e5c759e19e 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1256,6 +1256,8 @@ static void virtio_pci_common_write(void *opaque, hwa= ddr addr, break; case VIRTIO_PCI_COMMON_Q_SIZE: proxy->vqs[vdev->queue_sel].num =3D val; + virtio_queue_set_num(vdev, vdev->queue_sel, + proxy->vqs[vdev->queue_sel].num); break; case VIRTIO_PCI_COMMON_Q_MSIX: msix_vector_unuse(&proxy->pci_dev, --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415352; cv=none; d=zohomail.com; s=zohoarc; b=QFC78LbBxqOP/j3mRMbRKWDyV60ABxeC4Ms/O7izincfJwsfWSWPq4AfPpN0uOreVw23RnyQxyXt+WpgMbJINDPDllaONF2fVvd+0rpHuXrfq/pCzptiDiIzLy+CEnkFA97s/5jUIl+n538QLthwGViTBJfAsuZ1fy7/k2pN6p8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415352; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q6Os4L+WBppxRr1+PQZIGTRXnHgagS3ljQ3yg+JHbYs=; b=LcZD+3YocOD1jTvLbY3rarOfQ8FMI9UN0ZU7Bas/0ijRaU3qOl/MiyZ6FsbfImBZBfKI2Tcn/RFWhmPStXjDCGLWuk0bzK0BBUFLt3cYjuncqjMDpiNZ0u2+QLjyQkoOmVjAZ4JFb8sl9smOBK6FDPLjERYbV3Np1UP5O7ZiosY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157841535246493.6461299151398; Tue, 7 Jan 2020 08:42:32 -0800 (PST) Received: from localhost ([::1]:52850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorw6-0005Gu-Hm for importer@patchew.org; Tue, 07 Jan 2020 11:42:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46241) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorkF-0006xu-Vf for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorkD-0004x8-FX for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:15 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:30132 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorkD-0004wO-9z for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:13 -0500 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-267-zk-lcks1PSa0GtmR_hKngg-1; Tue, 07 Jan 2020 11:30:11 -0500 Received: by mail-qk1-f198.google.com with SMTP id 11so137976qkk.11 for ; Tue, 07 Jan 2020 08:30:11 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id d71sm46427qkg.4.2020.01.07.08.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:30:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414612; 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=q6Os4L+WBppxRr1+PQZIGTRXnHgagS3ljQ3yg+JHbYs=; b=XWmz3F8aBQOBn10/1XjMguETnXN8eVWvo8M+Bt3z+xUBCCuRfS9OkHhZOGzXWU24uJ0GM9 0ZqUSgqns47qu0+0g53keg2OlagZaXIwxKX/4w+KfynO+lh66c2b010dvTNj3AFMhqPkeV LEF93OJ21DDOCNQZIiLhvAk/x2NBGHs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Sh9NZFodPuDYsX7mh7EXFUKW/sqh5xR67aWfobfmobY=; b=c8G1GS2h8+Je5eOskcIdJQbxz3nScyEHNymK//FrRn+LBlMvJZjdor4lzidOLV93Ec gefDizcRou7HdRw2fSE6UBusAu0DgNxntbnDKu3lpvut6Ho5Ss1+AUmOXT2B8Q3r8ub5 fe3exQWr6bTh8cl64ZKKHtotYPO/9x/frMMNTAejFZZCyndkJsjVJRyGy4ug+xXiAfMh XnI5sOOJW7TOZGtJ8jKAERW88E95Z5x5RqEJy7LZKnIrjS+hw2o9ECC1yvAJJOxrnNwj mfwu5xUEb8zuY7nTgB7K9xG+o+flsbTSpak88nSXYst1tgjm3CYl68OYWAHEHHao0Gfr lV2w== X-Gm-Message-State: APjAAAXtRdwfUcOij6vHZVsy2+b4yyH2RBv2X4knpqGS9BgpKU5yg/Ye sFWHhW36mkQ5XfykDS2WyVwmqVK2XJtBVm5Djn9D8rM7soWj0YkICXwVdwxS+U7JRTCUu0m96g9 KgfEH/cEyCnD4Yhk= X-Received: by 2002:ae9:e40d:: with SMTP id q13mr167973qkc.2.1578414610707; Tue, 07 Jan 2020 08:30:10 -0800 (PST) X-Google-Smtp-Source: APXvYqyZjBdMSeHkVKTsXSxYWVeOo85DR2i7+vCWf1rESo7aVZdusX9IRR6vdSaMHHwDeMvxtzzEhA== X-Received: by 2002:ae9:e40d:: with SMTP id q13mr167936qkc.2.1578414610238; Tue, 07 Jan 2020 08:30:10 -0800 (PST) Date: Tue, 7 Jan 2020 11:30:06 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 08/32] virtio-pci: disable vring processing when bus-mastering is disabled Message-ID: <20200107162850.411448-9-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: zk-lcks1PSa0GtmR_hKngg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Alexey Kardashevskiy , Michael Roth , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Michael Roth Currently the SLOF firmware for pseries guests will disable/re-enable a PCI device multiple times via IO/MEM/MASTER bits of PCI_COMMAND register after the initial probe/feature negotiation, as it tends to work with a single device at a time at various stages like probing and running block/network bootloaders without doing a full reset in-between. In QEMU, when PCI_COMMAND_MASTER is disabled we disable the corresponding IOMMU memory region, so DMA accesses (including to vring fields like idx/flags) will no longer undergo the necessary translation. Normally we wouldn't expect this to happen since it would be misbehavior on the driver side to continue driving DMA requests. However, in the case of pseries, with iommu_platform=3Don, we trigger the following sequence when tearing down the virtio-blk dataplane ioeventfd in response to the guest unsetting PCI_COMMAND_MASTER: #2 0x0000555555922651 in virtqueue_map_desc (vdev=3Dvdev@entry=3D0x55555= 6dbcfb0, p_num_sg=3Dp_num_sg@entry=3D0x7fffe657e1a8, addr=3Daddr@entry=3D0x= 7fffe657e240, iov=3Diov@entry=3D0x7fffe6580240, max_num_sg=3Dmax_num_sg@ent= ry=3D1024, is_write=3Dis_write@entry=3Dfalse, pa=3D0, sz=3D0) at /home/mdroth/w/qemu.git/hw/virtio/virtio.c:757 #3 0x0000555555922a89 in virtqueue_pop (vq=3Dvq@entry=3D0x555556dc8660, = sz=3Dsz@entry=3D184) at /home/mdroth/w/qemu.git/hw/virtio/virtio.c:950 #4 0x00005555558d3eca in virtio_blk_get_request (vq=3D0x555556dc8660, s= =3D0x555556dbcfb0) at /home/mdroth/w/qemu.git/hw/block/virtio-blk.c:255 #5 0x00005555558d3eca in virtio_blk_handle_vq (s=3D0x555556dbcfb0, vq=3D= 0x555556dc8660) at /home/mdroth/w/qemu.git/hw/block/virtio-blk.c:776 #6 0x000055555591dd66 in virtio_queue_notify_aio_vq (vq=3Dvq@entry=3D0x5= 55556dc8660) at /home/mdroth/w/qemu.git/hw/virtio/virtio.c:1550 #7 0x000055555591ecef in virtio_queue_notify_aio_vq (vq=3D0x555556dc8660) at /home/mdroth/w/qemu.git/hw/virtio/virtio.c:1546 #8 0x000055555591ecef in virtio_queue_host_notifier_aio_poll (opaque=3D0= x555556dc86c8) at /home/mdroth/w/qemu.git/hw/virtio/virtio.c:2527 #9 0x0000555555d02164 in run_poll_handlers_once (ctx=3Dctx@entry=3D0x555= 55688bfc0, timeout=3Dtimeout@entry=3D0x7fffe65844a8) at /home/mdroth/w/qemu.git/util/aio-posix.c:520 #10 0x0000555555d02d1b in try_poll_mode (timeout=3D0x7fffe65844a8, ctx=3D= 0x55555688bfc0) at /home/mdroth/w/qemu.git/util/aio-posix.c:607 #11 0x0000555555d02d1b in aio_poll (ctx=3Dctx@entry=3D0x55555688bfc0, blo= cking=3Dblocking@entry=3Dtrue) at /home/mdroth/w/qemu.git/util/aio-posix.c:639 #12 0x0000555555d0004d in aio_wait_bh_oneshot (ctx=3D0x55555688bfc0, cb= =3Dcb@entry=3D0x5555558d5130 , opaque=3Dopaq= ue@entry=3D0x555556de86f0) at /home/mdroth/w/qemu.git/util/aio-wait.c:71 #13 0x00005555558d59bf in virtio_blk_data_plane_stop (vdev=3D) at /home/mdroth/w/qemu.git/hw/block/dataplane/virtio-blk.c:288 #14 0x0000555555b906a1 in virtio_bus_stop_ioeventfd (bus=3Dbus@entry=3D0x= 555556dbcf38) at /home/mdroth/w/qemu.git/hw/virtio/virtio-bus.c:245 #15 0x0000555555b90dbb in virtio_bus_stop_ioeventfd (bus=3Dbus@entry=3D0x= 555556dbcf38) at /home/mdroth/w/qemu.git/hw/virtio/virtio-bus.c:237 #16 0x0000555555b92a8e in virtio_pci_stop_ioeventfd (proxy=3D0x555556db4e= 40) at /home/mdroth/w/qemu.git/hw/virtio/virtio-pci.c:292 #17 0x0000555555b92a8e in virtio_write_config (pci_dev=3D0x555556db4e40, = address=3D, val=3D1048832, len=3D) at /home/mdroth/w/qemu.git/hw/virtio/virtio-pci.c:613 I.e. the calling code is only scheduling a one-shot BH for virtio_blk_data_plane_stop_bh, but somehow we end up trying to process an additional virtqueue entry before we get there. This is likely due to the following check in virtio_queue_host_notifier_aio_poll: static bool virtio_queue_host_notifier_aio_poll(void *opaque) { EventNotifier *n =3D opaque; VirtQueue *vq =3D container_of(n, VirtQueue, host_notifier); bool progress; if (!vq->vring.desc || virtio_queue_empty(vq)) { return false; } progress =3D virtio_queue_notify_aio_vq(vq); namely the call to virtio_queue_empty(). In this case, since no new requests have actually been issued, shadow_avail_idx =3D=3D last_avail_idx, so we actually try to access the vring via vring_avail_idx() to get the latest non-shadowed idx: int virtio_queue_empty(VirtQueue *vq) { bool empty; ... if (vq->shadow_avail_idx !=3D vq->last_avail_idx) { return 0; } rcu_read_lock(); empty =3D vring_avail_idx(vq) =3D=3D vq->last_avail_idx; rcu_read_unlock(); return empty; but since the IOMMU region has been disabled we get a bogus value (0 usually), which causes virtio_queue_empty() to falsely report that there are entries to be processed, which causes errors such as: "virtio: zero sized buffers are not allowed" or "virtio-blk missing headers" and puts the device in an error state. This patch works around the issue by introducing virtio_set_disabled(), which sets a 'disabled' flag to bypass checks like virtio_queue_empty() when bus-mastering is disabled. Since we'd check this flag at all the same sites as vdev->broken, we replace those checks with an inline function which checks for either vdev->broken or vdev->disabled. The 'disabled' flag is only migrated when set, which should be fairly rare, but to maintain migration compatibility we disable it's use for older machine types. Users requiring the use of the flag in conjunction with older machine types can set it explicitly as a virtio-device option. NOTES: - This leaves some other oddities in play, like the fact that DRIVER_OK also gets unset in response to bus-mastering being disabled, but not restored (however the device seems to continue working) - Similarly, we disable the host notifier via virtio_bus_stop_ioeventfd(), which seems to move the handling out of virtio-blk dataplane and back into the main IO thread, and it ends up staying there till a reset (but otherwise continues working normally) Cc: David Gibson , Cc: Alexey Kardashevskiy Cc: "Michael S. Tsirkin" Signed-off-by: Michael Roth Message-Id: <20191120005003.27035-1-mdroth@linux.vnet.ibm.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 15 +++++++++++++++ hw/core/machine.c | 1 + hw/virtio/virtio-pci.c | 12 ++++++++---- hw/virtio/virtio.c | 35 ++++++++++++++++++++++++++++------- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index e18756d50d..777772475c 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -100,6 +100,8 @@ struct VirtIODevice uint16_t device_id; bool vm_running; bool broken; /* device in invalid state, needs reset */ + bool use_disabled_flag; /* allow use of 'disable' flag when needed */ + bool disabled; /* device in temporarily disabled state */ bool use_started; bool started; bool start_on_kick; /* when virtio 1.0 feature has not been negotiated= */ @@ -380,4 +382,17 @@ static inline void virtio_set_started(VirtIODevice *vd= ev, bool started) vdev->started =3D started; } } + +static inline void virtio_set_disabled(VirtIODevice *vdev, bool disable) +{ + if (vdev->use_disabled_flag) { + vdev->disabled =3D disable; + } +} + +static inline bool virtio_device_disabled(VirtIODevice *vdev) +{ + return unlikely(vdev->disabled || vdev->broken); +} + #endif diff --git a/hw/core/machine.c b/hw/core/machine.c index 56137e9bf0..0854dcebdd 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -34,6 +34,7 @@ const size_t hw_compat_4_2_len =3D G_N_ELEMENTS(hw_compat= _4_2); =20 GlobalProperty hw_compat_4_1[] =3D { { "virtio-pci", "x-pcie-flr-init", "off" }, + { "virtio-device", "use-disabled-flag", "false" }, }; const size_t hw_compat_4_1_len =3D G_N_ELEMENTS(hw_compat_4_1); =20 diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index e5c759e19e..f723b9f631 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -608,10 +608,14 @@ static void virtio_write_config(PCIDevice *pci_dev, u= int32_t address, pcie_cap_flr_write_config(pci_dev, address, val, len); } =20 - if (range_covers_byte(address, len, PCI_COMMAND) && - !(pci_dev->config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { - virtio_pci_stop_ioeventfd(proxy); - virtio_set_status(vdev, vdev->status & ~VIRTIO_CONFIG_S_DRIVER_OK); + if (range_covers_byte(address, len, PCI_COMMAND)) { + if (!(pci_dev->config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { + virtio_set_disabled(vdev, true); + virtio_pci_stop_ioeventfd(proxy); + virtio_set_status(vdev, vdev->status & ~VIRTIO_CONFIG_S_DRIVER= _OK); + } else { + virtio_set_disabled(vdev, false); + } } =20 if (proxy->config_cap && diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 6de3cfdc2c..7bc6a9455e 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -546,7 +546,7 @@ static inline bool is_desc_avail(uint16_t flags, bool w= rap_counter) * Called within rcu_read_lock(). */ static int virtio_queue_empty_rcu(VirtQueue *vq) { - if (unlikely(vq->vdev->broken)) { + if (virtio_device_disabled(vq->vdev)) { return 1; } =20 @@ -565,7 +565,7 @@ static int virtio_queue_split_empty(VirtQueue *vq) { bool empty; =20 - if (unlikely(vq->vdev->broken)) { + if (virtio_device_disabled(vq->vdev)) { return 1; } =20 @@ -783,7 +783,7 @@ void virtqueue_fill(VirtQueue *vq, const VirtQueueEleme= nt *elem, =20 virtqueue_unmap_sg(vq, elem, len); =20 - if (unlikely(vq->vdev->broken)) { + if (virtio_device_disabled(vq->vdev)) { return; } =20 @@ -839,7 +839,7 @@ static void virtqueue_packed_flush(VirtQueue *vq, unsig= ned int count) =20 void virtqueue_flush(VirtQueue *vq, unsigned int count) { - if (unlikely(vq->vdev->broken)) { + if (virtio_device_disabled(vq->vdev)) { vq->inuse -=3D count; return; } @@ -1602,7 +1602,7 @@ err_undo_map: =20 void *virtqueue_pop(VirtQueue *vq, size_t sz) { - if (unlikely(vq->vdev->broken)) { + if (virtio_device_disabled(vq->vdev)) { return NULL; } =20 @@ -1698,7 +1698,7 @@ unsigned int virtqueue_drop_all(VirtQueue *vq) { struct VirtIODevice *vdev =3D vq->vdev; =20 - if (unlikely(vdev->broken)) { + if (virtio_device_disabled(vq->vdev)) { return 0; } =20 @@ -1816,7 +1816,7 @@ static void virtio_notify_vector(VirtIODevice *vdev, = uint16_t vector) BusState *qbus =3D qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); =20 - if (unlikely(vdev->broken)) { + if (virtio_device_disabled(vdev)) { return; } =20 @@ -1920,6 +1920,7 @@ void virtio_reset(void *opaque) vdev->guest_features =3D 0; vdev->queue_sel =3D 0; vdev->status =3D 0; + vdev->disabled =3D false; atomic_set(&vdev->isr, 0); vdev->config_vector =3D VIRTIO_NO_VECTOR; virtio_notify_vector(vdev, vdev->config_vector); @@ -2559,6 +2560,13 @@ static bool virtio_started_needed(void *opaque) return vdev->started; } =20 +static bool virtio_disabled_needed(void *opaque) +{ + VirtIODevice *vdev =3D opaque; + + return vdev->disabled; +} + static const VMStateDescription vmstate_virtqueue =3D { .name =3D "virtqueue_state", .version_id =3D 1, @@ -2724,6 +2732,17 @@ static const VMStateDescription vmstate_virtio_start= ed =3D { } }; =20 +static const VMStateDescription vmstate_virtio_disabled =3D { + .name =3D "virtio/disabled", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D &virtio_disabled_needed, + .fields =3D (VMStateField[]) { + VMSTATE_BOOL(disabled, VirtIODevice), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_virtio =3D { .name =3D "virtio", .version_id =3D 1, @@ -2741,6 +2760,7 @@ static const VMStateDescription vmstate_virtio =3D { &vmstate_virtio_extra_state, &vmstate_virtio_started, &vmstate_virtio_packed_virtqueues, + &vmstate_virtio_disabled, NULL } }; @@ -3575,6 +3595,7 @@ static void virtio_device_instance_finalize(Object *o= bj) static Property virtio_properties[] =3D { DEFINE_VIRTIO_COMMON_FEATURES(VirtIODevice, host_features), DEFINE_PROP_BOOL("use-started", VirtIODevice, use_started, true), + DEFINE_PROP_BOOL("use-disabled-flag", VirtIODevice, use_disabled_flag,= true), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415163; cv=none; d=zohomail.com; s=zohoarc; b=NHXA45Z5uLPhP1TXD6hRbbdXGLb7j0prQm8lw4V3JdfYMIYw5RiszZ2uRQX9jrOFBiS8l7pCTMzI0iJXVemtAMze0j+sxXtCYwM3ANadePTREhgDr4gGFexI06Pz6MbKYSrQCJcMC699qnDPI4t101ejBjBYi1YBn14dbzN1M0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415163; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2mjtemMUgB27JpLi8+N3bxzl1+0IVjBnBvvjPKdiAjc=; b=niThwcGZG+TRKHpriwqi7hrZk6aLxc4eq3Czs68CT+NE2zG90Sj3NHYmvXRVcXMPQM7XXHQg8sW9t3eMzqKYUSt/fwrkDBgdpopquBem3cv6DY1350t6iaMHb0ga8mSY1iRAOtJIb44UjrVhD2HX2SzCO1MXM22zErHEY7qCSg0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578415163656984.5784959260476; Tue, 7 Jan 2020 08:39:23 -0800 (PST) Received: from localhost ([::1]:52808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iort4-0000N8-1e for importer@patchew.org; Tue, 07 Jan 2020 11:39:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46296) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorkJ-000736-UE for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorkI-00051n-8V for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:19 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:43642 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorkI-00051Q-3W for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:18 -0500 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-399-dHfgYL-LNYKThYYUF6a-Jw-1; Tue, 07 Jan 2020 11:30:16 -0500 Received: by mail-qv1-f69.google.com with SMTP id n11so231433qvp.15 for ; Tue, 07 Jan 2020 08:30:15 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id q2sm46946qkm.5.2020.01.07.08.30.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:30:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414617; 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=2mjtemMUgB27JpLi8+N3bxzl1+0IVjBnBvvjPKdiAjc=; b=c9ldSnM2VvIdlBiak4kuwQsuCeFNctVJRUSVab5EqZOEDvaH4L2SILsPxQodEEMWHkBE6V l5h+NJ/PtJ0c3aLZ9a9uqRF1F24vY6DOxAqdHyyw2MJTRiIWaYmYxBghhlKvyVt1p9WRyS xb+nM9jif1H9w8z5lHMAgiiW5Vd2m1A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=P6B2QZEV+S1MRINFAeh/u30RoNzW+dHtR0xLU33u1wE=; b=t//CdrczMu455kZ7emNM2LK9+3UvFHtmVoupVIu7pTbS2wQe9fVOG+kO3MvoY3l3yM SZ1wNWZ5DAmGq0Mv2fEA6cnelWYah2SXtFa/U81Wsd1xUc28d+TeQxAV/zYA/f4NPGYe NrRJKBCrIAHvO1+f20xP9q7n9vZtA4Modpz21yoWYtqysgmvPnHbNyfKWyagQnLFSRFG L2N59JwNNTkqJ8uROQrTaip2pxCIlp4MF0gnMtLdAhFusFjl/WaeSEgKsvQ/iGolBTZR ICSeIWi/QL+KhGk5BwVqbtw/e5iBnp0G3MNp4g45bVTCujLfESBYERdLx4euvXQQXMht mgsw== X-Gm-Message-State: APjAAAWFAKti6hsssjlefAKhcy9FQm33K833nn8diTnW6CCNVCeQIbxF zkSTLB43rxCep9yXVSYGpPOzlAk4FMga/LmnvljXKR3847wwZRGswD/6SKk0pW2hJ/LJjJsg7VS w3PQJHZfSG+tNkak= X-Received: by 2002:a0c:fac7:: with SMTP id p7mr260249qvo.46.1578414614629; Tue, 07 Jan 2020 08:30:14 -0800 (PST) X-Google-Smtp-Source: APXvYqzXsJKJIsaS7He1wfVLTgMn3Ym73X9jPiD1JuiMAF1cW/+YK1uU/tm4O29tSaxxe400Qlkw1A== X-Received: by 2002:a0c:fac7:: with SMTP id p7mr260217qvo.46.1578414614239; Tue, 07 Jan 2020 08:30:14 -0800 (PST) Date: Tue, 7 Jan 2020 11:30:10 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 09/32] Implement backend program convention command for vhost-user-blk Message-ID: <20200107162850.411448-10-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: dHfgYL-LNYKThYYUF6a-Jw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Micky Yun Chan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Micky Yun Chan This patch is to add standard commands defined in docs/interop/vhost-user.r= st For vhost-user-* program Signed-off-by: Micky Yun Chan (michiboo) Message-Id: <20191209015331.5455-1-chanmickyyun@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/interop/vhost-user.json | 31 +++++++ contrib/vhost-user-blk/vhost-user-blk.c | 108 ++++++++++++++---------- docs/interop/vhost-user.rst | 17 ++++ 3 files changed, 112 insertions(+), 44 deletions(-) diff --git a/docs/interop/vhost-user.json b/docs/interop/vhost-user.json index da6aaf51c8..ce0ef74db5 100644 --- a/docs/interop/vhost-user.json +++ b/docs/interop/vhost-user.json @@ -54,6 +54,37 @@ ] } =20 +## +# @VHostUserBackendBlockFeature: +# +# List of vhost user "block" features. +# +# @read-only: The --read-only command line option is supported. +# @blk-file: The --blk-file command line option is supported. +# +# Since: 5.0 +## +{ + 'enum': 'VHostUserBackendBlockFeature', + 'data': [ 'read-only', 'blk-file' ] +} + +## +# @VHostUserBackendCapabilitiesBlock: +# +# Capabilities reported by vhost user "block" backends +# +# @features: list of supported features. +# +# Since: 5.0 +## +{ + 'struct': 'VHostUserBackendCapabilitiesBlock', + 'data': { + 'features': [ 'VHostUserBackendBlockFeature' ] + } +} + ## # @VHostUserBackendInputFeature: # diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-b= lk/vhost-user-blk.c index ae61034656..6fd91c7e99 100644 --- a/contrib/vhost-user-blk/vhost-user-blk.c +++ b/contrib/vhost-user-blk/vhost-user-blk.c @@ -576,70 +576,90 @@ vub_new(char *blk_file) return vdev_blk; } =20 +static int opt_fdnum =3D -1; +static char *opt_socket_path; +static char *opt_blk_file; +static gboolean opt_print_caps; +static gboolean opt_read_only; + +static GOptionEntry entries[] =3D { + { "print-capabilities", 'c', 0, G_OPTION_ARG_NONE, &opt_print_caps, + "Print capabilities", NULL }, + { "fd", 'f', 0, G_OPTION_ARG_INT, &opt_fdnum, + "Use inherited fd socket", "FDNUM" }, + { "socket-path", 's', 0, G_OPTION_ARG_FILENAME, &opt_socket_path, + "Use UNIX socket path", "PATH" }, + {"blk-file", 'b', 0, G_OPTION_ARG_FILENAME, &opt_blk_file, + "block device or file path", "PATH"}, + { "read-only", 'r', 0, G_OPTION_ARG_NONE, &opt_read_only, + "Enable read-only", NULL } +}; + int main(int argc, char **argv) { - int opt; - char *unix_socket =3D NULL; - char *blk_file =3D NULL; - bool enable_ro =3D false; int lsock =3D -1, csock =3D -1; VubDev *vdev_blk =3D NULL; + GError *error =3D NULL; + GOptionContext *context; =20 - while ((opt =3D getopt(argc, argv, "b:rs:h")) !=3D -1) { - switch (opt) { - case 'b': - blk_file =3D g_strdup(optarg); - break; - case 's': - unix_socket =3D g_strdup(optarg); - break; - case 'r': - enable_ro =3D true; - break; - case 'h': - default: - printf("Usage: %s [ -b block device or file, -s UNIX domain so= cket" - " | -r Enable read-only ] | [ -h ]\n", argv[0]); - return 0; + context =3D g_option_context_new(NULL); + g_option_context_add_main_entries(context, entries, NULL); + if (!g_option_context_parse(context, &argc, &argv, &error)) { + g_printerr("Option parsing failed: %s\n", error->message); + exit(EXIT_FAILURE); + } + if (opt_print_caps) { + g_print("{\n"); + g_print(" \"type\": \"block\",\n"); + g_print(" \"features\": [\n"); + g_print(" \"read-only\",\n"); + g_print(" \"blk-file\"\n"); + g_print(" ]\n"); + g_print("}\n"); + exit(EXIT_SUCCESS); + } + + if (!opt_blk_file) { + g_print("%s\n", g_option_context_get_help(context, true, NULL)); + exit(EXIT_FAILURE); + } + + if (opt_socket_path) { + lsock =3D unix_sock_new(opt_socket_path); + if (lsock < 0) { + exit(EXIT_FAILURE); } + } else if (opt_fdnum < 0) { + g_print("%s\n", g_option_context_get_help(context, true, NULL)); + exit(EXIT_FAILURE); + } else { + lsock =3D opt_fdnum; } =20 - if (!unix_socket || !blk_file) { - printf("Usage: %s [ -b block device or file, -s UNIX domain socket" - " | -r Enable read-only ] | [ -h ]\n", argv[0]); - return -1; - } - - lsock =3D unix_sock_new(unix_socket); - if (lsock < 0) { - goto err; - } - - csock =3D accept(lsock, (void *)0, (void *)0); + csock =3D accept(lsock, NULL, NULL); if (csock < 0) { - fprintf(stderr, "Accept error %s\n", strerror(errno)); - goto err; + g_printerr("Accept error %s\n", strerror(errno)); + exit(EXIT_FAILURE); } =20 - vdev_blk =3D vub_new(blk_file); + vdev_blk =3D vub_new(opt_blk_file); if (!vdev_blk) { - goto err; + exit(EXIT_FAILURE); } - if (enable_ro) { + if (opt_read_only) { vdev_blk->enable_ro =3D true; } =20 if (!vug_init(&vdev_blk->parent, VHOST_USER_BLK_MAX_QUEUES, csock, vub_panic_cb, &vub_iface)) { - fprintf(stderr, "Failed to initialized libvhost-user-glib\n"); - goto err; + g_printerr("Failed to initialize libvhost-user-glib\n"); + exit(EXIT_FAILURE); } =20 g_main_loop_run(vdev_blk->loop); - + g_main_loop_unref(vdev_blk->loop); + g_option_context_free(context); vug_deinit(&vdev_blk->parent); - -err: vub_free(vdev_blk); if (csock >=3D 0) { close(csock); @@ -647,8 +667,8 @@ err: if (lsock >=3D 0) { close(lsock); } - g_free(unix_socket); - g_free(blk_file); + g_free(opt_socket_path); + g_free(opt_blk_file); =20 return 0; } diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 7827b710aa..015ac08177 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -1376,3 +1376,20 @@ Command line options: Enable virgl rendering support. =20 (optional) + +vhost-user-blk +-------------- + +Command line options: + +--blk-file=3DPATH + + Specify block device or file path. + + (optional) + +--read-only + + Enable read-only. + + (optional) --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415537; cv=none; d=zohomail.com; s=zohoarc; b=fRg2zN4OJvoyQJ3U4h3xmmL0M5+q14TZqkm0rUz1X8ic5y6FWiT4TbhAKnMol+WE6thLJ+wLDLEjn2WnyVtrXzVsPqme65QQa/UpEvYQF1kLKH0unh1Sdjpn3jxIxRqhMn6Xse8AGTUWgjX1DS+erSBIumzrvk3tYOFHq5gZ+X0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415537; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w1jQK9Yxd2TIknp+M77tR7Mc2wzi2h6Dp27XqCYt2e4=; b=cHPotYolU+TvDweEaaDUSo6Osftstlxv3Zm74NWNUGai3VhvFFjVOJLco691XMBxa/dfnlkRZ+nY9JG1QgWCvsWBUoT5qXyI5qqquAiVvbh2gYUat/XUW8ELa+S7j4Ee8XTdrMShH4oHWR/0WZuRvovN+03C/Rl5F/58/wxSHgo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157841553776728.302428508122148; Tue, 7 Jan 2020 08:45:37 -0800 (PST) Received: from localhost ([::1]:52884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorz5-0003qG-Tg for importer@patchew.org; Tue, 07 Jan 2020 11:45:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46381) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorkP-00079w-LC for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorkN-00054r-Ta for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:25 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:33992 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorkN-00054a-O6 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:23 -0500 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-121-xg12IX3aNiiyuCfhwg9RAg-1; Tue, 07 Jan 2020 11:30:19 -0500 Received: by mail-qk1-f198.google.com with SMTP id d1so131128qkk.15 for ; Tue, 07 Jan 2020 08:30:19 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id t73sm33063qke.71.2020.01.07.08.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:30:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414623; 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=w1jQK9Yxd2TIknp+M77tR7Mc2wzi2h6Dp27XqCYt2e4=; b=JDJPf6LfMTmG+xL9059VWgwjiXZnJadox5iTeqbT5+7ZbFfyjX81EEJTtO8wQsyNL0/PV5 oekZNu40fP55RE4K1165TA6lWDWAuqvrn64frJo7s5630OhMynHXAe+LNXN93IQRfqNBqQ uIVqqBcUIf9hM05UQnNcKi5O+oqbTtQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ks6shax4mMonha1r8yzWlFliM2SkYmnLxhP6HsmGeGE=; b=Fwe/p5U+ZAAYqufn4zNGHHKy6OCBmcpw1R/YHDCXXaJjO1UyOGHAOPFYMMgQbf456m 1/TH19IreZ0MP/Ffn4JRL9RrbxqRO9Pqh1l5fdOTRuAC+A+BAwapII0wETOhMEw1IyHg Pw+Q9NhQawFzWfRUgsluB0VOiDsHdFzQKthDHC/MWrnDM0h4tjq4yv/vnb6PKIK0NkTz ZlTXOU++x7vKu2EErV4oduAz2RDzxxFc9dPF5Jkq52JvJKJYadxD6sRP34cNS6UbMWV8 dNaoDd0JkbhQbRmGtLpVozFigfVeRKCBO4nUsjonjxEibrLAzBBALlCKCos+uR/pWXtW xCMQ== X-Gm-Message-State: APjAAAWTlBZ00qAah3X8AKbZTgxmH8rzb6rz+quMm4FczJc0Co1DENT4 FQgl1g5gRE0742clXLc4MaoxyM5qqqpZ2fkKa4Rs237SGl3F39QuFkOFHJbM/gS4lYrb4LjqIpd Rf6obJNPsIbve+AI= X-Received: by 2002:ad4:4b6a:: with SMTP id m10mr229638qvx.116.1578414619134; Tue, 07 Jan 2020 08:30:19 -0800 (PST) X-Google-Smtp-Source: APXvYqzfMQGFR18WwTvHFSW5GJ9gR37znPFSMdOgvJO89YIRRpvXpo7QexUhtxdEylB0Y3BNuy4lWw== X-Received: by 2002:ad4:4b6a:: with SMTP id m10mr229611qvx.116.1578414618846; Tue, 07 Jan 2020 08:30:18 -0800 (PST) Date: Tue, 7 Jan 2020 11:30:14 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 10/32] virtio: don't enable notifications during polling Message-ID: <20200107162850.411448-11-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: xg12IX3aNiiyuCfhwg9RAg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , Paolo Bonzini , Fam Zheng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Virtqueue notifications are not necessary during polling, so we disable them. This allows the guest driver to avoid MMIO vmexits. Unfortunately the virtio-blk and virtio-scsi handler functions re-enable notifications, defeating this optimization. Fix virtio-blk and virtio-scsi emulation so they leave notifications disabled. The key thing to remember for correctness is that polling always checks one last time after ending its loop, therefore it's safe to lose the race when re-enabling notifications at the end of polling. There is a measurable performance improvement of 5-10% with the null-co block driver. Real-life storage configurations will see a smaller improvement because the MMIO vmexit overhead contributes less to latency. Signed-off-by: Stefan Hajnoczi Message-Id: <20191209210957.65087-1-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 1 + hw/block/virtio-blk.c | 9 +++++++-- hw/scsi/virtio-scsi.c | 9 +++++++-- hw/virtio/virtio.c | 12 ++++++------ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 777772475c..b69d517496 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -228,6 +228,7 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int ve= rsion_id); =20 void virtio_notify_config(VirtIODevice *vdev); =20 +bool virtio_queue_get_notification(VirtQueue *vq); void virtio_queue_set_notification(VirtQueue *vq, int enable); =20 int virtio_queue_ready(VirtQueue *vq); diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index d62e6377c2..b12157b5eb 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -764,13 +764,16 @@ bool virtio_blk_handle_vq(VirtIOBlock *s, VirtQueue *= vq) { VirtIOBlockReq *req; MultiReqBuffer mrb =3D {}; + bool suppress_notifications =3D virtio_queue_get_notification(vq); bool progress =3D false; =20 aio_context_acquire(blk_get_aio_context(s->blk)); blk_io_plug(s->blk); =20 do { - virtio_queue_set_notification(vq, 0); + if (suppress_notifications) { + virtio_queue_set_notification(vq, 0); + } =20 while ((req =3D virtio_blk_get_request(s, vq))) { progress =3D true; @@ -781,7 +784,9 @@ bool virtio_blk_handle_vq(VirtIOBlock *s, VirtQueue *vq) } } =20 - virtio_queue_set_notification(vq, 1); + if (suppress_notifications) { + virtio_queue_set_notification(vq, 1); + } } while (!virtio_queue_empty(vq)); =20 if (mrb.num_reqs) { diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index e8b2b64d09..f080545f48 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -597,12 +597,15 @@ bool virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQue= ue *vq) { VirtIOSCSIReq *req, *next; int ret =3D 0; + bool suppress_notifications =3D virtio_queue_get_notification(vq); bool progress =3D false; =20 QTAILQ_HEAD(, VirtIOSCSIReq) reqs =3D QTAILQ_HEAD_INITIALIZER(reqs); =20 do { - virtio_queue_set_notification(vq, 0); + if (suppress_notifications) { + virtio_queue_set_notification(vq, 0); + } =20 while ((req =3D virtio_scsi_pop_req(s, vq))) { progress =3D true; @@ -622,7 +625,9 @@ bool virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue= *vq) } } =20 - virtio_queue_set_notification(vq, 1); + if (suppress_notifications) { + virtio_queue_set_notification(vq, 1); + } } while (ret !=3D -EINVAL && !virtio_queue_empty(vq)); =20 QTAILQ_FOREACH_SAFE(req, &reqs, next, next) { diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 7bc6a9455e..95d8ff8508 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -432,6 +432,11 @@ static void virtio_queue_packed_set_notification(VirtQ= ueue *vq, int enable) } } =20 +bool virtio_queue_get_notification(VirtQueue *vq) +{ + return vq->notification; +} + void virtio_queue_set_notification(VirtQueue *vq, int enable) { vq->notification =3D enable; @@ -3410,17 +3415,12 @@ static bool virtio_queue_host_notifier_aio_poll(voi= d *opaque) { EventNotifier *n =3D opaque; VirtQueue *vq =3D container_of(n, VirtQueue, host_notifier); - bool progress; =20 if (!vq->vring.desc || virtio_queue_empty(vq)) { return false; } =20 - progress =3D virtio_queue_notify_aio_vq(vq); - - /* In case the handler function re-enabled notifications */ - virtio_queue_set_notification(vq, 0); - return progress; + return virtio_queue_notify_aio_vq(vq); } =20 static void virtio_queue_host_notifier_aio_poll_end(EventNotifier *n) --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415166; cv=none; d=zohomail.com; s=zohoarc; b=G0QheGq2wp4VOat1hR1BsV5EE+TQUggWo26WmIMTAzQJlFLAiDSEEIf1h9LUkQu3ChK8OTol0hltvwDowOZVOZg6qD5Q09ANxJuvmiFfKqt76fuQcONKElJuOM6WY130qn02lS29TsUbcS/j4ld8IpQSl/6wRsHyHf98WZ/djDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415166; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pXEsl8xj2B6C4J6CzOpzs7IZM8KuBGBRcno+vmHdxQg=; b=MGkNTCeRXVPdFUbcfekPVL9TSMcoulhkoZJf8zSvdvHtwSKDjXzt0tmuZ+QhmorcVM0+HEBdPQaqY0lqNsh2AndFgONa8d8ZtUFbIRTX3Kxg9xHPAIrIjMIscaFn+giLtDvB8YIMk9K2NV636RZ8t7WKaQET1wzDCAW/mNGxSyI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15784151666695.6870732429849795; Tue, 7 Jan 2020 08:39:26 -0800 (PST) Received: from localhost ([::1]:52810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iort6-0000S7-Q8 for importer@patchew.org; Tue, 07 Jan 2020 11:39:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46467) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorkV-0007Hw-Ok for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorkT-00058G-Cw for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:31 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:22744 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorkT-00057m-7h for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:29 -0500 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-Os4ANBfAPQiwVF2CGQ22Mw-1; Tue, 07 Jan 2020 11:30:25 -0500 Received: by mail-qt1-f199.google.com with SMTP id l56so127971qtk.11 for ; Tue, 07 Jan 2020 08:30:25 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id j1sm26918qkl.86.2020.01.07.08.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:30:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414628; 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=pXEsl8xj2B6C4J6CzOpzs7IZM8KuBGBRcno+vmHdxQg=; b=cs75ryBrsojt8gH3/Ht+wqtiR4YztsVFUD1VFuZVzEzbsuMovlr0uuNn3b1nV2HT6m3qn+ y8CbL3sito0JhtNet5ky1DqPmXuUeUdu98LllApYUU6YbEt2S8JdznpxmCd16DQ/np14bP QaMSrNlv90PU/V+0OQTds5d4jUqr/Hk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MPPKzQOazirg5jBND3h1wpeXbc817RV9EQNRRNDvGLg=; b=C2RRmCW3zqtA7ONL8NUznS0zk0WN/WCSQ6nPIxZMB3/HvIUdWyNEv9r/0Y7/7YLRKf /x8NGFBKNrkipxFEQIipcjJvGHl5WMOuatQEPCSq6V1xDF/rDcUng3talGvk1kedeokZ Q8TWKo4gGm22xKH8egcwKxmccYs2mHXrjBNICpPxPwnwOG2i23gJW9cVr8cR/qaK3qdL ic3OsltTOlQ3LBUeJMwGnt4m10xBqBbAyfu3ku/4Bzs7SsphkiNv5cNDcCUN9XrgqrQE XdtgLS2byl92xjrDB0PcdGck7LABrkIwYuQRhgLV3Ii747d8aq/deT73HSzTpmGOUTyK vUVA== X-Gm-Message-State: APjAAAUy8ozWcT+3ZvQwCZmVOkDVyicQUsnIPwWgh8ZT6aVXquRKgzqH kgpwirnBVvUFR+9ZRmEvGpB0ej6tez5ku1hGt9Ii5Kg3Ugt2EWrNcq8hTf0KWZi2Ih2Aj76Pet3 cxN2a0i7ujyBAWz8= X-Received: by 2002:ac8:fae:: with SMTP id b43mr78931080qtk.122.1578414624176; Tue, 07 Jan 2020 08:30:24 -0800 (PST) X-Google-Smtp-Source: APXvYqyIKfDncJlL+3r9vsQu4j/ayPHh4IwCXWWetDiGn071B8yMTzv2r6k96VXWlj+TJbFoU4zKng== X-Received: by 2002:ac8:fae:: with SMTP id b43mr78931049qtk.122.1578414623738; Tue, 07 Jan 2020 08:30:23 -0800 (PST) Date: Tue, 7 Jan 2020 11:30:19 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 11/32] numa: Extend CLI to provide initiator information for numa nodes Message-ID: <20200107162850.411448-12-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: Os4ANBfAPQiwVF2CGQ22Mw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Jingqi Liu , Tao Xu , Markus Armbruster , Igor Mammedov , Dan Williams Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Tao Xu In ACPI 6.3 chapter 5.2.27 Heterogeneous Memory Attribute Table (HMAT), The initiator represents processor which access to memory. And in 5.2.27.3 Memory Proximity Domain Attributes Structure, the attached initiator is defined as where the memory controller responsible for a memory proximity domain. With attached initiator information, the topology of heterogeneous memory can be described. Add new machine property 'hmat' to enable all HMAT specific options. Extend CLI of "-numa node" option to indicate the initiator numa node-id. In the linux kernel, the codes in drivers/acpi/hmat/hmat.c parse and report the platform's HMAT tables. Before using initiator option, enable HMAT with -machine hmat=3Don. Acked-by: Markus Armbruster Reviewed-by: Igor Mammedov Reviewed-by: Jingqi Liu Suggested-by: Dan Williams Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-2-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/machine.json | 10 ++++++- include/sysemu/numa.h | 5 ++++ hw/core/machine.c | 64 +++++++++++++++++++++++++++++++++++++++++++ hw/core/numa.c | 23 ++++++++++++++++ qemu-options.hx | 35 +++++++++++++++++++---- 5 files changed, 131 insertions(+), 6 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index ca26779f1a..27d0e37534 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -463,6 +463,13 @@ # @memdev: memory backend object. If specified for one node, # it must be specified for all nodes. # +# @initiator: defined in ACPI 6.3 Chapter 5.2.27.3 Table 5-145, +# points to the nodeid which has the memory controller +# responsible for this NUMA node. This field provides +# additional information as to the initiator node that +# is closest (as in directly attached) to this node, and +# therefore has the best performance (since 5.0) +# # Since: 2.1 ## { 'struct': 'NumaNodeOptions', @@ -470,7 +477,8 @@ '*nodeid': 'uint16', '*cpus': ['uint16'], '*mem': 'size', - '*memdev': 'str' }} + '*memdev': 'str', + '*initiator': 'uint16' }} =20 ## # @NumaDistOptions: diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index ae9c41d02b..788cbec7a2 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -18,6 +18,8 @@ struct NodeInfo { uint64_t node_mem; struct HostMemoryBackend *node_memdev; bool present; + bool has_cpu; + uint16_t initiator; uint8_t distance[MAX_NODES]; }; =20 @@ -33,6 +35,9 @@ struct NumaState { /* Allow setting NUMA distance for different NUMA nodes */ bool have_numa_distance; =20 + /* Detect if HMAT support is enabled. */ + bool hmat_enabled; + /* NUMA nodes information */ NodeInfo nodes[MAX_NODES]; }; diff --git a/hw/core/machine.c b/hw/core/machine.c index 0854dcebdd..f5e2b32b3b 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -430,6 +430,20 @@ static void machine_set_nvdimm(Object *obj, bool value= , Error **errp) ms->nvdimms_state->is_enabled =3D value; } =20 +static bool machine_get_hmat(Object *obj, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + return ms->numa_state->hmat_enabled; +} + +static void machine_set_hmat(Object *obj, bool value, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + ms->numa_state->hmat_enabled =3D value; +} + static char *machine_get_nvdimm_persistence(Object *obj, Error **errp) { MachineState *ms =3D MACHINE(obj); @@ -557,6 +571,7 @@ void machine_set_cpu_numa_node(MachineState *machine, const CpuInstanceProperties *props, Error *= *errp) { MachineClass *mc =3D MACHINE_GET_CLASS(machine); + NodeInfo *numa_info =3D machine->numa_state->nodes; bool match =3D false; int i; =20 @@ -626,6 +641,17 @@ void machine_set_cpu_numa_node(MachineState *machine, match =3D true; slot->props.node_id =3D props->node_id; slot->props.has_node_id =3D props->has_node_id; + + if (machine->numa_state->hmat_enabled) { + if ((numa_info[props->node_id].initiator < MAX_NODES) && + (props->node_id !=3D numa_info[props->node_id].initiator))= { + error_setg(errp, "The initiator of CPU NUMA node %" PRId64 + " should be itself", props->node_id); + return; + } + numa_info[props->node_id].has_cpu =3D true; + numa_info[props->node_id].initiator =3D props->node_id; + } } =20 if (!match) { @@ -846,6 +872,13 @@ static void machine_initfn(Object *obj) =20 if (mc->numa_mem_supported) { ms->numa_state =3D g_new0(NumaState, 1); + object_property_add_bool(obj, "hmat", + machine_get_hmat, machine_set_hmat, + &error_abort); + object_property_set_description(obj, "hmat", + "Set on/off to enable/disable " + "ACPI Heterogeneous Memory Attribu= te " + "Table (HMAT)", NULL); } =20 /* Register notifier when init is done for sysbus sanity checks */ @@ -913,6 +946,32 @@ static char *cpu_slot_to_string(const CPUArchId *cpu) return g_string_free(s, false); } =20 +static void numa_validate_initiator(NumaState *numa_state) +{ + int i; + NodeInfo *numa_info =3D numa_state->nodes; + + for (i =3D 0; i < numa_state->num_nodes; i++) { + if (numa_info[i].initiator =3D=3D MAX_NODES) { + error_report("The initiator of NUMA node %d is missing, use " + "'-numa node,initiator' option to declare it", i); + exit(1); + } + + if (!numa_info[numa_info[i].initiator].present) { + error_report("NUMA node %" PRIu16 " is missing, use " + "'-numa node' option to declare it first", + numa_info[i].initiator); + exit(1); + } + + if (!numa_info[numa_info[i].initiator].has_cpu) { + error_report("The initiator of NUMA node %d is invalid", i); + exit(1); + } + } +} + static void machine_numa_finish_cpu_init(MachineState *machine) { int i; @@ -953,6 +1012,11 @@ static void machine_numa_finish_cpu_init(MachineState= *machine) machine_set_cpu_numa_node(machine, &props, &error_fatal); } } + + if (machine->numa_state->hmat_enabled) { + numa_validate_initiator(machine->numa_state); + } + if (s->len && !qtest_enabled()) { warn_report("CPU(s) not present in any NUMA nodes: %s", s->str); diff --git a/hw/core/numa.c b/hw/core/numa.c index e3332a984f..e60da99293 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -133,6 +133,29 @@ static void parse_numa_node(MachineState *ms, NumaNode= Options *node, numa_info[nodenr].node_mem =3D object_property_get_uint(o, "size",= NULL); numa_info[nodenr].node_memdev =3D MEMORY_BACKEND(o); } + + /* + * If not set the initiator, set it to MAX_NODES. And if + * HMAT is enabled and this node has no cpus, QEMU will raise error. + */ + numa_info[nodenr].initiator =3D MAX_NODES; + if (node->has_initiator) { + if (!ms->numa_state->hmat_enabled) { + error_setg(errp, "ACPI Heterogeneous Memory Attribute Table " + "(HMAT) is disabled, enable it with -machine hmat= =3Don " + "before using any of hmat specific options"); + return; + } + + if (node->initiator >=3D MAX_NODES) { + error_report("The initiator id %" PRIu16 " expects an integer " + "between 0 and %d", node->initiator, + MAX_NODES - 1); + return; + } + + numa_info[nodenr].initiator =3D node->initiator; + } numa_info[nodenr].present =3D true; max_numa_nodeid =3D MAX(max_numa_nodeid, nodenr + 1); ms->numa_state->num_nodes++; diff --git a/qemu-options.hx b/qemu-options.hx index e9d6231438..b78bc52634 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -40,7 +40,8 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " suppress-vmdesc=3Don|off disables self-describing mig= ration (default=3Doff)\n" " nvdimm=3Don|off controls NVDIMM support (default=3Dof= f)\n" " enforce-config-section=3Don|off enforce configuration= section migration (default=3Doff)\n" - " memory-encryption=3D@var{} memory encryption object t= o use (default=3Dnone)\n", + " memory-encryption=3D@var{} memory encryption object t= o use (default=3Dnone)\n" + " hmat=3Don|off controls ACPI HMAT support (default=3Do= ff)\n", QEMU_ARCH_ALL) STEXI @item -machine [type=3D]@var{name}[,prop=3D@var{value}[,...]] @@ -94,6 +95,9 @@ NOTE: this parameter is deprecated. Please use @option{-g= lobal} @option{migration.send-configuration}=3D@var{on|off} instead. @item memory-encryption=3D@var{} Memory encryption object to use. The default is none. +@item hmat=3Don|off +Enables or disables ACPI Heterogeneous Memory Attribute Table (HMAT) suppo= rt. +The default is off. @end table ETEXI =20 @@ -168,14 +172,14 @@ If any on the three values is given, the total number= of CPUs @var{n} can be omi ETEXI =20 DEF("numa", HAS_ARG, QEMU_OPTION_numa, - "-numa node[,mem=3Dsize][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode]\n" - "-numa node[,memdev=3Did][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode]\= n" + "-numa node[,mem=3Dsize][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode][,= initiator=3Dnode]\n" + "-numa node[,memdev=3Did][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode][= ,initiator=3Dnode]\n" "-numa dist,src=3Dsource,dst=3Ddestination,val=3Ddistance\n" "-numa cpu,node-id=3Dnode[,socket-id=3Dx][,core-id=3Dy][,thread-id=3Dz= ]\n", QEMU_ARCH_ALL) STEXI -@item -numa node[,mem=3D@var{size}][,cpus=3D@var{firstcpu}[-@var{lastcpu}]= ][,nodeid=3D@var{node}] -@itemx -numa node[,memdev=3D@var{id}][,cpus=3D@var{firstcpu}[-@var{lastcpu= }]][,nodeid=3D@var{node}] +@item -numa node[,mem=3D@var{size}][,cpus=3D@var{firstcpu}[-@var{lastcpu}]= ][,nodeid=3D@var{node}][,initiator=3D@var{initiator}] +@itemx -numa node[,memdev=3D@var{id}][,cpus=3D@var{firstcpu}[-@var{lastcpu= }]][,nodeid=3D@var{node}][,initiator=3D@var{initiator}] @itemx -numa dist,src=3D@var{source},dst=3D@var{destination},val=3D@var{di= stance} @itemx -numa cpu,node-id=3D@var{node}[,socket-id=3D@var{x}][,core-id=3D@va= r{y}][,thread-id=3D@var{z}] @findex -numa @@ -222,6 +226,27 @@ split equally between them. @samp{mem} and @samp{memdev} are mutually exclusive. Furthermore, if one node uses @samp{memdev}, all of them have to use it. =20 +@samp{initiator} is an additional option that points to an @var{initiator} +NUMA node that has best performance (the lowest latency or largest bandwid= th) +to this NUMA @var{node}. Note that this option can be set only when +the machine property 'hmat' is set to 'on'. + +Following example creates a machine with 2 NUMA nodes, node 0 has CPU. +node 1 has only memory, and its initiator is node 0. Note that because +node 0 has CPU, by default the initiator of node 0 is itself and must be +itself. +@example +-machine hmat=3Don \ +-m 2G,slots=3D2,maxmem=3D4G \ +-object memory-backend-ram,size=3D1G,id=3Dm0 \ +-object memory-backend-ram,size=3D1G,id=3Dm1 \ +-numa node,nodeid=3D0,memdev=3Dm0 \ +-numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0 \ +-smp 2,sockets=3D2,maxcpus=3D2 \ +-numa cpu,node-id=3D0,socket-id=3D0 \ +-numa cpu,node-id=3D0,socket-id=3D1 +@end example + @var{source} and @var{destination} are NUMA node IDs. @var{distance} is the NUMA distance from @var{source} to @var{destination}. The distance from a node to itself is always 10. If any pair of nodes is --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415752; cv=none; d=zohomail.com; s=zohoarc; b=hGEpuvBtI35PRwO+x0yA+aS0oDYN5SHxBsnTkT0kofHpJA2YreFAebrUvn19d+28BhR148O/m6pXOwehDXzQesbjbCZMfoDYR9qwKZdcXsraQJ9qjciDR2G+11UlhUBlZnzo9pJa9wR90W+6LSVlZL3CLmanGtJJUuxMmNR8Mpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415752; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=22EPts6aFtlxMBe62U24R+ZdRqDDBVDzjTf7DPsfcPs=; b=bN4INtsLOVOr8pK3qZ5sAl3f7w72jYYpv56cwo+sCkblPqhOn3t5mKlCYyh/PsCoMWO9m0AVZhzcSdedFTfp8sDj3MYTHLt8yX7JjhOB17Ofd5fRkG0sk0H8VveNgFqnY9QeE4V81kGc4ylPZwMmelEK42i5Zfqk6SUdKvxD4zg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578415752514378.6015902004831; Tue, 7 Jan 2020 08:49:12 -0800 (PST) Received: from localhost ([::1]:52978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ios2Y-0000MU-Et for importer@patchew.org; Tue, 07 Jan 2020 11:49:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46511) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorkZ-0007KL-5C for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorkW-00059t-3S for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:35 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:21101 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorkV-00059P-T1 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:32 -0500 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-225-hmn-a0kUNzKjZ4a6kQdL0g-1; Tue, 07 Jan 2020 11:30:30 -0500 Received: by mail-qt1-f197.google.com with SMTP id l5so129605qte.10 for ; Tue, 07 Jan 2020 08:30:30 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id 124sm45930qko.11.2020.01.07.08.30.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:30:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414631; 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=22EPts6aFtlxMBe62U24R+ZdRqDDBVDzjTf7DPsfcPs=; b=jGBuZQMsbssZTUJ49jyhH9eHqQDKKDsyeCusm0eyJDZ45xd8yRLtoQEa7zcWVtenp7/4kA 3fhFW26Y8bYvwg+KrBlVsdzlWXasTedTXM2zuUnMp1Y3eSsEvkx/e578vq/ShTHJVR6AMe yV9PTi928OwPstQJdgnkySxqj8eQp3Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=xnCcrYb/jhhSnPfhxsRrpT5AqLZcj5F/dVmLqeFIs/8=; b=l+CI9amjZgMcUJanbHN1r4jyOOsyd/4C2b+vQDfQqPnTN8x5eKbkcHQJmWyDBoJgaC PX/gN58rSpEKXBV1q/FLYdbR7H1sm01Iz2VMmIyqA9Pt7IbIa2novIrpYa4kq56aPFYP 4QKUjc1bpyzU/5cVSb+qjv87NUU31vtuNZkOkgZ/ta2kNBsKsZgsFJkxfktMB3pOQ/b2 JW21sg4xqh5AomDpzBQs5/tBhudemDk2c8Vx3iYKaqNIyvDEUppdtarFcSWDYfa93sKd K6tigDZHPX9EoF+j61lEz/A6dLBzoieMiU5jsCxZrVtgeYCWGhF6JpXPHeyQ6TTg9dBP N3AQ== X-Gm-Message-State: APjAAAWrbhkNnkWKyuGSJBk3PHHW9UbTTtWjRzGuYeEtzE7yeqMlZvWx sxnVGKXveun48ZLdwXfXOrJUnBrpLhifcIpHkyfkySE+FG1j/SAoy5pzZceubenkf6RdeWCxKW/ tDXRD8jARNqbpZGY= X-Received: by 2002:ac8:685:: with SMTP id f5mr78858547qth.199.1578414629043; Tue, 07 Jan 2020 08:30:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwr7odvULqKew4Ljh21DnJ/oeay+x2P1WDruXMFpeUPCje42lQ87ahSZl9pDshdBE/G/vEPPQ== X-Received: by 2002:ac8:685:: with SMTP id f5mr78858491qth.199.1578414628503; Tue, 07 Jan 2020 08:30:28 -0800 (PST) Date: Tue, 7 Jan 2020 11:30:24 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 12/32] numa: Extend CLI to provide memory latency and bandwidth information Message-ID: <20200107162850.411448-13-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: hmn-a0kUNzKjZ4a6kQdL0g-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Liu Jingqi , Tao Xu , Markus Armbruster , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liu Jingqi Add -numa hmat-lb option to provide System Locality Latency and Bandwidth Information. These memory attributes help to build System Locality Latency and Bandwidth Information Structure(s) in ACPI Heterogeneous Memory Attribute Table (HMAT). Before using hmat-lb option, enable HMAT with -machine hmat=3Don. Acked-by: Markus Armbruster Signed-off-by: Liu Jingqi Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-3-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- qapi/machine.json | 93 +++++++++++++++++++- include/sysemu/numa.h | 53 ++++++++++++ hw/core/numa.c | 194 ++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 47 +++++++++- 4 files changed, 384 insertions(+), 3 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index 27d0e37534..cf8faf5a2a 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -426,10 +426,12 @@ # # @cpu: property based CPU(s) to node mapping (Since: 2.10) # +# @hmat-lb: memory latency and bandwidth information (Since: 5.0) +# # Since: 2.1 ## { 'enum': 'NumaOptionsType', - 'data': [ 'node', 'dist', 'cpu' ] } + 'data': [ 'node', 'dist', 'cpu', 'hmat-lb' ] } =20 ## # @NumaOptions: @@ -444,7 +446,8 @@ 'data': { 'node': 'NumaNodeOptions', 'dist': 'NumaDistOptions', - 'cpu': 'NumaCpuOptions' }} + 'cpu': 'NumaCpuOptions', + 'hmat-lb': 'NumaHmatLBOptions' }} =20 ## # @NumaNodeOptions: @@ -557,6 +560,92 @@ 'base': 'CpuInstanceProperties', 'data' : {} } =20 +## +# @HmatLBMemoryHierarchy: +# +# The memory hierarchy in the System Locality Latency and Bandwidth +# Information Structure of HMAT (Heterogeneous Memory Attribute Table) +# +# For more information about @HmatLBMemoryHierarchy, see chapter +# 5.2.27.4: Table 5-146: Field "Flags" of ACPI 6.3 spec. +# +# @memory: the structure represents the memory performance +# +# @first-level: first level of memory side cache +# +# @second-level: second level of memory side cache +# +# @third-level: third level of memory side cache +# +# Since: 5.0 +## +{ 'enum': 'HmatLBMemoryHierarchy', + 'data': [ 'memory', 'first-level', 'second-level', 'third-level' ] } + +## +# @HmatLBDataType: +# +# Data type in the System Locality Latency and Bandwidth +# Information Structure of HMAT (Heterogeneous Memory Attribute Table) +# +# For more information about @HmatLBDataType, see chapter +# 5.2.27.4: Table 5-146: Field "Data Type" of ACPI 6.3 spec. +# +# @access-latency: access latency (nanoseconds) +# +# @read-latency: read latency (nanoseconds) +# +# @write-latency: write latency (nanoseconds) +# +# @access-bandwidth: access bandwidth (Bytes per second) +# +# @read-bandwidth: read bandwidth (Bytes per second) +# +# @write-bandwidth: write bandwidth (Bytes per second) +# +# Since: 5.0 +## +{ 'enum': 'HmatLBDataType', + 'data': [ 'access-latency', 'read-latency', 'write-latency', + 'access-bandwidth', 'read-bandwidth', 'write-bandwidth' ] } + +## +# @NumaHmatLBOptions: +# +# Set the system locality latency and bandwidth information +# between Initiator and Target proximity Domains. +# +# For more information about @NumaHmatLBOptions, see chapter +# 5.2.27.4: Table 5-146 of ACPI 6.3 spec. +# +# @initiator: the Initiator Proximity Domain. +# +# @target: the Target Proximity Domain. +# +# @hierarchy: the Memory Hierarchy. Indicates the performance +# of memory or side cache. +# +# @data-type: presents the type of data, access/read/write +# latency or hit latency. +# +# @latency: the value of latency from @initiator to @target +# proximity domain, the latency unit is "ns(nanosecond)". +# +# @bandwidth: the value of bandwidth between @initiator and @target +# proximity domain, the bandwidth unit is +# "Bytes per second". +# +# Since: 5.0 +## +{ 'struct': 'NumaHmatLBOptions', + 'data': { + 'initiator': 'uint16', + 'target': 'uint16', + 'hierarchy': 'HmatLBMemoryHierarchy', + 'data-type': 'HmatLBDataType', + '*latency': 'uint64', + '*bandwidth': 'size' }} + ## # @HostMemPolicy: # diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 788cbec7a2..70f93c83d7 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -14,11 +14,34 @@ struct CPUArchId; #define NUMA_DISTANCE_MAX 254 #define NUMA_DISTANCE_UNREACHABLE 255 =20 +/* the value of AcpiHmatLBInfo flags */ +enum { + HMAT_LB_MEM_MEMORY =3D 0, + HMAT_LB_MEM_CACHE_1ST_LEVEL =3D 1, + HMAT_LB_MEM_CACHE_2ND_LEVEL =3D 2, + HMAT_LB_MEM_CACHE_3RD_LEVEL =3D 3, + HMAT_LB_LEVELS /* must be the last entry */ +}; + +/* the value of AcpiHmatLBInfo data type */ +enum { + HMAT_LB_DATA_ACCESS_LATENCY =3D 0, + HMAT_LB_DATA_READ_LATENCY =3D 1, + HMAT_LB_DATA_WRITE_LATENCY =3D 2, + HMAT_LB_DATA_ACCESS_BANDWIDTH =3D 3, + HMAT_LB_DATA_READ_BANDWIDTH =3D 4, + HMAT_LB_DATA_WRITE_BANDWIDTH =3D 5, + HMAT_LB_TYPES /* must be the last entry */ +}; + +#define UINT16_BITS 16 + struct NodeInfo { uint64_t node_mem; struct HostMemoryBackend *node_memdev; bool present; bool has_cpu; + uint8_t lb_info_provided; uint16_t initiator; uint8_t distance[MAX_NODES]; }; @@ -28,6 +51,31 @@ struct NumaNodeMem { uint64_t node_plugged_mem; }; =20 +struct HMAT_LB_Data { + uint8_t initiator; + uint8_t target; + uint64_t data; +}; +typedef struct HMAT_LB_Data HMAT_LB_Data; + +struct HMAT_LB_Info { + /* Indicates it's memory or the specified level memory side cache. */ + uint8_t hierarchy; + + /* Present the type of data, access/read/write latency or bandwidth. */ + uint8_t data_type; + + /* The range bitmap of bandwidth for calculating common base */ + uint64_t range_bitmap; + + /* The common base unit for latencies or bandwidths */ + uint64_t base; + + /* Array to store the latencies or bandwidths */ + GArray *list; +}; +typedef struct HMAT_LB_Info HMAT_LB_Info; + struct NumaState { /* Number of NUMA nodes */ int num_nodes; @@ -40,11 +88,16 @@ struct NumaState { =20 /* NUMA nodes information */ NodeInfo nodes[MAX_NODES]; + + /* NUMA nodes HMAT Locality Latency and Bandwidth Information */ + HMAT_LB_Info *hmat_lb[HMAT_LB_LEVELS][HMAT_LB_TYPES]; }; typedef struct NumaState NumaState; =20 void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp); void parse_numa_opts(MachineState *ms); +void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node, + Error **errp); void numa_complete_configuration(MachineState *ms); void query_numa_node_mem(NumaNodeMem node_mem[], MachineState *ms); extern QemuOptsList qemu_numa_opts; diff --git a/hw/core/numa.c b/hw/core/numa.c index e60da99293..34eb413f5d 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -23,6 +23,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/units.h" #include "sysemu/hostmem.h" #include "sysemu/numa.h" #include "sysemu/sysemu.h" @@ -198,6 +199,186 @@ void parse_numa_distance(MachineState *ms, NumaDistOp= tions *dist, Error **errp) ms->numa_state->have_numa_distance =3D true; } =20 +void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node, + Error **errp) +{ + int i, first_bit, last_bit; + uint64_t max_entry, temp_base, bitmap_copy; + NodeInfo *numa_info =3D numa_state->nodes; + HMAT_LB_Info *hmat_lb =3D + numa_state->hmat_lb[node->hierarchy][node->data_type]; + HMAT_LB_Data lb_data =3D {}; + HMAT_LB_Data *lb_temp; + + /* Error checking */ + if (node->initiator > numa_state->num_nodes) { + error_setg(errp, "Invalid initiator=3D%d, it should be less than %= d", + node->initiator, numa_state->num_nodes); + return; + } + if (node->target > numa_state->num_nodes) { + error_setg(errp, "Invalid target=3D%d, it should be less than %d", + node->target, numa_state->num_nodes); + return; + } + if (!numa_info[node->initiator].has_cpu) { + error_setg(errp, "Invalid initiator=3D%d, it isn't an " + "initiator proximity domain", node->initiator); + return; + } + if (!numa_info[node->target].present) { + error_setg(errp, "The target=3D%d should point to an existing node= ", + node->target); + return; + } + + if (!hmat_lb) { + hmat_lb =3D g_malloc0(sizeof(*hmat_lb)); + numa_state->hmat_lb[node->hierarchy][node->data_type] =3D hmat_lb; + hmat_lb->list =3D g_array_new(false, true, sizeof(HMAT_LB_Data)); + } + hmat_lb->hierarchy =3D node->hierarchy; + hmat_lb->data_type =3D node->data_type; + lb_data.initiator =3D node->initiator; + lb_data.target =3D node->target; + + if (node->data_type <=3D HMATLB_DATA_TYPE_WRITE_LATENCY) { + /* Input latency data */ + + if (!node->has_latency) { + error_setg(errp, "Missing 'latency' option"); + return; + } + if (node->has_bandwidth) { + error_setg(errp, "Invalid option 'bandwidth' since " + "the data type is latency"); + return; + } + + /* Detect duplicate configuration */ + for (i =3D 0; i < hmat_lb->list->len; i++) { + lb_temp =3D &g_array_index(hmat_lb->list, HMAT_LB_Data, i); + + if (node->initiator =3D=3D lb_temp->initiator && + node->target =3D=3D lb_temp->target) { + error_setg(errp, "Duplicate configuration of the latency f= or " + "initiator=3D%d and target=3D%d", node->initiator, + node->target); + return; + } + } + + hmat_lb->base =3D hmat_lb->base ? hmat_lb->base : UINT64_MAX; + + if (node->latency) { + /* Calculate the temporary base and compressed latency */ + max_entry =3D node->latency; + temp_base =3D 1; + while (QEMU_IS_ALIGNED(max_entry, 10)) { + max_entry /=3D 10; + temp_base *=3D 10; + } + + /* Calculate the max compressed latency */ + temp_base =3D MIN(hmat_lb->base, temp_base); + max_entry =3D node->latency / hmat_lb->base; + max_entry =3D MAX(hmat_lb->range_bitmap, max_entry); + + /* + * For latency hmat_lb->range_bitmap record the max compressed + * latency which should be less than 0xFFFF (UINT16_MAX) + */ + if (max_entry >=3D UINT16_MAX) { + error_setg(errp, "Latency %" PRIu64 " between initiator=3D= %d and " + "target=3D%d should not differ from previously ent= ered " + "min or max values on more than %d", node->latency, + node->initiator, node->target, UINT16_MAX - 1); + return; + } else { + hmat_lb->base =3D temp_base; + hmat_lb->range_bitmap =3D max_entry; + } + + /* + * Set lb_info_provided bit 0 as 1, + * latency information is provided + */ + numa_info[node->target].lb_info_provided |=3D BIT(0); + } + lb_data.data =3D node->latency; + } else if (node->data_type >=3D HMATLB_DATA_TYPE_ACCESS_BANDWIDTH) { + /* Input bandwidth data */ + if (!node->has_bandwidth) { + error_setg(errp, "Missing 'bandwidth' option"); + return; + } + if (node->has_latency) { + error_setg(errp, "Invalid option 'latency' since " + "the data type is bandwidth"); + return; + } + if (!QEMU_IS_ALIGNED(node->bandwidth, MiB)) { + error_setg(errp, "Bandwidth %" PRIu64 " between initiator=3D%d= and " + "target=3D%d should be 1MB aligned", node->bandwidt= h, + node->initiator, node->target); + return; + } + + /* Detect duplicate configuration */ + for (i =3D 0; i < hmat_lb->list->len; i++) { + lb_temp =3D &g_array_index(hmat_lb->list, HMAT_LB_Data, i); + + if (node->initiator =3D=3D lb_temp->initiator && + node->target =3D=3D lb_temp->target) { + error_setg(errp, "Duplicate configuration of the bandwidth= for " + "initiator=3D%d and target=3D%d", node->initiator, + node->target); + return; + } + } + + hmat_lb->base =3D hmat_lb->base ? hmat_lb->base : 1; + + if (node->bandwidth) { + /* Keep bitmap unchanged when bandwidth out of range */ + bitmap_copy =3D hmat_lb->range_bitmap; + bitmap_copy |=3D node->bandwidth; + first_bit =3D ctz64(bitmap_copy); + temp_base =3D UINT64_C(1) << first_bit; + max_entry =3D node->bandwidth / temp_base; + last_bit =3D 64 - clz64(bitmap_copy); + + /* + * For bandwidth, first_bit record the base unit of bandwidth = bits, + * last_bit record the last bit of the max bandwidth. The max + * compressed bandwidth should be less than 0xFFFF (UINT16_MAX) + */ + if ((last_bit - first_bit) > UINT16_BITS || + max_entry >=3D UINT16_MAX) { + error_setg(errp, "Bandwidth %" PRIu64 " between initiator= =3D%d " + "and target=3D%d should not differ from previously= " + "entered values on more than %d", node->bandwidth, + node->initiator, node->target, UINT16_MAX - 1); + return; + } else { + hmat_lb->base =3D temp_base; + hmat_lb->range_bitmap =3D bitmap_copy; + } + + /* + * Set lb_info_provided bit 1 as 1, + * bandwidth information is provided + */ + numa_info[node->target].lb_info_provided |=3D BIT(1); + } + lb_data.data =3D node->bandwidth; + } else { + assert(0); + } + + g_array_append_val(hmat_lb->list, lb_data); +} + void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp) { Error *err =3D NULL; @@ -236,6 +417,19 @@ void set_numa_options(MachineState *ms, NumaOptions *o= bject, Error **errp) machine_set_cpu_numa_node(ms, qapi_NumaCpuOptions_base(&object->u.= cpu), &err); break; + case NUMA_OPTIONS_TYPE_HMAT_LB: + if (!ms->numa_state->hmat_enabled) { + error_setg(errp, "ACPI Heterogeneous Memory Attribute Table " + "(HMAT) is disabled, enable it with -machine hmat= =3Don " + "before using any of hmat specific options"); + return; + } + + parse_numa_hmat_lb(ms->numa_state, &object->u.hmat_lb, &err); + if (err) { + goto end; + } + break; default: abort(); } diff --git a/qemu-options.hx b/qemu-options.hx index b78bc52634..a0c0bbb7cf 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -175,16 +175,19 @@ DEF("numa", HAS_ARG, QEMU_OPTION_numa, "-numa node[,mem=3Dsize][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode][,= initiator=3Dnode]\n" "-numa node[,memdev=3Did][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode][= ,initiator=3Dnode]\n" "-numa dist,src=3Dsource,dst=3Ddestination,val=3Ddistance\n" - "-numa cpu,node-id=3Dnode[,socket-id=3Dx][,core-id=3Dy][,thread-id=3Dz= ]\n", + "-numa cpu,node-id=3Dnode[,socket-id=3Dx][,core-id=3Dy][,thread-id=3Dz= ]\n" + "-numa hmat-lb,initiator=3Dnode,target=3Dnode,hierarchy=3Dmemory|first= -level|second-level|third-level,data-type=3Daccess-latency|read-latency|wri= te-latency[,latency=3Dlat][,bandwidth=3Dbw]\n", QEMU_ARCH_ALL) STEXI @item -numa node[,mem=3D@var{size}][,cpus=3D@var{firstcpu}[-@var{lastcpu}]= ][,nodeid=3D@var{node}][,initiator=3D@var{initiator}] @itemx -numa node[,memdev=3D@var{id}][,cpus=3D@var{firstcpu}[-@var{lastcpu= }]][,nodeid=3D@var{node}][,initiator=3D@var{initiator}] @itemx -numa dist,src=3D@var{source},dst=3D@var{destination},val=3D@var{di= stance} @itemx -numa cpu,node-id=3D@var{node}[,socket-id=3D@var{x}][,core-id=3D@va= r{y}][,thread-id=3D@var{z}] +@itemx -numa hmat-lb,initiator=3D@var{node},target=3D@var{node},hierarchy= =3D@var{hierarchy},data-type=3D@var{tpye}[,latency=3D@var{lat}][,bandwidth= =3D@var{bw}] @findex -numa Define a NUMA node and assign RAM and VCPUs to it. Set the NUMA distance from a source node to a destination node. +Set the ACPI Heterogeneous Memory Attributes for the given nodes. =20 Legacy VCPU assignment uses @samp{cpus} option where @var{firstcpu} and @var{lastcpu} are CPU indexes. Each @@ -263,6 +266,48 @@ specified resources, it just assigns existing resource= s to NUMA nodes. This means that one still has to use the @option{-m}, @option{-smp} options to allocate RAM and VCPUs respectively. =20 +Use @samp{hmat-lb} to set System Locality Latency and Bandwidth Information +between initiator and target NUMA nodes in ACPI Heterogeneous Attribute Me= mory Table (HMAT). +Initiator NUMA node can create memory requests, usually it has one or more= processors. +Target NUMA node contains addressable memory. + +In @samp{hmat-lb} option, @var{node} are NUMA node IDs. @var{hierarchy} is= the memory +hierarchy of the target NUMA node: if @var{hierarchy} is 'memory', the str= ucture +represents the memory performance; if @var{hierarchy} is 'first-level|seco= nd-level|third-level', +this structure represents aggregated performance of memory side caches for= each domain. +@var{type} of 'data-type' is type of data represented by this structure in= stance: +if 'hierarchy' is 'memory', 'data-type' is 'access|read|write' latency or = 'access|read|write' +bandwidth of the target memory; if 'hierarchy' is 'first-level|second-leve= l|third-level', +'data-type' is 'access|read|write' hit latency or 'access|read|write' hit = bandwidth of the +target memory side cache. + +@var{lat} is latency value in nanoseconds. @var{bw} is bandwidth value, +the possible value and units are NUM[M|G|T], mean that the bandwidth value= are +NUM byte per second (or MB/s, GB/s or TB/s depending on used suffix). +Note that if latency or bandwidth value is 0, means the corresponding late= ncy or +bandwidth information is not provided. + +For example, the following options describe 2 NUMA nodes. Node 0 has 2 cpu= s and +a ram, node 1 has only a ram. The processors in node 0 access memory in no= de +0 with access-latency 5 nanoseconds, access-bandwidth is 200 MB/s; +The processors in NUMA node 0 access memory in NUMA node 1 with access-lat= ency 10 +nanoseconds, access-bandwidth is 100 MB/s. +@example +-machine hmat=3Don \ +-m 2G \ +-object memory-backend-ram,size=3D1G,id=3Dm0 \ +-object memory-backend-ram,size=3D1G,id=3Dm1 \ +-smp 2 \ +-numa node,nodeid=3D0,memdev=3Dm0 \ +-numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0 \ +-numa cpu,node-id=3D0,socket-id=3D0 \ +-numa cpu,node-id=3D0,socket-id=3D1 \ +-numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmemory,data-type=3Dacce= ss-latency,latency=3D5 \ +-numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmemory,data-type=3Dacce= ss-bandwidth,bandwidth=3D200M \ +-numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmemory,data-type=3Dacce= ss-latency,latency=3D10 \ +-numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmemory,data-type=3Dacce= ss-bandwidth,bandwidth=3D100M +@end example + ETEXI =20 DEF("add-fd", HAS_ARG, QEMU_OPTION_add_fd, --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415911; cv=none; d=zohomail.com; s=zohoarc; b=a4OLuLrHD2a6qgSR1eh3ju+7Z33nxMNCLerwYMl5GAuFl1cpN+y/iNyymYZi+lUTi1AkLA4/p2y7HwGAiOrwLIsdD4kSsdOCBX9AyulOPaeEvWfBUK5DT2dRD9eiCL/HTlBW+Q926U403FrbNQPSmZCPaiPcXYPJfjmiR1hd2ac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415911; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gA+pwh7nEEbohLHaQ73B+nUfWUkuIF1GGYQVjzNVnqg=; b=KCAgy+dpgmCx/nsvMkqWxB9QLt4vcVIHuJnZmOcBId1okmVlzfYqT+s93I7wpdUOJniKaY/ivxih98bEtpsfGLis5hcOm52zi+IQiXTOKpWCF2HJ8Sr9xIU8LL1lt1FaJSaoD4GnEInLqMfqrrrDiCfhwTdZGZpEIVJnrQnt7uo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578415911202427.43073827563774; Tue, 7 Jan 2020 08:51:51 -0800 (PST) Received: from localhost ([::1]:53030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ios57-0004ao-2q for importer@patchew.org; Tue, 07 Jan 2020 11:51:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47096) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorlX-0008MK-9D for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorlV-0005gj-6j for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:35 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:58659 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorka-0005C8-9f for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:33 -0500 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-VLP3mnYGPwqoLNG0jNjYQw-1; Tue, 07 Jan 2020 11:30:34 -0500 Received: by mail-qv1-f72.google.com with SMTP id e14so250269qvr.6 for ; Tue, 07 Jan 2020 08:30:34 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id v67sm38192qkh.46.2020.01.07.08.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:30:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414635; 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=gA+pwh7nEEbohLHaQ73B+nUfWUkuIF1GGYQVjzNVnqg=; b=OEeyxMuL/9XPqmf4G6owVHg/Hc1p2CBAYU2jfiIsH4X4zIuOTqrwVzVyFLpo7escDPUIlS 7+e2C7VleJLSE/5ozAjuFU0pHcxfPhjglTlFUxlJr5ia5sZZ/+FEp8PbvjnDhynSczZnSF sc2eKz36C0TNkYZ5yqrr7tg8DhcH0ZY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bjxdhZe8lLxQ+Az28/cWVrxvfjQRU8bK06t3mInr1NE=; b=pd6tSbhLuI/z7jiQJiy5Oa8Bwq+l6CHpFTtaiOap6s/sxWub7H0ZekEiGXmiNlGy2A wZS4IJyLmyX3pmMYre2PZCUmJkbn8xxzGRJUOaihgmReD5k/d8IVAD1v+pjVRxP20WdE NrJzORq5ROZS66H2EXF4fdOBVw7+xniQzZ6PAZfU3UaYWTSGfBVsdB3tlnLUikYhlWtL FtMf0QljbKTaBNEHMxuJ/+x/VG8yq79q0U9j7xKW1a3A8mr7ewrDIrrHCbcBmy+gs6L1 Ruyln/HSVvvnifzLMqXHFf9FMOgX8EISUQ5lTULmku2GNhtFhUkFJ22ZbtYqTblbiSaL o3Zw== X-Gm-Message-State: APjAAAXPAfH7j8rYRr6/ur/4K8996LVZcuZ9xUnsHckJKvu2JHYwnHXo keRgjM84YrW2W2Ypx033MTqOQEuKGHr7fiuDxA/nL31YkMZCGf0adYlFSQXWAsSVDTR7UkeWwWB JFImtK8wVv7D+NpI= X-Received: by 2002:ae9:e407:: with SMTP id q7mr140698qkc.160.1578414633690; Tue, 07 Jan 2020 08:30:33 -0800 (PST) X-Google-Smtp-Source: APXvYqy6KYFEh4DuPDYG8Rzf9Rsa7mdwwR7Bky86OTgoWzsWn6WUmFVLkhcUPF9UsqSua003fWuM3Q== X-Received: by 2002:ae9:e407:: with SMTP id q7mr140650qkc.160.1578414633220; Tue, 07 Jan 2020 08:30:33 -0800 (PST) Date: Tue, 7 Jan 2020 11:30:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 13/32] numa: Extend CLI to provide memory side cache information Message-ID: <20200107162850.411448-14-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: VLP3mnYGPwqoLNG0jNjYQw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Liu Jingqi , Tao Xu , Markus Armbruster , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liu Jingqi Add -numa hmat-cache option to provide Memory Side Cache Information. These memory attributes help to build Memory Side Cache Information Structure(s) in ACPI Heterogeneous Memory Attribute Table (HMAT). Before using hmat-cache option, enable HMAT with -machine hmat=3Don. Acked-by: Markus Armbruster Signed-off-by: Liu Jingqi Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-4-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- qapi/machine.json | 81 +++++++++++++++++++++++++++++++++++++++++-- include/sysemu/numa.h | 5 +++ hw/core/numa.c | 80 ++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 17 +++++++-- 4 files changed, 179 insertions(+), 4 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index cf8faf5a2a..b3d30bc816 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -428,10 +428,12 @@ # # @hmat-lb: memory latency and bandwidth information (Since: 5.0) # +# @hmat-cache: memory side cache information (Since: 5.0) +# # Since: 2.1 ## { 'enum': 'NumaOptionsType', - 'data': [ 'node', 'dist', 'cpu', 'hmat-lb' ] } + 'data': [ 'node', 'dist', 'cpu', 'hmat-lb', 'hmat-cache' ] } =20 ## # @NumaOptions: @@ -447,7 +449,8 @@ 'node': 'NumaNodeOptions', 'dist': 'NumaDistOptions', 'cpu': 'NumaCpuOptions', - 'hmat-lb': 'NumaHmatLBOptions' }} + 'hmat-lb': 'NumaHmatLBOptions', + 'hmat-cache': 'NumaHmatCacheOptions' }} =20 ## # @NumaNodeOptions: @@ -646,6 +649,80 @@ '*latency': 'uint64', '*bandwidth': 'size' }} =20 +## +# @HmatCacheAssociativity: +# +# Cache associativity in the Memory Side Cache Information Structure +# of HMAT +# +# For more information of @HmatCacheAssociativity, see chapter +# 5.2.27.5: Table 5-147 of ACPI 6.3 spec. +# +# @none: None (no memory side cache in this proximity domain, +# or cache associativity unknown) +# +# @direct: Direct Mapped +# +# @complex: Complex Cache Indexing (implementation specific) +# +# Since: 5.0 +## +{ 'enum': 'HmatCacheAssociativity', + 'data': [ 'none', 'direct', 'complex' ] } + +## +# @HmatCacheWritePolicy: +# +# Cache write policy in the Memory Side Cache Information Structure +# of HMAT +# +# For more information of @HmatCacheWritePolicy, see chapter +# 5.2.27.5: Table 5-147: Field "Cache Attributes" of ACPI 6.3 spec. +# +# @none: None (no memory side cache in this proximity domain, +# or cache write policy unknown) +# +# @write-back: Write Back (WB) +# +# @write-through: Write Through (WT) +# +# Since: 5.0 +## +{ 'enum': 'HmatCacheWritePolicy', + 'data': [ 'none', 'write-back', 'write-through' ] } + +## +# @NumaHmatCacheOptions: +# +# Set the memory side cache information for a given memory domain. +# +# For more information of @NumaHmatCacheOptions, see chapter +# 5.2.27.5: Table 5-147: Field "Cache Attributes" of ACPI 6.3 spec. +# +# @node-id: the memory proximity domain to which the memory belongs. +# +# @size: the size of memory side cache in bytes. +# +# @level: the cache level described in this structure. +# +# @associativity: the cache associativity, +# none/direct-mapped/complex(complex cache indexing). +# +# @policy: the write policy, none/write-back/write-through. +# +# @line: the cache Line size in bytes. +# +# Since: 5.0 +## +{ 'struct': 'NumaHmatCacheOptions', + 'data': { + 'node-id': 'uint32', + 'size': 'size', + 'level': 'uint8', + 'associativity': 'HmatCacheAssociativity', + 'policy': 'HmatCacheWritePolicy', + 'line': 'uint16' }} + ## # @HostMemPolicy: # diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 70f93c83d7..ba693cc80b 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -91,6 +91,9 @@ struct NumaState { =20 /* NUMA nodes HMAT Locality Latency and Bandwidth Information */ HMAT_LB_Info *hmat_lb[HMAT_LB_LEVELS][HMAT_LB_TYPES]; + + /* Memory Side Cache Information Structure */ + NumaHmatCacheOptions *hmat_cache[MAX_NODES][HMAT_LB_LEVELS]; }; typedef struct NumaState NumaState; =20 @@ -98,6 +101,8 @@ void set_numa_options(MachineState *ms, NumaOptions *obj= ect, Error **errp); void parse_numa_opts(MachineState *ms); void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node, Error **errp); +void parse_numa_hmat_cache(MachineState *ms, NumaHmatCacheOptions *node, + Error **errp); void numa_complete_configuration(MachineState *ms); void query_numa_node_mem(NumaNodeMem node_mem[], MachineState *ms); extern QemuOptsList qemu_numa_opts; diff --git a/hw/core/numa.c b/hw/core/numa.c index 34eb413f5d..747c9680b0 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -379,6 +379,73 @@ void parse_numa_hmat_lb(NumaState *numa_state, NumaHma= tLBOptions *node, g_array_append_val(hmat_lb->list, lb_data); } =20 +void parse_numa_hmat_cache(MachineState *ms, NumaHmatCacheOptions *node, + Error **errp) +{ + int nb_numa_nodes =3D ms->numa_state->num_nodes; + NodeInfo *numa_info =3D ms->numa_state->nodes; + NumaHmatCacheOptions *hmat_cache =3D NULL; + + if (node->node_id >=3D nb_numa_nodes) { + error_setg(errp, "Invalid node-id=3D%" PRIu32 ", it should be less= " + "than %d", node->node_id, nb_numa_nodes); + return; + } + + if (numa_info[node->node_id].lb_info_provided !=3D (BIT(0) | BIT(1))) { + error_setg(errp, "The latency and bandwidth information of " + "node-id=3D%" PRIu32 " should be provided before memory= side " + "cache attributes", node->node_id); + return; + } + + if (node->level < 1 || node->level >=3D HMAT_LB_LEVELS) { + error_setg(errp, "Invalid level=3D%" PRIu8 ", it should be larger = than 0 " + "and less than or equal to %d", node->level, + HMAT_LB_LEVELS - 1); + return; + } + + assert(node->associativity < HMAT_CACHE_ASSOCIATIVITY__MAX); + assert(node->policy < HMAT_CACHE_WRITE_POLICY__MAX); + if (ms->numa_state->hmat_cache[node->node_id][node->level]) { + error_setg(errp, "Duplicate configuration of the side cache for " + "node-id=3D%" PRIu32 " and level=3D%" PRIu8, + node->node_id, node->level); + return; + } + + if ((node->level > 1) && + ms->numa_state->hmat_cache[node->node_id][node->level - 1] && + (node->size >=3D + ms->numa_state->hmat_cache[node->node_id][node->level - 1]->si= ze)) { + error_setg(errp, "Invalid size=3D%" PRIu64 ", the size of level=3D= %" PRIu8 + " should be less than the size(%" PRIu64 ") of " + "level=3D%u", node->size, node->level, + ms->numa_state->hmat_cache[node->node_id] + [node->level - 1]->size, + node->level - 1); + return; + } + + if ((node->level < HMAT_LB_LEVELS - 1) && + ms->numa_state->hmat_cache[node->node_id][node->level + 1] && + (node->size <=3D + ms->numa_state->hmat_cache[node->node_id][node->level + 1]->si= ze)) { + error_setg(errp, "Invalid size=3D%" PRIu64 ", the size of level=3D= %" PRIu8 + " should be larger than the size(%" PRIu64 ") of " + "level=3D%u", node->size, node->level, + ms->numa_state->hmat_cache[node->node_id] + [node->level + 1]->size, + node->level + 1); + return; + } + + hmat_cache =3D g_malloc0(sizeof(*hmat_cache)); + memcpy(hmat_cache, node, sizeof(*hmat_cache)); + ms->numa_state->hmat_cache[node->node_id][node->level] =3D hmat_cache; +} + void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp) { Error *err =3D NULL; @@ -430,6 +497,19 @@ void set_numa_options(MachineState *ms, NumaOptions *o= bject, Error **errp) goto end; } break; + case NUMA_OPTIONS_TYPE_HMAT_CACHE: + if (!ms->numa_state->hmat_enabled) { + error_setg(errp, "ACPI Heterogeneous Memory Attribute Table " + "(HMAT) is disabled, enable it with -machine hmat= =3Don " + "before using any of hmat specific options"); + return; + } + + parse_numa_hmat_cache(ms, &object->u.hmat_cache, &err); + if (err) { + goto end; + } + break; default: abort(); } diff --git a/qemu-options.hx b/qemu-options.hx index a0c0bbb7cf..d4b73ef60c 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -176,7 +176,8 @@ DEF("numa", HAS_ARG, QEMU_OPTION_numa, "-numa node[,memdev=3Did][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode][= ,initiator=3Dnode]\n" "-numa dist,src=3Dsource,dst=3Ddestination,val=3Ddistance\n" "-numa cpu,node-id=3Dnode[,socket-id=3Dx][,core-id=3Dy][,thread-id=3Dz= ]\n" - "-numa hmat-lb,initiator=3Dnode,target=3Dnode,hierarchy=3Dmemory|first= -level|second-level|third-level,data-type=3Daccess-latency|read-latency|wri= te-latency[,latency=3Dlat][,bandwidth=3Dbw]\n", + "-numa hmat-lb,initiator=3Dnode,target=3Dnode,hierarchy=3Dmemory|first= -level|second-level|third-level,data-type=3Daccess-latency|read-latency|wri= te-latency[,latency=3Dlat][,bandwidth=3Dbw]\n" + "-numa hmat-cache,node-id=3Dnode,size=3Dsize,level=3Dlevel[,associativ= ity=3Dnone|direct|complex][,policy=3Dnone|write-back|write-through][,line= =3Dsize]\n", QEMU_ARCH_ALL) STEXI @item -numa node[,mem=3D@var{size}][,cpus=3D@var{firstcpu}[-@var{lastcpu}]= ][,nodeid=3D@var{node}][,initiator=3D@var{initiator}] @@ -184,6 +185,7 @@ STEXI @itemx -numa dist,src=3D@var{source},dst=3D@var{destination},val=3D@var{di= stance} @itemx -numa cpu,node-id=3D@var{node}[,socket-id=3D@var{x}][,core-id=3D@va= r{y}][,thread-id=3D@var{z}] @itemx -numa hmat-lb,initiator=3D@var{node},target=3D@var{node},hierarchy= =3D@var{hierarchy},data-type=3D@var{tpye}[,latency=3D@var{lat}][,bandwidth= =3D@var{bw}] +@itemx -numa hmat-cache,node-id=3D@var{node},size=3D@var{size},level=3D@va= r{level}[,associativity=3D@var{str}][,policy=3D@var{str}][,line=3D@var{size= }] @findex -numa Define a NUMA node and assign RAM and VCPUs to it. Set the NUMA distance from a source node to a destination node. @@ -287,11 +289,20 @@ NUM byte per second (or MB/s, GB/s or TB/s depending = on used suffix). Note that if latency or bandwidth value is 0, means the corresponding late= ncy or bandwidth information is not provided. =20 +In @samp{hmat-cache} option, @var{node-id} is the NUMA-id of the memory be= longs. +@var{size} is the size of memory side cache in bytes. @var{level} is the c= ache +level described in this structure, note that the cache level 0 should not = be used +with @samp{hmat-cache} option. @var{associativity} is the cache associativ= ity, +the possible value is 'none/direct(direct-mapped)/complex(complex cache in= dexing)'. +@var{policy} is the write policy. @var{line} is the cache Line size in byt= es. + For example, the following options describe 2 NUMA nodes. Node 0 has 2 cpu= s and a ram, node 1 has only a ram. The processors in node 0 access memory in no= de 0 with access-latency 5 nanoseconds, access-bandwidth is 200 MB/s; The processors in NUMA node 0 access memory in NUMA node 1 with access-lat= ency 10 nanoseconds, access-bandwidth is 100 MB/s. +And for memory side cache information, NUMA node 0 and 1 both have 1 level= memory +cache, size is 10KB, policy is write-back, the cache Line size is 8 bytes: @example -machine hmat=3Don \ -m 2G \ @@ -305,7 +316,9 @@ nanoseconds, access-bandwidth is 100 MB/s. -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmemory,data-type=3Dacce= ss-latency,latency=3D5 \ -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmemory,data-type=3Dacce= ss-bandwidth,bandwidth=3D200M \ -numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmemory,data-type=3Dacce= ss-latency,latency=3D10 \ --numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmemory,data-type=3Dacce= ss-bandwidth,bandwidth=3D100M +-numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmemory,data-type=3Dacce= ss-bandwidth,bandwidth=3D100M \ +-numa hmat-cache,node-id=3D0,size=3D10K,level=3D1,associativity=3Ddirect,p= olicy=3Dwrite-back,line=3D8 \ +-numa hmat-cache,node-id=3D1,size=3D10K,level=3D1,associativity=3Ddirect,p= olicy=3Dwrite-back,line=3D8 @end example =20 ETEXI --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415191; cv=none; d=zohomail.com; s=zohoarc; b=RRMADcBEyPS1bbZPKlKPf5yooHor+LtVkZyIBmEHMSBsKOSXEDJ5DAXxhfZAG+ei8TTU29aCK43ICmvF6jcnWZFdJY9t93BwZJLipWYwP9LJpw0ORk8X1INsPI/GRJ3wZI6fFHnOackq5ReqLh/BJnphgR8+2CqK0z7FYGlhgPY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415191; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FcK7WigJMJDie4qherce/SQbHzZxCxCRnKQYLmv9Zf4=; b=L/L1cmJLD1RMFqryYKqdTg0nWIoTUdXwlOC34J/B/v8HmlVXam0y2iX075pHPu4VvhLoDhDKB0I+SnGXkP/ZswYyLrTPgZNZZwK3yedjyIonWRBF9SgrtmSAYRi+uMMRBXtXcDrTzYSYBHupTs5abi30UIUuQCT1elcnQKgeAU8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578415191197761.3788288192461; Tue, 7 Jan 2020 08:39:51 -0800 (PST) Received: from localhost ([::1]:52814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iortV-0000tg-PN for importer@patchew.org; Tue, 07 Jan 2020 11:39:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46734) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorlA-0007zp-L3 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorl8-0005Sd-HH for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:12 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:20660 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorkg-0005Ej-6p for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:10 -0500 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-267-ondbbsQZPCS0n5WSjZVc6g-1; Tue, 07 Jan 2020 11:30:39 -0500 Received: by mail-qt1-f197.google.com with SMTP id m30so144233qtb.2 for ; Tue, 07 Jan 2020 08:30:39 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id n4sm98629qti.55.2020.01.07.08.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:30:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414641; 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=FcK7WigJMJDie4qherce/SQbHzZxCxCRnKQYLmv9Zf4=; b=i16E63jf7USDea/mhN4Ecfgmb6tkEtE8jUOY3EWLdY0v6bbdLk8x7g7Ldbw+Ly3hKchn4w qqFNyGYiMCsg6IZiAOg8uI7rcTTmSU5vwVHuaT2u8HBEij33z7czQpQRyyW0h3TId30ps9 A+FuZ8eFlEzejc+x2IxJDtskn0yaK8c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=OKLjdvfCJDfY6fGqKWe65+lk7+R2Zab8RzeVnW/XRtE=; b=HuxmiYEDmaftqVS8TgUvdmAX3Ko9cKKXL5qq+Z/n3Dl7cklhMUObmTidyjdwswMQ9T rjapbRgrt3WMj7OiqYORaswNHkP4HbF4pd1S9hG2XscSaN11LHS0XV6216gm1F/YbztI Xn2/ZqkSdr/JRLRy8sMZofb5Hyir53EHbN7+6yHWH6IyAyCm7f408oAG3ySWdsBCIgHp pp6B8eqAxGSZdnzqv1v0WIKV8q7BwZ6sFouuOKCUxoZbqaB2PuyL92vc613NvQWnFPfx 4USZZudPtgSFHN6yK80iosEG1Hyz11l+Pksjd52bOUo61pzPz72egLVw43OCec4C6PIG My6w== X-Gm-Message-State: APjAAAXyO5nqdlLMuu0O6TwQipijdwPRzTNA6rEWH+M0uQFZvOO06Boy 4R/a7LxzIK24BH6K9GRKKiCEPCLEPckZQfL0Rf9NdfYl16nFI7OLHH0i8TmJDXAjs0jxtlXsuI+ lwuYsLYp3cV+9yj4= X-Received: by 2002:ac8:43c1:: with SMTP id w1mr67899051qtn.156.1578414638788; Tue, 07 Jan 2020 08:30:38 -0800 (PST) X-Google-Smtp-Source: APXvYqz9GFa3d8UuqmbFRYwgQ2QkMrhQxU7Y9SBz60spN42uQcDAdYbq45MROqzx37IWSa+gYb/ZHQ== X-Received: by 2002:ac8:43c1:: with SMTP id w1mr67899017qtn.156.1578414638413; Tue, 07 Jan 2020 08:30:38 -0800 (PST) Date: Tue, 7 Jan 2020 11:30:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 14/32] hmat acpi: Build Memory Proximity Domain Attributes Structure(s) Message-ID: <20200107162850.411448-15-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: ondbbsQZPCS0n5WSjZVc6g-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Liu Jingqi , Tao Xu , Markus Armbruster , Daniel Black , Paolo Bonzini , Jonathan Cameron , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liu Jingqi HMAT is defined in ACPI 6.3: 5.2.27 Heterogeneous Memory Attribute Table (HMAT). The specification references below link: http://www.uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf It describes the memory attributes, such as memory side cache attributes and bandwidth and latency details, related to the Memory Proximity Domain. The software is expected to use this information as hint for optimization. This structure describes Memory Proximity Domain Attributes by memory subsystem and its associativity with processor proximity domain as well as hint for memory usage. In the linux kernel, the codes in drivers/acpi/hmat/hmat.c parse and report the platform's HMAT tables. Acked-by: Markus Armbruster Reviewed-by: Igor Mammedov Reviewed-by: Daniel Black Reviewed-by: Jonathan Cameron Signed-off-by: Liu Jingqi Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-5-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/hmat.h | 42 ++++++++++++++++++ hw/acpi/hmat.c | 99 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 5 +++ hw/acpi/Kconfig | 7 ++- hw/acpi/Makefile.objs | 1 + 5 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 hw/acpi/hmat.h create mode 100644 hw/acpi/hmat.c diff --git a/hw/acpi/hmat.h b/hw/acpi/hmat.h new file mode 100644 index 0000000000..437dbc6872 --- /dev/null +++ b/hw/acpi/hmat.h @@ -0,0 +1,42 @@ +/* + * HMAT ACPI Implementation Header + * + * Copyright(C) 2019 Intel Corporation. + * + * Author: + * Liu jingqi + * Tao Xu + * + * HMAT is defined in ACPI 6.3: 5.2.27 Heterogeneous Memory Attribute Table + * (HMAT) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#ifndef HMAT_H +#define HMAT_H + +#include "hw/acpi/aml-build.h" + +/* + * ACPI 6.3: 5.2.27.3 Memory Proximity Domain Attributes Structure, + * Table 5-145, Field "flag", Bit [0]: set to 1 to indicate that data in + * the Proximity Domain for the Attached Initiator field is valid. + * Other bits reserved. + */ +#define HMAT_PROXIMITY_INITIATOR_VALID 0x1 + +void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_st= ate); + +#endif diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c new file mode 100644 index 0000000000..9ff79308a4 --- /dev/null +++ b/hw/acpi/hmat.c @@ -0,0 +1,99 @@ +/* + * HMAT ACPI Implementation + * + * Copyright(C) 2019 Intel Corporation. + * + * Author: + * Liu jingqi + * Tao Xu + * + * HMAT is defined in ACPI 6.3: 5.2.27 Heterogeneous Memory Attribute Table + * (HMAT) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#include "qemu/osdep.h" +#include "sysemu/numa.h" +#include "hw/acpi/hmat.h" + +/* + * ACPI 6.3: + * 5.2.27.3 Memory Proximity Domain Attributes Structure: Table 5-145 + */ +static void build_hmat_mpda(GArray *table_data, uint16_t flags, + uint32_t initiator, uint32_t mem_node) +{ + + /* Memory Proximity Domain Attributes Structure */ + /* Type */ + build_append_int_noprefix(table_data, 0, 2); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 2); + /* Length */ + build_append_int_noprefix(table_data, 40, 4); + /* Flags */ + build_append_int_noprefix(table_data, flags, 2); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 2); + /* Proximity Domain for the Attached Initiator */ + build_append_int_noprefix(table_data, initiator, 4); + /* Proximity Domain for the Memory */ + build_append_int_noprefix(table_data, mem_node, 4); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); + /* + * Reserved: + * Previously defined as the Start Address of the System Physical + * Address Range. Deprecated since ACPI Spec 6.3. + */ + build_append_int_noprefix(table_data, 0, 8); + /* + * Reserved: + * Previously defined as the Range Length of the region in bytes. + * Deprecated since ACPI Spec 6.3. + */ + build_append_int_noprefix(table_data, 0, 8); +} + +/* Build HMAT sub table structures */ +static void hmat_build_table_structs(GArray *table_data, NumaState *numa_s= tate) +{ + uint16_t flags; + int i; + + for (i =3D 0; i < numa_state->num_nodes; i++) { + flags =3D 0; + + if (numa_state->nodes[i].initiator < MAX_NODES) { + flags |=3D HMAT_PROXIMITY_INITIATOR_VALID; + } + + build_hmat_mpda(table_data, flags, numa_state->nodes[i].initiator,= i); + } +} + +void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_st= ate) +{ + int hmat_start =3D table_data->len; + + /* reserve space for HMAT header */ + acpi_data_push(table_data, 40); + + hmat_build_table_structs(table_data, numa_state); + + build_header(linker, table_data, + (void *)(table_data->data + hmat_start), + "HMAT", table_data->len - hmat_start, 2, NULL, NULL); +} diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 7b8da62d41..e25df838f0 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -68,6 +68,7 @@ #include "hw/i386/intel_iommu.h" =20 #include "hw/acpi/ipmi.h" +#include "hw/acpi/hmat.h" =20 /* These are used to size the ACPI tables for -M pc-i440fx-1.7 and * -M pc-i440fx-2.0. Even if the actual amount of AML generated grows @@ -2835,6 +2836,10 @@ void acpi_build(AcpiBuildTables *tables, MachineStat= e *machine) acpi_add_table(table_offsets, tables_blob); build_slit(tables_blob, tables->linker, machine); } + if (machine->numa_state->hmat_enabled) { + acpi_add_table(table_offsets, tables_blob); + build_hmat(tables_blob, tables->linker, machine->numa_state); + } } if (acpi_get_mcfg(&mcfg)) { acpi_add_table(table_offsets, tables_blob); diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index 12e3f1e86e..54209c6f2f 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -7,6 +7,7 @@ config ACPI_X86 select ACPI_NVDIMM select ACPI_CPU_HOTPLUG select ACPI_MEMORY_HOTPLUG + select ACPI_HMAT =20 config ACPI_X86_ICH bool @@ -23,6 +24,10 @@ config ACPI_NVDIMM bool depends on ACPI =20 +config ACPI_HMAT + bool + depends on ACPI + config ACPI_PCI bool depends on ACPI && PCI @@ -33,5 +38,3 @@ config ACPI_VMGENID depends on PC =20 config ACPI_HW_REDUCED - bool - depends on ACPI diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs index 99253057e1..777da07f4d 100644 --- a/hw/acpi/Makefile.objs +++ b/hw/acpi/Makefile.objs @@ -7,6 +7,7 @@ common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) +=3D cpu.o common-obj-$(CONFIG_ACPI_NVDIMM) +=3D nvdimm.o common-obj-$(CONFIG_ACPI_VMGENID) +=3D vmgenid.o common-obj-$(CONFIG_ACPI_HW_REDUCED) +=3D generic_event_device.o +common-obj-$(CONFIG_ACPI_HMAT) +=3D hmat.o common-obj-$(call lnot,$(CONFIG_ACPI_X86)) +=3D acpi-stub.o common-obj-$(call lnot,$(CONFIG_PC)) +=3D acpi-x86-stub.o =20 --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415382; cv=none; d=zohomail.com; s=zohoarc; b=eAFXZaqKoMPuixj1EKQ+3NmXVuGCSZvJn3oSFvIylw94daOw9dCs4WO5CIzhCZuyCGzSe81S6KAE8r7Yxyv5esbYNj4JHY1SICp/bZDm4u/5KxcEYmWziHHtZ005v02Nk9Q+ma2FKQ/dsHwf1n5hn2/x45x/Oinw5HvXUOV6mu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415382; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bLV8rQCbLBZmY0FVDGOQq3AQD9eSmdJYBYmhF7NfsUU=; b=Xcr5ToEXI9+iDfm6ELAJglJ8Ckk0nfJTyFviSNZutsmR+ZFmsk3sgMxS31v7mNKc5BuVRW18XFzRdRHWSyMpZqr0DeOs++OrW/+2RDZc70AGvgExgtN5eewvk29IyBB6qdMh/OiDJImDQyJ29Xey32OjtukjxZNT1uDDihTF0k0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578415382318679.1376599475075; Tue, 7 Jan 2020 08:43:02 -0800 (PST) Received: from localhost ([::1]:52856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorwa-0006Sb-MR for importer@patchew.org; Tue, 07 Jan 2020 11:43:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46828) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorlF-00084v-DI for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorlE-0005Wi-2N for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:17 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47801 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorkl-0005Gu-PA for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:16 -0500 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-115--Yt23CJmOf2UDMdu_g5Jig-1; Tue, 07 Jan 2020 11:30:44 -0500 Received: by mail-qv1-f70.google.com with SMTP id n11so232368qvp.15 for ; Tue, 07 Jan 2020 08:30:44 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id c3sm49024qkk.8.2020.01.07.08.30.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:30:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414646; 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=bLV8rQCbLBZmY0FVDGOQq3AQD9eSmdJYBYmhF7NfsUU=; b=HjewaGEfJzQo92hvUs/AR4p9ZYeRe2N8kuzt2bXvCZywiWbSQUzsrtxCem3/sqaht/kMQ4 39HLUWINzJ+zZrAa/ZDJsjYgF0iAGmm3oHTxcYp0f8bWPfL6u38ZpTLB6z9NA8D10oXnGb 58zjXr1C9BBB53QaSqSp1pxxVrb0JcU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3qP/C/NttECQ066FqPp6xPe1UgZkrZPuw+r54Uke8BM=; b=GyU9hvazJM+KSiZZoqsZ8JiFDf2QqT915PilNXrGrobV5zoIhEDoozSU/oDNYAIm3u cMKGSiaH+EQt3oZqopWXSeqzxlku1y9GYrbctEvAc8TF/CrNjSSbfQvAgf6Aw3ZaaXo2 KLxbqoNJ2wIZbehpnS5qoHhQs4Q5f/Foo4ZlZ1gcDsAL7yqcD6nwXmoa4Y+fHXo0qFKW x+pt7nQ+Mr9p3wjNCIRtHGRnNTnA1bYuISkxLHjo2qJoduqXOtvGpzROAIPsoM1tfTDo rinMKjdycB7Er3uLMjjarx20RpNOxV/3rJpSBxntAv2cenWzWMgMa2lVpHc4tV8G5Wn/ zv+w== X-Gm-Message-State: APjAAAWxEwRKBOoTG5nohPt1MW1HPhnTJVz28dypOEEVqIBEys+XS3SS F9xI6+Aa4v9czL69ujlt7R3m1dVOQxJtSSZ36kRZn5OUxIrL/qicsMw0bOipbqG1Bo82q/oHB4x ePMPpBA2EUqg9mig= X-Received: by 2002:a37:e10f:: with SMTP id c15mr97758qkm.331.1578414643729; Tue, 07 Jan 2020 08:30:43 -0800 (PST) X-Google-Smtp-Source: APXvYqyXnH72yEnhryaaxGH1hUxkVE5gAuNrPlnSrf3PyNeUX2NBiWnnmzaIPdZnt4F74OumB8Y5IQ== X-Received: by 2002:a37:e10f:: with SMTP id c15mr97735qkm.331.1578414643427; Tue, 07 Jan 2020 08:30:43 -0800 (PST) Date: Tue, 7 Jan 2020 11:30:38 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 15/32] hmat acpi: Build System Locality Latency and Bandwidth Information Structure(s) Message-ID: <20200107162850.411448-16-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: -Yt23CJmOf2UDMdu_g5Jig-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov , Tao Xu , Markus Armbruster , Liu Jingqi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liu Jingqi This structure describes the memory access latency and bandwidth information from various memory access initiator proximity domains. The latency and bandwidth numbers represented in this structure correspond to rated latency and bandwidth for the platform. The software could use this information as hint for optimization. Acked-by: Markus Armbruster Reviewed-by: Igor Mammedov Signed-off-by: Liu Jingqi Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-6-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/hmat.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c index 9ff79308a4..4635d45dee 100644 --- a/hw/acpi/hmat.c +++ b/hw/acpi/hmat.c @@ -25,6 +25,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/units.h" #include "sysemu/numa.h" #include "hw/acpi/hmat.h" =20 @@ -67,11 +68,89 @@ static void build_hmat_mpda(GArray *table_data, uint16_= t flags, build_append_int_noprefix(table_data, 0, 8); } =20 +/* + * ACPI 6.3: 5.2.27.4 System Locality Latency and Bandwidth Information + * Structure: Table 5-146 + */ +static void build_hmat_lb(GArray *table_data, HMAT_LB_Info *hmat_lb, + uint32_t num_initiator, uint32_t num_target, + uint32_t *initiator_list) +{ + int i, index; + HMAT_LB_Data *lb_data; + uint16_t *entry_list; + uint32_t base; + /* Length in bytes for entire structure */ + uint32_t lb_length + =3D 32 /* Table length upto and including Entry Base Unit */ + + 4 * num_initiator /* Initiator Proximity Domain List */ + + 4 * num_target /* Target Proximity Domain List */ + + 2 * num_initiator * num_target; /* Latency or Bandwidth Entries = */ + + /* Type */ + build_append_int_noprefix(table_data, 1, 2); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 2); + /* Length */ + build_append_int_noprefix(table_data, lb_length, 4); + /* Flags: Bits [3:0] Memory Hierarchy, Bits[7:4] Reserved */ + assert(!(hmat_lb->hierarchy >> 4)); + build_append_int_noprefix(table_data, hmat_lb->hierarchy, 1); + /* Data Type */ + build_append_int_noprefix(table_data, hmat_lb->data_type, 1); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 2); + /* Number of Initiator Proximity Domains (s) */ + build_append_int_noprefix(table_data, num_initiator, 4); + /* Number of Target Proximity Domains (t) */ + build_append_int_noprefix(table_data, num_target, 4); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); + + /* Entry Base Unit */ + if (hmat_lb->data_type <=3D HMAT_LB_DATA_WRITE_LATENCY) { + /* Convert latency base from nanoseconds to picosecond */ + base =3D hmat_lb->base * 1000; + } else { + /* Convert bandwidth base from Byte to Megabyte */ + base =3D hmat_lb->base / MiB; + } + build_append_int_noprefix(table_data, base, 8); + + /* Initiator Proximity Domain List */ + for (i =3D 0; i < num_initiator; i++) { + build_append_int_noprefix(table_data, initiator_list[i], 4); + } + + /* Target Proximity Domain List */ + for (i =3D 0; i < num_target; i++) { + build_append_int_noprefix(table_data, i, 4); + } + + /* Latency or Bandwidth Entries */ + entry_list =3D g_malloc0(num_initiator * num_target * sizeof(uint16_t)= ); + for (i =3D 0; i < hmat_lb->list->len; i++) { + lb_data =3D &g_array_index(hmat_lb->list, HMAT_LB_Data, i); + index =3D lb_data->initiator * num_target + lb_data->target; + + entry_list[index] =3D (uint16_t)(lb_data->data / hmat_lb->base); + } + + for (i =3D 0; i < num_initiator * num_target; i++) { + build_append_int_noprefix(table_data, entry_list[i], 2); + } + + g_free(entry_list); +} + /* Build HMAT sub table structures */ static void hmat_build_table_structs(GArray *table_data, NumaState *numa_s= tate) { uint16_t flags; - int i; + uint32_t num_initiator =3D 0; + uint32_t initiator_list[MAX_NODES]; + int i, hierarchy, type; + HMAT_LB_Info *hmat_lb; =20 for (i =3D 0; i < numa_state->num_nodes; i++) { flags =3D 0; @@ -82,6 +161,29 @@ static void hmat_build_table_structs(GArray *table_data= , NumaState *numa_state) =20 build_hmat_mpda(table_data, flags, numa_state->nodes[i].initiator,= i); } + + for (i =3D 0; i < numa_state->num_nodes; i++) { + if (numa_state->nodes[i].has_cpu) { + initiator_list[num_initiator++] =3D i; + } + } + + /* + * ACPI 6.3: 5.2.27.4 System Locality Latency and Bandwidth Information + * Structure: Table 5-146 + */ + for (hierarchy =3D HMAT_LB_MEM_MEMORY; + hierarchy <=3D HMAT_LB_MEM_CACHE_3RD_LEVEL; hierarchy++) { + for (type =3D HMAT_LB_DATA_ACCESS_LATENCY; + type <=3D HMAT_LB_DATA_WRITE_BANDWIDTH; type++) { + hmat_lb =3D numa_state->hmat_lb[hierarchy][type]; + + if (hmat_lb && hmat_lb->list->len) { + build_hmat_lb(table_data, hmat_lb, num_initiator, + numa_state->num_nodes, initiator_list); + } + } + } } =20 void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_st= ate) --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415363; cv=none; d=zohomail.com; s=zohoarc; b=J31BNZG//qwVcVNjry71Db2I9KFBZj7sC58mZRF93wvlEqNbkOwOomHcVRlaAVJ7ftxETXBaieEkl+42y7OqJyZtqhaaZiDg+Ambm+Lt3siQdeEc+GWzVcaNj9L9fLgPP2tC2uL5Y/MNPMukf9jwE1rguVsaIzD6j7BGEGTazLs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415363; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9TnHo7VvJZaLFzHYDnog4vzTE/uU8KgG0+PD95HCZAE=; b=Fcsz33iVPhITmrYmXpywcBB5uBB+f/OH73KzR6OzlGPXoYzo0UHafYhVu8JP7W3UnqSer4/+IwxT8l201rol012Lr0EcnBrFwQWG97L2rZaNaALzHW9RjGUxPpki7SEyrbTaArftXDuEILfeTLzp0reHIpm8p/fgM8ubrc/Da4E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578415363626127.82219945014947; Tue, 7 Jan 2020 08:42:43 -0800 (PST) Received: from localhost ([::1]:52854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorwH-0005pP-SA for importer@patchew.org; Tue, 07 Jan 2020 11:42:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46587) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorkx-0007iM-3W for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorkv-0005Kz-Np for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:58 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:51940 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorko-0005Id-Ow for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:57 -0500 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-291-aqa2ZuW6OrejtwSoq3UWzw-1; Tue, 07 Jan 2020 11:30:49 -0500 Received: by mail-qv1-f69.google.com with SMTP id e14so250740qvr.6 for ; Tue, 07 Jan 2020 08:30:49 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id 201sm45486qkf.10.2020.01.07.08.30.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:30:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414650; 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=9TnHo7VvJZaLFzHYDnog4vzTE/uU8KgG0+PD95HCZAE=; b=LZdxdJAILFFCpakFfq20FtISWKdSH2mu5FVzwY+MAv8ULSZ2CQ2L3kPW6mNPACXdG3ktKn GGVA5Izml4L90Xq3h+GylM/ljUkrTFYZJ6yjWk64+H7wFY/lJYggFjJPVZyYWq1bac35d3 /0TZioq0uSzkQLzA087fJuOwMIK/kp8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=yLxJY7rN1k5OoWYN8rEjFXzk7p6lyE6U8ZaTa83HTg0=; b=Bme3pdXUrUGezCl3/zDyUkFkYe6bvmugosJlympXZOWypOX75D3ATyCQ27i55XBSBc sdKlwAcOZrWAfJN0CBHf89onubHj21EnGXAd0QMO4ecPEX9KQoGCfgzyMtW4vpxDe+kS 50F88Wa5Rd+pV0thuTa2gb96PtAOoU+qhT05SqqarXXdKBF0L49T83hO6jeTzVlztqKY aq/ig7DzX0tpJqeD5b5Qdys1XjYO6v8cdll4WiQh4sWq42uPz7yuuJ1ntdfvVnm9KfOO xlBTkDlXuS0YfpCSyONEe3xJzH/F7JuuUcphbxwzo9I68oklpnZ3Vs+PL9d8g+KLeWWS XmDA== X-Gm-Message-State: APjAAAXKar7Hm5BbrtQxGmzXwZWQ9Ghq0MMAc3Ou5MKwwvnyBwqPlnJ+ WP9nUOTWqZ1BonWD58/U1O7Jv0oKzTfzioqNAMFZT+4xIr6rM0iGPx7cTN7H5sfKjlXJeiTi0kR dCGJWHoiQoEu1r30= X-Received: by 2002:ac8:43c1:: with SMTP id w1mr67899799qtn.156.1578414648319; Tue, 07 Jan 2020 08:30:48 -0800 (PST) X-Google-Smtp-Source: APXvYqyWDX80KStv/ELPCNeed2iz8G5Ka9R7iIG/zuj/zoBKNQA7tKZv73aY8mvN8QrQclSqtCPZdg== X-Received: by 2002:ac8:43c1:: with SMTP id w1mr67899784qtn.156.1578414648096; Tue, 07 Jan 2020 08:30:48 -0800 (PST) Date: Tue, 7 Jan 2020 11:30:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 16/32] hmat acpi: Build Memory Side Cache Information Structure(s) Message-ID: <20200107162850.411448-17-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: aqa2ZuW6OrejtwSoq3UWzw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Liu Jingqi , Tao Xu , Markus Armbruster , Daniel Black , Jonathan Cameron , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liu Jingqi This structure describes memory side cache information for memory proximity domains if the memory side cache is present and the physical device forms the memory side cache. The software could use this information to effectively place the data in memory to maximize the performance of the system memory that use the memory side cache. Acked-by: Markus Armbruster Reviewed-by: Igor Mammedov Reviewed-by: Daniel Black Reviewed-by: Jonathan Cameron Signed-off-by: Liu Jingqi Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-7-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/hmat.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c index 4635d45dee..7c24bb5371 100644 --- a/hw/acpi/hmat.c +++ b/hw/acpi/hmat.c @@ -143,14 +143,62 @@ static void build_hmat_lb(GArray *table_data, HMAT_LB= _Info *hmat_lb, g_free(entry_list); } =20 +/* ACPI 6.3: 5.2.27.5 Memory Side Cache Information Structure: Table 5-147= */ +static void build_hmat_cache(GArray *table_data, uint8_t total_levels, + NumaHmatCacheOptions *hmat_cache) +{ + /* + * Cache Attributes: Bits [3:0] =E2=80=93 Total Cache Levels + * for this Memory Proximity Domain + */ + uint32_t cache_attr =3D total_levels; + + /* Bits [7:4] : Cache Level described in this structure */ + cache_attr |=3D (uint32_t) hmat_cache->level << 4; + + /* Bits [11:8] - Cache Associativity */ + cache_attr |=3D (uint32_t) hmat_cache->associativity << 8; + + /* Bits [15:12] - Write Policy */ + cache_attr |=3D (uint32_t) hmat_cache->policy << 12; + + /* Bits [31:16] - Cache Line size in bytes */ + cache_attr |=3D (uint32_t) hmat_cache->line << 16; + + /* Type */ + build_append_int_noprefix(table_data, 2, 2); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 2); + /* Length */ + build_append_int_noprefix(table_data, 32, 4); + /* Proximity Domain for the Memory */ + build_append_int_noprefix(table_data, hmat_cache->node_id, 4); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); + /* Memory Side Cache Size */ + build_append_int_noprefix(table_data, hmat_cache->size, 8); + /* Cache Attributes */ + build_append_int_noprefix(table_data, cache_attr, 4); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 2); + /* + * Number of SMBIOS handles (n) + * Linux kernel uses Memory Side Cache Information Structure + * without SMBIOS entries for now, so set Number of SMBIOS handles + * as 0. + */ + build_append_int_noprefix(table_data, 0, 2); +} + /* Build HMAT sub table structures */ static void hmat_build_table_structs(GArray *table_data, NumaState *numa_s= tate) { uint16_t flags; uint32_t num_initiator =3D 0; uint32_t initiator_list[MAX_NODES]; - int i, hierarchy, type; + int i, hierarchy, type, cache_level, total_levels; HMAT_LB_Info *hmat_lb; + NumaHmatCacheOptions *hmat_cache; =20 for (i =3D 0; i < numa_state->num_nodes; i++) { flags =3D 0; @@ -184,6 +232,25 @@ static void hmat_build_table_structs(GArray *table_dat= a, NumaState *numa_state) } } } + + /* + * ACPI 6.3: 5.2.27.5 Memory Side Cache Information Structure: + * Table 5-147 + */ + for (i =3D 0; i < numa_state->num_nodes; i++) { + total_levels =3D 0; + for (cache_level =3D 1; cache_level < HMAT_LB_LEVELS; cache_level+= +) { + if (numa_state->hmat_cache[i][cache_level]) { + total_levels++; + } + } + for (cache_level =3D 0; cache_level <=3D total_levels; cache_level= ++) { + hmat_cache =3D numa_state->hmat_cache[i][cache_level]; + if (hmat_cache) { + build_hmat_cache(table_data, total_levels, hmat_cache); + } + } + } } =20 void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_st= ate) --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415901; cv=none; d=zohomail.com; s=zohoarc; b=VcTo+voPGE9Z+ltOsvVJRX0UfamIOexwgnWYbYTeLETAxEUyyB+Xz6eIeCSPu4To4hHN0XGyEhLfsmt7j3AIhj0BN6/0gWMKA/LpGUldkL3DIBL+V2OcrMrt0eOnKrOp94qO6LNKiXhn4gSrt5BpLliXhit28CZUOmQj22bVfN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415901; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Cp6Js316PIXYZH4FnO2Nl29XN8Dewk3Zb8G0nu+p7nE=; b=Ss4dHyJTAcjvIxw7YafTnw5TUZteUhbpt80EIeRFmoNq4yl17w4BloLeOLLZdMAFZymq7pNV/eUvvXZdXofzsGSLiS0NaxGm4BYdcUShGp/aA6pzmrrEz0l/bv/TkXHotqWOqKL3WCauydh9S2rt9fmI77hwb+fKVxM2JqE8d7s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578415901939981.1036328921873; Tue, 7 Jan 2020 08:51:41 -0800 (PST) Received: from localhost ([::1]:53026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ios4y-0004KJ-5q for importer@patchew.org; Tue, 07 Jan 2020 11:51:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46589) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorkx-0007if-AA for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorkv-0005Km-7u for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:59 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:37477 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorku-0005KT-9q for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:30:57 -0500 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-236-dF8HsW8WMnyTv3wtiIegcg-1; Tue, 07 Jan 2020 11:30:54 -0500 Received: by mail-qk1-f200.google.com with SMTP id f22so139490qka.10 for ; Tue, 07 Jan 2020 08:30:54 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id i2sm88397qte.87.2020.01.07.08.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:30:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414655; 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=Cp6Js316PIXYZH4FnO2Nl29XN8Dewk3Zb8G0nu+p7nE=; b=NT9SblVzOWJwZKdV79L6qBx+jfZC/Ah+pB8n3dSN/jhg7w5D9hociW3Cs5s1NCVWfvlZCO HRtZtao/KA8wSbLZo8j9Vbm64cuXRPEpm3T3NbZoGyW//SUn+76fqkDpwgTZ58EV1ucOmV 0VwAW2s225Jn2OXF8on4YMGRF+aG36c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=5G41uwHBTYAB+Ul1VVsmoX3H1jPszYS18zVu3nGvXFk=; b=anNZ5/xzM5QgweBDZ/VXevyo9fSQnKlPG0Wfbl0rj38jDK6clYUoXOwOLaCVA19Xfp KonMjR1KSVaMmTHTPp1iXCYa5Q1A3b1A+wWY/o3YfpTpOl14erJlBkNJ/PEwkbIeEWjB JhfgnwDR4cqcZtZpSl2QPsvLciEsErx7jlxCv1iQh/BbD4Row/5dhNQ3NCp2YIlcgSL5 JJPnZzaNvC82W/SmMCfsXKOD1uu5CdjWAfdER9VXApvcOoZXaHP3tpY14XkcvmA1EKyK VXhYZJDZjF9MZKVWuWxemQLGRAJAoeGmULQAlBStPMNE3Vlbv1HllglIvTLOyOJFo5zU 8JLQ== X-Gm-Message-State: APjAAAWdUJvjneX9iUSjKW5pLzh4r1sM8oedS3DBMOtzawcafJyhRsSm a/2359t0WqJopjIoHEC73ws1eaNg+bDgtMDLMiFXH4qM4F7vrxeMIlbuKBG6IZ4LGjrJde/3Oyp k+fV3u2aR5YzKyp8= X-Received: by 2002:a05:620a:718:: with SMTP id 24mr119955qkc.77.1578414653244; Tue, 07 Jan 2020 08:30:53 -0800 (PST) X-Google-Smtp-Source: APXvYqwah7GUkx7y9fb2JGk7cA7ddC8Rl6cHrgBiVnDWK1wfCV8hu0P2HH1OD86pR6COxkElG27dyg== X-Received: by 2002:a05:620a:718:: with SMTP id 24mr119912qkc.77.1578414652783; Tue, 07 Jan 2020 08:30:52 -0800 (PST) Date: Tue, 7 Jan 2020 11:30:48 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 17/32] tests/numa: Add case for QMP build HMAT Message-ID: <20200107162850.411448-18-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: dF8HsW8WMnyTv3wtiIegcg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Tao Xu , Markus Armbruster , Paolo Bonzini , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Tao Xu Check configuring HMAT usecase Acked-by: Markus Armbruster Suggested-by: Igor Mammedov Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-8-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- tests/numa-test.c | 213 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 213 insertions(+) diff --git a/tests/numa-test.c b/tests/numa-test.c index 8de8581231..17dd807d2a 100644 --- a/tests/numa-test.c +++ b/tests/numa-test.c @@ -327,6 +327,216 @@ static void pc_dynamic_cpu_cfg(const void *data) qtest_quit(qs); } =20 +static void pc_hmat_build_cfg(const void *data) +{ + QTestState *qs =3D qtest_initf("%s -nodefaults --preconfig -machine hm= at=3Don " + "-smp 2,sockets=3D2 " + "-m 128M,slots=3D2,maxmem=3D1G " + "-object memory-backend-ram,size=3D64M,id=3Dm0 " + "-object memory-backend-ram,size=3D64M,id=3Dm1 " + "-numa node,nodeid=3D0,memdev=3Dm0 " + "-numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D1", + data ? (char *)data : ""); + + /* Fail: Initiator should be less than the number of nodes */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 2, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); + + /* Fail: Target should be less than the number of nodes */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 2," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); + + /* Fail: Initiator should contain cpu */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 1, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); + + /* Fail: Data-type mismatch */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"write-latency\"," + " 'bandwidth': 524288000 } }"))); + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"read-bandwidth\"," + " 'latency': 5 } }"))); + + /* Fail: Bandwidth should be 1MB (1048576) aligned */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 1048575 } }"))); + + /* Configuring HMAT bandwidth and latency details */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 1 } }"))); /* 1 ns */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 5 } }"))); /* Fail: Duplicate configuration */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 68717379584 } }"))); /* 65534 MB/s */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 65534 } }"))); /* 65534 ns */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 34358689792 } }"))); /* 32767 MB/s */ + + /* Fail: node_id should be less than the number of nodes */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 2, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* Fail: level should be less than HMAT_LB_LEVELS (4) */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 4, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* Fail: associativity option should be 'none', if level is 0 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 0, 'associativity': \"direct\", 'policy': \"none\"," + " 'line': 0 } }"))); + /* Fail: policy option should be 'none', if level is 0 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 0, 'associativity': \"none\", 'policy': \"write-back\"," + " 'line': 0 } }"))); + /* Fail: line option should be 0, if level is 0 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 0, 'associativity': \"none\", 'policy': \"none\"," + " 'line': 8 } }"))); + + /* Configuring HMAT memory side cache attributes */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); /* Fail: Duplicate configuration */ + /* Fail: The size of level 2 size should be small than level 1 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 2, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + /* Fail: The size of level 0 size should be larger than level 1 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 0, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 1, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* let machine initialization to complete and run */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, + "{ 'execute': 'x-exit-preconfig' }"))); + qtest_qmp_eventwait(qs, "RESUME"); + + qtest_quit(qs); +} + +static void pc_hmat_off_cfg(const void *data) +{ + QTestState *qs =3D qtest_initf("%s -nodefaults --preconfig " + "-smp 2,sockets=3D2 " + "-m 128M,slots=3D2,maxmem=3D1G " + "-object memory-backend-ram,size=3D64M,id=3Dm0 " + "-object memory-backend-ram,size=3D64M,id=3Dm1 " + "-numa node,nodeid=3D0,memdev=3Dm0", + data ? (char *)data : ""); + + /* + * Fail: Enable HMAT with -machine hmat=3Don + * before using any of hmat specific options + */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'node', 'nodeid': 1, 'memdev': \"m1\"," + " 'initiator': 0 } }"))); + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'node', 'nodeid': 1, 'memdev': \"m1\" } }= "))); + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 1 } }"))); + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* let machine initialization to complete and run */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, + "{ 'execute': 'x-exit-preconfig' }"))); + qtest_qmp_eventwait(qs, "RESUME"); + + qtest_quit(qs); +} + +static void pc_hmat_erange_cfg(const void *data) +{ + QTestState *qs =3D qtest_initf("%s -nodefaults --preconfig -machine hm= at=3Don " + "-smp 2,sockets=3D2 " + "-m 128M,slots=3D2,maxmem=3D1G " + "-object memory-backend-ram,size=3D64M,id=3Dm0 " + "-object memory-backend-ram,size=3D64M,id=3Dm1 " + "-numa node,nodeid=3D0,memdev=3Dm0 " + "-numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D1", + data ? (char *)data : ""); + + /* Can't store the compressed latency */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 1 } }"))); /* 1 ns */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 65535 } }"))); /* 65535 ns */ + + /* Test the 0 input (bandwidth not provided) */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 0 } }"))); /* 0 MB/s */ + /* Fail: bandwidth should be provided before memory side cache attribu= tes */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* Can't store the compressed bandwidth */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 68718428160 } }"))); /* 65535 MB/s */ + + /* let machine initialization to complete and run */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, + "{ 'execute': 'x-exit-preconfig' }"))); + qtest_qmp_eventwait(qs, "RESUME"); + + qtest_quit(qs); +} + int main(int argc, char **argv) { const char *args =3D NULL; @@ -346,6 +556,9 @@ int main(int argc, char **argv) if (!strcmp(arch, "i386") || !strcmp(arch, "x86_64")) { qtest_add_data_func("/numa/pc/cpu/explicit", args, pc_numa_cpu); qtest_add_data_func("/numa/pc/dynamic/cpu", args, pc_dynamic_cpu_c= fg); + qtest_add_data_func("/numa/pc/hmat/build", args, pc_hmat_build_cfg= ); + qtest_add_data_func("/numa/pc/hmat/off", args, pc_hmat_off_cfg); + qtest_add_data_func("/numa/pc/hmat/erange", args, pc_hmat_erange_c= fg); } =20 if (!strcmp(arch, "ppc64")) { --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578416050; cv=none; d=zohomail.com; s=zohoarc; b=XLqV99i+Eyi/STpAn6PH3zthF+WuOUmzGPlE9TUehFpaX+H8ixfrYRF4eNSEDnUD5noX1FTfQ0X7vwyETGcWpCPgaOvsQyw7ihGuqCR1UYwTd/7GhB0VkFGmrDgStgUG/07+HWvkF0pDsCrWDmGeMTu6VyN+dto6ptyosaxvQXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578416050; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZtYURyag3DLg8nTLoi8QUVY5fdiTw/VqNJshcmNYPY8=; b=LCXtF/PwRpboK4+NqkjppQoQPYKHcOxfHtdjqpCoeTeGsYNoyFg+z1vAWpI5eQXetVwOseTxSuL9CP1hnfFn96Ua5uLzADT3w8giSkGFz/SxVCOyl6lJZnXMGy/4r1CiGHsvf2/M2lnZjpoa8f8a+nrVhOx7qUt/eryJ8ZXwyDI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578416050453988.163181245972; Tue, 7 Jan 2020 08:54:10 -0800 (PST) Received: from localhost ([::1]:53064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ios7N-0008L9-20 for importer@patchew.org; Tue, 07 Jan 2020 11:54:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46644) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorl5-0007tF-52 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorl3-0005OL-E7 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:07 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:36816 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorkz-0005Mn-Vv for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:05 -0500 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-107-cjg94whSM9i0R8mqbQsHyA-1; Tue, 07 Jan 2020 11:30:58 -0500 Received: by mail-qt1-f197.google.com with SMTP id l1so107623qtp.21 for ; Tue, 07 Jan 2020 08:30:58 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id 124sm46626qko.11.2020.01.07.08.30.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:30:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414661; 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=ZtYURyag3DLg8nTLoi8QUVY5fdiTw/VqNJshcmNYPY8=; b=hEGBm+CtytLAvwVVbooG/TVO2q42XEDQ4AjGKqLKp8ZGVhcT7ZlzZj+WiqerBMHC4b0ywd 1rQwnvfqxnJeXkLY48Wx5iROpWPnFHEOSS1xdccOWv9T8/spCTIusdUrvzPPbgXW49Ntoy okA1ih6pML+IEnXf4lb5H/A9ouDYgTQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SruOAG0qaxCXWnEXh2DvWIZr1jCGMkEnWfc8/NLsCZo=; b=PSI+OEIz1RinYrfmcv+NeIBLkZSkkWyMea2ceXjybL3jbdJYj4FV4TNEtoVl+wlR9g +MF0tE0846tKGQ5JAdYF1OSem2xoYPcc8XeWJDEyj685MlDLdYJnFBNB1GXtxge2oqoY bdJqRl8Ty497KmhYsq+Ttv0xh9JiQiJgwEX6ptx1IXIMfqDCoTKS38CoDKpFG/1IdlOL LpN9tr8qqqG8zSXE1Kf18ID1QySThivOY06FmqaVdq816xRD6TDLi26sdhb+3EOkfl/S ggK3ZGcvlS49Ow5aSMJgPf/DDzuzKLuR4VEveVFWJmIwyju8P1FL+5PGwL+FngC+WybY XFDg== X-Gm-Message-State: APjAAAXlLGs1vPsiEx8gWM0HP4QFBNJ1Eth7hSPUOpW1uJf1TODkOvFj bl97ks/OU+/myUzapoHK3LDE1ShPTCF0FVpwnVm/h+Pyo7KYYUHeVr9gXC0JQk8wshqOS8HgdYL hhAAVosoEZkCArbc= X-Received: by 2002:a05:620a:1478:: with SMTP id j24mr87888qkl.363.1578414657995; Tue, 07 Jan 2020 08:30:57 -0800 (PST) X-Google-Smtp-Source: APXvYqyqhWMHPc8jJe4TRnp8Yv+uWWfCRvwSjwEEydRBUqX4CFBkucJyEYIB9+mleZGMFc8PD3IcqA== X-Received: by 2002:a05:620a:1478:: with SMTP id j24mr87856qkl.363.1578414657699; Tue, 07 Jan 2020 08:30:57 -0800 (PST) Date: Tue, 7 Jan 2020 11:30:53 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 18/32] tests/bios-tables-test: add test cases for ACPI HMAT Message-ID: <20200107162850.411448-19-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: cjg94whSM9i0R8mqbQsHyA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Jingqi Liu , Tao Xu , Markus Armbruster , Daniel Black , Paolo Bonzini , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Tao Xu ACPI table HMAT has been introduced, QEMU now builds HMAT tables for Heterogeneous Memory with boot option '-numa node'. Add test cases on PC and Q35 machines with 2 numa nodes. Because HMAT is generated when system enable numa, the following tables need to be added for this test: tests/data/acpi/pc/APIC.acpihmat tests/data/acpi/pc/SRAT.acpihmat tests/data/acpi/pc/HMAT.acpihmat tests/data/acpi/pc/DSDT.acpihmat tests/data/acpi/q35/APIC.acpihmat tests/data/acpi/q35/SRAT.acpihmat tests/data/acpi/q35/HMAT.acpihmat tests/data/acpi/q35/DSDT.acpihmat Acked-by: Markus Armbruster Reviewed-by: Igor Mammedov Reviewed-by: Daniel Black Reviewed-by: Jingqi Liu Suggested-by: Igor Mammedov Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-9-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/bios-tables-test-allowed-diff.h | 8 +++++ tests/bios-tables-test.c | 44 +++++++++++++++++++++++++++ tests/data/acpi/pc/APIC.acpihmat | 0 tests/data/acpi/pc/DSDT.acpihmat | 0 tests/data/acpi/pc/HMAT.acpihmat | 0 tests/data/acpi/pc/SRAT.acpihmat | 0 tests/data/acpi/q35/APIC.acpihmat | 0 tests/data/acpi/q35/DSDT.acpihmat | 0 tests/data/acpi/q35/HMAT.acpihmat | 0 tests/data/acpi/q35/SRAT.acpihmat | 0 10 files changed, 52 insertions(+) create mode 100644 tests/data/acpi/pc/APIC.acpihmat create mode 100644 tests/data/acpi/pc/DSDT.acpihmat create mode 100644 tests/data/acpi/pc/HMAT.acpihmat create mode 100644 tests/data/acpi/pc/SRAT.acpihmat create mode 100644 tests/data/acpi/q35/APIC.acpihmat create mode 100644 tests/data/acpi/q35/DSDT.acpihmat create mode 100644 tests/data/acpi/q35/HMAT.acpihmat create mode 100644 tests/data/acpi/q35/SRAT.acpihmat diff --git a/tests/bios-tables-test-allowed-diff.h b/tests/bios-tables-test= -allowed-diff.h index dfb8523c8b..3c9e0c979b 100644 --- a/tests/bios-tables-test-allowed-diff.h +++ b/tests/bios-tables-test-allowed-diff.h @@ -1 +1,9 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/APIC.acpihmat", +"tests/data/acpi/pc/SRAT.acpihmat", +"tests/data/acpi/pc/HMAT.acpihmat", +"tests/data/acpi/pc/DSDT.acpihmat", +"tests/data/acpi/q35/APIC.acpihmat", +"tests/data/acpi/q35/SRAT.acpihmat", +"tests/data/acpi/q35/HMAT.acpihmat", +"tests/data/acpi/q35/DSDT.acpihmat", diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index bc0ad594a1..f1ac2d7e96 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -947,6 +947,48 @@ static void test_acpi_virt_tcg_numamem(void) =20 } =20 +static void test_acpi_tcg_acpi_hmat(const char *machine) +{ + test_data data; + + memset(&data, 0, sizeof(data)); + data.machine =3D machine; + data.variant =3D ".acpihmat"; + test_acpi_one(" -machine hmat=3Don" + " -smp 2,sockets=3D2" + " -m 128M,slots=3D2,maxmem=3D1G" + " -object memory-backend-ram,size=3D64M,id=3Dm0" + " -object memory-backend-ram,size=3D64M,id=3Dm1" + " -numa node,nodeid=3D0,memdev=3Dm0" + " -numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0" + " -numa cpu,node-id=3D0,socket-id=3D0" + " -numa cpu,node-id=3D0,socket-id=3D1" + " -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D1" + " -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D65534M" + " -numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D65534" + " -numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D32767M" + " -numa hmat-cache,node-id=3D0,size=3D10K,level=3D1," + "associativity=3Ddirect,policy=3Dwrite-back,line=3D8" + " -numa hmat-cache,node-id=3D1,size=3D10K,level=3D1," + "associativity=3Ddirect,policy=3Dwrite-back,line=3D8", + &data); + free_test_data(&data); +} + +static void test_acpi_q35_tcg_acpi_hmat(void) +{ + test_acpi_tcg_acpi_hmat(MACHINE_Q35); +} + +static void test_acpi_piix4_tcg_acpi_hmat(void) +{ + test_acpi_tcg_acpi_hmat(MACHINE_PC); +} + static void test_acpi_virt_tcg(void) { test_data data =3D { @@ -991,6 +1033,8 @@ int main(int argc, char *argv[]) qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem); qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm); qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm); + qtest_add_func("acpi/piix4/acpihmat", test_acpi_piix4_tcg_acpi_hma= t); + qtest_add_func("acpi/q35/acpihmat", test_acpi_q35_tcg_acpi_hmat); } else if (strcmp(arch, "aarch64") =3D=3D 0) { qtest_add_func("acpi/virt", test_acpi_virt_tcg); qtest_add_func("acpi/virt/numamem", test_acpi_virt_tcg_numamem); diff --git a/tests/data/acpi/pc/APIC.acpihmat b/tests/data/acpi/pc/APIC.acp= ihmat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/pc/DSDT.acpihmat b/tests/data/acpi/pc/DSDT.acp= ihmat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/pc/HMAT.acpihmat b/tests/data/acpi/pc/HMAT.acp= ihmat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/pc/SRAT.acpihmat b/tests/data/acpi/pc/SRAT.acp= ihmat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/APIC.acpihmat b/tests/data/acpi/q35/APIC.a= cpihmat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/DSDT.acpihmat b/tests/data/acpi/q35/DSDT.a= cpihmat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/HMAT.acpihmat b/tests/data/acpi/q35/HMAT.a= cpihmat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/SRAT.acpihmat b/tests/data/acpi/q35/SRAT.a= cpihmat new file mode 100644 index 0000000000..e69de29bb2 --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415357; cv=none; d=zohomail.com; s=zohoarc; b=RdD2E+TOIxaQXI2c+M4Mq3qescVafj0W4jRN7qvWTX9KapiEAqezmrR+K+cGSLQD1u/t4EZcCXuNfxWMfUkf9ye501nFN8yT+Dm2raiFeENSCs3lhdc2Z8C5RYa2c9WXzhgQfRiak8FPB3hz3sA7QBNVp9wbJc75l+FMUmSXxhM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415357; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KK1l/PHjlNOm2EdO0lI4ftoCkLwZHJNbAAGaDddroN4=; b=K+ac0ZyL7YjQPF7QzIbdB2L7rom7S8LsQ+mW0tb0Qf+2BqmGabHSUU/F4YHGF5Tu3DRZuGIm5xPmx5qIQCv6cQ21xqGDcefQ7dcjzX55gtV4s73lH+9bVZjgMkLQZ0vltJX6ldjOIH0DmHnwpJEqg14rXkCxLLn/1/C4JHpMg68= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578415357368943.5423807954224; Tue, 7 Jan 2020 08:42:37 -0800 (PST) Received: from localhost ([::1]:52852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorwB-0005d2-KL for importer@patchew.org; Tue, 07 Jan 2020 11:42:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46658) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorl5-0007u4-Vs for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorl3-0005PK-Kg for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:07 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:25133 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorl3-0005OB-Fo for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:05 -0500 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319-trYg252LMRaQM8TlxQ2Alg-1; Tue, 07 Jan 2020 11:31:03 -0500 Received: by mail-qt1-f198.google.com with SMTP id l1so107799qtp.21 for ; Tue, 07 Jan 2020 08:31:03 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id n20sm35186qkk.54.2020.01.07.08.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414665; 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=KK1l/PHjlNOm2EdO0lI4ftoCkLwZHJNbAAGaDddroN4=; b=dlpMc+/EtVYjcd7q9PMWz9qBXHkDeAr2EalO1/GR9qfA2cewjQPLnmrn3RD/bNqFq0VWU7 4ThVoqdCp1l3CiyjLbmTetBvElEKu4KRuu1JpJg/kusCEn2SFaQG8760FFvz30MbPAspDK 8XzTLzcT+oxfq2UD5PrUV6wSpaF064s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WHf91FL9X6R/LHFT3E8dg17f/3EsgQa7B7wKa5HVzBM=; b=qIUACDvPNRQVWDqmmzDRPwJJCBSt2hXWYH9OSgQVFbo2zfDN2FFBPn4gASCSFRznKw m/Xk1gXuowQbjSfCCuhbIOM2NphF+FttwASQX7MnEPePAE9N2Ku/B7Lwc7KgcHWn7/oE 7620j6EvPoEZMrWTP4j78W8SGAuKLvN7JcUrbE7zPE44utLZ5fTAYeCghRkBcFxEY9DB 8YD9Gz0dSCbcOjtTtTvr3E5RiJGooSvy+n/jpbeyxmOVNDeqfD2/TCL1zocUKRvapzUG V/ionoUR2f15vnKPBEFFUBgPXerMlHOYa+tLt/+mZJvK7LV4ZSgcN/K67ukvnasIkZh1 Zptg== X-Gm-Message-State: APjAAAXTLPInukiTbfk4dHucCqCYGRpC+xGmYNToJjFqTOcaQaOSaK7w 463TS+9mnmHE1QMv3QdII+DkAlrAxuyJayEaxQl7bO/Kn2YmPbWeNGYld3iVjdhBqpoxLjaVQb4 pixl3TkjXyswNXEE= X-Received: by 2002:a37:8182:: with SMTP id c124mr118102qkd.165.1578414662975; Tue, 07 Jan 2020 08:31:02 -0800 (PST) X-Google-Smtp-Source: APXvYqwhuU01rk3ZJ9o+Kct81LPRLk2JlWOK96oLg3/6p90HDT0jCjvyjFJ7SlkADRHkXNWZuySebg== X-Received: by 2002:a37:8182:: with SMTP id c124mr118001qkd.165.1578414661912; Tue, 07 Jan 2020 08:31:01 -0800 (PST) Date: Tue, 7 Jan 2020 11:30:58 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 19/32] ACPI: add expected files for HMAT tests (acpihmat) Message-ID: <20200107162850.411448-20-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: trYg252LMRaQM8TlxQ2Alg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Daniel Black , Shameer Kolothum , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michael S. Tsirkin --- tests/bios-tables-test-allowed-diff.h | 8 -------- tests/data/acpi/pc/APIC.acpihmat | Bin 0 -> 128 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 0 -> 6455 bytes tests/data/acpi/pc/HMAT.acpihmat | Bin 0 -> 280 bytes tests/data/acpi/pc/SRAT.acpihmat | Bin 0 -> 280 bytes tests/data/acpi/q35/APIC.acpihmat | Bin 0 -> 128 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 0 -> 9203 bytes tests/data/acpi/q35/HMAT.acpihmat | Bin 0 -> 280 bytes tests/data/acpi/q35/SRAT.acpihmat | Bin 0 -> 280 bytes 9 files changed, 8 deletions(-) diff --git a/tests/bios-tables-test-allowed-diff.h b/tests/bios-tables-test= -allowed-diff.h index 3c9e0c979b..dfb8523c8b 100644 --- a/tests/bios-tables-test-allowed-diff.h +++ b/tests/bios-tables-test-allowed-diff.h @@ -1,9 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/APIC.acpihmat", -"tests/data/acpi/pc/SRAT.acpihmat", -"tests/data/acpi/pc/HMAT.acpihmat", -"tests/data/acpi/pc/DSDT.acpihmat", -"tests/data/acpi/q35/APIC.acpihmat", -"tests/data/acpi/q35/SRAT.acpihmat", -"tests/data/acpi/q35/HMAT.acpihmat", -"tests/data/acpi/q35/DSDT.acpihmat", diff --git a/tests/data/acpi/pc/APIC.acpihmat b/tests/data/acpi/pc/APIC.acp= ihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a21f164699bfccd8992ea1bdb57= 17f2dc3025496 100644 GIT binary patch literal 128 zcmZ<^@N{lqU|?Xp<>c?|5v<@85#a0y6k`O6f!H9Lf#JbFFwFr}2jX%tGJA8l)n3DUlYJT5~Da#Tw;OmQgB5 z;e`?xQH-Fp0w_-I0@g(f^nx~cZ9hWu2zi9`6;d?uRn+h7awwY80?9=3DQh?+C!o9~>N zIp@p_4clm3JxpZZtF6 zQqyh}m`6RXM_sK?U7@Go8VvOxF_0>z{4Y}*=3Dowjb~^1iRBDC2O&%H{P469?*Yd<3S)Dt4h6;IOcSyOPx- z!WD4$wLe@U78=3DP|`7%3EwMsS4-eFO_K#izg#6ML(cR4Bz6PvU5R=3DuHvG+44E7K{9y z6ECfDk9kauEHJ*xci0Y#Ozbje@9J977{a4bE#a@qaH9S|m${5%)E3*q|Ah$V>+HR5 zu5SznPS1`HR78A%sRS%2D~3MY#1jLL=3DEdA9|33PCl*Ly0kI^5oPz%fKV$A2xtyHao z-0T&jGLuo6h>LZR<>Hx$h*$A9Bj&|{_)z>HriG$3SBz5nl+Y*)M?Vn=3D&ffb~t1uE{d-UPP0&mPByb5_OVD*q(BW%2Nc(JOlG3`}LFI|f`=3DSey^@YH<&jQ>9`(iJt-z0wM57Jv?U^J)4RXZ+GHZiZuivg zZGaL;n`&*%U|YQl-P^pE?zTj1*ln||$CE>;08qMnTSSIE#X(PW*rT&8@3Y-ap)w>c zd$`4zcfSRD54Sk;wjR1IcCXcUod*{#N6A~t70Nbl)vsq2eC6nCk-qYZHe0!lRqZA2 zi%uI!pXiIEwp6*U*AoELv*{_3{BnXN{9xN>e`_EP71Ng*)#Txr%OxH~VrDldeQQa<8Ge8=3DJMn+3DE47N^G3vzH=3DWh8`3cdvXO%`;klFjC_}?-2FHc0qdkOl%cqf+NSnr(A-=3D_dWw&8kU!5Ae#H60Rg?h_=3DNlq`P6jF9mmnKqB)ShY&cQg#u0?%&`j zQ7BN5I`NVGHp^B}!6vPml`UkK;4co4N%PL1?(Xbn+DFnnxbOw}EpV#LQGS;#I_{Ye zbGVO{g3JVSP@2b>jf!bzw(k6Sn~H{F8nwEJI1et3EHwE)Jt(s(vC}! zP9%M zs8J=3D79qOhAjU~ZX)99Y|i26vsLo)X}(|#xac-TX&D(R{{<3yLb5kU3)V)~po`^Blz zDbrMGnlwd!dig~mK;Oii(44~9LGvUWYI z9!00zR9E{I0;>@_0@|ja^FE-c3n;Y(#Az1y;TN|PVS?}tAV}K@)5_wVL)n@A1f^zp z@^|E&fr5hckg4+YDW(Q8)tEl{?8|AYKvD9JMAQw8pprsv_&o!2c#{mw<^Hecw6i8M zV{lN@GzSMYnmDKrt65%FGb%2WlInVl3Z1_cgBt)!nD#CzUyjj9F?_uSPmPfdORxE* z`~`%nYeDs*OMFo3mWBA|!$}swQ=3DbBgzVKFko_e0*3i^4FXFo#yJT;Uj{qXzGXiy3S zBVEAh6Jfq4DE5pg2M7Q9DbRfL!;#$mhG2-}-_m1q$81!w)DkM~dLM1B#FK{3k23?Y@DG5!5LM7{@gieM*uS(V_37ras zN>;q117D}ZpzlalRYKKJsANq`XgUn~u4J8&(3w!EWSy1J*)V89vLf<>X=3D$NQ$@-Fn zz7z&6O4gGSdNLF$Sx-smsW7N6S?45lE)*(RPfO_OFsLC}&q(N*P^e^`m(ckzXi2i3 zmC&=3DHP|5nTguWaGU6HJ>Na!n}P|12uLeCus)ynh6jannpOWkkdA+k@kZrc}B2&iU( zkRd^8mLZ@b1)2^Cq?x?mPU01_Z=3DMiD(R;0w^3bjitO7+I4R>CfqbaPX|iu4b)+6IEy#y@m1HD=3D)MtG8P`^wv!ddD& zzI>?nXNek Qg_O1sXWa%LGz<~_AAR>eTL1t6 literal 0 HcmV?d00001 diff --git a/tests/data/acpi/pc/HMAT.acpihmat b/tests/data/acpi/pc/HMAT.acp= ihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c00f7ba6cd0acecbc4b158f430d= 29b2f32988522 100644 GIT binary patch literal 280 zcmeb9bqtYUWME*L;pFe^5v<@85#a0r6axw|fY=3D}!1~h;SWIjwBokmuNOFc;30ICth zW`eR`Fhdzga*PcB{=3D?M+<&o8c*vJ6H|M&lYJ;*!-WC@U?fIv`?15Cr@;rh|!0TAyG A0RR91 literal 0 HcmV?d00001 diff --git a/tests/data/acpi/pc/SRAT.acpihmat b/tests/data/acpi/pc/SRAT.acp= ihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1dcae90aec688e88f9d212e632f= aaaaf2e0dc7bc 100644 GIT binary patch literal 280 zcmWFzatx7RWME)C;N1+c3F q8VCj-m|+T0)xmizPc?|5v<@85#a0y6k`O6f!H9Lf#JbFFwFr}2jX%tGJl1TZsreZQ3+HD9Lq;HVsVfQY0;|Op$crfCjjB<5o&q zWT7}k(jb7O0QuoVfrNF?-snJw-g@gb{u6R*fS!8oH7Md!)c4Ko$TLd{h!53)oNxBM z@0+(fGjFv^zvFkmxxkneRIYmUPO);m<@xBd7-Q6?Z>N#D!FqdsrPjA{sf^Xz&xtlZ zDz^KqU%6JZ{<0l@9)@>53ay(FyY+>0@7B%egO9^oj6iSSia4i+v%&kFO22pD@s`&p z+5LLM&zHaAw%zw+D{c47ew*3-YYpFWo0I*k9WQhD4d(f;tPD3N2HS;s?(~9xt$n+^ zboujF?vx+=3D>Yu;4`v%Vdu!?UR-)j+lgztrXIUG8l4R);ei7t+<4Cg-^h{Lkap(9a9 zJ@@mni&Cu|zTpJ69Bb9Cx2jz=3DRtqD<*l<4Tt!}{bjD7W8j%9lL4#o2?S2z7)tL^uT z?xlXGTV@gUgb{V!{A0+SaG3ve5VAp-J32aK!XDpf7<-pFmnWa6;m~Qr>B}}c<-Ryo7{D?H(`vN0Qat4O-d+<|Fva(Hs<(fJ z+RVEel+(<@R|Q|qR@YAnR5is92z3gmD)Y+KP0Op`quIiTbNTcOX;qP`^$wnEcRdu9 z*DQx?L?d0~r)pNjBIcydGplCpvR#(SzRP+CKijDI$MAI8of7BcSfU_?EMyi~ud&zg zeLe-Hy@RKNtJjW+v-3%!%_q(?hk!3Z%P}y++(miDY5d_Zi?e*l?q`k*I()ijy_0?? zZQJMfM4@U1=3DVV1Gny}(o7pI{Ua#EUy>4#}%pLax>bxO0ENW)WVICM@=3D%#(VULLM7=3D z>{i2DXKucaZ!6lS$obQ&7F`0z`;S;It#-FHxAE5ATrPvz!?Ue?l6%tcb!MvAPktZXV3Yw8jHF$)&&Iv>3gkUP@gk-A0Bh+N>GQXlHuL&^cx5M5ycJhE8tiN=3D+lozsTSX;UXcUFVFUbH>m)W9mex>zp-o z&Kf#rO`QmJosOZ?F?2enPK3J7f}yiu=3Dq#8z5$ZbU44rd^&N)*jLS5&)p>y8QIdAGj zsOxkMovxwNHFYA?b)GVGo-%ZvGIb)7Yv;XrcQ*q&eMj@(}vE|rcQ*q&P7A# zqM>uq)QM2nc}6hH@lJR~Fe~w9cSbV3M#1vZ4{0T6amW0AdNs3g@H<(up|rjI|8U2GbN!aB&L!E1C>~1pc<46 zR6+%l3=3D|$|V8TE(C>f}P3MLsSLZuT1DzSnI1J$5ppb{#WWS|I@P8g`f z3MLFxgOY(ts9=3D(TB2+qIpb{&XFi;Ij1}dR~Nd}5g>4bqwtYE@GH7FUVgbF4ZC_<$Z z1}d?F2?N!jWS|l%m}H;`l};F_#0n-1RD+U%N~mCxfg)5oVW1K#m@rTcN(L&Sf=3DLF7 zQ0at$N~~bQKs6{CsDuh887M-f69y`=3Df(ZlFpk$yDDwt%T2$fD4sKg2;3{-=3DXfl8=3Dg zl7S*rI$@v^E0{1)4N3+op@K;Uicsl$|V8TE( zC>f}P3MLsSLZuT1DzSnI1J$5ppb{#WWS|I@P8g`f3MLFxgOY(ts9=3D(TB2+qIpolaB zMWh=3DjLft?SY6hw?VW1k53{+#1foe<`sK$hWYD_XvjY$ToF=3D3z@69%d=3D$v`zG8K}mD zfoe<`sKz7%)tF?U8WRSJNL^hRC?Z@jaWct35#lnakeKS+!axzJa|;7Sq|PlFC_;5^ z$v_eM%stzOg|cCOApTiBq<=3D{7XX&fl+yBK2Y5Fgfo)ys32&>iJD#LNND)iyehi@}H z8`-K-d!0UN^ij9n`NmeKYYnH~<9pk92r_lZbMD2)me-yFpj|4=3D@Z2X^HboDk@SpNs z>f;mmY((#E^I1kM45E!EBh5+NBb3$u;(0typ@%g#hTSPF@cB<>*i;(s#;|`g?8M0C z&dTQ!Gz5&M>=3Dycdqr=3D{(Hs2FHv-G5c9nyeAe7fIhcdWbH@ffH)^~cpKiRyT)@V%>7 zwCWX6y@K)S)hq7!>XqI>K-#@Tb)I^R@}5@S6Xm@`dGCbsUR>T!mdE3=3D@2%d~%KM_c zpD6F2P~MNrSCi#4k5Rs=3Dm9L8O)kOK~3FWJC`SoP^iN`3vu9aUG<<}GC*H0+F9+$5r z%V!^>d`&A~6Xk1(^0gDn*W&W^WckU*C|}pg*G2hyqI~^?@^zHY&{mc#@5u6M^T2Hd zJ!TV6EzLeRE0#RIXkEwYlFOJE%yhWd7)dAl#-ro;WqNIKa!Hr>d)UNF<)re-9a>>HbIWS*Wj z)8S5MB%SOt(>XuT9?75S1eN%OM%H0i_jrwwPvhCVbLB<(9>L=3D`9z9WSwW}R9Upba3 zTx!~DT`Sh#yc7NI?cWx6Z@=3D~C+q=3DKM{TAz4UaPqg&)aFvYu4BKuk%(O55VD0u+7}p zc|7*tzd%8m6+L=3D-?=3D?0%me&qmw!G?e~v(DuTyOnf%MDWA|5z5HXC-t zs1s9v<%ST2vB>dFm%Ub_R9Y#~2;@7O33tisuD_ZZ^1(Ly&?}WnJJhtOxw7NdvmORA z)w^)xg^YTEKypdO(NVOW>_**)g~PLhA@!7EV^vIFs#$o6N6D02O3R%fi$S^j) zTc7bd-llz$3@iMioEwCA^$|uanG`2`Sj&tE5*Gz$E(ynVu%eNX0UcT4{f*49KAK8g z+VQD)dNdc{$TePQFy&qCbn_<(9ece-1`EZ}&KO-0PbGT^`g*bxr(o>pdLO(*6AUX7 zf0(P7S@t2#FHFav+%4p|&G7#}-5I(wcv;xZkr=3DkU^E%e_^?>z0*vQbd6t|8>0^F7z zC$KD$AlIkGB36u+%sNiyp2Om(wW|GUX%*L8ydI;4LK6i`XF^-wLA@on=3D;_vGt5hys z!gy(o2e*I!=3DI*=3D2?U7|JeMziu+?;Z@Nb9@a3fdN)0`SG&LAfedCNfJeNo4jLK~Q|{ z_8)d=3D)35`7vrX^zp4Uz^jfpa*gLb7^#77+;O=3D>mKYF+Oad;8Ch!I#-(9#lJhE1(G+ z(9{d6SNeDl{L~n9I-uPpxLSP~A04mg&Wro&;naY}gjaI7x$jv))7xNfIUC^Au}8XXzbmHOiLrd+G+1CIuZwOgqmZ z&8ax1J?4)C(cBC1AraODHr4xB!9bslTx^nc;BEfH{KLFu zqu-J<=3DUW_pm_LrE#T@!ZpIIC;ivAs^zZ4TkFY-VnVp8>3AMz-Z` HcG>>`zx=3DOx literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/HMAT.acpihmat b/tests/data/acpi/q35/HMAT.a= cpihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c00f7ba6cd0acecbc4b158f430d= 29b2f32988522 100644 GIT binary patch literal 280 zcmeb9bqtYUWME*L;pFe^5v<@85#a0r6axw|fY=3D}!1~h;SWIjwBokmuNOFc;30ICth zW`eR`Fhdzga*PcB{=3D?M+<&o8c*vJ6H|M&lYJ;*!-WC@U?fIv`?15Cr@;rh|!0TAyG A0RR91 literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/SRAT.acpihmat b/tests/data/acpi/q35/SRAT.a= cpihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1dcae90aec688e88f9d212e632f= aaaaf2e0dc7bc 100644 GIT binary patch literal 280 zcmWFzatx7RWME)C;N1+c3F q8VCj-m|+T0)xmizP (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578415014166522.3696589467296; Tue, 7 Jan 2020 08:36:54 -0800 (PST) Received: from localhost ([::1]:52778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorqd-0005a4-JP for importer@patchew.org; Tue, 07 Jan 2020 11:36:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46731) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorlA-0007zm-Da for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorl9-0005T0-5c for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:12 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53001 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorl9-0005RF-1O for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:11 -0500 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-205-sheGaT3jPIuVOC1QUVkmVA-1; Tue, 07 Jan 2020 11:31:07 -0500 Received: by mail-qk1-f200.google.com with SMTP id u10so160547qkk.1 for ; Tue, 07 Jan 2020 08:31:07 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id 13sm28573qke.85.2020.01.07.08.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414668; 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=75DSOPWG53BQMc2DQp8pZrGaf6WLAio2xZatEQc8yH4=; b=NwCOXtFjWowvxj6PnY7VkhZKmzjf+UPSrUgG6npMsJzDQ2gjnFSzxS1sbnRz3vy2cBhlAh VQJz84M5vHx+LDizxTgJnIunPTx/1wWvxx3zJQaLWsqt0I65yVStlUFMput5hcfFBIWa0b IVumAC9eqt6AOoJNoqXVYbaMmjl2oSg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ilfUa7pwbD2DsrhFhXRw/VkM07xbn4jtSmYjKOWR/YA=; b=tcE3lyNXE+oUXzCGaNFFF1tyuTlECIQK3f/FtLMfyK0PdOzYWOP5mnbWm+zLqjF+4N 1O3b2TyXPvBd7ixSreqGnLFf4ebcfDTE519qZZbKzsKGfptLyalCACeq2pIzEztgdzQP x2mK+Eu/0bZa/B4uIpyDImudF6fi/iH3BP/JskqllG4cPou9ED/91Zh6Dsfra1w6/sqe q5QjqAt4n6w5ggCH3OioJFGFUzoWvj6eoOyloZ9a31qUFgPj9sr3AXvRIyywgXdYBj1+ pK2Zhtl8/+xv1yxySxcp9uwUtewLdhvfWzucsiFaZtLdzm3srUdy0TD/bJSbWXIrDYCP HH8w== X-Gm-Message-State: APjAAAVtXThG9u7qOu5Z7wBMWqdrRI1/Twfe+cl2o69d3F25jNi7mPz6 Hx/tpYqdNgpl7XTUTEQzQxxEhkt+qwXODoLEqYTAauMu2FWk78jiDKJACeahP8DHF2JTgLMDrBo qu9HJtg/r7p7D4eI= X-Received: by 2002:a0c:9e6d:: with SMTP id z45mr217804qve.65.1578414666250; Tue, 07 Jan 2020 08:31:06 -0800 (PST) X-Google-Smtp-Source: APXvYqwYk1zSLoynRO0i+iVI6DIIR+BbhIy0qAJK6peA5xTlEWqkTHYCWKxAXrd8ILo8K74v61CyqQ== X-Received: by 2002:a0c:9e6d:: with SMTP id z45mr217786qve.65.1578414666026; Tue, 07 Jan 2020 08:31:06 -0800 (PST) Date: Tue, 7 Jan 2020 11:31:02 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 20/32] virtio-mmio: Clear v2 transport state on soft reset Message-ID: <20200107162850.411448-21-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: sheGaT3jPIuVOC1QUVkmVA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Sergio Lopez , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker At the moment when the guest writes a status of 0, we only reset the virtio core state but not the virtio-mmio state. The virtio-mmio specification says (v1.1 cs01, 4.2.2.1 Device Requirements: MMIO Device Register Layout): Upon reset, the device MUST clear all bits in InterruptStatus and ready bits in the QueueReady register for all queues in the device. The core already takes care of InterruptStatus by clearing isr, but we still need to clear QueueReady. It would be tempting to clean all registers, but since the specification doesn't say anything more, guests could rely on the registers keeping their state across reset. Linux for example, relies on this for GuestPageSize in the legacy MMIO tranport. Fixes: 44e687a4d9ab ("virtio-mmio: implement modern (v2) personality (virti= o-1)") Signed-off-by: Jean-Philippe Brucker Message-Id: <20191213095410.1516119-1-jean-philippe@linaro.org> Reviewed-by: Sergio Lopez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mmio.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 94d934c44b..ef40b7a9b2 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -65,6 +65,19 @@ static void virtio_mmio_stop_ioeventfd(VirtIOMMIOProxy *= proxy) virtio_bus_stop_ioeventfd(&proxy->bus); } =20 +static void virtio_mmio_soft_reset(VirtIOMMIOProxy *proxy) +{ + int i; + + if (proxy->legacy) { + return; + } + + for (i =3D 0; i < VIRTIO_QUEUE_MAX; i++) { + proxy->vqs[i].enabled =3D 0; + } +} + static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned siz= e) { VirtIOMMIOProxy *proxy =3D (VirtIOMMIOProxy *)opaque; @@ -378,6 +391,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offs= et, uint64_t value, =20 if (vdev->status =3D=3D 0) { virtio_reset(vdev); + virtio_mmio_soft_reset(proxy); } break; case VIRTIO_MMIO_QUEUE_DESC_LOW: --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415560; cv=none; d=zohomail.com; s=zohoarc; b=GFmmjLHbLrrjaGI0rK39m758N3sTYNAg3K0W7kOrA5H2iqqvDRPCNw3eOqGkpCRNjv50K/PYTfUwCz/OkMGmxYPxQ//Y/YEB6vR9mJPlHqHNSrYmLC9qna6In1ruOiUaG+ZCmgmjRbE94hiK1++ZEEdC6YimYH2foa1FMApJUzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415560; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WMQapAZoKHuzNu9Pp7IYAg1kGSgMFQ0zkXvOLbEXi5E=; b=ds6BXbL5XrwPPMKVVlfStS/3ZHk5qKyJnKG4rl2NWxmhw77CHeFWPYrTQ1OZFcwDYP97H+Qw9ctkpTCiM1MDVmjFJjO/vDk7udMwDS76qZz6Rw9I+86gbl4Xn/iGtuguXpoc+yL27YdKHQF/u7A+QOGt6xpzK2+iwrKzCsDJLFA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578415560367505.5332888772922; Tue, 7 Jan 2020 08:46:00 -0800 (PST) Received: from localhost ([::1]:52888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorzS-000424-H2 for importer@patchew.org; Tue, 07 Jan 2020 11:45:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46784) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorlC-00082V-Ge for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorlB-0005UV-4a for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:14 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:56668 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorlB-0005U3-0a for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:13 -0500 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-48eCXMtmPI6bA6wxrROUVQ-1; Tue, 07 Jan 2020 11:31:11 -0500 Received: by mail-qk1-f200.google.com with SMTP id f22so140096qka.10 for ; Tue, 07 Jan 2020 08:31:11 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id l19sm104584qtq.48.2020.01.07.08.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414672; 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=WMQapAZoKHuzNu9Pp7IYAg1kGSgMFQ0zkXvOLbEXi5E=; b=XZOxK8ERui9RLPTSAp44vRg84Y+iwIdb6adM71p1HFvn3bY/M/GLGTeb9vg11lvLgdic0F 4Dw4AcZEHkZRLx0LNLO8xq6RzScyqrok8OBI2Qmhjgnc/oC5BP61IHGB1qAIa/z+dcxI12 C+ykqInRl2ESXgYAumcJJq2hctwjqUE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=kOPqzhUAAr1F9DHkT+R7bzvkT8C45cWHnUcu3/B6bq0=; b=n9jPPgbahBq/0RzAJCUD1oHVhIPgfY/rtlvcSV+F0IIlZmoODnXBOvby5UGLTR/TJt mZFDtERMWN3fStXqcBLzZN1gxhARS6q7FS9TUR4hqAB54Wbs7JTDOOHgryGhpLuerisk 2OIDRFBsQfwRTCGrAU8qZ5TZzzXL/XN4J2WE5cHL796dm/p/F3BtpEApKMJGcb9KDDNX fDYHGEUD4s9azqe/Jn1iixO+JN94CwXgkzCkazBxlxznSMgtuECg94N4RSUMY5YXu/Ph MBJ8w/j8Pb6y69mv3OoynbzaorWIIlWFAQqmRU1lhdcvJ7nf3mBAKp5E4baPqFsgQ+rU 1Gjg== X-Gm-Message-State: APjAAAXAv5qiw/1miqWbkJl4/x2a2r6tLkkMvngFCGb/sDflubapYjkv VU/4f76gX7g+YpXM/ayiemGH9Xl8RJ51wp8ozjvX9zOowJjYl8rq7hn+U73eraSD48oTQSJzDzS bJo2W0nadq0N0XRE= X-Received: by 2002:ac8:787:: with SMTP id l7mr74248674qth.99.1578414670283; Tue, 07 Jan 2020 08:31:10 -0800 (PST) X-Google-Smtp-Source: APXvYqz4O/fwO+euCWFnJPVKllTyp8EKWmD+hHgprNXUecX7oh52pZTVr4TynySFOSLntGx0ojapRg== X-Received: by 2002:ac8:787:: with SMTP id l7mr74248656qth.99.1578414670102; Tue, 07 Jan 2020 08:31:10 -0800 (PST) Date: Tue, 7 Jan 2020 11:31:06 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 21/32] hw/pci/pci_host: Remove redundant PCI_DPRINTF() Message-ID: <20200107162850.411448-22-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 48eCXMtmPI6bA6wxrROUVQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 In commit 3bf4dfdd111 we introduced the pci_cfg_[read/write] trace events in pci_host_config_[read/write]_common(). We have the following call trace: pci_host_data_[read/write]() - PCI_DPRINTF() - pci_data_[read/write]() - PCI_DPRINTF() - pci_host_config_[read/write]_common() trace_pci_cfg_[read/write]() Since the PCI_DPRINTF() calls are redundant with the trace events, remove them. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20191216002134.18279-2-philmd@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pci_host.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index c5f9244934..0958d157de 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -115,8 +115,6 @@ void pci_data_write(PCIBus *s, uint32_t addr, uint32_t = val, int len) return; } =20 - PCI_DPRINTF("%s: %s: addr=3D%02" PRIx32 " val=3D%08" PRIx32 " len=3D%d= \n", - __func__, pci_dev->name, config_addr, val, len); pci_host_config_write_common(pci_dev, config_addr, PCI_CONFIG_SPACE_SI= ZE, val, len); } @@ -125,18 +123,13 @@ uint32_t pci_data_read(PCIBus *s, uint32_t addr, int = len) { PCIDevice *pci_dev =3D pci_dev_find_by_addr(s, addr); uint32_t config_addr =3D addr & (PCI_CONFIG_SPACE_SIZE - 1); - uint32_t val; =20 if (!pci_dev) { return ~0x0; } =20 - val =3D pci_host_config_read_common(pci_dev, config_addr, - PCI_CONFIG_SPACE_SIZE, len); - PCI_DPRINTF("%s: %s: addr=3D%02"PRIx32" val=3D%08"PRIx32" len=3D%d\n", - __func__, pci_dev->name, config_addr, val, len); - - return val; + return pci_host_config_read_common(pci_dev, config_addr, + PCI_CONFIG_SPACE_SIZE, len); } =20 static void pci_host_config_write(void *opaque, hwaddr addr, @@ -167,8 +160,7 @@ static void pci_host_data_write(void *opaque, hwaddr ad= dr, uint64_t val, unsigned len) { PCIHostState *s =3D opaque; - PCI_DPRINTF("write addr " TARGET_FMT_plx " len %d val %x\n", - addr, len, (unsigned)val); + if (s->config_reg & (1u << 31)) pci_data_write(s->bus, s->config_reg | (addr & 3), val, len); } @@ -177,14 +169,11 @@ static uint64_t pci_host_data_read(void *opaque, hwaddr addr, unsigned len) { PCIHostState *s =3D opaque; - uint32_t val; + if (!(s->config_reg & (1U << 31))) { return 0xffffffff; } - val =3D pci_data_read(s->bus, s->config_reg | (addr & 3), len); - PCI_DPRINTF("read addr " TARGET_FMT_plx " len %d val %x\n", - addr, len, val); - return val; + return pci_data_read(s->bus, s->config_reg | (addr & 3), len); } =20 const MemoryRegionOps pci_host_conf_le_ops =3D { --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415579; cv=none; d=zohomail.com; s=zohoarc; b=GIVq4K2f1zGTWok+7VWNEWwp6a4IPZPVuWkZORBO4O395t2yaCVrrzKlrw53Tiw3L3Thhac5Jh4MbMFbjZADDMWpetjzHDCQVTSyd4uV6UOWHOx3QDgiCoYXlDWrtgN5WqtfF+dtbl9xKXaqKSmeLZ0fZ5myRVn5keJb00D37R8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415579; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mD5CnKaHCqEnDtYsfaWuvKKdqaTymxgk4zlUTmpGAA8=; b=dtrj4M14af3fgtRyAein1PCE7fsL9MPGc+gfyhKbM0Hxf5nAnb0Fm+IipljHPhnK3B8kWLB364gsuGZ7iCl6lD21l9sohHrs9lSFgD90FkRO0RHq9wLD+l2iIoyojeWxF3fvWiB7fNQzvvJ0ZkljBzpCXJ4agBPur5aIJ7dJhHw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578415579400218.9358947247266; Tue, 7 Jan 2020 08:46:19 -0800 (PST) Received: from localhost ([::1]:52890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorzl-0004O7-V6 for importer@patchew.org; Tue, 07 Jan 2020 11:46:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46869) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorlI-00086C-D6 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorlG-0005YN-Kj for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:19 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:47224 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorlG-0005Xd-HM for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:18 -0500 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-39Gq8W05N5GkhesmgeZEKQ-1; Tue, 07 Jan 2020 11:31:16 -0500 Received: by mail-qt1-f198.google.com with SMTP id b14so149793qtt.1 for ; Tue, 07 Jan 2020 08:31:15 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id d143sm19992qke.123.2020.01.07.08.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414677; 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=mD5CnKaHCqEnDtYsfaWuvKKdqaTymxgk4zlUTmpGAA8=; b=OT2WbIEXrsyllY/Ag22SPdGMxrHtGA9AWBEgFID7NH3ulnTkBXyMBvq1fFY3C2fpHyXCKS YPI8dmiFfJLfOEkg060mYbZQLvU6D/DbNBtYoOA3A/rLMzwRGmQJpUgbRMujxZtV4c/yOO oBr6tGbIJg25g6piWVeIZ8zQJu4P+jg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=zrcV6NduOW424RfDjQAFC57USpEMc62nbflawLr92Qk=; b=ZUvBWzPn0A5ERnD2Ejus6Rbs1Gzwx2hshgN8Y4Q0y+yU2TJ2HF30Ohc1v1HSV48azn yyFrboFqaj2vxlg6Dytx7LQQgKG8ljkFdMrPeWtqhY7oahLQ3M40B0HCyZwGniTYbZYU J+MNtiQs5BrclJz9mYRHSus9NI3BnvI5ZwR5+J3ehztFR/BZd+BOmIrQcPSAjDXXxjut XkHWuO5SfwngXk/hgKzKMxYx18HmKadER2e7BAFcHNGHp+dU8n0vFqPJsc+aiv2OZtpV zFrUUHltL0X9Bv4ZLywX3wTlG+onPsAmVRZZPBjm5VU/2Izh5xab7OQNahUpu4OSAADV o96A== X-Gm-Message-State: APjAAAVit/BwSuqcc1xN2Mm0ljvdGni9hfrwUHIPmBC9WLksi5i3mHv1 LbkVE/FmzmD01SfPky57Lb5gxU2+SKdKtwtEOzDb0eREGaxdMTCGsSBcTfJv/Sc7Xb+vOa8DAma VmDykz7PV7KzKutA= X-Received: by 2002:ad4:55a7:: with SMTP id f7mr260280qvx.36.1578414674366; Tue, 07 Jan 2020 08:31:14 -0800 (PST) X-Google-Smtp-Source: APXvYqwIZcSXc7lFqaGIHTOODsXqMqSv0VfskeWYrkHQCbJe0eVs0ekd+BeLV84arSTSdPHTLuy3dA== X-Received: by 2002:ad4:55a7:: with SMTP id f7mr260262qvx.36.1578414674160; Tue, 07 Jan 2020 08:31:14 -0800 (PST) Date: Tue, 7 Jan 2020 11:31:10 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 22/32] hw/pci/pci_host: Let pci_data_[read/write] use unsigned 'size' argument Message-ID: <20200107162850.411448-23-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 39Gq8W05N5GkhesmgeZEKQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 Both functions are called by MemoryRegionOps.[read/write] handlers with unsigned 'size' argument. Both functions call pci_host_config_[read/write]_common() which expect a uint32_t 'len' parameter (also unsigned). Since it is pointless (and confuse) to use a signed value, use a unsigned type. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20191216002134.18279-3-philmd@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci_host.h | 4 ++-- hw/pci/pci_host.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/hw/pci/pci_host.h b/include/hw/pci/pci_host.h index ba31595fc7..9ce088bd13 100644 --- a/include/hw/pci/pci_host.h +++ b/include/hw/pci/pci_host.h @@ -62,8 +62,8 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uin= t32_t addr, uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr, uint32_t limit, uint32_t len); =20 -void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len); -uint32_t pci_data_read(PCIBus *s, uint32_t addr, int len); +void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, unsigned len); +uint32_t pci_data_read(PCIBus *s, uint32_t addr, unsigned len); =20 extern const MemoryRegionOps pci_host_conf_le_ops; extern const MemoryRegionOps pci_host_conf_be_ops; diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index 0958d157de..ce7bcdb1d5 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -106,7 +106,7 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev= , uint32_t addr, return ret; } =20 -void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len) +void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, unsigned len) { PCIDevice *pci_dev =3D pci_dev_find_by_addr(s, addr); uint32_t config_addr =3D addr & (PCI_CONFIG_SPACE_SIZE - 1); @@ -119,7 +119,7 @@ void pci_data_write(PCIBus *s, uint32_t addr, uint32_t = val, int len) val, len); } =20 -uint32_t pci_data_read(PCIBus *s, uint32_t addr, int len) +uint32_t pci_data_read(PCIBus *s, uint32_t addr, unsigned len) { PCIDevice *pci_dev =3D pci_dev_find_by_addr(s, addr); uint32_t config_addr =3D addr & (PCI_CONFIG_SPACE_SIZE - 1); --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578416199; cv=none; d=zohomail.com; s=zohoarc; b=iMTHlc/64ZPj12CiROZ9X8CmQSFuPhkuX/c25m2Gf6+v79pCCqy4CUK5IGPPkQ+Z1bFnx0CT3za1eIZuYOetBkgljn8t2W6zJgup2bvqLXJHpzBSCXkbMUqLl9k4tW6albTIi0VrpDb0WI9apOAdRGNR021H/PzHg/T0sUS+PXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578416199; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=51WDbq+PBwGZb4DLRjFJvXY/baMy4xbXgzhN6b6J6AM=; b=PuLJ83+jr7KzENSnEKd04H+tQjEBqMHzZ4eYDNiLX7fY6oDGkmyZD5Rq4cuu0F+WCXeTVZ3q5GnBBGITp23K89uzgNQCLHa7SYppptb3DaDzoy+srONgj8Fac7ZVNHRcjdvcMcRjWnY3CpExYKlkfey4s6NB05oDiVhioGxCK1Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578416199680378.01136003077056; Tue, 7 Jan 2020 08:56:39 -0800 (PST) Received: from localhost ([::1]:53140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ios9m-00046z-2u for importer@patchew.org; Tue, 07 Jan 2020 11:56:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46909) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorlK-00087c-TU for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorlJ-0005a1-Hp for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:22 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:30980 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorlJ-0005Zs-EC for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:21 -0500 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-105-llPQ_F3pNdGVWtCvFgerog-1; Tue, 07 Jan 2020 11:31:19 -0500 Received: by mail-qk1-f199.google.com with SMTP id a6so146781qkl.7 for ; Tue, 07 Jan 2020 08:31:19 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id k21sm86403qtp.92.2020.01.07.08.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414681; 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=51WDbq+PBwGZb4DLRjFJvXY/baMy4xbXgzhN6b6J6AM=; b=HJ+cvGS68koGnjViu5vJkd3C0pa+xNEA4XyRdBJULnD1s97QjK8er9kH7HvCDpAaec/ZXw bg4yNbM9I6DQO9Ar3aWmVq/QMnlsStdfpDFmsqqxhS3Bbejv0hYfH17O+FGo9eVrH3PvKk vn8/082rag17yChSEDKEm99CKfSZOsI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=o8odu1UwTWT4bWPiNG9EYA27yURxcpg5mIlh0CMeiVA=; b=rTnw+N4+9XCcTawH/95c+6cCRw+1Iu2WbsgvxPsZFgXJyPZFHMKNUiwjhLkHNG0Nl5 acH8jSNVgx0BhgV9y/AzbBwnQfiajnlKawA9DcRFSdSms9r1TAkXkgHUXrkMhqaXrUWd rRcfP9LyTmL1w95wi519VYwWOZzF0gK+UZ1FN84meJPQjkVBxhqZX/AqEaanpgMAm30k 9ZtJElBVS/CLL8uCxanDxA0nX0KWA5K/3O83dVTlW0ojBlG+JQlhBu6plFpkNyCge7TS 13LNEYzKkr0ngscRjWwY3UIekE1ajuYl48XV1nsB/Ps2/08xNoJm81utqq1jOS8H34Zr rQlw== X-Gm-Message-State: APjAAAVzLLqAC27dWyY3i0G+I0GxmCQ+ez/tBZ4DHxo9Zaz9wSaKheyI R88o0jUxX1WhSan4fEeMc5IJDtpjNDYzobGCMIQJNncSSnByI7pyK271vpIHhBBvJ3ippkW4457 QDROPYUg0xVjmDcQ= X-Received: by 2002:a05:620a:1112:: with SMTP id o18mr156917qkk.126.1578414678526; Tue, 07 Jan 2020 08:31:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxmywUj3AsUnzO3uXL9nzho3iWKp5JeLqWA/UAPzNxC2KFRx8VTRf6uKaHbHj3STvDbb80h8A== X-Received: by 2002:a05:620a:1112:: with SMTP id o18mr156894qkk.126.1578414678252; Tue, 07 Jan 2020 08:31:18 -0800 (PST) Date: Tue, 7 Jan 2020 11:31:14 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 23/32] vhost-user: add VHOST_USER_RESET_DEVICE to reset devices Message-ID: <20200107162850.411448-24-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: llPQ_F3pNdGVWtCvFgerog-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Vrabel , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Raphael Norwitz Add a VHOST_USER_RESET_DEVICE message which will reset the vhost user backend. Disabling all rings, and resetting all internal state, ready for the backend to be reinitialized. A backend has to report it supports this features with the VHOST_USER_PROTOCOL_F_RESET_DEVICE protocol feature bit. If it does so, the new message is used instead of sending a RESET_OWNER which has had inconsistent implementations. Signed-off-by: David Vrabel Signed-off-by: Raphael Norwitz Message-Id: <1572385083-5254-2-git-send-email-raphael.norwitz@nutanix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user.c | 8 +++++++- docs/interop/vhost-user.rst | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 02a9b25199..d27a10fcc6 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -58,6 +58,7 @@ enum VhostUserProtocolFeature { VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD =3D 10, VHOST_USER_PROTOCOL_F_HOST_NOTIFIER =3D 11, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD =3D 12, + VHOST_USER_PROTOCOL_F_RESET_DEVICE =3D 13, VHOST_USER_PROTOCOL_F_MAX }; =20 @@ -98,6 +99,7 @@ typedef enum VhostUserRequest { VHOST_USER_GET_INFLIGHT_FD =3D 31, VHOST_USER_SET_INFLIGHT_FD =3D 32, VHOST_USER_GPU_SET_SOCKET =3D 33, + VHOST_USER_RESET_DEVICE =3D 34, VHOST_USER_MAX } VhostUserRequest; =20 @@ -890,10 +892,14 @@ static int vhost_user_set_owner(struct vhost_dev *dev) static int vhost_user_reset_device(struct vhost_dev *dev) { VhostUserMsg msg =3D { - .hdr.request =3D VHOST_USER_RESET_OWNER, .hdr.flags =3D VHOST_USER_VERSION, }; =20 + msg.hdr.request =3D virtio_has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_RESET_DEVIC= E) + ? VHOST_USER_RESET_DEVICE + : VHOST_USER_RESET_OWNER; + if (vhost_user_write(dev, &msg, NULL, 0) < 0) { return -1; } diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 015ac08177..5f8b3a456b 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -785,6 +785,7 @@ Protocol features #define VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD 10 #define VHOST_USER_PROTOCOL_F_HOST_NOTIFIER 11 #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12 + #define VHOST_USER_PROTOCOL_F_RESET_DEVICE 13 =20 Master message types -------------------- @@ -1190,6 +1191,20 @@ Master message types ancillary data. The GPU protocol is used to inform the master of rendering state and updates. See vhost-user-gpu.rst for details. =20 +``VHOST_USER_RESET_DEVICE`` + :id: 34 + :equivalent ioctl: N/A + :master payload: N/A + :slave payload: N/A + + Ask the vhost user backend to disable all rings and reset all + internal device state to the initial state, ready to be + reinitialized. The backend retains ownership of the device + throughout the reset operation. + + Only valid if the ``VHOST_USER_PROTOCOL_F_RESET_DEVICE`` protocol + feature is set by the backend. + Slave message types ------------------- =20 --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578416371; cv=none; d=zohomail.com; s=zohoarc; b=HNth+5YHxP4XsAsD0EzORmt+DQSJ6RSXxQdofqv63y1/Wq8QhX4NRRkUlYjpvciKgzYTxK3Zcmriv6gpn2qveGGeO1dUbIPRUjtAMfiX0ovsnXdDThJyzZemOOza6MTwa1/IJXsc8N3XB7DizjRayrwOeF2TAJsm5s2FH4HPaCQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578416371; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5EhLJ8ESaItKzPeue3PIZ6PBy1w7sicN5shNVXQfGIo=; b=CGjGxOC4tyN5DLq9DEb8Pob+6N+uXBv+yxQdvzrx8mho/tkYYovoLYyDs96wIAUaV/PusaLUE8Ss9ZlhTxC/SR+4fpyblnHfeyD/tcchW/0TaYGxDRmUoVRwMRdeCUtg7At//gC8Gpxwf5ncmuIqwfQUTI+27+sUUpPE1CBHyBw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578416371524961.6684668475287; Tue, 7 Jan 2020 08:59:31 -0800 (PST) Received: from localhost ([::1]:53174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iosCY-0007gd-3p for importer@patchew.org; Tue, 07 Jan 2020 11:59:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46981) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorlO-0008C2-Bs for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorlN-0005cU-5J for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:26 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:25670 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorlN-0005cF-1o for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:25 -0500 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-359-M4vKjBZzNse9x2nYKlKJ-A-1; Tue, 07 Jan 2020 11:31:23 -0500 Received: by mail-qv1-f69.google.com with SMTP id l1so238698qvu.13 for ; Tue, 07 Jan 2020 08:31:23 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id o6sm36586qkk.53.2020.01.07.08.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414684; 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=5EhLJ8ESaItKzPeue3PIZ6PBy1w7sicN5shNVXQfGIo=; b=EAV9cfjXaw2NTFyNadIfQNkGdEwgnd5byYhoW3OkvxYXFddP7hrZO2Q+mYmIBvwKnKT9lA Ae3B9wO9TlhtAkYwuS6m+GVCOkqCo4iciSYV3KaWBY4xtqT7++RiRrZQT1jt1sKramkkR/ /5gzdZ/qXyns22idkELQGs0Frk86/yQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wp7IEacTPDnbh2fT1ey9LJUjRbVmj0GN0bCAT90OXe4=; b=YwTSeQnfry0l1VpZW25HENuQmDLRiXgQ00plewEM9HdRevDQjsXB7laxWv2AzqVcJS 4LNSO8OHDkFRjpDwKlfG85ow/ZHsKziCLHnZYSj5axC6Ebz52VHAFUCWT0DskzB/sNWW bZlf8IxBpeRPb7MACSPD0rGXR+hLwZkPkooEME538+X6eA1y7Kxtvib44o0CY544kXnh zA8Ozl/yFUrdFbLyD0RGHLxvOXT8GdrU8XoX3mqnKayYzOcHunTajuUyNtKag3WWqkh/ golETSGAYJP143X63OjpkzCoPIee3HLT+9Ju7Aa7/gZiU0Z2GxX8pNsL2uggp842H2j3 Ou7Q== X-Gm-Message-State: APjAAAUNQEan8L7AecAWY2eP6UGOQAqPAB8eQGMx/BSkofoZOhJ8N/MF fG8/KLoJI1YvOH0aERp7uoVjTl7Rhs5fc4xlHvEoDji5/z/8RmM6ACEBaE8mnM2KcrHBQWMD4uz cThZoCCav/MZv700= X-Received: by 2002:ae9:f80d:: with SMTP id x13mr156333qkh.226.1578414682835; Tue, 07 Jan 2020 08:31:22 -0800 (PST) X-Google-Smtp-Source: APXvYqwS1Lsg7YmN4uiPzCU6FEB8sVBZTlaTRhM0vdtVfv26YYL71hps7Rz//4Khg6RLOFKISBC0bA== X-Received: by 2002:ae9:f80d:: with SMTP id x13mr156308qkh.226.1578414682582; Tue, 07 Jan 2020 08:31:22 -0800 (PST) Date: Tue, 7 Jan 2020 11:31:18 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 24/32] vhost-user-scsi: reset the device if supported Message-ID: <20200107162850.411448-25-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: M4vKjBZzNse9x2nYKlKJ-A-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Paolo Bonzini , David Vrabel , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Raphael Norwitz If the vhost-user-scsi backend supports the VHOST_USER_F_RESET_DEVICE protocol feature, then the device can be reset when requested. If this feature is not supported, do not try a reset as this will send a VHOST_USER_RESET_OWNER that the backend is not expecting, potentially putting into an inoperable state. Signed-off-by: David Vrabel Signed-off-by: Raphael Norwitz Message-Id: <1572385083-5254-3-git-send-email-raphael.norwitz@nutanix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/scsi/vhost-user-scsi.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 6a6c15dd32..23f972df59 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -39,6 +39,10 @@ static const int user_feature_bits[] =3D { VHOST_INVALID_FEATURE_BIT }; =20 +enum VhostUserProtocolFeature { + VHOST_USER_PROTOCOL_F_RESET_DEVICE =3D 13, +}; + static void vhost_user_scsi_set_status(VirtIODevice *vdev, uint8_t status) { VHostUserSCSI *s =3D (VHostUserSCSI *)vdev; @@ -62,6 +66,25 @@ static void vhost_user_scsi_set_status(VirtIODevice *vde= v, uint8_t status) } } =20 +static void vhost_user_scsi_reset(VirtIODevice *vdev) +{ + VHostSCSICommon *vsc =3D VHOST_SCSI_COMMON(vdev); + struct vhost_dev *dev =3D &vsc->dev; + + /* + * Historically, reset was not implemented so only reset devices + * that are expecting it. + */ + if (!virtio_has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_RESET_DEVICE)) { + return; + } + + if (dev->vhost_ops->vhost_reset_device) { + dev->vhost_ops->vhost_reset_device(dev); + } +} + static void vhost_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq) { } @@ -182,6 +205,7 @@ static void vhost_user_scsi_class_init(ObjectClass *kla= ss, void *data) vdc->get_features =3D vhost_scsi_common_get_features; vdc->set_config =3D vhost_scsi_common_set_config; vdc->set_status =3D vhost_user_scsi_set_status; + vdc->reset =3D vhost_user_scsi_reset; fwc->get_dev_path =3D vhost_scsi_common_get_fw_dev_path; } =20 --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415762; cv=none; d=zohomail.com; s=zohoarc; b=mzx7AaShaMoX4M/lVdlvcVctXxQCRTUz1tMKPHs+Voy0nh90lbUqCf2fUGlwF19rqsi/mHnOP+Ia6+B6sbNoDzuQKDEQDsietGuipjyESaIOeYtiO7F08kOpnqEKVPFnGjHD8YcBHLOQQ/f2nHqcpOEn9cV71/hhaVIvhURBlgo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415762; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=piqn6mX5WQ96VESO5T0tIJ0XhrZt2DhdjHLkZukt+8U=; b=iCBAZlBeBV3DagU38QiNfz3cQkZycTrT+aNfpnmNGIt9jULSPlO+e2VsKtpn/OZ9KPf/UdaXBXRMW4D55cb49YEIJnKzYPVhHIh0a5RHcDWNzMMS5jBOWcx60A13/Ka+tdyuYDauB7uY9HNF76mFHnfm3Wm1K4+Gj471gzjpY1Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578415762743736.6743640263271; Tue, 7 Jan 2020 08:49:22 -0800 (PST) Received: from localhost ([::1]:52980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ios2j-0000d3-44 for importer@patchew.org; Tue, 07 Jan 2020 11:49:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47071) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorlV-0008KI-P3 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorlT-0005fo-J5 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:33 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:25649 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorlT-0005ey-Fa for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:31 -0500 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-268-MtWvPTN0O1CKEkhqIFuc7A-1; Tue, 07 Jan 2020 11:31:28 -0500 Received: by mail-qk1-f200.google.com with SMTP id 65so113853qkl.23 for ; Tue, 07 Jan 2020 08:31:28 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id s91sm102251qtd.50.2020.01.07.08.31.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414689; 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=piqn6mX5WQ96VESO5T0tIJ0XhrZt2DhdjHLkZukt+8U=; b=Bpok0cX59L4ymg5tc27+VNkPl0w8olMeuNhRvvU28ldWJv0zuLYKQKdGi7i58HHrPESVd7 C8d098OXXByD834OTt/XGB/mU2jegCzbAAKXcvja/+uL5P43TZzM+No+rtGJj5l/g6InB0 1Dc19lj8EgvJWdaBx4DRZ+zetIe5vE4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tN9j8nC8UNjEIUbDqAKywg3EszM5OfgJu5L0vZrOdtE=; b=fkg+8KNp1T030GV8wehSw9hCa6/Rl8i4+tmpzkgVdCEQ8UqnMAj2Ydm+K10odqQan9 Uu8ckzgwbpUF2Cv6uOjSrOAlxsSdt6QtFnUmiKyuUkqGFwM1zZdNb2nvz/BkzQ/hU6cw YJOWLDT2HLQXzNfsfid5QaR5s8GipVy355UPI/m5h8qMaZgjEzE9+QHPr3hAkvuc2Gqh jrIMG4EG/ih6aCYLOhtvRRthECvMDcEqpk58J558STuqluEn0egN5c/2TW2uHE+zZu0R 9nlYBrDcYUH6U85O8d1bmkSWbBdgk+njdb7sTeJ3k1koztWYIyMAcmRAlWG4MyshUO6R G7qQ== X-Gm-Message-State: APjAAAVb7SBsycB0HUEswoePnwqLCr9e6M61d2xCjBN/9k0cItD/z7ja 3ZULA/zI++kQEyhIX4+aCTX9Cgew43UJzTr+Go5lVnSJIYbUsUjlWIQ9Gr9IZyjXN7rwt+Slv1l NQev81KoPVOyikJc= X-Received: by 2002:a0c:bd2c:: with SMTP id m44mr221783qvg.248.1578414687618; Tue, 07 Jan 2020 08:31:27 -0800 (PST) X-Google-Smtp-Source: APXvYqyf1dU1aJdCxWSZXf+xztBtirWgRPKsyzxoJC0/OAU7jMMoU1MnPn/pCQWCkvUz3TpW+PJVyw== X-Received: by 2002:a0c:bd2c:: with SMTP id m44mr221735qvg.248.1578414687158; Tue, 07 Jan 2020 08:31:27 -0800 (PST) Date: Tue, 7 Jan 2020 11:31:23 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 25/32] hw: fix using 4.2 compat in 5.0 machine types for i440fx/q35 Message-ID: <20200107162850.411448-26-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: MtWvPTN0O1CKEkhqIFuc7A-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Denis Plotnikov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Denis Plotnikov 5.0 machine type uses 4.2 compats. This seems to be incorrect, since the latests machine type by now is 5.0 and it should use its own compat or shouldn't use any relying on the defaults. Seems, like this appeared because of some problems on merge/rebase. Signed-off-by: Denis Plotnikov Message-Id: <20191223072856.5369-1-dplotnikov@virtuozzo.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc_piix.c | 1 - hw/i386/pc_q35.c | 1 - 2 files changed, 2 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 721c7aa64e..fa12203079 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -425,7 +425,6 @@ static void pc_i440fx_5_0_machine_options(MachineClass = *m) m->alias =3D "pc"; m->is_default =3D 1; pcmc->default_cpu_version =3D 1; - compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len); } =20 DEFINE_I440FX_MACHINE(v5_0, "pc-i440fx-5.0", NULL, diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 52f45735e4..84cf925cf4 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -354,7 +354,6 @@ static void pc_q35_5_0_machine_options(MachineClass *m) pc_q35_machine_options(m); m->alias =3D "q35"; pcmc->default_cpu_version =3D 1; - compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len); } =20 DEFINE_Q35_MACHINE(v5_0, "pc-q35-5.0", NULL, --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578416590; cv=none; d=zohomail.com; s=zohoarc; b=D4qe+Y+G+0XV8riMmFxk2taItm6ZDiqviLVs2is/Dm8bRUzXlgsV3syZVyNk/lRGpAjLXb98iSAhbFl+FeUVHvKH7vr2CdX2QUQm/Dfwf1R5Cz2sKw0ksgwLdWh2JVLk345D4hqFL1pB16PQkimREilFPi8ehteKEvV0KT1I3OA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578416590; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Z13KJ0vWOirv0bpEydzTz+1MhtfDLJdvDbH6dIjPp+0=; b=b57Y/1emjg+Q8b6LsFfOuVMjQRe8XVSrtZjv1UQjWDHQNN+Lz49RqIq2ze6VsOQS2ytiStboYH+LbWZDSz33Jbb67cr/4q4QaGAwmu8+E/2Bl3N/Eq8B3SyAYVeRmiwHENy2OxxlEQ9Nhr6C6FAho7iMMTJSGEqpxw3aIu5jfyU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578416590816234.8909287623103; Tue, 7 Jan 2020 09:03:10 -0800 (PST) Received: from localhost ([::1]:53344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iosG4-0004xF-Px for importer@patchew.org; Tue, 07 Jan 2020 12:03:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47145) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorla-0008R9-7k for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorlY-0005io-Gi for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:38 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:27865 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorlY-0005iZ-C9 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:36 -0500 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-50-nT-DiKBjOpiCnDeTOzZi1g-1; Tue, 07 Jan 2020 11:31:33 -0500 Received: by mail-qv1-f71.google.com with SMTP id z12so238046qvk.14 for ; Tue, 07 Jan 2020 08:31:33 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id e3sm105569qtj.30.2020.01.07.08.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414695; 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=Z13KJ0vWOirv0bpEydzTz+1MhtfDLJdvDbH6dIjPp+0=; b=BlivjNvy7Iiw1UVlpFcpEFC8M8GHmIolwBZQI96M0yCb2TAVx9ulI/7eetsU+MMt/nPFmW uguLnDV2lCQ4Bqw/BBgshwD4vmxQGO4g6839UjWNnkGiHjjtUnf+Y2hxLoiiwr2UBC4hEB sM1DVOwSKomvCfHMEHiSAvh8qM2VdZQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=fzSk4nDQJOb6ecY+TCyTxG5Cc5pBBrBejXKsi0VExAI=; b=otjW9c4QAF2SqxocT1Zg1p8Jv5ICuwxMdBepVOxpUsoCJMEQpD5AXXpoiwNNcBnTDj yhmnQbbHh88dDF6Lv42gFXUkybQhQhlRSwio4KWC6HQWHT+xoEIdT3mrRezpBVO9Ufy7 voTRe4kogciyCVPbMPaCrsgyNf09lB+cifTY7UvctwCZoEcl0+h9H9xdiSZOLCB5sUZx OTLHbAms/2rRaiTRc/fl0UxX96iWwK8PqQ5x+WYAN7B2WKH18qlrZSF5y6N8OGL4AvTR sCHod2UPIQKlQ50OSKVDh160NdCOp4xn+NRQF1NAFy1kn8to2qEvv00iNPK44b1zOnC4 qXHw== X-Gm-Message-State: APjAAAVNB3mOAVFNs/eKriqy911MhJUpA6BeE214RUfl1skQhAhs0kWn qhoije0VZesRfZ9v1AHlstdP/TkLGaj01wA/Jb4ykB7Q2KP8hS0i1DWXG/c3vA/wX+FMmMNHQMh QIeiVoFRtpr3Ur2g= X-Received: by 2002:a05:620a:15e8:: with SMTP id p8mr82440qkm.469.1578414693057; Tue, 07 Jan 2020 08:31:33 -0800 (PST) X-Google-Smtp-Source: APXvYqxPeGGbQGhvmApR7G5VYRy2GDQpa9+q1vrpyNXd55Yy1rHHtiYohyfiIk9blFGxvHdZZzngow== X-Received: by 2002:a05:620a:15e8:: with SMTP id p8mr82409qkm.469.1578414692754; Tue, 07 Jan 2020 08:31:32 -0800 (PST) Date: Tue, 7 Jan 2020 11:31:27 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 26/32] virtio: make seg_max virtqueue size dependent Message-ID: <20200107162850.411448-27-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: nT-DiKBjOpiCnDeTOzZi1g-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Eduardo Habkost , qemu-block@nongnu.org, Max Reitz , Denis Plotnikov , Stefan Hajnoczi , Paolo Bonzini , Fam Zheng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Denis Plotnikov Before the patch, seg_max parameter was immutable and hardcoded to 126 (128 - 2) without respect to queue size. This has two negative effec= ts: 1. when queue size is < 128, we have Virtio 1.1 specfication violation: (2.6.5.3.1 Driver Requirements) seq_max must be <=3D queue_size. This violation affects the old Linux guests (ver < 4.14). These guests crash on these queue_size setups. 2. when queue_size > 128, as was pointed out by Denis Lunev , seg_max restrics guest's block request length which affects guests' performance making them issues more block request than needed. https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg03721.html To mitigate this two effects, the patch adds the property adjusting seg_max to queue size automaticaly. Since seg_max is a guest visible parameter, the property is machine type managable and allows to choose between old (seg_max =3D 126 always) and new (seg_max =3D queue_size - 2) behaviors. Not to change the behavior of the older VMs, prevent setting the default seg_max_adjust value for older machine types. Reviewed-by: Stefan Hajnoczi Signed-off-by: Denis Plotnikov Message-Id: <20191220140905.1718-2-dplotnikov@virtuozzo.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-blk.h | 1 + include/hw/virtio/virtio-scsi.h | 1 + hw/block/virtio-blk.c | 9 ++++++++- hw/core/machine.c | 3 +++ hw/scsi/vhost-scsi.c | 2 ++ hw/scsi/virtio-scsi.c | 10 +++++++++- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index 9c19f5b634..1e62f869b2 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -38,6 +38,7 @@ struct VirtIOBlkConf uint32_t request_merging; uint16_t num_queues; uint16_t queue_size; + bool seg_max_adjust; uint32_t max_discard_sectors; uint32_t max_write_zeroes_sectors; bool x_enable_wce_if_config_wce; diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scs= i.h index 122f7c4b6f..24e768909d 100644 --- a/include/hw/virtio/virtio-scsi.h +++ b/include/hw/virtio/virtio-scsi.h @@ -48,6 +48,7 @@ typedef struct virtio_scsi_config VirtIOSCSIConfig; struct VirtIOSCSIConf { uint32_t num_queues; uint32_t virtqueue_size; + bool seg_max_adjust; uint32_t max_sectors; uint32_t cmd_per_lun; #ifdef CONFIG_VHOST_SCSI diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index b12157b5eb..9bee514c4e 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -913,7 +913,8 @@ static void virtio_blk_update_config(VirtIODevice *vdev= , uint8_t *config) blk_get_geometry(s->blk, &capacity); memset(&blkcfg, 0, sizeof(blkcfg)); virtio_stq_p(vdev, &blkcfg.capacity, capacity); - virtio_stl_p(vdev, &blkcfg.seg_max, 128 - 2); + virtio_stl_p(vdev, &blkcfg.seg_max, + s->conf.seg_max_adjust ? s->conf.queue_size - 2 : 128 - 2= ); virtio_stw_p(vdev, &blkcfg.geometry.cylinders, conf->cyls); virtio_stl_p(vdev, &blkcfg.blk_size, blk_size); virtio_stw_p(vdev, &blkcfg.min_io_size, conf->min_io_size / blk_size); @@ -1138,6 +1139,11 @@ static void virtio_blk_device_realize(DeviceState *d= ev, Error **errp) error_setg(errp, "num-queues property must be larger than 0"); return; } + if (conf->queue_size <=3D 2) { + error_setg(errp, "invalid queue-size property (%" PRIu16 "), " + "must be > 2", conf->queue_size); + return; + } if (!is_power_of_2(conf->queue_size) || conf->queue_size > VIRTQUEUE_MAX_SIZE) { error_setg(errp, "invalid queue-size property (%" PRIu16 "), " @@ -1267,6 +1273,7 @@ static Property virtio_blk_properties[] =3D { true), DEFINE_PROP_UINT16("num-queues", VirtIOBlock, conf.num_queues, 1), DEFINE_PROP_UINT16("queue-size", VirtIOBlock, conf.queue_size, 128), + DEFINE_PROP_BOOL("seg-max-adjust", VirtIOBlock, conf.seg_max_adjust, t= rue), DEFINE_PROP_LINK("iothread", VirtIOBlock, conf.iothread, TYPE_IOTHREAD, IOThread *), DEFINE_PROP_BIT64("discard", VirtIOBlock, host_features, diff --git a/hw/core/machine.c b/hw/core/machine.c index f5e2b32b3b..ec2e3fcb61 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -29,6 +29,9 @@ =20 GlobalProperty hw_compat_4_2[] =3D { { "virtio-blk-device", "x-enable-wce-if-config-wce", "off" }, + { "virtio-blk-device", "seg-max-adjust", "off"}, + { "virtio-scsi-device", "seg_max_adjust", "off"}, + { "vhost-blk-device", "seg_max_adjust", "off"}, }; const size_t hw_compat_4_2_len =3D G_N_ELEMENTS(hw_compat_4_2); =20 diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index c693fc748a..26f710d3ec 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -275,6 +275,8 @@ static Property vhost_scsi_properties[] =3D { DEFINE_PROP_UINT32("num_queues", VirtIOSCSICommon, conf.num_queues, 1), DEFINE_PROP_UINT32("virtqueue_size", VirtIOSCSICommon, conf.virtqueue_= size, 128), + DEFINE_PROP_BOOL("seg_max_adjust", VirtIOSCSICommon, conf.seg_max_adju= st, + true), DEFINE_PROP_UINT32("max_sectors", VirtIOSCSICommon, conf.max_sectors, 0xFFFF), DEFINE_PROP_UINT32("cmd_per_lun", VirtIOSCSICommon, conf.cmd_per_lun, = 128), diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index f080545f48..4bc73a370e 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -659,7 +659,8 @@ static void virtio_scsi_get_config(VirtIODevice *vdev, VirtIOSCSICommon *s =3D VIRTIO_SCSI_COMMON(vdev); =20 virtio_stl_p(vdev, &scsiconf->num_queues, s->conf.num_queues); - virtio_stl_p(vdev, &scsiconf->seg_max, 128 - 2); + virtio_stl_p(vdev, &scsiconf->seg_max, + s->conf.seg_max_adjust ? s->conf.virtqueue_size - 2 : 128= - 2); virtio_stl_p(vdev, &scsiconf->max_sectors, s->conf.max_sectors); virtio_stl_p(vdev, &scsiconf->cmd_per_lun, s->conf.cmd_per_lun); virtio_stl_p(vdev, &scsiconf->event_info_size, sizeof(VirtIOSCSIEvent)= ); @@ -898,6 +899,11 @@ void virtio_scsi_common_realize(DeviceState *dev, virtio_cleanup(vdev); return; } + if (s->conf.virtqueue_size <=3D 2) { + error_setg(errp, "invalid virtqueue_size property (=3D %" PRIu32 "= ), " + "must be > 2", s->conf.virtqueue_size); + return; + } s->cmd_vqs =3D g_new0(VirtQueue *, s->conf.num_queues); s->sense_size =3D VIRTIO_SCSI_SENSE_DEFAULT_SIZE; s->cdb_size =3D VIRTIO_SCSI_CDB_DEFAULT_SIZE; @@ -954,6 +960,8 @@ static Property virtio_scsi_properties[] =3D { DEFINE_PROP_UINT32("num_queues", VirtIOSCSI, parent_obj.conf.num_queue= s, 1), DEFINE_PROP_UINT32("virtqueue_size", VirtIOSCSI, parent_obj.conf.virtqueue_size, 1= 28), + DEFINE_PROP_BOOL("seg_max_adjust", VirtIOSCSI, + parent_obj.conf.seg_max_adjust, true), DEFINE_PROP_UINT32("max_sectors", VirtIOSCSI, parent_obj.conf.max_sect= ors, 0xFFFF), DEFINE_PROP_UINT32("cmd_per_lun", VirtIOSCSI, parent_obj.conf.cmd_per_= lun, --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415783; cv=none; d=zohomail.com; s=zohoarc; b=CQw1l8tLBpUfrqPZNygafFIKU67r1/Kkfnqqd0/GTDEd4WQa3WU+fh1P02R1DTrYDZaYzfBY+Ziglxav9SBrTlc1h1x4vsuq6BwsuikQofAn1BTAbLh5Hn4ywHKcLqQOBcwT+T3RzfgAKuGp8xQAj7qcZ17kvLru9iTpaVUrH8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415783; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HtbxL2MG3al1vaYV6o8j0WZPnL+D8nNZeJUMf96yEUQ=; b=d9ZQuFA6MH2kVxka+Tc7jUc4w6zL86jJvMDiTzidUqfmVVaCf+Fg9Gseoac0fIObujeybdj6X67cwB6TGWKUg1P0Sj/IQsk9zEvdS8n1qyvgZshCyYLBJCmPSksHVnoU8ogBC7tixQgOErBR2bJLnyC5xXyMg9PESWcAI84ycPY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15784157836781009.9582189022708; Tue, 7 Jan 2020 08:49:43 -0800 (PST) Received: from localhost ([::1]:52982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ios34-0001AN-4F for importer@patchew.org; Tue, 07 Jan 2020 11:49:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47202) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorld-0008Vb-TC for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorlc-0005l9-AH for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:41 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:44568 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorlc-0005kl-6p for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:40 -0500 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-381-ncw2GS9kNtqNQVzTXuE6Gw-1; Tue, 07 Jan 2020 11:31:38 -0500 Received: by mail-qk1-f198.google.com with SMTP id l7so144488qke.8 for ; Tue, 07 Jan 2020 08:31:38 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id h6sm108958qtr.33.2020.01.07.08.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414699; 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=HtbxL2MG3al1vaYV6o8j0WZPnL+D8nNZeJUMf96yEUQ=; b=dYOlm81734keZuBNmeMCn/I+0Aur1B7nHM5DazkuiUn8vg9Ej1I+4LO5dD/2+7MdeNxE0k m33iYRIwQCNyKib1Kd8pFhJtdhUgf8Mchac0XhdAYxOPbeOVICp/Js5oJTgrPux9qYD5vo ny05p9oDn1ef7Hj7NJmKGZY07QWff9E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ukejZrijNO6M+6ThiPk3cjbO646qqmDoI6mt9ROtSGs=; b=q62KQrXY0rxk4H3gtZc4v1UpM64ClsbseUPKxtmn/6eNs5okENgqIctMAhn6nmiKaS W3OJSILCbstz99RwXAxmDR1WZpyeKIHEeBCILEjsKxnj49LRuwyegYqeXP/QYrQFnSTM HT245jYldG80VOgR4GW/3y7uQn5TC0/rkQZtMruxJcVG5pvnZ30PIxDXOFdPHgK/MUEe Ydo1OJ+I8+lIC2uKnHnwGdpFUyR02RxRWyqz6PH58HG5onB4FcZtDyEnpG1TGdZQ8wYB ZWf3CWfLt2qqS4lit6BOSyG8pr+znEOeLeDho1YQIJfmYuFpoS2n48fOAyqb12byHRMD SrBw== X-Gm-Message-State: APjAAAXx1DEO2S4AurfCl81kW7Hzll9c5Jx31G2RwRFHqpuSVJSgGsps /EsQp/FZOnfrA6a1z4Ly9o45yjVMYpf7dHnSMd1rOGSRVs6rNyAxkjiJhipsvbrzshajZoHffUh hYKfEQlOzH0IHeao= X-Received: by 2002:ac8:42d7:: with SMTP id g23mr65266439qtm.206.1578414697388; Tue, 07 Jan 2020 08:31:37 -0800 (PST) X-Google-Smtp-Source: APXvYqwhBOQOT+vtm2OhyjeBtvj8TZzlt6UdqcY679CT1AnyTX5UZWUlUscfLneG9zgpE8GsjhgXdg== X-Received: by 2002:ac8:42d7:: with SMTP id g23mr65266419qtm.206.1578414697161; Tue, 07 Jan 2020 08:31:37 -0800 (PST) Date: Tue, 7 Jan 2020 11:31:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 27/32] tests: add virtio-scsi and virtio-blk seg_max_adjust test Message-ID: <20200107162850.411448-28-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: ncw2GS9kNtqNQVzTXuE6Gw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Denis Plotnikov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Denis Plotnikov It tests proper seg_max_adjust settings for all machine types except 'none', 'isapc', 'microvm' Signed-off-by: Denis Plotnikov Message-Id: <20191220140905.1718-3-dplotnikov@virtuozzo.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/acceptance/virtio_seg_max_adjust.py | 134 ++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100755 tests/acceptance/virtio_seg_max_adjust.py diff --git a/tests/acceptance/virtio_seg_max_adjust.py b/tests/acceptance/v= irtio_seg_max_adjust.py new file mode 100755 index 0000000000..5458573138 --- /dev/null +++ b/tests/acceptance/virtio_seg_max_adjust.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python +# +# Test virtio-scsi and virtio-blk queue settings for all machine types +# +# Copyright (c) 2019 Virtuozzo International GmbH +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import sys +import os +import re + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) +from qemu.machine import QEMUMachine +from avocado_qemu import Test + +#list of machine types and virtqueue properties to test +VIRTIO_SCSI_PROPS =3D {'seg_max_adjust': 'seg_max_adjust'} +VIRTIO_BLK_PROPS =3D {'seg_max_adjust': 'seg-max-adjust'} + +DEV_TYPES =3D {'virtio-scsi-pci': VIRTIO_SCSI_PROPS, + 'virtio-blk-pci': VIRTIO_BLK_PROPS} + +VM_DEV_PARAMS =3D {'virtio-scsi-pci': ['-device', 'virtio-scsi-pci,id=3Dsc= si0'], + 'virtio-blk-pci': ['-device', + 'virtio-blk-pci,id=3Dscsi0,drive=3Ddri= ve0', + '-drive', + 'driver=3Dnull-co,id=3Ddrive0,if=3Dnon= e']} + + +class VirtioMaxSegSettingsCheck(Test): + @staticmethod + def make_pattern(props): + pattern_items =3D ['{0} =3D \w+'.format(prop) for prop in props] + return '|'.join(pattern_items) + + def query_virtqueue(self, vm, dev_type_name): + query_ok =3D False + error =3D None + props =3D None + + output =3D vm.command('human-monitor-command', + command_line =3D 'info qtree') + props_list =3D DEV_TYPES[dev_type_name].values(); + pattern =3D self.make_pattern(props_list) + res =3D re.findall(pattern, output) + + if len(res) !=3D len(props_list): + props_list =3D set(props_list) + res =3D set(res) + not_found =3D props_list.difference(res) + not_found =3D ', '.join(not_found) + error =3D '({0}): The following properties not found: {1}'\ + .format(dev_type_name, not_found) + else: + query_ok =3D True + props =3D dict() + for prop in res: + p =3D prop.split(' =3D ') + props[p[0]] =3D p[1] + return query_ok, props, error + + def check_mt(self, mt, dev_type_name): + with QEMUMachine(self.qemu_bin) as vm: + vm.set_machine(mt["name"]) + for s in VM_DEV_PARAMS[dev_type_name]: + vm.add_args(s) + vm.launch() + query_ok, props, error =3D self.query_virtqueue(vm, dev_type_n= ame) + + if not query_ok: + self.fail('machine type {0}: {1}'.format(mt['name'], error)) + + for prop_name, prop_val in props.items(): + expected_val =3D mt[prop_name] + self.assertEqual(expected_val, prop_val) + + @staticmethod + def seg_max_adjust_enabled(mt): + # machine types >=3D 5.0 should have seg_max_adjust =3D true + # others seg_max_adjust =3D false + mt =3D mt.split("-") + + # machine types with one line name and name like pc-x.x + if len(mt) <=3D 2: + return False + + # machine types like pc--x.x[.x] + ver =3D mt[2] + ver =3D ver.split("."); + + # versions >=3D 5.0 goes with seg_max_adjust enabled + major =3D int(ver[0]) + + if major >=3D 5: + return True + return False + + def test_machine_types(self): + # collect all machine types except 'none', 'isapc', 'microvm' + with QEMUMachine(self.qemu_bin) as vm: + vm.launch() + machines =3D [m['name'] for m in vm.command('query-machines')] + vm.shutdown() + machines.remove('none') + machines.remove('isapc') + machines.remove('microvm') + + for dev_type in DEV_TYPES: + # create the list of machine types and their parameters. + mtypes =3D list() + for m in machines: + if self.seg_max_adjust_enabled(m): + enabled =3D 'true' + else: + enabled =3D 'false' + mtypes.append({'name': m, + DEV_TYPES[dev_type]['seg_max_adjust']: enab= led}) + + # test each machine type for a device type + for mt in mtypes: + self.check_mt(mt, dev_type) --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578416749; cv=none; d=zohomail.com; s=zohoarc; b=Zlr8UZaf7oxcUNfk6ffFUHY1Rwz/bcugS+9ouZbbXBelUEeDn/PNkjAPdwuf/+H7cYxcnF6AUvVFpWt/OZ0fpEBAn+VADzWZfD1Wcjpp9jANM0mU6I+6NS8oQjTlIzblIkSMFIPqcLvWQtMFg25kJD0qDx5UXWj9vETsxRnO30s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578416749; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=10wNZRiSDwsgBzUvgX+qZm4UOG4d0UwTiZy8rXJV4jo=; b=MQoeN6H7m6NAFGlNHZPS5CjJo2iSNth/OP2giawkcygUbBHBHuDPA4iV6SqxW8eWL0qsAwyfMOmSOvlGmjZ5L9nbx2m4+R2EPz51DOhV5SH2IoQd9fT6rgRlWX07hfZVEA6KOB0k0Pbddp7UKBiKk4mwKu8RqVG7RpTkP59rP54= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578416749633105.38678545420612; Tue, 7 Jan 2020 09:05:49 -0800 (PST) Received: from localhost ([::1]:53491 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iosIe-00014Q-1q for importer@patchew.org; Tue, 07 Jan 2020 12:05:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47246) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorlh-00008a-Ge for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorlg-0005n9-7B for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:45 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37983 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorlg-0005mx-3l for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:44 -0500 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-149-1A66pp0oOm-Daz28AYJGoQ-1; Tue, 07 Jan 2020 11:31:42 -0500 Received: by mail-qt1-f199.google.com with SMTP id b7so105614qtg.23 for ; Tue, 07 Jan 2020 08:31:42 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id l184sm25959qkc.107.2020.01.07.08.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414703; 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=10wNZRiSDwsgBzUvgX+qZm4UOG4d0UwTiZy8rXJV4jo=; b=ijGlQUsKsYCuElg+pYZenDIyevqjG3Q57vonQgSpjvsceDO3G0IBOfayEo7prgaNQ+6llx lWBKAktHrBakG+x57BQKxoyeJhk6d+e3W4lGgSnaKtMNXMZgMFXOnWFTZKiziCkAT0gjmG EJYaCT8n78dK88Yql55LKBMdikevZog= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tfGwPPQntx/q9Ytbl/8/C6b7fB9jJ0SAUnXApOete/4=; b=lF2GannW6IkBgvFe5TcsEVamk0yGOyOAscozt3/c6w537h2sx3qAWfzitSiW5sGnuu eVSOfD62oLk17cBJnUvgWYVB3KCI1/aVnk8H/Hpu9hJi0cNl4tfrh9UwhpNGbwNy2NG/ bJ1ECnGh23KPd+sWOjj6AloH7HF7lLBUgis8xKLoGZvlBO6tlnU+ymD2IoYjJO9QGnKI eb3Il1BHGSHxXdODann7/J1OnOLZQ/rGRo8TRSKrVs49xS/c9RGCswnhfYUa7fJJhkSV tOB1jme5S6eZcpb2nUu8EwNhV5EG5i95kXrN4qp5gV4ry+EBWcz62cAzZMdSSYYXeyhx xYqg== X-Gm-Message-State: APjAAAUdyt9+P2r/nMqyoG3kwJmJejT2MC2Yng1w4yguJwn0si2LDyrG EHgoCG4C+WPLoUNxj6wXe1zgYw9vUBsB84+3CShYN3GH7JQumKY4ABu2qFQz2WT3tCE+dNrhI1m jLXmqdixoQd4o1B0= X-Received: by 2002:a05:620a:166a:: with SMTP id d10mr128911qko.37.1578414701325; Tue, 07 Jan 2020 08:31:41 -0800 (PST) X-Google-Smtp-Source: APXvYqwvb5KKZr2BkRauQ6Zeg0juDXNN9cPCctvqYKJEipgs2vuu5RW+bTvQGee9Z89TdvdUzBxlBA== X-Received: by 2002:a05:620a:166a:: with SMTP id d10mr128884qko.37.1578414701090; Tue, 07 Jan 2020 08:31:41 -0800 (PST) Date: Tue, 7 Jan 2020 11:31:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 28/32] virtio-mmio: update queue size on guest write Message-ID: <20200107162850.411448-29-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 1A66pp0oOm-Daz28AYJGoQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Denis Plotnikov , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Denis Plotnikov Some guests read back queue size after writing it. Always update the on size write otherwise they might be confused. Cc: qemu-stable@nongnu.org Signed-off-by: Denis Plotnikov Message-Id: <20191224081446.17003-1-dplotnikov@virtuozzo.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mmio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index ef40b7a9b2..872f2cd237 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -308,8 +308,9 @@ static void virtio_mmio_write(void *opaque, hwaddr offs= et, uint64_t value, break; case VIRTIO_MMIO_QUEUE_NUM: trace_virtio_mmio_queue_write(value, VIRTQUEUE_MAX_SIZE); + virtio_queue_set_num(vdev, vdev->queue_sel, value); + if (proxy->legacy) { - virtio_queue_set_num(vdev, vdev->queue_sel, value); virtio_queue_update_rings(vdev, vdev->queue_sel); } else { proxy->vqs[vdev->queue_sel].num =3D value; --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578416061; cv=none; d=zohomail.com; s=zohoarc; b=SrT2p0rUV7scYIBQ1RXy8sRpf4jIY+2R6ndyyn9l0cfNRE+/GkQ8lI95yV2NmlMPn0Hw5U+81Pr2oRgLw85jCSIe6Ny1Z+DqHf5kl7dUsqQOHKb8tnKv7+6Vf4wnMRHcYf+mRyT8T2l/VOCp0Vp66IpMfDeKhifPaXXViDWigGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578416061; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9q2/1/1fqOdhU65sqIDbx6cBRpFU6//iIePNlnfAizE=; b=ZDqT4KiFwAAo+obe2KUUK5Pa/Tc+lBWVY5wQEXK7z78A06nmAjIjCovmynqvlxtYQb2cy4zOyEBN1lqbbsMuj8bFabWMzGW0T8naht5ODid9VlO0m+cPdQQYhG9ErPIXdHVzhp+1vm084G7wzje8simMXCe3y0LWZ6x6Ff02+OE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578416061886842.5369940524814; Tue, 7 Jan 2020 08:54:21 -0800 (PST) Received: from localhost ([::1]:53066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ios7X-0000AA-Sr for importer@patchew.org; Tue, 07 Jan 2020 11:54:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47325) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorll-0000Dw-D1 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorlk-0005pz-3j for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:49 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:22511 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorlk-0005ph-0V for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:48 -0500 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-383-eNt4qTNUPkuT-noPvjDTKQ-1; Tue, 07 Jan 2020 11:31:46 -0500 Received: by mail-qk1-f198.google.com with SMTP id c202so153499qkg.4 for ; Tue, 07 Jan 2020 08:31:46 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id s20sm18909qkg.131.2020.01.07.08.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414707; 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=9q2/1/1fqOdhU65sqIDbx6cBRpFU6//iIePNlnfAizE=; b=FZB9pA+L9vx+j3z7oqQz/23ayP6p9QrMcGpR7QfzoP1hof+TfnIj3XFwey5rEc0+p/fPhz 1MQCddgrY8OX+svNYKXRKGIZ25pc4oSA+UfOU4Fdq/Z9j2BzuiWWFTg8whwjY9J6K0g/Vh p0kYTNHptvh5axDfg7SU6OkthJwdVw4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6oUZcRx6oHUh2LroAUnKmJ6d2Eg7LapR5X4J56q3mek=; b=tRAu0e4J2ylB4C9n4cn9fSuJ40Wsx+yGUYsdDBbGCXf2LnkotB2Q2oUD0ILw3YEl9+ fmFk2TSpH4ihQ2UGT4pkET/e1NdRG4jcKARmEYpxOrhD6HjvNfZnLQ0rr6J2z/qOzDdY Pyr3AuFXsnlMBIm2HtLJKZXR/mBZuzOIf2J6m4iRE6F7YuvIm6utoX/9muLMwQMtop+0 XkZfQ/Y3exQYsU0ICs9m+TR8uqTBkrQjUsYlubsR0S4pL/Tds9YmdMNq8ETtcDtddHY/ w8wFw7/zsRBZ5aMXB1CnslTWytFgQ+TPjuh1yaNm1Lc1GTdVKvkwL+sV+L7OK1FqX0Td 79kw== X-Gm-Message-State: APjAAAW2BeGOlVKLT9Bfta4K5yaKoy3Fp0VxOmK4ZxMYE+K9m4q+HNna d3ib87cw+Qi1Qfw4GZsgPbZgHSKdnxQsuvBAni4mfJ87wOfVyvw7Kb7VfE3jhV6bbVmVnBnRvf+ 45eE26/qI1ncMt18= X-Received: by 2002:ad4:5429:: with SMTP id g9mr238612qvt.134.1578414705311; Tue, 07 Jan 2020 08:31:45 -0800 (PST) X-Google-Smtp-Source: APXvYqycIedPO/XbkLmXwdC3GRhqeryefbBc9k2Iip/xyAIWnnLN0jr2EGsuUgI/jvtGLrP72306Og== X-Received: by 2002:ad4:5429:: with SMTP id g9mr238590qvt.134.1578414705090; Tue, 07 Jan 2020 08:31:45 -0800 (PST) Date: Tue, 7 Jan 2020 11:31:41 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 29/32] virtio: reset region cache when on queue deletion Message-ID: <20200107162850.411448-30-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: eNt4qTNUPkuT-noPvjDTKQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-stable@nongnu.org, Yuri Benditovich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Yuri Benditovich https://bugzilla.redhat.com/show_bug.cgi?id=3D1708480 Fix leak of region reference that prevents complete device deletion on hot unplug. Cc: qemu-stable@nongnu.org Signed-off-by: Yuri Benditovich Message-Id: <20191226043649.14481-2-yuri.benditovich@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 95d8ff8508..7b861e0ca0 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2344,6 +2344,7 @@ void virtio_delete_queue(VirtQueue *vq) vq->handle_aio_output =3D NULL; g_free(vq->used_elems); vq->used_elems =3D NULL; + virtio_virtqueue_reset_region_cache(vq); } =20 void virtio_del_queue(VirtIODevice *vdev, int n) --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415624; cv=none; d=zohomail.com; s=zohoarc; b=T+HRvP63c/Po+HFiQ1ZL+F6oqvG1KlTtVWqtOnvJl4/x+N7yZXP5lW6KjQVTlfsvkxqodqD3bosDRvSpdRjOiLjOIroBNKz68BOGAjjeJa9O4AJPq7VN8HvyNxzQdDF0vULpO6AL5ByyFAdBT/qqcgZJWQ/7d0UENUa0fwq1lBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415624; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BgmNsnDUrIKv5qIqtQ+hIbBMXsq7KvX1kSU3ybRDZeQ=; b=dz1b8b6rKkOjINCqIkJL5WY6A0NMyGL30yf8XAYOoO1FT9wNM+afzceyAaH+N0a/94wPrUX7IaMvMQY44g01+W58FhqUs5jXZqSRg95JpX4xQembC8BHuWnXG8eSqPrJJr4svhaAQnBTgiifqvrBmH8ibIW8VN2BLLfSHCIMxMg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157841562482581.15985662686376; Tue, 7 Jan 2020 08:47:04 -0800 (PST) Received: from localhost ([::1]:52904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ios0T-00059L-I1 for importer@patchew.org; Tue, 07 Jan 2020 11:47:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47415) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorlq-0000LF-P2 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorlp-0005uK-KV for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:54 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:39826 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorlp-0005tw-Go for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:53 -0500 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-300-Zm_bMpedPl6ipgeP0x-h-w-1; Tue, 07 Jan 2020 11:31:50 -0500 Received: by mail-qk1-f200.google.com with SMTP id 11so141274qkk.11 for ; Tue, 07 Jan 2020 08:31:50 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id 201sm46809qkf.10.2020.01.07.08.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414713; 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=BgmNsnDUrIKv5qIqtQ+hIbBMXsq7KvX1kSU3ybRDZeQ=; b=e9exI0DQAmGuSUlb49EmEzKK5qvn6MsM9mlDPbFMl32y6UCSclJYqT/lgnczPhjgtEfX5K 320YK30pOhkkBtVjvEXQp3LE9rYYqHFYp+ym3eLVztm69pm6BRIv8cnR0hX3ixjSdS9sBC 77a37Ms8jSVC1BfEJQVfRCHkUSTh1rA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tdoWlLoYwJDJiT74CT7GYIP+izHUlkgXXi1RbTtf6v8=; b=paS035tEVgQiUDHwaTO54IsFuETL0Q51jCHcy+9DWgC/M5396pbnm6LLOdqx22XVIa GcGFuzJJA11D4qy5XkBIQwLjB8OYh+Gs8lT8PyKrFvAY3Xj/HNyEbXadgCN5Qt9+Xr7u 8nH7IHTPsaJKQdJMT9pMOrzanOUE9dT5Mn1GS94eVeZC5p/FLz+97vshdzSq2UdxCLVc onRES0O1JOKhAA9jL1rIDqVT0YlIGtIK9sT8KfGBg0E6zppLCw1u443tbfeHuMupQ5t1 QgjvOOaf4jRsTi20E5/XSL/awZ/j9fZqlHREgTEVUtPSsYlMhxCi8tINq8lx/ICmQt5H DIYg== X-Gm-Message-State: APjAAAUIPmzseA0/KBKFhntuDpgNPbdMVBT/XXqLeWNP2+StC/pd5MOx 1R4WptywQuVs3fMcSIHrVCNTpkuVq32AuKntdIQGxv9KreXa0fQjQmPz8qkLfnelCA9RSGZvVz0 RVAiepgF25c3mYT0= X-Received: by 2002:a05:6214:965:: with SMTP id do5mr234693qvb.202.1578414709818; Tue, 07 Jan 2020 08:31:49 -0800 (PST) X-Google-Smtp-Source: APXvYqyoMgg8OtyFiNoK+ZXqXiuH3lonojNzltmM8yAYTvdBDzCKbvtHnN/qetpi/uIK5AziIU+OLg== X-Received: by 2002:a05:6214:965:: with SMTP id do5mr234674qvb.202.1578414709586; Tue, 07 Jan 2020 08:31:49 -0800 (PST) Date: Tue, 7 Jan 2020 11:31:45 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 30/32] virtio-net: delete also control queue when TX/RX deleted Message-ID: <20200107162850.411448-31-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: Zm_bMpedPl6ipgeP0x-h-w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , qemu-stable@nongnu.org, Yuri Benditovich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Yuri Benditovich https://bugzilla.redhat.com/show_bug.cgi?id=3D1708480 If the control queue is not deleted together with TX/RX, it later will be ignored in freeing cache resources and hot unplug will not be completed. Cc: qemu-stable@nongnu.org Signed-off-by: Yuri Benditovich Message-Id: <20191226043649.14481-3-yuri.benditovich@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index db3d7c38e6..f325440d01 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3101,7 +3101,8 @@ static void virtio_net_device_unrealize(DeviceState *= dev, Error **errp) for (i =3D 0; i < max_queues; i++) { virtio_net_del_queue(n, i); } - + /* delete also control vq */ + virtio_del_queue(vdev, max_queues * 2); qemu_announce_timer_del(&n->announce_timer, false); g_free(n->vqs); qemu_del_nic(n->nic); --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578415790; cv=none; d=zohomail.com; s=zohoarc; b=JWxh0bnGmc4mkUhtkT4wyWra6fcwXf9XbwTc+LNaMsMpHSXM4FUqGHQ9ZenWekJkIfIQ0bpa876bOA6FYnCKJejqenYjH33L9VEQFHLdR1F5R7O3yDjp2ve3ebq36FJjL4i6ztEI3thkwIMuPeyNd8+M9Xi4V6WJ201d2+H5Voc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578415790; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s9CW2f1wTLCUXOOV0nNq1e86u0ryEb/Y8cd2jez9DrU=; b=L1MI3Uybx8WzqUxTx0AUzfxAtScg/8lwwrvY8hiKQJSbA8P7+Wd46pBsAOq4gT4YCF7qOuP7oWcOKSPrLQkyCV0tto0c+i0k8U6IUS0wNc3H54Y1Gp68hhF+uC3ewJ2WcKK+aWQFDYnR/TDl11b0G0SyKMjnD8ZLNCzMgH0KUI8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578415790483554.8154577779477; Tue, 7 Jan 2020 08:49:50 -0800 (PST) Received: from localhost ([::1]:52984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ios3B-0001MH-4X for importer@patchew.org; Tue, 07 Jan 2020 11:49:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47503) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorlx-0000To-EZ for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:32:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorlw-0005yN-9h for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:32:01 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:59819 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorlw-0005xv-66 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:32:00 -0500 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-352-9citjb5eOLGnegp1efK7iw-1; Tue, 07 Jan 2020 11:31:56 -0500 Received: by mail-qt1-f200.google.com with SMTP id d9so127803qtq.13 for ; Tue, 07 Jan 2020 08:31:56 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id h1sm111122qte.42.2020.01.07.08.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414719; 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=s9CW2f1wTLCUXOOV0nNq1e86u0ryEb/Y8cd2jez9DrU=; b=QSXNjrRyJXLeHIiU77RndLXVabQQAWgZ7n70KhGpfBoSYsC5bdkuSiSsqrpVR06Xqb89Ey 5xw7BSqvya2jDoadRL/zbr1qGI3vF5HelSmzDRNUJOmCOodcIgj9UiaPqnzjNCAWPdx8Ae gBj/245FA0+kjFxjMSgQhVyse4WP02c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=pNIx/NiIdCE26OJhITv4+Fn8KZTuaXrKqh88qEn+vzc=; b=f6XOtqKRVpHlJnkoOK9t2pWagKRLJAk6Eme64wtFHUrPQWEUWUei9K43EEwcjAsjoP MhVf3CQm+7NAgINuMlpl7xAJc4dTRSVopCR2hul72rxa6JQfqHNzXWYAMAYPjZoarBU4 nlNbxehdhs6bsxxB3uVxz8KujP4FrIQXAmKBGy6lLtMM8O5JTjvOZGjuItS+BoxRrrbJ 5j9gZzaUBXwvJy25yoew+KW1YFNFN/F0J7PkrNbilimicu/tfzeZN4WY0UeYT/irFuC0 JnsWe6QeQPfkaZ8YT432UWNY6AVfrEfbZO9q6xwIROTFPDTUO/eNPHlXoJC2PEecOY1g Q0mw== X-Gm-Message-State: APjAAAVQZgjvs1mgrTTXFQ8ojnWsFToLzRH5uIx1E/Qi6jn4EM8AiUOh nn2/2y0V3nr1Mbkmfv4ms619s1Bd2iz/KRKgXq/u06KP3drGVqrFYBbCT6DJYqkmrjHtxF0n6iT t+9YQoTJkBOiyW+U= X-Received: by 2002:a37:8ec7:: with SMTP id q190mr141717qkd.412.1578414715055; Tue, 07 Jan 2020 08:31:55 -0800 (PST) X-Google-Smtp-Source: APXvYqxkrThP5YQgrQvG0mYq1wmrd2uPHD2tITEVJ6fJjZFsHj53YEW+so06qTREo8UP4/vLl26CGA== X-Received: by 2002:a37:8ec7:: with SMTP id q190mr141690qkd.412.1578414714796; Tue, 07 Jan 2020 08:31:54 -0800 (PST) Date: Tue, 7 Jan 2020 11:31:50 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 31/32] intel_iommu: a fix to vtd_find_as_from_bus_num() Message-ID: <20200107162850.411448-32-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 9citjb5eOLGnegp1efK7iw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Kevin Tian , Jacob Pan , Yi Sun , Eduardo Habkost , qemu-stable@nongnu.org, Peter Xu , Liu Yi L , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liu Yi L Ensure the return value of vtd_find_as_from_bus_num() is NULL by enforcing vtd_bus=3DNULL. This would help caller of vtd_find_as_from_bus_nu= m() to decide if any further operation on the returned vtd_bus. Cc: qemu-stable@nongnu.org Cc: Kevin Tian Cc: Jacob Pan Cc: Peter Xu Cc: Yi Sun Signed-off-by: Liu Yi L Signed-off-by: Yi Sun Message-Id: <1578058086-4288-2-git-send-email-yi.l.liu@intel.com> Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index ee06993675..609b80750a 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -948,6 +948,7 @@ static VTDBus *vtd_find_as_from_bus_num(IntelIOMMUState= *s, uint8_t bus_num) return vtd_bus; } } + vtd_bus =3D NULL; } return vtd_bus; } --=20 MST From nobody Tue May 7 13:50:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578417247; cv=none; d=zohomail.com; s=zohoarc; b=PMNjXuErEDFcjNnRwWv/xoHBzVUO5l38XlO7sgeK6zbWPwVLK2SO+Zh8At3Rs1MuHcfZfv0ZJXE+l/DTAYD/Or7Am8Id+7A5h3Lp0U2ZNpedDkAqRxSXKfQj5s16aPuWnH1p3hmFMpb86XEG9cxeJ2x1G6+y6tZ+U1GsvFN+bwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578417247; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VvaA+Bcc2Gxeb7XmQhJgoMxxUrIKTcdYM4rBXSKaGgM=; b=BIFLrH2bX0l3O3OB1GOY0NPwG93x1GGiYN4J1/hqtqC2nYxvpDA8vaEFWgJIxw9tQC9GfFombqK1Lm68HKjkJe4c3pYZcONPWJMhP5idTY2R8ii7HCEr6sDiOvXXLZON3J7Ufolv6TlzEaIES3IwnaIIGzVdxw5Oqkz1AmQQjgo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578417247124371.7677962796721; Tue, 7 Jan 2020 09:14:07 -0800 (PST) Received: from localhost ([::1]:53668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iosQf-00064i-VC for importer@patchew.org; Tue, 07 Jan 2020 12:14:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52436) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorso-0000jO-8A for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:39:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorsm-0002Gq-R1 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:39:06 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:42669 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorsm-0002Gd-NE for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:39:04 -0500 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-273-1HraykThNhuiGWalQl6THQ-1; Tue, 07 Jan 2020 11:39:03 -0500 Received: by mail-pg1-f200.google.com with SMTP id d129so59864pgc.17 for ; Tue, 07 Jan 2020 08:39:02 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id t2sm110843qtn.22.2020.01.07.08.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578415144; 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=VvaA+Bcc2Gxeb7XmQhJgoMxxUrIKTcdYM4rBXSKaGgM=; b=D5YHKao/BvEtfyG3K40XZwTTbZgaFn7twSPCYP27TOSIMxBj56jkDJje3mla44E2Fi+LhI IzncFwBdwAVTaMIshdFp2lEULTLDBWbpvyTBdjljJanfVGNUA0uo9AuCqAyCZEq1UMCh0r CCiRz3PNp7/uxiRmk2WEd/sWflJGTG0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aNLKl1oKPF+kDyM8hwhwxdKmZvFLTYfwlNBJlJeT2zg=; b=AEc1/WEsi1dHcGpU5L2vc9NUqW3FM/PrbpphCQn4tNkvZyiWJ7cWQPq+jar0xY+TV6 ncRZsQ6hoMsVRQYF/9yXlCpTJhID3QYzIeHv2KIcOko2ddzYiMhjepgXpgB0O9cZ+BzU yyU9yx+n6pr8iMKleHGCfAamRIrlGir7nMdvvyeEj0xlxIYuT3DXCm+Fugrylg4qoCRg XyOleJKy2qYs2u2tr1V4SOGwQBe/WNJlM7VwnzSr9cRqWXJjeRqE4BIpUSGHdh1KelLB JAhZJpFHBEG0sz6BdZpGfg0XLKngXQolitybRv3+RkvKB538fbsJRVAaQS3lFMUnzeUw 8E1Q== X-Gm-Message-State: APjAAAUzS0X762C/RL4LGmpZzvfxRfGyJ+0kpHRClVB/8pHx1ajQ8rES JXyFZEneL7j2MGNQw9VDBlIy0BS952Voa+4Jr3fX89+F6DswAS9qd3QFltjJjqQyVd5kSd70hBx tA6FucylSOp+AjKI= X-Received: by 2002:a05:6214:8c3:: with SMTP id da3mr184613qvb.249.1578414720337; Tue, 07 Jan 2020 08:32:00 -0800 (PST) X-Google-Smtp-Source: APXvYqwFQi6Kx4b0tuBGcER7Y8602LqqUbho2q0b8dyFUsgXqU7NwNXymqe5t4FSAm+kHmlWMIsQVA== X-Received: by 2002:a05:6214:8c3:: with SMTP id da3mr184585qvb.249.1578414720113; Tue, 07 Jan 2020 08:32:00 -0800 (PST) Date: Tue, 7 Jan 2020 11:31:55 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 32/32] intel_iommu: add present bit check for pasid table entries Message-ID: <20200107162850.411448-33-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 1HraykThNhuiGWalQl6THQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Kevin Tian , Jacob Pan , Yi Sun , Eduardo Habkost , qemu-stable@nongnu.org, Peter Xu , Liu Yi L , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liu Yi L The present bit check for pasid entry (pe) and pasid directory entry (pdire) were missed in previous commits as fpd bit check doesn't require present bit as "Set". This patch adds the present bit check for callers which wants to get a valid pe/pdire. Cc: qemu-stable@nongnu.org Cc: Kevin Tian Cc: Jacob Pan Cc: Peter Xu Cc: Yi Sun Reviewed-by: Peter Xu Signed-off-by: Liu Yi L Message-Id: <1578058086-4288-3-git-send-email-yi.l.liu@intel.com> Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 1 + hw/i386/intel_iommu.c | 92 +++++++++++++++++++++++++++------- 2 files changed, 74 insertions(+), 19 deletions(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index edcf9fc9bb..862033ebe6 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -479,6 +479,7 @@ typedef struct VTDRootEntry VTDRootEntry; #define VTD_PASID_ENTRY_FPD (1ULL << 1) /* Fault Processing Disa= ble */ =20 /* PASID Granular Translation Type Mask */ +#define VTD_PASID_ENTRY_P 1ULL #define VTD_SM_PASID_ENTRY_PGTT (7ULL << 6) #define VTD_SM_PASID_ENTRY_FLT (1ULL << 6) #define VTD_SM_PASID_ENTRY_SLT (2ULL << 6) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 609b80750a..a523ef0e65 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -686,9 +686,18 @@ static inline bool vtd_pe_type_check(X86IOMMUState *x8= 6_iommu, return true; } =20 -static int vtd_get_pasid_dire(dma_addr_t pasid_dir_base, - uint32_t pasid, - VTDPASIDDirEntry *pdire) +static inline bool vtd_pdire_present(VTDPASIDDirEntry *pdire) +{ + return pdire->val & 1; +} + +/** + * Caller of this function should check present bit if wants + * to use pdir entry for futher usage except for fpd bit check. + */ +static int vtd_get_pdire_from_pdir_table(dma_addr_t pasid_dir_base, + uint32_t pasid, + VTDPASIDDirEntry *pdire) { uint32_t index; dma_addr_t addr, entry_size; @@ -703,18 +712,22 @@ static int vtd_get_pasid_dire(dma_addr_t pasid_dir_ba= se, return 0; } =20 -static int vtd_get_pasid_entry(IntelIOMMUState *s, - uint32_t pasid, - VTDPASIDDirEntry *pdire, - VTDPASIDEntry *pe) +static inline bool vtd_pe_present(VTDPASIDEntry *pe) +{ + return pe->val[0] & VTD_PASID_ENTRY_P; +} + +static int vtd_get_pe_in_pasid_leaf_table(IntelIOMMUState *s, + uint32_t pasid, + dma_addr_t addr, + VTDPASIDEntry *pe) { uint32_t index; - dma_addr_t addr, entry_size; + dma_addr_t entry_size; X86IOMMUState *x86_iommu =3D X86_IOMMU_DEVICE(s); =20 index =3D VTD_PASID_TABLE_INDEX(pasid); entry_size =3D VTD_PASID_ENTRY_SIZE; - addr =3D pdire->val & VTD_PASID_TABLE_BASE_ADDR_MASK; addr =3D addr + index * entry_size; if (dma_memory_read(&address_space_memory, addr, pe, entry_size)) { return -VTD_FR_PASID_TABLE_INV; @@ -732,25 +745,54 @@ static int vtd_get_pasid_entry(IntelIOMMUState *s, return 0; } =20 -static int vtd_get_pasid_entry_from_pasid(IntelIOMMUState *s, - dma_addr_t pasid_dir_base, - uint32_t pasid, - VTDPASIDEntry *pe) +/** + * Caller of this function should check present bit if wants + * to use pasid entry for futher usage except for fpd bit check. + */ +static int vtd_get_pe_from_pdire(IntelIOMMUState *s, + uint32_t pasid, + VTDPASIDDirEntry *pdire, + VTDPASIDEntry *pe) +{ + dma_addr_t addr =3D pdire->val & VTD_PASID_TABLE_BASE_ADDR_MASK; + + return vtd_get_pe_in_pasid_leaf_table(s, pasid, addr, pe); +} + +/** + * This function gets a pasid entry from a specified pasid + * table (includes dir and leaf table) with a specified pasid. + * Sanity check should be done to ensure return a present + * pasid entry to caller. + */ +static int vtd_get_pe_from_pasid_table(IntelIOMMUState *s, + dma_addr_t pasid_dir_base, + uint32_t pasid, + VTDPASIDEntry *pe) { int ret; VTDPASIDDirEntry pdire; =20 - ret =3D vtd_get_pasid_dire(pasid_dir_base, pasid, &pdire); + ret =3D vtd_get_pdire_from_pdir_table(pasid_dir_base, + pasid, &pdire); if (ret) { return ret; } =20 - ret =3D vtd_get_pasid_entry(s, pasid, &pdire, pe); + if (!vtd_pdire_present(&pdire)) { + return -VTD_FR_PASID_TABLE_INV; + } + + ret =3D vtd_get_pe_from_pdire(s, pasid, &pdire, pe); if (ret) { return ret; } =20 - return ret; + if (!vtd_pe_present(pe)) { + return -VTD_FR_PASID_TABLE_INV; + } + + return 0; } =20 static int vtd_ce_get_rid2pasid_entry(IntelIOMMUState *s, @@ -763,7 +805,7 @@ static int vtd_ce_get_rid2pasid_entry(IntelIOMMUState *= s, =20 pasid =3D VTD_CE_GET_RID2PASID(ce); pasid_dir_base =3D VTD_CE_GET_PASID_DIR_TABLE(ce); - ret =3D vtd_get_pasid_entry_from_pasid(s, pasid_dir_base, pasid, pe); + ret =3D vtd_get_pe_from_pasid_table(s, pasid_dir_base, pasid, pe); =20 return ret; } @@ -781,7 +823,11 @@ static int vtd_ce_get_pasid_fpd(IntelIOMMUState *s, pasid =3D VTD_CE_GET_RID2PASID(ce); pasid_dir_base =3D VTD_CE_GET_PASID_DIR_TABLE(ce); =20 - ret =3D vtd_get_pasid_dire(pasid_dir_base, pasid, &pdire); + /* + * No present bit check since fpd is meaningful even + * if the present bit is clear. + */ + ret =3D vtd_get_pdire_from_pdir_table(pasid_dir_base, pasid, &pdire); if (ret) { return ret; } @@ -791,7 +837,15 @@ static int vtd_ce_get_pasid_fpd(IntelIOMMUState *s, return 0; } =20 - ret =3D vtd_get_pasid_entry(s, pasid, &pdire, &pe); + if (!vtd_pdire_present(&pdire)) { + return -VTD_FR_PASID_TABLE_INV; + } + + /* + * No present bit check since fpd is meaningful even + * if the present bit is clear. + */ + ret =3D vtd_get_pe_from_pdire(s, pasid, &pdire, &pe); if (ret) { return ret; } --=20 MST