From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641475273; cv=none; d=zohomail.com; s=zohoarc; b=I4eOyDIOf2VV5QPUObGR1Y/lbu8vm/3HhAxN90co4AXwLNR/f6pwBZFc4CrhQVQawm57PLes0IdQ8+jbGzLMGr4Oo74dUuJbpH15WdIYbf+OzMMNa64con5fzhjGX54Nug6vQYvxz9zHbsaKgvSI1EYx9kGtNWJ4bRb2Dv3+LXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641475273; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZDYUVmJkHemLI5KByv30OJoOAnuNT00GDgLmkQC7+Is=; b=GjvO9RzdkgwUu3fwYpLPJQPLg0uL0DSeTkH27TgwDMS2aqMxBt2LIGJxgp3Eued1ZINfuiJjOoZnxXHry1KEneFY6aS1UEEQA6owffBJ2w+UASZOG1vrPa5TC9CaY4aRp3xzQFD2S7khPqTYsPaz/xkDjf+whoAjmStJyHtRs0g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641475273676826.731511327854; Thu, 6 Jan 2022 05:21:13 -0800 (PST) Received: from localhost ([::1]:51976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5Shc-0007hb-8T for importer@patchew.org; Thu, 06 Jan 2022 08:21:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sd1-0003xt-3h for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35697) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Scy-0000kZ-Fn for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:26 -0500 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-371-1gTIMxnNPeagePRUgYZrJA-1; Thu, 06 Jan 2022 08:16:22 -0500 Received: by mail-wr1-f69.google.com with SMTP id v14-20020adfa1ce000000b001a49d6587ceso1180861wrv.21 for ; Thu, 06 Jan 2022 05:16:22 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id y1sm2042607wrm.3.2022.01.06.05.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:16:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641474983; 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=QXB7msUPjLbNqpLHm1Pt0ctuSt17boocXhgd2P8UPux8vB9Znx+hJTBnjS6Iu7/UbZ6G8H Ld6GBZkg67t7s4c7AvQo1dA/FR49j5E/dcw5U0ggMhz6QFjljN4zbiRXkXXq27mql12E1B 4VBJZMEgiGYcp/s795rqyNd+9fugGQc= X-MC-Unique: 1gTIMxnNPeagePRUgYZrJA-1 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=2oApD/xslSYyIR8xwrBuYXVpcOoNmP3MXoMdlwEV3snNeMEAnbNx1CgW9T0Dq7gwLq YFGIWPRo3VDQa5ORVDsEMLcM1R5OVCiF8ZsMmCiSXPoIIxXfUQMXGv+xLBxxyvHvXnO5 4X6OjyRvmbU/ZhunsVOpMq/uf+S27e94xrV0khe/YGiOD/AAvshpiA178UNSA6schez9 WjJpG6rFQUJV7VENTyfjKpD2BiJJzhgTcDLGBDV+e93VliqAuifjfGfAWJ6cRNLCPCdf 0VP1iVjaRUwIQN8jEIteZdDoGtnu8BNBP475mIqtY91r85V0fCj7KlfpAeTXOvsB67DM H5/w== X-Gm-Message-State: AOAM533r9O5UFvBylYRcBsbv45Wwf3966medkTSbNrVeWHrMd+hyqbup 4ixnYa1QzKGOmqmyXdiEjcI0nJN1S+pKp9zYy/SnGUNC8UkPA5nyT+UbxwnouKufXxqJafvUViF YJnz3J8tg9VH2X2qV1vqPEzRRmjHBJVXk5Bi/iYE1sjuHeWROqlNWAtJQus/k X-Received: by 2002:a7b:c00d:: with SMTP id c13mr7098276wmb.99.1641474981056; Thu, 06 Jan 2022 05:16:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDrFmdjz6pfz0Ur0h37d34VIiVz04l/+lhIzncN4XfqVaoMrWYOKnYpuVSmrtfc9aiJANAsg== X-Received: by 2002:a7b:c00d:: with SMTP id c13mr7098261wmb.99.1641474980818; Thu, 06 Jan 2022 05:16:20 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:18 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 01/52] virtio-mem: Don't skip alignment checks when warning about block size Message-ID: <20220106131534.423671-2-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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 , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641475274269100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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); --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164147567055775.38396901976023; Thu, 6 Jan 2022 05:27:50 -0800 (PST) Received: from localhost ([::1]:60878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5So1-0007LB-E5 for importer@patchew.org; Thu, 06 Jan 2022 08:27:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sd2-0003xv-C5 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:28320) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sd0-0000l5-R1 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:28 -0500 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-587--DIFZMgHOV2TBPSj29TJAA-1; Thu, 06 Jan 2022 08:16:25 -0500 Received: by mail-wm1-f72.google.com with SMTP id k40-20020a05600c1ca800b00345bf554707so1927781wms.4 for ; Thu, 06 Jan 2022 05:16:25 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id m15sm2310762wrw.27.2022.01.06.05.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641474986; 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=S7YkuYMRBEUzH7kXKzwTqeE/MegYkp8krvBpjAugAHlxdN1mS6CMx2koVQ9wA/16ugWfit CvO0NczN90oGEtMph2MmrR7QIDSRpOfJQ5+BltyjcmtWpFSf9/lBbuuegyl28JwBoxoqmo THtf4pLZWS9HcQuPs54i61w8olXZFcw= X-MC-Unique: -DIFZMgHOV2TBPSj29TJAA-1 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=MgkSSuabC3O24zs+Yw3unL9WdA6Bf7L6y3OJbDhs7O9mWbJr/lNeyuUzMAdxZhVidM uN/WJVUTBTAWQwBEvd/MrLboqLXCRQ4p3dR+xI6ZKIgIZk2o++NZoiP/aM18n1N+RTqA gRdG/xzmyl5lnjkVvYazPecgT0zpDq5E9kY/V4IuK/UUMJnz4xRF43ImBQlGb1DGoMkZ cVMbwVCaMFr/LisLqd0LQY42o9I1pVVs3z1meAoJPYiDIKn+FZ/+ONrBdUOHf70c2KVu 4t5PNDLiRg22FHztJ2yXGoedstbs15mCl6gcTmxE+fVMHa5o3719dg/gEePMGAGLugcH ZDdg== X-Gm-Message-State: AOAM533rHQl0rSXbBz2bEe68T+T6CzFF1i35sZoRngGWA6qt+/kWb60n wfvTFb+cryW13z/Bil1wn2kSliWCDjssWTkzNddVuUbFjQBUexaR5FP/JKmrn06LIRpNktD6rIY cj+65xGmXzPNs6cc1KajLEOFmvyg7pe+DmzKO8iB7KcLCUeLQuscisthK+x8t X-Received: by 2002:a1c:2544:: with SMTP id l65mr7224494wml.101.1641474983611; Thu, 06 Jan 2022 05:16:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTrLPJnOVzKwIGOTfW1jfGlrRpV0KZpsU3ibO6xuyDOVeFvZLWKvb/7tp2CMeo6l2YOLnK8w== X-Received: by 2002:a1c:2544:: with SMTP id l65mr7224476wml.101.1641474983426; Thu, 06 Jan 2022 05:16:23 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 02/52] acpi: validate hotplug selector on access Message-ID: <20220106131534.423671-3-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641475671400100003 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=C3=A9 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, } =20 bus =3D acpi_pcihp_find_hotplug_bus(s, s->hotplug_select); + if (!bus) { + break; + } QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) { Object *o =3D OBJECT(kid->child); PCIDevice *dev =3D PCI_DEVICE(o); --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641475668676454.6407548536039; Thu, 6 Jan 2022 05:27:48 -0800 (PST) Received: from localhost ([::1]:60636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5Snz-0007B6-FC for importer@patchew.org; Thu, 06 Jan 2022 08:27:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sd7-00041T-Gq for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sd5-0000mp-Km for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:33 -0500 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-507-PtVDgtunNDeFF_t-V6THhA-1; Thu, 06 Jan 2022 08:16:29 -0500 Received: by mail-wr1-f71.google.com with SMTP id t26-20020adfa2da000000b001a585909b5dso99245wra.6 for ; Thu, 06 Jan 2022 05:16:29 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id b1sm2291915wrd.92.2022.01.06.05.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:16:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641474990; 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=Odya/Hajzv384fDJJfOf901tGX5a5ysIYwoVzHRnOefstEMba+E5u9O1M3rg7vQzDFBmvJ ILxnrr5KORqyGz32P74oYY4dvgwZZsA3Av2hzpWkYfxWNe/c+bBCN8iiB+HyUb0v2gpFmz W/nuHNR6xkAjoSi8rZJFdDgAwpi1/Xc= X-MC-Unique: PtVDgtunNDeFF_t-V6THhA-1 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=GwQDVmVk5qCBvfA3yT5ZryzdwxwQSSHrUd6DJ60b+TqdiLwOE1oGBkGw8vFaZX6u0s Tk2zJ95OJB0TIp4kS2X4zI8WS7I6Mtqd7pF9lXTKzU2prs9294MPZsfQiimzo6H1MY06 hMWpowQLA3TBUle3O1vBDcj56NPI+xLoWyFBRtrDIBA0nVp10a8LCu0h2P23DkXQsmpD JsdtLSBKxf+JylmZG8fIPQvzuUQTmP8W/NgnoKqYmA5YT5oxkclDnQ3ggFcgBXrUZWiU DaaGQZ+quiAWqYJvT43r0af9OUFP0oAzy33FnB2po3Dq63qvdiILmxf5yXNwjjHgO2/L +UTA== X-Gm-Message-State: AOAM530q4/sJg9PQKqH8g7qQ8uUQSDILfWpzZkqgH5leUqAKFEXOqkk3 6A42fr640eHbg1IiF8LAcUIdV72YgAj7shrIP8Gh+nwYBhsTudViSLlTQ2mpAy+6hFT7DL8F9Np fpFN1TU496jlig+nOa24b0N09Uf4hUczZBpdpK5kYv+jA+qlF1Bq7Dg+oLj5Q X-Received: by 2002:a1c:f414:: with SMTP id z20mr7063753wma.17.1641474986639; Thu, 06 Jan 2022 05:16:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyavRknoFrp8+NvBMCQ1BfuY6iASLVZk1xSmc0lQUPnbiUNFzV+8byfSfN+uJDpMhbLCd+4VQ== X-Received: by 2002:a1c:f414:: with SMTP id z20mr7063721wma.17.1641474986362; Thu, 06 Jan 2022 05:16:26 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:23 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 03/52] virtio: introduce macro IRTIO_CONFIG_IRQ_IDX Message-ID: <20220106131534.423671-4-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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 , 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641475669793100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_pend= ing. Add the check of queue index in these drivers, if the driver does not suppo= rt 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 =20 #define VIRTIO_NO_VECTOR 0xffff =20 +/* 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) =20 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 *vde= v, int idx) { VhostUserGPU *g =3D VHOST_USER_GPU(vdev); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return vhost_virtqueue_pending(&g->vhost->dev, idx); } =20 @@ -493,6 +496,9 @@ vhost_user_gpu_guest_notifier_mask(VirtIODevice *vdev, = int idx, bool mask) { VhostUserGPU *g =3D VHOST_USER_GPU(vdev); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } vhost_virtqueue_mask(&g->vhost->dev, vdev, idx, mask); } =20 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(VirtIOD= evice *vdev, int idx) VirtIONet *n =3D VIRTIO_NET(vdev); NetClientState *nc =3D qemu_get_subqueue(n->nic, vq2q(idx)); assert(n->vhost_started); + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return vhost_net_virtqueue_pending(get_vhost_net(nc->peer), idx); } =20 @@ -3177,8 +3180,11 @@ static void virtio_net_guest_notifier_mask(VirtIODev= ice *vdev, int idx, VirtIONet *n =3D VIRTIO_NET(vdev); NetClientState *nc =3D 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 =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } + + vhost_net_virtqueue_mask(get_vhost_net(nc->peer), vdev, idx, mask); } =20 static void virtio_net_set_config_size(VirtIONet *n, uint64_t host_feature= s) 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 =3D VHOST_USER_FS(vdev); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } vhost_virtqueue_mask(&fs->vhost_dev, vdev, idx, mask); } =20 @@ -168,6 +171,9 @@ static bool vuf_guest_notifier_pending(VirtIODevice *vd= ev, int idx) { VHostUserFS *fs =3D VHOST_USER_FS(vdev); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return vhost_virtqueue_pending(&fs->vhost_dev, idx); } =20 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(Virt= IODevice *vdev, int idx, { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } vhost_virtqueue_mask(&vvc->vhost_dev, vdev, idx, mask); } =20 @@ -133,6 +136,9 @@ static bool vhost_vsock_common_guest_notifier_pending(V= irtIODevice *vdev, { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return vhost_virtqueue_pending(&vvc->vhost_dev, idx); } =20 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(VirtIODev= ice *vdev, int idx, =20 assert(vcrypto->vhost_started); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } cryptodev_vhost_virtqueue_mask(vdev, queue, idx, mask); } =20 @@ -958,6 +961,9 @@ static bool virtio_crypto_guest_notifier_pending(VirtIO= Device *vdev, int idx) =20 assert(vcrypto->vhost_started); =20 + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } return cryptodev_vhost_virtqueue_pending(vdev, queue, idx); } =20 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641478691; cv=none; d=zohomail.com; s=zohoarc; b=B8E30OA7U8HtIrrmRvMrx79mnVG42icv2PX1MOpKY3qQIjWjC8F1+5q0K2t+soObBbW1F+uYddgfXWDNDKok01jGWsxRdPAtkZSEjZdM7hY51msAdr/dKnp4wAI/a2sc/2JVDXohJeI51YtzscaP4ZAg29VsCHtMi5s2ick85uk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641478691; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hOPjiFqJP+CxAguLqjRkfscaiAq3ABKE+YBS09bWzw4=; b=Xi+qjymQC5dzl8PEkNN2Tz6aeKgDy5RA21e5v5jhvrudsem5Xlrx9HiICb7KypPKmqBBBYoq4/vDpQHv+Sdtjy0ikD99zvTeXLz28BWMRBjps25GCpuQBNq5uxAYoLAWMKbox40Z4NARxYdAiBa+s66DrnUDjzSDgnPAMOy3zV4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641478691355600.0275165951473; Thu, 6 Jan 2022 06:18:11 -0800 (PST) Received: from localhost ([::1]:35748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5Taj-0005Zh-7f for importer@patchew.org; Thu, 06 Jan 2022 09:18:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sin-0003fe-UW for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:22:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59267) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sil-0001tI-NL for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:22:25 -0500 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-654-PoTpd1EjNcSUW21D2L2JBA-1; Thu, 06 Jan 2022 08:22:22 -0500 Received: by mail-ed1-f69.google.com with SMTP id b8-20020a056402350800b003f8f42a883dso1913903edd.16 for ; Thu, 06 Jan 2022 05:22:18 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id w7sm713273ede.66.2022.01.06.05.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:22:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475343; 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=RkT4txowM1l6OQ0tVmQUpmsrOfP8uOrPYQua4jGgKlKlhcDEzsoXFpu8wbGdkectlXbAW3 NVy8EQxEtwPZ0VKQVkY4Lc5vWjCd8ZUd2Dm/2C6sF3rE/JDQealVVXq7aJY5At+K8Jx/bQ AKpOb9cfBIsrHcxQAq79q0nXYpd3w80= X-MC-Unique: PoTpd1EjNcSUW21D2L2JBA-1 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=sYl9T3K1Z5YN8k9MOLvnthODKA4ASR+e05JrktSmgnrCUEBWK6VI/2CZMqYb0iWRHT Bx4HEOYnUriMGq4+51xi6Cymr+m+uL3CkNv0ndJqkDolq+Swy63x5QXrWCgf+nW26+0R sjuLgMRXoiCOMeHErQitqRlV0/bes4wlnL3UmNiF4nKf6vewPpPsSdYzkQQJwAkIPrVe JHVxF8HOWMKrfcTpM8nJlO3ttiCY625s3PzEPCxAIifJqgJdig00shVQYZ2640roSw+b gAIALB8Fx0K6VQaPwSS8c59/s0Or5rXS1u9Yn2HgAWt/F97UXm62Guw6Q2OvXv8LBHQ5 sPDg== X-Gm-Message-State: AOAM532Crcw/7MXOoPyiKd64Qo5/tHIvJ7awlYUeqU9IQ1zsCIsDPRJ7 5XsilvQnYIcaLlX9R32O6GUY1TTF9qxHpniBb2e8yL5mYeSw3eqxKXxvT5aZh/BPjFi7NicdvQD D1sRXwzUIwj+5rPsiEyViQJ2uKk1KLJru9OXnEBngoNggpM9V9PEyvdIwnzoL X-Received: by 2002:aa7:ccc7:: with SMTP id y7mr3316375edt.96.1641475336506; Thu, 06 Jan 2022 05:22:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWW+RVxbPRxGrMX+rvuZ7DCeIVTgB8S9+6/PivceEJEyAva3BSmCCwl28iieo+aWJRYCAetg== X-Received: by 2002:aa7:ccc7:: with SMTP id y7mr3316354edt.96.1641475336304; Thu, 06 Jan 2022 05:22:16 -0800 (PST) Date: Thu, 6 Jan 2022 08:22:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 04/52] virtio-pci: decouple notifier from interrupt process Message-ID: <20220106131534.423671-5-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641478693235100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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(VirtIOPC= IProxy *proxy, } =20 static int kvm_virtio_pci_irqfd_use(VirtIOPCIProxy *proxy, - unsigned int queue_no, + EventNotifier *n, unsigned int vector) { VirtIOIRQFD *irqfd =3D &proxy->vector_irqfd[vector]; - VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); - VirtQueue *vq =3D virtio_get_queue(vdev, queue_no); - EventNotifier *n =3D virtio_queue_get_guest_notifier(vq); return kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, NULL, irqfd->v= irq); } =20 static void kvm_virtio_pci_irqfd_release(VirtIOPCIProxy *proxy, - unsigned int queue_no, + EventNotifier *n , unsigned int vector) { - VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); - VirtQueue *vq =3D virtio_get_queue(vdev, queue_no); - EventNotifier *n =3D virtio_queue_get_guest_notifier(vq); VirtIOIRQFD *irqfd =3D &proxy->vector_irqfd[vector]; int ret; =20 ret =3D kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, n, irqfd->vir= q); assert(ret =3D=3D 0); } +static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no, + EventNotifier **n, unsigned int *vec= tor) +{ + VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); + VirtQueue *vq; + + if (queue_no =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return -1; + } else { + if (!virtio_queue_get_num(vdev, queue_no)) { + return -1; + } + *vector =3D virtio_queue_vector(vdev, queue_no); + vq =3D virtio_get_queue(vdev, queue_no); + *n =3D virtio_queue_get_guest_notifier(vq); + } + return 0; +} =20 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 =3D VIRTIO_DEVICE_GET_CLASS(vdev); unsigned int vector; int ret, queue_no; - + EventNotifier *n; for (queue_no =3D 0; queue_no < nvqs; queue_no++) { if (!virtio_queue_get_num(vdev, queue_no)) { break; } - vector =3D virtio_queue_vector(vdev, queue_no); + ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + break; + } if (vector >=3D msix_nr_vectors_allocated(dev)) { continue; } @@ -752,7 +767,7 @@ static int kvm_virtio_pci_vector_use(VirtIOPCIProxy *pr= oxy, int nvqs) * Otherwise, delay until unmasked in the frontend. */ if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - ret =3D kvm_virtio_pci_irqfd_use(proxy, queue_no, vector); + ret =3D 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 =3D 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(VirtIOPCIPr= oxy *proxy, int nvqs) unsigned int vector; int queue_no; VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); - + EventNotifier *n; + int ret ; for (queue_no =3D 0; queue_no < nvqs; queue_no++) { if (!virtio_queue_get_num(vdev, queue_no)) { break; } - vector =3D virtio_queue_vector(vdev, queue_no); + ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + break; + } if (vector >=3D msix_nr_vectors_allocated(dev)) { continue; } @@ -795,21 +818,20 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIPr= oxy *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); } } =20 -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 =3D virtio_bus_get_device(&proxy->bus); VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); - VirtQueue *vq =3D virtio_get_queue(vdev, queue_no); - EventNotifier *n =3D virtio_queue_get_guest_notifier(vq); VirtIOIRQFD *irqfd; int ret =3D 0; =20 @@ -836,14 +858,15 @@ static int virtio_pci_vq_vector_unmask(VirtIOPCIProxy= *proxy, event_notifier_set(n); } } else { - ret =3D kvm_virtio_pci_irqfd_use(proxy, queue_no, vector); + ret =3D kvm_virtio_pci_irqfd_use(proxy, n, vector); } return ret; } =20 -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 =3D virtio_bus_get_device(&proxy->bus); VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); @@ -854,7 +877,7 @@ static void virtio_pci_vq_vector_mask(VirtIOPCIProxy *p= roxy, 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); } } =20 @@ -864,6 +887,7 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, uns= igned vector, VirtIOPCIProxy *proxy =3D container_of(dev, VirtIOPCIProxy, pci_dev); VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); VirtQueue *vq =3D virtio_vector_first_queue(vdev, vector); + EventNotifier *n; int ret, index, unmasked =3D 0; =20 while (vq) { @@ -872,7 +896,8 @@ static int virtio_pci_vector_unmask(PCIDevice *dev, uns= igned vector, break; } if (index < proxy->nvqs_with_notifiers) { - ret =3D virtio_pci_vq_vector_unmask(proxy, index, vector, msg); + n =3D virtio_queue_get_guest_notifier(vq); + ret =3D virtio_pci_one_vector_unmask(proxy, index, vector, msg= , n); if (ret < 0) { goto undo; } @@ -888,7 +913,8 @@ undo: while (vq && unmasked >=3D 0) { index =3D virtio_get_queue_index(vq); if (index < proxy->nvqs_with_notifiers) { - virtio_pci_vq_vector_mask(proxy, index, vector); + n =3D virtio_queue_get_guest_notifier(vq); + virtio_pci_one_vector_mask(proxy, index, vector, n); --unmasked; } vq =3D virtio_vector_next_queue(vq); @@ -901,15 +927,17 @@ static void virtio_pci_vector_mask(PCIDevice *dev, un= signed vector) VirtIOPCIProxy *proxy =3D container_of(dev, VirtIOPCIProxy, pci_dev); VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); VirtQueue *vq =3D virtio_vector_first_queue(vdev, vector); + EventNotifier *n; int index; =20 while (vq) { index =3D virtio_get_queue_index(vq); + n =3D 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 =3D 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; =20 for (queue_no =3D 0; queue_no < proxy->nvqs_with_notifiers; queue_no++= ) { - if (!virtio_queue_get_num(vdev, queue_no)) { + ret =3D virtio_pci_get_notifier(proxy, queue_no, ¬ifier, &vecto= r); + if (ret < 0) { break; } - vector =3D virtio_queue_vector(vdev, queue_no); if (vector < vector_start || vector >=3D vector_end || !msix_is_masked(dev, vector)) { continue; } - vq =3D virtio_get_queue(vdev, queue_no); - notifier =3D virtio_queue_get_guest_notifier(vq); if (k->guest_notifier_pending) { if (k->guest_notifier_pending(vdev, queue_no)) { msix_set_pending(dev, vector); --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641475279; cv=none; d=zohomail.com; s=zohoarc; b=mafSgMZac8bSsdBk1va7fByuMEfVOXrV7VLuSE5F6nqt0FJUPsc9F3Er9upPKRS4KxZrsvJffsOacFq7XaIu4r5GuE9KUNp5mQ1Ours5MPp5Lp7yILLdE2pfg5i8qH42UQe/K/hA+FSSPp79mdazrfpGWilzHenj6hBJmuRydhw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641475279; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ClYbQ4kuyaz5beNK9wuLMbdICDpNeUV54F3CfDPsyqg=; b=Geb+5vpu0I2lWd5VtyWfd7eCHKYy354XoUj1iyS2zl5nMUNY/80YcctmNTIC+v7EA/KX8+F/IA5cB12msPoXAmxV4M6GGrXoPT4DowzOwXIl5EfSkTYVp/LFrdXgyy9J+sTjqbb4V6PeyL/VciL3OAVRnyx48kpuYyyQzGCWs3c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641475279697771.8351926635034; Thu, 6 Jan 2022 05:21:19 -0800 (PST) Received: from localhost ([::1]:52296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5Shh-0007uG-H9 for importer@patchew.org; Thu, 06 Jan 2022 08:21:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdC-00042x-Vf for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37010) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sd9-0000nY-JJ for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:37 -0500 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-2-qbjAOk76OlWR7slIfQFQWg-1; Thu, 06 Jan 2022 08:16:33 -0500 Received: by mail-wr1-f71.google.com with SMTP id r10-20020adfa14a000000b001a375e65e60so1256676wrr.2 for ; Thu, 06 Jan 2022 05:16:33 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id m17sm5434332wmq.31.2022.01.06.05.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:16:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641474994; 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=gHx5VZejrzCwud4pGXdSfEsM2BGLQg6gyMerlo57NtT7zJW0vz12MAiLlm7tLCSLHYxP1N loW+1bd1A3DpNzebNTq+I1Iek79GbgtSBSQyF8QOpgvEfyBh88GXrUeVgU9mL74cjCYAwQ x8IoOHH8TZiSzzFedkfZAR4KgtxGwQg= X-MC-Unique: qbjAOk76OlWR7slIfQFQWg-1 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=yRKNCewVqbLJ9M5OfKtJ1uJwuQ+GuBOXODJyRJvQ3XLWFxp1cLObkgpv6ewIQGCObX zscZzuUcgiXqlOknk4oA+GkLCi3p9/ExFHavMEMN+YvuXpUcFct6i30DqQ/az9UKmAeL uVlYcQDfaOivj+Qh8DsRwVeyEtaeHE+kc5AxCkSwhY5Cudindxd+wuG3NUzZ7EekmYeS D+IUuenrgCLhcjDJYMYnZN/2bjeCrllrZAXLoAY0Dhb7XaF/jmGSuQ4JWcW/LZ2TJv8F bt2laY92YyeUOLH547ni8vgp7MQlJ9WvCdCu07CyDgMh16wQEd5fSrWZX7401gfx7NvN e+KA== X-Gm-Message-State: AOAM530o7dEt49eRoglIifgKvGRt8hRoPVIJLQBrLpVJ6kmpCHGmTrGe Mr6gz1TlXvkP5k8CRtsuDdse4iHW0Wl0uWr+Wj+3Hb98aOThv+dJYEo77Smd453IhrqiuqwUp9C VTObJDRTN4ZMUCitby8EKQQG++cye5oYnLlL1lTvLrskNt5iC3RA2X6eGCtBy X-Received: by 2002:a5d:588f:: with SMTP id n15mr49238381wrf.240.1641474991992; Thu, 06 Jan 2022 05:16:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmPgon5lQMOjgYCaybYa81uwGykoWYovdOiqtplb7dzXqY7cBvpJYxz08a/C6HjJKFa8raIQ== X-Received: by 2002:a5d:588f:: with SMTP id n15mr49238369wrf.240.1641474991758; Thu, 06 Jan 2022 05:16:31 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:29 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 05/52] virtio-pci: decouple the single vector from the interrupt process Message-ID: <20220106131534.423671-6-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641475280240100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu To reuse the interrupt process in configure interrupt Need to decouple the single vector from the interrupt process. Add new func= tion 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 n= umber. 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, } =20 static int kvm_virtio_pci_vq_vector_use(VirtIOPCIProxy *proxy, - unsigned int queue_no, unsigned int vector) { VirtIOIRQFD *irqfd =3D &proxy->vector_irqfd[vector]; @@ -740,87 +739,103 @@ static int virtio_pci_get_notifier(VirtIOPCIProxy *p= roxy, int queue_no, return 0; } =20 -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 =3D &proxy->pci_dev; VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); - unsigned int vector; - int ret, queue_no; - EventNotifier *n; - for (queue_no =3D 0; queue_no < nvqs; queue_no++) { - if (!virtio_queue_get_num(vdev, queue_no)) { - break; - } - ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); - if (ret < 0) { - break; - } - if (vector >=3D msix_nr_vectors_allocated(dev)) { - continue; - } - ret =3D kvm_virtio_pci_vq_vector_use(proxy, queue_no, vector); + + ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + return ret; + } + if (vector >=3D msix_nr_vectors_allocated(dev)) { + return 0; + } + ret =3D 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 =3D 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 =3D kvm_virtio_pci_irqfd_use(proxy, n, vector); - if (ret < 0) { - kvm_virtio_pci_vq_vector_release(proxy, vector); - goto undo; - } - } } - return 0; =20 + return 0; undo: - while (--queue_no >=3D 0) { - vector =3D virtio_queue_vector(vdev, queue_no); - if (vector >=3D msix_nr_vectors_allocated(dev)) { - continue; + + vector =3D virtio_queue_vector(vdev, queue_no); + if (vector >=3D msix_nr_vectors_allocated(dev)) { + return ret; + } + if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { + ret =3D 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 =3D 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 =3D 0; + VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); + + for (queue_no =3D 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 =3D kvm_virtio_pci_vector_use_one(proxy, queue_no); } return ret; } =20 -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 =3D &proxy->pci_dev; VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); unsigned int vector; - int queue_no; - VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); EventNotifier *n; - int ret ; + int ret; + VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); + PCIDevice *dev =3D &proxy->pci_dev; + + ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); + if (ret < 0) { + return; + } + if (vector >=3D 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 =3D virtio_bus_get_device(&proxy->bus); + for (queue_no =3D 0; queue_no < nvqs; queue_no++) { if (!virtio_queue_get_num(vdev, queue_no)) { break; } - ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); - if (ret < 0) { - break; - } - if (vector >=3D 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); } } =20 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641476001; cv=none; d=zohomail.com; s=zohoarc; b=mNoVxWv8WZCcGxgNZGR8zvisaUVsILmqAeywQ2qpcPbqx6qgnA1qBnxB3tkFwKwdJuefK5RkPuzzQN0Y+y/mquT2X2RNNMli9g3N2cHfABGepu9Od3KbcxpOxLTP0h3MPEbs0Uh9wU+iQsUgobFOFMOCG87gP39HdRCq3jLK1o4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641476001; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=873JIwL0Ssx4x2GI9hqUqv8te9fEzO/xVfFKyB9oXJQ=; b=TRYQWS/u1X6s4DilIMN/F4UvZAMjNKctSHOPxzFj4aOjMSFRnDybf91KwRtnUsQC5+QvBbsB/rtTDjI2Qyt3Seukmj0n/tpHUeJskN3PVVxeJKiLU3CtBUaWeG9XGrZY+0pFaLAKES+OzsJvkjmfkchc51T8Bg5vUCYGtIQTTJA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476001924474.04527298574044; Thu, 6 Jan 2022 05:33:21 -0800 (PST) Received: from localhost ([::1]:41058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5StM-0004qB-Se for importer@patchew.org; Thu, 06 Jan 2022 08:33:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdD-000430-Gm for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22421) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdB-0000nf-PF for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:39 -0500 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-50-yVP_dRDDMQKmsxkLWZPihw-1; Thu, 06 Jan 2022 08:16:35 -0500 Received: by mail-wr1-f72.google.com with SMTP id g6-20020adfbc86000000b001a2d62be244so1226491wrh.23 for ; Thu, 06 Jan 2022 05:16:35 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id u3sm2591977wrs.0.2022.01.06.05.16.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:16:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641474996; 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=MFf4jo2oVapJinEjfccQ+NqcgGaEzMenvoIiFVDe7rVZ/FRT3JdWtuFFv1WOxURzW3MBje rdooXoOH6vDRXO0hmoUY8SUzS2zpudLMRm4pWwjkQ3ZOk9Ux3tV7q84rff4oJG5rzfVfCC gZAOslFIA/bbUNrqXxVGnwJ7shRelr4= X-MC-Unique: yVP_dRDDMQKmsxkLWZPihw-1 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=tJ1tq/KENY8peugxEUrXYFrsDtyKamN9vg4TXrD+tPEH4I/kGKmVT7SizhLnH5Cqzh Jt0a3Xg5maqwX4EQaZTDXUCvH4lLZx3I3mDGZmjpL/cckOQaTogW03S9ghduKUDBgUWh ImRizv7obTMKI9uJ6nV4S5R/a0EWHWoILGwn/jtVIv5NSX2rTpnIXUKiTThEK3gPRhsp eZjRqSF4mGhUT8P3U29jvQgzAAghnhEnmTSGbRszEfHrztFqXajedFf9oLNvmvIE36/I OgFARi+xY6P3Uh1a1UvaBP+KyAypKjPTXjri1P/nY8qTZ4yc8FGschcoXuyhxOgJsvge WBwQ== X-Gm-Message-State: AOAM531POadlnK0tW63eYfw6m6R1IHLFxE1AiuC5hQmi6wvtVL4V9Jo/ Pl8LILAzpv5UB9zgMGbgYIg2t06kaMa9juXt77b1o0g3GIh0Tpts0xRL+0acPoxCJUnhbKkFFHC ZkAGOadWzfSUwDgnV/gsXZktrRTQ+2WxJKA6+bX8ALW4Phh4keVj63wxT4WtY X-Received: by 2002:a5d:698c:: with SMTP id g12mr1997027wru.69.1641474994382; Thu, 06 Jan 2022 05:16:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwat/pZUfiX15cypImFWbngHmZHLilyyUZLSLa80u9Yxs2xgbghz+82ojbMJDgArIMKZxgmGg== X-Received: by 2002:a5d:698c:: with SMTP id g12mr1997006wru.69.1641474994129; Thu, 06 Jan 2022 05:16:34 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:31 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 06/52] vhost: introduce new VhostOps vhost_set_config_call Message-ID: <20220106131534.423671-7-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641476002749100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu This patch introduces new VhostOps vhost_set_config_call. This function all= ows 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-ba= ckend.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); =20 typedef bool (*vhost_force_iommu_op)(struct vhost_dev *dev); =20 +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; =20 int vhost_backend_update_device_iotlb(struct vhost_dev *dev, --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641475675; cv=none; d=zohomail.com; s=zohoarc; b=jfMWxzslzN/J2fVhRQ51g9/xIqFGu7rYb7OpBXdC+EHhHU89n887cdLhdjQwg50/sIcZ/Y+tC/eh4njhav+GQ+x3IEwiMllqLQfHQEj32pvWUxP9lXkTSv77tGpByY05ymfS6KVbBBlol0JyakgTeUXJBgb0uRgFbGhp11svewo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641475675; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Gv52akJFHQiv170C8mObbPapN00kjPRMbnaS61dDiXs=; b=FiGY2jQ3t6k3uGXJFpq7/Jrj6u4i948rUkadezSo/gBkqWXvUACw1j7Vph364nAQ3F121IBWI3fxQFjLkkwOTB8LJWt1JYOj8tTBTOWWv6oowUe/4q3GIDSDYcPzY16wHWzM2HVBxGZbZBVPrLzfT3ccaqetYBeolqC8Dq9kwoc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164147567536594.80755963740114; Thu, 6 Jan 2022 05:27:55 -0800 (PST) Received: from localhost ([::1]:32876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5So6-0007YH-6h for importer@patchew.org; Thu, 06 Jan 2022 08:27:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdH-00043z-6B for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32167) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdF-0000oH-HI for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:42 -0500 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-139-gpyPDDBEMBq5g9kOojNQ7A-1; Thu, 06 Jan 2022 08:16:39 -0500 Received: by mail-wm1-f71.google.com with SMTP id m21-20020a7bcf35000000b00346ddc490efso179127wmg.8 for ; Thu, 06 Jan 2022 05:16:39 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id z22sm6117302wmp.40.2022.01.06.05.16.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:16:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475000; 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=F9DmEmHx2VRwo2Ax7XNEL3WJoN/DMfVBQH+qM8SLMdZyD7IOs88KmfS2+gSP3/komQiNd9 GaDeLUA02RWTmgGzWA6CxKqK1Q28nXXgcXQxuuG8AYpAoJ3WfBf9t6c69WY0NFSqBvap5F jqFEjIw82MEjV4eEfX+O/G4y+aoTuYI= X-MC-Unique: gpyPDDBEMBq5g9kOojNQ7A-1 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=k5Reir9nJxztTMoM41OGNV8noNkn+ZA97gPGq7KSyYYl1Ci0u8KbwNe+N2kg/T6kCe W4muQsnDQsTVzKmDO3f8bu1rj3Vogf/X+MxG2NlRXV8YT3kMNDz3WPNHfYMw468UxC51 K3h0HJOlZ/a6chqmoiri/9Ou3J4zE43op3d9m949QLXkQO99jpCjcjFMBLDkzaH6nvfZ uJSxauqTq5eIVgzY1yREvOURwlt4iCyxnYyuEdhVLw643ZPIn+eTDWRGVdnfXhWOS69P MfgtICOMHf70fwFXES77q+k+fDTYepFbDdlL78n9xkbKsorKt8aSL9KsbiDOwfHZ7QCk PB5g== X-Gm-Message-State: AOAM533YKn9T3mpWTJLcKFs7JVlpLmtWexm5tCdfZM67mrXARkpajyY6 Yw3tCTOpV8CdvwcdIUxWymGI985UlDkhaRf2ruR0jydo8kzmaIh2xxUhax6SiZzcnPTgEZinMUM WMvEOZT6qBXibiL5rQu2V4XLqVgUJVYuojxfsSBlQZaWZaj+Ft+PgoedFM8/F X-Received: by 2002:adf:f5d2:: with SMTP id k18mr3323647wrp.567.1641474997046; Thu, 06 Jan 2022 05:16:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZcp1AUNLDR2xl0TbDGORZI7yH31u+XB5AZ/vo0D5rE9cofxpSa7Lmr9RjwzuUMpPR1gPxhg== X-Received: by 2002:adf:f5d2:: with SMTP id k18mr3323624wrp.567.1641474996809; Thu, 06 Jan 2022 05:16:36 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:34 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 07/52] vhost-vdpa: add support for config interrupt Message-ID: <20220106131534.423671-8-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641475677380100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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); +} =20 static int vhost_vdpa_get_features(struct vhost_dev *dev, uint64_t *features) @@ -795,4 +801,5 @@ const VhostOps vdpa_ops =3D { .vhost_get_device_id =3D vhost_vdpa_get_device_id, .vhost_vq_get_addr =3D vhost_vdpa_vq_get_addr, .vhost_force_iommu =3D vhost_vdpa_force_iommu, + .vhost_set_config_call =3D 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) "de= v: %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, uint6= 4_t avail_user_addr, uint64_t used_user_addr) "dev: %p vq: %p desc_user_add= r: 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" =20 # virtio.c virtqueue_alloc_element(void *elem, size_t sz, unsigned in_num, unsigned o= ut_num) "elem %p size %zd in_num %u out_num %u" --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641476000; cv=none; d=zohomail.com; s=zohoarc; b=MjlVk+jT7xQ2Rm7qEdlxkA27iGFJ26kC8V+710cEoGqJAj9gykQ/icEYvWuAqpOl8XDpKn2GcdffL49siHisOqGgnTNWNzJVPdivqf8e1l9RtGRR6S0dAPSupRoOUIs0Jcj4T3myH4KjiEkTw9UbL0zsoKOj+YaaL/VrQq9Zc+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641476000; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=m0o2ISf2fuLkjyQa6eo4LTXkqbFcr+aoyo0kUY28Ncc=; b=dSk+8jK50z+dpqvsCHUPq9stf9BHn5eTP+tijWnI6tpF7ofeD7X5Lv1sXw+XW/Zslm5wSJg9FNkvjKo5acJgabcvnZNq5jmI5KecuBNn5Ci3tJQBl7wEYMaosYMX7X5tCbo/nFGzJP+sUmmtNHVZIo42+oBVdCsydSX2J6QRO1Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476000246984.5700610943749; Thu, 6 Jan 2022 05:33:20 -0800 (PST) Received: from localhost ([::1]:40960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5StK-0004m7-PO for importer@patchew.org; Thu, 06 Jan 2022 08:33:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdJ-00044V-Ir for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54352) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdH-0000oQ-04 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:44 -0500 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-530-9INMkKndMSCwMlAt4L-W6w-1; Thu, 06 Jan 2022 08:16:41 -0500 Received: by mail-wm1-f72.google.com with SMTP id k40-20020a05600c1ca800b00345bf554707so1928146wms.4 for ; Thu, 06 Jan 2022 05:16:41 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id i8sm1840682wmq.4.2022.01.06.05.16.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:16:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475002; 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=Q664L/gek76X6JSLmGpf6LXH4keq4beHNEgi9TD6hUvWF6DAWgp03h6iZ6ae18XepJAHdR kWaX1XgiweYfb0qEcJO7fzqK/e6wv83CzRtVqo7zo72/XlZ46QQgwihqEkQe6VrrUTk+zO Jc9M1uXkH6/B4KmgRH8GC6Was/RqgVI= X-MC-Unique: 9INMkKndMSCwMlAt4L-W6w-1 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=gwhAXUOXVj6wQ5bYpAM1scTJFr34uqcoQ3zV0fD3If9TOX9XzDxRmrZnSL3jVoUqHx yCCf43/N1L6QT+JI42O1FpajF4LjtIXVByr5P+3dUAQBKY+C/jJfDZAYNlvzthOoBohq 7EOYButqYLx8hDre9+z4b4XyWkN94ObwnyQi+fvvQvaR1nstsLz3LEMGvCSKZ2GxnRk3 jDN9A1IdKVbEtDAuUhOXpCsWbI+kX7JT5Ez9rutmgBbcEx6wD6o0wMyAj9BVmwNmmU/H Tl4Agf01dbV455VG4PL67UAz8UUsM6rVEexrx+0rkFa9o8G/sZiQviPNPc0ThXYEqlFo Er1g== X-Gm-Message-State: AOAM532h90E0UMYCeAltFYsV7F31O0p7vbShWc2FhLfzkFW38aUAtwbW dyr327KqB0A4FXADyt3SaxGVkaNkiz+yB9Jnk0pnaTz4yMaC2j2I6hl5IAu4VfT7aFTXsIDRr5m ZaBQmQzfJeqk4+My2EdlgZD/W3VOd0jYLTjhDxPc9Sv8o03i/YLDo1a8LtKV9 X-Received: by 2002:a7b:c959:: with SMTP id i25mr2623395wml.164.1641474999746; Thu, 06 Jan 2022 05:16:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJy7gnWuIq3IoY/IWeL2h4+K/3lg8vFbUgvr8rbQD/9QFHO1VVO2RE9v1hQGmAI+3d86HK5E+A== X-Received: by 2002:a7b:c959:: with SMTP id i25mr2623372wml.164.1641474999478; Thu, 06 Jan 2022 05:16:39 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 08/52] virtio: add support for configure interrupt Message-ID: <20220106131534.423671-9-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641476002749100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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; }; =20 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_ir= qfd); 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(EventNo= tifier *n) virtio_irq(vq); } } +static void virtio_config_guest_notifier_read(EventNotifier *n) +{ + VirtIODevice *vdev =3D container_of(n, VirtIODevice, config_notifier); =20 + 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(Virt= Queue *vq, bool assign, } } =20 +void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev, + bool assign, bool with_ir= qfd) +{ + EventNotifier *n; + n =3D &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(VirtQu= eue *vq) return &vq->host_notifier; } =20 +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 =3D enabled; --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641475280; cv=none; d=zohomail.com; s=zohoarc; b=YLryBANKwZPxCelVIwmMin3aEPLrgh7hmtQY+ZSfAhd4imbhq52zObnkfJle72Pb+IYpP0uTxcP4bCUtMLnFa7VveTa60+lDXWTQnl1wPbePRMXpvH/rG7gEXe//5tcIA+SpXqZ63DcZ81Nyl9kcIL2hGKtrTvr4zfm0KcCp8Wk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641475280; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ETB+n0NhBVWLTVk31iuRnbCsPO0dzdop/Y6jcjDWEjk=; b=Vgn7yKlrfEweEFaQVq5SS3bha/bZ1r79Elva3/D6L9hejRMAleE3Q0t/GHNRUNaqnbECwURmJeNLULwtA5Vb6Jdnf1tczdgixe+Mo2N/KGHsZBCFbpL0NaJebLcv/dTu7SkfINnPMQ3Y6GxzomcNNFm6cduWdQ9TYvZfTeQiEjA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641475280551703.5770975628316; Thu, 6 Jan 2022 05:21:20 -0800 (PST) Received: from localhost ([::1]:52300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5Shj-0007uM-CL for importer@patchew.org; Thu, 06 Jan 2022 08:21:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdL-00044x-Sj for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57535) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdK-0000oj-01 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:47 -0500 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-141-dvaVktDGPYKl1HbGOcUZHg-1; Thu, 06 Jan 2022 08:16:44 -0500 Received: by mail-wr1-f72.google.com with SMTP id v14-20020adfa1ce000000b001a49d6587ceso1181237wrv.21 for ; Thu, 06 Jan 2022 05:16:44 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id u16sm1990171wrn.24.2022.01.06.05.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:16:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475005; 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=FXVLQOm45T40k84dZgsUgt9OtPI7Y3b9qt3iRG7PZPbEA2EuN4zK0IHuByqZq7GCUYc90L eS/KeZsR9XAQk5pZoTc2tejyi6ocwaIOBD9LbSKXTHezC4VB9jCyq9ZiQdts/AvBmxTaqB j/KnoY3AjNK8IAKMTCUO+dPUGOEEqxY= X-MC-Unique: dvaVktDGPYKl1HbGOcUZHg-1 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=7EvrVizNMHSzL6tjrY/ZAuAJb0RUHK3lyZJJUyGqJaFIu3+PvTIqtzJPmqZQXjjLj0 MAVOImq3Zp6H7YZQORWtPp+T9yYfPrmSE9gqxMmFzZbNnhlStloWg0kmEoT1wN7CKvnQ Est5MZ1UmUpJnaPnZwyrUCWDZVgVWzhQDfp7A72pnNLBUHI5Fz86Bc+7a8psAW8knpd4 2oLuTqeh9RG3/c6+BkkB0jejkT5P4NLJojBMkTHlbNHTrOkt4aQCNwnYuZTQFU6Kg5gN s5YPFymnv4EWjVhVUlPk4tVxUffSAeorvbflkTEsG56H3dslQWMj85nDfEKSxC9HCB54 Wc6Q== X-Gm-Message-State: AOAM533XyDqZMd1sJ4W0w99zZCZpFCZLMAcucXSjEPxzy0VPb62IGIBj 8rBZK1DK4JBXIbNRCoOcwla+Hfx+sxzZoFocCVUL/8w+fzlPM3OKzNs/fGjEQ812ncPI/cR1psx n7PkMMz0c4I8C6dXPaVtGgrT8/Yg8jbv0fTQ4z0K6TWNeEgWfVzZu96pr5VNM X-Received: by 2002:adf:ea4a:: with SMTP id j10mr3668867wrn.275.1641475002300; Thu, 06 Jan 2022 05:16:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcCOKY6Owkxz6J3JFzYqoAd6HIt4+241OFgjEdgxlC/CGzhX48j3+ujN24XEvkeI32J4613w== X-Received: by 2002:adf:ea4a:: with SMTP id j10mr3668847wrn.275.1641475002067; Thu, 06 Jan 2022 05:16:42 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 09/52] vhost: add support for configure interrupt Message-ID: <20220106131534.423671-10-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641475282264100007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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; }; =20 @@ -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 =20 struct vhost_log { unsigned long long size; @@ -116,6 +118,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevic= e *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 *vde= v); +bool vhost_config_pending(struct vhost_dev *hdev); +void vhost_config_mask(struct vhost_dev *hdev, VirtIODevice *vdev, bool ma= sk); =20 /* 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, Vi= rtIODevice *vdev, int n, } } =20 +bool vhost_config_pending(struct vhost_dev *hdev) +{ + assert(hdev->vhost_ops); + if ((hdev->started =3D=3D false) || + (hdev->vhost_ops->vhost_set_config_call =3D=3D NULL)) { + return false; + } + + EventNotifier *notifier =3D + &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 ma= sk) +{ + int fd; + int r; + EventNotifier *notifier =3D + &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier; + EventNotifier *config_notifier =3D &vdev->config_notifier; + assert(hdev->vhost_ops); + + if ((hdev->started =3D=3D false) || + (hdev->vhost_ops->vhost_set_config_call =3D=3D NULL)) { + return; + } + if (mask) { + assert(vdev->use_guest_notifier_mask); + fd =3D event_notifier_get_fd(notifier); + } else { + fd =3D event_notifier_get_fd(config_notifier); + } + r =3D 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 =3D -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 =3D event_notifier_get_fd(&dev->vdev->config_notifier); + if (dev->vhost_ops->vhost_set_config_call) { + r =3D 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_bit= s, uint64_t features) { @@ -1773,6 +1834,16 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODe= vice *vdev) } } =20 + r =3D 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; =20 @@ -1806,6 +1877,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODev= ice *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, VirtIODev= ice *vdev) =20 /* 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); =20 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, VirtIODev= ice *vdev) } memory_listener_unregister(&hdev->iommu_listener); } + vhost_stop_config_intr(hdev); vhost_log_put(hdev, true); hdev->started =3D false; hdev->vdev =3D NULL; --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476023203255.4890134699383; Thu, 6 Jan 2022 05:33:43 -0800 (PST) Received: from localhost ([::1]:41682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5Sti-0005Fc-1T for importer@patchew.org; Thu, 06 Jan 2022 08:33:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdR-000478-V9 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36094) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdM-0000oq-7o for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:51 -0500 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-301-b5z4Fdu9N8G8vfM_5QqSEw-1; Thu, 06 Jan 2022 08:16:46 -0500 Received: by mail-wm1-f69.google.com with SMTP id m15-20020a7bce0f000000b003473d477618so544097wmc.8 for ; Thu, 06 Jan 2022 05:16:46 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id w6sm1311444wro.114.2022.01.06.05.16.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:16:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475007; 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=hk3B2Abvr8nT1jKUQbmrWarvr90bi4+YLo3wLpkRHks=; b=KI4WXNkD0MkrkZCFb6YStG/9ItHbTsS336kr50CRIAzPHYSbn2eJwRSgo85LLgFpjbf0CJ 0mORhdMK3ivYLOHqpR8ENtUAicoAss/5vzEeyRTAYcGPbzNfAItPiI0GsynithRZ7yPppL koJ3i3uOty8RjZGfhfCBvX0Z/MRB3fY= X-MC-Unique: b5z4Fdu9N8G8vfM_5QqSEw-1 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=hk3B2Abvr8nT1jKUQbmrWarvr90bi4+YLo3wLpkRHks=; b=375tAL4pS7911onC+TrjpmDlgOoCGwqOi2X417CthE/6DRLkEladnkEooE6sPKFxas tY7b5AwCXQjzkKEBk3/vBQCNMqK3mpG5qS+q6ZxF0oTWXUy0khB/rdX/eJBGmdKjFChA H3IN54ORXeMEiPKnupcYMUGLcEUdxQTkf0dswYwPg5oUxQh02Dg6FiC+wmXkBFYLlaNY AVT51CvLjbqhAps/EZkOjaSiI6VICeJMLFWPA2A3yDH1+71p1KwDKtHLXbx/3xrYPbDU PL9I4F0E7xrxPR8PH79RYneJKT+ePaK64blmX3SzOIrSJ6RQVLvyuOpIsoHA4lVgfotr mWgg== X-Gm-Message-State: AOAM5306zBDVLhs2jMkgryQ32QLYs9YToLIhfUCrmaUiL6nTSePXVa6I aP9Blx7f61stMZiES4P7Z3LmwL3e6kGmzKjd15wMjGFjXjyXlzflRYrotU+vqbL98Y569HQl0Lv qvtQfDuqtPH0KgRLdTkmBNYssLKTPC/MiKwMZWw0el6Ga8VzHF31T9piOB9by X-Received: by 2002:a05:6000:1688:: with SMTP id y8mr48801217wrd.682.1641475005126; Thu, 06 Jan 2022 05:16:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwAPuiGhNJCyx9RG5C/fAOorqU/xc6Ioy6KzrQmimhwnQwpVVaHdy6g4M1bJ3/+6V5HiHZ6DQ== X-Received: by 2002:a05:6000:1688:: with SMTP id y8mr48801196wrd.682.1641475004803; Thu, 06 Jan 2022 05:16:44 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:42 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 10/52] virtio-net: add support for configure interrupt Message-ID: <20220106131534.423671-11-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476024956100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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.c | 9 +++++++++ hw/net/virtio-net.c | 4 ++-- 3 files changed, 13 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 uin= t8_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 mas= k); int vhost_net_notify_migration_done(VHostNetState *net, char* mac_addr); VHostNetState *get_vhost_net(NetClientState *nc); =20 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, Virt= IODevice *dev, vhost_virtqueue_mask(&net->dev, dev, idx, mask); } =20 +bool vhost_net_config_pending(VHostNetState *net) +{ + return vhost_config_pending(&net->dev); +} + +void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mas= k) +{ + vhost_config_mask(&net->dev, dev, mask); +} VHostNetState *get_vhost_net(NetClientState *nc) { VHostNetState *vhost_net =3D 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(VirtIOD= evice *vdev, int idx) NetClientState *nc =3D qemu_get_subqueue(n->nic, vq2q(idx)); assert(n->vhost_started); if (idx =3D=3D 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(VirtIODevi= ce *vdev, int idx, NetClientState *nc =3D qemu_get_subqueue(n->nic, vq2q(idx)); assert(n->vhost_started); if (idx =3D=3D 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); } =20 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641476262; cv=none; d=zohomail.com; s=zohoarc; b=WY6iA1zdzJ6fb4CVEPl5b6X8RwdwzVABeFNoY0668+gFd/WYT4qAq4uadCgPcygdWAYp1LkQdQ2p0P6JyUeTMcfLLATEnnAn0XxdnRLqq4fu59wg7pFl/0Dd92sp3XOXP3pVMrrwmtxKGJEtpN6QqK3R2/daGeOG4ixWR2zF/H8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641476262; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cSicCZD+rdT4rp9zVpF4X3HF/ofaRyPJFH9NwIHYGDo=; b=VWB8ick6oi/dHwMf1b2Qq3ZZuCn6RRe6Y4jn0gSH39NDKgCWkUTCWZL3AVXliCIxIDcxIQbJ+rFlELU5XwkVmrMrnWhwHkEjMPR2WuzXB+Ye7/oXorNJSzqjzq7nUUobTAY0JF3mEIAX7ZNHSyDP03ePD4Kt76cxSDfR/5+t3dI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476262755260.4622306825994; Thu, 6 Jan 2022 05:37:42 -0800 (PST) Received: from localhost ([::1]:50264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5SxZ-0002js-Lv for importer@patchew.org; Thu, 06 Jan 2022 08:37:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdR-00047J-VV for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:58276) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdO-0000p6-7h for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:51 -0500 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-433-sQliyDFUMvWyXoolceDAgw-1; Thu, 06 Jan 2022 08:16:48 -0500 Received: by mail-wr1-f72.google.com with SMTP id w25-20020adf8bd9000000b001a255212b7cso1232356wra.18 for ; Thu, 06 Jan 2022 05:16:48 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id 14sm2157125wry.23.2022.01.06.05.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:16:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475009; 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=gSKEDsVurF7HihEKQLJBd0Hy4pakzwpGWJ6OnTg6Snuu+FKRBuo+tWAeZ0mwup+ipit/KA pSAW5wTw3t9M9IQggbacuuZxUGqTLL0xEPVpc0hTjQLM7sXDEyBNcWA6KwXqKzoehns5WG UuYcU7mRm0PGJZkldZPAXGKCzQVgxPc= X-MC-Unique: sQliyDFUMvWyXoolceDAgw-1 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=ZInt+BXME9E5Q/6A6VzCPMievtLAEwg5EVwyqa2Zzx4yFixx14TTWhent20pe79vE2 2lZW0WABhTJyNzfJumbMgB3PjFizLYO8bkcPJI1OQtPy0IJuPLf2o6AH+Zl1GIiz1ORL N+91rgTga6n9RI4GcBfVmseNUOUBuwn0giiPQkJn1KnlmyJ1UBmNRoqYGfCvs8VaycoK 96dfUNK9XMB29QL0oIzPP8KSEIK+814m+xk3hJzrURuwhbmdg+lp45shsE3Ik3SxA/wb J/JBA3uVv18JGc6PP3FxjKcggV335Fn9/T0h2UK3k1P38XrNCga/exKoPm0x/gGO7sHD /Vpg== X-Gm-Message-State: AOAM533qu3jm7+XMy2ozArxOYBp7YiV869N3OTyqh7Wg9KyiGdB9IRgM +ems0I0xh34MPFFdRG29PBGUxW4L1Mdxi8gSyIUZofd7JFX4UjK4FdtQnxSN4w5OqFbi9H5ZmH8 jIVz78Zwq7KfLK1zalsUyo6qUTlCr4QA/ICR4mWXTZ13hnOCOgmIFDKwd//qK X-Received: by 2002:a05:600c:2114:: with SMTP id u20mr4465209wml.67.1641475007333; Thu, 06 Jan 2022 05:16:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJx5ZgHC6FztOMLVC4WpnnL0hUyjegs5o0MP0ukrw1iDQxbhpanGepyjELZRn0Xecvsv8M2tog== X-Received: by 2002:a05:600c:2114:: with SMTP id u20mr4465194wml.67.1641475007131; Thu, 06 Jan 2022 05:16:47 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:44 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 11/52] virtio-mmio: add support for configure interrupt Message-ID: <20220106131534.423671-12-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641476263227100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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, =20 return 0; } +static int virtio_mmio_set_config_guest_notifier(DeviceState *d, bool assi= gn) +{ + VirtIOMMIOProxy *proxy =3D VIRTIO_MMIO(d); + VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); + bool with_irqfd =3D false; + EventNotifier *notifier =3D virtio_config_get_guest_notifier(vdev); + int r =3D 0; =20 + if (assign) { + r =3D event_notifier_init(notifier, 0); + if (r < 0) { + return r; + } + virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irq= fd); + } else { + virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irq= fd); + 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 =3D virtio_mmio_set_config_guest_notifier(d, assign); + if (r < 0) { + goto assign_error; + } =20 return 0; =20 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641475783; cv=none; d=zohomail.com; s=zohoarc; b=dlF73fOzBVy9ourmFBT6uj0iHlUiGPmCxHAaCWdp2NoOx3UN5ZFkRn7ghFteT9xUXFQfG+ut1P2bSBeTLd8pLpArjb2eS3j3kvFuDo6rw0nO3O6O+ostSx+nUtxDoCc6iyM89eR+r4X68DUsvgP6uabwIGXeABXopJBWc5vXQVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641475783; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5QxedhqdIVW/4TN1ei0pMq/CHa5wdqs2AGGdB1TxsBA=; b=gSXeocrK1prog31ZqCHZd2EFAVipYEA1uqwmroXGv+YRJ3Zj4ilL2S9LjyNdU9z4mY3L1XZSPnR4ZgZATALdKYTOsp/SHRroscrmIUh6lasay4kd/mz0wc4cNljXQo3l46PiFJ7oRDfIh55b+uI3FOqbSEmmGkwffbOR6rp/fpU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164147578323767.29755289567856; Thu, 6 Jan 2022 05:29:43 -0800 (PST) Received: from localhost ([::1]:35434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5Spp-0000rm-UG for importer@patchew.org; Thu, 06 Jan 2022 08:29:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdT-0004Az-O0 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdR-0000pR-Ph for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:55 -0500 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-118-PRKG2t-FO1Gs3D37IlYpNQ-1; Thu, 06 Jan 2022 08:16:52 -0500 Received: by mail-wm1-f72.google.com with SMTP id j8-20020a05600c1c0800b00346504f5743so3053981wms.6 for ; Thu, 06 Jan 2022 05:16:51 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id z6sm2224526wmp.9.2022.01.06.05.16.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:16:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475013; 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=buDM3lMzdSCCTXDPKAz/K4yUHtgSg1MqNV6hlcJzC0OwBtZGb2VxlO1NNUhKZVyvR7JAC3 f4PIZMPJgSvJ4+3nG1MukkNZbAR8zaslNx6639E3lS8mi4CK9O3OSVoINMD+5LErYXyqz9 p7preMloO4JlRBiiA9dwXnxCr8/s6wM= X-MC-Unique: PRKG2t-FO1Gs3D37IlYpNQ-1 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=UkESkIwf1DcwQXPhnRXf8BG5z2jrtBBeASpROCQKMwtdgfcUeluSTSXRKq/gGlHMz7 JDYvaFU5ci+lKNG48Yr1yrJxqbbVFyTn0ec4rbMv4n4cY/WJA8m6a6GE/8fKsXQ5kxEW 88CSpCW4t/fReeGd1HLjbtP8qdr+n/GN/PtroxC5yJbmYIVPVSoJP4pHw/1tIAwhE/cb CYSVDjrF1TQZvkpz+nTVasU4aP8QFPlKKF9Q0IbJb6mmvVUGPMVp7/oAnarfNWnGOZXN MtPFsWfgsJl46Ymssv0N4ZDSrFWPhQmATygLYxbEXdIen/iKYtO9Qdx1B45SuKpcu3QP uLfQ== X-Gm-Message-State: AOAM533nxp9qMnRLA4tyATMbMsbDeD9doItanu9tcGqXv8H4SdXn4oXm GTmlHtiPWPqy/UDiTbtSDR3JrRr2a78Lo+0VR3nMYae2k/M5jqm3S0yxpAEBiPqkeRuV0gyXO4J vuyybvk0uPvXRVOVowLpjkXmurVAh9CUq4mFL9n25uTmFuzMBeibewDhNsNdv X-Received: by 2002:a7b:cb98:: with SMTP id m24mr7239333wmi.188.1641475010597; Thu, 06 Jan 2022 05:16:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0S/umfe8ZD5yf4BQg2AzgYilHhonxyyKVYbgZMxj74ihnQ7ZRKig+8eSpeqj1iZ5SOpUang== X-Received: by 2002:a7b:cb98:: with SMTP id m24mr7239307wmi.188.1641475010286; Thu, 06 Jan 2022 05:16:50 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:47 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 12/52] virtio-pci: add support for configure interrupt Message-ID: <20220106131534.423671-13-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641475784315100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 VirtioPCIDeviceTyp= eInfo *t); * @fixed_queues. */ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); - +void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueu= e *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 *prox= y, int queue_no, VirtQueue *vq; =20 if (queue_no =3D=3D VIRTIO_CONFIG_IRQ_IDX) { - return -1; + *n =3D virtio_config_get_guest_notifier(vdev); + *vector =3D 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 *p= roxy, int nvqs) return ret; } =20 +static int kvm_virtio_pci_vector_config_use(VirtIOPCIProxy *proxy) +{ + return kvm_virtio_pci_vector_use_one(proxy, VIRTIO_CONFIG_IRQ_IDX); +} =20 static void kvm_virtio_pci_vector_release_one(VirtIOPCIProxy *proxy, int queue_no) @@ -839,6 +844,11 @@ static void kvm_virtio_pci_vector_release(VirtIOPCIPro= xy *proxy, int nvqs) } } =20 +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, un= signed vector, } vq =3D virtio_vector_next_queue(vq); } - + /* unmask config intr */ + n =3D virtio_config_get_guest_notifier(vdev); + ret =3D virtio_pci_one_vector_unmask(proxy, VIRTIO_CONFIG_IRQ_IDX, vec= tor, + msg, n); + if (ret < 0) { + goto undo_config; + } return 0; - +undo_config: + n =3D virtio_config_get_guest_notifier(vdev); + virtio_pci_one_vector_mask(proxy, VIRTIO_CONFIG_IRQ_IDX, vector, n); undo: vq =3D virtio_vector_first_queue(vdev, vector); while (vq && unmasked >=3D 0) { @@ -956,6 +974,8 @@ static void virtio_pci_vector_mask(PCIDevice *dev, unsi= gned vector) } vq =3D virtio_vector_next_queue(vq); } + n =3D virtio_config_get_guest_notifier(vdev); + virtio_pci_one_vector_mask(proxy, VIRTIO_CONFIG_IRQ_IDX, vector, n); } =20 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 =3D virtio_pci_get_notifier(proxy, VIRTIO_CONFIG_IRQ_IDX, ¬ifie= r, + &vector); + if (ret < 0) { + return; + } + if (vector < vector_start || vector >=3D 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, VirtQueu= e *vq, + int n, bool assign, + bool with_irqfd) +{ + if (n =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + virtio_config_set_guest_notifier_fd_handler(vdev, assign, with_irq= fd); + } else { + virtio_queue_set_guest_notifier_fd_handler(vq, assign, with_irqfd); + } } =20 static int virtio_pci_set_guest_notifier(DeviceState *d, int n, bool assig= n, @@ -995,17 +1043,25 @@ static int virtio_pci_set_guest_notifier(DeviceState= *d, int n, bool assign, VirtIOPCIProxy *proxy =3D to_virtio_pci_proxy(d); VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); - VirtQueue *vq =3D virtio_get_queue(vdev, n); - EventNotifier *notifier =3D virtio_queue_get_guest_notifier(vq); + VirtQueue *vq =3D NULL; + EventNotifier *notifier =3D NULL; + + if (n =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + notifier =3D virtio_config_get_guest_notifier(vdev); + } else { + vq =3D virtio_get_queue(vdev, n); + notifier =3D virtio_queue_get_guest_notifier(vq); + } =20 if (assign) { int r =3D 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_i= rqfd); } 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); } =20 @@ -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 =3D NULL; } @@ -1062,7 +1119,11 @@ static int virtio_pci_set_guest_notifiers(DeviceStat= e *d, int nvqs, bool assign) goto assign_error; } } - + r =3D 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(DeviceSta= te *d, int nvqs, bool assign) msix_nr_vectors_allocated(&proxy->pci_dev)); r =3D kvm_virtio_pci_vector_use(proxy, nvqs); if (r < 0) { - goto assign_error; + goto config_assign_error; } } - r =3D msix_set_vector_notifiers(&proxy->pci_dev, - virtio_pci_vector_unmask, + r =3D kvm_virtio_pci_vector_config_use(proxy); + if (r < 0) { + goto config_error; + } + r =3D 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); --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476126545281.175011377135; Thu, 6 Jan 2022 05:35:26 -0800 (PST) Received: from localhost ([::1]:44082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5SvN-0006sn-K1 for importer@patchew.org; Thu, 06 Jan 2022 08:35:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdW-0004EF-IX for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56515) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SdU-0000ps-LD for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:16:58 -0500 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-543-DipdJaVmMPiD5ulDUqKZbA-1; Thu, 06 Jan 2022 08:16:55 -0500 Received: by mail-wr1-f72.google.com with SMTP id q16-20020adfbb90000000b001a4838099baso1248477wrg.10 for ; Thu, 06 Jan 2022 05:16:54 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id k19sm4987186wmo.29.2022.01.06.05.16.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:16:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475016; 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=hGthJhgcoPfIr3AnwFMjonyHKoDBVB7ahsnzlk4qj/ieVybCTR9j9pB3lMmvHNG3u0rvGI EHKjSef49gnOqGmvEFlFzGsSGjSUvSyfTcDTBRWPWRJePH7nR52OW/XsRWTzMTHmJzcxZF J1yov0xAYLihn5pJyZi0lbwmm4Ziipo= X-MC-Unique: DipdJaVmMPiD5ulDUqKZbA-1 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=E+95/S4skXzWUQ1zKj5nBNXpRvyLrJDPTT5fvjxiKsWsfWH7ejHVRuHDqLRKOtNDry QG3i0vQLzO2pA2aXgbA6sl3IAmiScMG0x/2lvA81GoewuNXayHOorrwFK0V/WJwjdwIV wFUjkTuHApxWeuDxcKw3jJywSfHqMOXcvMGj2UkMRC6Y9AzBbb+LfzvxNVenR67yvkPi zVLBud3+4rlL0wpGfemfYthN16fxnRKOj3Qaq94crviknzTV2wdtGl6/DGNHwEC4QBOw lAKPRXAxJUZv7H834/oofS1R+W029sF9iWpMmDqOuXNQOYNygwX4/H9UiM8YYs67z4QH 4Ibw== X-Gm-Message-State: AOAM532m0e6mHKf6gr0oMI6OOdSNOJa76mOrHgWx1f5tpmHJxUPZ5z7n 6EkwvBAL/EApAcT9bUu7ws/bR8ky2d8OFR4qYY+G45uI4fShq8EfKZtQt1O77VReiDCHOMOsYUH tpTcvkUyeg+BlcBkijhl5CjjekiEuWDW8kuwE04L9oriJLH5oWhJoF2ekMEht X-Received: by 2002:a5d:59af:: with SMTP id p15mr50374370wrr.237.1641475013491; Thu, 06 Jan 2022 05:16:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJySSRQIIV0h7BY3dQ59v4vBKXhs7IAfJv0EFew+XT8fUcBMP0lgJ0OMJdelpXnx7vrLQ9hlvg== X-Received: by 2002:a5d:59af:: with SMTP id p15mr50374348wrr.237.1641475013217; Thu, 06 Jan 2022 05:16:53 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:50 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 13/52] trace-events,pci: unify trace events format Message-ID: <20220106131534.423671-14-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476127746100001 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=3D0x555810b92330 01:00.0 4,0xffffc000+0x4000 pci_update_mappings_add d=3D0x555810b92330 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=C3=A9 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) =20 /* now do the real mapping */ if (r->addr !=3D 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 =3D new_addr; if (r->addr !=3D 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, uin= t32_t addr, return; } =20 - 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, } =20 ret =3D 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); =20 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. =20 # pci.c -pci_update_mappings_del(void *d, uint32_t bus, uint32_t slot, uint32_t fun= c, int bar, uint64_t addr, uint64_t size) "d=3D%p %02x:%02x.%x %d,0x%"PRIx6= 4"+0x%"PRIx64 -pci_update_mappings_add(void *d, uint32_t bus, uint32_t slot, uint32_t fun= c, int bar, uint64_t addr, uint64_t size) "d=3D%p %02x:%02x.%x %d,0x%"PRIx6= 4"+0x%"PRIx64 +pci_update_mappings_del(const char *dev, uint32_t bus, uint32_t slot, uint= 32_t func, int bar, uint64_t addr, uint64_t size) "%s %02x:%02x.%x %d,0x%"P= RIx64"+0x%"PRIx64 +pci_update_mappings_add(const char *dev, uint32_t bus, uint32_t slot, uint= 32_t func, int bar, uint64_t addr, uint64_t size) "%s %02x:%02x.%x %d,0x%"P= RIx64"+0x%"PRIx64 =20 # 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 off= s, 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" =20 # msix.c msix_write_config(char *name, bool enabled, bool masked) "dev %s enabled %= d masked %d" --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476384963451.1755866049766; Thu, 6 Jan 2022 05:39:44 -0800 (PST) Received: from localhost ([::1]:59076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5SzX-0000Pv-Vy for importer@patchew.org; Thu, 06 Jan 2022 08:39:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdi-0004W9-Jv for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29980) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdb-0000qU-FR for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:10 -0500 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-266-DECdt5NHNk2GUeyhDc7qKg-1; Thu, 06 Jan 2022 08:16:57 -0500 Received: by mail-wr1-f70.google.com with SMTP id v14-20020adfa1ce000000b001a49d6587ceso1181506wrv.21 for ; Thu, 06 Jan 2022 05:16:57 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id o3sm1731769wmr.15.2022.01.06.05.16.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:16:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475020; 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=Jl1fS7TXVJ3CLATWqfYkcjSj7vM7a7AYUX39N27SQ+IoOCufYLaiC2MRj6Z8StqRXy/OCi Z6poCIdWnqynJMDpMN0jaWJIAOObNwZ2XCUu0bupk9tLLNqiMWjoV/dguSeio5r8cg4Ylm AJ80OIxFXs4l3tobud/QUFy4XaXdlCE= X-MC-Unique: DECdt5NHNk2GUeyhDc7qKg-1 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=U+HkDLsYoEg2LNMzECuGUMIij18ZXfXydKi83xUXPNJS4q9Ed+oZU6oCsp8227qavM cnsDu21eXCk8DrntYZqV6tua83Ni6A5DYIkXFjDI8os0pJL92P+7syl6EBwDUzwwh9V8 SWpzGjQFn+Ska4b4X8R2+khZOxY6vzHas+N2/xbB3biMIKbnOw7O42VjOKafDMKpziG0 jrSOcfaYNcvVWG+DEB+eUEXVjWCaViBpyNHBJ0uNctGdVOd3psmhzfzyVpQfy2KpJ996 dSWBd1Q3hToLJmQXEBK5OJnHYRMXxLgXREY84SHhu20YXoRyrpiFnaIVfLXuBk6NC8ht ZORw== X-Gm-Message-State: AOAM5328BimlqC5uLUF8lu7U0qe5pgjqLx4UkHHssLlhG6RD1ONHjt3t 2lRlQuxrl2qfQuI5DNQhEa15lI9W9MhgHpBmfPEgau9AxRLwXCgxWSAtCTcbPHPQxHBgOhngLz6 ek8ipPl1RogMj3AZXAzCE3ktt/GvJOCMxY5K6qBsUuVypYkdwpQ8EP/Pn0x7S X-Received: by 2002:a7b:cb98:: with SMTP id m24mr7239661wmi.188.1641475016090; Thu, 06 Jan 2022 05:16:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwmVSChZUbyq6RP9z9zDyrXAHrHYkUZS1v+eNy0ZI6vpzvEfw/2A8OgikUNmJ8IRH22dH2Ihg== X-Received: by 2002:a7b:cb98:: with SMTP id m24mr7239645wmi.188.1641475015916; Thu, 06 Jan 2022 05:16:55 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:53 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 14/52] vhost-user-blk: reconnect on any error during realize Message-ID: <20220106131534.423671-15-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476386338100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D NULL; } ret =3D vhost_user_blk_realize_connect(s, errp); - } while (ret =3D=3D -EPROTO && retries--); + } while (ret < 0 && retries--); =20 if (ret < 0) { goto virtio_err; --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16414762639085.218927408368472; Thu, 6 Jan 2022 05:37:43 -0800 (PST) Received: from localhost ([::1]:50446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5Sxa-0002uQ-TT for importer@patchew.org; Thu, 06 Jan 2022 08:37:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdk-0004Xa-Ax for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:49886) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdg-0000qa-PE for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:11 -0500 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-167-fzWUrAfHOh-VXgil2kJtlg-1; Thu, 06 Jan 2022 08:17:00 -0500 Received: by mail-wm1-f72.google.com with SMTP id l20-20020a05600c1d1400b003458e02cea0so3056212wms.7 for ; Thu, 06 Jan 2022 05:17:00 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id d11sm2168984wri.101.2022.01.06.05.16.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:16:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475021; 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=D6+Zr1mQSSYGIngRE5C7Y3sV8/ri3HF0zoqoF87a6faqhCpVfBjUILNHVv7UR0PiSIjTHy 1uENpnnmlXTxpzS2U6M/febppAyHD0ZYEwT1912A3JQGsbzPbLYHfROGDvL29rMSla6g3L 6nmoLdoNPgA8OiJDyPIcK+3GXCQVHoU= X-MC-Unique: fzWUrAfHOh-VXgil2kJtlg-1 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=WDHjrDT+Q99e6t7WxfFJedzJpLbrptJK6viRWBBwfrVbHStmawqIfqWFt+/wO+iXpW PhSRe06kL/1bn8WSYx5O3jhknY/42FE9UU2pTAXqXfhDnM6rL06yEHc8Q+2CJHwgshTn Nlm6mOlVDAl7VW2a0Elrps3nlQbGDfRVw69nELuAjAaBxc8RNvBfDhpsv2JQBWpuY/qB 7+u/MCZHenKB1OII0Qfgx9nECobKCfQmoTRltgeJCnd2XmuyeZgP4pJKekEyDcMYX278 e3E5d7aG7pdFXoFw4sHaSbYXAakirkYbFmRw+C305lgHgUKvjjTpoxFB1aRMhU2YuYMb uosQ== X-Gm-Message-State: AOAM532JdMMZZNiz+v1xw0mg68tqe7BuNecU2NNqbgDm6Hk1UQtajzVK mXqNwgUw/GibbisunajWRHwmGjXG4/2X5vcKHTyqnwFelMMZx2QdpN4yQB9QyRwS4ueX+0KM23B P+gpwTnvcYDQNLjzZR0iRADqpfez2CFaciHggBK7sCxFfb/cMHU0pca3AkadA X-Received: by 2002:a5d:488c:: with SMTP id g12mr41141629wrq.96.1641475018801; Thu, 06 Jan 2022 05:16:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXV06/Zb9BwUp8UQvA1VkRUKWTLgCkY4sMB4lehLSrKBUvvuwicCc8guXwO2pCBw8PZ2Wkbg== X-Received: by 2002:a5d:488c:: with SMTP id g12mr41141614wrq.96.1641475018601; Thu, 06 Jan 2022 05:16:58 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:56 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 15/52] chardev/char-socket: tcp_chr_recv: don't clobber errno Message-ID: <20220106131534.423671-16-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476265258100003 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=C3=A9 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, s= ize_t len) NULL); } =20 - if (ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { - errno =3D EAGAIN; - ret =3D -1; - } else if (ret =3D=3D -1) { - errno =3D EIO; - } - if (msgfds_num) { /* close and clean read_msgfds */ for (i =3D 0; i < s->read_msgfds_num; i++) { @@ -325,6 +318,13 @@ static ssize_t tcp_chr_recv(Chardev *chr, char *buf, s= ize_t len) #endif } =20 + if (ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { + errno =3D EAGAIN; + ret =3D -1; + } else if (ret =3D=3D -1) { + errno =3D EIO; + } + return ret; } =20 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164147679311019.14471678118855; Thu, 6 Jan 2022 05:46:33 -0800 (PST) Received: from localhost ([::1]:39510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5T68-0006zO-0f for importer@patchew.org; Thu, 06 Jan 2022 08:46:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdk-0004Xc-BI for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39208) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdg-0000qm-P8 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:11 -0500 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-2-WFlGkHywMzGBkNN1lvBMtQ-1; Thu, 06 Jan 2022 08:17:02 -0500 Received: by mail-wm1-f70.google.com with SMTP id m9-20020a05600c4f4900b0034644da3525so180429wmq.3 for ; Thu, 06 Jan 2022 05:17:02 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id u11sm6033219wmq.41.2022.01.06.05.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475023; 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=gKBUJ+kz5md0KXfsw1vuagsDe5ey2724ADDA4vVJDLN2BnFT6X3jaae2NOhuZCxzcN11PI ft/dEKeejbTFY+rEcf0F4qMyFvjbMjZQwgO1y3WmKfXZZbq9On187zYR4qbFJ7shKQYEb+ eX3XCbwns5TN1Aq7ouuJVbppRpJz9GE= X-MC-Unique: WFlGkHywMzGBkNN1lvBMtQ-1 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=GZYd1XoKgtifrmgXzUhR4OXvc2pJO02S/m1vrlxbQrrcoTi4JlpkY5lunTYt+74rE1 QTYCpKQOq3g9blB1Hlm7CjjhRlt6YGW7dqe8Wwij2oiThJw57mPZqA00HiLgbpH1GzjZ iatxVYDQG4EifhNnZCW1X8Dy1n7HtyldsO9m8E5k7IY+dhlIr8E/XMf8qD/yZ2b1WYmm NNWADGXrlNEJV3Hg+abyYFeGyJtpt4EHNt4ot2u0jhEO7inlDpXgPGQMkYzmv/TJ7Y97 DjwxuE0B+o5LXP3XUKDbTPupR67/Jm4+llcMa3JwwE32zQFGN9NGzVJtUcpHun9z23Fk HHsQ== X-Gm-Message-State: AOAM531/k56x4eff5e9LD7k0o7SdH5aS5OqE8dIK1su23wvEkMSSUmwK qb8SWlZTuJeiOfIFhd4IchpNRleR6xxuoAfpEhymfXhzrI0sR+nWJeDNlHAOQ9RF8p63gbt/0nb spPD7YG2iL81MTgmy3mwOHfsMdDbkNQfDlnNE2c5V/eR+VIYVyppvREOHtgw1 X-Received: by 2002:a5d:47c6:: with SMTP id o6mr52339351wrc.326.1641475021183; Thu, 06 Jan 2022 05:17:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkToWx5J8CBcEwUEHBnV45iFfVTvitO7zfZCBcocMJChc+DEMTsv2cMEBIX0nQsIRrHRsSiA== X-Received: by 2002:a5d:47c6:: with SMTP id o6mr52339333wrc.326.1641475020892; Thu, 06 Jan 2022 05:17:00 -0800 (PST) Date: Thu, 6 Jan 2022 08:16:58 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 16/52] chardev/char-socket: tcp_chr_sync_read: don't clobber errno Message-ID: <20220106131534.423671-17-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476794316100001 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=C3=A9 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 =3D SOCKET_CHARDEV(chr); int size; + int saved_errno; =20 if (s->state !=3D TCP_CHARDEV_STATE_CONNECTED) { return 0; @@ -532,6 +533,7 @@ static int tcp_chr_sync_read(Chardev *chr, const uint8_= t *buf, int len) =20 qio_channel_set_blocking(s->ioc, true, NULL); size =3D tcp_chr_recv(chr, (void *) buf, len); + saved_errno =3D errno; if (s->state !=3D 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); } =20 + errno =3D saved_errno; return size; } =20 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476379619492.3494932217452; Thu, 6 Jan 2022 05:39:39 -0800 (PST) Received: from localhost ([::1]:58684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5SzS-00007d-Cp for importer@patchew.org; Thu, 06 Jan 2022 08:39:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdl-0004YE-9Q for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:25329) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdg-0000rB-Tt for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:12 -0500 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-527-FVQYQktrNkiK4YFhfJucNw-1; Thu, 06 Jan 2022 08:17:05 -0500 Received: by mail-wm1-f71.google.com with SMTP id k40-20020a05600c1ca800b00345bf554707so1928760wms.4 for ; Thu, 06 Jan 2022 05:17:05 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id u10sm2091129wrs.28.2022.01.06.05.17.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475026; 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=fRLEluCcRU1DyGAgQKqkCo0JzsmNz5eRHZp54zgfXrN5Tiu92ZyoKIRqUKNibX8jYkMJ4o I3ewcxuc7w5y6sLi4sHfzIZceSYs1E0PDctJxM3HdTIDXtqPnLiPKoNxgEFw0zZD6Qttpw 4wUsEFs5oTjNQIJRvBlBuLf99YUGRPQ= X-MC-Unique: FVQYQktrNkiK4YFhfJucNw-1 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=fcIHnrPBa7LyJQRqrv7SEI+F+gs1elBFf7GMj4x2enemkYZm37X8bGQw2DLLzQd8uO euVBjqvMhXFZZoEqaUHUrt43Wu5iN9Nq3rmorQwTUHgBQvJpoWO6fJuyH7SqGZSwDEgG Y1T8z0A1AxP5J8nPMz7mudescEeTxhcaNJ1I5gRP2Qvh2ABY2ebhM9l75+dXNq42O3X1 k9Nbdo0hmN9DjWukHU+EESE+Tuk+mxsw6AoOF3/nS8VLBJ+jM5oMDydLLM3T3JSsTdvg dc4WpJItlLdVLvUm0Ud94MCbXli3vcU+3/iIwvz6LTOLum0XuipiG5iyQbTyLTogOgEU dwgg== X-Gm-Message-State: AOAM532gKyR+fl9WKychB+KB61u4aLoCHV6sCY46gl8A/4Av//zVugFk BF8VvBvG7ilnaC+7LaUUQkEbHJx4ply3pXZpiwpeENytj9mR7xXAl0pxneJRE3DUg62cme5sCPV pIQiF8IXNHcViwp8y0GvOOkCyuVdAxll3l5DsAqx+n7Vv8ddsQmDbaGUN7w03 X-Received: by 2002:adf:f3c5:: with SMTP id g5mr51160043wrp.683.1641475023858; Thu, 06 Jan 2022 05:17:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/gS0WvX1zOKitKkIshtjJW3f0dVft4SUWXtCBihHvdx23ja6hLN2jGB6JH2o7yQQch/GCKQ== X-Received: by 2002:adf:f3c5:: with SMTP id g5mr51160027wrp.683.1641475023611; Thu, 06 Jan 2022 05:17:03 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 17/52] vhost-backend: avoid overflow on memslots_limit Message-ID: <20220106131534.423671-18-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476380209100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D g_ascii_strtoull(s, NULL, 10); - if (!((val =3D=3D G_MAXUINT64 || !val) && errno)) { + if (val < INT_MAX && val > 0) { g_free(s); return val; } --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477289495688.6236439496862; Thu, 6 Jan 2022 05:54:49 -0800 (PST) Received: from localhost ([::1]:37052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TE8-00009X-IL for importer@patchew.org; Thu, 06 Jan 2022 08:54:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Se2-0004vy-P6 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29853) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdh-0000rd-KT for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:29 -0500 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-269-wdjkzg_VM76nl0RY5NmQNA-1; Thu, 06 Jan 2022 08:17:08 -0500 Received: by mail-wr1-f71.google.com with SMTP id g6-20020adfbc86000000b001a2d62be244so1227042wrh.23 for ; Thu, 06 Jan 2022 05:17:08 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id u14sm1986163wrf.39.2022.01.06.05.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475029; 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=Tfxk/mXxUBh16TwzE8kxugm+G7uwj2kBB15uwmlr4IQXST2l3iQkIafUIcGHpZ1Rt5Mi9a C64ut6g3N7tzfg66lB7YHYEOXQSwfoNkLGTKais6snetceTTz9yjTeaTIpjPBwl9sEr8IA Sh6GPtm9qq1FqeCXiXQfWcntuTHI66k= X-MC-Unique: wdjkzg_VM76nl0RY5NmQNA-1 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=0LMduXC6/4L5edZw0JH9cgfZEtsm+oNk/FHy6P9cDJ0rJAmIZiUKF34VOMccRG61pY 9/erhuzUknzQ5GgzUnQoY2bJa65ioB1qE+5+vCUqUyH047VLQsvPuQI1Olxe0CG4XyMr ThQOt+zCbD20ZYZkJVaRZFRU/dqMNIltlwCalYGBHimf2lUURPqU+naI69UGudiKvodv RBazhqkqjvGk3gN0hGtfq0jHC/t3zDAx72J6ubzwCPlnZWvFcdIopUnAVdpSYdy9XVh1 GK75Usx6zPCCOFApsPUHs66qXke3sZAeiU3ykgFmfTBzQXyYruMOi+E69UtXA6HUGZtZ 7kDw== X-Gm-Message-State: AOAM53112OV1vg6NLz4DzyNppiPrCtXYz5C5f49WIeHfxFLEOXDO6Jkr 3Xf+CUxhS6ZSJMRdkHnw1iK1fktt3bFmjKSnuWX0J/3xbZvlH1iYwYtc4LpVUaC7qRxZnx5dtno 1/Denkq4ZD3x/7M1fscxzLF7QSrrkAfKthX3rve13m8IUSe6aecISNW1OhrFz X-Received: by 2002:a1c:4406:: with SMTP id r6mr7017718wma.42.1641475026423; Thu, 06 Jan 2022 05:17:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpzehG4ul4BtHDDieNzsU1oK2TMPnh/u+vr+VP2rb5Iqnz50SVC9luQn/NRR22MQGXeJdFvA== X-Received: by 2002:a1c:4406:: with SMTP id r6mr7017700wma.42.1641475026180; Thu, 06 Jan 2022 05:17:06 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:03 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 18/52] vhost-backend: stick to -errno error return convention Message-ID: <20220106131534.423671-19-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, T_SPF_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 , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477290841100001 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=C3=A9 --- 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) =20 assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_KERNEL); =20 - return close(fd); + return close(fd) < 0 ? -errno : 0; } =20 static int vhost_kernel_memslots_limit(struct vhost_dev *dev) --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476254768746.0582212170347; Thu, 6 Jan 2022 05:37:34 -0800 (PST) Received: from localhost ([::1]:49532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5SxQ-0002Dx-Mk for importer@patchew.org; Thu, 06 Jan 2022 08:37:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdl-0004b7-WB for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:49558) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdk-0000rw-D5 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:13 -0500 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-645-m1Dqi8ajNE-rPAgfGx402Q-1; Thu, 06 Jan 2022 08:17:10 -0500 Received: by mail-wr1-f69.google.com with SMTP id s23-20020adf9797000000b001a485bd8e8dso1257895wrb.11 for ; Thu, 06 Jan 2022 05:17:10 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id o3sm2313088wry.98.2022.01.06.05.17.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475031; 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=d0YqPWjgKCakcHnIw/DNm8nknBGIfngAVKkI947EJSWFDSevvfKLPpzlDF1B5928gwn65Z A9+DyK6zE6SWO5zETwh/8tKzwcNAwvcabmRMswqcEWL89A8um3teIZ7kWQPEKYAgTmGCo4 0lqkZXVVSWAqp+erQ2TpM3nH72kI4w0= X-MC-Unique: m1Dqi8ajNE-rPAgfGx402Q-1 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=XbYJcY/ppoUWDwMCXGMLka3ceGONp14iPMWT713miA+ukrqiS111jH5+cL18aCANC4 U7RNm5D12GoFRviV5Nd7UwDwQwFrmbVFdPaEm/Q4UXqOHIHDYp9Ac5NqJDVZtYN3vSTL UB8x851YHkoWlY58hkInv5hQ+zSJ6PI35YMuputsrhqvr7+0hP02wr7+Hyzi+cX1sDP3 JV+k2Gx4vQMtQ2/5NNQSOkXakdVnh3DrVCmUugKya4CADrCGxS53taH0Ib4UxypJVU6G qyqx7FFQ7D1uvbJWD50H/bzsUd9pduOVZZnqa3SPtWKSboxeQP3NLeR9XCRnY6nQvhpd Ut4g== X-Gm-Message-State: AOAM532wwtKh3C7IxQrjpI0O9rRDKW67OFQ6BIcsVstymhLPAIwS1/SO dC2I9ygQ7PvQ9Ev1zafTEfBJtENQGJSnXpHCN5Tt16XfqPE/TYIrtTeKf+GHUKDzHQQCwsoTHPM rmZWsS0uH8fWkoK59TFqUlA1VdeppRqwCS6Pb5k+Jcd5Yd0q8URpQP68xJYN3 X-Received: by 2002:a5d:424c:: with SMTP id s12mr49873302wrr.465.1641475029097; Thu, 06 Jan 2022 05:17:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzLSKisoH9ftLfHv6OHkqU1c5SeZXPOoNvZND2aAIzf7T4uxnJmPFF0RYn/bmHa/ng6ROyBoA== X-Received: by 2002:a5d:424c:: with SMTP id s12mr49873290wrr.465.1641475028891; Thu, 06 Jan 2022 05:17:08 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:06 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 19/52] vhost-vdpa: stick to -errno error return convention Message-ID: <20220106131534.423671-20-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476257358100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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, uns= igned long int request, return ret < 0 ? -errno : ret; } =20 -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; =20 trace_vhost_vdpa_add_status(dev, status); - if (vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &s)) { - return; + ret =3D vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &s); + if (ret < 0) { + return ret; } =20 s |=3D status; =20 - vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &s); + ret =3D vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &s); + if (ret < 0) { + return ret; + } + + ret =3D vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &s); + if (ret < 0) { + return ret; + } + + if (!(s & status)) { + return -EIO; + } + + return 0; } =20 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 *d= ev, } } if (mem->padding) { - return -1; + return -EINVAL; } =20 return 0; @@ -501,14 +517,11 @@ static int vhost_vdpa_set_features(struct vhost_dev *= dev, =20 trace_vhost_vdpa_set_features(dev, features); ret =3D vhost_vdpa_call(dev, VHOST_SET_FEATURES, &features); - uint8_t status =3D 0; if (ret) { return ret; } - vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK); - vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &status); =20 - return !(status & VIRTIO_CONFIG_S_FEATURES_OK); + return vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK); } =20 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) } =20 if (started) { - uint8_t status =3D 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 | --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476940096148.64551271990774; Thu, 6 Jan 2022 05:49:00 -0800 (PST) Received: from localhost ([::1]:48174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5T8V-0004wa-0P for importer@patchew.org; Thu, 06 Jan 2022 08:48:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdr-0004j3-RV for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39445) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdo-0000sO-0O for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:19 -0500 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-588-3itXAY7WNkm2_0Xcdfuxlg-1; Thu, 06 Jan 2022 08:17:14 -0500 Received: by mail-wr1-f70.google.com with SMTP id n4-20020adf8b04000000b001a49cff5283so1216459wra.14 for ; Thu, 06 Jan 2022 05:17:14 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id j39sm1861343wms.0.2022.01.06.05.17.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475035; 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=idkKtWU8ntHkl8fuCjRTsJqNPycWpxin/I4M5iAtuBsudB/PeqsBPzcWEEvF+L6jW0CVP0 sYJXMNUxZtOSZ21SltHqmNDvuAHWe1yxc8bYy06dO7fGf1syyyFu7b2sfMtvtqWLq4a7qF nR7xgikairreBAj+ff4Z5DH1O2DYGt4= X-MC-Unique: 3itXAY7WNkm2_0Xcdfuxlg-1 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=Iu9wc5ymPCEvYdlYVslW9SlFSSi5lk0HUvzCI1DYX2Fr43+ttm+QEpFpY2V/GUWLcx kMj9Dm+BtAtFpVezZdQQyUEn2X5uCaLw/lAnD0jVqFaNK3SBrHMjeqnmpuxSKrX+W3e6 6d1lWONxWsNrghwwRUdoS+9EjkUFapbgMdPoyGaNl19XhE489sQzpgu6HvTwgWnSlIQF 9IpnUVPz5KOcbvutzuutMf1gHZ2Kldw2bMIYEOznnX4GDIagksHdiA0IlDNFaOgmF5P9 A89oGK5Eq4MdR8kHiozdEWDxxL2cKUCclBnQLwUD7xzqqP60J3UCIcn9L9uD9Ikmu5KF myHw== X-Gm-Message-State: AOAM531YOD0baZpOcgPb+pXGn+yj1MJUycAEpqlPtZnAMlCSbIbQjJ0q Yp6nvXURxLMPgQhGpYeujzw1h6rNId2BIRs1Gyi8KorGLf0PLOo+wbng2+RLIc/twN7/+t9Y8Lw a4PhGc/8KbW3xnxynIHc/tQXzwWjngWBjDDYmH6xVYl7mAybF4RFxNwKWtAyU X-Received: by 2002:a05:6000:1a45:: with SMTP id t5mr50164894wry.306.1641475032212; Thu, 06 Jan 2022 05:17:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnasl6jEkpd3ZTGFaTx3tv5oYkXe8qBkjYLtNWQIbIkfwGx8oBCfI4S0RvVshq0iZPcV1M+Q== X-Received: by 2002:a05:6000:1a45:: with SMTP id t5mr50164853wry.306.1641475031516; Thu, 06 Jan 2022 05:17:11 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:09 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 20/52] vhost-user: stick to -errno error return convention Message-ID: <20220106131534.423671-21-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476942049100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 *de= v, VhostUserMsg *msg) =20 r =3D qemu_chr_fe_read_all(chr, p, size); if (r !=3D size) { + int saved_errno =3D 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; } =20 /* 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; } =20 return 0; @@ -314,8 +315,9 @@ static gboolean vhost_user_read_cb(void *do_not_use, GI= OCondition condition, uint8_t *p =3D (uint8_t *) msg; int r, size; =20 - if (vhost_user_read_header(dev, msg) < 0) { - data->ret =3D -1; + r =3D vhost_user_read_header(dev, msg); + if (r < 0) { + data->ret =3D r; goto end; } =20 @@ -324,7 +326,7 @@ static gboolean vhost_user_read_cb(void *do_not_use, GI= OCondition condition, error_report("Failed to read msg header." " Size %d exceeds the maximum %zu.", msg->hdr.size, VHOST_USER_PAYLOAD_SIZE); - data->ret =3D -1; + data->ret =3D -EPROTO; goto end; } =20 @@ -333,9 +335,10 @@ static gboolean vhost_user_read_cb(void *do_not_use, G= IOCondition condition, size =3D msg->hdr.size; r =3D qemu_chr_fe_read_all(chr, p, size); if (r !=3D size) { + int saved_errno =3D errno; error_report("Failed to read msg payload." " Read %d instead of %d.", r, msg->hdr.size); - data->ret =3D -1; + data->ret =3D r < 0 ? -saved_errno : -EIO; goto end; } } @@ -418,24 +421,26 @@ static int vhost_user_read(struct vhost_dev *dev, Vho= stUserMsg *msg) static int process_message_reply(struct vhost_dev *dev, const VhostUserMsg *msg) { + int ret; VhostUserMsg msg_reply; =20 if ((msg->hdr.flags & VHOST_USER_NEED_REPLY_MASK) =3D=3D 0) { return 0; } =20 - if (vhost_user_read(dev, &msg_reply) < 0) { - return -1; + ret =3D vhost_user_read(dev, &msg_reply); + if (ret < 0) { + return ret; } =20 if (msg_reply.hdr.request !=3D msg->hdr.request) { error_report("Received unexpected msg type. " "Expected %d received %d", msg->hdr.request, msg_reply.hdr.request); - return -1; + return -EPROTO; } =20 - return msg_reply.payload.u64 ? -1 : 0; + return msg_reply.payload.u64 ? -EIO : 0; } =20 static bool vhost_user_one_time_request(VhostUserRequest request) @@ -472,14 +477,15 @@ static int vhost_user_write(struct vhost_dev *dev, Vh= ostUserMsg *msg, =20 if (qemu_chr_fe_set_msgfds(chr, fds, fd_num) < 0) { error_report("Failed to set msg fds."); - return -1; + return -EINVAL; } =20 ret =3D qemu_chr_fe_write_all(chr, (const uint8_t *) msg, size); if (ret !=3D size) { + int saved_errno =3D errno; error_report("Failed to write msg." " Wrote %d instead of %d.", ret, size); - return -1; + return ret < 0 ? -saved_errno : -EIO; } =20 return 0; @@ -502,6 +508,7 @@ static int vhost_user_set_log_base(struct vhost_dev *de= v, uint64_t base, size_t fd_num =3D 0; bool shmfd =3D virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_LOG_SHMFD); + int ret; VhostUserMsg msg =3D { .hdr.request =3D VHOST_USER_SET_LOG_BASE, .hdr.flags =3D VHOST_USER_VERSION, @@ -514,21 +521,23 @@ static int vhost_user_set_log_base(struct vhost_dev *= dev, uint64_t base, fds[fd_num++] =3D log->fd; } =20 - if (vhost_user_write(dev, &msg, fds, fd_num) < 0) { - return -1; + ret =3D vhost_user_write(dev, &msg, fds, fd_num); + if (ret < 0) { + return ret; } =20 if (shmfd) { msg.hdr.size =3D 0; - if (vhost_user_read(dev, &msg) < 0) { - return -1; + ret =3D vhost_user_read(dev, &msg); + if (ret < 0) { + return ret; } =20 if (msg.hdr.request !=3D 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; } } =20 @@ -588,7 +597,7 @@ static int vhost_user_fill_set_mem_table_msg(struct vho= st_user *u, u->region_rb[i] =3D mr->ram_block; } else if (*fd_num =3D=3D 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] =3D region_buffer; @@ -604,14 +613,14 @@ static int vhost_user_fill_set_mem_table_msg(struct v= host_user *u, if (!*fd_num) { error_report("Failed initializing vhost-user memory map, " "consider using -object memory-backend-file share=3Do= n"); - return -1; + return -EINVAL; } =20 msg->hdr.size =3D sizeof(msg->payload.memory.nregions); msg->hdr.size +=3D sizeof(msg->payload.memory.padding); msg->hdr.size +=3D *fd_num * sizeof(VhostUserMemoryRegion); =20 - return 1; + return 0; } =20 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 =3D region_buffer; =20 - if (vhost_user_write(dev, msg, &fd, 1) < 0) { - return -1; + ret =3D vhost_user_write(dev, msg, &fd, 1); + if (ret < 0) { + return ret; } =20 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 =3D region_buffer; =20 - if (vhost_user_write(dev, msg, &fd, 1) < 0) { - return -1; + ret =3D vhost_user_write(dev, msg, &fd, 1); + if (ret < 0) { + return ret; } =20 if (track_ramblocks) { uint64_t reply_gpa; =20 - if (vhost_user_read(dev, &msg_reply) < 0) { - return -1; + ret =3D vhost_user_read(dev, &msg_reply); + if (ret < 0) { + return ret; } =20 reply_gpa =3D 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; } =20 /* @@ -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; } =20 /* 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_add= r); - return -1; + return -EPROTO; } } else if (reply_supported) { ret =3D process_message_reply(dev, msg); @@ -887,6 +899,7 @@ static int vhost_user_add_remove_regions(struct vhost_d= ev *dev, struct scrub_regions rem_reg[VHOST_USER_MAX_RAM_SLOTS]; uint64_t shadow_pcb[VHOST_USER_MAX_RAM_SLOTS] =3D {}; int nr_add_reg, nr_rem_reg; + int ret; =20 msg->hdr.size =3D sizeof(msg->payload.mem_reg); =20 @@ -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); =20 - if (nr_rem_reg && send_remove_regions(dev, rem_reg, nr_rem_reg, msg, - reply_supported) < 0) - { - goto err; + if (nr_rem_reg) { + ret =3D send_remove_regions(dev, rem_reg, nr_rem_reg, msg, + reply_supported); + if (ret < 0) { + goto err; + } } =20 - 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 =3D send_add_regions(dev, add_reg, nr_add_reg, msg, shadow_pcb, + reply_supported, track_ramblocks); + if (ret < 0) { + goto err; + } } =20 if (track_ramblocks) { @@ -918,8 +935,9 @@ static int vhost_user_add_remove_regions(struct vhost_d= ev *dev, msg->hdr.size =3D sizeof(msg->payload.u64); msg->payload.u64 =3D 0; /* OK */ =20 - if (vhost_user_write(dev, msg, NULL, 0) < 0) { - return -1; + ret =3D vhost_user_write(dev, msg, NULL, 0); + if (ret < 0) { + return ret; } } =20 @@ -931,7 +949,7 @@ err: sizeof(uint64_t) * VHOST_USER_MAX_RAM_SLOTS); } =20 - return -1; + return ret; } =20 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 vho= st_dev *dev, size_t fd_num =3D 0; VhostUserMsg msg_reply; int region_i, msg_i; + int ret; =20 VhostUserMsg msg =3D { .hdr.flags =3D VHOST_USER_VERSION, @@ -961,29 +980,32 @@ static int vhost_user_set_mem_table_postcopy(struct v= host_dev *dev, } =20 if (config_mem_slots) { - if (vhost_user_add_remove_regions(dev, &msg, reply_supported, - true) < 0) { - return -1; + ret =3D 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 =3D vhost_user_fill_set_mem_table_msg(u, dev, &msg, fds, &fd_n= um, + true); + if (ret < 0) { + return ret; } =20 - if (vhost_user_write(dev, &msg, fds, fd_num) < 0) { - return -1; + ret =3D vhost_user_write(dev, &msg, fds, fd_num); + if (ret < 0) { + return ret; } =20 - if (vhost_user_read(dev, &msg_reply) < 0) { - return -1; + ret =3D vhost_user_read(dev, &msg_reply); + if (ret < 0) { + return ret; } =20 if (msg_reply.hdr.request !=3D 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; } =20 /* @@ -994,7 +1016,7 @@ static int vhost_user_set_mem_table_postcopy(struct vh= ost_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; } =20 memset(u->postcopy_client_bases, 0, @@ -1024,7 +1046,7 @@ static int vhost_user_set_mem_table_postcopy(struct v= host_dev *dev, error_report("%s: postcopy reply not fully consumed " "%d vs %zd", __func__, msg_i, fd_num); - return -1; + return -EIO; } =20 /* @@ -1035,8 +1057,9 @@ static int vhost_user_set_mem_table_postcopy(struct v= host_dev *dev, /* TODO: Use this for failure cases as well with a bad value. */ msg.hdr.size =3D sizeof(msg.payload.u64); msg.payload.u64 =3D 0; /* OK */ - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } } =20 @@ -1055,6 +1078,7 @@ static int vhost_user_set_mem_table(struct vhost_dev = *dev, bool config_mem_slots =3D virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS); + int ret; =20 if (do_postcopy) { /* @@ -1074,17 +1098,20 @@ static int vhost_user_set_mem_table(struct vhost_de= v *dev, } =20 if (config_mem_slots) { - if (vhost_user_add_remove_regions(dev, &msg, reply_supported, - false) < 0) { - return -1; + ret =3D 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 =3D vhost_user_fill_set_mem_table_msg(u, dev, &msg, fds, &fd_n= um, + false); + if (ret < 0) { + return ret; } - if (vhost_user_write(dev, &msg, fds, fd_num) < 0) { - return -1; + + ret =3D vhost_user_write(dev, &msg, fds, fd_num); + if (ret < 0) { + return ret; } =20 if (reply_supported) { @@ -1109,14 +1136,10 @@ static int vhost_user_set_vring_endian(struct vhost= _dev *dev, =20 if (!cross_endian) { error_report("vhost-user trying to send unhandled ioctl"); - return -1; + return -ENOTSUP; } =20 - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; - } - - return 0; + return vhost_user_write(dev, &msg, NULL, 0); } =20 static int vhost_set_vring(struct vhost_dev *dev, @@ -1130,11 +1153,7 @@ static int vhost_set_vring(struct vhost_dev *dev, .hdr.size =3D sizeof(msg.payload.state), }; =20 - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; - } - - return 0; + return vhost_user_write(dev, &msg, NULL, 0); } =20 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; =20 if (!virtio_has_feature(dev->features, VHOST_USER_F_PROTOCOL_FEATURES)= ) { - return -1; + return -EINVAL; } =20 for (i =3D 0; i < dev->nvqs; ++i) { + int ret; struct vhost_vring_state state =3D { .index =3D dev->vq_index + i, .num =3D enable, }; =20 - vhost_set_vring(dev, VHOST_USER_SET_VRING_ENABLE, &state); + ret =3D 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; + } } =20 return 0; @@ -1200,6 +1228,7 @@ static int vhost_user_set_vring_enable(struct vhost_d= ev *dev, int enable) static int vhost_user_get_vring_base(struct vhost_dev *dev, struct vhost_vring_state *ring) { + int ret; VhostUserMsg msg =3D { .hdr.request =3D VHOST_USER_GET_VRING_BASE, .hdr.flags =3D VHOST_USER_VERSION, @@ -1209,23 +1238,25 @@ static int vhost_user_get_vring_base(struct vhost_d= ev *dev, =20 vhost_user_host_notifier_remove(dev, ring->index); =20 - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } =20 - if (vhost_user_read(dev, &msg) < 0) { - return -1; + ret =3D vhost_user_read(dev, &msg); + if (ret < 0) { + return ret; } =20 if (msg.hdr.request !=3D 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; } =20 if (msg.hdr.size !=3D sizeof(msg.payload.state)) { error_report("Received bad msg size."); - return -1; + return -EPROTO; } =20 *ring =3D msg.payload.state; @@ -1252,11 +1283,7 @@ static int vhost_set_vring_file(struct vhost_dev *de= v, msg.payload.u64 |=3D VHOST_USER_VRING_NOFD_MASK; } =20 - if (vhost_user_write(dev, &msg, fds, fd_num) < 0) { - return -1; - } - - return 0; + return vhost_user_write(dev, &msg, fds, fd_num); } =20 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, =20 static int vhost_user_get_u64(struct vhost_dev *dev, int request, uint64_t= *u64) { + int ret; VhostUserMsg msg =3D { .hdr.request =3D request, .hdr.flags =3D VHOST_USER_VERSION, @@ -1283,23 +1311,25 @@ static int vhost_user_get_u64(struct vhost_dev *dev= , int request, uint64_t *u64) return 0; } =20 - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } =20 - if (vhost_user_read(dev, &msg) < 0) { - return -1; + ret =3D vhost_user_read(dev, &msg); + if (ret < 0) { + return ret; } =20 if (msg.hdr.request !=3D request) { error_report("Received unexpected msg type. Expected %d received %= d", request, msg.hdr.request); - return -1; + return -EPROTO; } =20 if (msg.hdr.size !=3D sizeof(msg.payload.u64)) { error_report("Received bad msg size."); - return -1; + return -EPROTO; } =20 *u64 =3D 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 =3D { .hdr.request =3D VHOST_USER_SET_VRING_ADDR, .hdr.flags =3D VHOST_USER_VERSION, @@ -1357,8 +1388,9 @@ static int vhost_user_set_vring_addr(struct vhost_dev= *dev, msg.hdr.flags |=3D VHOST_USER_NEED_REPLY_MASK; } =20 - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } =20 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 =3D u64, .hdr.size =3D sizeof(msg.payload.u64), }; + int ret; =20 if (wait_for_reply) { bool reply_supported =3D 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, } } =20 - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } =20 if (wait_for_reply) { @@ -1424,11 +1458,7 @@ static int vhost_user_set_owner(struct vhost_dev *de= v) .hdr.flags =3D VHOST_USER_VERSION, }; =20 - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -EPROTO; - } - - return 0; + return vhost_user_write(dev, &msg, NULL, 0); } =20 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; =20 - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; - } - - return 0; + return vhost_user_write(dev, &msg, NULL, 0); } =20 static int vhost_user_slave_handle_config_change(struct vhost_dev *dev) { - int ret =3D -1; - - if (!dev->config_ops) { - return -1; + if (!dev->config_ops || !dev->config_ops->vhost_dev_config_notifier) { + return -ENOSYS; } =20 - if (dev->config_ops->vhost_dev_config_notifier) { - ret =3D dev->config_ops->vhost_dev_config_notifier(dev); - } - - return ret; + return dev->config_ops->vhost_dev_config_notifier(dev); } =20 static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *d= ev, @@ -1497,7 +1517,7 @@ static int vhost_user_slave_handle_vring_host_notifie= r(struct vhost_dev *dev, if (!virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_HOST_NOTIFIER) || vdev =3D=3D NULL || queue_idx >=3D virtio_get_num_queues(vdev)) { - return -1; + return -EINVAL; } =20 n =3D &user->notifier[queue_idx]; @@ -1515,13 +1535,13 @@ static int vhost_user_slave_handle_vring_host_notif= ier(struct vhost_dev *dev, =20 /* Sanity check. */ if (area->size !=3D page_size) { - return -1; + return -EINVAL; } =20 addr =3D mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, area->offset); if (addr =3D=3D MAP_FAILED) { - return -1; + return -EFAULT; } =20 name =3D g_strdup_printf("vhost-user/host-notifier@%p mmaps[%d]", @@ -1534,7 +1554,7 @@ static int vhost_user_slave_handle_vring_host_notifie= r(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; } =20 n->addr =3D addr; @@ -1664,14 +1684,15 @@ static int vhost_setup_slave_channel(struct vhost_d= ev *dev) } =20 if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) =3D=3D -1) { + int saved_errno =3D errno; error_report("socketpair() failed"); - return -1; + return -saved_errno; } =20 ioc =3D 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 =3D 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 =3D dev->opaque; CharBackend *chr =3D u->user->chr; int ufd; + int ret; VhostUserMsg msg =3D { .hdr.request =3D VHOST_USER_POSTCOPY_ADVISE, .hdr.flags =3D VHOST_USER_VERSION, }; =20 - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { error_setg(errp, "Failed to send postcopy_advise to vhost"); - return -1; + return ret; } =20 - if (vhost_user_read(dev, &msg) < 0) { + ret =3D vhost_user_read(dev, &msg); + if (ret < 0) { error_setg(errp, "Failed to get postcopy_advise reply from vhost"); - return -1; + return ret; } =20 if (msg.hdr.request !=3D 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; } =20 if (msg.hdr.size) { error_setg(errp, "Received bad msg size."); - return -1; + return -EPROTO; } ufd =3D 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); =20 @@ -1820,7 +1844,7 @@ static int vhost_user_postcopy_advise(struct vhost_de= v *dev, Error **errp) return 0; #else error_setg(errp, "Postcopy not supported on non-Linux systems"); - return -1; + return -ENOSYS; #endif } =20 @@ -1836,10 +1860,13 @@ static int vhost_user_postcopy_listen(struct vhost_= dev *dev, Error **errp) .hdr.flags =3D VHOST_USER_VERSION | VHOST_USER_NEED_REPLY_MASK, }; u->postcopy_listen =3D true; + trace_vhost_user_postcopy_listen(); - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { + + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { error_setg(errp, "Failed to send postcopy_listen to vhost"); - return -1; + return ret; } =20 ret =3D 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 =3D dev->opaque; =20 trace_vhost_user_postcopy_end_entry(); - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { + + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { error_setg(errp, "Failed to send postcopy_end to vhost"); - return -1; + return ret; } =20 ret =3D process_message_reply(dev, &msg); @@ -2115,7 +2144,7 @@ static int vhost_user_migration_done(struct vhost_dev= *dev, char* mac_addr) =20 return vhost_user_write(dev, &msg, NULL, 0); } - return -1; + return -ENOTSUP; } =20 static bool vhost_user_can_merge(struct vhost_dev *dev, @@ -2136,6 +2165,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev *d= ev, uint16_t mtu) VhostUserMsg msg; bool reply_supported =3D virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_REPLY_= ACK); + int ret; =20 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 *d= ev, uint16_t mtu) msg.hdr.flags |=3D VHOST_USER_NEED_REPLY_MASK; } =20 - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } =20 /* 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 *d= ev, uint16_t mtu) static int vhost_user_send_device_iotlb_msg(struct vhost_dev *dev, struct vhost_iotlb_msg *imsg) { + int ret; VhostUserMsg msg =3D { .hdr.request =3D VHOST_USER_IOTLB_MSG, .hdr.size =3D sizeof(msg.payload.iotlb), @@ -2171,8 +2203,9 @@ static int vhost_user_send_device_iotlb_msg(struct vh= ost_dev *dev, .payload.iotlb =3D *imsg, }; =20 - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -EFAULT; + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } =20 return process_message_reply(dev, &msg); @@ -2187,6 +2220,7 @@ static void vhost_user_set_iotlb_callback(struct vhos= t_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 =3D { .hdr.request =3D VHOST_USER_GET_CONFIG, .hdr.flags =3D VHOST_USER_VERSION, @@ -2203,26 +2237,28 @@ static int vhost_user_get_config(struct vhost_dev *= dev, uint8_t *config, =20 msg.payload.config.offset =3D 0; msg.payload.config.size =3D config_len; - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - error_setg_errno(errp, EPROTO, "vhost_get_config failed"); - return -EPROTO; + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + error_setg_errno(errp, -ret, "vhost_get_config failed"); + return ret; } =20 - if (vhost_user_read(dev, &msg) < 0) { - error_setg_errno(errp, EPROTO, "vhost_get_config failed"); - return -EPROTO; + ret =3D vhost_user_read(dev, &msg); + if (ret < 0) { + error_setg_errno(errp, -ret, "vhost_get_config failed"); + return ret; } =20 if (msg.hdr.request !=3D 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; } =20 if (msg.hdr.size !=3D VHOST_USER_CONFIG_HDR_SIZE + config_len) { error_setg(errp, "Received bad msg size."); - return -EINVAL; + return -EPROTO; } =20 memcpy(config, msg.payload.config.region, config_len); @@ -2233,6 +2269,7 @@ static int vhost_user_get_config(struct vhost_dev *de= v, uint8_t *config, static int vhost_user_set_config(struct vhost_dev *dev, const uint8_t *dat= a, uint32_t offset, uint32_t size, uint32_t = flags) { + int ret; uint8_t *p; bool reply_supported =3D 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 *de= v, const uint8_t *data, =20 if (!virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_CONFIG)) { - return -1; + return -ENOTSUP; } =20 if (reply_supported) { @@ -2253,7 +2290,7 @@ static int vhost_user_set_config(struct vhost_dev *de= v, const uint8_t *data, } =20 if (size > VHOST_USER_MAX_CONFIG_SIZE) { - return -1; + return -EINVAL; } =20 msg.payload.config.offset =3D offset, @@ -2262,8 +2299,9 @@ static int vhost_user_set_config(struct vhost_dev *de= v, const uint8_t *data, p =3D msg.payload.config.region; memcpy(p, data, size); =20 - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } =20 if (reply_supported) { @@ -2277,6 +2315,7 @@ static int vhost_user_crypto_create_session(struct vh= ost_dev *dev, void *session_info, uint64_t *session_id) { + int ret; bool crypto_session =3D virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_CRYPTO_SESSIO= N); CryptoDevBackendSymSessionInfo *sess_info =3D session_info; @@ -2290,7 +2329,7 @@ static int vhost_user_crypto_create_session(struct vh= ost_dev *dev, =20 if (!crypto_session) { error_report("vhost-user trying to send unhandled ioctl"); - return -1; + return -ENOTSUP; } =20 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 =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + error_report("vhost_user_write() return %d, create session failed", + ret); + return ret; } =20 - if (vhost_user_read(dev, &msg) < 0) { - error_report("vhost_user_read() return -1, create session failed"); - return -1; + ret =3D vhost_user_read(dev, &msg); + if (ret < 0) { + error_report("vhost_user_read() return %d, create session failed", + ret); + return ret; } =20 if (msg.hdr.request !=3D 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; } =20 if (msg.hdr.size !=3D sizeof(msg.payload.session)) { error_report("Received bad msg size."); - return -1; + return -EPROTO; } =20 if (msg.payload.session.session_id < 0) { error_report("Bad session id: %" PRId64 "", msg.payload.session.session_id); - return -1; + return -EINVAL; } *session_id =3D msg.payload.session.session_id; =20 @@ -2337,6 +2380,7 @@ static int vhost_user_crypto_create_session(struct vh= ost_dev *dev, static int vhost_user_crypto_close_session(struct vhost_dev *dev, uint64_t session_id) { + int ret; bool crypto_session =3D virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_CRYPTO_SESSIO= N); VhostUserMsg msg =3D { @@ -2348,12 +2392,14 @@ vhost_user_crypto_close_session(struct vhost_dev *d= ev, uint64_t session_id) =20 if (!crypto_session) { error_report("vhost-user trying to send unhandled ioctl"); - return -1; + return -ENOTSUP; } =20 - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - error_report("vhost_user_write() return -1, close session failed"); - return -1; + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + error_report("vhost_user_write() return %d, close session failed", + ret); + return ret; } =20 return 0; @@ -2375,6 +2421,7 @@ static int vhost_user_get_inflight_fd(struct vhost_de= v *dev, { void *addr; int fd; + int ret; struct vhost_user *u =3D dev->opaque; CharBackend *chr =3D u->user->chr; VhostUserMsg msg =3D { @@ -2390,24 +2437,26 @@ static int vhost_user_get_inflight_fd(struct vhost_= dev *dev, return 0; } =20 - if (vhost_user_write(dev, &msg, NULL, 0) < 0) { - return -1; + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; } =20 - if (vhost_user_read(dev, &msg) < 0) { - return -1; + ret =3D vhost_user_read(dev, &msg); + if (ret < 0) { + return ret; } =20 if (msg.hdr.request !=3D 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; } =20 if (msg.hdr.size !=3D sizeof(msg.payload.inflight)) { error_report("Received bad msg size."); - return -1; + return -EPROTO; } =20 if (!msg.payload.inflight.mmap_size) { @@ -2417,7 +2466,7 @@ static int vhost_user_get_inflight_fd(struct vhost_de= v *dev, fd =3D qemu_chr_fe_get_msgfd(chr); if (fd < 0) { error_report("Failed to get mem fd"); - return -1; + return -EIO; } =20 addr =3D mmap(0, msg.payload.inflight.mmap_size, PROT_READ | PROT_WRIT= E, @@ -2426,7 +2475,7 @@ static int vhost_user_get_inflight_fd(struct vhost_de= v *dev, if (addr =3D=3D MAP_FAILED) { error_report("Failed to mmap mem fd"); close(fd); - return -1; + return -EFAULT; } =20 inflight->addr =3D addr; @@ -2456,11 +2505,7 @@ static int vhost_user_set_inflight_fd(struct vhost_d= ev *dev, return 0; } =20 - if (vhost_user_write(dev, &msg, &inflight->fd, 1) < 0) { - return -1; - } - - return 0; + return vhost_user_write(dev, &msg, &inflight->fd, 1); } =20 bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp) --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476776722799.9432848656267; Thu, 6 Jan 2022 05:46:16 -0800 (PST) Received: from localhost ([::1]:39096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5T5h-0006gw-6z for importer@patchew.org; Thu, 06 Jan 2022 08:46:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Se2-0004w0-Su for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:58413) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdp-0000sT-Lf for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:30 -0500 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-301-Iq_2RQifP2WC9tn7_r8Jiw-1; Thu, 06 Jan 2022 08:17:16 -0500 Received: by mail-wm1-f70.google.com with SMTP id l20-20020a05600c1d1400b003458e02cea0so3056553wms.7 for ; Thu, 06 Jan 2022 05:17:16 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id j11sm2285977wmq.23.2022.01.06.05.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475037; 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=FZaiQqu3m7wkeu834JR59fLDeMOgca51rdNs7HLXszhBeKGTCpKwKM3jM7NeuANMEjcHgt 8lOFIOv7DwpdFoo4qDU/qRtGVVj8ChdnyDKQBZTGseu2+D2LxOVV5CPMTwDc/9+CUuZBD4 Ew+xgnjVcDGcOQhHsh4H7zLIRlVwpGg= X-MC-Unique: Iq_2RQifP2WC9tn7_r8Jiw-1 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=CWaqN/GrNm28d8J0w7SUxbqAD0hXH1Ski+46fRJ4ySlgkqiKqoIfVDjG4gRet2gbqF H2bgp5egqXkBT7CTkO72jBLKhEbtVKzmVcNx8Q03tNPJgf9Wm2w65ChO0G+EZ1Ig1yJk 4TmiMD33BaSiu9iRj9ZMszadX5Z/W4ngBtTS+VmqUuZcZ5USTw591W2N9cBJVgKELUer 7DfuJXE/fhim5CKY/ytDPVUPwQt6Ra+ox9HUw8WDS7VLLq2Vra8RI+B6TrRZBlInjSmk 7V6m5yUpNGcInQPlsCkq/xc4IxFssWMIPCSOwFubJ/PfzjtgjB9lJSvPlojX3akWmBFR S6oQ== X-Gm-Message-State: AOAM531HSRk6KsQoixNt5JyCa5bodmSbRaRjaIR3yYKpQPDm+G3I+RaC hb2sosoac7FSFPdr9wEYabXrBB3Vn6siwPGIzpRAV04qbSmv87MLVslFsIAaATUyAJNhPbxz31n D3dmjWg1mPhD1AlPOxBDfK8BT8DbggfAIGqWTRHDac214jDPlDTY1BYS7VKUi X-Received: by 2002:a1c:c915:: with SMTP id f21mr7025903wmb.39.1641475034563; Thu, 06 Jan 2022 05:17:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXN2izkP2/nfk3gipiajRLps1XFnY5zfX1HsUrjCwjVYfQq5I/Lk76BXscep7/ySY4LzkJHw== X-Received: by 2002:a1c:c915:: with SMTP id f21mr7025879wmb.39.1641475034165; Thu, 06 Jan 2022 05:17:14 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:11 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 21/52] vhost: stick to -errno error return convention Message-ID: <20220106131534.423671-22-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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_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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476778169100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 #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 =20 @@ -297,7 +299,7 @@ static inline void vhost_dev_log_resize(struct vhost_de= v *dev, uint64_t size) releasing the current log, to ensure no logging is lost */ r =3D 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"); } =20 vhost_log_put(dev, true); @@ -550,7 +552,7 @@ static void vhost_commit(MemoryListener *listener) if (!dev->log_enabled) { r =3D 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 =3D 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 *d= ev, if (dev->vhost_ops->vhost_vq_get_addr) { r =3D 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 =3D (uint64_t)(unsigned long)vq->desc; @@ -816,10 +818,9 @@ static int vhost_virtqueue_set_addr(struct vhost_dev *= dev, addr.flags =3D enable_log ? (1 << VHOST_VRING_F_LOG) : 0; r =3D 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; } =20 static int vhost_dev_set_features(struct vhost_dev *dev, @@ -840,19 +841,19 @@ static int vhost_dev_set_features(struct vhost_dev *d= ev, } r =3D 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 =3D 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; } } =20 out: - return r < 0 ? -errno : 0; + return r; } =20 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(s= truct vhost_dev *dev, bool is_big_endian, int vhost_vq_index) { + int r; struct vhost_vring_state s =3D { .index =3D vhost_vq_index, .num =3D is_big_endian }; =20 - if (!dev->vhost_ops->vhost_set_vring_endian(dev, &s)) { - return 0; + r =3D 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 =3D=3D ENOTTY) { - error_report("vhost does not support cross-endian"); - return -ENOSYS; - } - - return -errno; + return r; } =20 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 =3D state.num =3D virtio_queue_get_num(vdev, idx); r =3D 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; } =20 state.num =3D virtio_queue_get_last_avail_idx(vdev, idx); r =3D 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; } =20 if (vhost_needs_vring_endian(vdev)) { @@ -1122,7 +1118,7 @@ static int vhost_virtqueue_start(struct vhost_dev *de= v, virtio_is_big_endian(v= dev), vhost_vq_index); if (r) { - return -errno; + return r; } } =20 @@ -1150,15 +1146,13 @@ static int vhost_virtqueue_start(struct vhost_dev *= dev, =20 r =3D vhost_virtqueue_set_addr(dev, vq, vhost_vq_index, dev->log_enabl= ed); if (r < 0) { - r =3D -errno; goto fail_alloc; } =20 file.fd =3D event_notifier_get_fd(virtio_queue_get_host_notifier(vvq)); r =3D dev->vhost_ops->vhost_set_vring_kick(dev, &file); if (r) { - VHOST_OPS_DEBUG("vhost_set_vring_kick failed"); - r =3D -errno; + VHOST_OPS_DEBUG(r, "vhost_set_vring_kick failed"); goto fail_kick; } =20 @@ -1218,7 +1212,7 @@ static void vhost_virtqueue_stop(struct vhost_dev *de= v, =20 r =3D 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(struc= t vhost_dev *dev, =20 r =3D 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; } =20 @@ -1296,8 +1290,7 @@ static int vhost_virtqueue_init(struct vhost_dev *dev, file.fd =3D event_notifier_get_fd(&vq->masked_notifier); r =3D dev->vhost_ops->vhost_set_vring_call(dev, &file); if (r) { - VHOST_OPS_DEBUG("vhost_set_vring_call failed"); - r =3D -errno; + VHOST_OPS_DEBUG(r, "vhost_set_vring_call failed"); goto fail_call; } =20 @@ -1557,7 +1550,7 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, Vir= tIODevice *vdev, int n, file.index =3D hdev->vhost_ops->vhost_get_vq_index(hdev, n); r =3D 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"); } } =20 @@ -1595,7 +1588,7 @@ void vhost_config_mask(struct vhost_dev *hdev, VirtIO= Device *vdev, bool mask) } r =3D 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"); } } =20 @@ -1660,7 +1653,7 @@ int vhost_dev_get_config(struct vhost_dev *hdev, uint= 8_t *config, } =20 error_setg(errp, "vhost_get_config not implemented"); - return -ENOTSUP; + return -ENOSYS; } =20 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, cons= t uint8_t *data, size, flags); } =20 - return -1; + return -ENOSYS; } =20 void vhost_dev_set_config_notifier(struct vhost_dev *hdev, @@ -1702,7 +1695,7 @@ static int vhost_dev_resize_inflight(struct vhost_inf= light *inflight, =20 if (err) { error_report_err(err); - return -1; + return -ENOMEM; } =20 vhost_dev_free_inflight(inflight); @@ -1735,8 +1728,9 @@ int vhost_dev_load_inflight(struct vhost_inflight *in= flight, QEMUFile *f) } =20 if (inflight->size !=3D size) { - if (vhost_dev_resize_inflight(inflight, size)) { - return -1; + int ret =3D vhost_dev_resize_inflight(inflight, size); + if (ret < 0) { + return ret; } } inflight->queue_size =3D qemu_get_be16(f); @@ -1759,7 +1753,7 @@ int vhost_dev_prepare_inflight(struct vhost_dev *hdev= , VirtIODevice *vdev) =20 r =3D 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; } =20 @@ -1774,8 +1768,8 @@ int vhost_dev_set_inflight(struct vhost_dev *dev, if (dev->vhost_ops->vhost_set_inflight_fd && inflight->addr) { r =3D 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; } } =20 @@ -1790,8 +1784,8 @@ int vhost_dev_get_inflight(struct vhost_dev *dev, uin= t16_t queue_size, if (dev->vhost_ops->vhost_get_inflight_fd) { r =3D dev->vhost_ops->vhost_get_inflight_fd(dev, queue_size, infli= ght); if (r) { - VHOST_OPS_DEBUG("vhost_get_inflight_fd failed"); - return -errno; + VHOST_OPS_DEBUG(r, "vhost_get_inflight_fd failed"); + return r; } } =20 @@ -1820,8 +1814,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODev= ice *vdev) =20 r =3D hdev->vhost_ops->vhost_set_mem_table(hdev, hdev->mem); if (r < 0) { - VHOST_OPS_DEBUG("vhost_set_mem_table failed"); - r =3D -errno; + VHOST_OPS_DEBUG(r, "vhost_set_mem_table failed"); goto fail_mem; } for (i =3D 0; i < hdev->nvqs; ++i) { @@ -1855,8 +1848,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODev= ice *vdev) hdev->log_size ? log_base = : 0, hdev->log); if (r < 0) { - VHOST_OPS_DEBUG("vhost_set_log_base failed"); - r =3D -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); } =20 - return -1; + return -ENOSYS; } --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477160262451.56247233579404; Thu, 6 Jan 2022 05:52:40 -0800 (PST) Received: from localhost ([::1]:56908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TC3-0002zQ-9v for importer@patchew.org; Thu, 06 Jan 2022 08:52:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sdu-0004jz-2v for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47897) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sds-0000tn-HN for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:21 -0500 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-90-zeVWAdWxOVaNFojVtD442A-1; Thu, 06 Jan 2022 08:17:18 -0500 Received: by mail-wm1-f72.google.com with SMTP id m15-20020a7bce0f000000b003473d477618so544793wmc.8 for ; Thu, 06 Jan 2022 05:17:18 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id u3sm2594246wrs.0.2022.01.06.05.17.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475039; 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=IU6RXzNtXZl/YgMRV/ZLPhkCIjDoFZsbWk7LrndbIbXUycCzOmyjUY9AFpOliJW3mFDtYs yKNFHlcOh2m0IO1pioPUKCDIbDkpY67CoH4JD8VcpBy4ivWVe1LC3px51IsP7PJEq06lEz As+UChcmerX/4XkjL08qPtE0pZvb1To= X-MC-Unique: zeVWAdWxOVaNFojVtD442A-1 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=3tY1cWj+y/6g8bqCOYXJ09jfngfyAMA2gaVMhS1mpvLZghZrbWVO9hUomf1omri/+Y 0kyFPMnxm60ZBBe4aB7xM4XjN65BIMNKWj+UboJHRigap4Y0s/6yRxyRh/eoa9sQA+mS WaRt/9uK/S6pKA9fvdGQRdqDM6pOPIuDCFXZTCI3q78a3oGG94CVtVIhLdlZRju1Iy4E TB1AiPH3sKntsxUFMYSAjHnSku2OlnzmiLMl7RoaGtYuXs+lQAJ23Fx+zI57tPPMjbyL 8P1+GVOB2dLOJXr6sqlzjqPXiLPG0rNDuM7CtbFXk8/D1/QccAYyT62cYCSEOMyVW5L/ TBlQ== X-Gm-Message-State: AOAM532bwYtKd4XJ1FL+wre2wgIgM2hEtjJNTL6NaglMWiUXgT9l0e6t pZmV27AmVflmKIx6VGodfk8vBJsRSyV19Soh8BvlLOehoOEJ1wJyOJCuzG/Lv8fGutJmj8zC6rd JZvif1DVpqfzcvAzEzejc+Da9py2p5L0g15YqK9tI/CSaEcrQ9TSAWEu4Q8x5 X-Received: by 2002:a05:600c:2f01:: with SMTP id r1mr7262760wmn.153.1641475037111; Thu, 06 Jan 2022 05:17:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDhLnebCSwwQVPV9cct8OqkFFe0vL+G+2ovuf5k57C65sUH1S3jme+r7sTQwp8IusQHJ7Uyg== X-Received: by 2002:a05:600c:2f01:: with SMTP id r1mr7262736wmn.153.1641475036876; Thu, 06 Jan 2022 05:17:16 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:14 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 22/52] vhost-user-blk: propagate error return from generic vhost Message-ID: <20220106131534.423671-23-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Raphael Norwitz , Roman Kagan , Hanna Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477162601100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 v= host_dev *dev) &local_err); if (ret < 0) { error_report_err(local_err); - return -1; + return ret; } =20 /* valid for resize only */ --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476366023223.56097464930224; Thu, 6 Jan 2022 05:39:26 -0800 (PST) Received: from localhost ([::1]:57870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5SzE-0007zH-T0 for importer@patchew.org; Thu, 06 Jan 2022 08:39:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Se4-00050P-92 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31261) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Se0-0000uK-IA for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:31 -0500 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-493-TMAf9tw_Naa5kFnj8FpGgQ-1; Thu, 06 Jan 2022 08:17:21 -0500 Received: by mail-wm1-f70.google.com with SMTP id az11-20020a05600c600b00b00345c4309bccso187557wmb.5 for ; Thu, 06 Jan 2022 05:17:21 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id b14sm2115357wrg.15.2022.01.06.05.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475042; 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=KfBouZyqK/8eqaRRArA6t9u1DE9BafO6pX65CuH9z2vuFI+7qGhW94xG1mFckJrl+9/boK AF/KTlbohnZO4OI2awPa70W2GaWP2C+eb+SuzfSw+66FLl5KfHYeudmBP8DVC5xHNMt3vc 3n2tXLBqTH+Dav47NtP9iMls0Nj28g4= X-MC-Unique: TMAf9tw_Naa5kFnj8FpGgQ-1 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=4pYeM5yT8DvBKRjQzz6DGAdZYWMTdWo9QP3B/Y4bfM9w/F8SiTAgcx8Gyf+0xyZujW Ykm6VWY3i7ZNfmpf6/+CBipDWJ5DEmloZhiwHhUUtiTIvfIwnIL85/mw2lZekU3KTsZo XESowmfmHmvXZIUR1Pn5OBJ2CWtxiGI7tGKKPrbJ0E5bC03OOzh/cJAerTN61uRkcoQ2 RCip5cCs1649OqvVpNbp+EWL7uDHQSfvn4TEe/JYO5Ctaug7ayzOhAgz7Y5MKXiMJ2sV zzVrwMTUsEK8q4WqmDp1DjatquvVPD6Rs5HheH0qRjYQmB4QA2Qd0Sqg04f+/X2MKrC1 BEDw== X-Gm-Message-State: AOAM5339wgAd5FTc/VXVwVx3QVhN0i2XZTCiR102yHtvA/BmjBc5UeAC ldCq5blR1p7H+05xgbSczlcBgzfE+EOn4Y2TGsflYRHSN0Hmqv4HjehiDL1ykNKsGSLIvwiNjO5 UpzDAJbYQ6JWjDTt0T4E0wW2TnchS+ZcN209np3fT5B3dW94Ewxk7OmKzBGTJ X-Received: by 2002:a1c:9d54:: with SMTP id g81mr4820001wme.51.1641475040104; Thu, 06 Jan 2022 05:17:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGCoYF29Yq+vs29I3LjgHp1b+huQtdC4fJrlzvexyjhHK0qGpeJsd/VRYhjLioNuU9Rpq7hw== X-Received: by 2002:a1c:9d54:: with SMTP id g81mr4819969wme.51.1641475039713; Thu, 06 Jan 2022 05:17:19 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 23/52] pci: Export the pci_intx() function Message-ID: <20220106131534.423671-24-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476368073100001 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=C3=A9dric 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); =20 +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_nu= m, int level) pci_change_irq_level(pci_dev, irq_num, change); } =20 -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 =3D pci_intx(pci_dev); --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477547012514.8885805605854; Thu, 6 Jan 2022 05:59:07 -0800 (PST) Received: from localhost ([::1]:47644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TIH-0007Qg-Ly for importer@patchew.org; Thu, 06 Jan 2022 08:59:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Se6-00052X-UR for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32309) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Se2-0000uU-RT for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:33 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-563-ONX9sE93NJmqrCAAXQgmog-1; Thu, 06 Jan 2022 08:17:25 -0500 Received: by mail-ed1-f72.google.com with SMTP id h6-20020a056402280600b003f9967993aeso1928330ede.10 for ; Thu, 06 Jan 2022 05:17:24 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id kw22sm489484ejc.132.2022.01.06.05.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475045; 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=DB1EgH50FPCBZDi9i0pUmpveYo5KGcxLFsfgYHnZ9jdZjBE3fyJa03ZPz34XrIYhOMtiE8 BvBo05WFIL/XAuv5k8fsn0iUltY07clxPF6I4Bju0LACn6z2XkwdCA/dwOEs8mzrPk3mP+ J3RaGFYeFR+CheuH19WEEHIb6E2AsQs= X-MC-Unique: ONX9sE93NJmqrCAAXQgmog-1 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=gcLWO4CjW8Q7NTOaplpa1/1gt1se0Bk7ihzhZxakHjGUUEXdu71CzSzc9dCaIl0Sz5 tTJdzgj9t5druHMBOGpXk9GLVeOyDXOo0vS27XxnBjeGcQKBq/WGp5cpXkstmvOhcqkf njorhP3sU5FgzS/YSJX4rG26oxouhr5vnSD181OXOcxQ8GZG5vKjSb6Bfpw4SkResiCU n4qZX1eKlJj0oJ/iGbYdoox1DpYZ3yxZkUHk0I2/7zzJHanfDyaXmym/IcY/XryBR+U9 pnTXU44VWuwz3p46SrZA5kFtyd0klRKteS2CdMEZXgZgUFOWkT0D7ZuunrpzhvPFi+xO ZOzQ== X-Gm-Message-State: AOAM531CblsS1cSgQVqh2mTC59/gbQirIg/ujYqhQ/Zhk2kyWoovhR9e sFHPgB7Iq5qxChI8xL5ciQyFesY1IeiF13b+4X4nuiWQ4hwSzmgqDIi7KkaRnaiaYEjUc2WNu9A bfJ2QjIYN9q3EncAjRrrdfaavgzfv5tgUQ1yMm+awNo4CNmC1771N7Nq8Wq42 X-Received: by 2002:a17:907:6e23:: with SMTP id sd35mr45920612ejc.202.1641475043031; Thu, 06 Jan 2022 05:17:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzx9QGgutMuaszm4o8KKtPnmkke00KeiIBIsjz9H4vaZQwdl7dg/MAeld3nT8QpqWhNXvDdgw== X-Received: by 2002:a17:907:6e23:: with SMTP id sd35mr45920589ejc.202.1641475042718; Thu, 06 Jan 2022 05:17:22 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:19 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 24/52] pcie_aer: Don't trigger a LSI if none are defined Message-ID: <20220106131534.423671-25-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477547649100001 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=C3=A9dric 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 =3D 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) !=3D -1) { + pci_set_irq(dev, !!(root_cmd & enabled_cmd)); + } return; } =20 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476304955488.20968588431515; Thu, 6 Jan 2022 05:38:24 -0800 (PST) Received: from localhost ([::1]:52800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5SyF-0004XC-QD for importer@patchew.org; Thu, 06 Jan 2022 08:38:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Se4-000523-I4 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39402) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Se2-0000uv-Gj for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:32 -0500 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-78-_3wuVHiwOm2GQd2LFRCzww-1; Thu, 06 Jan 2022 08:17:28 -0500 Received: by mail-ed1-f70.google.com with SMTP id i5-20020a05640242c500b003f84839a8c3so1938556edc.6 for ; Thu, 06 Jan 2022 05:17:28 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id qk34sm492348ejc.143.2022.01.06.05.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475049; 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=FuyIo7Emv5YQh76Y0q/FwH6NxHSG38JjlmP8PsX3L4E7e8n1rixgxBgrc2+KJn9YhEadaS 79Y74g0Dm715U5WyRtedqYq5HIxDHFs/9jeaiOCbyJ9TsN3EuDDVDWEEXuCi6VW10j9LaI Nf8LNc22zsEXGA0fu5orMfUKZ8nmoNE= X-MC-Unique: _3wuVHiwOm2GQd2LFRCzww-1 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=wgCD3/pFd1Xpx4kkaOVY6RWIKmfz27/jYN/n96gEXkX1By0fmMbOBykf+oMyuU0Nhp bvc3x26//bPusCbU8wEhJKZSHe7piDK15QQCaMwFa2feKmyMgoYhvw7KbRSPF5QJMv8j zLy9v+ncQk2fYn/2dTsjL3MqlWVnXHoW1GN9GXchF+ME1eI96DDs+C9d4H221GNeCYu9 WwbkuMm3KHmv39VkPJh/t8UTssKfHkHz83mN0THXIKfQ6K8qFTrMk/S9zM/2qlECsjlk h/BDA2pnJgg4AGMegCJN6SsVKHp0t1lfroUh5jIkYu48bjmlaFRIU5gW4BS7+ze5kjGq Bxcw== X-Gm-Message-State: AOAM5334K9G7+JCQs77c+4SWNOfREaxLsOJMokBdj85EhOHKtChwrRCp dGaAkOEZ3AXjArtrpqYbyBUf3DoqmPKALn8YXoqEphI2x0MIFmfI7y71k/L/7bwgXwW07xqaXKI 8C0Slh8mOoD3FvbZ1oMkFIFlWaZd5YYUFpEtV3T6I1+YlGsLcE9PKZMRfbaFb X-Received: by 2002:a17:907:6d87:: with SMTP id sb7mr48269417ejc.220.1641475046550; Thu, 06 Jan 2022 05:17:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJw46ED+z4x+q7QQpntGTyF51zKK9+DHFBCxQ4xySEhk2XyPAcMfDiwc64SHXKWv3BDCVDz7HQ== X-Received: by 2002:a17:907:6d87:: with SMTP id sb7mr48269396ejc.220.1641475046315; Thu, 06 Jan 2022 05:17:26 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:22 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 25/52] smbios: Rename SMBIOS_ENTRY_POINT_* enums Message-ID: <20220106131534.423671-26-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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 , 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476305741100001 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=C3=A9. Signed-off-by: Eduardo Habkost Message-Id: <20211026151100.1691925-2-ehabkost@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 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; =20 /* 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) =20 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); =20 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); } =20 /* 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); } =20 /* 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 =3D SMBIOS_ENTRY_POINT_21; +static SmbiosEntryPointType smbios_ep_type =3D SMBIOS_ENTRY_POINT_TYPE_32; =20 static SmbiosEntryPoint ep; =20 @@ -432,7 +432,7 @@ static void smbios_validate_table(MachineState *ms) exit(1); } =20 - if (smbios_ep_type =3D=3D SMBIOS_ENTRY_POINT_21 && + if (smbios_ep_type =3D=3D 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, cons= t 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 =3D sizeof(struct smbios_21_entry_point); @@ -950,7 +950,7 @@ static void smbios_entry_point_setup(void) ep.ep21.structure_table_address =3D cpu_to_le32(0); =20 break; - case SMBIOS_ENTRY_POINT_30: + case SMBIOS_ENTRY_POINT_TYPE_64: memcpy(ep.ep30.anchor_string, "_SM3_", 5); ep.ep30.length =3D sizeof(struct smbios_30_entry_point); ep.ep30.entry_point_revision =3D 1; --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476910910111.94033328964156; Thu, 6 Jan 2022 05:48:30 -0800 (PST) Received: from localhost ([::1]:47614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5T81-0004XT-Pp for importer@patchew.org; Thu, 06 Jan 2022 08:48:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Se7-00052Z-3d for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38889) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Se5-0000vc-5f for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:34 -0500 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-619-FQ7PjI_qMg-6rYhwzyiuJA-1; Thu, 06 Jan 2022 08:17:31 -0500 Received: by mail-ed1-f69.google.com with SMTP id b8-20020a056402350800b003f8f42a883dso1904688edd.16 for ; Thu, 06 Jan 2022 05:17:31 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id e6sm719782edz.54.2022.01.06.05.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475052; 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=HN9w9rFldkBNpCALZtYKcWKqhe/KMI6H2E8BAn50viBgPC/aqezuboNIyIuR1ynDJBQMml ZzkzWpPKUTy5URfxH691JwHUP3X1NZKAyJ835DRwT5M36BeuhSuEZhQTulwtQG4BSvdTdR aL6j0Bv7Vn4o62yyClDkqifssjfV3bk= X-MC-Unique: FQ7PjI_qMg-6rYhwzyiuJA-1 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=IUu69Xv56yRjJjgbDQ6GgTxGIV25hHXI1FiDdzO8gGZOUd+NBIHphBk5wOtGWI0K6s 6cBSFsTPF1yuCjZ2P+E2smxbGl1LBVhOaBvEIb42Z9kXQnyc+xJmNa4DJsDinK3gG62c yn9jWnkL+d3kSUKnzjPk5bgvr4Or4Kl8ZXd9y2q/oZuOEwOcXQrbeB7Z4L5kqr8Vukpk tksEuYp5HlRiUbhnvZK/8+TymbZGjXuvYlxLYk4SpxWQIlHk7PC/qgNRDR0lP8DaDzcC QDAQWGp3rnXcZVg4x5Ow3jfEMn2QxkuJWIvPJc0rFlENkR3VE8USvc54JhJXIYyj69Y4 pSfQ== X-Gm-Message-State: AOAM532ZzHLyql7RFb393Ff0FHLgzp1tuDAR9MYgVstCW70Fxs8x0eYE +W1K+QxuyHBQKB3sQyR9n6uZwrj2PN6fPxUFGg16V+aWCGuxSvRnAFU5hCf+vs8rEyrhKOHcyxO vCvw8sI5poJjzWTJ76YK4KLcmQPl48Nl/E7eGLigw/l7VXMwsV68Q3h/SJZ4o X-Received: by 2002:a17:906:bc97:: with SMTP id lv23mr45060567ejb.506.1641475050268; Thu, 06 Jan 2022 05:17:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+Hn/7ZeI/If3xYJYvlzDChL/AjbhekgBqj05UyrrIc72c73ZLCeVMAP8yb4BkAbyvfay0Fg== X-Received: by 2002:a17:906:bc97:: with SMTP id lv23mr45060536ejb.506.1641475049935; Thu, 06 Jan 2022 05:17:29 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:26 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 26/52] hw/smbios: Use qapi for SmbiosEntryPointType Message-ID: <20220106131534.423671-27-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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?LiBCZXJyYW5nw6k=?= , Eduardo Habkost , Eric Blake , Markus Armbruster , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Yanan Wang , Ani Sinha , Igor Mammedov , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476911852100003 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=C3=A9. Signed-off-by: Daniel P. Berrang=C3=A9 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=C3=A9 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 =20 +#include "qapi/qapi-types-machine.h" + /* * SMBIOS Support * @@ -23,14 +25,6 @@ struct smbios_phys_mem_area { uint64_t length; }; =20 -/* - * 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 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476494809869.9751634321674; Thu, 6 Jan 2022 05:41:34 -0800 (PST) Received: from localhost ([::1]:32968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5T1J-0001wo-Qg for importer@patchew.org; Thu, 06 Jan 2022 08:41:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SeB-00053L-Hu for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27420) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Se8-0000wa-Ox for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:38 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.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-_monbUxSNJmGfDrFjs3L6A-1; Thu, 06 Jan 2022 08:17:35 -0500 Received: by mail-ed1-f72.google.com with SMTP id y10-20020a056402358a00b003f88b132849so1973176edc.0 for ; Thu, 06 Jan 2022 05:17:35 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id ga37sm488331ejc.65.2022.01.06.05.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475056; 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=Bx6084BLXgGtjH6n0SKGcbcOhnkfcJtNx6JWEYQ/bER/YtP8+I1E6zHvfC2W0hKm/29F8e 4GexGeOg9xibdDAOhlsSBQI5+HLS8qWZwFfe9H7Ghie/5DoI5Q5pUs7vjqQJVt1yUBOXax pkKdhdjazoBIBdMdjqxMy+Kgyw72vuI= X-MC-Unique: _monbUxSNJmGfDrFjs3L6A-1 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=te+v7qpBaA7oztlUFnMadlxA2skbyJzC4IgkDy/QDY/eE6hdSuH7kr5mZEk+p+QJ5U hUi/+YjCpPzkfj/+a6breY/OgmRgT1Zvzbf6vA8w6NJK59q7F0v6mgPCjt9L10mk92ra FORD4X/FVQGVQB85vSH1Nw4LCEj7JoBjY8vsH7kAwacp1haPB+eEuLKEysovYc7+1Gtw xtQCDVOdc7g3g7XjCEOFO4KHDDhQ0S28XwpMv23Yqela4AyXGTxiS4Xb9HfuGCc2PTPI 0zs5qI/JZWzb1rH0mKdZbE41yXA/xXy6hJxdWzTQvlpFZbEp1XCRFGVQiYw0X5Z9X86w V9mA== X-Gm-Message-State: AOAM531z2ZW0cDuqv8wi80R7p5g9tzu3yWjnjH2vtbKjg5rQi1H64Kcl N++N2zcrLlh5I4uDHV8KXWE0NjDMiy6XsqfHdl8wuP8ATSFafnrz3vBrTRX5uxEx7nUJQ7qc9Dk ouFGUT7lYh9pylzTdkqytHznih6BvTg00tn2ni7Sb1LCjxe7XMnTLqiHCSlhe X-Received: by 2002:a17:906:36d8:: with SMTP id b24mr13256026ejc.342.1641475053669; Thu, 06 Jan 2022 05:17:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrkTth4wyPkFVFdSfuH11WtRajdP6C296BnUsZtML1sqhzXGZ9YB3aGgkNWp0flf1Kr889/Q== X-Received: by 2002:a17:906:36d8:: with SMTP id b24mr13256004ejc.342.1641475053402; Thu, 06 Jan 2022 05:17:33 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:30 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 27/52] hw/i386: expose a "smbios-entry-point-type" PC machine property Message-ID: <20220106131534.423671-28-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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?LiBCZXJyYW5nw6k=?= , Eduardo Habkost , Richard Henderson , Paolo Bonzini , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476495525100001 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=3D64 Based on a patch submitted by Daniel Berrang=C3=A9. Signed-off-by: Daniel P. Berrang=C3=A9 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=C3=A9 --- 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" =20 #define HPET_INTCAP "hpet-intcap" =20 @@ -40,6 +41,7 @@ typedef struct PCMachineState { /* Configuration options: */ uint64_t max_ram_below_4g; OnOffAuto vmport; + SmbiosEntryPointType smbios_entry_point_type; =20 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 =3D value; } =20 +static void pc_machine_get_smbios_ep(Object *obj, Visitor *v, const char *= name, + void *opaque, Error **errp) +{ + PCMachineState *pcms =3D PC_MACHINE(obj); + SmbiosEntryPointType smbios_entry_point_type =3D pcms->smbios_entry_po= int_type; + + visit_type_SmbiosEntryPointType(v, name, &smbios_entry_point_type, err= p); +} + +static void pc_machine_set_smbios_ep(Object *obj, Visitor *v, const char *= name, + void *opaque, Error **errp) +{ + PCMachineState *pcms =3D PC_MACHINE(obj); + + visit_type_SmbiosEntryPointType(v, name, &pcms->smbios_entry_point_typ= e, 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 =3D ON_OFF_AUTO_OFF; #endif /* CONFIG_VMPORT */ pcms->max_ram_below_4g =3D 0; /* use default */ + pcms->smbios_entry_point_type =3D SMBIOS_ENTRY_POINT_TYPE_32; + /* acpi build is enabled by default if machine supports it */ pcms->acpi_build_enabled =3D PC_MACHINE_GET_CLASS(pcms)->has_acpi_buil= d; pcms->smbus_enabled =3D true; @@ -1756,6 +1776,12 @@ static void pc_machine_class_init(ObjectClass *oc, v= oid *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]"); } =20 static const TypeInfo pc_machine_info =3D { 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); } =20 /* 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); } =20 /* allocate ram and load rom/bios */ --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477151138518.357428136215; Thu, 6 Jan 2022 05:52:31 -0800 (PST) Received: from localhost ([::1]:56012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TBu-0002Nl-32 for importer@patchew.org; Thu, 06 Jan 2022 08:52:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SeE-00057v-6g for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SeB-0000ws-EC for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:41 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-cE_Z2cH1O7W63tThW1Btlw-1; Thu, 06 Jan 2022 08:17:38 -0500 Received: by mail-ed1-f72.google.com with SMTP id r8-20020a05640251c800b003f9a52daa3fso1892354edd.22 for ; Thu, 06 Jan 2022 05:17:37 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id r8sm714058edd.39.2022.01.06.05.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475058; 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=gG1BvchU0Sd+D1TNMUsEOsKCcQuhOWjG9TSlQf8yJQdnR+BOv1ZX2dhifcqckashm+yXye BhAmjTdhwnsn5nDtIBCdjEg0g9OwPRjRTbRT7W++Ru8gJq8zGfG6pAO1/c5qMH7P3Otk/I SWE7zjN5n9w17y+c3qjGi16I89oSA38= X-MC-Unique: cE_Z2cH1O7W63tThW1Btlw-1 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=Aa+3VWfRH7KlB28jVc3lOQPn8lvaKXsb++Icg+nVP13vxRqpDnH3FF3B6AdR7/HsvY bGIZC0wmai0vo/y1ww/LRDuhAxdOHC7xO4dcqqX13EVCab5x4WeytjDh/Wul8vl24OSV OjDL+LyueADSGeHRXKtTTwxcDmNU4HXkgS9aaEqqu46yxtp0OIgFZgZd7qbhzkWGWYbR eryeo7+PwyDtmVLcUise11BXxJ5RB4DH9nZiXgDYDrrkJBKeEHSMWfQWXR22mVUiMuYH WeuD0Hn4+r8JbJKJ5moVJHx7m3iTo9FKFdbhe6hkbnJNA7Pgn0DzrqpNWjjqqYBo89g+ 5ZBg== X-Gm-Message-State: AOAM531MRgUVHDXz+F6AB4SqcXEeVKM8Pf6qqXMh8qV5kVMNdvOp9r2T EbsHEgmVpknSZpVbS7PNj5/CqS0WDrVIrVGjk12skTi5qERQ1s6l17wnzPMo5DMmFyvydc9+PiA KNvjT30MaqDP71SIS2T6zUIwjl0IP/oQp79Oi8Wrm16Wtu7a7w5nFhILdQ3wI X-Received: by 2002:a17:907:3e0f:: with SMTP id hp15mr46818892ejc.432.1641475056459; Thu, 06 Jan 2022 05:17:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvlZDcCfBMW1I4RXynka/sjQCnouy/j+LHjpZ+DLjFSPuNP0HOr1FxdhOGq4VFBJ6uNK8BjA== X-Received: by 2002:a17:907:3e0f:: with SMTP id hp15mr46818869ejc.432.1641475056191; Thu, 06 Jan 2022 05:17:36 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 28/52] hw/vhost-user-blk: turn on VIRTIO_BLK_F_SIZE_MAX feature for virtio blk device Message-ID: <20220106131534.423671-29-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Raphael Norwitz , Hanna Reitz , Andy Pei Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477151698100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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(VirtIODevic= e *vdev, VHostUserBlk *s =3D VHOST_USER_BLK(vdev); =20 /* 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); --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476694324617.7047684590273; Thu, 6 Jan 2022 05:44:54 -0800 (PST) Received: from localhost ([::1]:38238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5T4V-000658-RD for importer@patchew.org; Thu, 06 Jan 2022 08:44:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5See-0005Ct-T1 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41179) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SeE-0000xb-Ly for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:17:44 -0500 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-528-7B_UgYl1O92_fQIZw0f-7Q-1; Thu, 06 Jan 2022 08:17:41 -0500 Received: by mail-ed1-f70.google.com with SMTP id w6-20020a05640234c600b003f916e1b615so1907843edc.17 for ; Thu, 06 Jan 2022 05:17:40 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id c30sm489068ejj.190.2022.01.06.05.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475062; 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=EljeNnqYEBK4HOcft2cQ3j2fsqc/nAZYQJvexfB5h/ZKPxEKAsPGysSnpL/ViYfkkvIZ3N abdkBOGTfBCqL9vkRA8OIdM5mCRa3w/oqaMyPhMbjyDSqazaLyipCb/TO0Ho0z4JxCrM60 m7VT6B7p7+YpZmfFL9+GYP9ILaBxBok= X-MC-Unique: 7B_UgYl1O92_fQIZw0f-7Q-1 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=V14AICx5T2b2w3Ak5MUSF2iZixVPhzxeHii9UH4xaMv486WlcQJimhxkS/1csyayqZ 7Gh9rR1VK8Y+i1+vPx1UwRCTByNQDC4suLctUgOcFRVdMDyIbYZYQEH6pmEkdIuyhXSi cFYOJwS8SAm4B171GHOCcsyGBl9yOogvM0AYjbI0caM0NYYKtNlgg0cuVXcKQNBSRNa0 6T1MoZ0JS0+TA1NXli6RFt4Z7Yqzs7hHFDvmPvDiAlnluO9Jbm4zBUGxNvY0HkRMhKBW sRV73LNQr4j6bxqnfrvNxuAS9QBOvmg3V1o6OdCYuO+sgU6cJaAD7WTK8CiAzFE2fsLb 1Ypg== X-Gm-Message-State: AOAM530+6HbJhTTEOMzncz/rV6izxZE8rQLD26egN/4TuDne3d7kGWix nVPSkD8j3sbGi88WBa5DIdm80+bJG0txN46mu8OGTCGbr98/hmbUABWbOXYBAMEZN3nDoI2kHRR nWBFrEKMntyao7x0h9ZyPNAKFC+TJe/gTKp4ehin1gwUri5WRfJLLeEVTpt/w X-Received: by 2002:a17:907:2ce6:: with SMTP id hz6mr18344588ejc.768.1641475059367; Thu, 06 Jan 2022 05:17:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQidv4rSnbEST2NRuFl2nxdgNe3FPfAieReUY8UdBEvHyovlvXKB2B46Xn5stAY6UjK+gu/Q== X-Received: by 2002:a17:907:2ce6:: with SMTP id hz6mr18344563ejc.768.1641475059009; Thu, 06 Jan 2022 05:17:39 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:36 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 29/52] util/oslib-posix: Let touch_all_pages() return an error Message-ID: <20220106131534.423671-30-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476696561100001 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=C3=A9 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; =20 static MemsetThread *memset_thread; static int memset_num_threads; -static bool memset_thread_failed; =20 static QemuMutex page_mutex; static QemuCond page_cond; @@ -452,6 +451,7 @@ static void *do_touch_pages(void *arg) { MemsetThread *memset_args =3D (MemsetThread *)arg; sigset_t set, oldset; + int ret =3D 0; =20 /* * 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); =20 if (sigsetjmp(memset_args->env, 1)) { - memset_thread_failed =3D true; + ret =3D -EFAULT; } else { char *addr =3D memset_args->addr; size_t numpages =3D 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; } =20 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; } =20 -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 =3D 0; size_t numpages_per_thread, leftover; + int ret =3D 0, i =3D 0; char *addr =3D area; - int i =3D 0; =20 if (g_once_init_enter(&initialized)) { qemu_mutex_init(&page_mutex); @@ -523,7 +523,6 @@ static bool touch_all_pages(char *area, size_t hpagesiz= e, size_t numpages, g_once_init_leave(&initialized, 1); } =20 - memset_thread_failed =3D false; threads_created_flag =3D false; memset_num_threads =3D get_memset_num_threads(smp_cpus); memset_thread =3D g_new0(MemsetThread, memset_num_threads); @@ -545,12 +544,16 @@ static bool touch_all_pages(char *area, size_t hpages= ize, size_t numpages, qemu_mutex_unlock(&page_mutex); =20 for (i =3D 0; i < memset_num_threads; i++) { - qemu_thread_join(&memset_thread[i].pgthread); + int tmp =3D (uintptr_t)qemu_thread_join(&memset_thread[i].pgthread= ); + + if (tmp) { + ret =3D tmp; + } } g_free(memset_thread); memset_thread =3D NULL; =20 - return memset_thread_failed; + return ret; } =20 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, } =20 /* 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 =3D touch_all_pages(area, hpagesize, numpages, smp_cpus); + if (ret) { + error_setg_errno(errp, -ret, + "os_mem_prealloc: preallocating memory failed"); } =20 ret =3D sigaction(SIGBUS, &oldact, NULL); --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476840972735.532239436628; Thu, 6 Jan 2022 05:47:20 -0800 (PST) Received: from localhost ([::1]:41734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5T6s-0000F6-UY for importer@patchew.org; Thu, 06 Jan 2022 08:47:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Seg-0005Cv-L4 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20971) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SeW-0000xl-78 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:10 -0500 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-660-s9-XuL5BPt2k4UgE2V6Y_w-1; Thu, 06 Jan 2022 08:17:45 -0500 Received: by mail-ed1-f71.google.com with SMTP id y10-20020a056402358a00b003f88b132849so1973506edc.0 for ; Thu, 06 Jan 2022 05:17:44 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id sc3sm491789ejc.93.2022.01.06.05.17.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475066; 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=VHN+imyg1pGnfTyul997/F4l99EItL0OpVbJWicbvwhUX2oAt4Xc2zbEBbbY1tH/uBuV6K H6VkEdZp66PVPsRZNAPO5sxXKujVfngRxlhNuEjI5GeLKHuoKQLQi6814mR0h+Qdlj8vHX ptkrw5/emyB6Jw+lPv7ua3KIHw9K/HU= X-MC-Unique: s9-XuL5BPt2k4UgE2V6Y_w-1 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=WlasRZYsSbGtupJmqMjJre2XMfH3VTcuJnVipKDnBPZgKJT9ljwqezrm+cJJPR85rL 7FsQ1y+CV5pHdj3Hl+NPcBbjZdZtTqLIjhFKIUbfZbaovX01hwVBfOpyN/X8XrOOj7i1 WCwS0cFXXddNhSiXbuIcV3P/PDt6vscEm9yO8Hhu7cP5dzCgzDU/nVphn/gUTpuqP6m6 5Q7fGBsW/Xe7fwgPNAhWEXpCYz/s+TscIxlcFTzATYAdfNoGjxcLAToW2FaX0RrNddyw 8vZ7IX8gAkr5hnAsByYljnbiZO11KYlS6v27ul6UoMDveOG84eeznk6d0verPBmMvsLe dlQw== X-Gm-Message-State: AOAM533syQBmxJQ0ma+GGtz/Z22GmXQZTBT7g7z7JkHZfonIpLwTTVxn xNKkei7wvjBNZq1cZznCLaRb3SLqeHLHkcA5KVWIquDFAKlDR8pfjjIzMK68MI0jDhEC467NlDI CHLmT09LICJPS1LJFYn1fIr8bGPukGHi/ZHSDedhSH0/Mq3oCR+5BNsyU7qxH X-Received: by 2002:a05:6402:1602:: with SMTP id f2mr4162001edv.80.1641475062507; Thu, 06 Jan 2022 05:17:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwN8PxHvlqMai4HfwFMywp65pvPEZnqJK5GbMh/1xSX9RQVhsT4usgzxPK3DE6+Fq8XDPZuXQ== X-Received: by 2002:a05:6402:1602:: with SMTP id f2mr4161967edv.80.1641475062236; Thu, 06 Jan 2022 05:17:42 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 30/52] util/oslib-posix: Support MADV_POPULATE_WRITE for os_mem_prealloc() Message-ID: <20220106131534.423671-31-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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?LiBCZXJyYW5nw6k=?= , David Hildenbrand , Michal Privoznik , Pankaj Gupta , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476843110100001 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=C3=A9 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 =20 #elif defined(CONFIG_POSIX_MADVISE) =20 @@ -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 =20 #else /* no-op */ =20 @@ -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 =20 #endif =20 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 =3D *addr; addr +=3D hpagesize; @@ -497,6 +493,26 @@ static void *do_touch_pages(void *arg) return (void *)(uintptr_t)ret; } =20 +static void *do_madv_populate_write_pages(void *arg) +{ + MemsetThread *memset_args =3D (MemsetThread *)arg; + const size_t size =3D memset_args->numpages * memset_args->hpagesize; + char * const addr =3D memset_args->addr; + int ret =3D 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 =3D -errno; + } + return (void *)(uintptr_t)ret; +} + static inline int get_memset_num_threads(int smp_cpus) { long host_procs =3D sysconf(_SC_NPROCESSORS_ONLN); @@ -510,10 +526,11 @@ static inline int get_memset_num_threads(int smp_cpus) } =20 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 =3D 0; size_t numpages_per_thread, leftover; + void *(*touch_fn)(void *); int ret =3D 0, i =3D 0; char *addr =3D area; =20 @@ -523,6 +540,12 @@ static int touch_all_pages(char *area, size_t hpagesiz= e, size_t numpages, g_once_init_leave(&initialized, 1); } =20 + if (use_madv_populate_write) { + touch_fn =3D do_madv_populate_write_pages; + } else { + touch_fn =3D do_touch_pages; + } + threads_created_flag =3D false; memset_num_threads =3D get_memset_num_threads(smp_cpus); memset_thread =3D 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 =3D numpages_per_thread + (i < leftover); memset_thread[i].hpagesize =3D 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 +=3D memset_thread[i].numpages * hpagesize; } @@ -556,6 +579,12 @@ static int touch_all_pages(char *area, size_t hpagesiz= e, size_t numpages, return ret; } =20 +static bool madv_populate_write_possible(char *area, size_t pagesize) +{ + return !qemu_madvise(area, pagesize, QEMU_MADV_POPULATE_WRITE) || + errno !=3D 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 memor= y, int smp_cpus, struct sigaction act, oldact; size_t hpagesize =3D qemu_fd_getpagesize(fd); size_t numpages =3D DIV_ROUND_UP(memory, hpagesize); + bool use_madv_populate_write; =20 - memset(&act, 0, sizeof(act)); - act.sa_handler =3D &sigbus_handler; - act.sa_flags =3D 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 =3D madv_populate_write_possible(area, hpagesi= ze); =20 - ret =3D 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 =3D &sigbus_handler; + act.sa_flags =3D 0; + + ret =3D sigaction(SIGBUS, &act, &oldact); + if (ret) { + error_setg_errno(errp, errno, + "os_mem_prealloc: failed to install signal handler"); + return; + } } =20 /* touch pages simultaneously */ - ret =3D touch_all_pages(area, hpagesize, numpages, smp_cpus); + ret =3D 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"); } =20 - ret =3D 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 =3D 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); + } } } =20 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641478089947914.043315697157; Thu, 6 Jan 2022 06:08:09 -0800 (PST) Received: from localhost ([::1]:40686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TR2-0005Cz-A2 for importer@patchew.org; Thu, 06 Jan 2022 09:08:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sel-0005Ly-2x for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24302) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Seh-0000y1-6B for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:14 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-628-yU0i45FxP9WXVASnIzULgQ-1; Thu, 06 Jan 2022 08:17:47 -0500 Received: by mail-ed1-f72.google.com with SMTP id g2-20020a056402424200b003f8ee03207eso1937988edb.7 for ; Thu, 06 Jan 2022 05:17:47 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id oz31sm488170ejc.35.2022.01.06.05.17.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475073; 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=SJG/vUWvYrP2OVXHr58DWwDiqBtqNoV0NWjgFbrFBGfSUCB/u8Loe7GIUR1x/uLyl0H6Wf IiVmgOUM3zCoM8y1zskDm6QNHWZhVaBsNZ/oPWxgTue630bnxBkeeqFHbG6kl2m1wLWYYe 9lWCwAG2aK16yv/vv8jPrewGuvZw8Vc= X-MC-Unique: yU0i45FxP9WXVASnIzULgQ-1 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=fkavEZ6nKa2/IfmikVHvZ95s3b66GiB2g9/B3xK6+lOCMJIDDE1SdJUtxzb5nj0VAk NkE/v6U49M/KhjmEJCZCgoLVeYnKRX0vawPZnn/qDABXLSO910UG1ucm3NTa+UfJ99db lnw4ZK2yo2BCyxo5p8WBKvgLLiWrbDRv9n/V9/2sykd1sbXUdxk4IGENFURoA0LDCtjI fuLAT4caZ7cmYRp3YFFAL3NWX5jG6c+H4LWJqP5RKytpknHy1wKXFAzJzZhRfwUxvecR ndgOwcvzFTE6Vqoou/s0F4jveN/AQk5scZq5FrJgrgac8cEemJIFie5aJztQnu31gElB 0zdQ== X-Gm-Message-State: AOAM532Kr2j8xRMTf/wTvBsMWwsut3V5KfZ2VY1+F5zO4IJRvTFvxhwX hc/xxjM3sn6iZ1vaMNV7WHCW97x6Xzd7cD+o96l/bKATjkSz79axIZe4WdeBV4X6WrmNI7YYi9A 3WpyfdUDE9iJcnimmLImQ2hCRRSPNsYTDvYE3KS98GLWsERXPv1U8XQIDtvIZ X-Received: by 2002:a17:907:6da2:: with SMTP id sb34mr45961670ejc.309.1641475065506; Thu, 06 Jan 2022 05:17:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJyclM1Fo9+Ne5S7PpD6Pgf+Ijxxc1OxYBZvrpHHOcerN9SJGqgE1t06uBih96hhzO7x0+E0Iw== X-Received: by 2002:a17:907:6da2:: with SMTP id sb34mr45961648ejc.309.1641475065226; Thu, 06 Jan 2022 05:17:45 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:42 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 31/52] util/oslib-posix: Introduce and use MemsetContext for touch_all_pages() Message-ID: <20220106131534.423671-32-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641478091205100001 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=C3=A9 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 @@ =20 #define MAX_MEM_PREALLOC_THREAD_COUNT 16 =20 +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; =20 -static MemsetThread *memset_thread; -static int memset_num_threads; +/* used by sigbus_handler() */ +static MemsetContext *sigbus_memset_context; =20 static QemuMutex page_mutex; static QemuCond page_cond; -static bool threads_created_flag; =20 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 =3D 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 =3D 0; i < sigbus_memset_context->num_threads; i++) { + MemsetThread *thread =3D &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) =20 /* 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 =3D 0; + MemsetContext context =3D { + .num_threads =3D get_memset_num_threads(smp_cpus), + }; size_t numpages_per_thread, leftover; void *(*touch_fn)(void *); int ret =3D 0, i =3D 0; @@ -546,35 +561,41 @@ static int touch_all_pages(char *area, size_t hpagesi= ze, size_t numpages, touch_fn =3D do_touch_pages; } =20 - threads_created_flag =3D false; - memset_num_threads =3D get_memset_num_threads(smp_cpus); - memset_thread =3D g_new0(MemsetThread, memset_num_threads); - numpages_per_thread =3D numpages / memset_num_threads; - leftover =3D numpages % memset_num_threads; - for (i =3D 0; i < memset_num_threads; i++) { - memset_thread[i].addr =3D addr; - memset_thread[i].numpages =3D numpages_per_thread + (i < leftover); - memset_thread[i].hpagesize =3D hpagesize; - qemu_thread_create(&memset_thread[i].pgthread, "touch_pages", - touch_fn, &memset_thread[i], + context.threads =3D g_new0(MemsetThread, context.num_threads); + numpages_per_thread =3D numpages / context.num_threads; + leftover =3D numpages % context.num_threads; + for (i =3D 0; i < context.num_threads; i++) { + context.threads[i].addr =3D addr; + context.threads[i].numpages =3D numpages_per_thread + (i < leftove= r); + context.threads[i].hpagesize =3D hpagesize; + context.threads[i].context =3D &context; + qemu_thread_create(&context.threads[i].pgthread, "touch_pages", + touch_fn, &context.threads[i], QEMU_THREAD_JOINABLE); - addr +=3D memset_thread[i].numpages * hpagesize; + addr +=3D context.threads[i].numpages * hpagesize; + } + + if (!use_madv_populate_write) { + sigbus_memset_context =3D &context; } =20 qemu_mutex_lock(&page_mutex); - threads_created_flag =3D true; + context.all_threads_created =3D true; qemu_cond_broadcast(&page_cond); qemu_mutex_unlock(&page_mutex); =20 - for (i =3D 0; i < memset_num_threads; i++) { - int tmp =3D (uintptr_t)qemu_thread_join(&memset_thread[i].pgthread= ); + for (i =3D 0; i < context.num_threads; i++) { + int tmp =3D (uintptr_t)qemu_thread_join(&context.threads[i].pgthre= ad); =20 if (tmp) { ret =3D tmp; } } - g_free(memset_thread); - memset_thread =3D NULL; + + if (!use_madv_populate_write) { + sigbus_memset_context =3D NULL; + } + g_free(context.threads); =20 return ret; } --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641478304073391.38122941156143; Thu, 6 Jan 2022 06:11:44 -0800 (PST) Received: from localhost ([::1]:49272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TUV-00035E-0U for importer@patchew.org; Thu, 06 Jan 2022 09:11:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sek-0005KH-MP for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37694) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Seg-0000xx-MY for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:13 -0500 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-88-moZtS6feOFiot9BTuS9TJA-1; Thu, 06 Jan 2022 08:17:51 -0500 Received: by mail-ed1-f71.google.com with SMTP id g11-20020a056402090b00b003f8fd1ac475so1950105edz.1 for ; Thu, 06 Jan 2022 05:17:51 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id dz8sm717935edb.29.2022.01.06.05.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475072; 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=MDIUKBX+9iDv8lADjowhdJFpMS7Luz9ms6FAtGL2ukoBxb7hwZhEQerOUExMaQOfereClz zlKxcKmALaF1RemyNNn9Aa2sFJDBf6XDlGAFSeE9ct2Ytx30sO4JQ7RU2+mTxtu5JUTZC/ dpOgJfsOv0I/Q9Hflm9jBosT501y0Wg= X-MC-Unique: moZtS6feOFiot9BTuS9TJA-1 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=KYgH8mbdh4VcrM2hOSAY0VzpUDwZrsGnYASK6KQncdbIbmbWEecOEWBtHDHTOl0rya 4C+A9EtIN20jDG5AEG/N5Y32yaDIibXmOy95vxasoQjqXQerS63b60/HomAb2dZ8uwbM XDsiS7drhQJVsd+VqmL3rfSY0JCrWOGXUK0cK0p962zYNmwt1lsPVPnmpHKAOtv/RG0d tezbaAV6fyqo+EuYDhRb3jF9FPjKCddSw2wrb6Ir5DaXkCr9AZlasX+4K5AzF9iOXfWh cLm938lygNn5kUcY87AeMHsiiMSbqzysKe1YE3JOk4KcTGYduq1SWcj/3xa56XDbBgqq G1Ig== X-Gm-Message-State: AOAM533a9fYfw9xs7ElDO0109T3JuS1Zq6/6L9H9+WRUhUOKA5BB/olQ uLZOsOfsge3Cn+1BRtLdk/Q//LCnGQnmBd2K7NIcNHxkwFRHJnjFkSc0N7lAAg1jQ/XwKUwq3Bn UAp3Ecv+Wh/kvZEsAt59v4vjLdUFcOb4FDN+BCUALFJ1WMJGQADAmSNXXgOE1 X-Received: by 2002:a17:907:6d20:: with SMTP id sa32mr47862757ejc.35.1641475068715; Thu, 06 Jan 2022 05:17:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwf0s9I5636gvk8wvszIwThJZ2kamXAkNntU11D8XvCCs40iQHj+DVLFyuPlYJKnXdydjH5NA== X-Received: by 2002:a17:907:6d20:: with SMTP id sa32mr47862735ejc.35.1641475068439; Thu, 06 Jan 2022 05:17:48 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:45 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 32/52] util/oslib-posix: Don't create too many threads with small memory or little pages Message-ID: <20220106131534.423671-33-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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?LiBCZXJyYW5nw6k=?= , David Hildenbrand , Michal Privoznik , Pankaj Gupta , "Dr . David Alan Gilbert" , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641478305626100001 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=C3=A9 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" =20 #ifdef CONFIG_LINUX #include @@ -525,7 +526,8 @@ static void *do_madv_populate_write_pages(void *arg) return (void *)(uintptr_t)ret; } =20 -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 =3D sysconf(_SC_NPROCESSORS_ONLN); int ret =3D 1; @@ -533,6 +535,12 @@ static inline int get_memset_num_threads(int smp_cpus) if (host_procs > 0) { ret =3D MIN(MIN(host_procs, MAX_MEM_PREALLOC_THREAD_COUNT), smp_cp= us); } + + /* Especially with gigantic pages, don't create more threads than page= s. */ + ret =3D MIN(ret, numpages); + /* Don't start threads to prealloc comparatively little memory. */ + ret =3D 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 =3D 0; MemsetContext context =3D { - .num_threads =3D get_memset_num_threads(smp_cpus), + .num_threads =3D get_memset_num_threads(hpagesize, numpages, smp_c= pus), }; size_t numpages_per_thread, leftover; void *(*touch_fn)(void *); --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477281653723.8983016442536; Thu, 6 Jan 2022 05:54:41 -0800 (PST) Received: from localhost ([::1]:36252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TE0-00083t-EY for importer@patchew.org; Thu, 06 Jan 2022 08:54:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Seh-0005EQ-Nh for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42411) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5See-0000y7-RV for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:11 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-137-85AJpeVDODuYn1uIhD_ubQ-1; Thu, 06 Jan 2022 08:17:54 -0500 Received: by mail-ed1-f72.google.com with SMTP id w6-20020a05640234c600b003f916e1b615so1908261edc.17 for ; Thu, 06 Jan 2022 05:17:54 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id dd5sm493669ejc.59.2022.01.06.05.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475075; 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=bfA5L1p1S3odbDxbXg4HyluEfyWgChYUw1WW2WLt8EmO3vjWgfIT8mGRciDHiGyrSrOrJ6 hnXdJTUIlrjfKf7cez1SWjc/yrzrPLGCaZ04/HQ7cvWkkqiGXm/1sySYiCtSE3vwm9bbGC 1LUEkTXHr2yD3t2Tuf7OiarDSh4OpXs= X-MC-Unique: 85AJpeVDODuYn1uIhD_ubQ-1 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=SJuxxUDj+OxMkc6bc18ZixUcxizyz2m+65rMh4ffmTNx28yymTxlKLY1CjFXkub/H0 Zxh29VvfoZdC10auNdMwTVHP+hz9H35fAN+YHiiBkdU/7rTjidUIhZqAb/bjC7ON6x6r Gg1Fq23QQBnhNV1ySyvELBWTG2p8vEUKPRKvU5cNCc/xwcAHTb5Gw65KXvWp0N3muvXk 0ohK7RYc8+TVVPEiL+9mqmvXHhSF/LdxQ1UojolDU9BSKRSsjcu0nogG/qP8PBZvxFNv qccHgfzBP7ZQxo3XQHGcs+IfvFGoqWG0dOLg4Uy36v2RjECZM758KwPWsT1s6K5NJKJh 6tsg== X-Gm-Message-State: AOAM530O/pzH5zOYXjdN3xvrl4TVQTd4m0rN4hLVTb6eNB1sMLoQK02i HToe3ScXwsm+FtAhLLUysD70zmBZAn13cbK3RU8RJLRO6GnmgmH2dCExCnTr9xNmgn5owYSZKdt HxJVkNjc30s7VMQ54I5TcDqH/hD5zMu+NIQzkbGnWEyWKysf5z2KPgPsn5U/9 X-Received: by 2002:a05:6402:3550:: with SMTP id f16mr46204017edd.407.1641475072583; Thu, 06 Jan 2022 05:17:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxREDbZk5jA/1xuBHLVkP+/BDMfcGBLL9VnltSxcOCOerNEjdHav9ANBPDfftC/Omv6L+0J7w== X-Received: by 2002:a05:6402:3550:: with SMTP id f16mr46203991edd.407.1641475072308; Thu, 06 Jan 2022 05:17:52 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:48 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 33/52] util/oslib-posix: Avoid creating a single thread with MADV_POPULATE_WRITE Message-ID: <20220106131534.423671-34-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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?LiBCZXJyYW5nw6k=?= , David Hildenbrand , Michal Privoznik , Pankaj Gupta , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477282785100001 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=C3=A9 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 hpagesiz= e, size_t numpages, } =20 if (use_madv_populate_write) { + /* Avoid creating a single thread for MADV_POPULATE_WRITE */ + if (context.num_threads =3D=3D 1) { + if (qemu_madvise(area, hpagesize * numpages, + QEMU_MADV_POPULATE_WRITE)) { + return -errno; + } + return 0; + } touch_fn =3D do_madv_populate_write_pages; } else { touch_fn =3D do_touch_pages; --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477192948133.48143984097453; Thu, 6 Jan 2022 05:53:12 -0800 (PST) Received: from localhost ([::1]:58546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TCZ-00045O-Qm for importer@patchew.org; Thu, 06 Jan 2022 08:53:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sej-0005Hc-LK for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Seg-0000z5-Ax for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:13 -0500 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-444-_VU8r7-MOJuF4l8ifr4aVA-1; Thu, 06 Jan 2022 08:17:58 -0500 Received: by mail-ed1-f71.google.com with SMTP id z10-20020a05640235ca00b003f8efab3342so1950559edc.2 for ; Thu, 06 Jan 2022 05:17:57 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id l16sm731820edb.3.2022.01.06.05.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475083; 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=PLrh0Z+vkWUEOP6Y0/qPzQ36x97Y9RwWwb9UVRa+OFazI9DE5OtnbZxLx3Kh7C1lQyc6rg WR/4pILYG9Vj6iellUEldC7m4M44z4gDyeS66eKnpBG7kTcWAwopbeNx2gg+msVfPM2AVQ nRmWsaj1B2ix7TPkl0jYavhvY6zULZw= X-MC-Unique: _VU8r7-MOJuF4l8ifr4aVA-1 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=GKjWxLRd40GYNIP9Jt3RbGU2Rtq9rDGxS6eCJNo7CobJnylqRx/ORDtYA7Xj1HJ9Th x5q3JzCtMMnRH4tWP7KgS28EhtON0ioCGasXamsIOBYl2S4UGTd+4KvRLIZyjn4gXWJy p3kSLytCog8rPspjgv56ZmwC2fPefpjgzWBvNGIbbWhsue96hyqW/IY7ZhjcJfqtSffj qn17xeTCWmguGG8BvH9MWqAmk2veFMLTHoGZ3LkMC4MirmCtEFetI9hYz4yYH7wJ6z1V e+gD3SLC5tOIoNZl3hetnvZTdlMp1C97yUd3i57e6P1AuUx5NX9W0iVs3PqKaJg/hv0C rhHA== X-Gm-Message-State: AOAM533u9UEpNlm1EGN4cs0ZjV4P0YjperxGhsGP+WiGAc0K1u+6tywY 0nz4Vg1bU3dzCGbcLSj7LN0F774Yt1hLXvTWVAM98CvNSPwFW6KQZ1h3jMNW/fNJy13rTLFtASt LIRyUySDqNFu7cdB0FDnY160A5+int2m44ky+pMhaFOGaA1ZusDW63GLiTyro X-Received: by 2002:a17:906:5509:: with SMTP id r9mr2334033ejp.389.1641475075804; Thu, 06 Jan 2022 05:17:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyY+U8jtuQeB1mop4I/8s59M7oPnHiG4RUQJAhAn0e9spoj3i4MKpGm9J2cy6ejJmfe4bXAcQ== X-Received: by 2002:a17:906:5509:: with SMTP id r9mr2334013ejp.389.1641475075612; Thu, 06 Jan 2022 05:17:55 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:52 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 34/52] util/oslib-posix: Support concurrent os_mem_prealloc() invocation Message-ID: <20220106131534.423671-35-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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?LiBCZXJyYW5nw6k=?= , David Hildenbrand , Michal Privoznik , Pankaj Gupta , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477193938100001 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=C3=A9 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; =20 /* used by sigbus_handler() */ static MemsetContext *sigbus_memset_context; +static QemuMutex sigbus_mutex; =20 static QemuMutex page_mutex; static QemuCond page_cond; @@ -625,6 +626,7 @@ static bool madv_populate_write_possible(char *area, si= ze_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 =3D 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 =3D madv_populate_write_possible(area, hpagesi= ze); =20 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 =3D &sigbus_handler; act.sa_flags =3D 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); } } =20 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477518279269.29459866781883; Thu, 6 Jan 2022 05:58:38 -0800 (PST) Received: from localhost ([::1]:44916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5THo-0005bs-Sc for importer@patchew.org; Thu, 06 Jan 2022 08:58:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Seh-0005ER-SN for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42125) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5See-0000yj-Jn for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:11 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-232-8tcRaFtENTm9_pwzR2wg0w-1; Thu, 06 Jan 2022 08:18:00 -0500 Received: by mail-ed1-f72.google.com with SMTP id i5-20020a05640242c500b003f84839a8c3so1939578edc.6 for ; Thu, 06 Jan 2022 05:18:00 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id 19sm485624ejv.207.2022.01.06.05.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:17:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475082; 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=kgzqJC25sNjBn6Va784JQ0lgK8k1CWrkfr62QAcjXXk=; b=AvoZFaNgz9kcS+0kk1XOlPe+idWzOnpD/dzNWLSWdzBBb8ygd3isc6Jx+U2XMtYGo3QtHs S4EWcNtbYkPO71IfFda1qCUJ4pl7+7QyNNN5BbiuvrI3BuHgE9wPgsyVQ4fjO4x0gFrRh1 yOtp8pWavF0e2iRLIDCGARZxGodvbZI= X-MC-Unique: 8tcRaFtENTm9_pwzR2wg0w-1 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=kgzqJC25sNjBn6Va784JQ0lgK8k1CWrkfr62QAcjXXk=; b=kZOuM6BAxsQjX9sz/clovrqqvgBPD4nMXawowXgXAdQuOWy8nU2wM/srj1HhTvIOAi OfucBZTnS8YooNW4VUxmiksxn+GAAjmHk32E2gy8Pg5au15e6ps3gLjj3PcfmbZ66bGq bblsobz/3u2Gb8PRj0K9KUMogNPY7bzOhLSPOjXHBDKwlLkSiPRSmr8tFGgfK7cCH87Q 9pNpf9DWtD2za0zCKDSDeQIntu/ZCKor8ZuOeJriK/KRmOWqzB/v7xYykYeZzWGElgC/ HI4qVDGoIrZeiE1YXp43DOQH9ClUEmIDcaN4Yz4a4tB34lu3niA7qeSzIlZQ3Ou/JZ2j 0aFg== X-Gm-Message-State: AOAM532qvQJmh73qHFHe5riyvI/TzLaWTZmiQp35UwsPMR+GMW8iAcT6 5PEgq+dmt13yMWjmFi5lnsH7+tesmuGHEBDSjwgqGg+e30YLx7AgkMVb8+P6Y9vBURxaD6Ic7nq 4H0RdCo0VmhLmhmKYu/QztoFWEFxKsc4tqSQkdg2gJOMzK8PDAgsyuTymVSFW X-Received: by 2002:a05:6402:3d9:: with SMTP id t25mr53473508edw.70.1641475079225; Thu, 06 Jan 2022 05:17:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPjMR5AVkYJgRCzkgs/UpOzT+Y5C8c8UQDOdFvfOBAiAVQLeAWYxQvEORf0FD4woHmtGJNQg== X-Received: by 2002:a05:6402:3d9:: with SMTP id t25mr53473480edw.70.1641475078900; Thu, 06 Jan 2022 05:17:58 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:55 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 35/52] util/oslib-posix: Forward SIGBUS to MCE handler under Linux Message-ID: <20220106131534.423671-36-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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?LiBCZXJyYW5nw6k=?= , David Hildenbrand , Michal Privoznik , Richard Henderson , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477519639100001 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=C3=A9 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 | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 37 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; =20 + /* + * 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 =3D SA_SIGINFO; action.sa_sigaction =3D sigbus_handler; diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 9829149e4b..5c47aa9cb7 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -95,6 +95,7 @@ typedef struct MemsetThread MemsetThread; =20 /* used by sigbus_handler() */ static MemsetContext *sigbus_memset_context; +struct sigaction sigbus_oldact; static QemuMutex sigbus_mutex; =20 static QemuMutex page_mutex; @@ -446,7 +447,11 @@ const char *qemu_get_exec_dir(void) return exec_dir; } =20 +#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; =20 @@ -459,6 +464,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 shoul= d 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 SI= GBUS + * 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"); } =20 static void *do_touch_pages(void *arg) @@ -628,10 +653,10 @@ void os_mem_prealloc(int fd, char *area, size_t memor= y, int smp_cpus, { static gsize initialized; int ret; - struct sigaction act, oldact; size_t hpagesize =3D qemu_fd_getpagesize(fd); size_t numpages =3D DIV_ROUND_UP(memory, hpagesize); bool use_madv_populate_write; + struct sigaction act; =20 /* * Sense on every invocation, as MADV_POPULATE_WRITE cannot be used for @@ -647,10 +672,15 @@ void os_mem_prealloc(int fd, char *area, size_t memor= y, int smp_cpus, =20 qemu_mutex_lock(&sigbus_mutex); memset(&act, 0, sizeof(act)); +#ifdef CONFIG_LINUX + act.sa_sigaction =3D &sigbus_handler; + act.sa_flags =3D SA_SIGINFO; +#else /* CONFIG_LINUX */ act.sa_handler =3D &sigbus_handler; act.sa_flags =3D 0; +#endif /* CONFIG_LINUX */ =20 - ret =3D sigaction(SIGBUS, &act, &oldact); + ret =3D sigaction(SIGBUS, &act, &sigbus_oldact); if (ret) { error_setg_errno(errp, errno, "os_mem_prealloc: failed to install signal handler"); @@ -667,7 +697,7 @@ void os_mem_prealloc(int fd, char *area, size_t memory,= int smp_cpus, } =20 if (!use_madv_populate_write) { - ret =3D sigaction(SIGBUS, &oldact, NULL); + ret =3D 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"); --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477880368620.3521279843437; Thu, 6 Jan 2022 06:04:40 -0800 (PST) Received: from localhost ([::1]:60446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TNf-0007oi-66 for importer@patchew.org; Thu, 06 Jan 2022 09:04:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sei-0005HZ-Vc for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31944) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Seg-0000z9-0K for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:12 -0500 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-269-uEGEdwzeO-2HTgphdNYYTw-1; Thu, 06 Jan 2022 08:18:03 -0500 Received: by mail-ed1-f69.google.com with SMTP id g11-20020a056402090b00b003f8fd1ac475so1950479edz.1 for ; Thu, 06 Jan 2022 05:18:03 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id q18sm23146eds.11.2022.01.06.05.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475084; 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=TFgihAcLUNcvMrQKwwkd3/C316hKPGpM3aHHUo+itgTrzoPY8uaCFg8IetNMhNfJ2mkjUS bFZ/W985hnjhZErmRWh9rdpGS2VSAK9gdPnQowNceVei42oisaFdSj/g5RjNcLeebjtKMe OM+nqz+/JP+23m3NX6eIbPVBtjhLkjE= X-MC-Unique: uEGEdwzeO-2HTgphdNYYTw-1 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=QxZKjdeyHOAzBUnkmNN3B/7AohLfDA1FwkT/KY4L/fRHKn8F7S5r84uki8dWVu/F+N 75j1pmsqbRmWzAjpD8NpZugmtCGVtJCHfgQ16XuwYjrrZOZUf70DJy9oR/KPokwf4fQV EUvpVRhvtSIFBJ4axdfOdwxqNpNsWiu8+Inr9i9I06SUqR487XLRbL00QmVJtr2m/UAj 4gwlNJY3TYzqrr3Dbj+SpMYveoCWdpQbKhEALF3EEdHk4zWeYBA4JNkscTv0ra8ya74l 14jgkLUDsIxUf/3AXO1ZeffGoeXpo7oICwL6NqJ2+tX+7/O4CeKA6QBHTnAy7C/UpqEf iP5g== X-Gm-Message-State: AOAM530x1lbtFOX/dMGKs7vTO8NW6tLPMMYewKoxzcqE/RSqCJjZjhJq xdSgG+RshKLWpRNc5mxeCySGTAyoSb6IMwD8TlL/WYUYgIoG+Yox+Xl7/jvAgYPQwhA1q5+SvpW Qjiw17KB67/7zsWCIySeEq9x+dbluff6FnTVIthRlnbIvN1vnuvSk4xgQE8tD X-Received: by 2002:a17:907:9810:: with SMTP id ji16mr44576245ejc.601.1641475081879; Thu, 06 Jan 2022 05:18:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwv/1mrShMtoH/JqlZzcUU6mgtQxhF+LCX8o5t9HQMs1Rs5GUac7JtM7HaSfWSIHqOjEfh5ow== X-Received: by 2002:a17:907:9810:: with SMTP id ji16mr44576229ejc.601.1641475081622; Thu, 06 Jan 2022 05:18:01 -0800 (PST) Date: Thu, 6 Jan 2022 08:17:59 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 36/52] virtio-mem: Support "prealloc=on" option Message-ID: <20220106131534.423671-37-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477882631100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=3Doff,prealloc=3Doff" = for the memory backend and "prealloc=3Don" 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" =20 struct VirtIOMEM { VirtIODevice parent_obj; @@ -62,6 +63,9 @@ struct VirtIOMEM { /* block size and alignment */ uint64_t block_size; =20 + /* whether to prealloc memory when plugging new blocks */ + bool prealloc; + /* notifiers to notify when "size" changes */ NotifierList size_change_notifiers; =20 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 =3D 0; + + if (vmem->prealloc) { + void *area =3D memory_region_get_ram_ptr(&vmem->memdev->mr) + = offset; + int fd =3D memory_region_get_fd(&vmem->memdev->mr); + Error *local_err =3D 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 =3D true; + } else { + error_free(local_err); + } + ret =3D -EBUSY; + } + } + if (!ret) { + ret =3D 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, si= ze); + 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[] =3D { 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(), --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476964085260.4725131924789; Thu, 6 Jan 2022 05:49:24 -0800 (PST) Received: from localhost ([::1]:50082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5T8t-0006LH-4S for importer@patchew.org; Thu, 06 Jan 2022 08:49:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sej-0005Ha-0c for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28960) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Seg-0000za-8L for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:12 -0500 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-98-_x3YPVmYMCyuPJ0aj-25TA-1; Thu, 06 Jan 2022 08:18:06 -0500 Received: by mail-ed1-f71.google.com with SMTP id q15-20020a056402518f00b003f87abf9c37so1911415edd.15 for ; Thu, 06 Jan 2022 05:18:06 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id p5sm709398edx.34.2022.01.06.05.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475088; 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=Edv9RffO+noJK3EimlBMr2p/cfgLjuXggK3NpyaueNTivMQZVOLZBvg6A6fd+s6Fuaym8Q 8FjWf9cMwm9wSF6qLMpZ8a+YRXZMXH00gttJQKGtmgWKL01kRzSfPUBTsPP2+e6BrOsmsP Ffg7h6GN60h4c5JrY9s5NFdKgRq9S7Y= X-MC-Unique: _x3YPVmYMCyuPJ0aj-25TA-1 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=Bg0hQSN8+bTpr0Cr6SjOzp9iOJnPhqQ4Y4nvSh+sNLIMxacQO9VL9Tk0ZLYfnfgr6T W0hsRwUHI3RhlnRAMIxIT8BciyTrvwf5hHpgI74V3+AZLPNQoJyZxMwFKBmSPdmINem9 0xXByZLppT2HuLTkVQZIm6l1mmYXXLGuWmqxluFLgPDEsgdneFhDScCa1YaKx6f+s13I vvkmR5Tx88k8ZJkQxy7y8SYbxUg0mbYJV6JTdR3uM6DtlrtUd6eICwCrfLYH99EMVd/5 kyUymF+yUfP/PRg9QNqUh5irjTmZ9hkaf+1zlwmF7VYM/SdZ2g+nRVmpzKVADPQt1982 DKCg== X-Gm-Message-State: AOAM532n/F+rultNBJk1f7A4JrrP8KY/q/kW8R0LIguKLikfbSwFRDzE dLyZQGMDmeCT8w1G+P5by8dt+HqkpSdiXLpdJvIyMFIT/AmSXXhumH/KKWOLPQ+AqJYSpKDyL7U O8re5JsOYA4IjPCtACRYTNceeEDbysinQCZJ6wm29nRYUsC63ywTKdi7m5wIQ X-Received: by 2002:a17:906:48c9:: with SMTP id d9mr46065692ejt.57.1641475084913; Thu, 06 Jan 2022 05:18:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPf/zbRaQEoZw4Ne3moE/IsL095GJEWzLHbM98YiFaE+NDk0hQt8DoarfwfI9eQ0NnI/Syng== X-Received: by 2002:a17:906:48c9:: with SMTP id d9mr46065675ejt.57.1641475084616; Thu, 06 Jan 2022 05:18:04 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 37/52] virtio: signal after wrapping packed used_idx Message-ID: <20220106131534.423671-38-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476966017100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 virt= queue 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, unsig= ned int count) if (vq->used_idx >=3D vq->vring.num) { vq->used_idx -=3D vq->vring.num; vq->used_wrap_counter ^=3D 1; + vq->signalled_used_valid =3D false; } } =20 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641476894225887.1455590098093; Thu, 6 Jan 2022 05:48:14 -0800 (PST) Received: from localhost ([::1]:46618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5T7l-0003qA-7G for importer@patchew.org; Thu, 06 Jan 2022 08:48:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Seo-0005Tj-3B for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42594) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sel-00011S-Mu for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:17 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-203-aWw69w76MAyrx208Wk3YMw-1; Thu, 06 Jan 2022 08:18:09 -0500 Received: by mail-ed1-f72.google.com with SMTP id i5-20020a05640242c500b003f84839a8c3so1939837edc.6 for ; Thu, 06 Jan 2022 05:18:09 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id hd43sm490979ejc.62.2022.01.06.05.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475095; 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=gX/Lz7dYpjLN3J3posaDK3jybhCeNx2nS3p8sqjKvdMgA9NOABnL+YDcxyjp6iPDqXYKjP axG5vhzTli5b9gB8i6MPYFGMzK71NsOcOv48XWRAkk9LW18k8BAJWSyH2AOLM2ubv5IlaJ bcFujJrOwr6SeYdlpJkqiNl/56svZgU= X-MC-Unique: aWw69w76MAyrx208Wk3YMw-1 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=Ny6soGs0lZgJHIRvvpsTfzbmcg4fdMataiA70Gbn1IiFs8nu5H1yzKz4nL5Wli/jiJ UzqqRet1yklBq3s3FGICNvLVV+ZUj0drpFv+divltYk7Ws+eO/gsv7L5CgEXuX8RSBnN v5U5BbSgBbL4uJANlFtERgbYjo2a3YmXDk1mkmbXxEX/i9tIYfUs7vB47Ajco/9duKU6 6V7qrqcfSqQOnnjS02FrkpSyLPwLgjmSh7CSaGdaJ/56ujQdfCMz26cEmOtmXHhpZDFA +BFd/OVn5Yo/h0FJ0l4QoOt3a9rHy/v+IDu3Iov5hxKcK4rNrKVHloyMGyChXrumyFPL JOtw== X-Gm-Message-State: AOAM531unJxCgAMIFWOZZaVsbyOqjusCr0B6yLd3U2jA401Z87qj2lVc +kni1/OXnqOl6tB1RsWKDfRn1JqXWIolUppUGUYAB/U74ibvo4Zv/+aOa7PnpqAzDwt3WMx1lhr O2OAEC5a80qg8zpuJHMizW7BdHorbzeTWOk6UpXG3e2nMPzyq9Dg8UT5WwQC0 X-Received: by 2002:aa7:cc10:: with SMTP id q16mr31853322edt.60.1641475087969; Thu, 06 Jan 2022 05:18:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHvUk+02uInteZne1RrGvuEwi1tewCxNY5TrNmbMMAenROgDb4odAJLu5nwZqEyjWpA/Mbdw== X-Received: by 2002:aa7:cc10:: with SMTP id q16mr31853301edt.60.1641475087815; Thu, 06 Jan 2022 05:18:07 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:04 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 38/52] MAINTAINERS: Add a separate entry for acpi/VIOT tables Message-ID: <20220106131534.423671-39-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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 , Jean-Philippe Brucker , Richard Henderson , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Ani Sinha , Alex =?utf-8?Q?Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641476895583100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 +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 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477127344656.1552980578255; Thu, 6 Jan 2022 05:52:07 -0800 (PST) Received: from localhost ([::1]:54944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TBV-0001UJ-Vy for importer@patchew.org; Thu, 06 Jan 2022 08:52:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Seo-0005Tk-3M for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51146) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sek-000112-Pb for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:16 -0500 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-536-HX-B3jJxMnqj1i5-Peeu3g-1; Thu, 06 Jan 2022 08:18:13 -0500 Received: by mail-ed1-f69.google.com with SMTP id r8-20020a05640251c800b003f9a52daa3fso1893462edd.22 for ; Thu, 06 Jan 2022 05:18:12 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id e16sm718122edu.15.2022.01.06.05.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475094; 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=U+ahPK1PE0vKqpqNNGQ8jxd3svegOkhy3s9IIRdIMPXhn5nraIGoGvrovihyVRuOPkrvSP HSthho9/VYgP0UgxeqshCCzzt8AlnsD3KQJZXBn+235CgdV+8n4vYPeXJiHV48Zzf83kS/ ANqF3pvMWWukdu5gJ2ehk8Ws0r/RRNw= X-MC-Unique: HX-B3jJxMnqj1i5-Peeu3g-1 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=44eSHiR8d0UK8Rj4OhCTs9X/R5p7Pd5XR1iie8pVVcfGF1fdoMldZQ3DIS1TtdG7Is E7AVllnl9yDGb6y4dSK3yh+9KGKRBPDZHxQ6jIvOIc9ZBZ0QmCw38OGKwpCCqIbco4Qn 5hRPwN2F2gzqwYZ6He1gKMyp9a8LQoHjnmKvKjBiJcR0oB5i+4vzKZYnB/nb+oYyo8RM 1cfuXZLvRJT8oYrhL1NefymWKRqSMmIFSmL9UYAuF9k8DokoML1O64RBzZ0apLk3Jrkx 6rG2rTRgixLCZgHnlWfS0Z3CJ0RWtiBpD2IWvZf5QIWGBySbjVpTxY2x8DUc+wv1YULv XVWQ== X-Gm-Message-State: AOAM530uHBUkZ/ZtJPW197Yj0s6LqDAR0KMmA6EKBfoBuJiy/rCTLlNz WE5nDa9kLDUhfUYp7MCAOFhjHNw/9hiErOcHMXkOp8QGQAANofyBvU2CMbyW38siEdEKxTZFEYo jzQpHnA0acyYUGBdqkcudy/vBPbVpkkXJgt5TJGasZG0QUWH8IF+DAWKSYz34 X-Received: by 2002:aa7:d394:: with SMTP id x20mr56883952edq.268.1641475091181; Thu, 06 Jan 2022 05:18:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+bhLporZPqSHYfBpgkUi+skSCtMwYsQmLQ0bq5r1abKVVkPkPKQRfFF7KJuhce8394VkvBQ== X-Received: by 2002:aa7:d394:: with SMTP id x20mr56883932edq.268.1641475090979; Thu, 06 Jan 2022 05:18:10 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:07 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 39/52] linux-headers: sync VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE Message-ID: <20220106131534.423671-40-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477129617100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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, becau= se + * 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 @@ =20 /* 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 =20 =20 /* --- virtio-mem: guest -> host requests --- */ --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477270736355.4791873642141; Thu, 6 Jan 2022 05:54:30 -0800 (PST) Received: from localhost ([::1]:35346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TDp-0007Ru-Mg for importer@patchew.org; Thu, 06 Jan 2022 08:54:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Ser-0005ZA-NT for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45685) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Seo-00011c-85 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:21 -0500 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-662-F-FiL-12NUGeQDlJT8FtQQ-1; Thu, 06 Jan 2022 08:18:16 -0500 Received: by mail-ed1-f70.google.com with SMTP id z8-20020a056402274800b003f8580bfb99so1925256edd.11 for ; Thu, 06 Jan 2022 05:18:16 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id nb20sm490403ejc.25.2022.01.06.05.18.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475097; 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=Yj8PF1T1NrEYgJ1hcQlPi54KvymigBErLePFdAB6ptwyBsO6q5/eWh0CLajaIS5wtfYGxn 2LoBRJo8vIN1dCbdgJ20PNlnqeGrIuew4bQ9H1ZAg8imCbKZPCbqAF+0et49AdHgGM3nNL /nfHIOu6ri94QPOYMHf2d08oSaXJA2Q= X-MC-Unique: F-FiL-12NUGeQDlJT8FtQQ-1 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=0pUCNwwVQzUWhpAP9D3Yvf8gkBgnGhwKZxNFtP3jdCG/HfIh2FQ7fo+uCAJoijJmk8 27nGgwROG89pkirn0Ei1mv8rLHo1EH4yjevPzWM1aTuozFBaim0FDoFpoGwfrciLM/sM v+s+Bv3QM9KildPC+mo15+7oJdo4n5+Utn7tSfunc/BoBOfto1Ygj1vMPAkEAWp5V3Ks Mhlo1rbIlG3a241ga9lX73J0eFcU8jCTqSFKZDVXhVf96lB5W0MKIT6yUvFVhtQiYLzV LjfPgLfDmUju1PNqUSK3gc0IbIszbQ9hqRvcrWA/QtaR22Z9tfMblG+U+ioDXonIdSJZ FWAw== X-Gm-Message-State: AOAM532aUQxxfRwWJPuZ/1xSfFlXmocoltwiRfk36PC0KFnRF1L8kqQx iCC0SgIQI4KhKL1KdUPlOeW5NycYhYXfLzPyz2vDoEQVX2vbNi/oRw5Nk/jyNKXN5+MJnIiasTk ORiOVuOZh+YaxkPVPdRcicYXzozwoOdDOkQK7jiCdhIV/SUVPPV6S85yIphEd X-Received: by 2002:aa7:cada:: with SMTP id l26mr58558347edt.376.1641475094587; Thu, 06 Jan 2022 05:18:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIuWa63AkiGd+uIlEGu1Ir7N4f4QArn3X47AGCGY0KF4VTe9MY/IM9F0aQfRvIoKM6qooHBQ== X-Received: by 2002:aa7:cada:: with SMTP id l26mr58558318edt.376.1641475094313; Thu, 06 Jan 2022 05:18:14 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:11 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 40/52] virtio-mem: Support VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE Message-ID: <20220106131534.423671-41-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477272697100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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" =20 struct VirtIOMEM { @@ -63,6 +64,13 @@ struct VirtIOMEM { /* block size and alignment */ uint64_t block_size; =20 + /* + * Whether we indicate VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE to the gues= t. + * 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; =20 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" =20 +/* + * We only had legacy x86 guests that did not support + * VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE. Other targets don't have legacy gu= ests. + */ +#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 tra= cking * 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); } =20 +#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) =3D=3D 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 =3D MACHINE(qdev_get_machine()); + VirtIOMEM *vmem =3D VIRTIO_MEM(vdev); =20 if (ms->numa_state) { #if defined(CONFIG_ACPI) virtio_add_feature(&features, VIRTIO_MEM_F_ACPI_PXM); #endif } + assert(vmem->unplugged_inaccessible !=3D ON_OFF_AUTO_AUTO); + if (vmem->unplugged_inaccessible =3D=3D ON_OFF_AUTO_ON) { + virtio_add_feature(&features, VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE); + } return features; } =20 +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 =3D VIRTIO_MEM(opaque); @@ -746,6 +781,29 @@ static void virtio_mem_device_realize(DeviceState *dev= , Error **errp) rb =3D vmem->memdev->mr.ram_block; page_size =3D qemu_ram_pagesize(rb); =20 +#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 =3D ON_OFF_AUTO_OFF; + } else { + vmem->unplugged_inaccessible =3D 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 doe= s" + " not support the shared zeropage.", + VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP); + } + break; + default: + break; + } +#else /* VIRTIO_MEM_HAS_LEGACY_GUESTS */ + vmem->unplugged_inaccessible =3D 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[] =3D { 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, VirtIO= MEM, + unplugged_inaccessible, ON_OFF_AUTO_OFF), +#endif DEFINE_PROP_END_OF_LIST(), }; =20 @@ -1279,6 +1341,7 @@ static void virtio_mem_class_init(ObjectClass *klass,= void *data) vdc->unrealize =3D virtio_mem_device_unrealize; vdc->get_config =3D virtio_mem_get_config; vdc->get_features =3D virtio_mem_get_features; + vdc->validate_features =3D virtio_mem_validate_features; vdc->vmsd =3D &vmstate_virtio_mem_device; =20 vmc->fill_device_info =3D virtio_mem_fill_device_info; --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477725586205.1768487844206; Thu, 6 Jan 2022 06:02:05 -0800 (PST) Received: from localhost ([::1]:53526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TLA-0002ya-DZ for importer@patchew.org; Thu, 06 Jan 2022 09:02:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sev-0005Zv-8s for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Ser-00013E-E9 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:23 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-106-TCqInghCNH6mWDow2XG1kw-1; Thu, 06 Jan 2022 08:18:19 -0500 Received: by mail-ed1-f72.google.com with SMTP id m8-20020a056402510800b003f9d22c4d48so1898098edd.21 for ; Thu, 06 Jan 2022 05:18:19 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id ne31sm492394ejc.48.2022.01.06.05.18.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475100; 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=PnAWB1gLmTImidPX80Q6Pz7kMf3Chy5OIPIaQvcyAxlUrSqTiOZtr9qtQWiYS4y3S0f7Ck M2s1GJAauxco5pHFs8ArdQQBBRL23AoNO5UnIpQ2/+2tYPTZxgQ0aBuoJWJ1ksimlyZmqw 5s/SdLAIPh6PN/YQVtiIpNOv9a/rDiE= X-MC-Unique: TCqInghCNH6mWDow2XG1kw-1 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=rDPqAd+FccE68eyKRXj44INxaqf1nFepHG/Tc883Zg7tD72K/7Xw5bJhcK7QI1MCaX i2expthsDvh9y2HqzPhOZj0gyr5onHi8EnpcYN6YeULui3ksvPOHXVppia3TLHRUq/lz DNm8ve4VkbHu6bVeEu+3MvrLHHrzJxhCSWQokrworWGk/5H0DoPaxYy5A+2jnlWPfXHm PIiLigib0YMsw//94XLV4b/fEPz3Q7oKk2yNFXsw734Z4hA/ipYDOX62pu9zsDAeMfGf Vfx0k5k2qHjSkd8O+lpABc/wezpvwp65LweF1sO6OEf6vvJEG9vsicim9D86/dorN5rz APiQ== X-Gm-Message-State: AOAM531jXLGcf/WeOpwrCw41f/zjq4B3IQKBip/3qAFMTINd8XAiEQEq yaBnicNB8b5cH6BL5D5KtEYE0TFaSQ0OavITKr1tz/Mi+co7E9nN1PZbFiHub3wSFtkr4wnI6zR 8xhBZdwh0199XdSDBYBGciU2OYX0qLsc7gU9T7x/HN5OFTnjh/pUhu9NrnR2C X-Received: by 2002:a17:907:94c2:: with SMTP id dn2mr47244646ejc.325.1641475097904; Thu, 06 Jan 2022 05:18:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBeQG6Mpq47DgwKVCL0FSawIspZqo9z1MivqJ6EczsW0hBH9PBQnGjwN/zQWnxS/4GtjC2KQ== X-Received: by 2002:a17:907:94c2:: with SMTP id dn2mr47244621ejc.325.1641475097539; Thu, 06 Jan 2022 05:18:17 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:14 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 41/52] virtio-mem: Set "unplugged-inaccessible=auto" for the 7.0 machine on x86 Message-ID: <20220106131534.423671-42-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477727015100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 -GlobalProperty pc_compat_6_2[] =3D {}; +GlobalProperty pc_compat_6_2[] =3D { + { "virtio-mem", "unplugged-inaccessible", "off" }, +}; const size_t pc_compat_6_2_len =3D G_N_ELEMENTS(pc_compat_6_2); =20 GlobalProperty pc_compat_6_1[] =3D { 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[] =3D { TYPE_MEMORY_BACKEND, HostMemoryBackend *), #if defined(VIRTIO_MEM_HAS_LEGACY_GUESTS) DEFINE_PROP_ON_OFF_AUTO(VIRTIO_MEM_UNPLUGGED_INACCESSIBLE_PROP, VirtIO= MEM, - unplugged_inaccessible, ON_OFF_AUTO_OFF), + unplugged_inaccessible, ON_OFF_AUTO_AUTO), #endif DEFINE_PROP_END_OF_LIST(), }; --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477348517754.4315173094805; Thu, 6 Jan 2022 05:55:48 -0800 (PST) Received: from localhost ([::1]:39144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TF5-0001Ys-Fc for importer@patchew.org; Thu, 06 Jan 2022 08:55:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sf3-0005bE-53 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51265) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sev-00013c-AA for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:31 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-172-OIYP1ub0MM2Orb9rLEdprg-1; Thu, 06 Jan 2022 08:18:23 -0500 Received: by mail-ed1-f72.google.com with SMTP id s7-20020a056402520700b003f841380832so1943185edd.5 for ; Thu, 06 Jan 2022 05:18:23 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id hp18sm491497ejc.40.2022.01.06.05.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475104; 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=O8dPLUslE/0unLcPKXkiRxa2qKFE7+mNJ/v/JQbJuYqElJa87gJkpWJxi6EKth/nzh4ZRO nyIFHlOkLaeYDdqIf4dqoUAVCmt+PJJl1scVdMgWB1KnWTXThneoOsxh/9XAzhbK13AbmQ QpWKZQsMx6NXtqPnWNItvJ7XMSAILbM= X-MC-Unique: OIYP1ub0MM2Orb9rLEdprg-1 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=CGagaV6VGBqE6veMeWk5Qk/dt4bXgSaurmr1q5D8K3LgXx9ZpjvqvcHGA1vwjfhA1/ E+NoRTUKYJW8lrUycGL+X9FsfNsphUnfkAhO1gDvPdGJb2JcrIse1IpX9mT6zFq30WcP FZi7BwySjGoA2GwdzVqb6JkIEzPX9NilhHRDnSMGm/eTNZv0h9WBQY5UDLumrGgOMbYr C9qSk5l4pcdC/NSSwc49rzDSX3wWsjYo8gQZezf9AfQWBjWydInHBGHOcxH1QUYdQlZ0 4Y6GaPpHJHbiyUecnGu85Nm/EXGsLCE+DX+bSc2IxZ2iCKfOPqXH9T6B357mVCTZ9qqa NKig== X-Gm-Message-State: AOAM5303U4pUcX638E+ofFMiH+W1BoyJKrQxnKiuS6sQycfqHl3b15+B 5pKd5RM4Ct/qfjwBbwpsjmPkw50brufVtIgQKnySZsRlqjYjYXuJC89oArXnKa3fgTfyMKHEtvY HpWjdBUMer3dT9vxacykR+bH1kbAJNgc7+VI5KYTwKjYjvM3XoQce+uEEMzdf X-Received: by 2002:a17:906:84f0:: with SMTP id zp16mr16694867ejb.477.1641475100940; Thu, 06 Jan 2022 05:18:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPUnwgn65YAkWJ6sYLc03ZLDGB/o1fNqLW+1zfUiFaZP0x2BVP2Ixt0HDamgiO92adHH0tzA== X-Received: by 2002:a17:906:84f0:: with SMTP id zp16mr16694840ejb.477.1641475100607; Thu, 06 Jan 2022 05:18:20 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 42/52] intel-iommu: correctly check passthrough during translation Message-ID: <20220106131534.423671-43-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477350015100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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(VTDAddressSpa= ce *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 =3D vtd_ce_get_rid2pasid_entry(s, ce, &pe); + if (ret) { + error_report_once("%s: vtd_ce_get_rid2pasid_entry error: %"PRI= d32, + __func__, ret); + return false; + } + return (VTD_PE_GET_TYPE(&pe) =3D=3D VTD_SM_PASID_ENTRY_PT); + } + + return (vtd_ce_get_type(ce) =3D=3D VTD_CONTEXT_TT_PASS_THROUGH); + +} + +static bool vtd_as_pt_enabled(VTDAddressSpace *as) { IntelIOMMUState *s; VTDContextEntry ce; - VTDPASIDEntry pe; int ret; =20 assert(as); @@ -1538,17 +1556,7 @@ static bool vtd_dev_pt_enabled(VTDAddressSpace *as) return false; } =20 - if (s->root_scalable) { - ret =3D vtd_ce_get_rid2pasid_entry(s, &ce, &pe); - if (ret) { - error_report_once("%s: vtd_ce_get_rid2pasid_entry error: %"PRI= d32, - __func__, ret); - return false; - } - return (VTD_PE_GET_TYPE(&pe) =3D=3D VTD_SM_PASID_ENTRY_PT); - } - - return (vtd_ce_get_type(&ce) =3D=3D VTD_CONTEXT_TT_PASS_THROUGH); + return vtd_dev_pt_enabled(s, &ce); } =20 /* Return whether the device is using IOMMU translation. */ @@ -1560,7 +1568,7 @@ static bool vtd_switch_address_space(VTDAddressSpace = *as) =20 assert(as); =20 - use_iommu =3D as->iommu_state->dmar_enabled && !vtd_dev_pt_enabled(as); + use_iommu =3D as->iommu_state->dmar_enabled && !vtd_as_pt_enabled(as); =20 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 *v= td_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) =3D=3D VTD_CONTEXT_TT_PASS_THROUGH) { + if (vtd_dev_pt_enabled(s, &ce)) { entry->iova =3D addr & VTD_PAGE_MASK_4K; entry->translated_addr =3D entry->iova; entry->addr_mask =3D ~VTD_PAGE_MASK_4K; --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16414779044752.1706948052736834; Thu, 6 Jan 2022 06:05:04 -0800 (PST) Received: from localhost ([::1]:34048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TO3-0000bO-8t for importer@patchew.org; Thu, 06 Jan 2022 09:05:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sf3-0005bF-7U for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:22003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sf0-00013x-Gq for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:32 -0500 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-17-23jAQoh_OsqeYbn8z7zOgA-1; Thu, 06 Jan 2022 08:18:28 -0500 Received: by mail-ed1-f69.google.com with SMTP id z3-20020a05640240c300b003f9154816ffso1916041edb.9 for ; Thu, 06 Jan 2022 05:18:27 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id nd10sm341644ejc.214.2022.01.06.05.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475109; 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=NS3LMpVQJgAbvMBKWo3PQZkUgVabZ0CSjmcrporpq6uyhNZGDuCS29VmZtV4aeTtmQLzEE QBckIihTu7AmN0AVCJiKMHP5QQUkW8biAYkFwOYSJgZzhmTjGGPjr7/w8KzZQJ/XBVtp1x 5QlsIXoFhCcA01r4oYqCVPhTgZbGLJ8= X-MC-Unique: 23jAQoh_OsqeYbn8z7zOgA-1 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=1bTP0EBJOP8Zy6m6hxpNnaFPuYSKb2HwheYSOHYoKTIUdRrh1H1NHA3KANIDNVa/az g1t1eqItsDaLX4G4E1rdWg2BAB7ZaLGttb4w/OUsXQwBcf9VtqdiXlK8AtzeKHkb2Js3 Gap16Pd+7GdbN3RsrMNq3Uh3/GblDIUjzK/cMOjUF8JITcY+iHJ++dvHPPpK+zjxu/pD cL8WrlPHZ4b8Wvl3orVxx3kU1pn21Sxiv8tsydUFCAfiYvqKt0XZr6eBES5SKmowvavk qat+5nKNaSZvh5Iod5SmGCFxqQrqjRCQ8kWu57YrrdgMdLZhv4B5RtDGiwRdk14D6EGA SBgA== X-Gm-Message-State: AOAM532NLW/zQh9j4Fpyq7ZkdQh9OEav+Faf9bI76yMhSsF0hkean74z 9x36rSQAB4oBcoTjr9vcXKlUlEschX3mbWo9CHu0hkN0Zz9NArSMfACmpfYJ/59JjDH0yByQwPT yx8fzmZxb5TTyJfGsegNseDYKAMrd4J7oUlMDbqqKBXIS51I2pgst0WAKEPkJ X-Received: by 2002:a17:907:7e95:: with SMTP id qb21mr48935227ejc.105.1641475104887; Thu, 06 Jan 2022 05:18:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJ1CA6Od+0OpgpKZI5gV+mXhFUKibP4Wbf2h/wcOGUt644WU3j7AQ6rZVSL19wCsJGGdEbdA== X-Received: by 2002:a17:907:7e95:: with SMTP id qb21mr48935200ejc.105.1641475104631; Thu, 06 Jan 2022 05:18:24 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:20 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 43/52] acpi: fix QEMU crash when started with SLIC table Message-ID: <20220106131534.423671-44-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477905331100001 From: Igor Mammedov if QEMU is started with used provided SLIC table blob, -acpitable sig=3DSLIC,oem_id=3D'CRASH ',oem_table_id=3D"ME",oem_rev=3D000= 02210,asl_compiler_id=3D"",asl_compiler_rev=3D00000000,data=3D/dev/null it will assert with: hw/acpi/aml-build.c:61:build_append_padded_str: assertion failed: (len <= =3D maxlen) and following backtrace: ... build_append_padded_str (array=3D0x555556afe320, str=3D0x555556afdb2e "CR= ASH ME", maxlen=3D0x6, pad=3D0x20) at hw/acpi/aml-build.c:61 acpi_table_begin (desc=3D0x7fffffffd1b0, array=3D0x555556afe320) at hw/ac= pi/aml-build.c:1727 build_fadt (tbl=3D0x555556afe320, linker=3D0x555557ca3830, f=3D0x7fffffff= d318, oem_id=3D0x555556afdb2e "CRASH ME", oem_table_id=3D0x555556afdb34 "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_e= nd() 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=C3=A9 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 =3D (void *)(u - sizeof(hdr->_length= )); =20 if (memcmp(hdr->sig, "SLIC", 4) =3D=3D 0) { - oem->id =3D hdr->oem_id; - oem->table_id =3D hdr->oem_table_id; + oem->id =3D g_strndup(hdr->oem_id, 6); + oem->table_id =3D 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) =20 /* Cleanup memory that's no longer used. */ g_array_free(table_offsets, true); + g_free(slic_oem.id); + g_free(slic_oem.table_id); } =20 static void acpi_ram_update(MemoryRegion *mr, GArray *data) --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641478377893510.8366954836307; Thu, 6 Jan 2022 06:12:57 -0800 (PST) Received: from localhost ([::1]:50932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TVg-0004HN-VM for importer@patchew.org; Thu, 06 Jan 2022 09:12:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sih-0003e9-PR for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:22:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60334) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SiV-0001r9-7y for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:22:18 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-201-pwHxoCrDNf-NSInD1Zgaig-1; Thu, 06 Jan 2022 08:22:03 -0500 Received: by mail-ed1-f72.google.com with SMTP id dz8-20020a0564021d4800b003f897935eb3so1934116edb.12 for ; Thu, 06 Jan 2022 05:22:03 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id h13sm705295edt.61.2022.01.06.05.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:22:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475324; 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=TpQgIXKn3VheZO/h2ZNmbAvWxiyXgLy8/33sYFE6AfcnAlnbVfA3qjGRB8qzAlt31W8msp p1WdKWLT4bOqzG5I2hy7x9vIkgpb9PfYkFwx7Zj6LvPzKgPnUjfl8AA/5tN48D4kF08g16 /GeDO+M0KA85ZBafb2+j3mePfjAufTk= X-MC-Unique: pwHxoCrDNf-NSInD1Zgaig-1 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=h8tx6ZkCnETl4UWhc9l5q0geLLDurh3hULpPjb8/VX687qsH+5Ok8/D2JEkILPlBBZ 30WaK+jQheFZS4YG170m5q4mdGnOHrBN81jwhhk6YGP2cAEqXAxQhCaLycH0GEsduVCQ jLbeczL6gw1z9GbqIiKB+cJie9BZ6IbpWadR9xB5bIvRofX4KHVcIf8FNWN5xsv2pVNH XBzGRtfdl7Z2jKDoGRghP+uDHyRmiC1vqHnt8LHYMfOZJd7QA9tGynj1ZQr8hZersGp3 OBjttjY7zmddyffjDJMpgSnQns54B+6xCrv+qS1kk4wbECE5w3gu6ibpw9ea0OQZjcyZ lTNA== X-Gm-Message-State: AOAM532i1bqvcErIh2SonZTIxn6FzVism8dTseHxAl/NBCuhXtVl47Dz b3+f+lKQmZkuN49wEcz2GvjqAyr6KxbS2IhzOnseQELFXUsQNpo496XiaEsQDSnTWemCYqCKvkJ M48T6SscFTUPss3JhaRLc1so59mxrZwJ466WDoAj9sQWpfO1MHO0vhe7oyCCN X-Received: by 2002:a17:907:97cf:: with SMTP id js15mr42375102ejc.16.1641475321799; Thu, 06 Jan 2022 05:22:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+rwhF4v1lSassPLfnrbLxdjxPZfHOHbVW/KKrKeXI9CqVIeNxC19JYwiJSPHNC4vJDhpdVw== X-Received: by 2002:a17:907:97cf:: with SMTP id js15mr42375070ejc.16.1641475321307; Thu, 06 Jan 2022 05:22:01 -0800 (PST) Date: Thu, 6 Jan 2022 08:21:58 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 44/52] tests: acpi: whitelist expected blobs before changing them Message-ID: <20220106131534.423671-45-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641478380410100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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..f6a864cc863c7763f6c09d3814a= d184a658fa0a0 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 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477987964995.747070068295; Thu, 6 Jan 2022 06:06:27 -0800 (PST) Received: from localhost ([::1]:37048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TPN-0002gz-Pt for importer@patchew.org; Thu, 06 Jan 2022 09:06:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Si1-00021n-2y for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:21:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56329) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Shx-0001k5-JG for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:21:36 -0500 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-613-kFqcSU8mPTyuzVh-hXh8EA-1; Thu, 06 Jan 2022 08:21:31 -0500 Received: by mail-ed1-f70.google.com with SMTP id r8-20020a05640251c800b003f9a52daa3fso1899832edd.22 for ; Thu, 06 Jan 2022 05:21:30 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id 1sm495764ejw.175.2022.01.06.05.21.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:21:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475292; 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=O35ivc9piKRw9gchywGYUbToBjI3CYXbEHGNWxhd4g6tCDX2aps842012PlRJti9Ak+eWH 0vASBY3OFix9AAxx+h/dXwPJoUNNo90i2VudSEg4rboQD3+7mMfkOynW3zQQ9UQ9bmQqWn JPzL7Xae9a+o3lStSNol3rr0vNCEaxE= X-MC-Unique: kFqcSU8mPTyuzVh-hXh8EA-1 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=H1Is0oxY9p4n+2nuc2Q8a9EW6Q3+fg9QHxhODfl6tcwp1VDxAEYFRLJIhlJPRLGkkW N6tkJpIxCSSZcD9SNFIAG3xvR/+3vN467HAcfaCOniRtxiL5x2Q0cJby31d5L0pGJAqI Wxl4XcOUM43Vv8ShY6T4AW8tAZYOfJN13JknvJtl0UWjqBGqYqxEbUajuJ6CIyHfNlm2 GbZvDcNuo5Lp1MQ7j5LTgheGv2PQq2xeOPsB+eUWK8lPl/K4QDRN9UCa0LyJQY7kZql4 lkD48KTtcGSdcnx+BFmD9asy7V0kAPyo4lF/FNRwaXVJ7kxrT/0NmRYqoAF6beRNyQQH dbug== X-Gm-Message-State: AOAM532IfnAkHMNlpbwkE0tN/MRyAhdunSd+nmLTffIQvadt9hWdrCuZ Rx94Qwq/bWUrjPiqV5ARtp5zAygE3uOrHL4AoypqL7lA3x8zweyeuB3d/5XLIgSF9x+gk/37NDj qdFBTBm0Pp/muG8FLkKFDwnte/Hwdbe9AcjAx8ipcclK5vg5HJJvZo4D+iU5g X-Received: by 2002:a17:906:824c:: with SMTP id f12mr29278169ejx.446.1641475289459; Thu, 06 Jan 2022 05:21:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/ZNX3yAvaKoCqrrRnbr6uzhwlwrcfAle9c46+RQ9p5Igo7wJXfsQmNrfEL65tjqqLOFy2oQ== X-Received: by 2002:a17:906:824c:: with SMTP id f12mr29278153ejx.446.1641475289218; Thu, 06 Jan 2022 05:21:29 -0800 (PST) Date: Thu, 6 Jan 2022 08:21:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 45/52] tests: acpi: add SLIC table test Message-ID: <20220106131534.423671-46-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477990091100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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); } =20 +static void test_acpi_q35_slic(void) +{ + test_data data =3D { + .machine =3D MACHINE_Q35, + .variant =3D ".slic", + }; + + test_acpi_one("-acpitable sig=3DSLIC,oem_id=3D'CRASH ',oem_table_id=3D= 'ME'," + "oem_rev=3D00002210,asl_compiler_id=3D'qemu'," + "asl_compiler_rev=3D00000000,data=3D/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") =3D=3D 0) { if (has_tcg) { qtest_add_func("acpi/virt", test_acpi_virt_tcg); --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477520594355.44685280871136; Thu, 6 Jan 2022 05:58:40 -0800 (PST) Received: from localhost ([::1]:45208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5THr-0005nQ-75 for importer@patchew.org; Thu, 06 Jan 2022 08:58:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sf8-0005fL-6i for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:49281) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sf6-00015O-H3 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:37 -0500 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-183-wJlr8IVpN1-ndcg6oxxEow-1; Thu, 06 Jan 2022 08:18:34 -0500 Received: by mail-ed1-f70.google.com with SMTP id o20-20020a056402439400b003f83cf1e472so1912097edc.18 for ; Thu, 06 Jan 2022 05:18:34 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id hb17sm482890ejc.195.2022.01.06.05.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475116; 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=Rk4t2P+6CkNHIqMdnaXTSlxdtIHKJBlNm7dWhBZySBxR2KGOIz45BGfon/zxSgl0fSESJL d3gI8FqFs8MPNyqUY5ub0jEZuSaE1tX4JNJA+m30d7c6r0FWgRYN83g0JZyFsCJLiPnmGG j2VRBaS16PmLyuuvqrhbCIEq3jFvTDc= X-MC-Unique: wJlr8IVpN1-ndcg6oxxEow-1 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=Xj0FoFEOCv3+1o9p2tejTKhvfLIApIbVTdUHTJlzjQ/gZyrym0weFdPsvssQBW5hXD v4IqDfdQWonp33pm9bKKItESusjttLC4gsAFPa73CC4sMQ0v5rMAb+3N2l9EYVZ4D4tn h4BrhfEXHGJ6GFD67mmSYpFuCnpL0L4Okgr//mNFfPd/xo9enFOO/xVmRydYR0CP5MCG 6jscRxMFany/fcnzULTLVnUc105Ah/pIs1d1/VhpJe7IQxlFqeV/M3cEHjNxs8zPnUZL JDdgamzJuq3SguSFD67qjFfF7eaGLmTHIAdkaY3KfQD4QLGSOzem3i44ELrJNQDkL9Ao zQUg== X-Gm-Message-State: AOAM5324m7Ow4JTiVuhea3k+J/VwHmy/F5qK+XO1z3PPDmn/5cg8g+0g XgloyHU5VnvpuhIMqq15XrDhONe3tfteV8mJ0AKas8ToPq5ZtmYXI3r66mo0SoIzV1okOIuEKJL qlZW/iumWULmwipxVsRrXA5MvIsk6vHQrxIdeN+OchspJWgPs+AtdVLozgQUy X-Received: by 2002:a05:6402:5202:: with SMTP id s2mr50905411edd.206.1641475113388; Thu, 06 Jan 2022 05:18:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfmCgocRcF1x2u5obTs7lGCOuLwsvamPeBIMVVJgfbFoD+3iGnirzo2Tt1GLBQ5LsDY/R87g== X-Received: by 2002:a05:6402:5202:: with SMTP id s2mr50905392edd.206.1641475113119; Thu, 06 Jan 2022 05:18:33 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:30 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 46/52] tests: acpi: SLIC: update expected blobs Message-ID: <20220106131534.423671-47-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477521745100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/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", diff --git a/tests/data/acpi/q35/FACP.slic b/tests/data/acpi/q35/FACP.slic index f6a864cc863c7763f6c09d3814ad184a658fa0a0..891fd4b784b7b6b3ea303976db7= ecd5b669bc84b 100644 GIT binary patch delta 28 jcmeyu_=3DQo#&CxmF3j+fKvygL;W3Y#Uud9N>M3Dyoc<=3D}c delta 28 jcmeyu_=3DQo#&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..fd26592e2480c5d02a018e0d855= a04106661a7b5 100644 GIT binary patch literal 36 mcmWIc@pM*UU|?YMbPjS1_E7M31#*C(gN1>iFg3Rn#0CI%)&>Cp literal 0 HcmV?d00001 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477745145737.5287414307322; Thu, 6 Jan 2022 06:02:25 -0800 (PST) Received: from localhost ([::1]:53908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TLT-0003F6-A0 for importer@patchew.org; Thu, 06 Jan 2022 09:02:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SfA-0005hb-NQ for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Sf9-00015o-5g for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:40 -0500 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-504-2eoWaVxtOGC2ENdDGGQilw-1; Thu, 06 Jan 2022 08:18:37 -0500 Received: by mail-ed1-f69.google.com with SMTP id d7-20020aa7ce07000000b003f84e9b9c2fso1936701edv.3 for ; Thu, 06 Jan 2022 05:18:37 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id f18sm178941edf.95.2022.01.06.05.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475118; 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=IuOslyxdPz2+ggLOizNnYUjgah65GTs1sZmlIeEhHkPBS/BB5bBUCpyuCjdxIyuC4V+KqH eOuNwbnNupbbggt6mcqNESqfA17OpduDG6aHEZBriob1SrVsc7oBqtVH1vcZdgZH2jSGBy O1JuwrWLZ/uqC0sQuzEaXgFfp+7Uuzs= X-MC-Unique: 2eoWaVxtOGC2ENdDGGQilw-1 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=BzlKVI/7bVWjDHy+/Y1n4Jly/2KdHAUXvFnB8JckmVh+qCocI5faK1lJKyzh0GIYAE va+2M5Ewytur6kdMrrnFFky9LfZsB3RpbgKM6Sw/HX9q8Y+exhT3z5BpZxjh8cyW7Z9w V3hfTsqQS3xOvI6o1VZXNM+sG2JPzYoW0aojW24Ss1FyCeZixzqIHBmSJuGBJ2je14NS uQkMaq5AbJJqAi4ZtCVADBp58lqot08ASqJCHCRuVrqzxP/e/pjooThiHEsgHNo9fbK+ TEQS8c5H6nBdBw60rsxmptLnlV3Jz5e3OIJDhup4H0t4STLUKVyeRdtYupI19m1HgYg/ wnXw== X-Gm-Message-State: AOAM533ZDbparVpJlq1lSzJ7BW4EMfBMOO+wwNucvrv26I1cXgFwzr/c ucqxEEg7zcppnUxhSGJHXhX3MffLDjy3MfPqaDmF/AI4KWNeBJ5z0InwZrroF6EVPEKzPj26xUa eorlPH9m8liK7IIcQe5jVJVkD/jaqx/hTTtmUvMbn/SHibK3pRN/Y9PpbIkMV X-Received: by 2002:a17:907:7289:: with SMTP id dt9mr37530517ejc.545.1641475116091; Thu, 06 Jan 2022 05:18:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyO+/xtQynjQQ88wDSi0wD7OJFaS1QKkNrcOCrIiaCdyUJWwmvVGb467lpN7xPyICUWYi/lVQ== X-Received: by 2002:a17:907:7289:: with SMTP id dt9mr37530497ejc.545.1641475115861; Thu, 06 Jan 2022 05:18:35 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 47/52] acpihp: simplify acpi_pcihp_disable_root_bus Message-ID: <20220106131534.423671-48-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477747030100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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) =20 static void acpi_pcihp_disable_root_bus(void) { - static bool root_hp_disabled; Object *host =3D acpi_get_i386_pci_host(); PCIBus *bus; =20 - if (root_hp_disabled) { - return; - } - bus =3D PCI_HOST_BRIDGE(host)->bus; - if (bus) { + if (bus && qbus_is_hotpluggable(BUS(bus))) { /* setting the hotplug handler to NULL makes the bus non-hotplugga= ble */ qbus_set_hotplug_handler(BUS(bus), NULL); } - root_hp_disabled =3D true; + return; } =20 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477549957732.7998999849933; Thu, 6 Jan 2022 05:59:09 -0800 (PST) Received: from localhost ([::1]:47982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TIL-0007eS-0n for importer@patchew.org; Thu, 06 Jan 2022 08:59:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SfE-0005rq-9p for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:51694) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SfC-000169-Le for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:43 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-103-D2o7fGFcPxGfMws7W_kq5g-1; Thu, 06 Jan 2022 08:18:41 -0500 Received: by mail-ed1-f72.google.com with SMTP id l14-20020aa7cace000000b003f7f8e1cbbdso1896530edt.20 for ; Thu, 06 Jan 2022 05:18:41 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id p5sm709870edx.34.2022.01.06.05.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475122; 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=HOosF8/wMpflCeuNtBBkhXP6IEwM3ryGmF14L4TM31VpMlSn+nO1vAia/x6cpEkQwJP1sF PSaR1xRUl24p4Xc5fsavdBr790h60B2mzPYwMahhUvQJVF2GSe7x9k5396fzxZj4mU5VtK ACoHDg1ENKNA9P3P8tBt0zxl+qTzC2s= X-MC-Unique: D2o7fGFcPxGfMws7W_kq5g-1 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=VmRFvS5m9oyA+gCAzdON+wrGVprEK5uVwevgda5w7+XEsdEPjdSDNyeREltv/Yda5K D4ZX555vUPeYjuDlTgEzDK3R3CyKxOKULo/Q+BM2/WL29y00sV2gU3pCTJa0qy93ETjK eATxT5raftIUad+myeL1HudVN5d+X63q60KbwiDJFFhOzH73ZLGbQM0Hx57ulsGyAy2U oBjH4Jo3jDChvAbOJdlYL2QnwClYGWd+Fib+4qGUS5H4C1w0ynzIOmj1HreUeLpXkMwv pVU8Vgz+7ZsZ7vHAS1waoFTORPBOR/52RR92PFc8/5qQwuT8rOQVKtBJ6sputhgUxxqc bSoA== X-Gm-Message-State: AOAM530to0idcrkXSdqzZkB0hgS3hV1s1B8Q5XDYXyntDUOBiesM9d8m ycBgB51Q2mT3ZpCX8L12/Agb90mPd/b1VCEefxdM0CfRsUEmb4F7Oeq0X5g+Dly/FNMXhAtnaWs l1ObNZbWZphG+SScWj/FwMLuZUj57d/hkSzcYwtfqyroExpF3fcSm0u5bMJFP X-Received: by 2002:a17:906:bc56:: with SMTP id s22mr1691504ejv.760.1641475119232; Thu, 06 Jan 2022 05:18:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/lqiSHjZAbh82+6Xt1SuftNhJlMkiJYGqL0+XMk6mx9vkxk9qNPKL8bwmVi07lJv+aRVwNQ== X-Received: by 2002:a17:906:bc56:: with SMTP id s22mr1691485ejv.760.1641475118999; Thu, 06 Jan 2022 05:18:38 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:35 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 48/52] hw/i386/pc: Add missing property descriptions Message-ID: <20220106131534.423671-49-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477551676100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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) =20 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"); =20 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"); =20 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"); =20 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"); =20 object_class_property_add_bool(oc, "default-bus-bypass-iommu", pc_machine_get_default_bus_bypass_iommu, --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641477814; cv=none; d=zohomail.com; s=zohoarc; b=Xi9yjGXKrfboZ3SK86JvvDGsqRaTvZtkam9XCr6EM3tsUovs1E4UA0P0n+/fFO8oePTTyueBkH4NsfmHMjjdCUmRG2aH046af6bgJEFyWc0wHyGyDmf5nLN1vO+ybrHCRxsjwn1UewuX/ZYsekSbOc72IAuXZP1PXGcWEWxhmj0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641477814; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=I9fRFWidMhAfy5/v5TIFdNUDGEE35GIYo1QYqVMvWCg=; b=mx+trgt6YOxUS7xnx8ef93oeJeZZbIpI8fs1PGPCEovexyRzXNrDCLtweu5ZV3r+ksGDKvwhmgAyKVJ10DZ9FBgwZbwccDjVu/BEh8wqoq0zF4+0ldMi8ZQZpaI1a6h/Z+iSL+dx0uSFuMIPCpQlRFR2g0nAztw24/RQAXFiflw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477814888993.6009478767393; Thu, 6 Jan 2022 06:03:34 -0800 (PST) Received: from localhost ([::1]:56708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TMa-0005Lm-2h for importer@patchew.org; Thu, 06 Jan 2022 09:03:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SfH-00061t-2N for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51576) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SfF-00016M-4w for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:46 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-528-f-1IaEWiNri-rZ43OOYbHw-1; Thu, 06 Jan 2022 08:18:43 -0500 Received: by mail-ed1-f72.google.com with SMTP id s7-20020a056402520700b003f841380832so1943726edd.5 for ; Thu, 06 Jan 2022 05:18:43 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id u1sm717985edp.19.2022.01.06.05.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475124; 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=Gd0S7oGtYildABLi/DEwY26s+yFLlT0jRzomQjRt+4XdpVXf9zfKnlL/lirVM8aBUFBdpH 95Ph0qO9pG2nhIxlRgx8MYC5OZTDbUwujjBKumdNELaEOtikpIGh4Gyy/XYX6ZILpQj6sG lRr9gptV8i2Ovp3GYbaIUC3ePoAUM0I= X-MC-Unique: f-1IaEWiNri-rZ43OOYbHw-1 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=W4/FSig3Z4nzKJKI55UVuD8Vf5lRUPoG+743w+GpT+8ymd3BaJnjDKDf1TuuvV+NMU sF4gTMoUNhRwICzsvgbLVu0+hN/PNjNbUjiov2VKNzX83Gh9GK13ugvO6HI0hfrFPBLX S0I7HSyYUdJSihQ37/OaGxiRFRYuHcsMkKQih+f6ROBoKveAaAXkiIl42GtUEX4dZHQy lp++WNd9nJBIaqIROoMSuHjG6foj+85cKlCq5tLYkpKjTMN1BIaUX103JOd52Bat8GRv lOmTAgW1Ijc1ty+HpfPq7JlhGJgh37c6y6sVBBQXhEQrIVC0r8F4ekf1TwqKrortJvqL B/sQ== X-Gm-Message-State: AOAM530MhcSSJWzhzufKHx67FFE0Y4OFiYY2Wb4riadin4slD96EJiDq rgeI45X6YDVyNv/MLKdfixiTm4G6ZSqyZIeKrBm/6oohRma1PdsnFRTB5pS4v0iNG41ddQW4bT5 1czT34OQHrpdF+xUXy6CCGV1p7ZlV+yEnKZZzCgmH7TcRARlKLP5DYfAusKZo X-Received: by 2002:a05:6402:40cf:: with SMTP id z15mr46148758edb.185.1641475121919; Thu, 06 Jan 2022 05:18:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJygyi6guFOxmx1MCKd+60wZsi6LhmkRgivrFv0zwezCpkmBOBXyiugFLzx4d+xEG+POFgbbLw== X-Received: by 2002:a05:6402:40cf:: with SMTP id z15mr46148735edb.185.1641475121614; Thu, 06 Jan 2022 05:18:41 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 49/52] docs: reSTify virtio-balloon-stats documentation and move to docs/interop Message-ID: <20220106131534.423671-50-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641477815784100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D> interop/virtio-balloon-stats.rs= t} (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 softwa= re. vhost-user vhost-user-gpu vhost-vdpa + virtio-balloon-stats diff --git a/docs/virtio-balloon-stats.txt b/docs/interop/virtio-balloon-st= ats.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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D =20 The virtio balloon driver supports guest memory statistics reporting. These @@ -9,10 +9,12 @@ Before querying the available stats, clients first have t= o enable polling. This is done by writing a time interval value (in seconds) to the guest-stats-polling-interval property. This value can be: =20 - > 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 =20 - 0 disables polling. Previous polled statistics are still valid and + 0 + disables polling. Previous polled statistics are still valid and can be queried. =20 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: =20 - 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: =20 @@ -37,7 +39,7 @@ which will return a dictionary containing: - stat-htlb-pgalloc - stat-htlb-pgfail =20 - 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 =20 -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. =20 -Enable polling with 2 seconds interval: +Enable polling with 2 seconds interval:: =20 -{ "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 } } =20 -{ "return": {} } + { "return": {} } =20 -Change polling to 10 seconds: +Change polling to 10 seconds:: =20 -{ "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 } } =20 -{ "return": {} } + { "return": {} } =20 -Get stats: +Get stats:: =20 -{ "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 } -} + } =20 -Disable polling: +Disable polling:: =20 -{ "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 } } =20 -{ "return": {} } + { "return": {} } --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641477989461710.6786694407646; Thu, 6 Jan 2022 06:06:29 -0800 (PST) Received: from localhost ([::1]:37218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TPQ-0002nN-H7 for importer@patchew.org; Thu, 06 Jan 2022 09:06:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SfJ-0006CY-Gh for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28904) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SfH-00016o-RB for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:49 -0500 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-582-6DLZ0N5mMlCXpVxo72tfiQ-1; Thu, 06 Jan 2022 08:18:46 -0500 Received: by mail-ed1-f70.google.com with SMTP id t1-20020a056402524100b003f8500f6e35so1942650edd.8 for ; Thu, 06 Jan 2022 05:18:46 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id gt7sm485315ejc.180.2022.01.06.05.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475127; 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=Yq8DksF0lLG6uDeRGqAbDBLZigpMSpRw06p20HgizEWES0m2q5sEt9xmdV/7nj1Tfb3Ope yhf25xiIwxysiRlSRwUd4YT9XUsMQ6z02Z3RypC/XqHruP25FWpBEJPq3RHgQN7fOCQG5R tieY0T1ahDRT2nJEQhMk328PkhD9gaE= X-MC-Unique: 6DLZ0N5mMlCXpVxo72tfiQ-1 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=Xq7KM5sB1lS04KDAo/RPM00p5IJf9khD1xt/OVHP5NgCTqnov4B5eSmzmA51lArAR/ 9XDh65VH+bVaSTRm6mZNO97O7BQhdJCAVvkSc6nuhykP6I9p6npfOfdmO/zxd+xj0oez O9AE0C6F8wHoHRT/SY76XvMgvw3cblx0K/H5j6vg2pSm/wQheCR48dnh3nH2n+jREUXm WnvdTsJGd4OYEmPpbXo/q2VBKTJMlpwCNJmhCdTs7QFD6jxz/rUKS22pTiLML4RMYv2r 5cNmOGhEyfzuaz+Q2H27mo5P6NiHITBHe0hHIzFA6P+1xeySu4AKOULUR7/wUNyQOOlE eqZA== X-Gm-Message-State: AOAM531ot7l7BTs/ZC0mHF5Ct8ouAf07MXllWjRqmvH1rE8WvkPkZ0be nrg8y/OW0UC2F6bGwAHflsSJUItZ4YedQN/FgUYrovlJkdM2OSpi0BTriGifpFB+teBRXuC8mxJ mgtswy/wnxmQwW2ZVYS2h7+CxMt8Ddk3lgOdFqzckUjJ5EHxWn3dcCmH8h31a X-Received: by 2002:a05:6402:4313:: with SMTP id m19mr58865620edc.326.1641475124847; Thu, 06 Jan 2022 05:18:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcKym7+U8HQPvOOeLrkMNfjmnVEqJ45KWASMV9GoRn4qZbFP/p8y0CGFvYFeDMsUOQaT4IuQ== X-Received: by 2002:a05:6402:4313:: with SMTP id m19mr58865594edc.326.1641475124674; Thu, 06 Jan 2022 05:18:44 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:41 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 50/52] hw/scsi/vhost-scsi: don't leak vqs on error Message-ID: <20220106131534.423671-51-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641477990325100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D NULL; int vhostfd =3D -1; int ret; + struct vhost_virtqueue *vqs =3D NULL; =20 if (!vs->conf.wwpn) { error_setg(errp, "vhost-scsi: missing wwpn"); @@ -213,7 +214,8 @@ static void vhost_scsi_realize(DeviceState *dev, Error = **errp) } =20 vsc->dev.nvqs =3D VHOST_SCSI_VQ_NUM_FIXED + vs->conf.num_queues; - vsc->dev.vqs =3D g_new0(struct vhost_virtqueue, vsc->dev.nvqs); + vqs =3D g_new0(struct vhost_virtqueue, vsc->dev.nvqs); + vsc->dev.vqs =3D vqs; vsc->dev.vq_index =3D 0; vsc->dev.backend_features =3D 0; =20 @@ -232,7 +234,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error = **errp) return; =20 free_vqs: - g_free(vsc->dev.vqs); + g_free(vqs); if (!vsc->migratable) { migrate_del_blocker(vsc->migration_blocker); } --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641478245078176.34176485839225; Thu, 6 Jan 2022 06:10:45 -0800 (PST) Received: from localhost ([::1]:45728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TTY-0000Pp-3i for importer@patchew.org; Thu, 06 Jan 2022 09:10:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SfM-0006O4-5X for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SfK-00017N-Hy for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:51 -0500 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-672-Sk6p2j8lM-20DYa8KcUEwA-1; Thu, 06 Jan 2022 08:18:49 -0500 Received: by mail-ed1-f69.google.com with SMTP id o20-20020a056402439400b003f83cf1e472so1912498edc.18 for ; Thu, 06 Jan 2022 05:18:48 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id r17sm500271eje.15.2022.01.06.05.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475130; 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=gmDsEo3v+Gy4/9YIc888wjuZy/kOQt048Nv6g+U5j4KjtDl0kwjiNFDQispOsabKZMmbqb UrzulOFAEZV07KFHRmEtJyTqQFTp9o9LXCHYS2phBdeArNM+WrxjBNrVI19N2xhSEop+Lz hnjIdeml8rcF3kxcecmfV1Dl9+IsRFM= X-MC-Unique: Sk6p2j8lM-20DYa8KcUEwA-1 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=zrhYOcmHXPP2ogPYa3myR2gkCAYbTAkalfA61DlidQ2EPG/aFyd3BQW8AlTHMOIZHG Zmv/XmW+VzPtW6P+x7GXdmcABc9eygJ9yv7ugzFb4AYZE3IQFtVXT7h1NswNJ4ABUcZQ OUkU6LFJgh+20O5Mzf5NnfjajqUDpdlXGw+ZLVWukA/dZkQwZqJbBsrZeQujwNWVfxNu dF9PKK5Qm3tOtIvitGaYZ2BCNCcUjrkEOjpaWZxRhrOVUN92/9aTX5sSH/O9Our9C/ol fX5T8ihxkkOZDUU9KFZ2jXqE54rDuetTgv7NlJJIdx1YYbdsuVSpIehbxrpwi5C8tRaq /1jQ== X-Gm-Message-State: AOAM531KhbAWQvFuQQUuOyyb9IO//7zSLPQRXTedD5p+D/WXPtimGFeZ GZq8Gif3BRjUWqsPkO3+/5TmYbeBoz4xx1xnsiqzdPL+kO75D+1nBIRrfJlQICD+iKz3gbAltG2 Lscm2Hr1ce+j+iIM6xxiyPvTa+gk1x7jjq6syKZ2z8pdw90BAfjMV58u1RHH/ X-Received: by 2002:a17:906:c144:: with SMTP id dp4mr46219824ejc.88.1641475127433; Thu, 06 Jan 2022 05:18:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMmPAqtaWaWqFOf9Q1kCxF0boyOH1N8Vl2Tewwfoih+wHwU4eX+kcn52fYCipQuWvJrpO5Ug== X-Received: by 2002:a17:906:c144:: with SMTP id dp4mr46219808ejc.88.1641475127199; Thu, 06 Jan 2022 05:18:47 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:44 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 51/52] hw/scsi/vhost-scsi: don't double close vhostfd on error Message-ID: <20220106131534.423671-52-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641478246942100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D 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 =3D -1; goto free_vqs; } =20 @@ -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 >=3D 0) { + close(vhostfd); + } return; } =20 --=20 MST From nobody Sat May 4 15:22:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641478478; cv=none; d=zohomail.com; s=zohoarc; b=P1zI7ClyudLiD6L1R9RiLQUFQ9wKbGB4oP0Ms7bVU18b036hoZSq7HpUflVKBPCgFk1bH+8Q8opSP78UY0VhYia63hmfqQJ1dm9JXDzGDPMBtk16kLZ7bLy8N6P21Z5eYia7o9eDwYjDg1zRMcmS3dSFNhr9A3WBC7tQvqec8Ak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641478478; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sZKl68SrJVJX9J/g8uBNG773VeE63EY7yyNvoTLPOxc=; b=UBn3SMMbAKDxvuu0oOGG3TacoswvNGKphYaQixiwz7yKe8AVB6G+JOPlsUuDDo232FMBdxbKnkqohtxkWKKC3gzHtMynaiiD8M051APLmYeKKNlCfJbqWzCyq81qA9lISAGpsCwbOXd9hOWWj/S7PNitcOT4nvG+eZpRQ67TOjo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641478478440109.76764010653528; Thu, 6 Jan 2022 06:14:38 -0800 (PST) Received: from localhost ([::1]:54274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TXJ-0007Ss-8X for importer@patchew.org; Thu, 06 Jan 2022 09:14:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SfO-0006aU-JT for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46938) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SfM-00017Z-Vl for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:54 -0500 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-654-ez0CdN6AOtGu0iODoSafSQ-1; Thu, 06 Jan 2022 08:18:51 -0500 Received: by mail-ed1-f69.google.com with SMTP id s7-20020a056402520700b003f841380832so1943968edd.5 for ; Thu, 06 Jan 2022 05:18:51 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id r17sm500302eje.15.2022.01.06.05.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475132; 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=Hvi0E7WsphqjpF9QUnaF6PTqvovzUacwpPtlMK+LSmB1qg5EGuOzdmvgn0BTyXRmJNj+ZP H71lqfOjUuURylh5FeEKOSzDSqUFOvLXx5hLdGCagfwZQckJkraogcGyiGBiivEeIJrPNW CVlHzgG5770z7+hp+wsbOZaZaCqbYlM= X-MC-Unique: ez0CdN6AOtGu0iODoSafSQ-1 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=ZSMnMDFb8l82fPZ4OSz6igbSi/NzvqkJ8wZzvyMiAAI32NZoHBiJqJXe7Zte4Wdj3B xRw9w1IObo8jiadgS8R05oSLUpm95dYOWNXdkcqywqKVPUaE9jLq2gTg3raRsA7W04Cv QKRE446IKda6plQ7bidy0PlmxlwooCkhzUqFUXjbyZnLzTm8cAV4vOaTScxilhKqrm5A TQgpdWSrRYWq1qJWIePFWH9DOMisb3s5tV826NkG4ElTudXd11UCInABjLtZBLBo1ldx DfLvUGGOFCJr8lOHMq/eWmZAU+fi99ByO34P0AnRLxKq3LZSbigkjIwDczJT4oO5x8xV HqIQ== X-Gm-Message-State: AOAM530mkQtUofH+x32eZR7qB8+IlAz2SVswSBxDdU/WK0z0pyVJXWR6 upFvYPVF5PdCKwMzFF0jzZdOwAKKd13J0d1INFO/FQlNMuYlCAjkAt2VDkjIDrpS3NI1QHiL70q B6fs2D44nDZ1LBpovkahNJGXsDo2Gz0cRN31VMtZgN4h6/4/BmPcrmoxvhj5t X-Received: by 2002:a05:6402:2793:: with SMTP id b19mr56255000ede.353.1641475130193; Thu, 06 Jan 2022 05:18:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcVtpDp46hIDOlR8avCRQF9fh5fJnT8Ik41AdP3NPm9WJosYtOZsntM1M73RJsXUEBeY5YFQ== X-Received: by 2002:a05:6402:2793:: with SMTP id b19mr56254976ede.353.1641475129917; Thu, 06 Jan 2022 05:18:49 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:47 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 52/52] virtio/vhost-vsock: don't double close vhostfd, remove redundant cleanup Message-ID: <20220106131534.423671-53-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641478479467100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 *de= v, Error **errp) ret =3D 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; } =20 @@ -183,15 +187,10 @@ static void vhost_vsock_device_realize(DeviceState *d= ev, Error **errp) return; =20 err_vhost_dev: - vhost_dev_cleanup(&vvc->vhost_dev); /* vhost_dev_cleanup() closes the vhostfd passed to vhost_dev_init() */ - vhostfd =3D -1; + vhost_dev_cleanup(&vvc->vhost_dev); err_virtio: vhost_vsock_common_unrealize(vdev); - if (vhostfd >=3D 0) { - close(vhostfd); - } - return; } =20 static void vhost_vsock_device_unrealize(DeviceState *dev) --=20 MST