From patchwork Fri Jan 7 11:03:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576544 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BrGWvxQe; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgNC2WkTz9sXM for ; Fri, 7 Jan 2022 22:04:41 +1100 (AEDT) Received: from localhost ([::1]:59582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5n30-0007d4-AB for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:04:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n1h-00062c-Th for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46192) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n1e-0001gp-HK for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZDYUVmJkHemLI5KByv30OJoOAnuNT00GDgLmkQC7+Is=; b=BrGWvxQegRnvTmamb3wxz0wu/igfM1epoTmfH7D3z8dTP+bSnEUsrULJLB/m/oYYlmMsf9 ZXTQ8VagvZXjOOm4JcmwNiZCQ6DOZVww5IHFRxI0sI8bFGZ/OEE/HoM3zq3+q9JxKR0dZl MNJYJI9+GGYKsi0Gvxn+L9zYDQuQnnU= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-44-kfVXy5ffOsW2EZUmGLWLbg-1; Fri, 07 Jan 2022 06:03:13 -0500 X-MC-Unique: kfVXy5ffOsW2EZUmGLWLbg-1 Received: by mail-wr1-f70.google.com with SMTP id g6-20020adfbc86000000b001a2d62be244so2087054wrh.23 for ; Fri, 07 Jan 2022 03:03:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZDYUVmJkHemLI5KByv30OJoOAnuNT00GDgLmkQC7+Is=; b=XN7YpoBDkU8lCuy2Dpw9gWJsIODUgNm7GxUxc2rv3YxbXpdo/Ak6O0AlqMxYruCA4g S6tFPeOsso2rpilv2ZDsxYOCSfRnZGKtwKWYiBUuXwa/5lbaTImg8KNd27uBCRi1sB9m zKQmn50IaEQtCPMRSYwKLOb7Nhtp3WIbQFCxdBjQUCrF1+8NqEjx/4B5tUIx1OUvGKgk a2tTfuBSMLVmF2AehIIJynf/i5Cp0O295RQM76NwkwNDvfEo5Zh/LbN92BxP7RkdR/3K GeCknr9FuFopuKD72ZT4BDCoRvrzvxHrdzwg1CHb+grh1Uq7GuftVpbbU7IMGL80/6w8 CraQ== X-Gm-Message-State: AOAM5326PpWbQ7/ihGvtWGiyabc9h0FMDozGbRU0AtyM3otDHrtX4oxU TsAc8sWTCI+zkn6C7blhaGyNFXFuKIxzvQnplM/3Sz3NFNgClrwAFwOif+hMTI9em4iXY3I+pBx OQFnEEOx6glOkBFgmrvzj/8mNY5FvVa2/zAoDIHWffEgMDawlC8yu/a32O7Os X-Received: by 2002:a05:6000:1048:: with SMTP id c8mr55719120wrx.508.1641553391402; Fri, 07 Jan 2022 03:03:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFc9WD93lq+eefOIuAYubneC1d9o+bk5vQO59LhPdPg+ud/HFeAmltB0aejxJbV+EIDZQECA== X-Received: by 2002:a05:6000:1048:: with SMTP id c8mr55719101wrx.508.1641553391124; Fri, 07 Jan 2022 03:03:11 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id u11sm4324946wmq.2.2022.01.07.03.03.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:10 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:08 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 01/55] virtio-mem: Don't skip alignment checks when warning about block size Message-ID: <20220107102526.39238-2-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand If we warn about the block size being smaller than the default, we skip some alignment checks. This can currently only fail on x86-64, when specifying a block size of 1 MiB, however, we detect the THP size of 2 MiB. Fixes: 228957fea3a9 ("virtio-mem: Probe THP size to determine default block size") Cc: "Michael S. Tsirkin" Signed-off-by: David Hildenbrand Message-Id: <20211011173305.13778-1-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index d5a578142b..341c3fa2c1 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -733,7 +733,8 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp) warn_report("'%s' property is smaller than the default block size (%" PRIx64 " MiB)", VIRTIO_MEM_BLOCK_SIZE_PROP, virtio_mem_default_block_size(rb) / MiB); - } else if (!QEMU_IS_ALIGNED(vmem->requested_size, vmem->block_size)) { + } + if (!QEMU_IS_ALIGNED(vmem->requested_size, vmem->block_size)) { error_setg(errp, "'%s' property has to be multiples of '%s' (0x%" PRIx64 ")", VIRTIO_MEM_REQUESTED_SIZE_PROP, VIRTIO_MEM_BLOCK_SIZE_PROP, vmem->block_size); From patchwork Fri Jan 7 11:03:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576542 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=SE/swSDj; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgMS3Qj0z9sXM for ; Fri, 7 Jan 2022 22:04:04 +1100 (AEDT) Received: from localhost ([::1]:57458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5n2Q-000681-2O for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:04:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n1i-00065D-Ue for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52166) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n1h-0001hF-5q for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553396; 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=vpoC0+6a4IT38j+kX8wAPq8AuzqmXiw7PFqYGYauyfQ=; b=SE/swSDjKqr6uL3nGTH8d1uhgr8Xkva8+QoycUk0oCrYDVcQDEXtt7d+2KRqVExFfYvC+8 wXb+HgIIKPrpGFQQOMbilCoiOxVlcI7MhLtd4Rxe59zb05rEbXXLx8htEFN+H8yCY9HIlK FVQRNAvCk/G5rb6Kz5cb8eLcKCcEGPE= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-633-mfBLoZkzMX-I78owkm1B-g-1; Fri, 07 Jan 2022 06:03:15 -0500 X-MC-Unique: mfBLoZkzMX-I78owkm1B-g-1 Received: by mail-wr1-f70.google.com with SMTP id g6-20020adfbc86000000b001a2d62be244so2087116wrh.23 for ; Fri, 07 Jan 2022 03:03:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=vpoC0+6a4IT38j+kX8wAPq8AuzqmXiw7PFqYGYauyfQ=; b=2mebqXq1/+9ZunxoXB4pa1Cpyi3u0v8xRLmHW4bE2iyRqAoAqFAB4Pw1swggkNqiv1 0YXwseo124BnKC9CX+5yL568dBXXcoEY8Ef4EOg6Ng8+tGJMVTEQSLXQXo8JXts3OiAD JlstAn2JKjknQrnYxU3oMoBRUm2I/UopOecm52zpKOuLLj11JzAPWykT7YD7LBMKIynE 47ynJTK+DCiagZ3gTWgCSykwWihpD4ibZmivEDGYXuSqmQxkGVKxNkFoPYClj9MDDnuB 76ivi1thdA+D2oQTuir8c2AzEMU4QvWSiyrfM2gTGpd28+tOV9fKRvtSrWAqJthvJJg6 Ot6g== X-Gm-Message-State: AOAM5328OItTsjV1np0ViH6/IGc5NE91tpbrSJkCv+2/thpKc3kQ1m+8 dXsnQRHxI0wmzNHeeUZa55ny/eOeECxsQ7Ltq8EFuDwQ67cNQFjOoywlOMgIi0mbg3DQQb0MqrP TTcGs0R8BfYyTDHHHSqhchsFFVTGOuQX28D87h7PDY43CUv4UjsREQHf3+P5r X-Received: by 2002:a5d:5984:: with SMTP id n4mr48177001wri.562.1641553394203; Fri, 07 Jan 2022 03:03:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJybpI/nPg1+rg56pgpdbl0Gnrzd9F7EQ+9//9nU6pv9ZJV7NUwewhiPoPtVMS8dspyn7r7pYA== X-Received: by 2002:a5d:5984:: with SMTP id n4mr48176976wri.562.1641553393962; Fri, 07 Jan 2022 03:03:13 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id n4sm4400383wrc.1.2022.01.07.03.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:13 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:11 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 02/55] acpi: validate hotplug selector on access Message-ID: <20220107102526.39238-3-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Igor Mammedov Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" When bus is looked up on a pci write, we didn't validate that the lookup succeeded. Fuzzers thus can trigger QEMU crash by dereferencing the NULL bus pointer. Fixes: b32bd763a1 ("pci: introduce acpi-index property for PCI device") Fixes: CVE-2021-4158 Cc: "Igor Mammedov" Fixes: https://gitlab.com/qemu-project/qemu/-/issues/770 Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Ani Sinha --- hw/acpi/pcihp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 30405b5113..a5e182dd3a 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -491,6 +491,9 @@ static void pci_write(void *opaque, hwaddr addr, uint64_t data, } bus = acpi_pcihp_find_hotplug_bus(s, s->hotplug_select); + if (!bus) { + break; + } QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) { Object *o = OBJECT(kid->child); PCIDevice *dev = PCI_DEVICE(o); From patchwork Fri Jan 7 11:03:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=T0gFEIYf; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgYQ0c4kz9tjx for ; Fri, 7 Jan 2022 22:12:42 +1100 (AEDT) Received: from localhost ([::1]:50890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nAl-0004od-Tv for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:12:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n1n-0006Bm-LF for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n1l-0001hq-Rx for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4xF0oyxSEx4yZpu2UWzU3ZDgd5LpH3STc2xOOd8w1GU=; b=T0gFEIYfWoGLeHDUMMOBdLhKyDp6Z444/4Ffn+J5/vca4BY/oH+81wRWXD/EbgImAIGpYB yMidwl6RF0me69TGEtmgz9Md5QzNMEojHSWpQFBjffzvWYtrJBaPD65A6Y6HjKhmEpsILi Kf0kNAL4Jd4BgPzN1NDd8zsAIZZFOFI= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-214-5LLrHm6MP9eQlynDhTqJZw-1; Fri, 07 Jan 2022 06:03:20 -0500 X-MC-Unique: 5LLrHm6MP9eQlynDhTqJZw-1 Received: by mail-wr1-f69.google.com with SMTP id q16-20020adfbb90000000b001a4838099baso2114142wrg.10 for ; Fri, 07 Jan 2022 03:03:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4xF0oyxSEx4yZpu2UWzU3ZDgd5LpH3STc2xOOd8w1GU=; b=MgS4cIszZMGTz9ewt7JV5mh3Im9/fRpMoCok9ijZs4xW/BygyzB3+IlF4JyWt9dAQH TqBbg1zQIekFA/ebVV5nzsBqViLUy+exAxUpnFRgaWj0u8C8LrKFjiWKwkHR9dhy1QBX JvtKBN7tGQB1S/qc/vFm4oNaQ5WUzTLaf4IoimU663DMFbi2CxJfBnocGRHU59aEk5JW SdC4Q4aZMWwTKawMvuohdFO5Oksge/SZ3/1LcyHWY9rth7RxX6mpSObATe/Pv/GxzPH+ QwtxIyhFaMeIP553Sjj3IE67hWUKrtOjSA+i+On3eB/XCzLuvvge8n2LqyrHC7kVIZ3J R4AA== X-Gm-Message-State: AOAM531T5tBKKILi3fGzpf+cZHKfkRaVD/3/wMW9xhPVMBrYeKFkDS8d 19KTe0nDu8YqYEDd2qrv0n9QFWyEe6V5kqP3hQt6VQS54PRkl+w4SRdjkIQ/vwPgSWTvILOBeHc wm/YCB7WRvST8JiWAcyUfDF5QOXXdH/rkbo+EH49/rO1XNYweQXiC1xmezkq6 X-Received: by 2002:adf:ed10:: with SMTP id a16mr9678806wro.617.1641553397980; Fri, 07 Jan 2022 03:03:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzEcethcOvRxPMdYu6vVVsZMe3XpClTCPkcLh1yk8E9X1GtnoMfdWcBU7ScTQWsrr01Sidtw== X-Received: by 2002:adf:ed10:: with SMTP id a16mr9678782wro.617.1641553397748; Fri, 07 Jan 2022 03:03:17 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id o29sm2256625wms.3.2022.01.07.03.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:17 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:14 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 03/55] virtio: introduce macro IRTIO_CONFIG_IRQ_IDX Message-ID: <20220107102526.39238-4-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cindy Lu , Jason Wang , "Dr. David Alan Gilbert" , virtio-fs@redhat.com, "Gonglei \(Arei\)" , Gerd Hoffmann , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cindy Lu To support configure interrupt for vhost-vdpa Introduce VIRTIO_CONFIG_IRQ_IDX -1 as configure interrupt's queue index, Then we can reuse the functions guest_notifier_mask and guest_notifier_pending. Add the check of queue index in these drivers, if the driver does not support configure interrupt, the function will just return Signed-off-by: Cindy Lu Message-Id: <20211104164827.21911-2-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 3 +++ hw/display/vhost-user-gpu.c | 6 ++++++ hw/net/virtio-net.c | 10 ++++++++-- hw/virtio/vhost-user-fs.c | 6 ++++++ hw/virtio/vhost-vsock-common.c | 6 ++++++ hw/virtio/virtio-crypto.c | 6 ++++++ 6 files changed, 35 insertions(+), 2 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 8bab9cfb75..605ea79c90 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -67,6 +67,9 @@ typedef struct VirtQueueElement #define VIRTIO_NO_VECTOR 0xffff +/* special index value used internally for config irqs */ +#define VIRTIO_CONFIG_IRQ_IDX -1 + #define TYPE_VIRTIO_DEVICE "virtio-device" OBJECT_DECLARE_TYPE(VirtIODevice, VirtioDeviceClass, VIRTIO_DEVICE) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 09818231bd..d4a440e815 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -485,6 +485,9 @@ vhost_user_gpu_guest_notifier_pending(VirtIODevice *vdev, int idx) { VhostUserGPU *g = VHOST_USER_GPU(vdev); + if (idx == VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return vhost_virtqueue_pending(&g->vhost->dev, idx); } @@ -493,6 +496,9 @@ vhost_user_gpu_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) { VhostUserGPU *g = VHOST_USER_GPU(vdev); + if (idx == VIRTIO_CONFIG_IRQ_IDX) { + return; + } vhost_virtqueue_mask(&g->vhost->dev, vdev, idx, mask); } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index cf8ab0f8af..5e03c0dd14 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3168,6 +3168,9 @@ static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx) VirtIONet *n = VIRTIO_NET(vdev); NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(idx)); assert(n->vhost_started); + if (idx == VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return vhost_net_virtqueue_pending(get_vhost_net(nc->peer), idx); } @@ -3177,8 +3180,11 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx, VirtIONet *n = VIRTIO_NET(vdev); NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(idx)); assert(n->vhost_started); - vhost_net_virtqueue_mask(get_vhost_net(nc->peer), - vdev, idx, mask); + if (idx == VIRTIO_CONFIG_IRQ_IDX) { + return; + } + + vhost_net_virtqueue_mask(get_vhost_net(nc->peer), vdev, idx, mask); } static void virtio_net_set_config_size(VirtIONet *n, uint64_t host_features) diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index c595957983..9b0349922e 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -161,6 +161,9 @@ static void vuf_guest_notifier_mask(VirtIODevice *vdev, int idx, { VHostUserFS *fs = VHOST_USER_FS(vdev); + if (idx == VIRTIO_CONFIG_IRQ_IDX) { + return; + } vhost_virtqueue_mask(&fs->vhost_dev, vdev, idx, mask); } @@ -168,6 +171,9 @@ static bool vuf_guest_notifier_pending(VirtIODevice *vdev, int idx) { VHostUserFS *fs = VHOST_USER_FS(vdev); + if (idx == VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return vhost_virtqueue_pending(&fs->vhost_dev, idx); } diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 3f3771274e..d1b9c027b6 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -125,6 +125,9 @@ static void vhost_vsock_common_guest_notifier_mask(VirtIODevice *vdev, int idx, { VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); + if (idx == VIRTIO_CONFIG_IRQ_IDX) { + return; + } vhost_virtqueue_mask(&vvc->vhost_dev, vdev, idx, mask); } @@ -133,6 +136,9 @@ static bool vhost_vsock_common_guest_notifier_pending(VirtIODevice *vdev, { VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); + if (idx == VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return vhost_virtqueue_pending(&vvc->vhost_dev, idx); } diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 54f9bbb789..1d5192f8b4 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -948,6 +948,9 @@ static void virtio_crypto_guest_notifier_mask(VirtIODevice *vdev, int idx, assert(vcrypto->vhost_started); + if (idx == VIRTIO_CONFIG_IRQ_IDX) { + return; + } cryptodev_vhost_virtqueue_mask(vdev, queue, idx, mask); } @@ -958,6 +961,9 @@ static bool virtio_crypto_guest_notifier_pending(VirtIODevice *vdev, int idx) assert(vcrypto->vhost_started); + if (idx == VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return cryptodev_vhost_virtqueue_pending(vdev, queue, idx); } From patchwork Fri Jan 7 11:03:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576554 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QUbK7Lb3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgcc6Zd4z9tjx for ; Fri, 7 Jan 2022 22:15:28 +1100 (AEDT) Received: from localhost ([::1]:59432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nDS-0002Bh-Ow for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:15:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n1q-0006K8-JX for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35135) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n1o-0001iB-EW for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hOPjiFqJP+CxAguLqjRkfscaiAq3ABKE+YBS09bWzw4=; b=QUbK7Lb3t5Vz8Jk3C+wp6V9LFLqY9M2o8bdseE94ecbEQ5HsSHfr0X88x4cgujmW2U6w8u MFVGAlNg5ULigacKaBs4VNKsX9D43JR5UHO9RzntAD19sQnpribPKCKi5VHve1Fg5qgB7U RPrdPD5I5eloZlklwLG7qzYLadgU31E= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-518-52_ylYajO9m-qcYszkqjZw-1; Fri, 07 Jan 2022 06:03:23 -0500 X-MC-Unique: 52_ylYajO9m-qcYszkqjZw-1 Received: by mail-wr1-f69.google.com with SMTP id v1-20020adfc5c1000000b001a37fd2fa2dso2110961wrg.22 for ; Fri, 07 Jan 2022 03:03:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=hOPjiFqJP+CxAguLqjRkfscaiAq3ABKE+YBS09bWzw4=; b=ZrmdmvHqbZq2Te0DCjCRf8GWAQp+Q7DrWhis/69m1CwjJkam+kZzR6XrtYOLwq5bHT JKY6pAOiUTSva8/W5BFqd1cZ/jCJ8WuY+2mWnsfEvdFc7oU8L9Kks+sNHsAzOTTX455D pU7XvcjWUlN1kdKrpPhp0TaizW+0YmPkUOy1TU4ILx6jd4xizdAF5yB1tNEZcPWft5iu BOSeJNM75xl/A0dZ0I0aqP5SQ0Z7KKNaiUDWqr5rq9FzBMLXwnb3Y9eX5rkS267F38RU LibUsMjhOsv1ejuT4b99n90igc44I5d/GyXx7SaIcLscqpW/z85arfZzx6lRSX6G7m0e q0IQ== X-Gm-Message-State: AOAM532QBcFOkaQSf5J8bMjZtNDN9oQGKEumOkr+IDX8jWA9nSrXCFHZ tcc1ey/vsGskkiSfHf5JPi9TKcvBvsI1+Nc0oXSCisXgwt4x+FqjwJ9yRYyIMPB7NhjNofzjI8p u69u4+TwfDSeX7og26udvAeR4RXBxZ/b44cXeskMxFTCgSh7MyE8SUPp+1PBi X-Received: by 2002:a05:600c:1f19:: with SMTP id bd25mr10651730wmb.42.1641553401351; Fri, 07 Jan 2022 03:03:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJytAvspExskL6/NczeItZX7F9Uj7NzUfHcEvRzm4K5x07bgcorp8pAxIpyyWMdxrk6HHYNOfA== X-Received: by 2002:a05:600c:1f19:: with SMTP id bd25mr10651710wmb.42.1641553401027; Fri, 07 Jan 2022 03:03:21 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id g12sm5307611wrd.71.2022.01.07.03.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:20 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 04/55] virtio-pci: decouple notifier from interrupt process Message-ID: <20220107102526.39238-5-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cindy Lu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cindy Lu To reuse the notifier process in configure interrupt. Use the virtio_pci_get_notifier function to get the notifier. the INPUT of this function is the IDX, the OUTPUT is notifier and the vector Signed-off-by: Cindy Lu Message-Id: <20211104164827.21911-3-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 88 +++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 31 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 750aa47ec1..4bdb6e5694 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -704,29 +704,41 @@ static void kvm_virtio_pci_vq_vector_release(VirtIOPCIProxy *proxy, } static int kvm_virtio_pci_irqfd_use(VirtIOPCIProxy *proxy, - unsigned int queue_no, + EventNotifier *n, unsigned int vector) { VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector]; - VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); - VirtQueue *vq = virtio_get_queue(vdev, queue_no); - EventNotifier *n = virtio_queue_get_guest_notifier(vq); return kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, NULL, irqfd->virq); } static void kvm_virtio_pci_irqfd_release(VirtIOPCIProxy *proxy, - unsigned int queue_no, + EventNotifier *n , unsigned int vector) { - VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); - VirtQueue *vq = virtio_get_queue(vdev, queue_no); - EventNotifier *n = virtio_queue_get_guest_notifier(vq); VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector]; int ret; ret = kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, n, irqfd->virq); assert(ret == 0); } +static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no, + EventNotifier **n, unsigned int *vector) +{ + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); + VirtQueue *vq; + + if (queue_no == VIRTIO_CONFIG_IRQ_IDX) { + return -1; + } else { + if (!virtio_queue_get_num(vdev, queue_no)) { + return -1; + } + *vector = virtio_queue_vector(vdev, queue_no); + vq = virtio_get_queue(vdev, queue_no); + *n = virtio_queue_get_guest_notifier(vq); + } + return 0; +} static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs) { @@ -735,12 +747,15 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs) VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); unsigned int vector; int ret, queue_no; - + EventNotifier *n; for (queue_no = 0; queue_no < nvqs; queue_no++) { if (!virtio_queue_get_num(vdev, queue_no)) { break; } - vector = virtio_queue_vector(vdev, queue_no); + ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + break; + } if (vector >= msix_nr_vectors_allocated(dev)) { continue; } @@ -752,7 +767,7 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs) * Otherwise, delay until unmasked in the frontend. */ if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - ret = kvm_virtio_pci_irqfd_use(proxy, queue_no, vector); + ret = kvm_virtio_pci_irqfd_use(proxy, n, vector); if (ret < 0) { kvm_virtio_pci_vq_vector_release(proxy, vector); goto undo; @@ -768,7 +783,11 @@ undo: continue; } if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - kvm_virtio_pci_irqfd_release(proxy, queue_no, vector); + ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + break; + } + kvm_virtio_pci_irqfd_release(proxy, n, vector); } kvm_virtio_pci_vq_vector_release(proxy, vector); } @@ -782,12 +801,16 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs) unsigned int vector; int queue_no; VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); - + EventNotifier *n; + int ret ; for (queue_no = 0; queue_no < nvqs; queue_no++) { if (!virtio_queue_get_num(vdev, queue_no)) { break; } - vector = virtio_queue_vector(vdev, queue_no); + ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + break; + } if (vector >= msix_nr_vectors_allocated(dev)) { continue; } @@ -795,21 +818,20 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs) * Otherwise, it was cleaned when masked in the frontend. */ if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - kvm_virtio_pci_irqfd_release(proxy, queue_no, vector); + kvm_virtio_pci_irqfd_release(proxy, n, vector); } kvm_virtio_pci_vq_vector_release(proxy, vector); } } -static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy, +static int virtio_pci_one_vector_unmask(VirtIOPCIProxy *proxy, unsigned int queue_no, unsigned int vector, - MSIMessage msg) + MSIMessage msg, + EventNotifier *n) { VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); - VirtQueue *vq = virtio_get_queue(vdev, queue_no); - EventNotifier *n = virtio_queue_get_guest_notifier(vq); VirtIOIRQFD *irqfd; int ret = 0; @@ -836,14 +858,15 @@ static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy *proxy, event_notifier_set(n); } } else { - ret = kvm_virtio_pci_irqfd_use(proxy, queue_no, vector); + ret = kvm_virtio_pci_irqfd_use(proxy, n, vector); } return ret; } -static void virtio_pci_vq_vector_mask(VirtIOPCIProxy *proxy, +static void virtio_pci_one_vector_mask(VirtIOPCIProxy *proxy, unsigned int queue_no, - unsigned int vector) + unsigned int vector, + EventNotifier *n) { VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); @@ -854,7 +877,7 @@ static void virtio_pci_vq_vector_mask(VirtIOPCIProxy *proxy, if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { k->guest_notifier_mask(vdev, queue_no, true); } else { - kvm_virtio_pci_irqfd_release(proxy, queue_no, vector); + kvm_virtio_pci_irqfd_release(proxy, n, vector); } } @@ -864,6 +887,7 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, unsigned vector, VirtIOPCIProxy *proxy = container_of(dev, VirtIOPCIProxy, pci_dev); VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); VirtQueue *vq = virtio_vector_first_queue(vdev, vector); + EventNotifier *n; int ret, index, unmasked = 0; while (vq) { @@ -872,7 +896,8 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, unsigned vector, break; } if (index < proxy->nvqs_with_notifiers) { - ret = virtio_pci_vq_vector_unmask(proxy, index, vector, msg); + n = virtio_queue_get_guest_notifier(vq); + ret = virtio_pci_one_vector_unmask(proxy, index, vector, msg, n); if (ret < 0) { goto undo; } @@ -888,7 +913,8 @@ undo: while (vq && unmasked >= 0) { index = virtio_get_queue_index(vq); if (index < proxy->nvqs_with_notifiers) { - virtio_pci_vq_vector_mask(proxy, index, vector); + n = virtio_queue_get_guest_notifier(vq); + virtio_pci_one_vector_mask(proxy, index, vector, n); --unmasked; } vq = virtio_vector_next_queue(vq); @@ -901,15 +927,17 @@ static void virtio_pci_vector_mask(PCIDevice *dev, unsigned vector) VirtIOPCIProxy *proxy = container_of(dev, VirtIOPCIProxy, pci_dev); VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); VirtQueue *vq = virtio_vector_first_queue(vdev, vector); + EventNotifier *n; int index; while (vq) { index = virtio_get_queue_index(vq); + n = virtio_queue_get_guest_notifier(vq); if (!virtio_queue_get_num(vdev, index)) { break; } if (index < proxy->nvqs_with_notifiers) { - virtio_pci_vq_vector_mask(proxy, index, vector); + virtio_pci_one_vector_mask(proxy, index, vector, n); } vq = virtio_vector_next_queue(vq); } @@ -925,19 +953,17 @@ static void virtio_pci_vector_poll(PCIDevice *dev, int queue_no; unsigned int vector; EventNotifier *notifier; - VirtQueue *vq; + int ret; for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) { - if (!virtio_queue_get_num(vdev, queue_no)) { + ret = virtio_pci_get_notifier(proxy, queue_no, ¬ifier, &vector); + if (ret < 0) { break; } - vector = virtio_queue_vector(vdev, queue_no); if (vector < vector_start || vector >= vector_end || !msix_is_masked(dev, vector)) { continue; } - vq = virtio_get_queue(vdev, queue_no); - notifier = virtio_queue_get_guest_notifier(vq); if (k->guest_notifier_pending) { if (k->guest_notifier_pending(vdev, queue_no)) { msix_set_pending(dev, vector); From patchwork Fri Jan 7 11:03:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576543 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BApGejVh; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgMZ6ZGdz9sXM for ; Fri, 7 Jan 2022 22:04:10 +1100 (AEDT) Received: from localhost ([::1]:58012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5n2W-0006W8-5q for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:04:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n1t-0006RA-8D for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47326) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n1r-0001iv-63 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ClYbQ4kuyaz5beNK9wuLMbdICDpNeUV54F3CfDPsyqg=; b=BApGejVh0nklDWITfUIK0uLm9e4qLShx58NyedgbUreQtJW/vM0Op4JL+ZaPzL8YeUXJLU yR95nDVgSU2VBY0YSuVHP3dKWdhIF1TCoElbSTU63IYXbrdsgpOgIQpFk+ayRCR/MtVUVZ CmLUXlSkKXS+rChJtce9sjkpxHhw6r0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-550-5in-s2yoMU-53wIBozuTqg-1; Fri, 07 Jan 2022 06:03:25 -0500 X-MC-Unique: 5in-s2yoMU-53wIBozuTqg-1 Received: by mail-wm1-f70.google.com with SMTP id j18-20020a05600c1c1200b003335872db8dso700958wms.2 for ; Fri, 07 Jan 2022 03:03:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ClYbQ4kuyaz5beNK9wuLMbdICDpNeUV54F3CfDPsyqg=; b=iFy9Iz3f8wJWUJ8hMRnaPzziWmPLaQW1gYv8D0fbvewVjSBPvoDs8L5AkMf1HV7Xqs uqkyOrHszfC9ZBnj7dyZ6BLlYFN3YotnFpgttMqXfG8DhvzP5FlUKdjhXBE2l9XmlqZQ K40hPxsAqT8+4VoORepAUTBXdWx3t6DgIeD1TdvCthxoTyZB+hOllj4fnMNYCV6Vs6op +CJxtRnhymw+UXi7YTiXCvfZJl7AtfOeI+I+NHah5iXZ7E5zhp458HiFuJaC5t7/muH/ gcAZ/B/1pe6JbJiHC0ANBX0cLN9RDZjBwa4SuJS5el6htHZb/36PgG6OpjAeJMQSgZvs HkKA== X-Gm-Message-State: AOAM531ctDCCLbLYjBS173YfRP4yCqhwr+x5BvE8klM3XK0VhuNYcEyI osnMltVYY+alWybkjWKQE2Dtm3wD6fH9mdMSSkQ4Vw/xpDO86cwWuKdgI7cs2JFTq3P8kfp2iX6 iWu4541o7d0dwLLejOnl1LcxKqmBrw24cK06jW8cdFydJS2pnQVY1aGklfEqN X-Received: by 2002:a5d:64a1:: with SMTP id m1mr52776130wrp.503.1641553404130; Fri, 07 Jan 2022 03:03:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxa5IejRFcKPJYlvFkAlIKinY+WkfIKqX+yhxYqHmbAhen0uMEiOULaw6eidW2PUnZFlGHG7g== X-Received: by 2002:a5d:64a1:: with SMTP id m1mr52776108wrp.503.1641553403781; Fri, 07 Jan 2022 03:03:23 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id e12sm4851753wrg.110.2022.01.07.03.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:23 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 05/55] virtio-pci: decouple the single vector from the interrupt process Message-ID: <20220107102526.39238-6-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cindy Lu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cindy Lu To reuse the interrupt process in configure interrupt Need to decouple the single vector from the interrupt process. Add new function kvm_virtio_pci_vector_use_one and _release_one. These functions are use for the single vector, the whole process will finish in a loop for the vq number. Signed-off-by: Cindy Lu Message-Id: <20211104164827.21911-4-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 131 +++++++++++++++++++++++------------------ 1 file changed, 73 insertions(+), 58 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 4bdb6e5694..7201cf3dc1 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -677,7 +677,6 @@ static uint32_t virtio_read_config(PCIDevice *pci_dev, } static int kvm_virtio_pci_vq_vector_use(VirtIOPCIProxy *proxy, - unsigned int queue_no, unsigned int vector) { VirtIOIRQFD *irqfd = &proxy->vector_irqfd[vector]; @@ -740,87 +739,103 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no, return 0; } -static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs) +static int kvm_virtio_pci_vector_use_one(VirtIOPCIProxy *proxy, int queue_no) { + unsigned int vector; + int ret; + EventNotifier *n; PCIDevice *dev = &proxy->pci_dev; VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); - unsigned int vector; - int ret, queue_no; - EventNotifier *n; - for (queue_no = 0; queue_no < nvqs; queue_no++) { - if (!virtio_queue_get_num(vdev, queue_no)) { - break; - } - ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector); - if (ret < 0) { - break; - } - if (vector >= msix_nr_vectors_allocated(dev)) { - continue; - } - ret = kvm_virtio_pci_vq_vector_use(proxy, queue_no, vector); + + ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + return ret; + } + if (vector >= msix_nr_vectors_allocated(dev)) { + return 0; + } + ret = kvm_virtio_pci_vq_vector_use(proxy, vector); + if (ret < 0) { + goto undo; + } + /* + * If guest supports masking, set up irqfd now. + * Otherwise, delay until unmasked in the frontend. + */ + if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { + ret = kvm_virtio_pci_irqfd_use(proxy, n, vector); if (ret < 0) { + kvm_virtio_pci_vq_vector_release(proxy, vector); goto undo; } - /* If guest supports masking, set up irqfd now. - * Otherwise, delay until unmasked in the frontend. - */ - if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - ret = kvm_virtio_pci_irqfd_use(proxy, n, vector); - if (ret < 0) { - kvm_virtio_pci_vq_vector_release(proxy, vector); - goto undo; - } - } } - return 0; + return 0; undo: - while (--queue_no >= 0) { - vector = virtio_queue_vector(vdev, queue_no); - if (vector >= msix_nr_vectors_allocated(dev)) { - continue; + + vector = virtio_queue_vector(vdev, queue_no); + if (vector >= msix_nr_vectors_allocated(dev)) { + return ret; + } + if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { + ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + return ret; } - if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector); - if (ret < 0) { - break; - } - kvm_virtio_pci_irqfd_release(proxy, n, vector); + kvm_virtio_pci_irqfd_release(proxy, n, vector); + } + return ret; +} +static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs) +{ + int queue_no; + int ret = 0; + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); + + for (queue_no = 0; queue_no < nvqs; queue_no++) { + if (!virtio_queue_get_num(vdev, queue_no)) { + return -1; } - kvm_virtio_pci_vq_vector_release(proxy, vector); + ret = kvm_virtio_pci_vector_use_one(proxy, queue_no); } return ret; } -static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs) + +static void kvm_virtio_pci_vector_release_one(VirtIOPCIProxy *proxy, + int queue_no) { - PCIDevice *dev = &proxy->pci_dev; VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); unsigned int vector; - int queue_no; - VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); EventNotifier *n; - int ret ; + int ret; + VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); + PCIDevice *dev = &proxy->pci_dev; + + ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + return; + } + if (vector >= msix_nr_vectors_allocated(dev)) { + return; + } + if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { + kvm_virtio_pci_irqfd_release(proxy, n, vector); + } + kvm_virtio_pci_vq_vector_release(proxy, vector); +} + +static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs) +{ + int queue_no; + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); + for (queue_no = 0; queue_no < nvqs; queue_no++) { if (!virtio_queue_get_num(vdev, queue_no)) { break; } - ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector); - if (ret < 0) { - break; - } - if (vector >= msix_nr_vectors_allocated(dev)) { - continue; - } - /* If guest supports masking, clean up irqfd now. - * Otherwise, it was cleaned when masked in the frontend. - */ - if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - kvm_virtio_pci_irqfd_release(proxy, n, vector); - } - kvm_virtio_pci_vq_vector_release(proxy, vector); + kvm_virtio_pci_vector_release_one(proxy, queue_no); } } From patchwork Fri Jan 7 11:03:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576546 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DikqDfxy; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgSt2PLNz9tjx for ; Fri, 7 Jan 2022 22:08:46 +1100 (AEDT) Received: from localhost ([::1]:40320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5n6x-0005mu-So for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:08:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n1v-0006V5-9C for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53481) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n1t-0001jn-IN for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553409; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=873JIwL0Ssx4x2GI9hqUqv8te9fEzO/xVfFKyB9oXJQ=; b=DikqDfxyg/PzkzoKH86OjfUsDdPfQgDloigYxvq2VgvoA+o6fUpM9Ha3ao1lOAXq30hCj3 xlFMT/ve9sgh/mRSAKVsBAQskTNL2ZXEFLnqvPMGIXnCgjgssidd1ao7lhLWEkjo9tdB72 aOMeYcRkZ+OjElypRluAx3wr0W6gteI= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-9H_6uD27OISFvSTygXtHLQ-1; Fri, 07 Jan 2022 06:03:28 -0500 X-MC-Unique: 9H_6uD27OISFvSTygXtHLQ-1 Received: by mail-wr1-f72.google.com with SMTP id w25-20020adf8bd9000000b001a255212b7cso2092632wra.18 for ; Fri, 07 Jan 2022 03:03:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=873JIwL0Ssx4x2GI9hqUqv8te9fEzO/xVfFKyB9oXJQ=; b=FioH2u5OX481BL1RsdXvc7CiY4YJ9ZqDo3dXybL1I5LuKk8ehn1ULKlPqIIZuXDcae 9NpHj7tlFTtbFCLRKMK43yWHycckCYSDIyvsgFHSn/2R7RiRKdh4VVzrdZA1hung6x7W 0YtlvUASBTd+ofj1P7e9RuQ+0kQv5F0I4ct3mg6O08wXjGe48XWZ62kwbXRrfhVU10y1 6PJwX/bIn/dvZ4oDjZaQ2ycv6iq8pOsw7VFxfgA3x+T+yE+jvW3mOtruRmJ+OmkiklV1 xcaNetdgtvqILenaUs1d8mKWfKbyLCmrN00tXowOTWzsUHaxO628n7n9UJLJa9vQDTMM KSQw== X-Gm-Message-State: AOAM531viJZ8aKjNfk1S68/1vEH77wi4mlfvIHhJhCfXQVXIIIl5ul84 g3MaYwY4OVKkiBYdpZYfk4a6nHvOP39PzW2hhzivZZBIVS0TV6KaqDlgRtY97VVdHqaQjGeXtVZ du6/OKMpOVwLRsgj1TrGW7/wF32wuq3SBt9qKF76fG8PpL4fJ8Nr9O2MEwf61 X-Received: by 2002:adf:f390:: with SMTP id m16mr52821663wro.589.1641553406528; Fri, 07 Jan 2022 03:03:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwYEvmw2Z8LO0Iqlc9Mcy235idzl+vCMcH/j9WenxzoXUiC4g49jAhd7VLNUBNTqs+vXXyxA== X-Received: by 2002:adf:f390:: with SMTP id m16mr52821645wro.589.1641553406271; Fri, 07 Jan 2022 03:03:26 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id m5sm7580168wml.14.2022.01.07.03.03.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:25 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:24 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 06/55] vhost: introduce new VhostOps vhost_set_config_call Message-ID: <20220107102526.39238-7-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cindy Lu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cindy Lu This patch introduces new VhostOps vhost_set_config_call. This function allows the vhost to set the event fd to kernel Signed-off-by: Cindy Lu Message-Id: <20211104164827.21911-5-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-backend.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h index 81bf3109f8..ff34eb7c8a 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -126,6 +126,8 @@ typedef int (*vhost_get_device_id_op)(struct vhost_dev *dev, uint32_t *dev_id); typedef bool (*vhost_force_iommu_op)(struct vhost_dev *dev); +typedef int (*vhost_set_config_call_op)(struct vhost_dev *dev, + int fd); typedef struct VhostOps { VhostBackendType backend_type; vhost_backend_init vhost_backend_init; @@ -171,6 +173,7 @@ typedef struct VhostOps { vhost_vq_get_addr_op vhost_vq_get_addr; vhost_get_device_id_op vhost_get_device_id; vhost_force_iommu_op vhost_force_iommu; + vhost_set_config_call_op vhost_set_config_call; } VhostOps; int vhost_backend_update_device_iotlb(struct vhost_dev *dev, From patchwork Fri Jan 7 11:03:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576545 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CRVrvz/x; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgSW1Tf9z9tk3 for ; Fri, 7 Jan 2022 22:08:27 +1100 (AEDT) Received: from localhost ([::1]:38654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5n6f-0004gY-10 for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:08:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n1x-0006dM-Ut for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:30446) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n1w-0001ks-Do for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553411; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Gv52akJFHQiv170C8mObbPapN00kjPRMbnaS61dDiXs=; b=CRVrvz/xsLGrNtHPTR10W8ZxDQfqGfLkFY32yVlmyubCBxPurNkoMU3Y9PI7q8mG9GmX1K d5H+C8aAV+e4D6Ch+EM/K3/HBgGIXsWURJw2FhhE45q4CpgFUnCUZzsHCC9Tk8gIuWgFD4 WO4yd4XyQfKmodXmU5Z+VO/+kMa4wr8= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-13-ldPrOLCfMkWGZS6RhFf93g-1; Fri, 07 Jan 2022 06:03:31 -0500 X-MC-Unique: ldPrOLCfMkWGZS6RhFf93g-1 Received: by mail-wm1-f72.google.com with SMTP id m15-20020a05600c3b0f00b003465ede5e04so1349786wms.2 for ; Fri, 07 Jan 2022 03:03:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Gv52akJFHQiv170C8mObbPapN00kjPRMbnaS61dDiXs=; b=4dcgHtJ8WebbrQxSNBdAkUznL3uZ8ktiWNiamYQVmgD0m+GTlySiSakONm576gj8Ok MVx2DiO0OzoNqr+83cqyd0gOVVf+a5Cb4PACwJBg/jhNbP0TzzUmR2pDUhYyQo3jLTgW H6pDIVEzJ7fKnOjy8FkVhKCZDaZJHwWHgKAztEUue1kmllS1uqSjE8MKJXEExZkeyVu3 BTV8MNbMFObN4nSEZb3w1Vp0eadj+iYq/HKOXQf/ghx1B3MPqNX+Vnpao/YVkDVw0/0K 1jSNxAg1Sq0xB6KbHL/bTD2blula3sp7m5gQt5T0B330e82w50qW3BLNIkIVB0Uu1MKT W9eQ== X-Gm-Message-State: AOAM531Z/RwoYxnme+rZdBfbmiMLFV2tD3gph5neCy5avXh3mWEQTLIu SxZ+yT9h1ouE3ZrcrQhuws2eYuVpMZCYxHw9tL1TT17QsAj8fkUUOU53Q6g63pidqt2WtjqH/vS NJQpzyE2TDJf2PW0XSJbDd6Jc/gzFl+/QNLaB1PM7EDJTm+vnhanQBtgIjZEg X-Received: by 2002:a7b:c0ce:: with SMTP id s14mr10724503wmh.135.1641553409425; Fri, 07 Jan 2022 03:03:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHpIyG0Xjumrt1f/H9n8R5doq1sTMF/zenriTPQQN0wT1VVDXo2pGoRruKm+1efrKEsbTsbg== X-Received: by 2002:a7b:c0ce:: with SMTP id s14mr10724481wmh.135.1641553409163; Fri, 07 Jan 2022 03:03:29 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id 5sm4549260wrb.77.2022.01.07.03.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:28 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:26 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 07/55] vhost-vdpa: add support for config interrupt Message-ID: <20220107102526.39238-8-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cindy Lu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cindy Lu Add new call back function in vhost-vdpa, this function will set the event fd to kernel. This function will be called in the vhost_dev_start and vhost_dev_stop Signed-off-by: Cindy Lu Message-Id: <20211104164827.21911-6-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vdpa.c | 7 +++++++ hw/virtio/trace-events | 1 + 2 files changed, 8 insertions(+) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index bcaf00e09f..0a4a83713c 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -725,6 +725,12 @@ static int vhost_vdpa_set_vring_call(struct vhost_dev *dev, trace_vhost_vdpa_set_vring_call(dev, file->index, file->fd); return vhost_vdpa_call(dev, VHOST_SET_VRING_CALL, file); } +static int vhost_vdpa_set_config_call(struct vhost_dev *dev, + int fd) +{ + trace_vhost_vdpa_set_config_call(dev, fd); + return vhost_vdpa_call(dev, VHOST_VDPA_SET_CONFIG_CALL, &fd); +} static int vhost_vdpa_get_features(struct vhost_dev *dev, uint64_t *features) @@ -795,4 +801,5 @@ const VhostOps vdpa_ops = { .vhost_get_device_id = vhost_vdpa_get_device_id, .vhost_vq_get_addr = vhost_vdpa_vq_get_addr, .vhost_force_iommu = vhost_vdpa_force_iommu, + .vhost_set_config_call = vhost_vdpa_set_config_call, }; diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index f7ad6be5fb..595ce015ff 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -53,6 +53,7 @@ vhost_vdpa_get_features(void *dev, uint64_t features) "dev: %p features: 0x%"PRI vhost_vdpa_set_owner(void *dev) "dev: %p" vhost_vdpa_vq_get_addr(void *dev, void *vq, uint64_t desc_user_addr, uint64_t avail_user_addr, uint64_t used_user_addr) "dev: %p vq: %p desc_user_addr: 0x%"PRIx64" avail_user_addr: 0x%"PRIx64" used_user_addr: 0x%"PRIx64 vhost_vdpa_get_iova_range(void *dev, uint64_t first, uint64_t last) "dev: %p first: 0x%"PRIx64" last: 0x%"PRIx64 +vhost_vdpa_set_config_call(void *dev, int fd)"dev: %p fd: %d" # virtio.c virtqueue_alloc_element(void *elem, size_t sz, unsigned in_num, unsigned out_num) "elem %p size %zd in_num %u out_num %u" From patchwork Fri Jan 7 11:03:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576550 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KTGqSNjh; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgY04PlDz9tjx for ; Fri, 7 Jan 2022 22:12:20 +1100 (AEDT) Received: from localhost ([::1]:49128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nAQ-0003FC-6B for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:12:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n24-0006tr-FY for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:59209) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n22-0001mW-Ci for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=m0o2ISf2fuLkjyQa6eo4LTXkqbFcr+aoyo0kUY28Ncc=; b=KTGqSNjhjf5vzqBC9GDG1R7w6dTVW2S17RyjT4SJnqyGHT73JwCrxsvgGuoIB6OiC1VaHY YDRIROdaFgOH6REOEkXGaqVDVez+vAJ+x1P1Q1Mn6IQrT/OCX2eLSXYMQBSapf5/bTy6Pv jIoEpToj7L63o3wRVLVlZttTvNCJAAo= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-417-PpEji4TOPe-3UlxLsys5xw-1; Fri, 07 Jan 2022 06:03:33 -0500 X-MC-Unique: PpEji4TOPe-3UlxLsys5xw-1 Received: by mail-wr1-f72.google.com with SMTP id k4-20020adfc704000000b001a32d86a772so2129761wrg.5 for ; Fri, 07 Jan 2022 03:03:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=m0o2ISf2fuLkjyQa6eo4LTXkqbFcr+aoyo0kUY28Ncc=; b=2gzg1bWw+S9h5AtzwGrytIy5XaKc2PnQihKETmfke34NYjKTmqG/M/mXXmj1x2GZZO n+FaS9GtGmKjGv9xldjmScUqdCfyBCPv47lAiMUCp+cfvoxMG23YonGzfQlEBh3FIHHF 2J7+asLmdDfYbyE7n9q2Ggfj1dNWKI6nGo8DtHuaM/OS20TL+kaxJJkM/AbozJQ8qAdp AARJjIGM/nO3gWTqz2oFJd8YlEcbovKzv7thUuBQeXF5bzpfaQtjkeLSx6z3PuzymJqd byzZEvfi8Kx9EPm5toSPhFTWZRAbZOv54vSNLIMktTkzpvZq31DHFlQDwWXKSVqb5Y6U p/Kw== X-Gm-Message-State: AOAM533OugRRwfMXKW1+SNATXqh4xjBnFNAwBcRrVyzj0vC0ZIbXIS0i Gm+l0lvmQOaRjqGvY4hJx7AU9gNVOt4PvZUHodtbRrOp0jweOgsumhcP5XUwHSqBuuCjC2Z5d6f 96y3F400KZtNtk1RxbK73wakUBwhuI+6OOyaXGQGB/I903pWnCARGdICuoBA+ X-Received: by 2002:a05:6000:1377:: with SMTP id q23mr7569045wrz.371.1641553412344; Fri, 07 Jan 2022 03:03:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbvNEFEhKxPhCHH+nwiD7ZLjbq7Y6L/yDuvAf/N4iugfBVujcXiFMRi90z2Y9axx2r/nyC7w== X-Received: by 2002:a05:6000:1377:: with SMTP id q23mr7569020wrz.371.1641553412031; Fri, 07 Jan 2022 03:03:32 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id j11sm537633wrt.5.2022.01.07.03.03.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:31 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:29 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 08/55] virtio: add support for configure interrupt Message-ID: <20220107102526.39238-9-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cindy Lu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cindy Lu Add the functions to support the configure interrupt in virtio The function virtio_config_guest_notifier_read will notify the guest if there is an configure interrupt. The function virtio_config_set_guest_notifier_fd_handler is to set the fd hander for the notifier Signed-off-by: Cindy Lu Message-Id: <20211104164827.21911-7-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 4 ++++ hw/virtio/virtio.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 605ea79c90..d78088d872 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -111,6 +111,7 @@ struct VirtIODevice bool use_guest_notifier_mask; AddressSpace *dma_as; QLIST_HEAD(, VirtQueue) *vector_queues; + EventNotifier config_notifier; }; struct VirtioDeviceClass { @@ -313,11 +314,14 @@ uint16_t virtio_get_queue_index(VirtQueue *vq); EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq); void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign, bool with_irqfd); +void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev, + bool assign, bool with_irqfd); int virtio_device_start_ioeventfd(VirtIODevice *vdev); int virtio_device_grab_ioeventfd(VirtIODevice *vdev); void virtio_device_release_ioeventfd(VirtIODevice *vdev); bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev); EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq); +EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev); void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled); void virtio_queue_host_notifier_read(EventNotifier *n); void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx, diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index e11a8a0dba..36edb1dad5 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3493,7 +3493,14 @@ static void virtio_queue_guest_notifier_read(EventNotifier *n) virtio_irq(vq); } } +static void virtio_config_guest_notifier_read(EventNotifier *n) +{ + VirtIODevice *vdev = container_of(n, VirtIODevice, config_notifier); + if (event_notifier_test_and_clear(n)) { + virtio_notify_config(vdev); + } +} void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign, bool with_irqfd) { @@ -3510,6 +3517,23 @@ void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign, } } +void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev, + bool assign, bool with_irqfd) +{ + EventNotifier *n; + n = &vdev->config_notifier; + if (assign && !with_irqfd) { + event_notifier_set_handler(n, virtio_config_guest_notifier_read); + } else { + event_notifier_set_handler(n, NULL); + } + if (!assign) { + /* Test and clear notifier before closing it,*/ + /* in case poll callback didn't have time to run. */ + virtio_config_guest_notifier_read(n); + } +} + EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq) { return &vq->guest_notifier; @@ -3583,6 +3607,11 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq) return &vq->host_notifier; } +EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev) +{ + return &vdev->config_notifier; +} + void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled) { vq->host_notifier_enabled = enabled; From patchwork Fri Jan 7 11:03:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576548 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=E9okE7ZP; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgW11qGhz9tjx for ; Fri, 7 Jan 2022 22:10:35 +1100 (AEDT) Received: from localhost ([::1]:46696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5n8i-0001Zu-32 for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:10:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n23-0006tW-SM for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41274) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n22-0001mM-1m for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ETB+n0NhBVWLTVk31iuRnbCsPO0dzdop/Y6jcjDWEjk=; b=E9okE7ZP8HrBuFryt6hmMPe6icQBAS6iD1reLttqubbqm9uU91wlbUO+Fy2tZ687+Cl3lj i7ScD3sJmjmkevgldnLChPdD8blEa3oxedbOGh/2st8aWt2RosBb36+0cKEnY6d7h2hfMZ 7ul7bqkD0JKqwLxW7dkq/WX+eONBriI= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-114-eESNXyQpPY66eDoiChwZyA-1; Fri, 07 Jan 2022 06:03:36 -0500 X-MC-Unique: eESNXyQpPY66eDoiChwZyA-1 Received: by mail-wr1-f72.google.com with SMTP id k14-20020adfb34e000000b001a5d060e1edso524306wrd.7 for ; Fri, 07 Jan 2022 03:03:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ETB+n0NhBVWLTVk31iuRnbCsPO0dzdop/Y6jcjDWEjk=; b=Yay+QvL3awCNTGHGbABOESaBW1qn7VoRJTZf4VHed8wONnp+iIUi/VVaqGcuuIeRrl yL0Id1mcChx/PXQjP8h6PxcdvwNwOqzPIzg3zuxw0EE+6kDsuK5q6o4hulDID4YDfc29 xPEqjIqHVEbUsASHTsc0ODxPEWWqsnBYWacvrsdbizVo4rj9sPzbdKJ5GF9mFy219k4A wmEJrYfFEs7li70h/LiPVMXqe44LVW80lar0lMagVMb2PVFr2Lrw1d+8aaQ+B491DhUk 6y/8ilg/QcrW6jBJq63Z+PZovz7fz+uzdeyERP90jW/TccDs3wKqeqscn14BCx3rEcSh adDg== X-Gm-Message-State: AOAM532dUvjmW5Lzuyi5PK/3PzzPrWoDjLBtG+kAMCuxCT5bGrzOUszY jvD5nPOtSa78Yi1yfBcLD3MgWGvbo1SbJ2lFEJ0vSiyOP6Spmugmtvi8O+ZrMaCQnPMpQsDbNxK zM/yvMrM+RXjBo2YEW1CC5+FmG8eEMb8GZ7l1MhTn/WDJRcZPHxUv1FhHyEp1 X-Received: by 2002:adf:cf0c:: with SMTP id o12mr3565272wrj.134.1641553415126; Fri, 07 Jan 2022 03:03:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxSJKnNutm6pzohAqDZbSwEqoyVYWO0GxPV51OpZbrGgLcOBNCimyR4otVKUYQKWMWuTolU+Q== X-Received: by 2002:adf:cf0c:: with SMTP id o12mr3565252wrj.134.1641553414906; Fri, 07 Jan 2022 03:03:34 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id d22sm22451wrb.83.2022.01.07.03.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:34 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:32 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 09/55] vhost: add support for configure interrupt Message-ID: <20220107102526.39238-10-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cindy Lu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cindy Lu Add functions to support configure interrupt. The configure interrupt process will start in vhost_dev_start and stop in vhost_dev_stop. Also add the functions to support vhost_config_pending and vhost_config_mask, for masked_config_notifier, we only use the notifier saved in vq 0. Signed-off-by: Cindy Lu Message-Id: <20211104164827.21911-8-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost.h | 4 +++ hw/virtio/vhost.c | 76 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 58a73e7b7a..b0f3b78987 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -29,6 +29,7 @@ struct vhost_virtqueue { unsigned long long used_phys; unsigned used_size; EventNotifier masked_notifier; + EventNotifier masked_config_notifier; struct vhost_dev *dev; }; @@ -37,6 +38,7 @@ typedef unsigned long vhost_log_chunk_t; #define VHOST_LOG_BITS (8 * sizeof(vhost_log_chunk_t)) #define VHOST_LOG_CHUNK (VHOST_LOG_PAGE * VHOST_LOG_BITS) #define VHOST_INVALID_FEATURE_BIT (0xff) +#define VHOST_QUEUE_NUM_CONFIG_INR 0 struct vhost_log { unsigned long long size; @@ -116,6 +118,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev); void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev); int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev); void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev); +bool vhost_config_pending(struct vhost_dev *hdev); +void vhost_config_mask(struct vhost_dev *hdev, VirtIODevice *vdev, bool mask); /* Test and clear masked event pending status. * Should be called after unmask to avoid losing events. diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 20913cf8fb..98a4b0a0df 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1561,6 +1561,67 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n, } } +bool vhost_config_pending(struct vhost_dev *hdev) +{ + assert(hdev->vhost_ops); + if ((hdev->started == false) || + (hdev->vhost_ops->vhost_set_config_call == NULL)) { + return false; + } + + EventNotifier *notifier = + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier; + return event_notifier_test_and_clear(notifier); +} + +void vhost_config_mask(struct vhost_dev *hdev, VirtIODevice *vdev, bool mask) +{ + int fd; + int r; + EventNotifier *notifier = + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier; + EventNotifier *config_notifier = &vdev->config_notifier; + assert(hdev->vhost_ops); + + if ((hdev->started == false) || + (hdev->vhost_ops->vhost_set_config_call == NULL)) { + return; + } + if (mask) { + assert(vdev->use_guest_notifier_mask); + fd = event_notifier_get_fd(notifier); + } else { + fd = event_notifier_get_fd(config_notifier); + } + r = hdev->vhost_ops->vhost_set_config_call(hdev, fd); + if (r < 0) { + VHOST_OPS_DEBUG("vhost_set_config_call failed"); + } +} + +static void vhost_stop_config_intr(struct vhost_dev *dev) +{ + int fd = -1; + assert(dev->vhost_ops); + if (dev->vhost_ops->vhost_set_config_call) { + dev->vhost_ops->vhost_set_config_call(dev, fd); + } +} + +static void vhost_start_config_intr(struct vhost_dev *dev) +{ + int r; + + assert(dev->vhost_ops); + int fd = event_notifier_get_fd(&dev->vdev->config_notifier); + if (dev->vhost_ops->vhost_set_config_call) { + r = dev->vhost_ops->vhost_set_config_call(dev, fd); + if (!r) { + event_notifier_set(&dev->vdev->config_notifier); + } + } +} + uint64_t vhost_get_features(struct vhost_dev *hdev, const int *feature_bits, uint64_t features) { @@ -1773,6 +1834,16 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) } } + r = event_notifier_init( + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier, 0); + if (r < 0) { + return r; + } + event_notifier_test_and_clear( + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier); + if (!vdev->use_guest_notifier_mask) { + vhost_config_mask(hdev, vdev, true); + } if (hdev->log_enabled) { uint64_t log_base; @@ -1806,6 +1877,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) vhost_device_iotlb_miss(hdev, vq->used_phys, true); } } + vhost_start_config_intr(hdev); return 0; fail_log: vhost_log_put(hdev, false); @@ -1831,6 +1903,9 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev) /* should only be called after backend is connected */ assert(hdev->vhost_ops); + event_notifier_test_and_clear( + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier); + event_notifier_test_and_clear(&vdev->config_notifier); if (hdev->vhost_ops->vhost_dev_start) { hdev->vhost_ops->vhost_dev_start(hdev, false); @@ -1848,6 +1923,7 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev) } memory_listener_unregister(&hdev->iommu_listener); } + vhost_stop_config_intr(hdev); vhost_log_put(hdev, true); hdev->started = false; hdev->vdev = NULL; From patchwork Fri Jan 7 11:03:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576552 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iu7Nvsrb; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgbK1thZz9tjx for ; Fri, 7 Jan 2022 22:14:21 +1100 (AEDT) Received: from localhost ([::1]:55328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nCN-0007rP-1n for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:14:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n26-00071s-JR for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n24-0001nH-So for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553420; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=u6l62xg/lkH7hFw614JZRm2EiTHVevsZtQYv0uk5SXM=; b=iu7NvsrbNxu684ZOaI0soXicc1sL84+IjLPlu2DwgbkdZntwcvccNQ12U44N9vt2aQGfbk byvfvsWi/FxOZtXJ4bt1DfnWn4wZ6Iymtc2CJMFHtuij5+ECAKgnZ4qZxobb+703I3z80M U3iIhuwkQc63XUgYNY0b/w70xl/8ALo= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-597-m0MnKWlEMzS4VXakiy780w-1; Fri, 07 Jan 2022 06:03:39 -0500 X-MC-Unique: m0MnKWlEMzS4VXakiy780w-1 Received: by mail-wm1-f72.google.com with SMTP id c5-20020a1c3505000000b00345c92c27c6so4498679wma.2 for ; Fri, 07 Jan 2022 03:03:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=u6l62xg/lkH7hFw614JZRm2EiTHVevsZtQYv0uk5SXM=; b=OCItcmhOdf6ZDW5dJGLcP08r6tnCEjrOgrGzpRVvFKNK0ERWh+pXuNjPAjqv3n5dIS LSHJ93K4PWEPtSlhmbbTUCui/nklZQjSr3pTosD9RdPcNZAZpgDL7nK9a44g7Yi9Hoja rsRpYQ3q0hAN3Y9Sf2WnfgC+I4ugz9GnfJFhhRao87sxKh5HkjI8UsvW1nhZ2QDsRb3+ 3oSymxArGMzKCXix+Tb0GdWQ3PvA5leEBqXHS8DRLtjs863bkSlHJ1P52coTt50qKmM4 mX2sTx4rYLbl5B7h4+Q4dAmdpy/xOLa4+dMalULy2QmvKnvp9KUwvVCFIlaegiLtTYaD BvGA== X-Gm-Message-State: AOAM533VHyNmhntETHuQZ89eOd6uCPwAG6iQVxLAchyog+oBmxugnFxE rxlEaHrIDplUedc8O8lfZ/BBCRR93CuKj4F6A/8OMOO/wYLnxem0QRcoAN1XwK9T9ABv/IQeFTB ZAi7iyoNhLPjXrsxjPIIJAQzuFaXscjzqMs3ue9gPMLkG43qSvAuoEQzs/455 X-Received: by 2002:adf:c606:: with SMTP id n6mr43439627wrg.481.1641553417889; Fri, 07 Jan 2022 03:03:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCgDpHxGOcJNsK6PbZCp8W9Bjx8Buyjfpe9QEfqbzliR2BIfuvxB77pAR+C3exn27u3fQhPA== X-Received: by 2002:adf:c606:: with SMTP id n6mr43439605wrg.481.1641553417664; Fri, 07 Jan 2022 03:03:37 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id q3sm4553652wrr.55.2022.01.07.03.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:37 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:35 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 10/55] virtio-net: add support for configure interrupt Message-ID: <20220107102526.39238-11-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Cindy Lu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cindy Lu Add functions to support configure interrupt in virtio_net The functions are config_pending and config_mask, while this input idx is VIRTIO_CONFIG_IRQ_IDX will check the function of configure interrupt. Signed-off-by: Cindy Lu Message-Id: <20211104164827.21911-9-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/net/vhost_net.h | 2 ++ hw/net/vhost_net-stub.c | 9 +++++++++ hw/net/vhost_net.c | 9 +++++++++ hw/net/virtio-net.c | 4 ++-- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index 387e913e4e..fc37498550 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -39,6 +39,8 @@ int vhost_net_set_config(struct vhost_net *net, const uint8_t *data, bool vhost_net_virtqueue_pending(VHostNetState *net, int n); void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev, int idx, bool mask); +bool vhost_net_config_pending(VHostNetState *net); +void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mask); int vhost_net_notify_migration_done(VHostNetState *net, char* mac_addr); VHostNetState *get_vhost_net(NetClientState *nc); diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c index 89d71cfb8e..126ee35b70 100644 --- a/hw/net/vhost_net-stub.c +++ b/hw/net/vhost_net-stub.c @@ -101,3 +101,12 @@ int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu) { return 0; } + +bool vhost_net_config_pending(VHostNetState *net) +{ + return false; +} + +void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mask) +{ +} diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 30379d2ca4..9c9fd0a73f 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -457,6 +457,15 @@ void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev, vhost_virtqueue_mask(&net->dev, dev, idx, mask); } +bool vhost_net_config_pending(VHostNetState *net) +{ + return vhost_config_pending(&net->dev); +} + +void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mask) +{ + vhost_config_mask(&net->dev, dev, mask); +} VHostNetState *get_vhost_net(NetClientState *nc) { VHostNetState *vhost_net = 0; diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 5e03c0dd14..5806a50c8d 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3169,7 +3169,7 @@ static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx) NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(idx)); assert(n->vhost_started); if (idx == VIRTIO_CONFIG_IRQ_IDX) { - return false; + return vhost_net_config_pending(get_vhost_net(nc->peer)); } return vhost_net_virtqueue_pending(get_vhost_net(nc->peer), idx); } @@ -3181,9 +3181,9 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx, NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(idx)); assert(n->vhost_started); if (idx == VIRTIO_CONFIG_IRQ_IDX) { + vhost_net_config_mask(get_vhost_net(nc->peer), vdev, mask); return; } - vhost_net_virtqueue_mask(get_vhost_net(nc->peer), vdev, idx, mask); } From patchwork Fri Jan 7 11:03:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576561 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GbOi6NlN; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgpt4fgnz9tjx for ; Fri, 7 Jan 2022 22:24:22 +1100 (AEDT) Received: from localhost ([::1]:48384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nM4-00068S-FM for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:24:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n29-0007BF-3H for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:58786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n27-0001om-JN for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553423; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cSicCZD+rdT4rp9zVpF4X3HF/ofaRyPJFH9NwIHYGDo=; b=GbOi6NlNu4rJOH+8ANVcSt1KmklYTTj4Fh3xupFEdXRrTHfpiWhbnkaq+X4S6OeSrOtdsx JhrLDMhT/E6vxCfNL+wq0aZ3v/MieXPvEt+YIHJ6geVNpyIEdthrJw2mIUshhfkg3jjZw8 ibeos7UgbjxjsdjxYnhglwtZ3rfukqI= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-223-B-htt01kPN-9QbUCKb606A-1; Fri, 07 Jan 2022 06:03:42 -0500 X-MC-Unique: B-htt01kPN-9QbUCKb606A-1 Received: by mail-wr1-f71.google.com with SMTP id a11-20020adffb8b000000b001a0b0f4afe9so2112553wrr.13 for ; Fri, 07 Jan 2022 03:03:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=cSicCZD+rdT4rp9zVpF4X3HF/ofaRyPJFH9NwIHYGDo=; b=DxfFMAmPNDanNrhWTLT9kb8ZPN0TJUATGxP2bkw9nPcGEFI+2u5pw5WI7bYoqJc4DE fDuieXmA4TscdiRTNos2cJEB+VINciGVTbCsczsRHB8ojqc5tAi+qEaRQUA6vNIr/Vmr nv3ah6BYa9a/okgiqdYsMRLVYLoO7iydbjA4bqeY5uRsJRtbG+zEfkYvFdy4kqGTVt8f SROnAR4FoNqJ9KPt/GYGfHUc4bR67OTdGmdWWGB8KM20fhhUKmg6nS7kwS//CGmhrshz A0btezTkAV9dMrQsJkaBCD9EOtUPihvZjRF2pKlejFrhTMaOBtpM+gdOwhrc4N4Gvo/H KP6A== X-Gm-Message-State: AOAM533PDeqHlLcJ1HFidwkM5ylE+k3+kbeOVRZ0194OX5raVB3XZR1W An1bL5e+RB0uGTSrxLNv7nzLiYzPyqBCWoYW3IpF/SxNEsDh/KJcE7M2NqY+H/3zwhX9e7EHZew T5A3a7jZhyBcoboxNSwUgfNb4UrK3alLBR8CHMLDLyTGutM7MGFQRNOwsvKav X-Received: by 2002:a5d:6d4f:: with SMTP id k15mr40361673wri.345.1641553420536; Fri, 07 Jan 2022 03:03:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwolG/GAeijGo9GawYLWpzhB9mAbJLtWnIEoxWO1MfjSBQsjnXhhDruhTmX4mS7LXgRdi6j3Q== X-Received: by 2002:a5d:6d4f:: with SMTP id k15mr40361646wri.345.1641553420203; Fri, 07 Jan 2022 03:03:40 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id g18sm8826020wmq.5.2022.01.07.03.03.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:39 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 11/55] virtio-mmio: add support for configure interrupt Message-ID: <20220107102526.39238-12-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cindy Lu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cindy Lu Add configure interrupt support for virtio-mmio bus. This interrupt will be working while the backend is vhost-vdpa Signed-off-by: Cindy Lu Message-Id: <20211104164827.21911-10-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mmio.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 72da12fea5..809132018b 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -673,7 +673,30 @@ static int virtio_mmio_set_guest_notifier(DeviceState *d, int n, bool assign, return 0; } +static int virtio_mmio_set_config_guest_notifier(DeviceState *d, bool assign) +{ + VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d); + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); + VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); + bool with_irqfd = false; + EventNotifier *notifier = virtio_config_get_guest_notifier(vdev); + int r = 0; + if (assign) { + r = event_notifier_init(notifier, 0); + if (r < 0) { + return r; + } + virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irqfd); + } else { + virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irqfd); + event_notifier_cleanup(notifier); + } + if (vdc->guest_notifier_mask && vdev->use_guest_notifier_mask) { + vdc->guest_notifier_mask(vdev, VIRTIO_CONFIG_IRQ_IDX, !assign); + } + return r; +} static int virtio_mmio_set_guest_notifiers(DeviceState *d, int nvqs, bool assign) { @@ -695,6 +718,10 @@ static int virtio_mmio_set_guest_notifiers(DeviceState *d, int nvqs, goto assign_error; } } + r = virtio_mmio_set_config_guest_notifier(d, assign); + if (r < 0) { + goto assign_error; + } return 0; From patchwork Fri Jan 7 11:03:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576565 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JyEqQ8yl; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgwf1GP3z9tjx for ; Fri, 7 Jan 2022 22:29:22 +1100 (AEDT) Received: from localhost ([::1]:57152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nQt-0005ro-Vw for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:29:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2C-0007Kh-2K for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2A-0001p2-8L for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553425; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5QxedhqdIVW/4TN1ei0pMq/CHa5wdqs2AGGdB1TxsBA=; b=JyEqQ8ylzDNdyqv7O/Rc/qKoUcRYG13hrVk9iCigCAp+8xZT0Kz9D/T694auC1nHim8AOB /nopnp/F9lzj4at6cVInxiuYz8J6SLO6BII1LeVujQuyrjqEu5MRdccERCFYOAOywUOdc9 h7t4whsS3oC47OmuUUpTgtB+hdrQEpY= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-496-WB3QuuhQNN2F6IPRgTgV-w-1; Fri, 07 Jan 2022 06:03:44 -0500 X-MC-Unique: WB3QuuhQNN2F6IPRgTgV-w-1 Received: by mail-wm1-f69.google.com with SMTP id s190-20020a1ca9c7000000b00347c6c39d9aso308866wme.5 for ; Fri, 07 Jan 2022 03:03:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=5QxedhqdIVW/4TN1ei0pMq/CHa5wdqs2AGGdB1TxsBA=; b=FLuf4PWM+wEtbW25lZzYG8UtwHcOPjZVKbF+zDBdCYOn4hkpKT+Gvz0kDDYj3l+H3d E2FUnxHXFUHTd9Xkqm9hFACMY5lXB9uqA0nkEoUwkE1mzKR5RzBm17X1x8yM/bu1CYFB 0BWgTaiNfKBSZJzCV2iEkYvEAAxFEXx3MR+QoywvyJm/zgvSfJMaXH4u5BGLRkyru6rl OUS1wlMDkpBAkgnAShrAdy3OEnsA6Ri/r+QYhfMUtnzeWJS4ZnAttBLSNK6a1jba2MLG H2p/+x8joSQkVjd/g+LveIGeeLGfZ5TmT+clqHcsjU7yo22nsbS0f54yz+ZDMCU6ZWcm spIA== X-Gm-Message-State: AOAM532uWpqoGUcKFhOUpcCG5oCbFCG33CQvcQQf1F+QTIG6Z0BSkOq1 6gz4F2KrMuKh7uj0j8+VsQ4EBiX7Kti/z2OUdrOd8QjRclB7yhlzXzzhrUx3ffm7qa7qY9yjuDV 9OoxXqowGmer6y1znLIiCqHam/9zf2X3f6ZpgAczQ+7wbbrnwHf7tYNAA+RDB X-Received: by 2002:a5d:6691:: with SMTP id l17mr54777537wru.482.1641553423158; Fri, 07 Jan 2022 03:03:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6M6B39FNNBug59OCeyDDhX2EvLD6hdRr/gq9MqzFEglCoPvsucRasla1yblrPZWPth+WaIA== X-Received: by 2002:a5d:6691:: with SMTP id l17mr54777520wru.482.1641553422840; Fri, 07 Jan 2022 03:03:42 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id i6sm5075244wrf.79.2022.01.07.03.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:42 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:40 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 12/55] virtio-pci: add support for configure interrupt Message-ID: <20220107102526.39238-13-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cindy Lu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cindy Lu Add support for configure interrupt, The process is used kvm_irqfd_assign to set the gsi to kernel. When the configure notifier was signal by host, qemu will inject a msix interrupt to guest Signed-off-by: Cindy Lu Message-Id: <20211104164827.21911-11-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.h | 4 +- hw/virtio/virtio-pci.c | 92 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 83 insertions(+), 13 deletions(-) diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index 2446dcd9ae..b704acc5a8 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -251,5 +251,7 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t); * @fixed_queues. */ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); - +void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq, + int n, bool assign, + bool with_irqfd); #endif diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 7201cf3dc1..98fb5493ae 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -727,7 +727,8 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no, VirtQueue *vq; if (queue_no == VIRTIO_CONFIG_IRQ_IDX) { - return -1; + *n = virtio_config_get_guest_notifier(vdev); + *vector = vdev->config_vector; } else { if (!virtio_queue_get_num(vdev, queue_no)) { return -1; @@ -802,6 +803,10 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *proxy, int nvqs) return ret; } +static int kvm_virtio_pci_vector_config_use(VirtIOPCIProxy *proxy) +{ + return kvm_virtio_pci_vector_use_one(proxy, VIRTIO_CONFIG_IRQ_IDX); +} static void kvm_virtio_pci_vector_release_one(VirtIOPCIProxy *proxy, int queue_no) @@ -839,6 +844,11 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIProxy *proxy, int nvqs) } } +static void kvm_virtio_pci_vector_config_release(VirtIOPCIProxy *proxy) +{ + kvm_virtio_pci_vector_release_one(proxy, VIRTIO_CONFIG_IRQ_IDX); +} + static int virtio_pci_one_vector_unmask(VirtIOPCIProxy *proxy, unsigned int queue_no, unsigned int vector, @@ -920,9 +930,17 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, unsigned vector, } vq = virtio_vector_next_queue(vq); } - + /* unmask config intr */ + n = virtio_config_get_guest_notifier(vdev); + ret = virtio_pci_one_vector_unmask(proxy, VIRTIO_CONFIG_IRQ_IDX, vector, + msg, n); + if (ret < 0) { + goto undo_config; + } return 0; - +undo_config: + n = virtio_config_get_guest_notifier(vdev); + virtio_pci_one_vector_mask(proxy, VIRTIO_CONFIG_IRQ_IDX, vector, n); undo: vq = virtio_vector_first_queue(vdev, vector); while (vq && unmasked >= 0) { @@ -956,6 +974,8 @@ static void virtio_pci_vector_mask(PCIDevice *dev, unsigned vector) } vq = virtio_vector_next_queue(vq); } + n = virtio_config_get_guest_notifier(vdev); + virtio_pci_one_vector_mask(proxy, VIRTIO_CONFIG_IRQ_IDX, vector, n); } static void virtio_pci_vector_poll(PCIDevice *dev, @@ -987,6 +1007,34 @@ static void virtio_pci_vector_poll(PCIDevice *dev, msix_set_pending(dev, vector); } } + /* poll the config intr */ + ret = virtio_pci_get_notifier(proxy, VIRTIO_CONFIG_IRQ_IDX, ¬ifier, + &vector); + if (ret < 0) { + return; + } + if (vector < vector_start || vector >= vector_end || + !msix_is_masked(dev, vector)) { + return; + } + if (k->guest_notifier_pending) { + if (k->guest_notifier_pending(vdev, VIRTIO_CONFIG_IRQ_IDX)) { + msix_set_pending(dev, vector); + } + } else if (event_notifier_test_and_clear(notifier)) { + msix_set_pending(dev, vector); + } +} + +void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq, + int n, bool assign, + bool with_irqfd) +{ + if (n == VIRTIO_CONFIG_IRQ_IDX) { + virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irqfd); + } else { + virtio_queue_set_guest_notifier_fd_handler(vq, assign, with_irqfd); + } } static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign, @@ -995,17 +1043,25 @@ static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assign, VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d); VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); - VirtQueue *vq = virtio_get_queue(vdev, n); - EventNotifier *notifier = virtio_queue_get_guest_notifier(vq); + VirtQueue *vq = NULL; + EventNotifier *notifier = NULL; + + if (n == VIRTIO_CONFIG_IRQ_IDX) { + notifier = virtio_config_get_guest_notifier(vdev); + } else { + vq = virtio_get_queue(vdev, n); + notifier = virtio_queue_get_guest_notifier(vq); + } if (assign) { int r = event_notifier_init(notifier, 0); if (r < 0) { return r; } - virtio_queue_set_guest_notifier_fd_handler(vq, true, with_irqfd); + virtio_pci_set_guest_notifier_fd_handler(vdev, vq, n, true, with_irqfd); } else { - virtio_queue_set_guest_notifier_fd_handler(vq, false, with_irqfd); + virtio_pci_set_guest_notifier_fd_handler(vdev, vq, n, false, + with_irqfd); event_notifier_cleanup(notifier); } @@ -1047,6 +1103,7 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign) msix_unset_vector_notifiers(&proxy->pci_dev); if (proxy->vector_irqfd) { kvm_virtio_pci_vector_release(proxy, nvqs); + kvm_virtio_pci_vector_config_release(proxy); g_free(proxy->vector_irqfd); proxy->vector_irqfd = NULL; } @@ -1062,7 +1119,11 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign) goto assign_error; } } - + r = virtio_pci_set_guest_notifier(d, VIRTIO_CONFIG_IRQ_IDX, assign, + with_irqfd); + if (r < 0) { + goto config_assign_error; + } /* Must set vector notifier after guest notifier has been assigned */ if ((with_irqfd || k->guest_notifier_mask) && assign) { if (with_irqfd) { @@ -1071,11 +1132,14 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign) msix_nr_vectors_allocated(&proxy->pci_dev)); r = kvm_virtio_pci_vector_use(proxy, nvqs); if (r < 0) { - goto assign_error; + goto config_assign_error; } } - r = msix_set_vector_notifiers(&proxy->pci_dev, - virtio_pci_vector_unmask, + r = kvm_virtio_pci_vector_config_use(proxy); + if (r < 0) { + goto config_error; + } + r = msix_set_vector_notifiers(&proxy->pci_dev, virtio_pci_vector_unmask, virtio_pci_vector_mask, virtio_pci_vector_poll); if (r < 0) { @@ -1090,7 +1154,11 @@ notifiers_error: assert(assign); kvm_virtio_pci_vector_release(proxy, nvqs); } - +config_error: + kvm_virtio_pci_vector_config_release(proxy); +config_assign_error: + virtio_pci_set_guest_notifier(d, VIRTIO_CONFIG_IRQ_IDX, !assign, + with_irqfd); assign_error: /* We get here on assignment failure. Recover by undoing for VQs 0 .. n. */ assert(assign); From patchwork Fri Jan 7 11:03:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576556 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YERIBamW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVggY1qCVz9tjx for ; Fri, 7 Jan 2022 22:18:01 +1100 (AEDT) Received: from localhost ([::1]:35782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nFu-0005P5-Na for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:17:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2F-0007UR-74 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38580) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2D-0001pK-8s for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553428; 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=n1iLjx4SHThqUNpgxKUlFJfbmdTeh8ixg5DBOW9i3IU=; b=YERIBamWbptOfrBKBN1AyxtrlyeCkAIgNX5jAjHfXFP3WGItFZhlRXLbogir1gdJNGLS6S WYF+i7M8QjQqSYg7XcvC/473+Z/c5G1lppjEkwbx2JUczIFanH2Z5vVybKQzP0kFZkRtcp 41TI4zzzMvWp5HJlz0NzccN9gouYdyI= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-39-M6-XiOpwMu6MELXKfS8lYQ-1; Fri, 07 Jan 2022 06:03:47 -0500 X-MC-Unique: M6-XiOpwMu6MELXKfS8lYQ-1 Received: by mail-wm1-f70.google.com with SMTP id c5-20020a1c3505000000b00345c92c27c6so4498824wma.2 for ; Fri, 07 Jan 2022 03:03:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=n1iLjx4SHThqUNpgxKUlFJfbmdTeh8ixg5DBOW9i3IU=; b=FCZqx8mWVzkwz31fTKqgYfnHJZe+Yz5V7wuG/fUYRUb6ZoF3th+B7ikQAyqx77/yhA 9ogf8LzPHkY43jCC+LNVagh/iDisShQwMI5XBvARDEafalN0IJ/koDBEQ44VgbL9dYcA Zrpr+/5bpnZAgVvELlUa5ucDALfEU556dyU2oHj4MpWDYwMnU6LoFB30fqjKvLJA9SxH EYr+K8FwpXEqmF/TqKgc+8lrV/1b1F9OpHs5g8IqaO385h8lL3p5x6bJIQYOadAXPelJ lCNaDOKlArTZRT0T/Gcb4cxwLp/mJEfTb/jHFTjokAQ82GQW2j3C7bz5ZGejfr9R03LW GIIA== X-Gm-Message-State: AOAM530SGnlVaLBTlK0uOf8MS9P7MCcw4SkzGJ5nf+InBz/tWEe3nsEd uugDV7GuxGsGdNPyQaAi6tfnzVVvFZUGmTAUZ7TOz3ll+w4l4YSL2bmT748LfAZmxCw7HyzV2u2 Oum3fX9jIk02KlIJMIiSfn2M05VaBiSL4lcXcIsxCK4VuB+bgaYlubQvnah+j X-Received: by 2002:a05:600c:3643:: with SMTP id y3mr10909245wmq.54.1641553425995; Fri, 07 Jan 2022 03:03:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+dgX47hnzw+2Tqrn86Mywn40BjJLkLpvQbEI9sCkvNw/tdK1vzNnjWjP8x5aQeJmb+os7oA== X-Received: by 2002:a05:600c:3643:: with SMTP id y3mr10909225wmq.54.1641553425754; Fri, 07 Jan 2022 03:03:45 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id b14sm4776030wri.112.2022.01.07.03.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:45 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 13/55] trace-events,pci: unify trace events format Message-ID: <20220107102526.39238-14-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Yanan Wang , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier Unify format used by trace_pci_update_mappings_del(), trace_pci_update_mappings_add(), trace_pci_cfg_write() and trace_pci_cfg_read() to print the device name and bus number, slot number and function number. For instance: pci_cfg_read virtio-net-pci 00:0 @0x20 -> 0xffffc00c pci_cfg_write virtio-net-pci 00:0 @0x20 <- 0xfea0000c pci_update_mappings_del d=0x555810b92330 01:00.0 4,0xffffc000+0x4000 pci_update_mappings_add d=0x555810b92330 01:00.0 4,0xfea00000+0x4000 becomes pci_cfg_read virtio-net-pci 01:00.0 @0x20 -> 0xffffc00c pci_cfg_write virtio-net-pci 01:00.0 @0x20 <- 0xfea0000c pci_update_mappings_del virtio-net-pci 01:00.0 4,0xffffc000+0x4000 pci_update_mappings_add virtio-net-pci 01:00.0 4,0xfea00000+0x4000 Signed-off-by: Laurent Vivier Message-Id: <20211105192541.655831-1-lvivier@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Yanan Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pci.c | 4 ++-- hw/pci/pci_host.c | 6 ++++-- hw/pci/trace-events | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e5993c1ef5..322ba450e7 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1390,7 +1390,7 @@ static void pci_update_mappings(PCIDevice *d) /* now do the real mapping */ if (r->addr != PCI_BAR_UNMAPPED) { - trace_pci_update_mappings_del(d, pci_dev_bus_num(d), + trace_pci_update_mappings_del(d->name, pci_dev_bus_num(d), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn), i, r->addr, r->size); @@ -1398,7 +1398,7 @@ static void pci_update_mappings(PCIDevice *d) } r->addr = new_addr; if (r->addr != PCI_BAR_UNMAPPED) { - trace_pci_update_mappings_add(d, pci_dev_bus_num(d), + trace_pci_update_mappings_add(d->name, pci_dev_bus_num(d), PCI_SLOT(d->devfn), PCI_FUNC(d->devfn), i, r->addr, r->size); diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index 7beafd40a8..eaf217ff55 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -79,7 +79,8 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uint32_t addr, return; } - trace_pci_cfg_write(pci_dev->name, PCI_SLOT(pci_dev->devfn), + trace_pci_cfg_write(pci_dev->name, pci_dev_bus_num(pci_dev), + PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn), addr, val); pci_dev->config_write(pci_dev, addr, val, MIN(len, limit - addr)); } @@ -104,7 +105,8 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr, } ret = pci_dev->config_read(pci_dev, addr, MIN(len, limit - addr)); - trace_pci_cfg_read(pci_dev->name, PCI_SLOT(pci_dev->devfn), + trace_pci_cfg_read(pci_dev->name, pci_dev_bus_num(pci_dev), + PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn), addr, ret); return ret; diff --git a/hw/pci/trace-events b/hw/pci/trace-events index fc777d0b5e..7570752c40 100644 --- a/hw/pci/trace-events +++ b/hw/pci/trace-events @@ -1,12 +1,12 @@ # See docs/devel/tracing.rst for syntax documentation. # pci.c -pci_update_mappings_del(void *d, uint32_t bus, uint32_t slot, uint32_t func, int bar, uint64_t addr, uint64_t size) "d=%p %02x:%02x.%x %d,0x%"PRIx64"+0x%"PRIx64 -pci_update_mappings_add(void *d, uint32_t bus, uint32_t slot, uint32_t func, int bar, uint64_t addr, uint64_t size) "d=%p %02x:%02x.%x %d,0x%"PRIx64"+0x%"PRIx64 +pci_update_mappings_del(const char *dev, uint32_t bus, uint32_t slot, uint32_t func, int bar, uint64_t addr, uint64_t size) "%s %02x:%02x.%x %d,0x%"PRIx64"+0x%"PRIx64 +pci_update_mappings_add(const char *dev, uint32_t bus, uint32_t slot, uint32_t func, int bar, uint64_t addr, uint64_t size) "%s %02x:%02x.%x %d,0x%"PRIx64"+0x%"PRIx64 # pci_host.c -pci_cfg_read(const char *dev, unsigned devid, unsigned fnid, unsigned offs, unsigned val) "%s %02u:%u @0x%x -> 0x%x" -pci_cfg_write(const char *dev, unsigned devid, unsigned fnid, unsigned offs, unsigned val) "%s %02u:%u @0x%x <- 0x%x" +pci_cfg_read(const char *dev, uint32_t bus, uint32_t slot, uint32_t func, unsigned offs, unsigned val) "%s %02x:%02x.%x @0x%x -> 0x%x" +pci_cfg_write(const char *dev, uint32_t bus, uint32_t slot, uint32_t func, unsigned offs, unsigned val) "%s %02x:%02x.%x @0x%x <- 0x%x" # msix.c msix_write_config(char *name, bool enabled, bool masked) "dev %s enabled %d masked %d" From patchwork Fri Jan 7 11:03:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576559 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=g8uWJK36; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVglq3HBKz9tjx for ; Fri, 7 Jan 2022 22:21:41 +1100 (AEDT) Received: from localhost ([::1]:44394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nJS-0002jo-LJ for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:21:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2H-0007aD-F0 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2F-0001q0-Px for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=igipHoFkqG9ZkUxoX09dBUcpAVne7E9NONhvrwx9lW4=; b=g8uWJK36Qs9Zv41V7UuZjIqqY4Ht3rX89i1/ud70qMoliheIPXB5x9I5GDA6J6fphUQpmd CFAV0HUjZlf2+jcPY7izJ0QxGjwOECWMWhwZQVTU1JdhZ9TLq78ll+VydhjskCm+bO7PKz qrNQ6FDFdUfQbwk1ryuEWqJvy9HA8Lk= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-10-WSSzkhwgNpuMqcQ7dUZyuw-1; Fri, 07 Jan 2022 06:03:50 -0500 X-MC-Unique: WSSzkhwgNpuMqcQ7dUZyuw-1 Received: by mail-wm1-f71.google.com with SMTP id m15-20020a7bce0f000000b003473d477618so1969553wmc.8 for ; Fri, 07 Jan 2022 03:03:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=igipHoFkqG9ZkUxoX09dBUcpAVne7E9NONhvrwx9lW4=; b=OgqCoES55XfcA697CvuREQvVGQ5Rzv06UxckiDxJ+4+B2FvDCPXaU3SoELpVwCTvS7 z+jy1x4DXodeeDrWYAbXD/AVC5Nuc5YW5xfJtiMsYcJW+Mz8oNx1nK1Qc+bhrSChiiQu f8Rp0zSSXD89/8q+qsNADaFGNAs+yLv9RB11WsuenAjF7b7HySfzVFTNawM1FqQwHZyP mlFenSjsA651zxQWpBAMVaOOZUcECJsLZ9rPUZCIG5Nv1pTdIH3kvC7+SJbTugEtKIkh 61Z43a2PAi9jVXJLuk0Sfqzs13JeuL26Vd9z0YQkMOY7ESeqycgjuGCy1HVVebfCcasg 3QJg== X-Gm-Message-State: AOAM531/4DZ2jNNNikONlTLVSarxI7A7Omj7SdGPY1BPR//V/N2oPMGA NZlgSGBVXaNrL218lSw4/Oi4Duta9EEB1/JMT8JE0rNZ7nF3++xDHtgYPCIAze0oMP9R51f74il YLxC+1gBrpuIxvo8NNNh3Pq+S6HWVf6HWjkwO5mYMt/sK3CGERLz/T5aP7Wbj X-Received: by 2002:adf:d21b:: with SMTP id j27mr8345077wrh.381.1641553429000; Fri, 07 Jan 2022 03:03:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbEPX3htG5I/RDaRHR2NUunJSFURn8o4d99aOutFgSXGED1QayyTDoZbLdV6eyQKygPmXRdQ== X-Received: by 2002:adf:d21b:: with SMTP id j27mr8345049wrh.381.1641553428724; Fri, 07 Jan 2022 03:03:48 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id m15sm5103562wrw.27.2022.01.07.03.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:48 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:45 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 14/55] vhost-user-blk: reconnect on any error during realize Message-ID: <20220107102526.39238-15-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Raphael Norwitz , Roman Kagan , Hanna Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Roman Kagan vhost-user-blk realize only attempts to reconnect if the previous connection attempt failed on "a problem with the connection and not an error related to the content (which would fail again the same way in the next attempt)". However this distinction is very subtle, and may be inadvertently broken if the code changes somewhere deep down the stack and a new error gets propagated up to here. OTOH now that the number of reconnection attempts is limited it seems harmless to try reconnecting on any error. So relax the condition of whether to retry connecting to check for any error. This patch amends a527e312b5 "vhost-user-blk: Implement reconnection during realize". Signed-off-by: Roman Kagan Message-Id: <20211111153354.18807-2-rvkagan@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index ba13cb87e5..f9b17f6813 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -511,7 +511,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) *errp = NULL; } ret = vhost_user_blk_realize_connect(s, errp); - } while (ret == -EPROTO && retries--); + } while (ret < 0 && retries--); if (ret < 0) { goto virtio_err; From patchwork Fri Jan 7 11:03:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576549 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DZPiaXJ6; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgW5629Fz9tjx for ; Fri, 7 Jan 2022 22:10:41 +1100 (AEDT) Received: from localhost ([::1]:47318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5n8p-0001z7-Bu for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:10:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2K-0007jv-9i for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:55872) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2I-0001qH-Op for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:03:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553434; 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=v/nf9E9axwJOMcdCAGncabD48HF9k+D1ZiFHnSo9Ej0=; b=DZPiaXJ66e089+zS1CrqbPBMblZb6fwzX2V/tyiGvB4ub3ZZaRTx12BImcD1IeTHT0HtO/ rykuesJpy1Z/7QEydKfuifnaOCae1J/98AasAkJqFOG1T+zwcSH1dl2XoMfx09Ot11CfSU deR2KFeC8dMkAksT9ndMMP+2SMzyM9M= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-659-pK7FzylwPrCQft1xXE_1lg-1; Fri, 07 Jan 2022 06:03:53 -0500 X-MC-Unique: pK7FzylwPrCQft1xXE_1lg-1 Received: by mail-wr1-f70.google.com with SMTP id d14-20020adfa34e000000b001a631cb3ab5so376096wrb.12 for ; Fri, 07 Jan 2022 03:03:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=v/nf9E9axwJOMcdCAGncabD48HF9k+D1ZiFHnSo9Ej0=; b=TpgcsV31dHeu6D1w1GxRO7Uk2RHnfl3SYcCEbojH0cT9riH+vaRRHd1GUop6jcfzzS nQse8wLRtWFlN3p+7bsu0PG0TFLxMLMgxgNh8FAsS536lY2l3UR12pYBbOUdvy13WAbR 8IBh3gsYv1TVuImg+RtBGtXQEgVZ+2iIh5t++kcCptf2t9283uLQdgZJH5qlRQc4Mmu3 xx6gpI54J2Fb2MMYWm6e/FHR6Y3Djk6UvvAdtOaMxKbeaWCKEW93TdHovNKV/Ljxnpjs N3MJiFbDtegkCJS3RytaPL2MMRhxLdwUdGnHXsh0GGu/6AVwIF3BnPvbjAbIBVrIF25P rajg== X-Gm-Message-State: AOAM530pNobWvMvf2APE85rTspZL9FzaOlFolJe1aHeJqZjNKlyGaCgF Ww4kIYZe/RwFAXfHDZaPM0kdYrX4Ixwmf1eBztSv6ckoiqKaYrgHN0icIbjubzMG5CHmYp3NXUM NsN0WIOBBkNoIpa3lVBKRnZEkyRqc7PBJXZX0Q3QzO3pmfxrlMNSHhu/G7EGp X-Received: by 2002:a5d:5689:: with SMTP id f9mr52830779wrv.124.1641553431556; Fri, 07 Jan 2022 03:03:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzG3GaLtVoU80mirfdugtAhPxwPXBA9r/Iq9kBqMv7dkqiUxFM+ktqkcQ3naH6ixtdtAmfh3Q== X-Received: by 2002:a5d:5689:: with SMTP id f9mr52830761wrv.124.1641553431379; Fri, 07 Jan 2022 03:03:51 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id b5sm4374463wrr.19.2022.01.07.03.03.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:51 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:48 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 15/55] chardev/char-socket: tcp_chr_recv: don't clobber errno Message-ID: <20220107102526.39238-16-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Kagan , Peter Maydell , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Roman Kagan tcp_chr_recv communicates the specific error condition to the caller via errno. However, after setting it, it may call into some system calls or library functions which can clobber the errno. Avoid this by moving the errno assignment to the end of the function. Signed-off-by: Roman Kagan Message-Id: <20211111153354.18807-3-rvkagan@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marc-André Lureau --- chardev/char-socket.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index d619088232..3ddd98ed49 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -290,13 +290,6 @@ static ssize_t tcp_chr_recv(Chardev *chr, char *buf, size_t len) NULL); } - if (ret == QIO_CHANNEL_ERR_BLOCK) { - errno = EAGAIN; - ret = -1; - } else if (ret == -1) { - errno = EIO; - } - if (msgfds_num) { /* close and clean read_msgfds */ for (i = 0; i < s->read_msgfds_num; i++) { @@ -325,6 +318,13 @@ static ssize_t tcp_chr_recv(Chardev *chr, char *buf, size_t len) #endif } + if (ret == QIO_CHANNEL_ERR_BLOCK) { + errno = EAGAIN; + ret = -1; + } else if (ret == -1) { + errno = EIO; + } + return ret; } From patchwork Fri Jan 7 11:03:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576553 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bpCSmCZc; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgbZ2Fbmz9tjx for ; Fri, 7 Jan 2022 22:14:34 +1100 (AEDT) Received: from localhost ([::1]:56056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nCa-0008KX-3I for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:14:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2S-00085k-0n for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2M-0001qX-UK for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553437; 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=5NmSRsYDHdSt3mPPWE/VBrC0tl4EEty9M7O4eh0ePIo=; b=bpCSmCZchtE21Je62Rr5T6qVGzbrf1iQN4hsbLqIp3px3uZuaNUJ6VJ7Q0s1O6aXiVTQo/ sT4mdYa86uZJlceT2mHw9Mw1c+Q68opgRCUOXIwS6uoxwuVgc3mwPH4qY27ZGUrgPU7YEm WRnWLaDZdrT4FPnjT9FDtrD/Fmeciww= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-201-RCIEq3PDO1uhqBU_XecL6w-1; Fri, 07 Jan 2022 06:03:55 -0500 X-MC-Unique: RCIEq3PDO1uhqBU_XecL6w-1 Received: by mail-wm1-f71.google.com with SMTP id ay41-20020a05600c1e2900b00345a568e6b2so1348118wmb.4 for ; Fri, 07 Jan 2022 03:03:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=5NmSRsYDHdSt3mPPWE/VBrC0tl4EEty9M7O4eh0ePIo=; b=xNRAIDim97AgDyR8+pPCN6vrpbyz5Y45htZitaNUsGaFHdD/ylc+LWghu996oXzDPN ZNOTFITKeCFbVS069zFIU1fXUTHBca/RhIoKjLH6DxKhoRYqsemnF6teTvKeAhzoS2hP IyLKUuXx+EnbPdMthkqZcXMcZ0eQYIV5n8V/g906svWuWgA6zOiTq/xAS224ekTpJ0LH mxkaHBNR8bqK39nwa0/dL/+GV17xcSDHc+mIq/UV62xxP+cQVYDOeyyKJi8pF/zQJECf uBtoTo3MSVcSJCrXLIZTEEoRWyQdCQLp3XIU/2ZessG+GbXUEAoYrsMIiIIMlQ2v0f06 LawA== X-Gm-Message-State: AOAM531dXw8jpawAVbHm/yqBd8ggJsi4RaVu4Uxdg7Im+dM9Ls3BSAbm h0z6J+4cC3msuj6kn4e/jCLSYRmoZQqHuXBCrgcNjfLnPFR7OqfTZH0xvLG2nY3/fPZwWWH2B9F DkXDwiXVmasfPyFp7o5EtT3pqYO14LyLVWN372aQEL+Sz3L+3zuZJ1xRP2Vxn X-Received: by 2002:a5d:648b:: with SMTP id o11mr53390060wri.227.1641553434228; Fri, 07 Jan 2022 03:03:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyV7jnNP5g2bl4dFTRUdN7sWzahHLo/O0QtLsscxj8i7mwToyTedUE52xSLaDjpH2xQOd4sBw== X-Received: by 2002:a5d:648b:: with SMTP id o11mr53390041wri.227.1641553434045; Fri, 07 Jan 2022 03:03:54 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id s8sm5240127wra.9.2022.01.07.03.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:53 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:51 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 16/55] chardev/char-socket: tcp_chr_sync_read: don't clobber errno Message-ID: <20220107102526.39238-17-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Kagan , Peter Maydell , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Roman Kagan After the return from tcp_chr_recv, tcp_chr_sync_read calls into a function which eventually makes a system call and may clobber errno. Make a copy of errno right after tcp_chr_recv and restore the errno on return from tcp_chr_sync_read. Signed-off-by: Roman Kagan Message-Id: <20211111153354.18807-4-rvkagan@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Marc-André Lureau --- chardev/char-socket.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 3ddd98ed49..fab2d791d4 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -525,6 +525,7 @@ static int tcp_chr_sync_read(Chardev *chr, const uint8_t *buf, int len) { SocketChardev *s = SOCKET_CHARDEV(chr); int size; + int saved_errno; if (s->state != TCP_CHARDEV_STATE_CONNECTED) { return 0; @@ -532,6 +533,7 @@ static int tcp_chr_sync_read(Chardev *chr, const uint8_t *buf, int len) qio_channel_set_blocking(s->ioc, true, NULL); size = tcp_chr_recv(chr, (void *) buf, len); + saved_errno = errno; if (s->state != TCP_CHARDEV_STATE_DISCONNECTED) { qio_channel_set_blocking(s->ioc, false, NULL); } @@ -540,6 +542,7 @@ static int tcp_chr_sync_read(Chardev *chr, const uint8_t *buf, int len) tcp_chr_disconnect(chr); } + errno = saved_errno; return size; } From patchwork Fri Jan 7 11:03:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576563 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GhcGDQg2; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgvT0yqzz9tjx for ; Fri, 7 Jan 2022 22:28:19 +1100 (AEDT) Received: from localhost ([::1]:53158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nPr-0001rH-V7 for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:28:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2T-0008AG-Pk for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24794) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2N-0001qn-Ru for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553439; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HL8XzqiOuXS/c6MYdg/W1pc8MJs/HABojwX8X2NfKmA=; b=GhcGDQg2uSDcMn3zZZbK8GZ6yc6fi0/h2ZFaPBX30B7WCabaWsrP/wIZBaX/0vYITxrcf2 kfl8FxDpUqRzAYvbQQqTxtH+n6j+/gbGpaBV1ymnwncRtC0n21aEybrk9EvZQiC6P7LFyK Ean2618wwhokPXsMAaN/dIB2sbDM284= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-225-tPE1HUUpMKCB3miult7-BA-1; Fri, 07 Jan 2022 06:03:58 -0500 X-MC-Unique: tPE1HUUpMKCB3miult7-BA-1 Received: by mail-wr1-f72.google.com with SMTP id t28-20020adf97dc000000b001a5b98d2c81so578497wrb.3 for ; Fri, 07 Jan 2022 03:03:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HL8XzqiOuXS/c6MYdg/W1pc8MJs/HABojwX8X2NfKmA=; b=m1+hq6ijODeyofdQSH0j82cLiL4NzTEzstevWeJap+Vh5DocdKLSIML3oQDJ95si+u sQl+kOQyi9kf0ORLf6U4cpMR3uFT0ikv7yHZULpdgjwqwaobiQsMcOwIRSPNQ0ZGV1JT POiaFh0NCR7w9RJ6+dIjFMLmOXnLgtCRMMENIBAGiYcv093vj8Fe+72cbwcDGCIbn/Kz PiwZRfIck74HULKWTGYAE1Fr6KbpdpxD+Zp3nEfDy0P/wzZRUgbkeVVzZiblZs0JnxuF Yeno8EAB3hAgC+i6XrqW8uxLOIt6ZzWrDIJB2Uc1NOsMJP90mEUNhZlnB1cdJGqBVctG 73tA== X-Gm-Message-State: AOAM530GGBGBXUJ1wKTit88tb6fSbwY+zagYv5oAOIeHTx7Pgjo7pQSd 6y+Imp5A7wW+s9lunHdRioUUTtu2vd/QT7sh4y7046zSP4cczWGeEyq11ivzHZ+TkQihW9TN54r S0jNeF3tEMhyYCIxaEnwmGDFHUlCnOdceNgXffeDxTyhDlV7y98+hj0Ykrpt9 X-Received: by 2002:a05:6000:168c:: with SMTP id y12mr56215047wrd.409.1641553437096; Fri, 07 Jan 2022 03:03:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJw02eB/rHFXGk5PNTo+eAU+uTYeHfFyzX4SUIyEbcjWuMMq+XMVZ1PJ7wpHkxfUmTcL9C2ucA== X-Received: by 2002:a05:6000:168c:: with SMTP id y12mr56215033wrd.409.1641553436910; Fri, 07 Jan 2022 03:03:56 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id s22sm7739323wmc.1.2022.01.07.03.03.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:56 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:54 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 17/55] vhost-backend: avoid overflow on memslots_limit Message-ID: <20220107102526.39238-18-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Kagan , Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Roman Kagan Fix the (hypothetical) potential problem when the value parsed out of the vhost module parameter in sysfs overflows the return value from vhost_kernel_memslots_limit. Signed-off-by: Roman Kagan Message-Id: <20211111153354.18807-6-rvkagan@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index b65f8f7e97..44f7dbb243 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -58,7 +58,7 @@ static int vhost_kernel_memslots_limit(struct vhost_dev *dev) if (g_file_get_contents("/sys/module/vhost/parameters/max_mem_regions", &s, NULL, NULL)) { uint64_t val = g_ascii_strtoull(s, NULL, 10); - if (!((val == G_MAXUINT64 || !val) && errno)) { + if (val < INT_MAX && val > 0) { g_free(s); return val; } From patchwork Fri Jan 7 11:03:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576558 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=fA5RwpN1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgjz5GT7z9tjx for ; Fri, 7 Jan 2022 22:20:07 +1100 (AEDT) Received: from localhost ([::1]:40716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nHv-0000HI-Ps for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:20:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2Y-0008NS-TU for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:30918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2W-0001rq-8i for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553447; 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=mNzO3BmzKsU9XDhTDAgKzBlwWRwUQVLphv/ivYXligU=; b=fA5RwpN1Vumad5yvWasvC1CL9YOBMHUM4dHZPOlnr1l4h1/arxGy10JURXpiyLSFUewI5A jV1N7wTFhUXv3RKQeNDPQNC4f5gU7SRKJ4nhm1biK+bpnMs6Mqk1zdDjwghnuGy+dvvEaZ qkKr2KGHzFynilfw6YjiIlE++ri7NXY= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-377-0UkaKcBROZO2FvGAmNtgNA-1; Fri, 07 Jan 2022 06:04:01 -0500 X-MC-Unique: 0UkaKcBROZO2FvGAmNtgNA-1 Received: by mail-wm1-f72.google.com with SMTP id s190-20020a1ca9c7000000b00347c6c39d9aso309114wme.5 for ; Fri, 07 Jan 2022 03:04:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=mNzO3BmzKsU9XDhTDAgKzBlwWRwUQVLphv/ivYXligU=; b=PH+8AbUJpQYOm/tpOAB8c2AP3bo9DIZbqtGrRbxYTf0f4zelAIYgRrKZPTLKTwje8A /ihi5WcFoNgK2IOlMLAz0tr6KdHuhZ2ZneDeCd04zPDgNXuQPx/4xm19njDWTXrU0zWf tSyRfA43dXp6SSGf3kuEGnnf75PQBofqh+XLL/XivCY/eeoqzfHTtPMvBksFtPjoLKHA nWe9WWYQYqmrICF6mvJRvIny/8KOOdKy3H/EtaEzCzDrAi8Rom8uTYKzI3F1FcuTTVfc qKIcA70lml+HfI+JDTGcbzkaN+UxTiwfXHXNQuxm/gxrfTnQKcVzB3y1lUbKzgX1G8es wECA== X-Gm-Message-State: AOAM533BCIwtOYIDrYtAhoj9hh+hmUh1F3zHdKl8BjRpTawmiSJNNSj7 d4w8cki0Pb7NezIzChthTCzZklvbKuPiexvfJSIObJcQJZySixRXH7sI06gf7tUJdGLSdgs+3qc 4GoLtqrylhR0sFQLMRm5qmHtM3uH0ZwemKKEhhl8JNMspDlFDD6cmPm/DHIhM X-Received: by 2002:a05:6000:154c:: with SMTP id 12mr54184247wry.447.1641553439993; Fri, 07 Jan 2022 03:03:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJytNh5EhZo43ZN+Ku8G2tFsEu2jTVKuNOtmFDW33svOxz/QuZBNwgAaVD4XMZgKwMWww41k4Q== X-Received: by 2002:a05:6000:154c:: with SMTP id 12mr54184235wry.447.1641553439776; Fri, 07 Jan 2022 03:03:59 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id e12sm4853225wrg.110.2022.01.07.03.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:03:59 -0800 (PST) Date: Fri, 7 Jan 2022 06:03:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 18/55] vhost-backend: stick to -errno error return convention Message-ID: <20220107102526.39238-19-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Kagan , Peter Maydell , Philippe =?utf-8?q?Mathieu-Daud?= =?utf-8?q?=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Roman Kagan Almost all VhostOps methods in kernel_ops follow the convention of returning negated errno on error. Adjust the only one that doesn't. Signed-off-by: Roman Kagan Message-Id: <20211111153354.18807-7-rvkagan@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé --- hw/virtio/vhost-backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 44f7dbb243..e409a865ae 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -47,7 +47,7 @@ static int vhost_kernel_cleanup(struct vhost_dev *dev) assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_KERNEL); - return close(fd); + return close(fd) < 0 ? -errno : 0; } static int vhost_kernel_memslots_limit(struct vhost_dev *dev) From patchwork Fri Jan 7 11:04:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576555 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gQ2bkGnF; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgd42PC0z9tjx for ; Fri, 7 Jan 2022 22:15:50 +1100 (AEDT) Received: from localhost ([::1]:60450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nDn-0002rL-JC for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:15:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2V-0008EA-3U for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38030) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2T-0001rC-Gb for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553445; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Z6+ogC/x1lapccbXRX0wQz+1ayPjtYGNbtjSlz3Drok=; b=gQ2bkGnFHAEflEdVkHt5+4z2rduXn8fnsPVq5wPRcgqvuZnRvNxTkPWm/3VACNTAGExiVJ Rlgh+PVf7UlLVM/aK/u/a0vmCnMkH5fagF9lymTNAxk5nA892Hj1wDXZH/YpwfD1/HEv2x +b+8RXl9SrXvsSAhtuVq/kK9oQZDBfg= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-507-BTDcjSEAMiGpGLXBQdhLig-1; Fri, 07 Jan 2022 06:04:04 -0500 X-MC-Unique: BTDcjSEAMiGpGLXBQdhLig-1 Received: by mail-wr1-f69.google.com with SMTP id r10-20020adfa14a000000b001a375e65e60so2118557wrr.2 for ; Fri, 07 Jan 2022 03:04:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Z6+ogC/x1lapccbXRX0wQz+1ayPjtYGNbtjSlz3Drok=; b=C7d/sGNajw28oKsMCxWb2Uki3rGRe7H19Fy1eJhnuHUWc2Dl4jnX7102WoohxGkE3G XkzI0jH4vsX/cvf/AIlQ2gjJHwc+YW3kZ6bqkXRse3U2/P0q8kyF6jNJ25vtdxh/N8fq UWQleSKfWfAYsIHWa+B/+gQUsNArmEnnNXsLqWmlLxUDNmKXrFIi5SstZtNBD1uG8kgg WQQoEVEzIepUzBNEjNvWWbQhZI0udfgKGEs0tRBVyPvgUMDf71s8fsawU3J9i1W9m2Sh JmuoITOA/cwxZQGZjJIaffzsk25qlze/jNjzNCqbovmvj4xhhmavW7d65LTD7TzH7KhQ wUFg== X-Gm-Message-State: AOAM533GXTL5kxwWaLoe/F/cOgPjPK2IIUCtLaf8wWP3yMLyv1gWwvRj nqt3kSKqJVXAJcxQA010eXQEdrQ5sB43ruSxLyprgiJhWMFBxD6exRMg3mO5gQ/NO/f+DFmFPWL UCj5BYxhLH1g+EGtyMu+2/1ddo9qIz9wolD+9mYKJb6Jvwr7MRCN9o5SM0xjZ X-Received: by 2002:a05:600c:3508:: with SMTP id h8mr10536100wmq.143.1641553442508; Fri, 07 Jan 2022 03:04:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfzodPm7kfsdwy8gpqkUbuS3HWi+Zy8LEGFS3zonSwkvqiR5bYF0sQTNwn9S7vSQkXh8z1Tg== X-Received: by 2002:a05:600c:3508:: with SMTP id h8mr10536076wmq.143.1641553442276; Fri, 07 Jan 2022 03:04:02 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id m10sm4108364wms.25.2022.01.07.03.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:01 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:00 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 19/55] vhost-vdpa: stick to -errno error return convention Message-ID: <20220107102526.39238-20-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Kagan , Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Roman Kagan Almost all VhostOps methods in vdpa_ops follow the convention of returning negated errno on error. Adjust the few that don't. To that end, rework vhost_vdpa_add_status to check if setting of the requested status bits has succeeded and return the respective error code it hasn't, and propagate the error codes wherever it's appropriate. Signed-off-by: Roman Kagan Message-Id: <20211111153354.18807-8-rvkagan@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vdpa.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 0a4a83713c..ac0cb575fb 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -292,18 +292,34 @@ static int vhost_vdpa_call(struct vhost_dev *dev, unsigned long int request, return ret < 0 ? -errno : ret; } -static void vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status) +static int vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status) { uint8_t s; + int ret; trace_vhost_vdpa_add_status(dev, status); - if (vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &s)) { - return; + ret = vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &s); + if (ret < 0) { + return ret; } s |= status; - vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &s); + ret = vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &s); + if (ret < 0) { + return ret; + } + + ret = vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &s); + if (ret < 0) { + return ret; + } + + if (!(s & status)) { + return -EIO; + } + + return 0; } static void vhost_vdpa_get_iova_range(struct vhost_vdpa *v) @@ -484,7 +500,7 @@ static int vhost_vdpa_set_mem_table(struct vhost_dev *dev, } } if (mem->padding) { - return -1; + return -EINVAL; } return 0; @@ -501,14 +517,11 @@ static int vhost_vdpa_set_features(struct vhost_dev *dev, trace_vhost_vdpa_set_features(dev, features); ret = vhost_vdpa_call(dev, VHOST_SET_FEATURES, &features); - uint8_t status = 0; if (ret) { return ret; } - vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK); - vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &status); - return !(status & VIRTIO_CONFIG_S_FEATURES_OK); + return vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK); } static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev) @@ -650,12 +663,8 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started) } if (started) { - uint8_t status = 0; memory_listener_register(&v->listener, &address_space_memory); - vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); - vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &status); - - return !(status & VIRTIO_CONFIG_S_DRIVER_OK); + return vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); } else { vhost_vdpa_reset_device(dev); vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | From patchwork Fri Jan 7 11:04:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576569 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=izs5Q2c0; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVh1w2SBNz9tjx for ; Fri, 7 Jan 2022 22:33:54 +1100 (AEDT) Received: from localhost ([::1]:38356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nVH-0006Pj-Co for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:33:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2c-00008l-Be for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2Y-0001s1-E5 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0HgL78aMlUDVeLrG/7WuhOod06OvAxzf1VnxIoO8wCw=; b=izs5Q2c0aSmSjY0JflSqCR6mlT1x9/KmLwqUaZ4Ky4P0R9kqr8myY9xxyvBcQkb/CjKc1D OEUpdoiRDAHEXcrRt5WkEswaHHObOoXdXf7Ju/FALSB9iWxxUT9dRewMCXmUw0E7k4Gtzc MQ2GX8lKKpjmd3rPGnwGE9h9JyYcEpM= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-492-k98e_bVlMXe6V_YNmaSPJQ-1; Fri, 07 Jan 2022 06:04:08 -0500 X-MC-Unique: k98e_bVlMXe6V_YNmaSPJQ-1 Received: by mail-wm1-f70.google.com with SMTP id c5-20020a1c3505000000b00345c92c27c6so4499200wma.2 for ; Fri, 07 Jan 2022 03:04:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0HgL78aMlUDVeLrG/7WuhOod06OvAxzf1VnxIoO8wCw=; b=pjZjV+a2r6S7xFSFs6IGMa9gR+ONrDW/WGzuWMdqe4VtRGz68wM4QdIGcLhnoCS/c8 qsZAP9qMvstd+0ouGgvBx/7LxaS3bxPeClwia9IVMJYu5WlsJPic1vd1IxkGZ0bPjNZ8 Pg8GARkRzV5X8i3xg5vWrYYpkqtj8PeDH95Qew4e0zFzqHxjUVpKMaOWzy8ygqu3Hwe4 sKyncPi61OR0VQLHUJOrB4aLpFPRwXJdGzCymbu4YGhJDE0DP8Y4IqErlB7nF/JTelVd xHSD/zHMK/PFJpbrtQX2Jre5f1WD8HmW4KYlcyJa2Fd3PYoxVBQR3c5ejVGFcQ4kkL0X 5zfA== X-Gm-Message-State: AOAM530zsG9A4S55ztyWp++pt3XLYiduNvCHRoQN3RdZ+KZI8HkdWSyE ye2Sl7LtTYn7sXZZ9ByEdQhyHi+nxOYuRVjrK7frM4JxbjWeZ7T2A5l8IYJb85tx9SYbYY6U0j5 Z5nGzsNepBeHMTpCk20BiKX4s1zrCqt4iseYAbyFZQXJadCRxw798EZUiKsvf X-Received: by 2002:a5d:658c:: with SMTP id q12mr53616293wru.34.1641553446220; Fri, 07 Jan 2022 03:04:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPx9l1WD28DatqWXkG/yMr/PQNBE6GnlXHhXovGz/i6ib7NIMLs7wn42aOeoF4STBfZzDttA== X-Received: by 2002:a5d:658c:: with SMTP id q12mr53616250wru.34.1641553445559; Fri, 07 Jan 2022 03:04:05 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id r9sm4615175wrm.76.2022.01.07.03.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:05 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:02 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 20/55] vhost-user: stick to -errno error return convention Message-ID: <20220107102526.39238-21-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Kagan , Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Roman Kagan VhostOps methods in user_ops are not very consistent in their error returns: some return negated errno while others just -1. Make sure all of them consistently return negated errno. This also helps error propagation from the functions being called inside. Besides, this synchronizes the error return convention with the other two vhost backends, kernel and vdpa, and will therefore allow for consistent error propagation in the generic vhost code (in a followup patch). Signed-off-by: Roman Kagan Message-Id: <20211111153354.18807-9-rvkagan@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user.c | 401 +++++++++++++++++++++++------------------ 1 file changed, 223 insertions(+), 178 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index bf6e50223c..662853513e 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -280,9 +280,10 @@ static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg) r = qemu_chr_fe_read_all(chr, p, size); if (r != size) { + int saved_errno = errno; error_report("Failed to read msg header. Read %d instead of %d." " Original request %d.", r, size, msg->hdr.request); - return -1; + return r < 0 ? -saved_errno : -EIO; } /* validate received flags */ @@ -290,7 +291,7 @@ static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg) error_report("Failed to read msg header." " Flags 0x%x instead of 0x%x.", msg->hdr.flags, VHOST_USER_REPLY_MASK | VHOST_USER_VERSION); - return -1; + return -EPROTO; } return 0; @@ -314,8 +315,9 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition, uint8_t *p = (uint8_t *) msg; int r, size; - if (vhost_user_read_header(dev, msg) < 0) { - data->ret = -1; + r = vhost_user_read_header(dev, msg); + if (r < 0) { + data->ret = r; goto end; } @@ -324,7 +326,7 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition, error_report("Failed to read msg header." " Size %d exceeds the maximum %zu.", msg->hdr.size, VHOST_USER_PAYLOAD_SIZE); - data->ret = -1; + data->ret = -EPROTO; goto end; } @@ -333,9 +335,10 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition, size = msg->hdr.size; r = qemu_chr_fe_read_all(chr, p, size); if (r != size) { + int saved_errno = errno; error_report("Failed to read msg payload." " Read %d instead of %d.", r, msg->hdr.size); - data->ret = -1; + data->ret = r < 0 ? -saved_errno : -EIO; goto end; } } @@ -418,24 +421,26 @@ static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg) static int process_message_reply(struct vhost_dev *dev, const VhostUserMsg *msg) { + int ret; VhostUserMsg msg_reply; if ((msg->hdr.flags & VHOST_USER_NEED_REPLY_MASK) == 0) { return 0; } - if (vhost_user_read(dev, &msg_reply) < 0) { - return -1; + ret = vhost_user_read(dev, &msg_reply); + if (ret < 0) { + return ret; } if (msg_reply.hdr.request != msg->hdr.request) { error_report("Received unexpected msg type. " "Expected %d received %d", msg->hdr.request, msg_reply.hdr.request); - return -1; + return -EPROTO; } - return msg_reply.payload.u64 ? -1 : 0; + return msg_reply.payload.u64 ? -EIO : 0; } static bool vhost_user_one_time_request(VhostUserRequest request) @@ -472,14 +477,15 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg, if (qemu_chr_fe_set_msgfds(chr, fds, fd_num) < 0) { error_report("Failed to set msg fds."); - return -1; + return -EINVAL; } ret = qemu_chr_fe_write_all(chr, (const uint8_t *) msg, size); if (ret != size) { + int saved_errno = errno; error_report("Failed to write msg." " Wrote %d instead of %d.", ret, size); - return -1; + return ret < 0 ? -saved_errno : -EIO; } return 0; @@ -502,6 +508,7 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, size_t fd_num = 0; bool shmfd = virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_LOG_SHMFD); + int ret; VhostUserMsg msg = { .hdr.request = VHOST_USER_SET_LOG_BASE, .hdr.flags = VHOST_USER_VERSION, @@ -514,21 +521,23 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, fds[fd_num++] = log->fd; } - if (vhost_user_write(dev, &msg, fds, fd_num) < 0) { - return -1; + ret = vhost_user_write(dev, &msg, fds, fd_num); + if (ret < 0) { + return ret; } if (shmfd) { msg.hdr.size = 0; - if (vhost_user_read(dev, &msg) < 0) { - return -1; + ret = vhost_user_read(dev, &msg); + if (ret < 0) { + return ret; } if (msg.hdr.request != VHOST_USER_SET_LOG_BASE) { error_report("Received unexpected msg type. " "Expected %d received %d", VHOST_USER_SET_LOG_BASE, msg.hdr.request); - return -1; + return -EPROTO; } } @@ -588,7 +597,7 @@ static int vhost_user_fill_set_mem_table_msg(struct vhost_user *u, u->region_rb[i] = mr->ram_block; } else if (*fd_num == VHOST_MEMORY_BASELINE_NREGIONS) { error_report("Failed preparing vhost-user memory table msg"); - return -1; + return -ENOBUFS; } vhost_user_fill_msg_region(®ion_buffer, reg, offset); msg->payload.memory.regions[*fd_num] = region_buffer; @@ -604,14 +613,14 @@ static int vhost_user_fill_set_mem_table_msg(struct vhost_user *u, if (!*fd_num) { error_report("Failed initializing vhost-user memory map, " "consider using -object memory-backend-file share=on"); - return -1; + return -EINVAL; } msg->hdr.size = sizeof(msg->payload.memory.nregions); msg->hdr.size += sizeof(msg->payload.memory.padding); msg->hdr.size += *fd_num * sizeof(VhostUserMemoryRegion); - return 1; + return 0; } static inline bool reg_equal(struct vhost_memory_region *shadow_reg, @@ -741,8 +750,9 @@ static int send_remove_regions(struct vhost_dev *dev, vhost_user_fill_msg_region(®ion_buffer, shadow_reg, 0); msg->payload.mem_reg.region = region_buffer; - if (vhost_user_write(dev, msg, &fd, 1) < 0) { - return -1; + ret = vhost_user_write(dev, msg, &fd, 1); + if (ret < 0) { + return ret; } if (reply_supported) { @@ -801,15 +811,17 @@ static int send_add_regions(struct vhost_dev *dev, vhost_user_fill_msg_region(®ion_buffer, reg, offset); msg->payload.mem_reg.region = region_buffer; - if (vhost_user_write(dev, msg, &fd, 1) < 0) { - return -1; + ret = vhost_user_write(dev, msg, &fd, 1); + if (ret < 0) { + return ret; } if (track_ramblocks) { uint64_t reply_gpa; - if (vhost_user_read(dev, &msg_reply) < 0) { - return -1; + ret = vhost_user_read(dev, &msg_reply); + if (ret < 0) { + return ret; } reply_gpa = msg_reply.payload.mem_reg.region.guest_phys_addr; @@ -819,7 +831,7 @@ static int send_add_regions(struct vhost_dev *dev, "Expected %d received %d", __func__, VHOST_USER_ADD_MEM_REG, msg_reply.hdr.request); - return -1; + return -EPROTO; } /* @@ -830,7 +842,7 @@ static int send_add_regions(struct vhost_dev *dev, error_report("%s: Unexpected size for postcopy reply " "%d vs %d", __func__, msg_reply.hdr.size, msg->hdr.size); - return -1; + return -EPROTO; } /* Get the postcopy client base from the backend's reply. */ @@ -846,7 +858,7 @@ static int send_add_regions(struct vhost_dev *dev, "Got guest physical address %" PRIX64 ", expected " "%" PRIX64, __func__, reply_gpa, dev->mem->regions[reg_idx].guest_phys_addr); - return -1; + return -EPROTO; } } else if (reply_supported) { ret = process_message_reply(dev, msg); @@ -887,6 +899,7 @@ static int vhost_user_add_remove_regions(struct vhost_dev *dev, struct scrub_regions rem_reg[VHOST_USER_MAX_RAM_SLOTS]; uint64_t shadow_pcb[VHOST_USER_MAX_RAM_SLOTS] = {}; int nr_add_reg, nr_rem_reg; + int ret; msg->hdr.size = sizeof(msg->payload.mem_reg); @@ -894,16 +907,20 @@ static int vhost_user_add_remove_regions(struct vhost_dev *dev, scrub_shadow_regions(dev, add_reg, &nr_add_reg, rem_reg, &nr_rem_reg, shadow_pcb, track_ramblocks); - if (nr_rem_reg && send_remove_regions(dev, rem_reg, nr_rem_reg, msg, - reply_supported) < 0) - { - goto err; + if (nr_rem_reg) { + ret = send_remove_regions(dev, rem_reg, nr_rem_reg, msg, + reply_supported); + if (ret < 0) { + goto err; + } } - if (nr_add_reg && send_add_regions(dev, add_reg, nr_add_reg, msg, - shadow_pcb, reply_supported, track_ramblocks) < 0) - { - goto err; + if (nr_add_reg) { + ret = send_add_regions(dev, add_reg, nr_add_reg, msg, shadow_pcb, + reply_supported, track_ramblocks); + if (ret < 0) { + goto err; + } } if (track_ramblocks) { @@ -918,8 +935,9 @@ static int vhost_user_add_remove_regions(struct vhost_dev *dev, msg->hdr.size = sizeof(msg->payload.u64); msg->payload.u64 = 0; /* OK */ - if (vhost_user_write(dev, msg, NULL, 0) < 0) { - return -1; + ret = vhost_user_write(dev, msg, NULL, 0); + if (ret < 0) { + return ret; } } @@ -931,7 +949,7 @@ err: sizeof(uint64_t) * VHOST_USER_MAX_RAM_SLOTS); } - return -1; + return ret; } static int vhost_user_set_mem_table_postcopy(struct vhost_dev *dev, @@ -944,6 +962,7 @@ static int vhost_user_set_mem_table_postcopy(struct vhost_dev *dev, size_t fd_num = 0; VhostUserMsg msg_reply; int region_i, msg_i; + int ret; VhostUserMsg msg = { .hdr.flags = VHOST_USER_VERSION, @@ -961,29 +980,32 @@ static int vhost_user_set_mem_table_postcopy(struct vhost_dev *dev, } if (config_mem_slots) { - if (vhost_user_add_remove_regions(dev, &msg, reply_supported, - true) < 0) { - return -1; + ret = vhost_user_add_remove_regions(dev, &msg, reply_supported, true); + if (ret < 0) { + return ret; } } else { - if (vhost_user_fill_set_mem_table_msg(u, dev, &msg, fds, &fd_num, - true) < 0) { - return -1; + ret = vhost_user_fill_set_mem_table_msg(u, dev, &msg, fds, &fd_num, + true); + if (ret < 0) { + return ret; } - if (vhost_user_write(dev, &msg, fds, fd_num) < 0) { - return -1; + ret = vhost_user_write(dev, &msg, fds, fd_num); + if (ret < 0) { + return ret; } - if (vhost_user_read(dev, &msg_reply) < 0) { - return -1; + ret = vhost_user_read(dev, &msg_reply); + if (ret < 0) { + return ret; } if (msg_reply.hdr.request != VHOST_USER_SET_MEM_TABLE) { error_report("%s: Received unexpected msg type." "Expected %d received %d", __func__, VHOST_USER_SET_MEM_TABLE, msg_reply.hdr.request); - return -1; + return -EPROTO; } /* @@ -994,7 +1016,7 @@ static int vhost_user_set_mem_table_postcopy(struct vhost_dev *dev, error_report("%s: Unexpected size for postcopy reply " "%d vs %d", __func__, msg_reply.hdr.size, msg.hdr.size); - return -1; + return -EPROTO; } memset(u->postcopy_client_bases, 0, @@ -1024,7 +1046,7 @@ static int vhost_user_set_mem_table_postcopy(struct vhost_dev *dev, error_report("%s: postcopy reply not fully consumed " "%d vs %zd", __func__, msg_i, fd_num); - return -1; + return -EIO; } /* @@ -1035,8 +1057,9 @@ static int vhost_user_set_mem_table_postcopy(struct vhost_dev *dev, /* TODO: Use this for failure cases as well with a bad value. */ msg.hdr.size = sizeof(msg.payload.u64); msg.payload.u64 = 0; /* OK */ - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } } @@ -1055,6 +1078,7 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev, bool config_mem_slots = virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS); + int ret; if (do_postcopy) { /* @@ -1074,17 +1098,20 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev, } if (config_mem_slots) { - if (vhost_user_add_remove_regions(dev, &msg, reply_supported, - false) < 0) { - return -1; + ret = vhost_user_add_remove_regions(dev, &msg, reply_supported, false); + if (ret < 0) { + return ret; } } else { - if (vhost_user_fill_set_mem_table_msg(u, dev, &msg, fds, &fd_num, - false) < 0) { - return -1; + ret = vhost_user_fill_set_mem_table_msg(u, dev, &msg, fds, &fd_num, + false); + if (ret < 0) { + return ret; } - if (vhost_user_write(dev, &msg, fds, fd_num) < 0) { - return -1; + + ret = vhost_user_write(dev, &msg, fds, fd_num); + if (ret < 0) { + return ret; } if (reply_supported) { @@ -1109,14 +1136,10 @@ static int vhost_user_set_vring_endian(struct vhost_dev *dev, if (!cross_endian) { error_report("vhost-user trying to send unhandled ioctl"); - return -1; + return -ENOTSUP; } - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; - } - - return 0; + return vhost_user_write(dev, &msg, NULL, 0); } static int vhost_set_vring(struct vhost_dev *dev, @@ -1130,11 +1153,7 @@ static int vhost_set_vring(struct vhost_dev *dev, .hdr.size = sizeof(msg.payload.state), }; - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; - } - - return 0; + return vhost_user_write(dev, &msg, NULL, 0); } static int vhost_user_set_vring_num(struct vhost_dev *dev, @@ -1182,16 +1201,25 @@ static int vhost_user_set_vring_enable(struct vhost_dev *dev, int enable) int i; if (!virtio_has_feature(dev->features, VHOST_USER_F_PROTOCOL_FEATURES)) { - return -1; + return -EINVAL; } for (i = 0; i < dev->nvqs; ++i) { + int ret; struct vhost_vring_state state = { .index = dev->vq_index + i, .num = enable, }; - vhost_set_vring(dev, VHOST_USER_SET_VRING_ENABLE, &state); + ret = vhost_set_vring(dev, VHOST_USER_SET_VRING_ENABLE, &state); + if (ret < 0) { + /* + * Restoring the previous state is likely infeasible, as well as + * proceeding regardless the error, so just bail out and hope for + * the device-level recovery. + */ + return ret; + } } return 0; @@ -1200,6 +1228,7 @@ static int vhost_user_set_vring_enable(struct vhost_dev *dev, int enable) static int vhost_user_get_vring_base(struct vhost_dev *dev, struct vhost_vring_state *ring) { + int ret; VhostUserMsg msg = { .hdr.request = VHOST_USER_GET_VRING_BASE, .hdr.flags = VHOST_USER_VERSION, @@ -1209,23 +1238,25 @@ static int vhost_user_get_vring_base(struct vhost_dev *dev, vhost_user_host_notifier_remove(dev, ring->index); - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } - if (vhost_user_read(dev, &msg) < 0) { - return -1; + ret = vhost_user_read(dev, &msg); + if (ret < 0) { + return ret; } if (msg.hdr.request != VHOST_USER_GET_VRING_BASE) { error_report("Received unexpected msg type. Expected %d received %d", VHOST_USER_GET_VRING_BASE, msg.hdr.request); - return -1; + return -EPROTO; } if (msg.hdr.size != sizeof(msg.payload.state)) { error_report("Received bad msg size."); - return -1; + return -EPROTO; } *ring = msg.payload.state; @@ -1252,11 +1283,7 @@ static int vhost_set_vring_file(struct vhost_dev *dev, msg.payload.u64 |= VHOST_USER_VRING_NOFD_MASK; } - if (vhost_user_write(dev, &msg, fds, fd_num) < 0) { - return -1; - } - - return 0; + return vhost_user_write(dev, &msg, fds, fd_num); } static int vhost_user_set_vring_kick(struct vhost_dev *dev, @@ -1274,6 +1301,7 @@ static int vhost_user_set_vring_call(struct vhost_dev *dev, static int vhost_user_get_u64(struct vhost_dev *dev, int request, uint64_t *u64) { + int ret; VhostUserMsg msg = { .hdr.request = request, .hdr.flags = VHOST_USER_VERSION, @@ -1283,23 +1311,25 @@ static int vhost_user_get_u64(struct vhost_dev *dev, int request, uint64_t *u64) return 0; } - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } - if (vhost_user_read(dev, &msg) < 0) { - return -1; + ret = vhost_user_read(dev, &msg); + if (ret < 0) { + return ret; } if (msg.hdr.request != request) { error_report("Received unexpected msg type. Expected %d received %d", request, msg.hdr.request); - return -1; + return -EPROTO; } if (msg.hdr.size != sizeof(msg.payload.u64)) { error_report("Received bad msg size."); - return -1; + return -EPROTO; } *u64 = msg.payload.u64; @@ -1337,6 +1367,7 @@ static int enforce_reply(struct vhost_dev *dev, static int vhost_user_set_vring_addr(struct vhost_dev *dev, struct vhost_vring_addr *addr) { + int ret; VhostUserMsg msg = { .hdr.request = VHOST_USER_SET_VRING_ADDR, .hdr.flags = VHOST_USER_VERSION, @@ -1357,8 +1388,9 @@ static int vhost_user_set_vring_addr(struct vhost_dev *dev, msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK; } - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } if (wait_for_reply) { @@ -1377,6 +1409,7 @@ static int vhost_user_set_u64(struct vhost_dev *dev, int request, uint64_t u64, .payload.u64 = u64, .hdr.size = sizeof(msg.payload.u64), }; + int ret; if (wait_for_reply) { bool reply_supported = virtio_has_feature(dev->protocol_features, @@ -1386,8 +1419,9 @@ static int vhost_user_set_u64(struct vhost_dev *dev, int request, uint64_t u64, } } - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } if (wait_for_reply) { @@ -1424,11 +1458,7 @@ static int vhost_user_set_owner(struct vhost_dev *dev) .hdr.flags = VHOST_USER_VERSION, }; - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -EPROTO; - } - - return 0; + return vhost_user_write(dev, &msg, NULL, 0); } static int vhost_user_get_max_memslots(struct vhost_dev *dev, @@ -1459,26 +1489,16 @@ static int vhost_user_reset_device(struct vhost_dev *dev) ? VHOST_USER_RESET_DEVICE : VHOST_USER_RESET_OWNER; - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; - } - - return 0; + return vhost_user_write(dev, &msg, NULL, 0); } static int vhost_user_slave_handle_config_change(struct vhost_dev *dev) { - int ret = -1; - - if (!dev->config_ops) { - return -1; + if (!dev->config_ops || !dev->config_ops->vhost_dev_config_notifier) { + return -ENOSYS; } - if (dev->config_ops->vhost_dev_config_notifier) { - ret = dev->config_ops->vhost_dev_config_notifier(dev); - } - - return ret; + return dev->config_ops->vhost_dev_config_notifier(dev); } static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev, @@ -1497,7 +1517,7 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev, if (!virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_HOST_NOTIFIER) || vdev == NULL || queue_idx >= virtio_get_num_queues(vdev)) { - return -1; + return -EINVAL; } n = &user->notifier[queue_idx]; @@ -1515,13 +1535,13 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev, /* Sanity check. */ if (area->size != page_size) { - return -1; + return -EINVAL; } addr = mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, area->offset); if (addr == MAP_FAILED) { - return -1; + return -EFAULT; } name = g_strdup_printf("vhost-user/host-notifier@%p mmaps[%d]", @@ -1534,7 +1554,7 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev, if (virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true)) { object_unparent(OBJECT(&n->mr)); munmap(addr, page_size); - return -1; + return -ENXIO; } n->addr = addr; @@ -1664,14 +1684,15 @@ static int vhost_setup_slave_channel(struct vhost_dev *dev) } if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) { + int saved_errno = errno; error_report("socketpair() failed"); - return -1; + return -saved_errno; } ioc = QIO_CHANNEL(qio_channel_socket_new_fd(sv[0], &local_err)); if (!ioc) { error_report_err(local_err); - return -1; + return -ECONNREFUSED; } u->slave_ioc = ioc; slave_update_read_handler(dev, NULL); @@ -1778,35 +1799,38 @@ static int vhost_user_postcopy_advise(struct vhost_dev *dev, Error **errp) struct vhost_user *u = dev->opaque; CharBackend *chr = u->user->chr; int ufd; + int ret; VhostUserMsg msg = { .hdr.request = VHOST_USER_POSTCOPY_ADVISE, .hdr.flags = VHOST_USER_VERSION, }; - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { error_setg(errp, "Failed to send postcopy_advise to vhost"); - return -1; + return ret; } - if (vhost_user_read(dev, &msg) < 0) { + ret = vhost_user_read(dev, &msg); + if (ret < 0) { error_setg(errp, "Failed to get postcopy_advise reply from vhost"); - return -1; + return ret; } if (msg.hdr.request != VHOST_USER_POSTCOPY_ADVISE) { error_setg(errp, "Unexpected msg type. Expected %d received %d", VHOST_USER_POSTCOPY_ADVISE, msg.hdr.request); - return -1; + return -EPROTO; } if (msg.hdr.size) { error_setg(errp, "Received bad msg size."); - return -1; + return -EPROTO; } ufd = qemu_chr_fe_get_msgfd(chr); if (ufd < 0) { error_setg(errp, "%s: Failed to get ufd", __func__); - return -1; + return -EIO; } qemu_set_nonblock(ufd); @@ -1820,7 +1844,7 @@ static int vhost_user_postcopy_advise(struct vhost_dev *dev, Error **errp) return 0; #else error_setg(errp, "Postcopy not supported on non-Linux systems"); - return -1; + return -ENOSYS; #endif } @@ -1836,10 +1860,13 @@ static int vhost_user_postcopy_listen(struct vhost_dev *dev, Error **errp) .hdr.flags = VHOST_USER_VERSION | VHOST_USER_NEED_REPLY_MASK, }; u->postcopy_listen = true; + trace_vhost_user_postcopy_listen(); - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { + + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { error_setg(errp, "Failed to send postcopy_listen to vhost"); - return -1; + return ret; } ret = process_message_reply(dev, &msg); @@ -1864,9 +1891,11 @@ static int vhost_user_postcopy_end(struct vhost_dev *dev, Error **errp) struct vhost_user *u = dev->opaque; trace_vhost_user_postcopy_end_entry(); - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { + + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { error_setg(errp, "Failed to send postcopy_end to vhost"); - return -1; + return ret; } ret = process_message_reply(dev, &msg); @@ -2115,7 +2144,7 @@ static int vhost_user_migration_done(struct vhost_dev *dev, char* mac_addr) return vhost_user_write(dev, &msg, NULL, 0); } - return -1; + return -ENOTSUP; } static bool vhost_user_can_merge(struct vhost_dev *dev, @@ -2136,6 +2165,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu) VhostUserMsg msg; bool reply_supported = virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_REPLY_ACK); + int ret; if (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_NET_MTU))) { return 0; @@ -2149,8 +2179,9 @@ static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu) msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK; } - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } /* If reply_ack supported, slave has to ack specified MTU is valid */ @@ -2164,6 +2195,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu) static int vhost_user_send_device_iotlb_msg(struct vhost_dev *dev, struct vhost_iotlb_msg *imsg) { + int ret; VhostUserMsg msg = { .hdr.request = VHOST_USER_IOTLB_MSG, .hdr.size = sizeof(msg.payload.iotlb), @@ -2171,8 +2203,9 @@ static int vhost_user_send_device_iotlb_msg(struct vhost_dev *dev, .payload.iotlb = *imsg, }; - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -EFAULT; + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } return process_message_reply(dev, &msg); @@ -2187,6 +2220,7 @@ static void vhost_user_set_iotlb_callback(struct vhost_dev *dev, int enabled) static int vhost_user_get_config(struct vhost_dev *dev, uint8_t *config, uint32_t config_len, Error **errp) { + int ret; VhostUserMsg msg = { .hdr.request = VHOST_USER_GET_CONFIG, .hdr.flags = VHOST_USER_VERSION, @@ -2203,26 +2237,28 @@ static int vhost_user_get_config(struct vhost_dev *dev, uint8_t *config, msg.payload.config.offset = 0; msg.payload.config.size = config_len; - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - error_setg_errno(errp, EPROTO, "vhost_get_config failed"); - return -EPROTO; + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + error_setg_errno(errp, -ret, "vhost_get_config failed"); + return ret; } - if (vhost_user_read(dev, &msg) < 0) { - error_setg_errno(errp, EPROTO, "vhost_get_config failed"); - return -EPROTO; + ret = vhost_user_read(dev, &msg); + if (ret < 0) { + error_setg_errno(errp, -ret, "vhost_get_config failed"); + return ret; } if (msg.hdr.request != VHOST_USER_GET_CONFIG) { error_setg(errp, "Received unexpected msg type. Expected %d received %d", VHOST_USER_GET_CONFIG, msg.hdr.request); - return -EINVAL; + return -EPROTO; } if (msg.hdr.size != VHOST_USER_CONFIG_HDR_SIZE + config_len) { error_setg(errp, "Received bad msg size."); - return -EINVAL; + return -EPROTO; } memcpy(config, msg.payload.config.region, config_len); @@ -2233,6 +2269,7 @@ static int vhost_user_get_config(struct vhost_dev *dev, uint8_t *config, static int vhost_user_set_config(struct vhost_dev *dev, const uint8_t *data, uint32_t offset, uint32_t size, uint32_t flags) { + int ret; uint8_t *p; bool reply_supported = virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_REPLY_ACK); @@ -2245,7 +2282,7 @@ static int vhost_user_set_config(struct vhost_dev *dev, const uint8_t *data, if (!virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_CONFIG)) { - return -1; + return -ENOTSUP; } if (reply_supported) { @@ -2253,7 +2290,7 @@ static int vhost_user_set_config(struct vhost_dev *dev, const uint8_t *data, } if (size > VHOST_USER_MAX_CONFIG_SIZE) { - return -1; + return -EINVAL; } msg.payload.config.offset = offset, @@ -2262,8 +2299,9 @@ static int vhost_user_set_config(struct vhost_dev *dev, const uint8_t *data, p = msg.payload.config.region; memcpy(p, data, size); - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } if (reply_supported) { @@ -2277,6 +2315,7 @@ static int vhost_user_crypto_create_session(struct vhost_dev *dev, void *session_info, uint64_t *session_id) { + int ret; bool crypto_session = virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_CRYPTO_SESSION); CryptoDevBackendSymSessionInfo *sess_info = session_info; @@ -2290,7 +2329,7 @@ static int vhost_user_crypto_create_session(struct vhost_dev *dev, if (!crypto_session) { error_report("vhost-user trying to send unhandled ioctl"); - return -1; + return -ENOTSUP; } memcpy(&msg.payload.session.session_setup_data, sess_info, @@ -2303,31 +2342,35 @@ static int vhost_user_crypto_create_session(struct vhost_dev *dev, memcpy(&msg.payload.session.auth_key, sess_info->auth_key, sess_info->auth_key_len); } - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - error_report("vhost_user_write() return -1, create session failed"); - return -1; + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + error_report("vhost_user_write() return %d, create session failed", + ret); + return ret; } - if (vhost_user_read(dev, &msg) < 0) { - error_report("vhost_user_read() return -1, create session failed"); - return -1; + ret = vhost_user_read(dev, &msg); + if (ret < 0) { + error_report("vhost_user_read() return %d, create session failed", + ret); + return ret; } if (msg.hdr.request != VHOST_USER_CREATE_CRYPTO_SESSION) { error_report("Received unexpected msg type. Expected %d received %d", VHOST_USER_CREATE_CRYPTO_SESSION, msg.hdr.request); - return -1; + return -EPROTO; } if (msg.hdr.size != sizeof(msg.payload.session)) { error_report("Received bad msg size."); - return -1; + return -EPROTO; } if (msg.payload.session.session_id < 0) { error_report("Bad session id: %" PRId64 "", msg.payload.session.session_id); - return -1; + return -EINVAL; } *session_id = msg.payload.session.session_id; @@ -2337,6 +2380,7 @@ static int vhost_user_crypto_create_session(struct vhost_dev *dev, static int vhost_user_crypto_close_session(struct vhost_dev *dev, uint64_t session_id) { + int ret; bool crypto_session = virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_CRYPTO_SESSION); VhostUserMsg msg = { @@ -2348,12 +2392,14 @@ vhost_user_crypto_close_session(struct vhost_dev *dev, uint64_t session_id) if (!crypto_session) { error_report("vhost-user trying to send unhandled ioctl"); - return -1; + return -ENOTSUP; } - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - error_report("vhost_user_write() return -1, close session failed"); - return -1; + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + error_report("vhost_user_write() return %d, close session failed", + ret); + return ret; } return 0; @@ -2375,6 +2421,7 @@ static int vhost_user_get_inflight_fd(struct vhost_dev *dev, { void *addr; int fd; + int ret; struct vhost_user *u = dev->opaque; CharBackend *chr = u->user->chr; VhostUserMsg msg = { @@ -2390,24 +2437,26 @@ static int vhost_user_get_inflight_fd(struct vhost_dev *dev, return 0; } - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret = vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } - if (vhost_user_read(dev, &msg) < 0) { - return -1; + ret = vhost_user_read(dev, &msg); + if (ret < 0) { + return ret; } if (msg.hdr.request != VHOST_USER_GET_INFLIGHT_FD) { error_report("Received unexpected msg type. " "Expected %d received %d", VHOST_USER_GET_INFLIGHT_FD, msg.hdr.request); - return -1; + return -EPROTO; } if (msg.hdr.size != sizeof(msg.payload.inflight)) { error_report("Received bad msg size."); - return -1; + return -EPROTO; } if (!msg.payload.inflight.mmap_size) { @@ -2417,7 +2466,7 @@ static int vhost_user_get_inflight_fd(struct vhost_dev *dev, fd = qemu_chr_fe_get_msgfd(chr); if (fd < 0) { error_report("Failed to get mem fd"); - return -1; + return -EIO; } addr = mmap(0, msg.payload.inflight.mmap_size, PROT_READ | PROT_WRITE, @@ -2426,7 +2475,7 @@ static int vhost_user_get_inflight_fd(struct vhost_dev *dev, if (addr == MAP_FAILED) { error_report("Failed to mmap mem fd"); close(fd); - return -1; + return -EFAULT; } inflight->addr = addr; @@ -2456,11 +2505,7 @@ static int vhost_user_set_inflight_fd(struct vhost_dev *dev, return 0; } - if (vhost_user_write(dev, &msg, &inflight->fd, 1) < 0) { - return -1; - } - - return 0; + return vhost_user_write(dev, &msg, &inflight->fd, 1); } bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp) From patchwork Fri Jan 7 11:04:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576557 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VJeyQJal; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVghG4ZXZz9tjx for ; Fri, 7 Jan 2022 22:18:38 +1100 (AEDT) Received: from localhost ([::1]:36352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nGW-0005mB-Eu for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:18:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2c-00008z-RJ for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46647) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2a-0001sC-7D for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GNYsEEAwxi469lEgq3C6J6IxF3dZC/8ISDUNssUi2gE=; b=VJeyQJala6/2/qwj65I7Ysui4f4eiy8HI26ZpUzp5SVGc3zmN9qH7X2Lug7knyS0j58dB4 rqyOUR9QOy5XNCQfhWAsObIPBLScsA/vXGpln1uEKSqOPI0Kfr0VJlidSZvfnj+KloL7r+ AS769n3KToYdAgy2vcNVtd9NtKzSoiM= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-550-AwVyjAKaOCKyocQX1JmcMg-1; Fri, 07 Jan 2022 06:04:10 -0500 X-MC-Unique: AwVyjAKaOCKyocQX1JmcMg-1 Received: by mail-wr1-f71.google.com with SMTP id n4-20020adf8b04000000b001a49cff5283so2075342wra.14 for ; Fri, 07 Jan 2022 03:04:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GNYsEEAwxi469lEgq3C6J6IxF3dZC/8ISDUNssUi2gE=; b=JkljwtU8CEwV4CYMoGdT78+NrYYSNcyQQYi0c/9EgmyH4bU20em0kkmMjJldcCrX6s zIJCC4TBlj9R26hEgaEYs3VfxMVGpkVAuKFlO8lr7KxTRucGlmYjb3Y3LTuwg24Tzhln OZJpEC6TNsfgchNeMXcwwrCbw2Dr0seI2wgAKakKmLFvbv3reFgqhwG0iHQ0Fh/QtPn3 MQ5Q8+CkI+wpQXYiDEeSdGrNRprH+WVvqUOc0431dhWSIPh/DhWlVxfH/PA0tMQuLuyB C8FfgE13eMoNWrVEdzjuSfXnRz6/zMafaejnxzDDYvarVYawiqV/yD9dD3j4zeahv/Iu GYeA== X-Gm-Message-State: AOAM5301iexaZ7HisFC7E+WwddHX+D3mPT07H7qnxqI1AnPxhS+AVraa wxI4AXGqslLySENfCJTn4kH0dovMKCFhSCYZlUEpGtsfQKosBmsrJhDqVgmf7SjCQhaYAmlOB4j DjzHsgN05YCgj6VGR5AXd1CVVJ4vV1VbgFjI4oY4oRK0SgDuUrAjxA6p7+PmB X-Received: by 2002:a1c:f012:: with SMTP id a18mr10551959wmb.73.1641553448852; Fri, 07 Jan 2022 03:04:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYKCMTagyiRfcdK9N2gzpz+xRA23ynLjcgb+yL6Vy2qJ3eFEE+ERD8AgbyDFQBLJhGCUfVcg== X-Received: by 2002:a1c:f012:: with SMTP id a18mr10551915wmb.73.1641553448399; Fri, 07 Jan 2022 03:04:08 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id l8sm4507551wrv.25.2022.01.07.03.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:08 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:05 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 21/55] vhost: stick to -errno error return convention Message-ID: <20220107102526.39238-22-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Kagan , Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Roman Kagan The generic vhost code expects that many of the VhostOps methods in the respective backends set errno on errors. However, none of the existing backends actually bothers to do so. In a number of those methods errno from the failed call is clobbered by successful later calls to some library functions; on a few code paths the generic vhost code then negates and returns that errno, thus making failures look as successes to the caller. As a result, in certain scenarios (e.g. live migration) the device doesn't notice the first failure and goes on through its state transitions as if everything is ok, instead of taking recovery actions (break and reestablish the vhost-user connection, cancel migration, etc) before it's too late. To fix this, consolidate on the convention to return negated errno on failures throughout generic vhost, and use it for error propagation. Signed-off-by: Roman Kagan Message-Id: <20211111153354.18807-10-rvkagan@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost.c | 100 +++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 54 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 98a4b0a0df..cbf3b792da 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -33,11 +33,13 @@ #define _VHOST_DEBUG 1 #ifdef _VHOST_DEBUG -#define VHOST_OPS_DEBUG(fmt, ...) \ - do { error_report(fmt ": %s (%d)", ## __VA_ARGS__, \ - strerror(errno), errno); } while (0) +#define VHOST_OPS_DEBUG(retval, fmt, ...) \ + do { \ + error_report(fmt ": %s (%d)", ## __VA_ARGS__, \ + strerror(-retval), -retval); \ + } while (0) #else -#define VHOST_OPS_DEBUG(fmt, ...) \ +#define VHOST_OPS_DEBUG(retval, fmt, ...) \ do { } while (0) #endif @@ -297,7 +299,7 @@ static inline void vhost_dev_log_resize(struct vhost_dev *dev, uint64_t size) releasing the current log, to ensure no logging is lost */ r = dev->vhost_ops->vhost_set_log_base(dev, log_base, log); if (r < 0) { - VHOST_OPS_DEBUG("vhost_set_log_base failed"); + VHOST_OPS_DEBUG(r, "vhost_set_log_base failed"); } vhost_log_put(dev, true); @@ -550,7 +552,7 @@ static void vhost_commit(MemoryListener *listener) if (!dev->log_enabled) { r = dev->vhost_ops->vhost_set_mem_table(dev, dev->mem); if (r < 0) { - VHOST_OPS_DEBUG("vhost_set_mem_table failed"); + VHOST_OPS_DEBUG(r, "vhost_set_mem_table failed"); } goto out; } @@ -564,7 +566,7 @@ static void vhost_commit(MemoryListener *listener) } r = dev->vhost_ops->vhost_set_mem_table(dev, dev->mem); if (r < 0) { - VHOST_OPS_DEBUG("vhost_set_mem_table failed"); + VHOST_OPS_DEBUG(r, "vhost_set_mem_table failed"); } /* To log less, can only decrease log size after table update. */ if (dev->log_size > log_size + VHOST_LOG_BUFFER) { @@ -803,8 +805,8 @@ static int vhost_virtqueue_set_addr(struct vhost_dev *dev, if (dev->vhost_ops->vhost_vq_get_addr) { r = dev->vhost_ops->vhost_vq_get_addr(dev, &addr, vq); if (r < 0) { - VHOST_OPS_DEBUG("vhost_vq_get_addr failed"); - return -errno; + VHOST_OPS_DEBUG(r, "vhost_vq_get_addr failed"); + return r; } } else { addr.desc_user_addr = (uint64_t)(unsigned long)vq->desc; @@ -816,10 +818,9 @@ static int vhost_virtqueue_set_addr(struct vhost_dev *dev, addr.flags = enable_log ? (1 << VHOST_VRING_F_LOG) : 0; r = dev->vhost_ops->vhost_set_vring_addr(dev, &addr); if (r < 0) { - VHOST_OPS_DEBUG("vhost_set_vring_addr failed"); - return -errno; + VHOST_OPS_DEBUG(r, "vhost_set_vring_addr failed"); } - return 0; + return r; } static int vhost_dev_set_features(struct vhost_dev *dev, @@ -840,19 +841,19 @@ static int vhost_dev_set_features(struct vhost_dev *dev, } r = dev->vhost_ops->vhost_set_features(dev, features); if (r < 0) { - VHOST_OPS_DEBUG("vhost_set_features failed"); + VHOST_OPS_DEBUG(r, "vhost_set_features failed"); goto out; } if (dev->vhost_ops->vhost_set_backend_cap) { r = dev->vhost_ops->vhost_set_backend_cap(dev); if (r < 0) { - VHOST_OPS_DEBUG("vhost_set_backend_cap failed"); + VHOST_OPS_DEBUG(r, "vhost_set_backend_cap failed"); goto out; } } out: - return r < 0 ? -errno : 0; + return r; } static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log) @@ -999,22 +1000,17 @@ static int vhost_virtqueue_set_vring_endian_legacy(struct vhost_dev *dev, bool is_big_endian, int vhost_vq_index) { + int r; struct vhost_vring_state s = { .index = vhost_vq_index, .num = is_big_endian }; - if (!dev->vhost_ops->vhost_set_vring_endian(dev, &s)) { - return 0; + r = dev->vhost_ops->vhost_set_vring_endian(dev, &s); + if (r < 0) { + VHOST_OPS_DEBUG(r, "vhost_set_vring_endian failed"); } - - VHOST_OPS_DEBUG("vhost_set_vring_endian failed"); - if (errno == ENOTTY) { - error_report("vhost does not support cross-endian"); - return -ENOSYS; - } - - return -errno; + return r; } static int vhost_memory_region_lookup(struct vhost_dev *hdev, @@ -1106,15 +1102,15 @@ static int vhost_virtqueue_start(struct vhost_dev *dev, vq->num = state.num = virtio_queue_get_num(vdev, idx); r = dev->vhost_ops->vhost_set_vring_num(dev, &state); if (r) { - VHOST_OPS_DEBUG("vhost_set_vring_num failed"); - return -errno; + VHOST_OPS_DEBUG(r, "vhost_set_vring_num failed"); + return r; } state.num = virtio_queue_get_last_avail_idx(vdev, idx); r = dev->vhost_ops->vhost_set_vring_base(dev, &state); if (r) { - VHOST_OPS_DEBUG("vhost_set_vring_base failed"); - return -errno; + VHOST_OPS_DEBUG(r, "vhost_set_vring_base failed"); + return r; } if (vhost_needs_vring_endian(vdev)) { @@ -1122,7 +1118,7 @@ static int vhost_virtqueue_start(struct vhost_dev *dev, virtio_is_big_endian(vdev), vhost_vq_index); if (r) { - return -errno; + return r; } } @@ -1150,15 +1146,13 @@ static int vhost_virtqueue_start(struct vhost_dev *dev, r = vhost_virtqueue_set_addr(dev, vq, vhost_vq_index, dev->log_enabled); if (r < 0) { - r = -errno; goto fail_alloc; } file.fd = event_notifier_get_fd(virtio_queue_get_host_notifier(vvq)); r = dev->vhost_ops->vhost_set_vring_kick(dev, &file); if (r) { - VHOST_OPS_DEBUG("vhost_set_vring_kick failed"); - r = -errno; + VHOST_OPS_DEBUG(r, "vhost_set_vring_kick failed"); goto fail_kick; } @@ -1218,7 +1212,7 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev, r = dev->vhost_ops->vhost_get_vring_base(dev, &state); if (r < 0) { - VHOST_OPS_DEBUG("vhost VQ %u ring restore failed: %d", idx, r); + VHOST_OPS_DEBUG(r, "vhost VQ %u ring restore failed: %d", idx, r); /* Connection to the backend is broken, so let's sync internal * last avail idx to the device used idx. */ @@ -1274,7 +1268,7 @@ static int vhost_virtqueue_set_busyloop_timeout(struct vhost_dev *dev, r = dev->vhost_ops->vhost_set_vring_busyloop_timeout(dev, &state); if (r) { - VHOST_OPS_DEBUG("vhost_set_vring_busyloop_timeout failed"); + VHOST_OPS_DEBUG(r, "vhost_set_vring_busyloop_timeout failed"); return r; } @@ -1296,8 +1290,7 @@ static int vhost_virtqueue_init(struct vhost_dev *dev, file.fd = event_notifier_get_fd(&vq->masked_notifier); r = dev->vhost_ops->vhost_set_vring_call(dev, &file); if (r) { - VHOST_OPS_DEBUG("vhost_set_vring_call failed"); - r = -errno; + VHOST_OPS_DEBUG(r, "vhost_set_vring_call failed"); goto fail_call; } @@ -1557,7 +1550,7 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n, file.index = hdev->vhost_ops->vhost_get_vq_index(hdev, n); r = hdev->vhost_ops->vhost_set_vring_call(hdev, &file); if (r < 0) { - VHOST_OPS_DEBUG("vhost_set_vring_call failed"); + VHOST_OPS_DEBUG(r, "vhost_set_vring_call failed"); } } @@ -1595,7 +1588,7 @@ void vhost_config_mask(struct vhost_dev *hdev, VirtIODevice *vdev, bool mask) } r = hdev->vhost_ops->vhost_set_config_call(hdev, fd); if (r < 0) { - VHOST_OPS_DEBUG("vhost_set_config_call failed"); + VHOST_OPS_DEBUG(r, "vhost_set_config_call failed"); } } @@ -1660,7 +1653,7 @@ int vhost_dev_get_config(struct vhost_dev *hdev, uint8_t *config, } error_setg(errp, "vhost_get_config not implemented"); - return -ENOTSUP; + return -ENOSYS; } int vhost_dev_set_config(struct vhost_dev *hdev, const uint8_t *data, @@ -1673,7 +1666,7 @@ int vhost_dev_set_config(struct vhost_dev *hdev, const uint8_t *data, size, flags); } - return -1; + return -ENOSYS; } void vhost_dev_set_config_notifier(struct vhost_dev *hdev, @@ -1702,7 +1695,7 @@ static int vhost_dev_resize_inflight(struct vhost_inflight *inflight, if (err) { error_report_err(err); - return -1; + return -ENOMEM; } vhost_dev_free_inflight(inflight); @@ -1735,8 +1728,9 @@ int vhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f) } if (inflight->size != size) { - if (vhost_dev_resize_inflight(inflight, size)) { - return -1; + int ret = vhost_dev_resize_inflight(inflight, size); + if (ret < 0) { + return ret; } } inflight->queue_size = qemu_get_be16(f); @@ -1759,7 +1753,7 @@ int vhost_dev_prepare_inflight(struct vhost_dev *hdev, VirtIODevice *vdev) r = vhost_dev_set_features(hdev, hdev->log_enabled); if (r < 0) { - VHOST_OPS_DEBUG("vhost_dev_prepare_inflight failed"); + VHOST_OPS_DEBUG(r, "vhost_dev_prepare_inflight failed"); return r; } @@ -1774,8 +1768,8 @@ int vhost_dev_set_inflight(struct vhost_dev *dev, if (dev->vhost_ops->vhost_set_inflight_fd && inflight->addr) { r = dev->vhost_ops->vhost_set_inflight_fd(dev, inflight); if (r) { - VHOST_OPS_DEBUG("vhost_set_inflight_fd failed"); - return -errno; + VHOST_OPS_DEBUG(r, "vhost_set_inflight_fd failed"); + return r; } } @@ -1790,8 +1784,8 @@ int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size, if (dev->vhost_ops->vhost_get_inflight_fd) { r = dev->vhost_ops->vhost_get_inflight_fd(dev, queue_size, inflight); if (r) { - VHOST_OPS_DEBUG("vhost_get_inflight_fd failed"); - return -errno; + VHOST_OPS_DEBUG(r, "vhost_get_inflight_fd failed"); + return r; } } @@ -1820,8 +1814,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) r = hdev->vhost_ops->vhost_set_mem_table(hdev, hdev->mem); if (r < 0) { - VHOST_OPS_DEBUG("vhost_set_mem_table failed"); - r = -errno; + VHOST_OPS_DEBUG(r, "vhost_set_mem_table failed"); goto fail_mem; } for (i = 0; i < hdev->nvqs; ++i) { @@ -1855,8 +1848,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) hdev->log_size ? log_base : 0, hdev->log); if (r < 0) { - VHOST_OPS_DEBUG("vhost_set_log_base failed"); - r = -errno; + VHOST_OPS_DEBUG(r, "vhost_set_log_base failed"); goto fail_log; } } @@ -1936,5 +1928,5 @@ int vhost_net_set_backend(struct vhost_dev *hdev, return hdev->vhost_ops->vhost_net_set_backend(hdev, file); } - return -1; + return -ENOSYS; } From patchwork Fri Jan 7 11:04:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cVw7N3KN; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVh5r1n9dz9tjx for ; Fri, 7 Jan 2022 22:37:20 +1100 (AEDT) Received: from localhost ([::1]:47906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nYc-0004z5-1C for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:37:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2e-0000Cq-Ce for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:25515) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2c-0001sg-UM for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sHSJcWtTIMlbxRfYVXtkQUvuw3rw0rHE0YLD56kL/PM=; b=cVw7N3KNylkTgu4eeIvsaGRac8GajnNW8nK6RLWU8sFp3pkdH/oTgk67jPseFmm/d9ovBt ZHvF1y/7XM+uKEAz67imAMDPIYowdXThhAp1+4Mo5Zq/tas9igZzgexzLKBTPvtyfsF+Ts eoQC+pC5Sc9PZpXCyc+vE0ODNIsO84E= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-613-KDgftBRbPESjd02YesIKNg-1; Fri, 07 Jan 2022 06:04:13 -0500 X-MC-Unique: KDgftBRbPESjd02YesIKNg-1 Received: by mail-wm1-f72.google.com with SMTP id n3-20020a05600c3b8300b00345c3fc40b0so4489618wms.3 for ; Fri, 07 Jan 2022 03:04:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=sHSJcWtTIMlbxRfYVXtkQUvuw3rw0rHE0YLD56kL/PM=; b=i3pHWqFPtDxI3BOZLLt9NCIILSOvtrHO+qzxHBVbC1VPpVfys4CKe4BhhRkY10HsF+ pXdSGFSLes7B5eXd2tDKiLt/2xK5DI2wKoNVZKRe3EJeRj/xe1dfgOqnZ6da2t1/rn75 eysUR8kkYi3qT8kj4+UX+U3KyAyX4fZR4Qq2qUwJWCkhxGaPq34ISzbfG+64MVAeRRwc w7tzQc0Z5sXEJkvX+Q6UQDIeN77AZLyLf8FYrJc4XsMV/sP32Oh53K75109zW6gdeqkl 39vlZtfiO9HNoDbbfQMwJOjz3Obh1GWuxTkkUqkF6SY47nee3L5ElV10YGlZuOCM6mg0 FpKA== X-Gm-Message-State: AOAM530LK6WS+1DMV0S00STp/vEIC4R5kJkWbqwIrw76RdRe7vdiJsn+ KqrShlH4tH0sTYpkn9VEXZRqQAspK6yXSKxSUHO/uLqCrrKvZGEF/RNkmj9lZCn6vphc2Wajpzo N7+Vjuibw5BbRq1tvSTtHwjzV2IkKcYLNkYti8p833ZPt0XPpX98kkHntPuF/ X-Received: by 2002:a1c:7316:: with SMTP id d22mr10571748wmb.5.1641553452145; Fri, 07 Jan 2022 03:04:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2jf/dhdlzrmOt2TZ9xGQM1buhbPYlHP7dBDgO/HPodzmT4czjRMhjwnk9H7scCt/ghilOOg== X-Received: by 2002:a1c:7316:: with SMTP id d22mr10571729wmb.5.1641553451960; Fri, 07 Jan 2022 03:04:11 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id h2sm3109547wrr.96.2022.01.07.03.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:11 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:08 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 22/55] vhost-user-blk: propagate error return from generic vhost Message-ID: <20220107102526.39238-23-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Raphael Norwitz , Roman Kagan , Hanna Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Roman Kagan Fix the only callsite that doesn't propagate the error code from the generic vhost code. Signed-off-by: Roman Kagan Message-Id: <20211111153354.18807-11-rvkagan@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index f9b17f6813..ab11ce8252 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -100,7 +100,7 @@ static int vhost_user_blk_handle_config_change(struct vhost_dev *dev) &local_err); if (ret < 0) { error_report_err(local_err); - return -1; + return ret; } /* valid for resize only */ From patchwork Fri Jan 7 11:04:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576562 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=N+7aXXaJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgqT4Bg9z9tjx for ; Fri, 7 Jan 2022 22:24:53 +1100 (AEDT) Received: from localhost ([::1]:49276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nMZ-0006it-EB for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:24:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2h-0000M1-Hp for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:59369) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2f-0001tQ-V8 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553457; 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=J3xpoxaSN5NdlrS8+eCK2NDrLznN6O18Ki1VxrmK5/M=; b=N+7aXXaJH7XTrgnQ7lb6hvPkd97KUJTs/NXLxIy65DdSrtfNowPfwk0MxgN8ORxu7d26zr SNXmqgHxVP5zLXDQoUixJdlBoU9iFahqRIzJX0hmQftzTFxd5D7Hoox6uaLklNoYXl087a +Yvo151M/5034oyCqHto+oPJLdL73QI= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-547-CRz9_MpQNKuLjYY9st1TPQ-1; Fri, 07 Jan 2022 06:04:16 -0500 X-MC-Unique: CRz9_MpQNKuLjYY9st1TPQ-1 Received: by mail-wm1-f72.google.com with SMTP id b20-20020a05600c4e1400b003457da1c91eso698448wmq.4 for ; Fri, 07 Jan 2022 03:04:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=J3xpoxaSN5NdlrS8+eCK2NDrLznN6O18Ki1VxrmK5/M=; b=dys9pmn7c320dmiaUkcQOg9owpzlkJ/TLhM5/27atyk5AtRF+2jM/XhtCigU9hVXia BKXpIE1wr0Z7mtlQIesTwXiPzOLVfMZWS001XIEttTWz+HcBlcitvBp78VmR5Yw65ZM2 6dJ06UFtT38zlFjKD9+xu95yN+Ll2F1EyeKGGSwJE26KBWag3ERrVG1w8rns1lUrR6Tv e+vxdFS3ihgTiudjhlHsQWK6b1fIAC5r2MtxjOTrmdiF0ZvbnWcGxRXlszhecCpVjZ5m 7hkoy7FKS8JS4wVbWesfrBylR2p2A2Q4Hnrotovm8BggWZ7lVbmSBA+S3YcC7jChOwdL 6XCg== X-Gm-Message-State: AOAM5327RF8dshCIXgv27zsl2r8zo/YJFDwLs3+k3Uf/jlGXNVQJyGsk Vn946pNzJSjfUlDjD69TJHvoGYbK2w2rFT+2xrO+O54nqB0792YRi/Nj0m6wr7RZJgYsQSdyQ3u bTEIHJB366A5rbgCRjnv2BocnASAMdCjtsdO1/K82UBjuEsDsc96sukHFl6Mp X-Received: by 2002:a7b:ce01:: with SMTP id m1mr10230061wmc.115.1641553455229; Fri, 07 Jan 2022 03:04:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtS2e+I6TXBt9Zjd6KpBtpU7cRWblWQfvLJvyMt57gFvQK1EUszdo4aA9GaikXXrv2tJEACw== X-Received: by 2002:a7b:ce01:: with SMTP id m1mr10230042wmc.115.1641553454947; Fri, 07 Jan 2022 03:04:14 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id t6sm1978007wry.84.2022.01.07.03.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:14 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:12 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 23/55] pci: Export the pci_intx() function Message-ID: <20220107102526.39238-24-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Frederic Barrat , Peter Maydell , =?utf-8?q?C=C3=A9dric?= Le Goater Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Frederic Barrat Move the pci_intx() definition to the PCI header file, so that it can be called from other PCI files. It is used by the next patch. Signed-off-by: Frederic Barrat Message-Id: <20211116170133.724751-3-fbarrat@linux.ibm.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Cédric Le Goater --- include/hw/pci/pci.h | 5 +++++ hw/pci/pci.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 5b36334a28..483d5c7c72 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -735,6 +735,11 @@ void lsi53c8xx_handle_legacy_cmdline(DeviceState *lsi_dev); qemu_irq pci_allocate_irq(PCIDevice *pci_dev); void pci_set_irq(PCIDevice *pci_dev, int level); +static inline int pci_intx(PCIDevice *pci_dev) +{ + return pci_get_byte(pci_dev->config + PCI_INTERRUPT_PIN) - 1; +} + static inline void pci_irq_assert(PCIDevice *pci_dev) { pci_set_irq(pci_dev, 1); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 322ba450e7..5d30f9ca60 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1497,11 +1497,6 @@ static void pci_irq_handler(void *opaque, int irq_num, int level) pci_change_irq_level(pci_dev, irq_num, change); } -static inline int pci_intx(PCIDevice *pci_dev) -{ - return pci_get_byte(pci_dev->config + PCI_INTERRUPT_PIN) - 1; -} - qemu_irq pci_allocate_irq(PCIDevice *pci_dev) { int intx = pci_intx(pci_dev); From patchwork Fri Jan 7 11:04:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576576 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Kk3MqQAJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhC82nrMz9tjx for ; Fri, 7 Jan 2022 22:41:56 +1100 (AEDT) Received: from localhost ([::1]:56538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nd4-0002gs-5P for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:41:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2l-0000ST-0i for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23759) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2i-0001u3-VL for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553460; 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=uWTwMV+ZCbV0IF1/mOnNkd5ZGkoC7/f6dcJ4TuYv4Y0=; b=Kk3MqQAJLxznjyExNDQgHmEpXz+qXvBlbjLEcua0PlQGTF9nYZfmS4O2OsUkk8QuGIH1LM FwE10dKmuUwkTyWdH/I7nauJNqEU+j3OkMD7lKjOlFFh2L58If3iLuh06A4j6f2FG68xf0 +UxAKZF9YQns08wqON1JGikL+C0ZaQU= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-606-RKFozgvJNBKkFv5WPRNXyA-1; Fri, 07 Jan 2022 06:04:19 -0500 X-MC-Unique: RKFozgvJNBKkFv5WPRNXyA-1 Received: by mail-wm1-f70.google.com with SMTP id z13-20020a05600c0a0d00b003457d6619f8so1353363wmp.1 for ; Fri, 07 Jan 2022 03:04:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=uWTwMV+ZCbV0IF1/mOnNkd5ZGkoC7/f6dcJ4TuYv4Y0=; b=yP3Ww6Pb5sF6zBH8hJOsiQWI/t1k/G6gk6Z3QDm3G7mJgyZvFn0CvZ0Dun66tBfCSY 40fClWsCLK3m2uUzXKRVJWgQ+7QOmUTAn/osfwoXafW8y7hnOSRdz1h3K923cNPcWTrY LQxQvzcT0UzwIZryhdZAkHVKqfxxKcIE1h/vwB4ofb3UA9IJuzN0A7Wc1RPkcj4vHj3l ehRgZUdv2vru1nWrZMPErP2kSgp9GEMZ9EQMIKD7lHULL0IMDpChE32+Mw/XIvhwF+D3 4cWa8dmzc9o9hyil5TTlo8lobUygbca+qiwADeZ43fE9F6Z/k4JDz6UX68qInC1dvkB2 6IRg== X-Gm-Message-State: AOAM530gXABxqlgjjKqF33FlI0UiZqwIZnJotv4M96OryJ9kPFsqgajz iTqJpF/d4S0vienZ/l3I5lUAqbErHLlFrLi7KehGlKAa+2bDQeKkwVMNKpZttBrjCm++7qNf/vn wVWj+XOe7EduZBAOsm5wTz3RJp3G4hGpgQmJvC5gByX4s+aKljKezZWrlJrOl X-Received: by 2002:adf:f7d2:: with SMTP id a18mr55383676wrq.354.1641553458098; Fri, 07 Jan 2022 03:04:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxkoCtlvxDLaZCiG53kRr/4Xn9ScxVsRDZpYpfXwBmATSNaUI/pywQIvgO/8klEPYjC6PVVw== X-Received: by 2002:adf:f7d2:: with SMTP id a18mr55383654wrq.354.1641553457834; Fri, 07 Jan 2022 03:04:17 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id c8sm4588220wmq.34.2022.01.07.03.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:17 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:15 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 24/55] pcie_aer: Don't trigger a LSI if none are defined Message-ID: <20220107102526.39238-25-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Frederic Barrat , Peter Maydell , =?utf-8?q?C=C3=A9dric?= Le Goater Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Frederic Barrat Skip triggering an LSI when the AER root error status is updated if no LSI is defined for the device. We can have a root bridge with no LSI, MSI and MSI-X defined, for example on POWER systems. Signed-off-by: Frederic Barrat Message-Id: <20211116170133.724751-4-fbarrat@linux.ibm.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Cédric Le Goater --- hw/pci/pcie_aer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c index 27f9cc56af..e1a8a88c8c 100644 --- a/hw/pci/pcie_aer.c +++ b/hw/pci/pcie_aer.c @@ -774,7 +774,9 @@ void pcie_aer_root_write_config(PCIDevice *dev, uint32_t root_cmd = pci_get_long(aer_cap + PCI_ERR_ROOT_COMMAND); /* 6.2.4.1.2 Interrupt Generation */ if (!msix_enabled(dev) && !msi_enabled(dev)) { - pci_set_irq(dev, !!(root_cmd & enabled_cmd)); + if (pci_intx(dev) != -1) { + pci_set_irq(dev, !!(root_cmd & enabled_cmd)); + } return; } From patchwork Fri Jan 7 11:04:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576570 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LytLhvFV; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVh2d37wTz9tjx for ; Fri, 7 Jan 2022 22:34:33 +1100 (AEDT) Received: from localhost ([::1]:40938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nVv-00089P-8b for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:34:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2w-0000mc-FX for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40934) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2s-0001um-6C for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553469; 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=2nFeua7zjPU9qdmSR15xkvtgazR5lMIelJwJXZHlGtA=; b=LytLhvFVJHhSQKYgk7QvNJZ+R83e5Heb1J/hizzWNJHin1BJeT0oOgOI8nLM1MDBmNM7Mv tixX+u7L0l+GRYRTeHsEgwLVw54XbEOT5wXjdJsjC+acTXmgIZaKjZCrr/WOXhQn1IfSjr Z0h3i4WcBH0zGSHMeRGORjm52yrpqVU= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-73-5vQUA2d3N5CWHxz2Fbt2eg-1; Fri, 07 Jan 2022 06:04:23 -0500 X-MC-Unique: 5vQUA2d3N5CWHxz2Fbt2eg-1 Received: by mail-wr1-f69.google.com with SMTP id k4-20020adfc704000000b001a32d86a772so2130717wrg.5 for ; Fri, 07 Jan 2022 03:04:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=2nFeua7zjPU9qdmSR15xkvtgazR5lMIelJwJXZHlGtA=; b=1gaqZAws/1Be8H8vnpEct6w8NRPG3EVK7JL0DSa1rUfcmRAlxzjf/GTNf5rCOtF07I 28OS04B6mVFnWh5UnErsfLAj1+zjmLfzg0RQrOtYm7M/5jha0AuSb6Q+wfJTBGKpc9n9 zBenj06kgDSQYZvvTEaUqKypMY9LIh8UZpz1q9jKKvMlT3iqnaluGZtAPsfGxIVlSy9y dnytnTEnvWksuaqHnw8JW2Ivx3oGyA2ifeKRnLz5jJl6beYZOpr9QWO7gHY7pQ/1BCUy p0NEp6U/RVT5bIT86/lHk0kU9xnNzRbdSfSIKzMHnfCxgafZLm9kMYKGOxMhttbZiW0d d84g== X-Gm-Message-State: AOAM533/snicIt7wu/ua2FpZhGjEJym9OkYWFUELN2n02OOrAWRZA5bW xOB9GiUehEjuOsku4YhN5RI+ia21/nuFweaBTBIK1VFhHS95ML67NJz6o+sSWEeluYY66m2EBBL 1xlngRX0TdPbASOSrM9j7/TNDtA+AWK93w79UwrG1SK+K7kywW+A91xKRsqVH X-Received: by 2002:a05:6000:15ca:: with SMTP id y10mr52749422wry.718.1641553461957; Fri, 07 Jan 2022 03:04:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGiBBeFWEAE7SMOQE7TlgsSNaECHiwNizTscPVDjBs6Gz1sj7OU3mYqp/APLpy9YZsgpFASQ== X-Received: by 2002:a05:6000:15ca:: with SMTP id y10mr52749394wry.718.1641553461719; Fri, 07 Jan 2022 03:04:21 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id t12sm5404450wrs.72.2022.01.07.03.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:21 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:18 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 25/55] smbios: Rename SMBIOS_ENTRY_POINT_* enums Message-ID: <20220107102526.39238-26-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Peter Maydell , Eduardo Habkost , Richard Henderson , qemu-arm@nongnu.org, Igor Mammedov , Ani Sinha , Paolo Bonzini , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eduardo Habkost Rename the enums to match the naming style used by QAPI, and to use "32" and "64" instead of "20" and "31". This will allow us to more easily move the enum to the QAPI schema later. About the naming choice: "SMBIOS 2.1 entry point"/"SMBIOS 3.0 entry point" and "32-bit entry point"/"64-bit entry point" are synonymous in the SMBIOS specification. However, the phrases "32-bit entry point" and "64-bit entry point" are used more often. The new names also avoid confusion between the entry point format and the actual SMBIOS version reported in the entry point structure. For example: currently the 32-bit entry point actually report SMBIOS 2.8 support, not 2.1. Based on portions of a patch submitted by Daniel P. Berrangé. Signed-off-by: Eduardo Habkost Message-Id: <20211026151100.1691925-2-ehabkost@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/firmware/smbios.h | 4 ++-- hw/arm/virt.c | 2 +- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/smbios/smbios.c | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index 5a0dd0c8cf..d916baed6a 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -27,8 +27,8 @@ struct smbios_phys_mem_area { * SMBIOS spec defined tables */ typedef enum SmbiosEntryPointType { - SMBIOS_ENTRY_POINT_21, - SMBIOS_ENTRY_POINT_30, + SMBIOS_ENTRY_POINT_TYPE_32, + SMBIOS_ENTRY_POINT_TYPE_64, } SmbiosEntryPointType; /* SMBIOS Entry Point diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 4593fea1ce..b45b52c90e 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1589,7 +1589,7 @@ static void virt_build_smbios(VirtMachineState *vms) smbios_set_defaults("QEMU", product, vmc->smbios_old_sys_ver ? "1.0" : mc->name, false, - true, SMBIOS_ENTRY_POINT_30); + true, SMBIOS_ENTRY_POINT_TYPE_64); smbios_get_tables(MACHINE(vms), NULL, 0, &smbios_tables, &smbios_tables_len, diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 1999190276..25f918b609 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -177,7 +177,7 @@ static void pc_init1(MachineState *machine, smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)", mc->name, pcmc->smbios_legacy_mode, pcmc->smbios_uuid_encoded, - SMBIOS_ENTRY_POINT_21); + SMBIOS_ENTRY_POINT_TYPE_32); } /* allocate ram and load rom/bios */ diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 2e981f436c..1103fbcd90 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -200,7 +200,7 @@ static void pc_q35_init(MachineState *machine) smbios_set_defaults("QEMU", "Standard PC (Q35 + ICH9, 2009)", mc->name, pcmc->smbios_legacy_mode, pcmc->smbios_uuid_encoded, - SMBIOS_ENTRY_POINT_21); + SMBIOS_ENTRY_POINT_TYPE_32); } /* allocate ram and load rom/bios */ diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 7397e56737..6013df1698 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -62,7 +62,7 @@ uint8_t *smbios_tables; size_t smbios_tables_len; unsigned smbios_table_max; unsigned smbios_table_cnt; -static SmbiosEntryPointType smbios_ep_type = SMBIOS_ENTRY_POINT_21; +static SmbiosEntryPointType smbios_ep_type = SMBIOS_ENTRY_POINT_TYPE_32; static SmbiosEntryPoint ep; @@ -432,7 +432,7 @@ static void smbios_validate_table(MachineState *ms) exit(1); } - if (smbios_ep_type == SMBIOS_ENTRY_POINT_21 && + if (smbios_ep_type == SMBIOS_ENTRY_POINT_TYPE_32 && smbios_tables_len > SMBIOS_21_MAX_TABLES_LEN) { error_report("SMBIOS 2.1 table length %zu exceeds %d", smbios_tables_len, SMBIOS_21_MAX_TABLES_LEN); @@ -927,7 +927,7 @@ void smbios_set_defaults(const char *manufacturer, const char *product, static void smbios_entry_point_setup(void) { switch (smbios_ep_type) { - case SMBIOS_ENTRY_POINT_21: + case SMBIOS_ENTRY_POINT_TYPE_32: memcpy(ep.ep21.anchor_string, "_SM_", 4); memcpy(ep.ep21.intermediate_anchor_string, "_DMI_", 5); ep.ep21.length = sizeof(struct smbios_21_entry_point); @@ -950,7 +950,7 @@ static void smbios_entry_point_setup(void) ep.ep21.structure_table_address = cpu_to_le32(0); break; - case SMBIOS_ENTRY_POINT_30: + case SMBIOS_ENTRY_POINT_TYPE_64: memcpy(ep.ep30.anchor_string, "_SM3_", 5); ep.ep30.length = sizeof(struct smbios_30_entry_point); ep.ep30.entry_point_revision = 1; From patchwork Fri Jan 7 11:04:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576566 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iJEt7eI6; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgx43LnSz9tjx for ; Fri, 7 Jan 2022 22:29:44 +1100 (AEDT) Received: from localhost ([::1]:59416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nRG-0007OU-AX for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:29:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2u-0000go-3V for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:30624) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2s-0001ue-4Y for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553467; 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=Cur9SUZpW8iaVGB6IQWM8uAhUApOuqbaIkx16EmO6Y0=; b=iJEt7eI6Wut6d0km16V3lNeWuCsDoStourRoLmgd0bPIqxmt2OonEqxXRT0WXqqQefQunG n1NuwOaM9+dIP+qEuP3ecFfVuNK8K9BtD/RIZsB1r07Y2sWQhtURSahXiEYTebH99AVrxG U16Uj2XlimisVP2OJlqcg7dzhkBPQUo= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-631-ZjK0HZY5Njqa-CL5H-XnBQ-1; Fri, 07 Jan 2022 06:04:26 -0500 X-MC-Unique: ZjK0HZY5Njqa-CL5H-XnBQ-1 Received: by mail-wm1-f70.google.com with SMTP id o18-20020a05600c511200b00345c1603997so702959wms.1 for ; Fri, 07 Jan 2022 03:04:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Cur9SUZpW8iaVGB6IQWM8uAhUApOuqbaIkx16EmO6Y0=; b=qFt/XwltmclD5i8F/Eic05ty+4+d31I9Q7hDusf2thdqWFO6Jn6TjyTCBu1LR4D+pb 7KgXrPdyu99EKJx4BgjJPY0ob74Ps4vH3H55p1JklG5qfTZAKuda7mpMWEuHloyw92un 7MgC7JetrynBM5rpfguo/TM4/ltO0Hfx7LM3/40JzvhPGtuxmqjpg1U8NXom5MjgcdcM Mwt/SqnPOZtvid22Bl3tZbTxir9/TFGkoJoRvoxPN3t1I4ma6BnomDN2nyfvz0Mzb1Ci A37P8Nwp7Do3qtpA01IOb+4WIrk4+azlkCD4WCBoq4+SkEasFG+4WmucAs84Uw0Q/p19 3xVQ== X-Gm-Message-State: AOAM533P2JSxpSnGrjwBy2dtwfaq3IA7nrZ68CpJ8j/O9f5hzt/lgSw4 qeUEt1S06ovUnRd7MIgwdTInnBr9fD046L2dkQFGdk/oSlLXnieiIxwj4UKsG8t9jssrV8JhN6p E9oG1VxyIkoJ+utkDn4AEG7E6ocaroKbSCgixmmwpA3BGueF012DTBPDQ06Sg X-Received: by 2002:adf:d0cd:: with SMTP id z13mr53904405wrh.103.1641553465279; Fri, 07 Jan 2022 03:04:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6QyBSCWQZVOusfh+2ecHvFPLZTWXw+PPsGaho9/OInoygKx4MEuLBXvML46TKctW8bB7izA== X-Received: by 2002:adf:d0cd:: with SMTP id z13mr53904377wrh.103.1641553465023; Fri, 07 Jan 2022 03:04:25 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id bk2sm4357887wrb.65.2022.01.07.03.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:24 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 26/55] hw/smbios: Use qapi for SmbiosEntryPointType Message-ID: <20220107102526.39238-27-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Peter Maydell , Daniel P =?utf-8?b?LiBCZXJyYW5n?= =?utf-8?b?w6k=?= , Eduardo Habkost , Eric Blake , Markus Armbruster , Philippe =?utf-8?q?Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Yanan Wang , Ani Sinha , Igor Mammedov , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eduardo Habkost This prepares for exposing the SMBIOS entry point type as a machine property on x86. Based on a patch from Daniel P. Berrangé. Signed-off-by: Daniel P. Berrangé Signed-off-by: Eduardo Habkost Message-Id: <20211026151100.1691925-3-ehabkost@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé Acked-by: Markus Armbruster --- qapi/machine.json | 12 ++++++++++++ include/hw/firmware/smbios.h | 10 ++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index 372535b348..b6a37e17c4 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1568,3 +1568,15 @@ { 'command': 'x-query-usb', 'returns': 'HumanReadableText', 'features': [ 'unstable' ] } + +## +# @SmbiosEntryPointType: +# +# @32: SMBIOS version 2.1 (32-bit) Entry Point +# +# @64: SMBIOS version 3.0 (64-bit) Entry Point +# +# Since: 7.0 +## +{ 'enum': 'SmbiosEntryPointType', + 'data': [ '32', '64' ] } diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index d916baed6a..4b7ad77a44 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -1,6 +1,8 @@ #ifndef QEMU_SMBIOS_H #define QEMU_SMBIOS_H +#include "qapi/qapi-types-machine.h" + /* * SMBIOS Support * @@ -23,14 +25,6 @@ struct smbios_phys_mem_area { uint64_t length; }; -/* - * SMBIOS spec defined tables - */ -typedef enum SmbiosEntryPointType { - SMBIOS_ENTRY_POINT_TYPE_32, - SMBIOS_ENTRY_POINT_TYPE_64, -} SmbiosEntryPointType; - /* SMBIOS Entry Point * There are two types of entry points defined in the SMBIOS specification * (see below). BIOS must place the entry point(s) at a 16-byte-aligned From patchwork Fri Jan 7 11:04:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576585 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=M7qDrU5Q; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhMD5t6Pz9tjx for ; Fri, 7 Jan 2022 22:48:56 +1100 (AEDT) Received: from localhost ([::1]:46234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5njq-0008Ki-Ei for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:48:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2z-0000u4-AB for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54688) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2t-0001vP-OC for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553471; 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=EtPfDvFmE3YguG6jVHreVpLhjGHZGLUGaDiekrm7E4k=; b=M7qDrU5QOlv8GlAeZqoKU+xp6S3WPiGJilhO+l1xZwTzhUl3PKuRo+E/ZsOU26XMqEO/4j JUeGhWJCqlnKXEE34c5YmVxfcykaMM364a/NFUwlnIGV7ytqbCK9bk8hnBN0Pm7FcFOzeh GThwCk+RqRWd0YVxzY9NXKFvH0l1iu0= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-2-KKS9CEzsMaGB8I6L1aLRrg-1; Fri, 07 Jan 2022 06:04:29 -0500 X-MC-Unique: KKS9CEzsMaGB8I6L1aLRrg-1 Received: by mail-wr1-f70.google.com with SMTP id n4-20020adf8b04000000b001a49cff5283so2075667wra.14 for ; Fri, 07 Jan 2022 03:04:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=EtPfDvFmE3YguG6jVHreVpLhjGHZGLUGaDiekrm7E4k=; b=eJI22QinTNnYfprm38lTY3kuOvaR30xhIEqR8UK+rv/9IGH4D+ZgCaTKNcaZWbTnpE FpGoPKT/Rt1/uREUXwObPgmF/UWOk73gODkvMlx7OuXQ3j7fjdbF59YGaKOQQZ88JS9I o/80OMAkI7GnmUft17+9Y0tXuTSbWZMVX5vfs7KMfD7MWGYfmrHwv14585kQPZggLV25 AfMgGMdofNiajti4DYziEtmLQa6K4ZD+V4Zr8eH65UzrKz8DyxE+EJPxpOacq4EIPp7+ /hXyVGrzfuo0rRIeoTP24p5YbY0aN6V5qIhqATIVIYV3Jzn/GCzGD3/9PZ9qFVe6O3iI SWVg== X-Gm-Message-State: AOAM530FrcpLPq2lDdilMby+0a+Ragh2RD0fXQ61rul9ctN6tz+5uTn5 ne0DX/p4J0z7LHXL+MEagcrGPVo8Otx4M/rrBCrie83G93Y1wlUhY3SPRBnivKrYVyCd75YcJPZ A3j9TvEMZWk0T0ci1xXSQ7eVMiq7o3255UGK5rX8mVQcIAitjJEmp/dnc4LNF X-Received: by 2002:a5d:65c9:: with SMTP id e9mr919040wrw.181.1641553468239; Fri, 07 Jan 2022 03:04:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzPIMEGKflJI9OkF3ooLTqS6x3151YFFeTzGhIzoiaxQek9kN3tPxPn8gYK76JJV/sLaJURQ== X-Received: by 2002:a5d:65c9:: with SMTP id e9mr919014wrw.181.1641553467954; Fri, 07 Jan 2022 03:04:27 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id x8sm7220575wmj.44.2022.01.07.03.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:27 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 27/55] hw/i386: expose a "smbios-entry-point-type" PC machine property Message-ID: <20220107102526.39238-28-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Peter Maydell , Daniel P =?utf-8?b?LiBCZXJyYW5n?= =?utf-8?b?w6k=?= , Eduardo Habkost , Richard Henderson , Paolo Bonzini , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eduardo Habkost The i440fx and Q35 machine types are both hardcoded to use the legacy SMBIOS 2.1 (32-bit) entry point. This is a sensible conservative choice because SeaBIOS only supports SMBIOS 2.1 EDK2, however, can also support SMBIOS 3.0 (64-bit) entry points, and QEMU already uses this on the ARM virt machine type. This adds a property to allow the choice of SMBIOS entry point versions For example to opt in to 64-bit SMBIOS entry point: $QEMU -machine q35,smbios-entry-point-type=64 Based on a patch submitted by Daniel Berrangé. Signed-off-by: Daniel P. Berrangé Signed-off-by: Eduardo Habkost Message-Id: <20211026151100.1691925-4-ehabkost@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé --- include/hw/i386/pc.h | 4 ++++ hw/i386/pc.c | 26 ++++++++++++++++++++++++++ hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index b38947c224..9c9f4ac748 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -13,6 +13,7 @@ #include "hw/hotplug.h" #include "qom/object.h" #include "hw/i386/sgx-epc.h" +#include "hw/firmware/smbios.h" #define HPET_INTCAP "hpet-intcap" @@ -40,6 +41,7 @@ typedef struct PCMachineState { /* Configuration options: */ uint64_t max_ram_below_4g; OnOffAuto vmport; + SmbiosEntryPointType smbios_entry_point_type; bool acpi_build_enabled; bool smbus_enabled; @@ -63,6 +65,8 @@ typedef struct PCMachineState { #define PC_MACHINE_SATA "sata" #define PC_MACHINE_PIT "pit" #define PC_MACHINE_MAX_FW_SIZE "max-fw-size" +#define PC_MACHINE_SMBIOS_EP "smbios-entry-point-type" + /** * PCMachineClass: * diff --git a/hw/i386/pc.c b/hw/i386/pc.c index fccde2ef39..959efa5b3f 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -77,6 +77,7 @@ #include "hw/mem/nvdimm.h" #include "qapi/error.h" #include "qapi/qapi-visit-common.h" +#include "qapi/qapi-visit-machine.h" #include "qapi/visitor.h" #include "hw/core/cpu.h" #include "hw/usb.h" @@ -1524,6 +1525,23 @@ static void pc_machine_set_default_bus_bypass_iommu(Object *obj, bool value, pcms->default_bus_bypass_iommu = value; } +static void pc_machine_get_smbios_ep(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + PCMachineState *pcms = PC_MACHINE(obj); + SmbiosEntryPointType smbios_entry_point_type = pcms->smbios_entry_point_type; + + visit_type_SmbiosEntryPointType(v, name, &smbios_entry_point_type, errp); +} + +static void pc_machine_set_smbios_ep(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + PCMachineState *pcms = PC_MACHINE(obj); + + visit_type_SmbiosEntryPointType(v, name, &pcms->smbios_entry_point_type, errp); +} + static void pc_machine_get_max_ram_below_4g(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -1614,6 +1632,8 @@ static void pc_machine_initfn(Object *obj) pcms->vmport = ON_OFF_AUTO_OFF; #endif /* CONFIG_VMPORT */ pcms->max_ram_below_4g = 0; /* use default */ + pcms->smbios_entry_point_type = SMBIOS_ENTRY_POINT_TYPE_32; + /* acpi build is enabled by default if machine supports it */ pcms->acpi_build_enabled = PC_MACHINE_GET_CLASS(pcms)->has_acpi_build; pcms->smbus_enabled = true; @@ -1756,6 +1776,12 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) NULL, NULL); object_class_property_set_description(oc, PC_MACHINE_MAX_FW_SIZE, "Maximum combined firmware size"); + + object_class_property_add(oc, PC_MACHINE_SMBIOS_EP, "str", + pc_machine_get_smbios_ep, pc_machine_set_smbios_ep, + NULL, NULL); + object_class_property_set_description(oc, PC_MACHINE_SMBIOS_EP, + "SMBIOS Entry Point type [32, 64]"); } static const TypeInfo pc_machine_info = { diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 25f918b609..7c7790a5ce 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -177,7 +177,7 @@ static void pc_init1(MachineState *machine, smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)", mc->name, pcmc->smbios_legacy_mode, pcmc->smbios_uuid_encoded, - SMBIOS_ENTRY_POINT_TYPE_32); + pcms->smbios_entry_point_type); } /* allocate ram and load rom/bios */ diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 1103fbcd90..1780f79bc1 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -200,7 +200,7 @@ static void pc_q35_init(MachineState *machine) smbios_set_defaults("QEMU", "Standard PC (Q35 + ICH9, 2009)", mc->name, pcmc->smbios_legacy_mode, pcmc->smbios_uuid_encoded, - SMBIOS_ENTRY_POINT_TYPE_32); + pcms->smbios_entry_point_type); } /* allocate ram and load rom/bios */ From patchwork Fri Jan 7 11:04:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576580 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GjxsaQJY; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhHR4Xt7z9tjx for ; Fri, 7 Jan 2022 22:45:38 +1100 (AEDT) Received: from localhost ([::1]:37648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5ngc-00026S-PQ for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:45:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2y-0000rr-Jq for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2v-0001vl-Uq for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553473; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0yWWiwVH77KlZ9OPEUiCyLgKjq9lYAjmwlptCwnsdb0=; b=GjxsaQJYMwfW7J1tZCDO1LPNhcZvWo8ivdVAWy384sDhUvWAntJmLRsKjsxrZx3oyQhyHN yL6t3nkWb9bnSnPFQclLJhIOtHN/9s+EbjbXem+WQaMelIfYXHLwJggTq+m6GRdRWgP24J tfWZM0BaoiLZcjlvGOw+8A7CKXUKVTE= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-358-wrCD3D3SPluSY5AnM-n24A-1; Fri, 07 Jan 2022 06:04:32 -0500 X-MC-Unique: wrCD3D3SPluSY5AnM-n24A-1 Received: by mail-wr1-f72.google.com with SMTP id g6-20020adfbc86000000b001a2d62be244so2088376wrh.23 for ; Fri, 07 Jan 2022 03:04:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0yWWiwVH77KlZ9OPEUiCyLgKjq9lYAjmwlptCwnsdb0=; b=O9hcZtAR8EkpB5j6Eh8MTkN8zX9cUW1QXQUbAhD/CwLkgo2fJ7zwcQKhnE2gq8LF98 SRthLGfVX32vAgbiUFtwE6p86q13CSTFQI0syTmJ49esm4VZFtXwJg1eSm/JrSJDXzyO vrwaytuX+Fn5zrq0hsQ5mn9l/8/HeJSLULYvIJiYI4QTpp3KUXx/ohoGMCoec8i2NwW+ og1mb6LJJSO+zBQ3mgFML4ytU14EJE1dLVDXH+xNf0h0fuPNVlM/egsPA7+B0Z4j4xsC a+cVAKh1ZllhJhXdsMymgp+hPn4yuE2Z0Ey+78XVJ0/q3LjCkxUzriAK8Awuq8P/kHLP ZQ5Q== X-Gm-Message-State: AOAM530rcCIfLO9LeFM97SdnG2UMf0uc2F29Ei1l/i30gR0WiVWdkAfx cThXAtrq+l9Nrti5kX0Qlt3GtIATeEDu17PuykYqjE4TXOK29NSichvtAk7PwYrLJyLFKqKELp+ 33CvtsJf4e8lHePtQpvbxdscK/C8LMbFhA1EslXkTUnwhz3w1H3SR5sHEX+Sh X-Received: by 2002:a5d:65c9:: with SMTP id e9mr919203wrw.181.1641553470977; Fri, 07 Jan 2022 03:04:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6ZQXycovL24gf3HoQTMCVmELVNbjo/4AGJWIUuzSyGXJ+wXaVc5DiXE1CUR91mM7JwXj8eA== X-Received: by 2002:a5d:65c9:: with SMTP id e9mr919184wrw.181.1641553470812; Fri, 07 Jan 2022 03:04:30 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id 11sm5972406wrz.63.2022.01.07.03.04.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:30 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 28/55] hw/vhost-user-blk: turn on VIRTIO_BLK_F_SIZE_MAX feature for virtio blk device Message-ID: <20220107102526.39238-29-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Raphael Norwitz , Hanna Reitz , Andy Pei Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Andy Pei Turn on pre-defined feature VIRTIO_BLK_F_SIZE_MAX for virtio blk device to avoid guest DMA request sizes which are too large for hardware spec. Signed-off-by: Andy Pei Message-Id: <1641202092-149677-1-git-send-email-andy.pei@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index ab11ce8252..1a42ae9187 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -252,6 +252,7 @@ static uint64_t vhost_user_blk_get_features(VirtIODevice *vdev, VHostUserBlk *s = VHOST_USER_BLK(vdev); /* Turn on pre-defined features */ + virtio_add_feature(&features, VIRTIO_BLK_F_SIZE_MAX); virtio_add_feature(&features, VIRTIO_BLK_F_SEG_MAX); virtio_add_feature(&features, VIRTIO_BLK_F_GEOMETRY); virtio_add_feature(&features, VIRTIO_BLK_F_TOPOLOGY); From patchwork Fri Jan 7 11:04:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VjIboMBW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgyy6Lnnz9tjx for ; Fri, 7 Jan 2022 22:31:22 +1100 (AEDT) Received: from localhost ([::1]:33768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nSq-0000hr-3Y for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:31:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n30-0000zC-IN for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31673) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n2y-0001wY-TZ for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553476; 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=BkGrOZuaN+sKQzXuSFchNjulrxzkzkS5BeUisZ+6J2Q=; b=VjIboMBWgOkU41eqwKO4ABlCiGN5fh6SRycozm83J15YtI1eGuL0BaptTf6xB6ZMx85a85 4WR+Ae4WtqNnjrgTb3c/WFA8Y/+18e+SoPJ+ZJjRz+3cpU3i3BxlKeZzJ/CwkF8yblp6et wV++jdG8msR6NyOYiB9R3uUkVB0lDS0= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-645-jXunga79OwWY8ZbubdI8AA-1; Fri, 07 Jan 2022 06:04:35 -0500 X-MC-Unique: jXunga79OwWY8ZbubdI8AA-1 Received: by mail-wr1-f70.google.com with SMTP id r10-20020adfa14a000000b001a375e65e60so2119084wrr.2 for ; Fri, 07 Jan 2022 03:04:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=BkGrOZuaN+sKQzXuSFchNjulrxzkzkS5BeUisZ+6J2Q=; b=1fsstBkuHQiB6C3oJMR4RZoSPXn+znusYybfjGILJhwY4h5UkfuW4DXj5LkvFtUJWr V7gv9bGWiD3+uQ1EqNjH4sq0aVKppXG7gBe16CqbGxrYuXyrD4+FaUN5hs0S2mtPzqY7 pn0ik9TChY4FLCLl4WO+QU0pblXGiQP9+X9UX0LB6wZZAhGXK3+eaXb8CIGgS9O2IPqT kfa07Gcy2Av8macKkkok6aYg00guJC0AfMTeDm701Ig4QrKfARcS6c8y4wl+MUIxPZPS GKlC1vpJtgbPMh8/gg5Jt9S50QXhqlYZSn4LIh0+s6xf4LKbNrKPWAFdTLJeqOE9HZkg NlgA== X-Gm-Message-State: AOAM532EI6BlkTKz/9oXE7EluHX7ugIJngTndRF0ehG6DlrzVj6tBl/q AEzUcaTUL6oTQB1KKEtrHpS/Bx8yxibPKpgmY+xHN0YmAC+4zEDLA6tep5JNDEA4Bm4sIAHPgoM yB/LwXM5BsAOaKniq4n51JrvyGfUW+WmIPtwncBW/A8M3OtGibDYzuXHF+rLR X-Received: by 2002:a05:600c:2245:: with SMTP id a5mr7012683wmm.47.1641553473808; Fri, 07 Jan 2022 03:04:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJyE8KuM7WLMYyXPak3nGDpb5lcyss2piFtJ6eN17X6bZUBNxkzu/OJAh6WNb1KSPBlZLs16Ng== X-Received: by 2002:a05:600c:2245:: with SMTP id a5mr7012663wmm.47.1641553473605; Fri, 07 Jan 2022 03:04:33 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id o3sm5168379wry.98.2022.01.07.03.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:33 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:31 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 29/55] util/oslib-posix: Let touch_all_pages() return an error Message-ID: <20220107102526.39238-30-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Privoznik , Peter Maydell , Paolo Bonzini , Daniel P =?utf-8?b?LiBCZXJyYW5nw6k=?= , David Hildenbrand Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Let's prepare touch_all_pages() for returning differing errors. Return an error from the thread and report the last processed error. Translate SIGBUS to -EFAULT, as a SIGBUS can mean all different kind of things (memory error, read error, out of memory). When allocating memory fails via the current SIGBUS-based mechanism, we'll get: os_mem_prealloc: preallocating memory failed: Bad address Reviewed-by: Daniel P. Berrangé Reviewed-by: Michal Privoznik Signed-off-by: David Hildenbrand Message-Id: <20211217134611.31172-2-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- util/oslib-posix.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index e8bdb02e1d..b146beef78 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -84,7 +84,6 @@ typedef struct MemsetThread MemsetThread; static MemsetThread *memset_thread; static int memset_num_threads; -static bool memset_thread_failed; static QemuMutex page_mutex; static QemuCond page_cond; @@ -452,6 +451,7 @@ static void *do_touch_pages(void *arg) { MemsetThread *memset_args = (MemsetThread *)arg; sigset_t set, oldset; + int ret = 0; /* * On Linux, the page faults from the loop below can cause mmap_sem @@ -470,7 +470,7 @@ static void *do_touch_pages(void *arg) pthread_sigmask(SIG_UNBLOCK, &set, &oldset); if (sigsetjmp(memset_args->env, 1)) { - memset_thread_failed = true; + ret = -EFAULT; } else { char *addr = memset_args->addr; size_t numpages = memset_args->numpages; @@ -494,7 +494,7 @@ static void *do_touch_pages(void *arg) } } pthread_sigmask(SIG_SETMASK, &oldset, NULL); - return NULL; + return (void *)(uintptr_t)ret; } static inline int get_memset_num_threads(int smp_cpus) @@ -509,13 +509,13 @@ static inline int get_memset_num_threads(int smp_cpus) return ret; } -static bool touch_all_pages(char *area, size_t hpagesize, size_t numpages, - int smp_cpus) +static int touch_all_pages(char *area, size_t hpagesize, size_t numpages, + int smp_cpus) { static gsize initialized = 0; size_t numpages_per_thread, leftover; + int ret = 0, i = 0; char *addr = area; - int i = 0; if (g_once_init_enter(&initialized)) { qemu_mutex_init(&page_mutex); @@ -523,7 +523,6 @@ static bool touch_all_pages(char *area, size_t hpagesize, size_t numpages, g_once_init_leave(&initialized, 1); } - memset_thread_failed = false; threads_created_flag = false; memset_num_threads = get_memset_num_threads(smp_cpus); memset_thread = g_new0(MemsetThread, memset_num_threads); @@ -545,12 +544,16 @@ static bool touch_all_pages(char *area, size_t hpagesize, size_t numpages, qemu_mutex_unlock(&page_mutex); for (i = 0; i < memset_num_threads; i++) { - qemu_thread_join(&memset_thread[i].pgthread); + int tmp = (uintptr_t)qemu_thread_join(&memset_thread[i].pgthread); + + if (tmp) { + ret = tmp; + } } g_free(memset_thread); memset_thread = NULL; - return memset_thread_failed; + return ret; } void os_mem_prealloc(int fd, char *area, size_t memory, int smp_cpus, @@ -573,9 +576,10 @@ void os_mem_prealloc(int fd, char *area, size_t memory, int smp_cpus, } /* touch pages simultaneously */ - if (touch_all_pages(area, hpagesize, numpages, smp_cpus)) { - error_setg(errp, "os_mem_prealloc: Insufficient free host memory " - "pages available to allocate guest RAM"); + ret = touch_all_pages(area, hpagesize, numpages, smp_cpus); + if (ret) { + error_setg_errno(errp, -ret, + "os_mem_prealloc: preallocating memory failed"); } ret = sigaction(SIGBUS, &oldact, NULL); From patchwork Fri Jan 7 11:04:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576571 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NNdYrJZ+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVh310WQZz9tjx for ; Fri, 7 Jan 2022 22:34:53 +1100 (AEDT) Received: from localhost ([::1]:42408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nWE-0000nN-T6 for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:34:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n35-00019g-BC for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n33-0001y1-4e for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553480; 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=KVxkk8Uxdp5ILdib1v4tCfXPzG0FgwtRAVmrjfHU5Bg=; b=NNdYrJZ+Ulvd+9KQvOmBHe0BfPkhJzicwgaysuBe1xkxKdxgW6vBmOHyAWYV1m2UMPr6MU 7SDHcibtDaLFcD3gJxs/QjaDkKsPaIh7dvl8x0qml8rfJhHxiA2lC2Nglptl1ioJthe3zd LUZeQ8MDMaynXCxiQ4ma3lMOx+PSh14= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-416-0ZHKOlsYPemrlvGrShiqvw-1; Fri, 07 Jan 2022 06:04:39 -0500 X-MC-Unique: 0ZHKOlsYPemrlvGrShiqvw-1 Received: by mail-wr1-f69.google.com with SMTP id i23-20020adfaad7000000b001a6320b66b9so263242wrc.15 for ; Fri, 07 Jan 2022 03:04:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=KVxkk8Uxdp5ILdib1v4tCfXPzG0FgwtRAVmrjfHU5Bg=; b=auE8W+t7v4aAzPIdisdcaT7XlOml5Lcb/cP+3GHPI7QEb9WITP0M2y1t89ZvgPZtf2 TiEDsTl+1gEo9jh0tn74qRI9KymWhlgT/ZiOG/MyXD9hLqbJ3WMgJPtJ7xCXJzZLJKIZ XHZAOyAHMzFaQCOGw4x/1/hiZk1GGROH+yiEFfUip2eL9qsVCktqDSQ6+iDJHa4JzmSY Ddaf6zA3Bwj7ZePkNiVjpZZKQActtzW8Cmi8MHTYtc/R1lQT4cMPaxdes0G2R0+nNhBB lF0RpDP3QIxXVR2GPgRRaB6GN/kEoBuVyt+3IkX3IvSERnj1EUNXiVD1mcupjY6BiHfL 3evQ== X-Gm-Message-State: AOAM530s0jEKJeuiR8uBN2ay4ORzw+M+a/nGgquXOf2JSIVeFuUaTuHN hfgXXV3dKRUI1mD4uYNruUCjVK2zaUrnEm3TrVx4+R0Zsdj+/wLJAFhCTmDbimUhouaI3X5VUM7 t3MXEVli/NfocokWfu/kxQTiX770z5D4HEHd/OXdOSyAjGo6Fd+jvHjBruv3b X-Received: by 2002:a05:600c:4f49:: with SMTP id m9mr10633642wmq.8.1641553477153; Fri, 07 Jan 2022 03:04:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJygTYI9gBXld0VUFNtgZSKGqBEMUAC81pD8SR8m3fdC5wLKUX9Z0tcktT2mXpFLPCYScmiQhQ== X-Received: by 2002:a05:600c:4f49:: with SMTP id m9mr10633619wmq.8.1641553476853; Fri, 07 Jan 2022 03:04:36 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id p18sm8151869wmq.23.2022.01.07.03.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:36 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 30/55] util/oslib-posix: Support MADV_POPULATE_WRITE for os_mem_prealloc() Message-ID: <20220107102526.39238-31-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Daniel P =?utf-8?b?LiBCZXJy?= =?utf-8?b?YW5nw6k=?= , David Hildenbrand , Michal Privoznik , Pankaj Gupta , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Let's sense support and use it for preallocation. MADV_POPULATE_WRITE does not require a SIGBUS handler, doesn't actually touch page content, and avoids context switches; it is, therefore, faster and easier to handle than our current approach. While MADV_POPULATE_WRITE is, in general, faster than manual prefaulting, and especially faster with 4k pages, there is still value in prefaulting using multiple threads to speed up preallocation. More details on MADV_POPULATE_WRITE can be found in the Linux commits 4ca9b3859dac ("mm/madvise: introduce MADV_POPULATE_(READ|WRITE) to prefault page tables") and eb2faa513c24 ("mm/madvise: report SIGBUS as -EFAULT for MADV_POPULATE_(READ|WRITE)"), and in the man page proposal [1]. This resolves the TODO in do_touch_pages(). In the future, we might want to look into using fallocate(), eventually combined with MADV_POPULATE_READ, when dealing with shared file/fd mappings and not caring about memory bindings. [1] https://lkml.kernel.org/r/20210816081922.5155-1-david@redhat.com Reviewed-by: Pankaj Gupta Reviewed-by: Daniel P. Berrangé Reviewed-by: Michal Privoznik Signed-off-by: David Hildenbrand Message-Id: <20211217134611.31172-3-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/qemu/osdep.h | 7 ++++ util/oslib-posix.c | 81 +++++++++++++++++++++++++++++++++----------- 2 files changed, 68 insertions(+), 20 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 60718fc342..d1660d67fa 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -471,6 +471,11 @@ static inline void qemu_cleanup_generic_vfree(void *p) #else #define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED #endif +#ifdef MADV_POPULATE_WRITE +#define QEMU_MADV_POPULATE_WRITE MADV_POPULATE_WRITE +#else +#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID +#endif #elif defined(CONFIG_POSIX_MADVISE) @@ -484,6 +489,7 @@ static inline void qemu_cleanup_generic_vfree(void *p) #define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID #define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID #define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED +#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID #else /* no-op */ @@ -497,6 +503,7 @@ static inline void qemu_cleanup_generic_vfree(void *p) #define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID #define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID #define QEMU_MADV_REMOVE QEMU_MADV_INVALID +#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID #endif diff --git a/util/oslib-posix.c b/util/oslib-posix.c index b146beef78..cb89e07770 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -484,10 +484,6 @@ static void *do_touch_pages(void *arg) * * 'volatile' to stop compiler optimizing this away * to a no-op - * - * TODO: get a better solution from kernel so we - * don't need to write at all so we don't cause - * wear on the storage backing the region... */ *(volatile char *)addr = *addr; addr += hpagesize; @@ -497,6 +493,26 @@ static void *do_touch_pages(void *arg) return (void *)(uintptr_t)ret; } +static void *do_madv_populate_write_pages(void *arg) +{ + MemsetThread *memset_args = (MemsetThread *)arg; + const size_t size = memset_args->numpages * memset_args->hpagesize; + char * const addr = memset_args->addr; + int ret = 0; + + /* See do_touch_pages(). */ + qemu_mutex_lock(&page_mutex); + while (!threads_created_flag) { + qemu_cond_wait(&page_cond, &page_mutex); + } + qemu_mutex_unlock(&page_mutex); + + if (size && qemu_madvise(addr, size, QEMU_MADV_POPULATE_WRITE)) { + ret = -errno; + } + return (void *)(uintptr_t)ret; +} + static inline int get_memset_num_threads(int smp_cpus) { long host_procs = sysconf(_SC_NPROCESSORS_ONLN); @@ -510,10 +526,11 @@ static inline int get_memset_num_threads(int smp_cpus) } static int touch_all_pages(char *area, size_t hpagesize, size_t numpages, - int smp_cpus) + int smp_cpus, bool use_madv_populate_write) { static gsize initialized = 0; size_t numpages_per_thread, leftover; + void *(*touch_fn)(void *); int ret = 0, i = 0; char *addr = area; @@ -523,6 +540,12 @@ static int touch_all_pages(char *area, size_t hpagesize, size_t numpages, g_once_init_leave(&initialized, 1); } + if (use_madv_populate_write) { + touch_fn = do_madv_populate_write_pages; + } else { + touch_fn = do_touch_pages; + } + threads_created_flag = false; memset_num_threads = get_memset_num_threads(smp_cpus); memset_thread = g_new0(MemsetThread, memset_num_threads); @@ -533,7 +556,7 @@ static int touch_all_pages(char *area, size_t hpagesize, size_t numpages, memset_thread[i].numpages = numpages_per_thread + (i < leftover); memset_thread[i].hpagesize = hpagesize; qemu_thread_create(&memset_thread[i].pgthread, "touch_pages", - do_touch_pages, &memset_thread[i], + touch_fn, &memset_thread[i], QEMU_THREAD_JOINABLE); addr += memset_thread[i].numpages * hpagesize; } @@ -556,6 +579,12 @@ static int touch_all_pages(char *area, size_t hpagesize, size_t numpages, return ret; } +static bool madv_populate_write_possible(char *area, size_t pagesize) +{ + return !qemu_madvise(area, pagesize, QEMU_MADV_POPULATE_WRITE) || + errno != EINVAL; +} + void os_mem_prealloc(int fd, char *area, size_t memory, int smp_cpus, Error **errp) { @@ -563,30 +592,42 @@ void os_mem_prealloc(int fd, char *area, size_t memory, int smp_cpus, struct sigaction act, oldact; size_t hpagesize = qemu_fd_getpagesize(fd); size_t numpages = DIV_ROUND_UP(memory, hpagesize); + bool use_madv_populate_write; - memset(&act, 0, sizeof(act)); - act.sa_handler = &sigbus_handler; - act.sa_flags = 0; + /* + * Sense on every invocation, as MADV_POPULATE_WRITE cannot be used for + * some special mappings, such as mapping /dev/mem. + */ + use_madv_populate_write = madv_populate_write_possible(area, hpagesize); - ret = sigaction(SIGBUS, &act, &oldact); - if (ret) { - error_setg_errno(errp, errno, - "os_mem_prealloc: failed to install signal handler"); - return; + if (!use_madv_populate_write) { + memset(&act, 0, sizeof(act)); + act.sa_handler = &sigbus_handler; + act.sa_flags = 0; + + ret = sigaction(SIGBUS, &act, &oldact); + if (ret) { + error_setg_errno(errp, errno, + "os_mem_prealloc: failed to install signal handler"); + return; + } } /* touch pages simultaneously */ - ret = touch_all_pages(area, hpagesize, numpages, smp_cpus); + ret = touch_all_pages(area, hpagesize, numpages, smp_cpus, + use_madv_populate_write); if (ret) { error_setg_errno(errp, -ret, "os_mem_prealloc: preallocating memory failed"); } - ret = sigaction(SIGBUS, &oldact, NULL); - if (ret) { - /* Terminate QEMU since it can't recover from error */ - perror("os_mem_prealloc: failed to reinstall signal handler"); - exit(1); + if (!use_madv_populate_write) { + ret = sigaction(SIGBUS, &oldact, NULL); + if (ret) { + /* Terminate QEMU since it can't recover from error */ + perror("os_mem_prealloc: failed to reinstall signal handler"); + exit(1); + } } } From patchwork Fri Jan 7 11:04:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576590 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=E6awFcDA; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhRF10Tvz9tjx for ; Fri, 7 Jan 2022 22:52:23 +1100 (AEDT) Received: from localhost ([::1]:54952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nnA-0005qe-3I for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:52:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n36-0001B6-SR for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32993) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n35-0001yW-3g for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553482; 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=g64Nj4WV+Irx5qvL3Yea9s2X356RYx1CceDWXAsokho=; b=E6awFcDA3bS/vPBQF2ZHCasRypl0M7J93bz2vgPDcwKQ4B+L395eBo5Vu5CxQyGpBaq+bR g2NT9zIZkB3yvTrGxRzh4Frbb3uphH5vgXYr3zar40vGjRzn336SP18p6Jir18wWhfJSnJ fhwd1Bcp13Vwu35PvSWU+W8ZHPgcEVw= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-516-sIvAQtMlOO2t4PAMUbJtLg-1; Fri, 07 Jan 2022 06:04:41 -0500 X-MC-Unique: sIvAQtMlOO2t4PAMUbJtLg-1 Received: by mail-wm1-f70.google.com with SMTP id i81-20020a1c3b54000000b003467c58cbddso4119347wma.5 for ; Fri, 07 Jan 2022 03:04:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=g64Nj4WV+Irx5qvL3Yea9s2X356RYx1CceDWXAsokho=; b=rehwN86i07xKrMItThN8yEnlHamqXRWw6NeuzJxyEmasz9IeL2b5RusoFv/ctpUwKK G6aZ92avGw3hoMIHfBNgil/ukYyqDlHbjwAqAmKB43ga9j3MgZYgDGXk1vG8vLByucxl 8b+VUsBkw7qhdR3+Lj1iVTzk0HwWDwh2G/HXhOJN0eN1prZMmxMslrXG4++IEb/RDdWh YgN5GECA//Je5FvrRXqTf//3sYFXNQ3AIE1f0kHlD9NgI0n9yeOoz7iBOFWXBgKRaE/V JawzFr2SpVwtmL9+nPsmY8WgNOA6878hhIf8ZHJ20Di2SI1T1WeX20GBHC4Az073wmcW TZ9w== X-Gm-Message-State: AOAM531tmihywMlm+RM9b7AFJFPs+DRutVYPsiqCz6gCydOc8UB8fAxL rwXqEmy3gAXjjjRbKn7x5aoWQh7HNl6NKEN6EJOmMxTY05G40+qpAaMLV27kA1J6sP7Vo/Jl/Xf Rf00rFipi37E9rDhL5RLYT9RXcBmPP/tldj4KnKdv7jYPZHWxmkwkyXnpMFHt X-Received: by 2002:a1c:7214:: with SMTP id n20mr10749058wmc.118.1641553480277; Fri, 07 Jan 2022 03:04:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJz94HHCwJCPW/45wgTU2HA6FxxaWZRY6r4M7Bys1SKhrzC9QDNWWjLRQZojV2FYlQTF2RI+TQ== X-Received: by 2002:a1c:7214:: with SMTP id n20mr10749039wmc.118.1641553480005; Fri, 07 Jan 2022 03:04:40 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id j26sm8517901wms.46.2022.01.07.03.04.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:39 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 31/55] util/oslib-posix: Introduce and use MemsetContext for touch_all_pages() Message-ID: <20220107102526.39238-32-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Privoznik , Peter Maydell , Paolo Bonzini , Daniel P =?utf-8?b?LiBCZXJyYW5nw6k=?= , David Hildenbrand Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Let's minimize the number of global variables to prepare for os_mem_prealloc() getting called concurrently and make the code a bit easier to read. The only consumer that really needs a global variable is the sigbus handler, which will require protection via a mutex in the future either way as we cannot concurrently mess with the SIGBUS handler. Reviewed-by: Daniel P. Berrangé Reviewed-by: Michal Privoznik Signed-off-by: David Hildenbrand Message-Id: <20211217134611.31172-4-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- util/oslib-posix.c | 73 +++++++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index cb89e07770..cf2ead54ad 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -73,21 +73,30 @@ #define MAX_MEM_PREALLOC_THREAD_COUNT 16 +struct MemsetThread; + +typedef struct MemsetContext { + bool all_threads_created; + bool any_thread_failed; + struct MemsetThread *threads; + int num_threads; +} MemsetContext; + struct MemsetThread { char *addr; size_t numpages; size_t hpagesize; QemuThread pgthread; sigjmp_buf env; + MemsetContext *context; }; typedef struct MemsetThread MemsetThread; -static MemsetThread *memset_thread; -static int memset_num_threads; +/* used by sigbus_handler() */ +static MemsetContext *sigbus_memset_context; static QemuMutex page_mutex; static QemuCond page_cond; -static bool threads_created_flag; int qemu_get_thread_id(void) { @@ -438,10 +447,13 @@ const char *qemu_get_exec_dir(void) static void sigbus_handler(int signal) { int i; - if (memset_thread) { - for (i = 0; i < memset_num_threads; i++) { - if (qemu_thread_is_self(&memset_thread[i].pgthread)) { - siglongjmp(memset_thread[i].env, 1); + + if (sigbus_memset_context) { + for (i = 0; i < sigbus_memset_context->num_threads; i++) { + MemsetThread *thread = &sigbus_memset_context->threads[i]; + + if (qemu_thread_is_self(&thread->pgthread)) { + siglongjmp(thread->env, 1); } } } @@ -459,7 +471,7 @@ static void *do_touch_pages(void *arg) * clearing until all threads have been created. */ qemu_mutex_lock(&page_mutex); - while(!threads_created_flag){ + while (!memset_args->context->all_threads_created) { qemu_cond_wait(&page_cond, &page_mutex); } qemu_mutex_unlock(&page_mutex); @@ -502,7 +514,7 @@ static void *do_madv_populate_write_pages(void *arg) /* See do_touch_pages(). */ qemu_mutex_lock(&page_mutex); - while (!threads_created_flag) { + while (!memset_args->context->all_threads_created) { qemu_cond_wait(&page_cond, &page_mutex); } qemu_mutex_unlock(&page_mutex); @@ -529,6 +541,9 @@ static int touch_all_pages(char *area, size_t hpagesize, size_t numpages, int smp_cpus, bool use_madv_populate_write) { static gsize initialized = 0; + MemsetContext context = { + .num_threads = get_memset_num_threads(smp_cpus), + }; size_t numpages_per_thread, leftover; void *(*touch_fn)(void *); int ret = 0, i = 0; @@ -546,35 +561,41 @@ static int touch_all_pages(char *area, size_t hpagesize, size_t numpages, touch_fn = do_touch_pages; } - threads_created_flag = false; - memset_num_threads = get_memset_num_threads(smp_cpus); - memset_thread = g_new0(MemsetThread, memset_num_threads); - numpages_per_thread = numpages / memset_num_threads; - leftover = numpages % memset_num_threads; - for (i = 0; i < memset_num_threads; i++) { - memset_thread[i].addr = addr; - memset_thread[i].numpages = numpages_per_thread + (i < leftover); - memset_thread[i].hpagesize = hpagesize; - qemu_thread_create(&memset_thread[i].pgthread, "touch_pages", - touch_fn, &memset_thread[i], + context.threads = g_new0(MemsetThread, context.num_threads); + numpages_per_thread = numpages / context.num_threads; + leftover = numpages % context.num_threads; + for (i = 0; i < context.num_threads; i++) { + context.threads[i].addr = addr; + context.threads[i].numpages = numpages_per_thread + (i < leftover); + context.threads[i].hpagesize = hpagesize; + context.threads[i].context = &context; + qemu_thread_create(&context.threads[i].pgthread, "touch_pages", + touch_fn, &context.threads[i], QEMU_THREAD_JOINABLE); - addr += memset_thread[i].numpages * hpagesize; + addr += context.threads[i].numpages * hpagesize; + } + + if (!use_madv_populate_write) { + sigbus_memset_context = &context; } qemu_mutex_lock(&page_mutex); - threads_created_flag = true; + context.all_threads_created = true; qemu_cond_broadcast(&page_cond); qemu_mutex_unlock(&page_mutex); - for (i = 0; i < memset_num_threads; i++) { - int tmp = (uintptr_t)qemu_thread_join(&memset_thread[i].pgthread); + for (i = 0; i < context.num_threads; i++) { + int tmp = (uintptr_t)qemu_thread_join(&context.threads[i].pgthread); if (tmp) { ret = tmp; } } - g_free(memset_thread); - memset_thread = NULL; + + if (!use_madv_populate_write) { + sigbus_memset_context = NULL; + } + g_free(context.threads); return ret; } From patchwork Fri Jan 7 11:04:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576600 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GOjeRGz9; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhV44WZVz9tk3 for ; Fri, 7 Jan 2022 22:54:52 +1100 (AEDT) Received: from localhost ([::1]:35402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5npa-0003GT-Cw for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:54:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3B-0001Cq-Dy for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54316) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n38-0001zI-W5 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:04:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553486; 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=4akHXGYHIwd7HNeqwa3gMQKaZ7VYtAKPZ8TAtHqI2Gc=; b=GOjeRGz987bpStcYJr1GDItKayqAaFVNXR8hTA7Qc5YY1IQUYPWHtzDq8Co25jeT5R1jfe qrzhJN2CyyCR008QlhTeM+OxOedZe3/k4IuhBIyJ2dCWF84kH+BnUNuF6Lnugq5OYEKUQS 2jodqpGBUmURpDqgH6X8OXUfNTE2/cI= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-77-_kuNyE-XPvOMWk9xyiBZfA-1; Fri, 07 Jan 2022 06:04:45 -0500 X-MC-Unique: _kuNyE-XPvOMWk9xyiBZfA-1 Received: by mail-wr1-f71.google.com with SMTP id h24-20020adfaa98000000b001a4dbe0c51fso1780929wrc.0 for ; Fri, 07 Jan 2022 03:04:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=4akHXGYHIwd7HNeqwa3gMQKaZ7VYtAKPZ8TAtHqI2Gc=; b=5tc77OTzpPVLzezSSi9bmN8fO4ph06e++qv5mcn+lL+D1yVST7/9OVnaYcNHJuOoJa t5xxOCrx3Ozzkiy9KBS+AMrVw5W33IElOdQzH82BLjPnNE3Yl3ybotoTcqkSds4vQaaF SUaaveMPkSPFiMKFo8UcTzEI93z7IG14pmOokWlv0q4qHWTtUT0qGyAcNReUEGiNIPJe Kx+Hysw0+8Q/GlXyI3ExbhKbaL/X/yjjCysbLkKc33b6UsrIdA9sp3HKMUgOoeuwomwn iKj686m6zaAVFwYY9hIR18NXTjtdNBCp5q9ExCzZl97Fv6AWKj6oQ/4FOFKoIOd4so5J PZSQ== X-Gm-Message-State: AOAM533aiayKZ5xTmobjFflkCRfz03qhFohFcu7QqCnNkgQzjSekVtyF iFwoAkxZyusj8TFzTVWjI6m8FOhy6BVwaPGzd3UVh51mmaMvciJBXEEdjK3Mul92glTnv2huy4j NwYnorxkskiyEk6KnpGvMEwLLD+0VjwEZcHSjLBaFM4aO5n3WoKsM1kZGuZqB X-Received: by 2002:a05:6000:1002:: with SMTP id a2mr4282113wrx.501.1641553483370; Fri, 07 Jan 2022 03:04:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyidQzH+XJ35C0heg3oKG7uTqtYjFBlwa1atKvBNMCzOEKYFB5D24yDb3KC3Ki+U0gw8RdcNg== X-Received: by 2002:a05:6000:1002:: with SMTP id a2mr4282095wrx.501.1641553483184; Fri, 07 Jan 2022 03:04:43 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id q6sm4426000wrr.88.2022.01.07.03.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:42 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:40 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 32/55] util/oslib-posix: Don't create too many threads with small memory or little pages Message-ID: <20220107102526.39238-33-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Daniel P =?utf-8?b?LiBCZXJy?= =?utf-8?b?YW5nw6k=?= , David Hildenbrand , Michal Privoznik , Pankaj Gupta , "Dr . David Alan Gilbert" , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Let's limit the number of threads to something sane, especially that - We don't have more threads than the number of pages we have - We don't have threads that initialize small (< 64 MiB) memory Reviewed-by: Pankaj Gupta Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Daniel P. Berrangé Reviewed-by: Michal Privoznik Signed-off-by: David Hildenbrand Message-Id: <20211217134611.31172-5-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- util/oslib-posix.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index cf2ead54ad..67c08a425e 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -40,6 +40,7 @@ #include #include "qemu/cutils.h" #include "qemu/compiler.h" +#include "qemu/units.h" #ifdef CONFIG_LINUX #include @@ -525,7 +526,8 @@ static void *do_madv_populate_write_pages(void *arg) return (void *)(uintptr_t)ret; } -static inline int get_memset_num_threads(int smp_cpus) +static inline int get_memset_num_threads(size_t hpagesize, size_t numpages, + int smp_cpus) { long host_procs = sysconf(_SC_NPROCESSORS_ONLN); int ret = 1; @@ -533,6 +535,12 @@ static inline int get_memset_num_threads(int smp_cpus) if (host_procs > 0) { ret = MIN(MIN(host_procs, MAX_MEM_PREALLOC_THREAD_COUNT), smp_cpus); } + + /* Especially with gigantic pages, don't create more threads than pages. */ + ret = MIN(ret, numpages); + /* Don't start threads to prealloc comparatively little memory. */ + ret = MIN(ret, MAX(1, hpagesize * numpages / (64 * MiB))); + /* In case sysconf() fails, we fall back to single threaded */ return ret; } @@ -542,7 +550,7 @@ static int touch_all_pages(char *area, size_t hpagesize, size_t numpages, { static gsize initialized = 0; MemsetContext context = { - .num_threads = get_memset_num_threads(smp_cpus), + .num_threads = get_memset_num_threads(hpagesize, numpages, smp_cpus), }; size_t numpages_per_thread, leftover; void *(*touch_fn)(void *); From patchwork Fri Jan 7 11:04:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576564 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WI4TdFTH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgwZ1NFsz9tjx for ; Fri, 7 Jan 2022 22:29:18 +1100 (AEDT) Received: from localhost ([::1]:56764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nQo-0005Wj-VD for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:29:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3l-0001JC-1e for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:59636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3D-0001zX-70 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553489; 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=TnGOLm7lT8LwKDlvBDBF9jJhmbOnmc0+Fq8lIxyOVLg=; b=WI4TdFTH+eWAwSt92vLD0FK9psmXGzfEZIhsJmYjwFTQvdYe/25aCRMd9A8Rv+y8ch4Q52 0wxTnNLo6r/HNOGPP5SIk0/NlCDOFZ0NJcOQ/lbypvWrc3VFNL/iC4lsOKZHprG7LaUPZ/ 0OHMqksppzuMo15E60JuuTWpaV4laMQ= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-445-8IBhRD90NM2646DvbdCoYw-1; Fri, 07 Jan 2022 06:04:48 -0500 X-MC-Unique: 8IBhRD90NM2646DvbdCoYw-1 Received: by mail-wm1-f69.google.com with SMTP id e19-20020a05600c4e5300b003458be97976so1354103wmq.7 for ; Fri, 07 Jan 2022 03:04:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=TnGOLm7lT8LwKDlvBDBF9jJhmbOnmc0+Fq8lIxyOVLg=; b=yg1q+vRUIqzZ4pcVoR5PiP7ElCNE1MzIP6dw2m8emRPrfwj/kXTnm+Y4lNpnGPqqX6 oS3yRsnEAdjg0Ae4rj4JkUbawypTTSBfMVXQCGoYZZ/ogz9GnQcqDSdUg/GxqAhRXWYc 7WjmPZ/kUQgJheW3rFCb08u9LdCFj4P/z4L6n0jjdbirW1RyyQkcf7MQBwBz3ptyy4QG 8bQQuG4AfQnK91ORoqMfUI8lW5Gf0qRl5hILDkZxvvhOv0+qpik6RhrHXmLuaWAxXUJL Do0U2ZpKxkbAPMZFf0MSbcgVVEWcLfKqIae2y3JLjRkdSbm/Nb07hPcrUyxXRVg8ssa3 b2hg== X-Gm-Message-State: AOAM531sfyQuL0aivSpZHzZWWUd7tAJCxkam9CyhSkGlCwdj47ZYZmZX mJazddcuepvpPr5FGkbLunixIULBNZAVRxqTnV79rnEAW4aWl7FMnH8WfYKc8RcZOXAqglEyxLM ncuT3soceVuIHHfhhhLl0c5JtCrlgN9TxYa1O6c6ZaBYdq+iPEp2k4iXcFHid X-Received: by 2002:adf:a1d0:: with SMTP id v16mr8068660wrv.622.1641553486474; Fri, 07 Jan 2022 03:04:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyqUIXu61xSeOgWuQwjH7xYxk2x16Ctjya88vmdqXWu3lF7D2UGeq4M659cDbLa6uy9a/gJtg== X-Received: by 2002:adf:a1d0:: with SMTP id v16mr8068640wrv.622.1641553486199; Fri, 07 Jan 2022 03:04:46 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id r9sm4616859wrm.76.2022.01.07.03.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:45 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 33/55] util/oslib-posix: Avoid creating a single thread with MADV_POPULATE_WRITE Message-ID: <20220107102526.39238-34-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Daniel P =?utf-8?b?LiBCZXJy?= =?utf-8?b?YW5nw6k=?= , David Hildenbrand , Michal Privoznik , Pankaj Gupta , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Let's simplify the case when we only want a single thread and don't have to mess with signal handlers. Reviewed-by: Pankaj Gupta Reviewed-by: Daniel P. Berrangé Reviewed-by: Michal Privoznik Signed-off-by: David Hildenbrand Message-Id: <20211217134611.31172-6-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- util/oslib-posix.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 67c08a425e..efa4f96d56 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -564,6 +564,14 @@ static int touch_all_pages(char *area, size_t hpagesize, size_t numpages, } if (use_madv_populate_write) { + /* Avoid creating a single thread for MADV_POPULATE_WRITE */ + if (context.num_threads == 1) { + if (qemu_madvise(area, hpagesize * numpages, + QEMU_MADV_POPULATE_WRITE)) { + return -errno; + } + return 0; + } touch_fn = do_madv_populate_write_pages; } else { touch_fn = do_touch_pages; From patchwork Fri Jan 7 11:04:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576560 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=boZVSPzz; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVgpp3MK6z9tjx for ; Fri, 7 Jan 2022 22:24:18 +1100 (AEDT) Received: from localhost ([::1]:47954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nM0-0005Wi-AK for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:24:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3l-0001JF-7q for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:33589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3Q-0001zc-Cs for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553492; 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=9LQElm98aHXjiuFao5xnlm6/WpTSh3F0rFcwVGDak2Y=; b=boZVSPzzqwwTrW5p6cd7U3NIKN5zz5adlfCyHCJQNoEzPcI04hzKYQhp/1NGERDntDCcQQ g6FR4E/Y6qkynjkz+Zut44DfE1AXcoDmgc1Ep7TwQXYdTsdWjFlHgk/RKOMflGLMwERTrb xsGQU3NZg5x6GYl3/GI4Jkp00NRvR/I= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-455-L3E51C9rOR2TvEYEIGfYOA-1; Fri, 07 Jan 2022 06:04:51 -0500 X-MC-Unique: L3E51C9rOR2TvEYEIGfYOA-1 Received: by mail-wm1-f72.google.com with SMTP id i81-20020a1c3b54000000b003467c58cbddso4119472wma.5 for ; Fri, 07 Jan 2022 03:04:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=9LQElm98aHXjiuFao5xnlm6/WpTSh3F0rFcwVGDak2Y=; b=6VakFfTqcwJ5NYPNH7u0k+UUDUl6GD1aSvX3k79+EpwqkfERHzj9rORDH1HaTcrwOz 218gr4d60BxeDcKAwlvwjv0t71M9dgdOSQqg1G/fORyAdT/chRpNPyZtnYlriFPbsxqP 8nIEMq9ibD6UMEQFqZq3LRZtMda6VhVS/RS2tNBX1jCGygyUOjh6AT5Lhr4iTu5bbokP ydkjMLcXUplTBFboYk7PxH9sakgRQLgUg59jaLxCoI/grA+qx5orhdIM3jvoVtWykN7Z Ro76GpGoP2n1dZ4xO4iSwJOZFwx9YedyqPlU8XV0oGuYYeU3x9ziYSatAO0botUIhgh+ dOuQ== X-Gm-Message-State: AOAM530Vq+8xkkpok/Fr5DYU0e6ry7ZBun4p9PY5Ez/O/aZi64O+ShB4 TN3bii8SOJL0ZOTrfQYluDHIH+9PlWjG6b9rXDhQf88DcimvOQ66K72Wp2G4W344f6DBBOmJK7m 8K01FEkZrPcFGOQcR3dviPudtmp42l6KSZExzDElgzTd/Peie5AlWnY4fOOm2 X-Received: by 2002:a05:6000:545:: with SMTP id b5mr37829626wrf.452.1641553489403; Fri, 07 Jan 2022 03:04:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxN+/jroDqJZumZsHVbpVTzxlseVKLoXCKklUzLQQSZhiNaVTNg7bkBskCL2Bi4tmj/9Mbs8Q== X-Received: by 2002:a05:6000:545:: with SMTP id b5mr37829600wrf.452.1641553489166; Fri, 07 Jan 2022 03:04:49 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id d11sm4796099wri.101.2022.01.07.03.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:48 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 34/55] util/oslib-posix: Support concurrent os_mem_prealloc() invocation Message-ID: <20220107102526.39238-35-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Daniel P =?utf-8?b?LiBCZXJy?= =?utf-8?b?YW5nw6k=?= , David Hildenbrand , Michal Privoznik , Pankaj Gupta , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Add a mutex to protect the SIGBUS case, as we cannot mess concurrently with the sigbus handler and we have to manage the global variable sigbus_memset_context. The MADV_POPULATE_WRITE path can run concurrently. Note that page_mutex and page_cond are shared between concurrent invocations, which shouldn't be a problem. This is a preparation for future virtio-mem prealloc code, which will call os_mem_prealloc() asynchronously from an iothread when handling guest requests. Reviewed-by: Pankaj Gupta Reviewed-by: Daniel P. Berrangé Reviewed-by: Michal Privoznik Signed-off-by: David Hildenbrand Message-Id: <20211217134611.31172-7-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- util/oslib-posix.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index efa4f96d56..9829149e4b 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -95,6 +95,7 @@ typedef struct MemsetThread MemsetThread; /* used by sigbus_handler() */ static MemsetContext *sigbus_memset_context; +static QemuMutex sigbus_mutex; static QemuMutex page_mutex; static QemuCond page_cond; @@ -625,6 +626,7 @@ static bool madv_populate_write_possible(char *area, size_t pagesize) void os_mem_prealloc(int fd, char *area, size_t memory, int smp_cpus, Error **errp) { + static gsize initialized; int ret; struct sigaction act, oldact; size_t hpagesize = qemu_fd_getpagesize(fd); @@ -638,6 +640,12 @@ void os_mem_prealloc(int fd, char *area, size_t memory, int smp_cpus, use_madv_populate_write = madv_populate_write_possible(area, hpagesize); if (!use_madv_populate_write) { + if (g_once_init_enter(&initialized)) { + qemu_mutex_init(&sigbus_mutex); + g_once_init_leave(&initialized, 1); + } + + qemu_mutex_lock(&sigbus_mutex); memset(&act, 0, sizeof(act)); act.sa_handler = &sigbus_handler; act.sa_flags = 0; @@ -665,6 +673,7 @@ void os_mem_prealloc(int fd, char *area, size_t memory, int smp_cpus, perror("os_mem_prealloc: failed to reinstall signal handler"); exit(1); } + qemu_mutex_unlock(&sigbus_mutex); } } From patchwork Fri Jan 7 11:04:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576579 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=b6w9CVmk; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhFJ5V3mz9tjx for ; Fri, 7 Jan 2022 22:43:48 +1100 (AEDT) Received: from localhost ([::1]:59674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5neq-0005VX-P9 for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:43:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3y-0001RA-UP for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3n-0001zl-To for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553495; 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=3m5BJoEvWNhw8rt+WxqR9EVP//tM14PktOykO2ssbtA=; b=b6w9CVmkFz0rEpsKxyZIBVlAQs96trWmEnlTuxzszZdKy0hyv4fzrBFAr5rtYCcS7XGGrk 58fgmvfyUYgvBYGKolVQEZ6BldWEaI3jm75jBU2v/+HFkRgRq/JUlZzgmtNsQ+7BtAnw9v uMFxoFPSV8IZn2ka3maVxXI2K1XwbxU= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-X2yMPwEbMBuuyjQAETzWDg-1; Fri, 07 Jan 2022 06:04:54 -0500 X-MC-Unique: X2yMPwEbMBuuyjQAETzWDg-1 Received: by mail-wr1-f71.google.com with SMTP id j19-20020adfa553000000b001a375e473d8so2113058wrb.4 for ; Fri, 07 Jan 2022 03:04:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=3m5BJoEvWNhw8rt+WxqR9EVP//tM14PktOykO2ssbtA=; b=QXNWshIUOfB5r6K0Pj18h+fzM45Y/UAmgscJFfv6TDQuKfQ5WnHhifDvAVMheEvQi5 /zFC1tuMX0WkHBWj8630ATgnko4vhtqAMVMEi0ffl2PcTOiVYmO4gQQZR5oHe4K4hjkD HSWxaEaPNE+9AZQq7otVlXZzfANCGyQRYiKn3qVW3tK+vChtixQJqw+ZWYbMLfVf4LeE 6j07oM/sdzJaXDMf16+3fxUK15P19pjzic2kni6S9G3aND/US0mP6d2slXHx2QKPfKjE SjsABWdzX3Le+0hMVrfzG2Al99QYXMEJNCbt+1NGlOszgHuGkve6kWR+zSE4VGvrhPb9 W0XA== X-Gm-Message-State: AOAM532RPAY190vYi6br+/onKrQlzBDP7HVGm1xS6yPceja45k7XwxFD fVqRuNNwr6gtlXSfuQy6Tq3iHaTFsKzvpk2YyhfuXgZn04beefrmjmjuSHL9lyRDdV0VBszwAsX LQyCkC0JEtsy8vPPO1hreMnQrdxFBp4qBqMvaZhEqSZX9M7Q+rNj5F/kBXXH2 X-Received: by 2002:a5d:5848:: with SMTP id i8mr53388453wrf.398.1641553492502; Fri, 07 Jan 2022 03:04:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDUPhL98Oe3rVo4HZc1Tl/YyWMa2BcX1tRBCFxkYayFfjxNM0XZymEEEKBExt9y/jHQlnt4Q== X-Received: by 2002:a5d:5848:: with SMTP id i8mr53388432wrf.398.1641553492191; Fri, 07 Jan 2022 03:04:52 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id t15sm4395601wrz.82.2022.01.07.03.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:51 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 35/55] util/oslib-posix: Forward SIGBUS to MCE handler under Linux Message-ID: <20220107102526.39238-36-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Daniel P =?utf-8?b?LiBCZXJy?= =?utf-8?b?YW5nw6k=?= , David Hildenbrand , Michal Privoznik , Richard Henderson , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Temporarily modifying the SIGBUS handler is really nasty, as we might be unlucky and receive an MCE SIGBUS while having our handler registered. Unfortunately, there is no way around messing with SIGBUS when MADV_POPULATE_WRITE is not applicable or not around. Let's forward SIGBUS that don't belong to us to the already registered handler and document the situation. Reviewed-by: Daniel P. Berrangé Reviewed-by: Michal Privoznik Signed-off-by: David Hildenbrand Message-Id: <20211217134611.31172-8-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- softmmu/cpus.c | 4 ++++ util/oslib-posix.c | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/softmmu/cpus.c b/softmmu/cpus.c index 071085f840..23bca46b07 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -352,6 +352,10 @@ static void qemu_init_sigbus(void) { struct sigaction action; + /* + * ALERT: when modifying this, take care that SIGBUS forwarding in + * os_mem_prealloc() will continue working as expected. + */ memset(&action, 0, sizeof(action)); action.sa_flags = SA_SIGINFO; action.sa_sigaction = sigbus_handler; diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 9829149e4b..f7308d1cee 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -35,6 +35,7 @@ #include "sysemu/sysemu.h" #include "trace.h" #include "qapi/error.h" +#include "qapi/error-report.h" #include "qemu/sockets.h" #include "qemu/thread.h" #include @@ -95,6 +96,7 @@ typedef struct MemsetThread MemsetThread; /* used by sigbus_handler() */ static MemsetContext *sigbus_memset_context; +struct sigaction sigbus_oldact; static QemuMutex sigbus_mutex; static QemuMutex page_mutex; @@ -446,7 +448,11 @@ const char *qemu_get_exec_dir(void) return exec_dir; } +#ifdef CONFIG_LINUX +static void sigbus_handler(int signal, siginfo_t *siginfo, void *ctx) +#else /* CONFIG_LINUX */ static void sigbus_handler(int signal) +#endif /* CONFIG_LINUX */ { int i; @@ -459,6 +465,26 @@ static void sigbus_handler(int signal) } } } + +#ifdef CONFIG_LINUX + /* + * We assume that the MCE SIGBUS handler could have been registered. We + * should never receive BUS_MCEERR_AO on any of our threads, but only on + * the main thread registered for PR_MCE_KILL_EARLY. Further, we should not + * receive BUS_MCEERR_AR triggered by action of other threads on one of + * our threads. So, no need to check for unrelated SIGBUS when seeing one + * for our threads. + * + * We will forward to the MCE handler, which will either handle the SIGBUS + * or reinstall the default SIGBUS handler and reraise the SIGBUS. The + * default SIGBUS handler will crash the process, so we don't care. + */ + if (sigbus_oldact.sa_flags & SA_SIGINFO) { + sigbus_oldact.sa_sigaction(signal, siginfo, ctx); + return; + } +#endif /* CONFIG_LINUX */ + warn_report("os_mem_prealloc: unrelated SIGBUS detected and ignored"); } static void *do_touch_pages(void *arg) @@ -628,10 +654,10 @@ void os_mem_prealloc(int fd, char *area, size_t memory, int smp_cpus, { static gsize initialized; int ret; - struct sigaction act, oldact; size_t hpagesize = qemu_fd_getpagesize(fd); size_t numpages = DIV_ROUND_UP(memory, hpagesize); bool use_madv_populate_write; + struct sigaction act; /* * Sense on every invocation, as MADV_POPULATE_WRITE cannot be used for @@ -647,10 +673,15 @@ void os_mem_prealloc(int fd, char *area, size_t memory, int smp_cpus, qemu_mutex_lock(&sigbus_mutex); memset(&act, 0, sizeof(act)); +#ifdef CONFIG_LINUX + act.sa_sigaction = &sigbus_handler; + act.sa_flags = SA_SIGINFO; +#else /* CONFIG_LINUX */ act.sa_handler = &sigbus_handler; act.sa_flags = 0; +#endif /* CONFIG_LINUX */ - ret = sigaction(SIGBUS, &act, &oldact); + ret = sigaction(SIGBUS, &act, &sigbus_oldact); if (ret) { error_setg_errno(errp, errno, "os_mem_prealloc: failed to install signal handler"); @@ -667,7 +698,7 @@ void os_mem_prealloc(int fd, char *area, size_t memory, int smp_cpus, } if (!use_madv_populate_write) { - ret = sigaction(SIGBUS, &oldact, NULL); + ret = sigaction(SIGBUS, &sigbus_oldact, NULL); if (ret) { /* Terminate QEMU since it can't recover from error */ perror("os_mem_prealloc: failed to reinstall signal handler"); From patchwork Fri Jan 7 11:04:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576574 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hRtmdPJO; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVh7S04SNz9tjx for ; Fri, 7 Jan 2022 22:38:44 +1100 (AEDT) Received: from localhost ([::1]:49524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nZx-000641-PC for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:38:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3o-0001MH-6u for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:58367) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3S-0001zt-O6 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553497; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E8cVuTw3WnQz2PCB6BKnsgn/gSst2XbDgCGG/3vh9UE=; b=hRtmdPJOavgOzOZbw9KEdFISrs+D6lvn0VWMD3ZHL2rs4oWAgVFU+SRRFiV/edsqqJVThe RzSXisirak8rsMwk65RFoREiJZP/k147j/HX8/3KQK3uYQ/i24bMpYMUVZsz3AP2WR9X4Y y0nxMhd/Zyr8I6BJYUSvR5wGtKqkoBI= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-589-vWbQ2kHqM-SocpLVUPgM6g-1; Fri, 07 Jan 2022 06:04:56 -0500 X-MC-Unique: vWbQ2kHqM-SocpLVUPgM6g-1 Received: by mail-wm1-f70.google.com with SMTP id ay41-20020a05600c1e2900b00345a568e6b2so1349403wmb.4 for ; Fri, 07 Jan 2022 03:04:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=E8cVuTw3WnQz2PCB6BKnsgn/gSst2XbDgCGG/3vh9UE=; b=ZrYcoVn7wRUwF9PqASisQhhAMGQWt8rZdEqH1m8lpTVg/iCbnogwkuEpghQL5t83+u ixK7O8zgGV9qu8IJOtyZlffFvP5SqsN0kZNiId+c2kXYD49eNYceqmla2tF3Kgs/SxmV pyvMOvZ9+MeVNj6nRrgKk2tLxw9NZKOvbRSmO0injvjqshUChXJzi90ZU4+0T+Tke+7x 4u6QdUp+8co/dI1bgCkL6EyPv8qAmy8GVMJClmi9BkvkUJglqMs+Q6B9BTvlLOh/buWt Wq/Q+tiivaq6+I58XZ3MXT73H1edblyavunqR98E+CpRw/AC1sfm2JjZqHfvZfNBBckN xFAw== X-Gm-Message-State: AOAM530SX9pAKFwDoD5W9780GMIRVpFjlpI1D2aB0C1qdxf6rJieXoJK VjXSFdwB49jx8+P0yzAjqTeclSlKunHA8P0ArKzjpPCt2qTtoTArzgAY4TclmVdXMixi+I1WiJ4 x4IdnJo29MIlssx4cUQpMB4nAgEbZckhCNtLPQfy/cZRWJ9NXFSk2WrA/mNoZ X-Received: by 2002:adf:e6c9:: with SMTP id y9mr54814288wrm.697.1641553495302; Fri, 07 Jan 2022 03:04:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyv1otFjcMO2kvieKXtfeDd7Thwcu1osmBdw7J2P4B/imBSllzNsgOEok5DqXCO9KJx0yhcwg== X-Received: by 2002:adf:e6c9:: with SMTP id y9mr54814263wrm.697.1641553494975; Fri, 07 Jan 2022 03:04:54 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id j11sm5380370wmq.23.2022.01.07.03.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:54 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:52 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 36/55] virtio-mem: Support "prealloc=on" option Message-ID: <20220107102526.39238-37-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Privoznik , Peter Maydell , David Hildenbrand Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand For scarce memory resources, such as hugetlb, we want to be able to prealloc such memory resources in order to not crash later on access. On simple user errors we could otherwise easily run out of memory resources an crash the VM -- pretty much undesired. For ordinary memory devices, such as DIMMs, we preallocate memory via the memory backend for such use cases; however, with virtio-mem we're dealing with sparse memory backends; preallocating the whole memory backend destroys the whole purpose of virtio-mem. Instead, we want to preallocate memory when actually exposing memory to the VM dynamically, and fail plugging memory gracefully + warn the user in case preallocation fails. A common use case for hugetlb will be using "reserve=off,prealloc=off" for the memory backend and "prealloc=on" for the virtio-mem device. This way, no huge pages will be reserved for the process, but we can recover if there are no actual huge pages when plugging memory. Libvirt is already prepared for this. Note that preallocation cannot protect from the OOM killer -- which holds true for any kind of preallocation in QEMU. It's primarily useful only for scarce memory resources such as hugetlb, or shared file-backed memory. It's of little use for ordinary anonymous memory that can be swapped, KSM merged, ... but we won't forbid it. Reviewed-by: Michal Privoznik Signed-off-by: David Hildenbrand Message-Id: <20211217134611.31172-9-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-mem.h | 4 ++++ hw/virtio/virtio-mem.c | 39 ++++++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/include/hw/virtio/virtio-mem.h b/include/hw/virtio/virtio-mem.h index a5dd6a493b..0ac7bcb3b6 100644 --- a/include/hw/virtio/virtio-mem.h +++ b/include/hw/virtio/virtio-mem.h @@ -30,6 +30,7 @@ OBJECT_DECLARE_TYPE(VirtIOMEM, VirtIOMEMClass, #define VIRTIO_MEM_REQUESTED_SIZE_PROP "requested-size" #define VIRTIO_MEM_BLOCK_SIZE_PROP "block-size" #define VIRTIO_MEM_ADDR_PROP "memaddr" +#define VIRTIO_MEM_PREALLOC_PROP "prealloc" struct VirtIOMEM { VirtIODevice parent_obj; @@ -62,6 +63,9 @@ struct VirtIOMEM { /* block size and alignment */ uint64_t block_size; + /* whether to prealloc memory when plugging new blocks */ + bool prealloc; + /* notifiers to notify when "size" changes */ NotifierList size_change_notifiers; diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 341c3fa2c1..ab975ff566 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -429,10 +429,40 @@ static int virtio_mem_set_block_state(VirtIOMEM *vmem, uint64_t start_gpa, return -EBUSY; } virtio_mem_notify_unplug(vmem, offset, size); - } else if (virtio_mem_notify_plug(vmem, offset, size)) { - /* Could be a mapping attempt resulted in memory getting populated. */ - ram_block_discard_range(vmem->memdev->mr.ram_block, offset, size); - return -EBUSY; + } else { + int ret = 0; + + if (vmem->prealloc) { + void *area = memory_region_get_ram_ptr(&vmem->memdev->mr) + offset; + int fd = memory_region_get_fd(&vmem->memdev->mr); + Error *local_err = NULL; + + os_mem_prealloc(fd, area, size, 1, &local_err); + if (local_err) { + static bool warned; + + /* + * Warn only once, we don't want to fill the log with these + * warnings. + */ + if (!warned) { + warn_report_err(local_err); + warned = true; + } else { + error_free(local_err); + } + ret = -EBUSY; + } + } + if (!ret) { + ret = virtio_mem_notify_plug(vmem, offset, size); + } + + if (ret) { + /* Could be preallocation or a notifier populated memory. */ + ram_block_discard_range(vmem->memdev->mr.ram_block, offset, size); + return -EBUSY; + } } virtio_mem_set_bitmap(vmem, start_gpa, size, plug); return 0; @@ -1108,6 +1138,7 @@ static void virtio_mem_instance_init(Object *obj) static Property virtio_mem_properties[] = { DEFINE_PROP_UINT64(VIRTIO_MEM_ADDR_PROP, VirtIOMEM, addr, 0), DEFINE_PROP_UINT32(VIRTIO_MEM_NODE_PROP, VirtIOMEM, node, 0), + DEFINE_PROP_BOOL(VIRTIO_MEM_PREALLOC_PROP, VirtIOMEM, prealloc, false), DEFINE_PROP_LINK(VIRTIO_MEM_MEMDEV_PROP, VirtIOMEM, memdev, TYPE_MEMORY_BACKEND, HostMemoryBackend *), DEFINE_PROP_END_OF_LIST(), From patchwork Fri Jan 7 11:04:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576577 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=huEsxj6Y; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhCD3Z60z9tjx for ; Fri, 7 Jan 2022 22:42:00 +1100 (AEDT) Received: from localhost ([::1]:56938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nd8-0003EC-9M for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:41:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n41-0001Vt-SS for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38992) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3y-00020e-7h for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553504; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1bYEz3aJ2ZVHIKx33NW8o1kl0YJwc2D4eOCg251Ckdk=; b=huEsxj6YjeXui86SRucB8k6jR5wleGhaOx0xLx83B83/mcXAA6cnE9NTH6G9PJmJJflPhH BTCQwlmiPGvzng9+vh4FpXSw8sFh4Dczku9WSzksNki6uFJOxi18v9MNyMIjnLgjy3IjjQ FYhadA5K7hpdRCXuvj58FdDzIVO+k3g= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-653-noVLQ__UOWyU9CWObJzoeA-1; Fri, 07 Jan 2022 06:05:00 -0500 X-MC-Unique: noVLQ__UOWyU9CWObJzoeA-1 Received: by mail-wr1-f70.google.com with SMTP id h26-20020adfa4da000000b001a652d52d8eso135134wrb.16 for ; Fri, 07 Jan 2022 03:05:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1bYEz3aJ2ZVHIKx33NW8o1kl0YJwc2D4eOCg251Ckdk=; b=p9PPqfnPEMDN7r3pSh9qh2En+HZaAk92y1F6vwH9ueI0/SpL2CxqBOf4OS3ClnWS0G Mu5WRO0AJ1gbNP3GSDZPA1UlwnZ3ajl9HiaBQxHIQ89BJXSiG4QaQNOGWCb/IuJl+geZ KfkFKJFgu4na7A33VlnffK7/TdXoXkLCkD4NW3HKk+mda9ZhW1K4gWrWJ/XsBPYjJHk/ HKKgFeV0FRBESPCDXMF4c/msBuDCyfWqPewN+x7ABT8otz6dwcEoShnxpSjgON+rDi+B q64YzgPWiGnhd8pXQSujal+US3Nz/naX0couNfMK0MdXfm39t1kyHpWLotOPd9QA81TQ e6MQ== X-Gm-Message-State: AOAM532uT3ZPv7UD/Cfx/Fj1N3/Vy0O4EcIoJb45hQrq/F++uL5gVyKE q1No+nn97Vh+ihyAndivellSYMeapftO74Vv6bTrpDC4fh334CRwOH7G+s4MOMGbJHpvrc5GIi/ xIRb7qLrtRxK8zeHO4XF7fYCxtLo0ATSSpFQhSQ1TNhNW8RyQ96y2PUU+296V X-Received: by 2002:a05:600c:1548:: with SMTP id f8mr10557834wmg.24.1641553498175; Fri, 07 Jan 2022 03:04:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyabaXJmYSlhs0P5o02ebeHmjAcdRwzJNN8U1eMRQenXPx2u/h7J6Drwde4onzitCH2AJnETg== X-Received: by 2002:a05:600c:1548:: with SMTP id f8mr10557817wmg.24.1641553497978; Fri, 07 Jan 2022 03:04:57 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id n14sm4748307wrf.107.2022.01.07.03.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:04:57 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:55 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 37/55] virtio: signal after wrapping packed used_idx Message-ID: <20220107102526.39238-38-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Tiwei Bie , Stefan Hajnoczi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefan Hajnoczi Packed Virtqueues wrap used_idx instead of letting it run freely like Split Virtqueues do. If the used ring wraps more than once there is no way to compare vq->signalled_used and vq->used_idx in virtio_packed_should_notify() since they are modulo vq->vring.num. This causes the device to stop sending used buffer notifications when when virtio_packed_should_notify() is called less than once each time around the used ring. It is possible to trigger this with virtio-blk's dataplane notify_guest_bh() irq coalescing optimization. The call to virtio_notify_irqfd() (and virtio_packed_should_notify()) is deferred to a BH. If the guest driver is polling it can complete and submit more requests before the BH executes, causing the used ring to wrap more than once. The result is that the virtio-blk device ceases to raise interrupts and I/O hangs. Cc: Tiwei Bie Cc: Jason Wang Cc: Michael S. Tsirkin Signed-off-by: Stefan Hajnoczi Message-Id: <20211130134510.267382-1-stefanha@redhat.com> Fixes: 86044b24e865fb9596ed77a4d0f3af8b90a088a1 ("virtio: basic packed virtqueue support") Acked-by: Jason Wang 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 36edb1dad5..971e59a663 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -885,6 +885,7 @@ static void virtqueue_packed_flush(VirtQueue *vq, unsigned int count) if (vq->used_idx >= vq->vring.num) { vq->used_idx -= vq->vring.num; vq->used_wrap_counter ^= 1; + vq->signalled_used_valid = false; } } From patchwork Fri Jan 7 11:04:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576584 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GJo4FeF7; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhJC3cPdz9tk3 for ; Fri, 7 Jan 2022 22:46:19 +1100 (AEDT) Received: from localhost ([::1]:40064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nhJ-0003oa-95 for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:46:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n43-0001ZX-OI for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3z-00020i-Nb for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553504; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=U+s/eLBlC/CuoqRVZrYGYrsH9EkPsepN+hS3IAf50OQ=; b=GJo4FeF7vqbGbf5zZOoo77ZR5slTuynP/J0a0OMiCRHXd83tKXrkwP/x62JqOOaA6v75Dh /og/eHD8Q1w60h1AlgeHTVoyvZC5OVcpIvp/+uBKVDgjM3xavGuHGzTaRVAH1MXVUdZcnH xCkC4aBy8ZClfL2ek+xLnjmS/q6w3qU= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-604-3lcd0yl7M4yrdlY9LUOXMQ-1; Fri, 07 Jan 2022 06:05:03 -0500 X-MC-Unique: 3lcd0yl7M4yrdlY9LUOXMQ-1 Received: by mail-wr1-f69.google.com with SMTP id d14-20020adfa34e000000b001a631cb3ab5so377471wrb.12 for ; Fri, 07 Jan 2022 03:05:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=U+s/eLBlC/CuoqRVZrYGYrsH9EkPsepN+hS3IAf50OQ=; b=BQ8lEo9bMEIMMFN2A/xDmNQyIXLV9incqnrlLqUlwwF0ciEOA0evb5xqurVwn+sOP0 nJnXNK5/NYDCqnJWE1Ifk22N7s/tEFhdp3UfxLNmvXUJf8QunpRsnrLABnUb12yQx7cy VxRHguHrKo2lp4ZptUolq25WjC07DbqZhkWlr8bgIFuAhX3/OXJDVhSMJQWlBWGhY7t1 uXQsmEU+YOoLfR0bgFg8i7t9dm9oeAeqyXjlD7xp69WdQOWMnTXwwqklJCVFSYf9tM21 4oIVukNH/XHS+Vm4XKSwDW5/x0fdO1xDMGfLX2noxeqCq+zmM77Xdg3s0s4Q24qdOztt jXuA== X-Gm-Message-State: AOAM5339pd1mgDDP2y5NZ+x8TWly1G/VZsmgACuuse+Gs0tE4xpCiCtJ bphMAABxMCVnqwkuigcKzzaKe93AyaYsd7F0q7EROh3saAT86Ylq4CkZxr2OxlqP5SIY9MVRpWE 6sB63DIM+xoQs+Yhdmmru5YUuV9ijZIU5xcuFuBZpe45yD2+BlPpwWooOug17 X-Received: by 2002:a05:6000:1543:: with SMTP id 3mr55023108wry.140.1641553501771; Fri, 07 Jan 2022 03:05:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDKZyPDSWMleIOUwctyjnZGPpC4yZMQKatzwnlIvREXKJ3FIKI2KOIQPefMqbul9lBXryvbQ== X-Received: by 2002:a05:6000:1543:: with SMTP id 3mr55023082wry.140.1641553501468; Fri, 07 Jan 2022 03:05:01 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id a13sm3551740wrt.87.2022.01.07.03.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:01 -0800 (PST) Date: Fri, 7 Jan 2022 06:04:58 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 38/55] MAINTAINERS: Add a separate entry for acpi/VIOT tables Message-ID: <20220107102526.39238-39-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Jean-Philippe Brucker , Richard Henderson , Philippe =?utf-8?q?Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Ani Sinha , Alex =?utf-8?q?Benn=C3=A9e?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Ani Sinha All work related to VIOT tables are being done by Jean. Adding him as the maintainer for acpi VIOT table code in qemu. Signed-off-by: Ani Sinha Message-Id: <20211213045924.344214-1-ani@anisinha.ca> Acked-by: Jean-Philippe Brucker Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index f871d759fd..6aa0335560 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1777,6 +1777,13 @@ F: docs/specs/acpi_mem_hotplug.rst F: docs/specs/acpi_pci_hotplug.rst F: docs/specs/acpi_hw_reduced_hotplug.rst +ACPI/VIOT +M: Jean-Philippe Brucker +R: Ani Sinha +S: Supported +F: hw/acpi/viot.c +F: hw/acpi/viot.h + ACPI/HEST/GHES R: Dongjiu Geng L: qemu-arm@nongnu.org From patchwork Fri Jan 7 11:05:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576575 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=f9qhX4o3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVh802LSlz9tjx for ; Fri, 7 Jan 2022 22:39:10 +1100 (AEDT) Received: from localhost ([::1]:51010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5naN-00074b-4q for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:39:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3y-0001RC-Tp for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:49986) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3m-0002A3-6P for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553506; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=i2tUq/4w6a20igW6k3dOKqvL8Uaj1gMW3dBfTlVIDqA=; b=f9qhX4o3fa5icmRQzRKZ4mUpwIHodDxyS01rBusU90S1yf5c3UVYPlKzwiLKYIu0TZkjLE /5onuRvFr01ohlhv/2WJ2VXJ+Oi1KG9vx8So8t9O/WEHBUqEfdtOqWw5lpSfUM1AH3/vPX P7UMhwihuIitPkbhhwxXbM0cZmKKDyQ= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-49-Od-AtKcOMZGh3JO_3uQRdw-1; Fri, 07 Jan 2022 06:05:05 -0500 X-MC-Unique: Od-AtKcOMZGh3JO_3uQRdw-1 Received: by mail-wm1-f72.google.com with SMTP id i81-20020a1c3b54000000b003467c58cbddso4119793wma.5 for ; Fri, 07 Jan 2022 03:05:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=i2tUq/4w6a20igW6k3dOKqvL8Uaj1gMW3dBfTlVIDqA=; b=qVSFWHQYtT2/XbG4OiuzJPb5un+f2m8HNJcV68h1JDWgcyipN7AM9lrfpt5Jbtzuik jRRUqoVkeV93Pi7zpmokFt0IOEfoE0ZzHx/D0SCNRRbnFTQcRtGGriQAy2bsXTtxh58T M82VlIvZI6RrRoqmTqj0UclxvvDtGXFlEwX04cz4SLf88X9JdD8YiVAHbIi5gOomfEw+ GcgUPtIIdxCFKQLh4Ib8fJ0md9ZSnXunqqaimJo3qRS3gnIxSgdeu1thlWhAnDHbxUQp LY8ytX85FeEzz6jbhsNcL7/6G0YHCmVgyAGO0q+aDRi3fghk2XYTOffagDf9IySUVU97 Jx7A== X-Gm-Message-State: AOAM533yKoK7HH3yO4leJd785y0eP90AllCMzS4mmI+64HburJuR+yN0 aQaFNA5JywWXZ08JH3172DhvnUDH3s2jO0Y7/C1Q+HYEkLOQw/2PAYaoJ4DiEga2AdredLfeUv8 Op5fyXw2dhodQ6SyooRyNT1PkzbMljRGAEfHTgHMtWm7nA9iYN8AdlUW23P6Y X-Received: by 2002:a5d:4343:: with SMTP id u3mr29226434wrr.504.1641553504242; Fri, 07 Jan 2022 03:05:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHnEp7Xnl9ecOhWp/zL3jzNuBlqz/l2/oDUKJiRdnVQ3ZsFyJNHMQ/kc0KUkxV4Qjf/JywVQ== X-Received: by 2002:a5d:4343:: with SMTP id u3mr29226418wrr.504.1641553503977; Fri, 07 Jan 2022 03:05:03 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id g84sm5039590wme.7.2022.01.07.03.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:03 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 39/55] linux-headers: sync VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE Message-ID: <20220107102526.39238-40-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Privoznik , Peter Maydell , David Hildenbrand Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Let's synchronize the new feature flag, available in Linux since v5.16-rc1. Reviewed-by: Michal Privoznik Signed-off-by: David Hildenbrand Message-Id: <20211217134039.29670-2-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/standard-headers/linux/virtio_mem.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/standard-headers/linux/virtio_mem.h b/include/standard-headers/linux/virtio_mem.h index 05e5ade75d..18c74c527c 100644 --- a/include/standard-headers/linux/virtio_mem.h +++ b/include/standard-headers/linux/virtio_mem.h @@ -68,9 +68,10 @@ * explicitly triggered (VIRTIO_MEM_REQ_UNPLUG). * * There are no guarantees what will happen if unplugged memory is - * read/written. Such memory should, in general, not be touched. E.g., - * even writing might succeed, but the values will simply be discarded at - * random points in time. + * read/written. In general, unplugged memory should not be touched, because + * the resulting action is undefined. There is one exception: without + * VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, unplugged memory inside the usable + * region can be read, to simplify creation of memory dumps. * * It can happen that the device cannot process a request, because it is * busy. The device driver has to retry later. @@ -87,6 +88,8 @@ /* node_id is an ACPI PXM and is valid */ #define VIRTIO_MEM_F_ACPI_PXM 0 +/* unplugged memory must not be accessed */ +#define VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE 1 /* --- virtio-mem: guest -> host requests --- */ From patchwork Fri Jan 7 11:05:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576619 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WCp9EPoB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhn431H0z9sCD for ; Fri, 7 Jan 2022 23:07:52 +1100 (AEDT) Received: from localhost ([::1]:56678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5o2A-0001gr-81 for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 07:07:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n40-0001So-FT for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37889) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3p-0002BN-R6 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553509; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hs67YvZIvahNXlhwkP8umtVyFMBTNC8kSLZ1qlqLMz4=; b=WCp9EPoBpQjS1pmf6hMJOQ3V5cucslFbWWqB6JZz+7WHnFJ4yd5pxp7ylXjIl1/atpUgYG zxTA0bP/yJeZccZrxFxrxZTSy72MYrM00ztKQSR5XSQDA+ggQmRwn07wNwPdHzlO9OntfP 6cyaxcPq6UQiA/unyztVfPZc+Ddof50= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-214-E1rmQMLoNaK531MOxxjYVA-1; Fri, 07 Jan 2022 06:05:08 -0500 X-MC-Unique: E1rmQMLoNaK531MOxxjYVA-1 Received: by mail-wr1-f71.google.com with SMTP id k14-20020adfb34e000000b001a5d060e1edso526038wrd.7 for ; Fri, 07 Jan 2022 03:05:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=hs67YvZIvahNXlhwkP8umtVyFMBTNC8kSLZ1qlqLMz4=; b=k5G60TuTHoptWttKoGe8q+AaafysEnZyKs77l9QVjjDbjkycMntcOkZjx326XuMDFs +cd4KgDhwQYVUrpnIZbCq7Hpy/ynaNc3qCe17TT5vHATn/NqsG8OIqB3J08cJIQbnNfH YAll31mqejyY3VDKZsUKDAyDdYMU3oljXLaZlu0hRuOe2FjOY/vFCxoI7PRSGnW/jZyC z3wCaY9PYf8LBYmJsUQr1NpvcnhVZnwZZEkZEhUAv9FYDLmA+id61ROX8G91VOwZFxnl CAc5X/f1Qbjs8j+jnaDIgbDv2Jfg6mL3NAiatexwnWaNu/ImpJJ4eaa90ZxHCRyvM38G PWIA== X-Gm-Message-State: AOAM533KDJ0iPhwNpAkgXuYjbFTlyzt+pqOj2ZepZDj+oK5/lcKA3bs3 UhIq6R9CyXwDrlZ/5KcmKqAQZVNwvjEE1CHybroN1RSVXtCFEUoCSuZLwLnjavA6YV6/1gUQkZq eEKK8GAmeTB08aEX5yN++2cttUhHgvNjlCoKqDQPSoYnGNUUr7zSXzjUAsyw9 X-Received: by 2002:a05:6000:104f:: with SMTP id c15mr53635963wrx.665.1641553507271; Fri, 07 Jan 2022 03:05:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJy55cOnnOHszCtdqP0bpN2okqu4WFzgTkUIV3d7t+igN1pJ9fbfiqXOzphMOuegMvd6d2YwSA== X-Received: by 2002:a05:6000:104f:: with SMTP id c15mr53635942wrx.665.1641553506950; Fri, 07 Jan 2022 03:05:06 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id r62sm3986315wmr.35.2022.01.07.03.05.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:06 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:04 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 40/55] virtio-mem: Support VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE Message-ID: <20220107102526.39238-41-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Privoznik , Peter Maydell , David Hildenbrand Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand With VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, we signal the VM that reading unplugged memory is not supported. We have to fail feature negotiation in case the guest does not support VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE. First, VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE is required to properly handle memory backends (or architectures) without support for the shared zeropage in the hypervisor cleanly. Without the shared zeropage, even reading an unpopulated virtual memory location can populate real memory and consequently consume memory in the hypervisor. We have a guaranteed shared zeropage only on MAP_PRIVATE anonymous memory. Second, we want VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE to be the default long-term as even populating the shared zeropage can be problematic: for example, without THP support (possible) or without support for the shared huge zeropage with THP (unlikely), the PTE page tables to hold the shared zeropage entries can consume quite some memory that cannot be reclaimed easily. Third, there are other optimizations+features (e.g., protection of unplugged memory, reducing the total memory slot size and bitmap sizes) that will require VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE. We really only support x86 targets with virtio-mem for now (and Linux similarly only support x86), but that might change soon, so prepare for different targets already. Add a new "unplugged-inaccessible" tristate property for x86 targets: - "off" will keep VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE unset and legacy guests working. - "on" will set VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE and stop legacy guests from using the device. - "auto" selects the default based on support for the shared zeropage. Warn in case the property is set to "off" and we don't have support for the shared zeropage. For existing compat machines, the property will default to "off", to not change the behavior but eventually warn about a problematic setup. Short-term, we'll set the property default to "auto" for new QEMU machines. Mid-term, we'll set the property default to "on" for new QEMU machines. Long-term, we'll deprecate the parameter and disallow legacy guests completely. The property has to match on the migration source and destination. "auto" will result in the same VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE setting as long as the qemu command line (esp. memdev) match -- so "auto" is good enough for migration purposes and the parameter doesn't have to be migrated explicitly. Reviewed-by: Michal Privoznik Signed-off-by: David Hildenbrand Message-Id: <20211217134039.29670-3-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-mem.h | 8 +++++ hw/virtio/virtio-mem.c | 63 ++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/include/hw/virtio/virtio-mem.h b/include/hw/virtio/virtio-mem.h index 0ac7bcb3b6..7745cfc1a3 100644 --- a/include/hw/virtio/virtio-mem.h +++ b/include/hw/virtio/virtio-mem.h @@ -30,6 +30,7 @@ OBJECT_DECLARE_TYPE(VirtIOMEM, VirtIOMEMClass, #define VIRTIO_MEM_REQUESTED_SIZE_PROP "requested-size" #define VIRTIO_MEM_BLOCK_SIZE_PROP "block-size" #define VIRTIO_MEM_ADDR_PROP "memaddr" +#define VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP "unplugged-inaccessible" #define VIRTIO_MEM_PREALLOC_PROP "prealloc" struct VirtIOMEM { @@ -63,6 +64,13 @@ struct VirtIOMEM { /* block size and alignment */ uint64_t block_size; + /* + * Whether we indicate VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE to the guest. + * For !x86 targets this will always be "on" and consequently indicate + * VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE. + */ + OnOffAuto unplugged_inaccessible; + /* whether to prealloc memory when plugging new blocks */ bool prealloc; diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index ab975ff566..fb6687d4c7 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -32,6 +32,14 @@ #include CONFIG_DEVICES #include "trace.h" +/* + * We only had legacy x86 guests that did not support + * VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE. Other targets don't have legacy guests. + */ +#if defined(TARGET_X86_64) || defined(TARGET_I386) +#define VIRTIO_MEM_HAS_LEGACY_GUESTS +#endif + /* * Let's not allow blocks smaller than 1 MiB, for example, to keep the tracking * bitmap small. @@ -110,6 +118,19 @@ static uint64_t virtio_mem_default_block_size(RAMBlock *rb) return MAX(page_size, VIRTIO_MEM_MIN_BLOCK_SIZE); } +#if defined(VIRTIO_MEM_HAS_LEGACY_GUESTS) +static bool virtio_mem_has_shared_zeropage(RAMBlock *rb) +{ + /* + * We only have a guaranteed shared zeropage on ordinary MAP_PRIVATE + * anonymous RAM. In any other case, reading unplugged *can* populate a + * fresh page, consuming actual memory. + */ + return !qemu_ram_is_shared(rb) && rb->fd < 0 && + qemu_ram_pagesize(rb) == qemu_real_host_page_size; +} +#endif /* VIRTIO_MEM_HAS_LEGACY_GUESTS */ + /* * Size the usable region bigger than the requested size if possible. Esp. * Linux guests will only add (aligned) memory blocks in case they fully @@ -683,15 +704,29 @@ static uint64_t virtio_mem_get_features(VirtIODevice *vdev, uint64_t features, Error **errp) { MachineState *ms = MACHINE(qdev_get_machine()); + VirtIOMEM *vmem = VIRTIO_MEM(vdev); if (ms->numa_state) { #if defined(CONFIG_ACPI) virtio_add_feature(&features, VIRTIO_MEM_F_ACPI_PXM); #endif } + assert(vmem->unplugged_inaccessible != ON_OFF_AUTO_AUTO); + if (vmem->unplugged_inaccessible == ON_OFF_AUTO_ON) { + virtio_add_feature(&features, VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE); + } return features; } +static int virtio_mem_validate_features(VirtIODevice *vdev) +{ + if (virtio_host_has_feature(vdev, VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE) && + !virtio_vdev_has_feature(vdev, VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE)) { + return -EFAULT; + } + return 0; +} + static void virtio_mem_system_reset(void *opaque) { VirtIOMEM *vmem = VIRTIO_MEM(opaque); @@ -746,6 +781,29 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp) rb = vmem->memdev->mr.ram_block; page_size = qemu_ram_pagesize(rb); +#if defined(VIRTIO_MEM_HAS_LEGACY_GUESTS) + switch (vmem->unplugged_inaccessible) { + case ON_OFF_AUTO_AUTO: + if (virtio_mem_has_shared_zeropage(rb)) { + vmem->unplugged_inaccessible = ON_OFF_AUTO_OFF; + } else { + vmem->unplugged_inaccessible = ON_OFF_AUTO_ON; + } + break; + case ON_OFF_AUTO_OFF: + if (!virtio_mem_has_shared_zeropage(rb)) { + warn_report("'%s' property set to 'off' with a memdev that does" + " not support the shared zeropage.", + VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP); + } + break; + default: + break; + } +#else /* VIRTIO_MEM_HAS_LEGACY_GUESTS */ + vmem->unplugged_inaccessible = ON_OFF_AUTO_ON; +#endif /* VIRTIO_MEM_HAS_LEGACY_GUESTS */ + /* * If the block size wasn't configured by the user, use a sane default. This * allows using hugetlbfs backends of any page size without manual @@ -1141,6 +1199,10 @@ static Property virtio_mem_properties[] = { DEFINE_PROP_BOOL(VIRTIO_MEM_PREALLOC_PROP, VirtIOMEM, prealloc, false), DEFINE_PROP_LINK(VIRTIO_MEM_MEMDEV_PROP, VirtIOMEM, memdev, TYPE_MEMORY_BACKEND, HostMemoryBackend *), +#if defined(VIRTIO_MEM_HAS_LEGACY_GUESTS) + DEFINE_PROP_ON_OFF_AUTO(VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP, VirtIOMEM, + unplugged_inaccessible, ON_OFF_AUTO_OFF), +#endif DEFINE_PROP_END_OF_LIST(), }; @@ -1279,6 +1341,7 @@ static void virtio_mem_class_init(ObjectClass *klass, void *data) vdc->unrealize = virtio_mem_device_unrealize; vdc->get_config = virtio_mem_get_config; vdc->get_features = virtio_mem_get_features; + vdc->validate_features = virtio_mem_validate_features; vdc->vmsd = &vmstate_virtio_mem_device; vmc->fill_device_info = virtio_mem_fill_device_info; From patchwork Fri Jan 7 11:05:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576578 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZWNH2JEC; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhD0288Nz9tjx for ; Fri, 7 Jan 2022 22:42:40 +1100 (AEDT) Received: from localhost ([::1]:58072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5ndm-0004Nx-2b for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:42:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3y-0001RD-U5 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57609) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3o-0002BV-0R for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553512; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DFg4dF0zL+6DjrQEApY58jy53XB520+11YNtoCyrIVs=; b=ZWNH2JECqpfKMxlmyW1u9oQsQznSZURQkhMIdu6GS1/jdKDJ4hu/RNK/OD/Gq8KEH8ayn7 LS8IoQI5A+6uZb+Nb2o8WalXahtWmy2srIlQFojQ8rpXS4P5pzCa2Dg1P5O2vms0TjQjnX f1RdLGqpsEsxxGlxlT7CJ8TNUHngQMM= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-125-3sSEjoIAONKHBxzXWUYHsw-1; Fri, 07 Jan 2022 06:05:11 -0500 X-MC-Unique: 3sSEjoIAONKHBxzXWUYHsw-1 Received: by mail-wm1-f70.google.com with SMTP id r2-20020a05600c35c200b00345c3b82b22so4522881wmq.0 for ; Fri, 07 Jan 2022 03:05:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=DFg4dF0zL+6DjrQEApY58jy53XB520+11YNtoCyrIVs=; b=KI4VfJl8doOWUBMePQJzMD3QFycPU56Ns3RVk4oJRZaujrK+9GGdWQHGEDpEiXRAOK Jg6XamjkfGayM5SNTEwNrBRmjY+D2NnwihZgymiOpBzHATKDG4o2cgHBs+E+Xov/h74V pMIAStV98drkqcIF5xprpukCVpOb+zQQmRa57oZPnlLGShlpk9YiuAve/5xsQZnSVs2Y ghbv8dTtHSLju9qyFJLDOvejLluOQbsGm/5qU81Sn3oTYcXqWqqh9/WGmkHIotGCwTvW U69ysKCbtr3XXAdJFf42/lwVlkfkbAFLlJffztP9bVG2e10v5PG7O/SSgbaZeXuUp+su 5Xow== X-Gm-Message-State: AOAM531MbzkmfD0pFucLHXnybG5RkliWcFXPd+342OJQ+S4iaWvywc9N 3HJcp/ZmwBw8LDs/+kheBblzMzDsn7ufKmdbGmgRfNpvinIbAyuhY/H0COs8QqIcjmniatk5CBr V8wnh81MCQcVlzyTFW5jFv+K2/FKIEhllhforQnnskyJ3XAXj9XZHfy9ifiUn X-Received: by 2002:adf:f6c1:: with SMTP id y1mr2885076wrp.557.1641553510229; Fri, 07 Jan 2022 03:05:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwu2Ami5cxWXRBZ4/v5az0sgcjHAmyPaIZffGA5O9vJf2aD3UV4IZVHTH43gxcuVUEDkvxkIA== X-Received: by 2002:adf:f6c1:: with SMTP id y1mr2885056wrp.557.1641553509988; Fri, 07 Jan 2022 03:05:09 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id f6sm4488134wri.115.2022.01.07.03.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:09 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:07 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 41/55] virtio-mem: Set "unplugged-inaccessible=auto" for the 7.0 machine on x86 Message-ID: <20220107102526.39238-42-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Peter Maydell , David Hildenbrand , Michal Privoznik , Richard Henderson , Pankaj Gupta , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Set the new default to "auto", keeping it set to "off" for compat machines. This property is only available for x86 targets. Reviewed-by: Michal Privoznik Reviewed-by: Pankaj Gupta Signed-off-by: David Hildenbrand Message-Id: <20211217134039.29670-4-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc.c | 4 +++- hw/virtio/virtio-mem.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 959efa5b3f..718ab81ba8 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -95,7 +95,9 @@ #include "trace.h" #include CONFIG_DEVICES -GlobalProperty pc_compat_6_2[] = {}; +GlobalProperty pc_compat_6_2[] = { + { "virtio-mem", "unplugged-inaccessible", "off" }, +}; const size_t pc_compat_6_2_len = G_N_ELEMENTS(pc_compat_6_2); GlobalProperty pc_compat_6_1[] = { diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index fb6687d4c7..04c223b0c9 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -1201,7 +1201,7 @@ static Property virtio_mem_properties[] = { TYPE_MEMORY_BACKEND, HostMemoryBackend *), #if defined(VIRTIO_MEM_HAS_LEGACY_GUESTS) DEFINE_PROP_ON_OFF_AUTO(VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP, VirtIOMEM, - unplugged_inaccessible, ON_OFF_AUTO_OFF), + unplugged_inaccessible, ON_OFF_AUTO_AUTO), #endif DEFINE_PROP_END_OF_LIST(), }; From patchwork Fri Jan 7 11:05:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576614 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=P9DOfQ28; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhdq4KnJz9sCD for ; Fri, 7 Jan 2022 23:01:35 +1100 (AEDT) Received: from localhost ([::1]:48678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nw5-0003xQ-2N for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 07:01:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3y-0001R9-TS for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:51115) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3o-0002Cy-6b for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553517; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0ZXDQGGu0GtQDGXbNWl1ocN1Tqho3+nSq7/StQ09538=; b=P9DOfQ28BTFCZ+XmXwTGgw7YaW5iIEVhtUBJi6xV7Vmzz5fhWEj89a06ddUfDfVcoXbd1s 8nBXMFaVMDITY2Ojvph3c3P2wV2ZyJ4eMwYGfGQzB0NlxklNfvynwdhUVh3NENsSGYTtdW N6GAHnoRn3lEl+dhQE6Fp5UKe+UNMGk= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-333-XHDkMGlbMwOubmKKmE562g-1; Fri, 07 Jan 2022 06:05:16 -0500 X-MC-Unique: XHDkMGlbMwOubmKKmE562g-1 Received: by mail-wm1-f71.google.com with SMTP id bh10-20020a05600c3d0a00b00347aa76728fso729891wmb.9 for ; Fri, 07 Jan 2022 03:05:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0ZXDQGGu0GtQDGXbNWl1ocN1Tqho3+nSq7/StQ09538=; b=p9OBcwgM0YDpZHUe5NFYi2/IVt4aHJj+8sUJlRXAxrdXRUTLu29jEV6Z8LmeTcgGRh H6d08dNbBKQz1dgcvQUH3d9n4ZlpoM6VwGNrZapniCBuQmKvn3xstkh7RTYKzktkmdWE Qb8+C/FCq4co0HGsNdWEOGM6wuZBz7wuFq9R13F0Tw1SxChvHf7Uzs+LheZQtHGVJeK4 pLGg6LpyuQ2jWP2MdUPD4n0CuUcRzpgQ9zluM1ipmj5a4M72fNgzEsECP62NPlFv9DZg Ejc6skYNofUN83a5QsLIThU1b/w99vZu5pfjwtehHazGSzbhjYAkT5RqcWAQhB1Qcww7 6cGQ== X-Gm-Message-State: AOAM531quBM6Lxv111IOqXvRc4gUYE6jXPrfaqxHfAE5Q46HLGseIYJL O7q4qn3awPQK5rrgbQungviXWLcRIMXyC1MD6tJuzf3pRsOlq7cxEXFG+6sOXo1ZjElW6irRZWL jwvMTJvrBesVHY03COX/nKVnXwrBpvpHgzPlGU9w5ab1axWAnQAxTZ5y6T3nT X-Received: by 2002:a05:6000:15c6:: with SMTP id y6mr52615187wry.20.1641553513646; Fri, 07 Jan 2022 03:05:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKSoLN2fZe+7ln18wffVCtmk2Y0IVtyI7HpATkZyOWbmV8MQ12bjDkjO8t13VionLE1bpiYw== X-Received: by 2002:a05:6000:15c6:: with SMTP id y6mr52615162wry.20.1641553513378; Fri, 07 Jan 2022 03:05:13 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id i8sm4338950wmq.4.2022.01.07.03.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:13 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:10 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 42/55] intel-iommu: correctly check passthrough during translation Message-ID: <20220107102526.39238-43-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Peter Maydell , Jason Wang , Richard Henderson , Peter Xu , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jason Wang When scalable mode is enabled, the passthrough more is not determined by the context entry but PASID entry, so switch to use the logic of vtd_dev_pt_enabled() to determine the passthrough mode in vtd_do_iommu_translate(). Signed-off-by: Jason Wang Message-Id: <20220105041945.13459-2-jasowang@redhat.com> Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 5b865ac08c..4c6c016388 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1516,11 +1516,29 @@ static int vtd_sync_shadow_page_table(VTDAddressSpace *vtd_as) * 1st-level translation or 2nd-level translation, it depends * on PGTT setting. */ -static bool vtd_dev_pt_enabled(VTDAddressSpace *as) +static bool vtd_dev_pt_enabled(IntelIOMMUState *s, VTDContextEntry *ce) +{ + VTDPASIDEntry pe; + int ret; + + if (s->root_scalable) { + ret = vtd_ce_get_rid2pasid_entry(s, ce, &pe); + if (ret) { + error_report_once("%s: vtd_ce_get_rid2pasid_entry error: %"PRId32, + __func__, ret); + return false; + } + return (VTD_PE_GET_TYPE(&pe) == VTD_SM_PASID_ENTRY_PT); + } + + return (vtd_ce_get_type(ce) == VTD_CONTEXT_TT_PASS_THROUGH); + +} + +static bool vtd_as_pt_enabled(VTDAddressSpace *as) { IntelIOMMUState *s; VTDContextEntry ce; - VTDPASIDEntry pe; int ret; assert(as); @@ -1538,17 +1556,7 @@ static bool vtd_dev_pt_enabled(VTDAddressSpace *as) return false; } - if (s->root_scalable) { - ret = vtd_ce_get_rid2pasid_entry(s, &ce, &pe); - if (ret) { - error_report_once("%s: vtd_ce_get_rid2pasid_entry error: %"PRId32, - __func__, ret); - return false; - } - return (VTD_PE_GET_TYPE(&pe) == VTD_SM_PASID_ENTRY_PT); - } - - return (vtd_ce_get_type(&ce) == VTD_CONTEXT_TT_PASS_THROUGH); + return vtd_dev_pt_enabled(s, &ce); } /* Return whether the device is using IOMMU translation. */ @@ -1560,7 +1568,7 @@ static bool vtd_switch_address_space(VTDAddressSpace *as) assert(as); - use_iommu = as->iommu_state->dmar_enabled && !vtd_dev_pt_enabled(as); + use_iommu = as->iommu_state->dmar_enabled && !vtd_as_pt_enabled(as); trace_vtd_switch_address_space(pci_bus_num(as->bus), VTD_PCI_SLOT(as->devfn), @@ -1753,7 +1761,7 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus, * We don't need to translate for pass-through context entries. * Also, let's ignore IOTLB caching as well for PT devices. */ - if (vtd_ce_get_type(&ce) == VTD_CONTEXT_TT_PASS_THROUGH) { + if (vtd_dev_pt_enabled(s, &ce)) { entry->iova = addr & VTD_PAGE_MASK_4K; entry->translated_addr = entry->iova; entry->addr_mask = ~VTD_PAGE_MASK_4K; From patchwork Fri Jan 7 11:05:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576608 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=D/xeqVWA; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhYR6b3qz9sCD for ; Fri, 7 Jan 2022 22:57:46 +1100 (AEDT) Received: from localhost ([::1]:42844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nsN-0008Ol-6i for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:57:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3y-0001RB-Te for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23028) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3n-0002G5-UE for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553521; 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=frHd/5g516X/URldKy7BtToYamE3vI32g+batxojBlk=; b=D/xeqVWA6QoEdJbMg4nB2Bg+D1PBvbOJtZRGnrjorrbpgnoaGpTgKGhZNg2TqWbf4g0Db6 yGWUZRoh2WTUBVX/cdP+rEck1cF31XR131WS+focVZfwmW3CqDUzukDVg+RZ6+ZXq9DIuG x5DU56RwcoIBwoLItDlHLxagMdVPUwk= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-343-ggWaOORcOqSnXRG5s_SmoQ-1; Fri, 07 Jan 2022 06:05:20 -0500 X-MC-Unique: ggWaOORcOqSnXRG5s_SmoQ-1 Received: by mail-wr1-f71.google.com with SMTP id q2-20020adfab02000000b001a3ed59eb96so2100120wrc.20 for ; Fri, 07 Jan 2022 03:05:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=frHd/5g516X/URldKy7BtToYamE3vI32g+batxojBlk=; b=m9+A6dHBd6v+RjabB3Vv1UTT0NByia7NW9x0pB3GBaZyudB/tglMz1jOD2qtGvaAz4 AA+LsDz1Gi7IstRDKVc1BmNVo70JIvFCiNjWUSsZPw/rIrePSP60H/umcnlA+RYjQr5U gkGhHu741EVb+hQug8ELruJ8GK+hRaMnn97lFHnQfDHQ59yfSXkaXVyH5Sls1jCT0E6b 4M7p+qFA91OJnXfplU22NMuWMiyZVgSR24jYRlKyQSeog/KIOs3CBQGDxjX2agi8ivNJ eQIKiaU1SycKULPoDlDE2gvU7ZEbwjpRSzkvDSiZ8d4ZrxfYh+KRjxuQkuigN/3N73UW IhuA== X-Gm-Message-State: AOAM532DIiicilV82OUvv4utGA5OujBFLyZ9fQihxFJq2MZ3aEE+4LCr N8Q4W9khNUFe5Xqetkdzg8QnVqgQk0eG5LQ2RMaMlLaTAhgdj0mWguF2TJb/fUlK+uwj3QQ/c4q Ep03EEbXNN2LExnfVKvP04s9IFWg3+/e2dyVZlERMJvR+2IvYqOkjxgLjBHmH X-Received: by 2002:adf:fb42:: with SMTP id c2mr42684818wrs.168.1641553517277; Fri, 07 Jan 2022 03:05:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzx+INTrrV0A5nw89oWZXNPzQBrElo7i+j8iosL4IqwZBl+WxD9mwOR2WTgmAeFkFxmf+JC+Q== X-Received: by 2002:adf:fb42:: with SMTP id c2mr42684792wrs.168.1641553517040; Fri, 07 Jan 2022 03:05:17 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id f8sm4995143wry.16.2022.01.07.03.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:16 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 43/55] acpi: fix QEMU crash when started with SLIC table Message-ID: <20220107102526.39238-44-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Peter Maydell , Richard Henderson , qemu-stable@nongnu.org, Denis Lisov , Alexander Tsoy , Paolo Bonzini , Ani Sinha , Igor Mammedov , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov if QEMU is started with used provided SLIC table blob, -acpitable sig=SLIC,oem_id='CRASH ',oem_table_id="ME",oem_rev=00002210,asl_compiler_id="",asl_compiler_rev=00000000,data=/dev/null it will assert with: hw/acpi/aml-build.c:61:build_append_padded_str: assertion failed: (len <= maxlen) and following backtrace: ... build_append_padded_str (array=0x555556afe320, str=0x555556afdb2e "CRASH ME", maxlen=0x6, pad=0x20) at hw/acpi/aml-build.c:61 acpi_table_begin (desc=0x7fffffffd1b0, array=0x555556afe320) at hw/acpi/aml-build.c:1727 build_fadt (tbl=0x555556afe320, linker=0x555557ca3830, f=0x7fffffffd318, oem_id=0x555556afdb2e "CRASH ME", oem_table_id=0x555556afdb34 "ME") at hw/acpi/aml-build.c:2064 ... which happens due to acpi_table_begin() expecting NULL terminated oem_id and oem_table_id strings, which is normally the case, but in case of user provided SLIC table, oem_id points to table's blob directly and as result oem_id became longer than expected. Fix issue by handling oem_id consistently and make acpi_get_slic_oem() return NULL terminated strings. PS: After [1] refactoring, oem_id semantics became inconsistent, where NULL terminated string was coming from machine and old way pointer into byte array coming from -acpitable option. That used to work since build_header() wasn't expecting NULL terminated string and blindly copied the 1st 6 bytes only. However commit [2] broke that by replacing build_header() with acpi_table_begin(), which was expecting NULL terminated string and was checking oem_id size. 1) 602b45820 ("acpi: Permit OEM ID and OEM table ID fields to be changed") 2) Fixes: 4b56e1e4eb08 ("acpi: build_fadt: use acpi_table_begin()/acpi_table_end() instead of build_header()") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/786 Signed-off-by: Igor Mammedov Message-Id: <20211227193120.1084176-2-imammedo@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Tested-by: Denis Lisov Tested-by: Alexander Tsoy Cc: qemu-stable@nongnu.org Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/core.c | 4 ++-- hw/i386/acpi-build.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/acpi/core.c b/hw/acpi/core.c index 1e004d0078..3e811bf03c 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -345,8 +345,8 @@ int acpi_get_slic_oem(AcpiSlicOem *oem) struct acpi_table_header *hdr = (void *)(u - sizeof(hdr->_length)); if (memcmp(hdr->sig, "SLIC", 4) == 0) { - oem->id = hdr->oem_id; - oem->table_id = hdr->oem_table_id; + oem->id = g_strndup(hdr->oem_id, 6); + oem->table_id = g_strndup(hdr->oem_table_id, 8); return 0; } } diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 8383b83ee3..0234fe7588 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2723,6 +2723,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine) /* Cleanup memory that's no longer used. */ g_array_free(table_offsets, true); + g_free(slic_oem.id); + g_free(slic_oem.table_id); } static void acpi_ram_update(MemoryRegion *mr, GArray *data) From patchwork Fri Jan 7 11:05:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576581 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XxSQWEwU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhHX3l3Dz9tjx for ; Fri, 7 Jan 2022 22:45:44 +1100 (AEDT) Received: from localhost ([::1]:38382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5ngk-0002iH-AB for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:45:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n43-0001ZB-80 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32570) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3z-0002Gq-N3 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553523; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=x73NwhE1Jj1XHK61J5GDiGXpI7lT6xn6KSYOADx705c=; b=XxSQWEwUBnHieqEsevALqKmBbZhMc/mgMw6VpFq9Ip+MgCfpHTchxwYW+d2pIk0U+nZR/C XCeQWKPd4ui7OmZ07VbD5mydAqfKAu2ypyFyAMD5iblzY6OEuZL5rO09lzSXtrSv9IPIjF udm6Dg19th3ekztx+EozQL9/DvLLWlU= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-117-CpSYg9u4MVyzG3W_ApdhTA-1; Fri, 07 Jan 2022 06:05:22 -0500 X-MC-Unique: CpSYg9u4MVyzG3W_ApdhTA-1 Received: by mail-wr1-f72.google.com with SMTP id i23-20020adfaad7000000b001a6320b66b9so264056wrc.15 for ; Fri, 07 Jan 2022 03:05:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=x73NwhE1Jj1XHK61J5GDiGXpI7lT6xn6KSYOADx705c=; b=UZUF7k6qK+IJBW+/uHBK5sUHYgtbJR9hlxF7bXY2mYFrP6I+d/dtceoJ56b6jsp69q hEWbkEzPlEGANf7UX/WPP2i2o4SV0kqp8Y+iqmBlBs7SGc6ee/GO7siijcnCcw0/zicY 3RBDbIJcDVo1TKTcVsS9qaoriqHlyMt3whZUdkQrgHEofYf/C2uoLM89eW+srNyQbTrV T+thwXEyYIa7soiPESEQZWzHfyqBrY/QY40krRlXo68row3GIrpqBEvtMWoWebrLFLwA UOSdn5jCsuLrEAzsp093OE165vDfAzAJrERItKyee5AcZE4DF6Al2YJ7bD6WYHsdY630 Z3Sw== X-Gm-Message-State: AOAM530uzGDqN2FKF2Vkn8PUmAavrqUzQ0St1oUzcV9MJNELH5ihhCdC 8K+v9sDdgIMENNa22zgQPQ/hgeOPXLIod+jO8+x+HHk7tbPuw08b3JHH3hQcAI2AkPbGUSiDH7N S0VpF9oIxSWMaoKJtd31S/BAivDL0i3S8j0KOE2LXo/BcbZn2Y2xR+qG/im/o X-Received: by 2002:a05:6000:10d2:: with SMTP id b18mr53719296wrx.193.1641553520785; Fri, 07 Jan 2022 03:05:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzN5isByyhjq9dB1ToplghQcw4P6X2HMoszgUJKktTnXWlxnHYO9ed+cLvF9oqB6rCx72BTw== X-Received: by 2002:a05:6000:10d2:: with SMTP id b18mr53719276wrx.193.1641553520537; Fri, 07 Jan 2022 03:05:20 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id h204sm4052428wmh.33.2022.01.07.03.05.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:20 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 44/55] tests: acpi: whitelist expected blobs before changing them Message-ID: <20220107102526.39238-45-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Igor Mammedov Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov Signed-off-by: Igor Mammedov Message-Id: <20211227193120.1084176-3-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 2 ++ tests/data/acpi/q35/FACP.slic | Bin 0 -> 244 bytes tests/data/acpi/q35/SLIC.slic | 0 3 files changed, 2 insertions(+) create mode 100644 tests/data/acpi/q35/FACP.slic create mode 100644 tests/data/acpi/q35/SLIC.slic diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index dfb8523c8b..49dbf8fa3e 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,3 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/FACP.slic", +"tests/data/acpi/q35/SLIC.slic", diff --git a/tests/data/acpi/q35/FACP.slic b/tests/data/acpi/q35/FACP.slic new file mode 100644 index 0000000000000000000000000000000000000000..f6a864cc863c7763f6c09d3814ad184a658fa0a0 GIT binary patch literal 244 zcmZ>BbPo8!z`($~)5+i2BUr&HBEVSz2pEB4AU24G0Y(N+hD|^Y6El!tgNU*~X%LSC z$X0-fGcm9T0LA|E|L2FOWMD7?GM2V5Ffej3F#P0!h{7ddihwku0+2v57svwxMxcSn X_QAxFX+{NzJ3wNL4G8yu_%Hwf>-7!+ literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/SLIC.slic b/tests/data/acpi/q35/SLIC.slic new file mode 100644 index 0000000000..e69de29bb2 From patchwork Fri Jan 7 11:05:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576568 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EFxuBTwm; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVh0b2GRWz9tjx for ; Fri, 7 Jan 2022 22:32:47 +1100 (AEDT) Received: from localhost ([::1]:37120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nUD-0005U3-4E for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:32:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3z-0001RG-21 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27311) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3o-0002Iw-Sj for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UtXyrtn+0H59zIz1wAsdY62sOCwJtY4CRpesWdrs1nM=; b=EFxuBTwmEq6lSyVlWRVelbI4nTwsCANgfar/Y79RceSMWKIdwoIdPYBefgnM4A8aP0eoa/ 20FsBivO9Ww8BIBdK0pGTOit8URMXKE5/DVYxq1lhnMxcJ1whhG6TWUOOpUaRi3Re/2Buu vLlGcGfn8WjlNpCZ6i7elL9uNn0vaPI= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-457-5k3g6RYSNLaiGHJ7MMtcVA-1; Fri, 07 Jan 2022 06:05:25 -0500 X-MC-Unique: 5k3g6RYSNLaiGHJ7MMtcVA-1 Received: by mail-wr1-f72.google.com with SMTP id i23-20020adfaad7000000b001a6320b66b9so264104wrc.15 for ; Fri, 07 Jan 2022 03:05:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=UtXyrtn+0H59zIz1wAsdY62sOCwJtY4CRpesWdrs1nM=; b=w++Q93cFTCXHM4d0ChmtV/lNdngVAq+jg8zPTVkPPO2a7g+Wgkd+oJqVTfSLRXF0e7 7+P2txYoqMRRIiQrYGY4+IDcc7spGuqs0/Vkyf981+dFGNrjk1EOEP28S9ViK5vbr1S7 sTMhluMIoIOGxbTKAyO8tTk+w03+pSGtW2nPY/kGNtpB7rUIjIj4DGOGBcvvN+Q7YQf3 F8bXtB3I3EqYMC+45qxRv54xoi/gL5/o4WrXs6s2Z6tlAiyEJ360eOfUwqhDmHqf5jEw DMhJDpr8JzNF+Ij2tOcKWSOXoXUofQcfyxuilu6ZNvqOYmjSwB4dEKZ5zPjtjvPWxbOk Py/g== X-Gm-Message-State: AOAM5330I5gX4qDz6mLGcvokE6k4y3lv0Q31zd/ONlOnQxCE7fI0O3Xr b/tyjYecoOwQS8pd0misxEPeDFThjAF9U2O6SiFMQgVR5Hsrh/kecXvI+dJZyvvkHl2rgDC7pLB zDGR6plmfQXrmq7/xVkTrveoAS5PVdBSliaVbnHxaHyn8Xuscjtcphq4/rmcA X-Received: by 2002:a05:6000:1688:: with SMTP id y8mr52105919wrd.682.1641553523485; Fri, 07 Jan 2022 03:05:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBfMJcfM2q2+DgDB5jTDuSg3MIZ1AbCe40L2yCL3W0+YnKn+viP8sOIYgS6gQ2ud4YYlu+kA== X-Received: by 2002:a05:6000:1688:: with SMTP id y8mr52105893wrd.682.1641553523232; Fri, 07 Jan 2022 03:05:23 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id w6sm3768536wro.114.2022.01.07.03.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:22 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 45/55] tests: acpi: add SLIC table test Message-ID: <20220107102526.39238-46-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Igor Mammedov Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov When user uses '-acpitable' to add SLIC table, some ACPI tables (FADT) will change its 'Oem ID'/'Oem Table ID' fields to match that of SLIC. Test makes sure thati QEMU handles those fields correctly when SLIC table is added with '-acpitable' option. Signed-off-by: Igor Mammedov Message-Id: <20211227193120.1084176-4-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index 9a468e29eb..e6b72d9026 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -1502,6 +1502,20 @@ static void test_acpi_virt_viot(void) free_test_data(&data); } +static void test_acpi_q35_slic(void) +{ + test_data data = { + .machine = MACHINE_Q35, + .variant = ".slic", + }; + + test_acpi_one("-acpitable sig=SLIC,oem_id='CRASH ',oem_table_id='ME'," + "oem_rev=00002210,asl_compiler_id='qemu'," + "asl_compiler_rev=00000000,data=/dev/null", + &data); + free_test_data(&data); +} + static void test_oem_fields(test_data *data) { int i; @@ -1677,6 +1691,7 @@ int main(int argc, char *argv[]) qtest_add_func("acpi/q35/kvm/dmar", test_acpi_q35_kvm_dmar); } qtest_add_func("acpi/q35/viot", test_acpi_q35_viot); + qtest_add_func("acpi/q35/slic", test_acpi_q35_slic); } else if (strcmp(arch, "aarch64") == 0) { if (has_tcg) { qtest_add_func("acpi/virt", test_acpi_virt_tcg); From patchwork Fri Jan 7 11:05:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576628 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=aXPZel8Z; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVj8K5GK0z9sSs for ; Fri, 7 Jan 2022 23:24:32 +1100 (AEDT) Received: from localhost ([::1]:59470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5oIH-00083h-Ck for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 07:24:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n43-0001ZA-3r for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3z-0002QD-Bq for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HCH8M2xzOuTzVRMTHu52Ea//JZbOjY+v7CpKskn1oCw=; b=aXPZel8Z6OyvhxB+d1ZbEgwTZgdDMu4ysuZrlqRYQ+Z3MAJzA/rkNJuuaYhXOvlA8Q8EpC HaEyRYt+zuWgmu3F7/yPPJ2P3ufd0+n0ixNkXdzYTulY09sTBG/AcFvDUqcqDhd+YxYasI HHbKaRF5fBxTSjZeVNt0/konBs8AWlE= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-401-QoxjgFrLOySu42a5OIeBaQ-1; Fri, 07 Jan 2022 06:05:27 -0500 X-MC-Unique: QoxjgFrLOySu42a5OIeBaQ-1 Received: by mail-wm1-f69.google.com with SMTP id m19-20020a05600c4f5300b00345cb6e8dd4so699958wmq.3 for ; Fri, 07 Jan 2022 03:05:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HCH8M2xzOuTzVRMTHu52Ea//JZbOjY+v7CpKskn1oCw=; b=mlRqbB9JSEePnu3xItqTkmVCMGv83yRDksFarCURX825m4QoTNde+lOizfH41BpmpT N4BiEmM/uczIn9szR4pJHzi+wKc30OLT8IU0HIhrPzR8RjZpBEyNNbA4Z/1BViHYjZS/ nYLgiu3aNum6DBCOjB6eTDCXYjZaU3EO8MZm+4Mm2H0MAYB61d2pBeLP7J1ukTbq9L/L ooIM24pmFhJFrQypiZHeTCxe88WnOAyXmgHqr65wi0gj+2w3hB0tD1Mdbuvb/sNgQePg +wSeU1DsxsmeW7MfRhsZzd/6WCKbjJNFQjwJkfB7FMq5jETRNaEvgy60ilscqTPsztgN kzBA== X-Gm-Message-State: AOAM530tQrI/F2SEAHRlg/qk29iks73IVyAauNi+ISozhbi6UIME4nnl 3va3dj9DvtIvKDJmgZPtgzOgYzOcAIx4V7fNF3tcNkn+Z7AsfUJe8+oNBfNSt4i6bq2swVo+nzS AD6emcYwyLVwLEfayCC7pHlrm4VVcPAxj8pQLg+uemUxR9mwzELP+Q/qn1WTB X-Received: by 2002:a5d:588f:: with SMTP id n15mr55085177wrf.159.1641553525871; Fri, 07 Jan 2022 03:05:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjuCEpIvAbcJRfFZuIIJij0GeVrZ+vecVZ75ciUdM5ZQkOn/ZruC7f63J0AfmWis2kkNrJEg== X-Received: by 2002:a5d:588f:: with SMTP id n15mr55085161wrf.159.1641553525718; Fri, 07 Jan 2022 03:05:25 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id l8sm4510810wrv.25.2022.01.07.03.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:25 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:23 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 46/55] tests: acpi: SLIC: update expected blobs Message-ID: <20220107102526.39238-47-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Igor Mammedov Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov Signed-off-by: Igor Mammedov Message-Id: <20211227193120.1084176-5-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 2 -- tests/data/acpi/q35/FACP.slic | Bin 244 -> 244 bytes tests/data/acpi/q35/SLIC.slic | Bin 0 -> 36 bytes 3 files changed, 2 deletions(-) diff --git a/tests/data/acpi/q35/FACP.slic b/tests/data/acpi/q35/FACP.slic index f6a864cc863c7763f6c09d3814ad184a658fa0a0..891fd4b784b7b6b3ea303976db7ecd5b669bc84b 100644 GIT binary patch delta 28 jcmeyu_=Qo#&CxmF3j+fKvygL;W3Y#Uud9N>M3Dyoc<=}c delta 28 jcmeyu_=Qo#&CxmF3j+fK^G+v!XOCb7r-%UOi6RdGgN+Fa diff --git a/tests/data/acpi/q35/SLIC.slic b/tests/data/acpi/q35/SLIC.slic index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..fd26592e2480c5d02a018e0d855a04106661a7b5 100644 GIT binary patch literal 36 mcmWIc@pM*UU|?YMbPjS1_E7M31#*C(gN1>iFg3Rn#0CI%)&>Cp literal 0 HcmV?d00001 diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index 49dbf8fa3e..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,3 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/FACP.slic", -"tests/data/acpi/q35/SLIC.slic", From patchwork Fri Jan 7 11:05:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576573 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hL0y1oIP; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVh6D55Pzz9tjx for ; Fri, 7 Jan 2022 22:37:40 +1100 (AEDT) Received: from localhost ([::1]:48552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nYv-0005PR-AJ for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:37:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n41-0001Vl-N5 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45347) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3y-0002MP-Ls for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xrm8CIGRgPpnhTX6j94BNeJt2bCzqkKY9MsNy4P9oQo=; b=hL0y1oIPhvigiCZXjBODvbqaVpnEg6ACPR2HbMlqKpNfCUv6ogO0n5dn6S45a6UmPLM7ns vXOfv2J+k+BxYR1A04EfleA62LFnQzJAd+k4ULidfwkTNp+EhUqSzaAnkzDnRYz84lB4LA oZbuN5ooJ2zn7IfgrVh+XMDp2T1c4rI= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-547-uBXthJy6OvmCymVJNlmc1Q-1; Fri, 07 Jan 2022 06:05:30 -0500 X-MC-Unique: uBXthJy6OvmCymVJNlmc1Q-1 Received: by mail-wm1-f72.google.com with SMTP id az9-20020a05600c600900b0034692565ca8so3458632wmb.9 for ; Fri, 07 Jan 2022 03:05:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=xrm8CIGRgPpnhTX6j94BNeJt2bCzqkKY9MsNy4P9oQo=; b=n6To4bp8M29m/tHIxPryxJrujL7tMqxkypAxKZ8r2uRkF5tA2j1tpMjfCkvxlyE9ue 0Kg4W5NqwiCRFvEoKno5orGcgKIHAzM4G2Ecs+M8FI2Dtxo4ICXKX/WnNyGtFC3Om+al NqBDJWRo9/E6nbGdWZ6hokHPet0wYNb7M4i7iz04b6hMOlOQ+Oeyt7aXqmm9Y+MuDIsr 8RHB/cv/JuxllYQqyLf5LumSSsYqYmk9U5UkqHy3wcEwx07VKJomboLOa7tQcgkA3oVZ 0rstAXfPURkdk3iiQ7yaUp23t9g1VD5qZhoEd+9nEG1KrlyS+8XWlszbsypqtASyr0lY QsmQ== X-Gm-Message-State: AOAM532Eg6W4ZOV2Xy1WRsHeHywAKs4MixSaq2uxi5GnlAjjGnrCxXwn HKGMC/ndL+IoyWFi9N5i1nCtARFw8IWKjc72i08Hkhl68MzmxNKqd7qCpfNIK/ExI1sJsd4FbKB zaVG2IgLqnrRqJwpxYNWFeTrxvJI38d5vgghU5YMJpGsp/hGX1a4YWBvhq6X6 X-Received: by 2002:a5d:59af:: with SMTP id p15mr53775807wrr.237.1641553528957; Fri, 07 Jan 2022 03:05:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8wkk13gQFw6fCfBRv9N+vVS7zXQYf+RfYUTtNMpTaXHg1kRpJg6RyD3Yyse9XvM5euW5XRA== X-Received: by 2002:a5d:59af:: with SMTP id p15mr53775791wrr.237.1641553528707; Fri, 07 Jan 2022 03:05:28 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id 14sm4734920wry.23.2022.01.07.03.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:28 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:26 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 47/55] acpihp: simplify acpi_pcihp_disable_root_bus Message-ID: <20220107102526.39238-48-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Igor Mammedov Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Ani Sinha Get rid of the static variable that keeps track of whether hotplug has been disabled on the root pci bus. Simply use qbus_is_hotpluggable() api to perform the same check. This eliminates additional if conditional and simplifies the function. Signed-off-by: Ani Sinha Message-Id: <1640764674-7784-1-git-send-email-ani@anirban.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/pcihp.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index a5e182dd3a..6befd23e16 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -128,20 +128,15 @@ static void acpi_set_pci_info(void) static void acpi_pcihp_disable_root_bus(void) { - static bool root_hp_disabled; Object *host = acpi_get_i386_pci_host(); PCIBus *bus; - if (root_hp_disabled) { - return; - } - bus = PCI_HOST_BRIDGE(host)->bus; - if (bus) { + if (bus && qbus_is_hotpluggable(BUS(bus))) { /* setting the hotplug handler to NULL makes the bus non-hotpluggable */ qbus_set_hotplug_handler(BUS(bus), NULL); } - root_hp_disabled = true; + return; } From patchwork Fri Jan 7 11:05:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576625 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Uf/J6Lov; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhxq03y3z9sCD for ; Fri, 7 Jan 2022 23:15:26 +1100 (AEDT) Received: from localhost ([::1]:43340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5o9U-0004Ny-4U for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 07:15:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n41-0001Vr-Pc for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57000) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3y-0002Rm-UQ for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553534; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LvT4ppWsVTNHwP1QDeBfIbJrLtF0WPUv8XlijE9OykM=; b=Uf/J6LovQATLzg2TkC2h9XuvDs6aqt0GcVrvZ8WHDb1EunMukTXRAVpD1QcLorBrd1jaJR jKaZLuBAbQB9yDFsHKmRS+AhyuIBXMCSp97MCo2XBC12kD84S7lXhfBJCm2ivgCrcbMNME o73W7VSzPin/BBYvyHS76LNs/QLvdSM= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-29-EL5IghIOOXSmilT8qmp1ww-1; Fri, 07 Jan 2022 06:05:33 -0500 X-MC-Unique: EL5IghIOOXSmilT8qmp1ww-1 Received: by mail-wr1-f69.google.com with SMTP id i23-20020adfaad7000000b001a6320b66b9so264240wrc.15 for ; Fri, 07 Jan 2022 03:05:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=LvT4ppWsVTNHwP1QDeBfIbJrLtF0WPUv8XlijE9OykM=; b=Mexl0tBbDPjSj+B42Puf/e9A5J4d05CoOVVdQT26tNQKISiMLL0N/8e0KYQsH6K35B nmw9FuPMb+asUUDICJ77XsuCw5Lu4X1Uxuxug0CWRy2RQYrZ4kwpjvNS3CCR/DybD8iM kflSAkTRpT61u9j3LxpeRVJ+sHPcpc9r1nMTGQWoa1ZwuOdiLhBPXjgKHECsldQe7mt2 Psj7EZyE5fpwow4O6n3tZ6++Vqq0PRgo9vGKIW/w0sMrtkYYa4AvUt7EVzlYMrY5qDhB HoSmPVKNVyDZaiBqK1Lg/zzrlwUpW3aBD9EedGeI3K6dzCXrHuXDwXem08CmMcAFkUJV aBlw== X-Gm-Message-State: AOAM532mg4FCMF+JbkSwpE2uR7GPhb3WqGPD18nxgqdwdSh8HkBZNsmq spaBobc/WA9wffG7lUyYZ09q95h6wEjM6kYRC61QB+yYmevLjyrrHJxFCUA/FBSYJdYwP2YPnr9 bNyO1W+W6h07rUTpU7/wsWDJ6lSRJ1K8SEnRZREeycpwSMKP+dcHBVlovv6ya X-Received: by 2002:a7b:c146:: with SMTP id z6mr9707487wmi.6.1641553531846; Fri, 07 Jan 2022 03:05:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIGb0NbmAN5pv2UIRQEUSjh2upfz60t0DyslZTFh9KQmyh8PaKUegQBBZDCkEBqusZy8P/HA== X-Received: by 2002:a7b:c146:: with SMTP id z6mr9707463wmi.6.1641553531604; Fri, 07 Jan 2022 03:05:31 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id 1sm5087327wry.33.2022.01.07.03.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:31 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:29 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 48/55] hw/i386/pc: Add missing property descriptions Message-ID: <20220107102526.39238-49-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Peter Maydell , Thomas Huth , Richard Henderson , Igor Mammedov , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Thomas Huth When running "qemu-system-x86_64 -M pc,help" I noticed that some properties were still missing their description. Add them now so that users get at least a slightly better idea what they are all about. Signed-off-by: Thomas Huth Message-Id: <20211206134255.94784-1-thuth@redhat.com> Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 718ab81ba8..c8696ac01e 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1759,15 +1759,23 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) object_class_property_add_bool(oc, PC_MACHINE_SMBUS, pc_machine_get_smbus, pc_machine_set_smbus); + object_class_property_set_description(oc, PC_MACHINE_SMBUS, + "Enable/disable system management bus"); object_class_property_add_bool(oc, PC_MACHINE_SATA, pc_machine_get_sata, pc_machine_set_sata); + object_class_property_set_description(oc, PC_MACHINE_SATA, + "Enable/disable Serial ATA bus"); object_class_property_add_bool(oc, PC_MACHINE_PIT, pc_machine_get_pit, pc_machine_set_pit); + object_class_property_set_description(oc, PC_MACHINE_PIT, + "Enable/disable Intel 8254 programmable interval timer emulation"); object_class_property_add_bool(oc, "hpet", pc_machine_get_hpet, pc_machine_set_hpet); + object_class_property_set_description(oc, "hpet", + "Enable/disable high precision event timer emulation"); object_class_property_add_bool(oc, "default-bus-bypass-iommu", pc_machine_get_default_bus_bypass_iommu, From patchwork Fri Jan 7 11:05:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576626 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=E6ZzTO19; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVj351DcVz9sSs for ; Fri, 7 Jan 2022 23:20:01 +1100 (AEDT) Received: from localhost ([::1]:51018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5oDu-0001hg-Fo for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 07:19:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n42-0001Wh-BQ for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48969) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n3y-0002T2-U5 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553537; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=I9fRFWidMhAfy5/v5TIFdNUDGEE35GIYo1QYqVMvWCg=; b=E6ZzTO19ATF+87XFhdUxa+jLbQG0X0nkh4apqYb+QSz+LMI7Yy2PaU6XyvHUSLbmIiHylR z60Yf2f2cgGc1kx80K+kjX0yKN8kaiXowZTn3sx21n9vMhTAAqvjyBa1PGeldjn6gTFhsu BBcVTu+/Xr1mWhReC6hWAW0lB+F4MRs= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-161-hCLJg8pqPx6kbsrOONvqCA-1; Fri, 07 Jan 2022 06:05:36 -0500 X-MC-Unique: hCLJg8pqPx6kbsrOONvqCA-1 Received: by mail-wr1-f71.google.com with SMTP id o28-20020adfa11c000000b001a60fd79c21so428028wro.19 for ; Fri, 07 Jan 2022 03:05:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=I9fRFWidMhAfy5/v5TIFdNUDGEE35GIYo1QYqVMvWCg=; b=xTTRP9ZAyILVeq9UeMGD12gusohA7IEcGcrfO8aatfUuj1bUsKLvuZFdpX5GXBtjm+ 95eAY9a9BuCbDLZeQSKKbjbb2udJewSsYuyL7jmlQLfgsfTFi5ZFWL2C8rhvjyxim7tH LAzA5A5mabrSDmr27LOmNeupbDxDdmnb1a6+Vw6lhZ+J4ykcRkZthkMJjtBL7u5aalKj lrZ1vf6xQpb3Y5H5vcucgGj8tTXuFCV9kTOAD9aq3QvvZ4r2H5A92Q67tLGsIEN+EU5n MgQToIfiZK8+ayL4+rtsBLGDVNRGKsrExsr68SqxLVw3+EJvDTEErLr8sB9AbqpTkFYJ 9W/w== X-Gm-Message-State: AOAM530ekK7q0Lel8QrJCrcMvzc0obkbQ3Tfgo1v9mEgWP6bUw+ug+jp fr+i2bOkMcq892sSrpTbYVESzmXEXgW9T7xogu4MSsvkmtPEgYKKz17XYFZ3zaqqMk+QZmGsbJR PCGjfz7LAcBfObgrwEURQY5TQDgq7084zad1iiH4tWR02zN3rt0Po6loQPWEi X-Received: by 2002:adf:df83:: with SMTP id z3mr5922927wrl.456.1641553534548; Fri, 07 Jan 2022 03:05:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjKdPSLGGKCPbVs3YZrAHG+itOMIVWun3SDgHNNOfygik0cKrLUULIrcnnUOLh1CNrlug5Vw== X-Received: by 2002:adf:df83:: with SMTP id z3mr5922895wrl.456.1641553534204; Fri, 07 Jan 2022 03:05:34 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id bg19sm8950445wmb.47.2022.01.07.03.05.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:33 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:31 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 49/55] docs: reSTify virtio-balloon-stats documentation and move to docs/interop Message-ID: <20220107102526.39238-50-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , David Hildenbrand Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Thomas Huth The virtio-balloon-stats documentation might be useful for people that are implementing software that talks to QEMU via QMP, so this should reside in the docs/interop/ directory. While we're at it, also convert the file to restructured text and mention it in the MAINTAINERS file. Signed-off-by: Thomas Huth Message-Id: <20220105115245.420945-1-thuth@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- MAINTAINERS | 1 + docs/interop/index.rst | 1 + .../virtio-balloon-stats.rst} | 58 ++++++++++--------- 3 files changed, 32 insertions(+), 28 deletions(-) rename docs/{virtio-balloon-stats.txt => interop/virtio-balloon-stats.rst} (66%) diff --git a/MAINTAINERS b/MAINTAINERS index 6aa0335560..c98a61caee 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1932,6 +1932,7 @@ virtio-balloon M: Michael S. Tsirkin M: David Hildenbrand S: Maintained +F: docs/interop/virtio-balloon-stats.rst F: hw/virtio/virtio-balloon*.c F: include/hw/virtio/virtio-balloon.h F: softmmu/balloon.c diff --git a/docs/interop/index.rst b/docs/interop/index.rst index c59bac9834..b7632acb7b 100644 --- a/docs/interop/index.rst +++ b/docs/interop/index.rst @@ -22,3 +22,4 @@ are useful for making QEMU interoperate with other software. vhost-user vhost-user-gpu vhost-vdpa + virtio-balloon-stats diff --git a/docs/virtio-balloon-stats.txt b/docs/interop/virtio-balloon-stats.rst similarity index 66% rename from docs/virtio-balloon-stats.txt rename to docs/interop/virtio-balloon-stats.rst index 1732cc8c8a..b9a6a6edb2 100644 --- a/docs/virtio-balloon-stats.txt +++ b/docs/interop/virtio-balloon-stats.rst @@ -1,4 +1,4 @@ -virtio balloon memory statistics +Virtio balloon memory statistics ================================ The virtio balloon driver supports guest memory statistics reporting. These @@ -9,10 +9,12 @@ Before querying the available stats, clients first have to enable polling. This is done by writing a time interval value (in seconds) to the guest-stats-polling-interval property. This value can be: - > 0 enables polling in the specified interval. If polling is already + > 0 + enables polling in the specified interval. If polling is already enabled, the polling time interval is changed to the new value - 0 disables polling. Previous polled statistics are still valid and + 0 + disables polling. Previous polled statistics are still valid and can be queried. Once polling is enabled, the virtio-balloon device in QEMU will start @@ -22,7 +24,7 @@ interval. To retrieve those stats, clients have to query the guest-stats property, which will return a dictionary containing: - o A key named 'stats', containing all available stats. If the guest + * A key named 'stats', containing all available stats. If the guest doesn't support a particular stat, or if it couldn't be retrieved, its value will be -1. Currently, the following stats are supported: @@ -37,7 +39,7 @@ which will return a dictionary containing: - stat-htlb-pgalloc - stat-htlb-pgfail - o A key named last-update, which contains the last stats update + * A key named last-update, which contains the last stats update timestamp in seconds. Since this timestamp is generated by the host, a buggy guest can't influence its value. The value is 0 if the guest has not updated the stats (yet). @@ -61,32 +63,32 @@ It's also important to note the following: respond to the request the timer will never be re-armed, which has the same effect as disabling polling -Here are a few examples. QEMU is started with '-device virtio-balloon', -which generates '/machine/peripheral-anon/device[1]' as the QOM path for +Here are a few examples. QEMU is started with ``-device virtio-balloon``, +which generates ``/machine/peripheral-anon/device[1]`` as the QOM path for the balloon device. -Enable polling with 2 seconds interval: +Enable polling with 2 seconds interval:: -{ "execute": "qom-set", - "arguments": { "path": "/machine/peripheral-anon/device[1]", - "property": "guest-stats-polling-interval", "value": 2 } } + { "execute": "qom-set", + "arguments": { "path": "/machine/peripheral-anon/device[1]", + "property": "guest-stats-polling-interval", "value": 2 } } -{ "return": {} } + { "return": {} } -Change polling to 10 seconds: +Change polling to 10 seconds:: -{ "execute": "qom-set", - "arguments": { "path": "/machine/peripheral-anon/device[1]", - "property": "guest-stats-polling-interval", "value": 10 } } + { "execute": "qom-set", + "arguments": { "path": "/machine/peripheral-anon/device[1]", + "property": "guest-stats-polling-interval", "value": 10 } } -{ "return": {} } + { "return": {} } -Get stats: +Get stats:: -{ "execute": "qom-get", - "arguments": { "path": "/machine/peripheral-anon/device[1]", - "property": "guest-stats" } } -{ + { "execute": "qom-get", + "arguments": { "path": "/machine/peripheral-anon/device[1]", + "property": "guest-stats" } } + { "return": { "stats": { "stat-swap-out": 0, @@ -98,12 +100,12 @@ Get stats: }, "last-update": 1358529861 } -} + } -Disable polling: +Disable polling:: -{ "execute": "qom-set", - "arguments": { "path": "/machine/peripheral-anon/device[1]", - "property": "stats-polling-interval", "value": 0 } } + { "execute": "qom-set", + "arguments": { "path": "/machine/peripheral-anon/device[1]", + "property": "stats-polling-interval", "value": 0 } } -{ "return": {} } + { "return": {} } From patchwork Fri Jan 7 11:05:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576586 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=f0TRW0QR; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhMg4GmSz9tjx for ; Fri, 7 Jan 2022 22:49:19 +1100 (AEDT) Received: from localhost ([::1]:47010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nkD-0000PT-Dh for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:49:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n44-0001bT-I6 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41202) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n40-0002Wd-KY for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553540; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=q1Ji7D0+yweIY9HegKv+oFUY7MUbO+eKtuUlITnwqZ8=; b=f0TRW0QRyn0Q4sA7ITNmnwY63vUlpz03PdI9xGC0NZp4//Oa8VanW7Ldq2W0nS+ymWXhbg NiaOw4kAu2atAAmE8Y9KQ4QCUCTk+JnfBHcLW1FnOQOBHkFH+/ingqdHRcXJOq7YxGDjLW oHt1X9VZaX/bS8X+Kn8Y5dNb+l4Y14Q= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-126-EksNA1cONGWDZVyBZlgGIw-1; Fri, 07 Jan 2022 06:05:39 -0500 X-MC-Unique: EksNA1cONGWDZVyBZlgGIw-1 Received: by mail-wr1-f72.google.com with SMTP id r10-20020adfa14a000000b001a375e65e60so2120272wrr.2 for ; Fri, 07 Jan 2022 03:05:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=q1Ji7D0+yweIY9HegKv+oFUY7MUbO+eKtuUlITnwqZ8=; b=QknO+VUfJMVvV9NMDjfpN3r4XdizAHvBiYkHfiLgNb7MyDNfSUQErpmV4rxnmxP5xQ HC5rqBcOLNIqd2wbyUUxF9xlXQGboX9R6ucCuoB0P5r1kJhIa6LDVyfVKjp5+FVSmEkL FCwfhKHWgQ1OMPcSDwmOs0xmsTG7dO52M9ZkAEsWTiIyDOvIl0CQwzBEsW4Wr/YzZG9f eqHq+v/znviyOzgdMZdqdEMGKaV8ZWbMAQ1sYFYveAcKNHdTEbzP0irtqy5nDOZoGQOS iqWntyELmDQPCnSYFQvE55omCw6b04S06Qejpjo6gQGdcNxYSv4r+agkggMeKZdxMZJe DREQ== X-Gm-Message-State: AOAM531wN0Lw+oCswptDPfeAAdLbdkd7rBWFyv/ZFKzyYNEjBacPksbY j9eB33aMf27zd39Xfe+/9OROXDbgLovVYuTqWxeGbFL3X0w2OGmZmpTePUpB6A6xs+4rFD3Dlpv Fr5zRR20bR9Jdbukw0VrQp4kRNEvQg1CnTY7SL+c7T1lDG4IdK9SHnAD5Fgkx X-Received: by 2002:a1c:f01a:: with SMTP id a26mr10586629wmb.175.1641553537373; Fri, 07 Jan 2022 03:05:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcIY6ytk7OovWYiAEnqm2sN0NfFnkUesACw6vIUvkhAiEDPlJ5N2cDWqplwobYUPf8UySa3g== X-Received: by 2002:a1c:f01a:: with SMTP id a26mr10586610wmb.175.1641553537095; Fri, 07 Jan 2022 03:05:37 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id n7sm4146621wms.46.2022.01.07.03.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:36 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:34 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 50/55] hw/scsi/vhost-scsi: don't leak vqs on error Message-ID: <20220107102526.39238-51-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Daniil Tatianin , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Daniil Tatianin vhost_dev_init calls vhost_dev_cleanup in case of an error during initialization, which zeroes out the entire vsc->dev as well as the vsc->dev.vqs pointer. This prevents us from properly freeing it in free_vqs. Keep a local copy of the pointer so we can free it later. Signed-off-by: Daniil Tatianin Message-Id: <20211129132358.1110372-1-d-tatianin@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/scsi/vhost-scsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 039caf2614..efb3e14d9e 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -170,6 +170,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) Error *err = NULL; int vhostfd = -1; int ret; + struct vhost_virtqueue *vqs = NULL; if (!vs->conf.wwpn) { error_setg(errp, "vhost-scsi: missing wwpn"); @@ -213,7 +214,8 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) } vsc->dev.nvqs = VHOST_SCSI_VQ_NUM_FIXED + vs->conf.num_queues; - vsc->dev.vqs = g_new0(struct vhost_virtqueue, vsc->dev.nvqs); + vqs = g_new0(struct vhost_virtqueue, vsc->dev.nvqs); + vsc->dev.vqs = vqs; vsc->dev.vq_index = 0; vsc->dev.backend_features = 0; @@ -232,7 +234,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) return; free_vqs: - g_free(vsc->dev.vqs); + g_free(vqs); if (!vsc->migratable) { migrate_del_blocker(vsc->migration_blocker); } From patchwork Fri Jan 7 11:05:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576629 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=R0d+nZp3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVjDd28Dyz9sSs for ; Fri, 7 Jan 2022 23:28:16 +1100 (AEDT) Received: from localhost ([::1]:39114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5oLt-00052J-V0 for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 07:28:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n45-0001cO-Bo for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39717) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n43-0002Yu-7i for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553542; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tDeLlyz26ezikC22VaRSSlTH90Iv9SaCxPq3k3DQzw4=; b=R0d+nZp37Wi0s1dLjcYnXExqHnP0vdihgsZIUcxSOCbnPv/QaEW4GyrnUnijKb0TY28VlN vJofsoEMFW11QbgJxngf4d23Q+M4zbPO5Qrit+WnkO1gebITQMyqKdm6vKMGBSz+blf9zZ sjl32xxJlYLFkyx3oYparKF4FRgMXNE= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-640-J7GSJ0RIPMSXwFh9iJ-i3w-1; Fri, 07 Jan 2022 06:05:41 -0500 X-MC-Unique: J7GSJ0RIPMSXwFh9iJ-i3w-1 Received: by mail-wm1-f70.google.com with SMTP id 7-20020a1c1907000000b003471d9bbe8dso511082wmz.0 for ; Fri, 07 Jan 2022 03:05:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tDeLlyz26ezikC22VaRSSlTH90Iv9SaCxPq3k3DQzw4=; b=KYz4WK1X1BlYXvda++ml/Z8kDf6IBzIqcuMYmM6PsaWc715i7kFqDFverluTjEeFX8 ath/6JgNtc2Ktn5wWaxbq7vq+vmWjVnb8JqrZxx7qT//FezWfU2Ccf1v7BYEV9YsWFMs 4pcRh5KdrfghiDLEaQphc0pXqa4D2pepDE3UEPGQEpgGrC5vBiH46tGiYF76WUU5XWE9 El02+ashw13aofmyVw03rowubJB/Gav/683wVLneFjJ25tVA42S/Pw4uCYHN4rrqxHv/ aczMfVa9NE8sGbZZnmmSh31IANlji6skGY1B6d+A9R+8qZQSA9e4H4eJCQn/8zVCivJK yZWQ== X-Gm-Message-State: AOAM532URS4WPSD8ba5n3T6MGmf34cNeCN8wei8rjbKtDXVEezvI29Px lre7eECnL0pa12mp7CBZpHdw7iiLumKrJDZZ8y+K9uiJldnuBnmsHqj6eN+uQmXnnAguHjolFaN CWqYnrJYztVyVhOJpvv0l/UcoE3pCf+nJ9nKrLq2LGiIWgLYhNQjFD/P8Z57t X-Received: by 2002:a05:600c:a03:: with SMTP id z3mr10557108wmp.73.1641553539989; Fri, 07 Jan 2022 03:05:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7I7JqCvhYoMnBK+kDRXNWNY9dQjqSHvu7i4ZfkA9oq3AQ7ONCou0aq7Q7XOQM4fBWRdRQRg== X-Received: by 2002:a05:600c:a03:: with SMTP id z3mr10557085wmp.73.1641553539741; Fri, 07 Jan 2022 03:05:39 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id c8sm4591904wmq.34.2022.01.07.03.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:39 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 51/55] hw/scsi/vhost-scsi: don't double close vhostfd on error Message-ID: <20220107102526.39238-52-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Daniil Tatianin , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Daniil Tatianin vhost_dev_init calls vhost_dev_cleanup on error, which closes vhostfd, don't double close it. Signed-off-by: Daniil Tatianin Message-Id: <20211129132358.1110372-2-d-tatianin@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/scsi/vhost-scsi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index efb3e14d9e..778f43e4c1 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -222,6 +222,11 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) ret = vhost_dev_init(&vsc->dev, (void *)(uintptr_t)vhostfd, VHOST_BACKEND_TYPE_KERNEL, 0, errp); if (ret < 0) { + /* + * vhost_dev_init calls vhost_dev_cleanup on error, which closes + * vhostfd, don't double close it. + */ + vhostfd = -1; goto free_vqs; } @@ -242,7 +247,9 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) error_free(vsc->migration_blocker); virtio_scsi_common_unrealize(dev); close_fd: - close(vhostfd); + if (vhostfd >= 0) { + close(vhostfd); + } return; } From patchwork Fri Jan 7 11:05:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576582 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RQ2GtZXL; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhHX73y9z9tk3 for ; Fri, 7 Jan 2022 22:45:44 +1100 (AEDT) Received: from localhost ([::1]:38478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5ngk-0002lg-Q2 for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:45:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n47-0001fA-Ne for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n45-0002aA-SG for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553545; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sZKl68SrJVJX9J/g8uBNG773VeE63EY7yyNvoTLPOxc=; b=RQ2GtZXLWwmw69kSvw+uOO1/akzPuLnoir8K+iBI94ayKqZQXolN9yOYcX71C64jJAs/SR sozDFvTc2fbuxcuGzWbCsA0kBe9OjDM6q6LUEtPAzNGMr+xQhpv9296GJlgdUn98L1sje4 t+JiEecFe+K4cl7+XRfOvnivxuxfaLs= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-47-HC097CGQMDi2BKE3-8Hz6w-1; Fri, 07 Jan 2022 06:05:44 -0500 X-MC-Unique: HC097CGQMDi2BKE3-8Hz6w-1 Received: by mail-wr1-f72.google.com with SMTP id q2-20020adfab02000000b001a3ed59eb96so2100537wrc.20 for ; Fri, 07 Jan 2022 03:05:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=sZKl68SrJVJX9J/g8uBNG773VeE63EY7yyNvoTLPOxc=; b=etWDQxXBMKl60VUFRo3bQhy6EES+CK2HeiMIlAm6ON0nw45cepEbYBDCz/arYDEL7y 1K95BvGB/oxysIjkY3Ckuthl5U31MxTZEfECVOC6X5MSw9v7YyHLfVR18eWY5WH+Lssi bXo5Q2fwkK9ggcRiYS+sXc9rgqreu0xk4CTgPWc9bkDkbpcsVYYv0j13pfZYSezqe+vJ jACCl1lu2ma/V7j7YdIHnql5wXlbhgfy9Ec58IoSTjv/LOUPOuXX1u2ap/U/LTrWEO3h Ko3o1NcebjAcgVMYu9OKOpiGo7O9foBBZqs0LYemd2wS3yBEtSKVKArJb0Hh6yUCNKzP e2vQ== X-Gm-Message-State: AOAM532+vaKZ9HRwkqy/YN0UlxyT8zrSP8V+PbFNeru7qssxRigVpJCs /P2r4iLETkjDdWm+JzpuFRBQ5sJZXkdwcwCYoufmmfMP1qMD+4Gw3GU29/365C+DHzSHa3FrGl/ B4ulrTwHmBLFjEZ46W1Y4dpARc8g/C/sO2DizlGb2ThF3Kl3fEaQ3U5UNn2Mk X-Received: by 2002:a5d:66d1:: with SMTP id k17mr1399710wrw.239.1641553542845; Fri, 07 Jan 2022 03:05:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxE0ci59xpFPNg7Iq7Wpf3Dq63UhbA/fVu0oG9i+Xx8/V7CJ7HHcCkO59eB3crmF7unyZGrEQ== X-Received: by 2002:a5d:66d1:: with SMTP id k17mr1399698wrw.239.1641553542631; Fri, 07 Jan 2022 03:05:42 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id l8sm4511510wrv.25.2022.01.07.03.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:42 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:40 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 52/55] virtio/vhost-vsock: don't double close vhostfd, remove redundant cleanup Message-ID: <20220107102526.39238-53-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Daniil Tatianin , Stefano Garzarella Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Daniil Tatianin In case of an error during initialization in vhost_dev_init, vhostfd is closed in vhost_dev_cleanup. Remove close from err_virtio as it's both redundant and causes a double close on vhostfd. Signed-off-by: Daniil Tatianin Message-Id: <20211129125204.1108088-1-d-tatianin@yandex-team.ru> Reviewed-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vsock.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 478c0c9a87..433d42d897 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -171,6 +171,10 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp) ret = vhost_dev_init(&vvc->vhost_dev, (void *)(uintptr_t)vhostfd, VHOST_BACKEND_TYPE_KERNEL, 0, errp); if (ret < 0) { + /* + * vhostfd is closed by vhost_dev_cleanup, which is called + * by vhost_dev_init on initialization error. + */ goto err_virtio; } @@ -183,15 +187,10 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp) return; err_vhost_dev: - vhost_dev_cleanup(&vvc->vhost_dev); /* vhost_dev_cleanup() closes the vhostfd passed to vhost_dev_init() */ - vhostfd = -1; + vhost_dev_cleanup(&vvc->vhost_dev); err_virtio: vhost_vsock_common_unrealize(vdev); - if (vhostfd >= 0) { - close(vhostfd); - } - return; } static void vhost_vsock_device_unrealize(DeviceState *dev) From patchwork Fri Jan 7 11:05:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576591 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=X/LHfR4r; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhRS1R62z9tjx for ; Fri, 7 Jan 2022 22:52:36 +1100 (AEDT) Received: from localhost ([::1]:55602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nnN-0006I2-Vm for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:52:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n4B-0001p8-EK for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36819) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n49-0002b3-VY for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=whKn0pctPclugSGgiuj/6VncPkuXJJFQ5IPPduaKEoY=; b=X/LHfR4r+G4P1SnL2VtloigR1gBcYuaMkG03rQcMhtduAFZc/l11nUdn09H2ymgeSI+VA6 xk1Yq1lnHn8xv7iCtjaZJr0kunorC8FHluHsNPK3P7jHOvlKtuzK4ytzmyA7EgoaWUSjTG iK8jWmOBpplfVpdh7G8ZAmjNISQhsD4= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-54-c-8q1UyFNYeS4xYI_-seEw-1; Fri, 07 Jan 2022 06:05:47 -0500 X-MC-Unique: c-8q1UyFNYeS4xYI_-seEw-1 Received: by mail-wm1-f69.google.com with SMTP id m9-20020a05600c4f4900b0034644da3525so1353261wmq.3 for ; Fri, 07 Jan 2022 03:05:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=whKn0pctPclugSGgiuj/6VncPkuXJJFQ5IPPduaKEoY=; b=fNpn84BtA8SsqaMcKzNyvaf46kjqPEZgVM/AiLahke6krnKcUXO3zCd2mAg+SPFcDP CG4MBLOT/n2YRkJCO7TUnRyrv4DExOeDEK2FlqjFT1wc3p2PjXm3Pm98Mdre3H2+EKq3 uBDACegIccMhK/XdnGXwkiklHWrlEuhlNJOEqCb9/y+ZjgQOL2RoUOrIbUxolNZevLH8 xzQagALoEKWBuJgBoLtzajH6fhvAYbpCGZNwO71Czc8fxWiaeaGKslrzgelTLcFzo9iM B9DwthFZVUOZ3AcytfyplQ8K1FuPhi/svKNaHiHLUsw+dlC4/1PxKN1+rCwvQb3QNooF pjYA== X-Gm-Message-State: AOAM531V6b5wJsj9sZcVFN6dfglAlusOWvq94gJPmj413FsLi6zTmRjB X5ch+orRz336SAkkp5qdQFbaWVlM+J8HKpWWKlzOJdZlq0xndCtUryJF1kXdo41kKlFY4H5BBW4 3ae5ufo23TbPWufR5X+neZR7NenXOQcATOwmhgqnwAotISJGF+heoRJ9S0iph X-Received: by 2002:a05:6000:1ac9:: with SMTP id i9mr52688559wry.531.1641553546059; Fri, 07 Jan 2022 03:05:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxkv4X58l2gxFiHbgi+DUAIVSsaB6Mq8NapEC3gtq6C2nnZtvQ9e3YFQZ2L8La6q3T4UaPSpw== X-Received: by 2002:a05:6000:1ac9:: with SMTP id i9mr52688535wry.531.1641553545682; Fri, 07 Jan 2022 03:05:45 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id u11sm8579138wmq.41.2022.01.07.03.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:45 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 53/55] tests: acpi: prepare for updated TPM related tables Message-ID: <20220107102526.39238-54-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Igor Mammedov , Stefan Berger Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefan Berger Replace existing TPM related tables, that are about to change, with empty files. Cc: Michael S. Tsirkin Cc: Igor Mammedov Cc: Ani Sinha Signed-off-by: Stefan Berger Acked-by: Ani Sinha Message-id: 20211223022310.575496-2-stefanb@linux.ibm.com Message-Id: <20220104175806.872996-2-stefanb@linux.ibm.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Igor Mammedov --- tests/qtest/bios-tables-test-allowed-diff.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index dfb8523c8b..5d80e408d4 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,3 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DSDT.tis.tpm12", +"tests/data/acpi/q35/DSDT.tis.tpm2", From patchwork Fri Jan 7 11:05:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576587 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Mlxc9ibK; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVhMh0qN9z9tk3 for ; Fri, 7 Jan 2022 22:49:20 +1100 (AEDT) Received: from localhost ([::1]:47048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5nkD-0000Qy-TW for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 06:49:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n4G-00021A-0M for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34933) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n4D-0002bj-9B for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:05:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553552; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HOsqJqrBMIM1qexMOBxqQCQ/OVZSIyFbpDvHp5LI3u0=; b=Mlxc9ibKq4aXvsp1UPx1im2T9Z8HqfCgL88Q3O22ZiQU5c+2hl+LY3EA3R2BEDZ1h677aO 83m9rLx4T895AHxurHHEimMzwivro6KzOFCVYKfdd3MK/+x/Sr2Z2xjO0OQ8z3xXcNKg9N iuaxx1Zt5z1G0H7izr+ir60iKfAkG0U= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-166-0-2fg12YMUqoGkcDLMzfOQ-1; Fri, 07 Jan 2022 06:05:50 -0500 X-MC-Unique: 0-2fg12YMUqoGkcDLMzfOQ-1 Received: by mail-wr1-f72.google.com with SMTP id q2-20020adfab02000000b001a3ed59eb96so2100619wrc.20 for ; Fri, 07 Jan 2022 03:05:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HOsqJqrBMIM1qexMOBxqQCQ/OVZSIyFbpDvHp5LI3u0=; b=z9hVpAh19cq9oOat3FUr+t2LjqeJKEQL7qtHAhmEd0T0Y+eCssbjsjkl8l/Ywb4OvU wvG2GuGquy7NKe7C1yKl4c2NFbp3X+/QN9OiUhdttz3R3EcwzVFiV5vdkx9YdzvyScke 5SazM3f0vyphnke/DZWyrLHq3mnYSaLr7XnES0ybHO1Py6lu4EwBoo0VjZjmKjmFEiE9 i/o4SDZJHA2uOHnnCQcwHzsadAt16GWCExLvR6W44EeVesMIDtwVQ+3KMYVq8ugg9lDK C6Yi3qqVDgE6BwBGdVpbtQ42ACOWVMJZNvxKMclDiCSBlCfyo3O3yE83OKYW4UlTYk/O tIiQ== X-Gm-Message-State: AOAM533rBu4ubQt9CaHKI492gjQfMNfR7zBMwHsemujoEy/ucVQ/k6l5 8de4FJy/GNPX1QxL4FYJmPoIiWuzoQKVNXPXTUCjD6gGojf0j00J50dnTEWxZ5Z2WpcT+XT76gw AdgN3q8r6lman/pWuNLF+whzSIKNfBwgtHKCquvY8XScnnyGd/LpmHfp0GIWy X-Received: by 2002:a05:6000:1886:: with SMTP id a6mr55414163wri.614.1641553549019; Fri, 07 Jan 2022 03:05:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxaZH0bfhn22vbSn2E0wl+tTt22LFG4/guLqpF5EnUDKte/OtoFDrOt7+FGzE2mvLRZLl7wtQ== X-Received: by 2002:a05:6000:1886:: with SMTP id a6mr55414140wri.614.1641553548836; Fri, 07 Jan 2022 03:05:48 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id j13sm8315918wmq.11.2022.01.07.03.05.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:48 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 54/55] acpi: tpm: Add missing device identification objects Message-ID: <20220107102526.39238-55-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Peter Maydell , Richard Henderson , Shannon Zhao , qemu-arm@nongnu.org, Paolo Bonzini , Ani Sinha , Igor Mammedov , Stefan Berger Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefan Berger Add missing TPM device identification objects _STR and _UID. They will appear as files 'description' and 'uid' under Linux sysfs. Following inspection of sysfs entries for hardware TPMs we chose uid '1'. Cc: Shannon Zhao Cc: Michael S. Tsirkin Cc: Igor Mammedov Cc: Ani Sinha Resolves: https://gitlab.com/qemu-project/qemu/-/issues/708 Signed-off-by: Stefan Berger Reviewed-by: Ani Sinha Reviewed-by: Shannon Zhao Message-id: 20211223022310.575496-3-stefanb@linux.ibm.com Message-Id: <20220104175806.872996-3-stefanb@linux.ibm.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- hw/arm/virt-acpi-build.c | 1 + hw/i386/acpi-build.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index d0f4867fdf..f2514ce77c 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -229,6 +229,7 @@ static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms) Aml *dev = aml_device("TPM0"); aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101"))); + aml_append(dev, aml_name_decl("_STR", aml_string("TPM 2.0 Device"))); aml_append(dev, aml_name_decl("_UID", aml_int(0))); Aml *crs = aml_resource_template(); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 0234fe7588..ce823e8fcb 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1812,11 +1812,15 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, dev = aml_device("TPM"); aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101"))); + aml_append(dev, + aml_name_decl("_STR", + aml_string("TPM 2.0 Device"))); } else { dev = aml_device("ISA.TPM"); aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31"))); } + aml_append(dev, aml_name_decl("_UID", aml_int(1))); aml_append(dev, aml_name_decl("_STA", aml_int(0xF))); crs = aml_resource_template(); @@ -1844,12 +1848,15 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, if (TPM_IS_CRB(tpm)) { dev = aml_device("TPM"); aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101"))); + aml_append(dev, aml_name_decl("_STR", + aml_string("TPM 2.0 Device"))); crs = aml_resource_template(); aml_append(crs, aml_memory32_fixed(TPM_CRB_ADDR_BASE, TPM_CRB_ADDR_SIZE, AML_READ_WRITE)); aml_append(dev, aml_name_decl("_CRS", crs)); aml_append(dev, aml_name_decl("_STA", aml_int(0xf))); + aml_append(dev, aml_name_decl("_UID", aml_int(1))); tpm_build_ppi_acpi(tpm, dev); From patchwork Fri Jan 7 11:05:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576631 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=U+DVlHPv; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVjJt1Xg5z9sSs for ; Fri, 7 Jan 2022 23:31:57 +1100 (AEDT) Received: from localhost ([::1]:44266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5oPQ-0008Sw-MW for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2022 07:31:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n4N-0002Ic-RE for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:06:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:33038) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5n4I-0002cY-BL for qemu-devel@nongnu.org; Fri, 07 Jan 2022 06:06:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641553557; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IyIX4Y52IesbNq4lnMucnk8E/SfIhuYQ0BGXFbD8E9s=; b=U+DVlHPvFqWPnQeqz9DB1CP1pDfCu2ISQyuhO2ZRvX1OBtQLNMbzs4AHv2TJreHgUODIXS fqrUjsl5tcxJCi6zXXKnAQ8H/rNz7aBWRPliAyGkorRI9fkaSp6EXx6VKh/rEWtPHECSHf m4r5OjxBG90uXG5DDsN/fgLKL+a2sBw= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-421-GATO9yNONkuP39yBDieWJg-1; Fri, 07 Jan 2022 06:05:53 -0500 X-MC-Unique: GATO9yNONkuP39yBDieWJg-1 Received: by mail-wr1-f70.google.com with SMTP id o28-20020adfa11c000000b001a60fd79c21so428282wro.19 for ; Fri, 07 Jan 2022 03:05:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=IyIX4Y52IesbNq4lnMucnk8E/SfIhuYQ0BGXFbD8E9s=; b=jJ85x9FDGhtuutAMbCrIuabtmognW/yMTTRR9Y0TaytOPR+LicpexuRkgRV0Lyf95M XeJM8qMcgwC2Jwk0ssw4xMQlv9jXmr/FQsrjrdWcHFizTCSWYgwr169Hll9v/dcWBVB2 XZ4AKp06X1XHuyGKSUkTbAraIX35Zrj2+ynRfLcc/fI38Slp6S3H83aoAkisMYCUduE3 xux3KLQSeJCHeU8+Ow+b951G2hro8OZ3z6wRo5nbMWH+oeFv2j+QkuV8yEwMB7Whh+CD YuHbN12PgwFChZdWMx7N4JyTsE5hIyi1529IJY1r0bFMLYwzDbwi/jqwzuS/6x3s3N+v frIA== X-Gm-Message-State: AOAM532fldD0x5+peqqFC/huGag0iWU/ehuSd6IIbQyHeYCSceNpysjv nZtY2gpZEAOfLBSHM/omnabhb9DeorZSenfEL/+pwzhcIQVuqFQZJAT0HgQnHieyyyxIPVXkXad KXV1GIxI8dkcJfO5zvcNI7H5MFiWunHhFPTIBBZ4jrLyI11x5T/rsRUsdftWP X-Received: by 2002:a5d:64e2:: with SMTP id g2mr23944143wri.690.1641553551838; Fri, 07 Jan 2022 03:05:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjQQjaCY2XpEPUdHpwZkTWkbX7rXsoRa87IP5Mla8GX3U+T9XCaIcSLL6quRTO6+hhtxmz2w== X-Received: by 2002:a5d:64e2:: with SMTP id g2mr23944127wri.690.1641553551618; Fri, 07 Jan 2022 03:05:51 -0800 (PST) Received: from redhat.com ([2.55.16.192]) by smtp.gmail.com with ESMTPSA id o13sm1323386wrc.111.2022.01.07.03.05.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 03:05:51 -0800 (PST) Date: Fri, 7 Jan 2022 06:05:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 55/55] tests: acpi: Add updated TPM related tables Message-ID: <20220107102526.39238-56-mst@redhat.com> References: <20220107102526.39238-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220107102526.39238-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Igor Mammedov , Stefan Berger Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefan Berger The updated TPM related tables have the following additions: Device (TPM) { Name (_HID, "MSFT0101" /* TPM 2.0 Security Device */) // _HID: Hardware ID + Name (_STR, "TPM 2.0 Device") // _STR: Description String + Name (_UID, One) // _UID: Unique ID Name (_STA, 0x0F) // _STA: Status Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings Cc: Michael S. Tsirkin Cc: Igor Mammedov Cc: Ani Sinha Signed-off-by: Stefan Berger Acked-by: Ani Sinha Message-id: 20211223022310.575496-4-stefanb@linux.ibm.com Message-Id: <20220104175806.872996-4-stefanb@linux.ibm.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 2 -- tests/data/acpi/q35/DSDT.tis.tpm12 | Bin 8894 -> 8900 bytes tests/data/acpi/q35/DSDT.tis.tpm2 | Bin 8894 -> 8921 bytes 3 files changed, 2 deletions(-) diff --git a/tests/data/acpi/q35/DSDT.tis.tpm12 b/tests/data/acpi/q35/DSDT.tis.tpm12 index 0ebdf6fbd77967f1ab5d5337b7b1fed314cfaca8..fb9dd1f0599afd6b555ea570ecd00a3bb227aa84 100644 GIT binary patch delta 50 zcmdnzdc>8>CDH@7HQF#!OXcoHoD delta 46 zcmccVy3du%CD