From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465539; cv=none; d=zohomail.com; s=zohoarc; b=Oer4bmQ2oengKRE7rDG92wb/Ppxk1nb+x3kQakdk01dRaJtKr6ExFUjFFl4b1PdjTcxfBQHD3EjoGEFGY7QVcvCQpHpdVvsWWpKhaKG9TqI3d6QsJS/oM/GEM1TpXyIHDRI4M3EaIAbxQah2H0iFykGjvxb7lkfAp7tZ0J1rFD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465539; 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=h0heXC8AZt7eXzCvDvOmqsibMEQ+v+zzRIJ+pXZVz+w=; b=e4bL5nPNaGGWKTti/XMRwKIeqlLf9W62oxPmUOrVEkRU/FuDHXGzOL7oJX60YAL35Ys7bS0PUkI821aHWRic//5VMivznAYB+R/WZeeJmqdRS/jYfmFPzlfuinwOB1Z1ZLQKXlhzV92TaxujCuQwOyXo/W5XPmPaNbtiNT4AR6E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16044655395218.919569688151341; Tue, 3 Nov 2020 20:52:19 -0800 (PST) Received: from localhost ([::1]:34682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAmP-0006Xl-NM for importer@patchew.org; Tue, 03 Nov 2020 23:52:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAl1-0005Gx-HA for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:50:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31967) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAkz-0004G7-G1 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:50:50 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-91-mzhFKT23P-aRPJiB6CRmTw-1; Tue, 03 Nov 2020 23:50:47 -0500 Received: by mail-wr1-f71.google.com with SMTP id w3so6590269wrt.11 for ; Tue, 03 Nov 2020 20:50:47 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id q2sm881069wrw.40.2020.11.03.20.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:50:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465448; 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=h0heXC8AZt7eXzCvDvOmqsibMEQ+v+zzRIJ+pXZVz+w=; b=Mtv2DFmJVLZwa7O3SAkBYgj3z5YbvdqlbWzRVgUigCtclKYhoACFWZ1d/Vk9syQr7xyguD ngpmBFhSNnE9KkvqbbcSJ6BGYGqdOegEwR5C4OLub+olYDT7BPO64yzbCPVnKqeMSkCwCd vPlN4kOLnUosyzcO+Ou5MVmQq9j28P8= X-MC-Unique: mzhFKT23P-aRPJiB6CRmTw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=h0heXC8AZt7eXzCvDvOmqsibMEQ+v+zzRIJ+pXZVz+w=; b=G1eTEVq3RKi1bAqCSlkPopjHlk2mbN7fK1wTvz8SYUchCCV1dgAbQFYgs+RDi3DuuF BwlX1pmW7uJeMDMAWB282+kOUe5Bnu/sWl8g+OwpXInwCCmKxFS5Y3OuSzpcH4+QPSax P4EAe5dbA0RoboHU/BUncsPFtVvQFV40VxDiKrXdRcEguwk3vsMXy1rVPY0FSmZCVg8q 9iepAgioxNpyGU9O/esB65hereEiAx01WoGOefVIW22VVMbjsrM1YWamCoYlbdbA5IgJ pq+gikoqAlDIQ0T2r8YajrpBA+6WSlMXedS5P7hWrQDz9qq/etMBJ0qrXlWHXxvP9pJv WJVw== X-Gm-Message-State: AOAM531BsbQCVInANCQSUGm2b0dG5PAv07eAEnlludRpYp41ioYXAnOp rD1iRgxNR1lxFOl4xwjBntu+v5Noqqbr67TDye6Pqy6s3ZpjPDSYocCKplK/jLajxOQm73NiRYr t/GnzwBLaSSqg/R4= X-Received: by 2002:adf:f142:: with SMTP id y2mr29293504wro.160.1604465446226; Tue, 03 Nov 2020 20:50:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwR8fS79irP/yMcqEEsTB+znKS1JR1WXzlvmNG1CDNAANTzslmkfifgBTPhApTG3c0iiAJIPQ== X-Received: by 2002:adf:f142:: with SMTP id y2mr29293487wro.160.1604465446008; Tue, 03 Nov 2020 20:50:46 -0800 (PST) Date: Tue, 3 Nov 2020 23:50:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 01/38] pc: comment style fixup Message-ID: <20201104044937.226370-2-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Chen Qun , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Fix up checkpatch comment style warnings. Signed-off-by: Michael S. Tsirkin Reviewed-by: Chen Qun --- hw/i386/pc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 5e6c0023e0..17b514d1da 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1149,10 +1149,11 @@ void pc_basic_device_init(struct PCMachineState *pc= ms, error_report("couldn't create HPET device"); exit(1); } - /* For pc-piix-*, hpet's intcap is always IRQ2. For pc-q35-1.7 - * and earlier, use IRQ2 for compat. Otherwise, use IRQ16~23, - * IRQ8 and IRQ2. - */ + /* + * For pc-piix-*, hpet's intcap is always IRQ2. For pc-q35-1.7 and + * earlier, use IRQ2 for compat. Otherwise, use IRQ16~23, IRQ8 and + * IRQ2. + */ uint8_t compat =3D object_property_get_uint(OBJECT(hpet), HPET_INTCAP, NULL); if (!compat) { --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465626; cv=none; d=zohomail.com; s=zohoarc; b=jykE3evithZrs0BfoamaCPglY4TOdcMBZya10uonuxRlZ5oFIYZSzQnh8RROSTfn8n8NCkuIwKQmeI5iKx+DwwRgyrWT7ynQMLqViY6qxoHe5ETSnx3WbCOLNKcxdKIsuQTeopUj41vE8GZeFc0vDE7jtOqpmJuqyV/TbDTvN7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465626; 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=6mgCjhnq9faNGq2/uhjHeag8wnNyBtF7y3xz069QrTc=; b=YpAAAjUi/GBXEQot1PCkJMXUotUHqUB0u6TIJduMLd+ybVLKIw/5Z5u0sas2yXix9Vn+ZPAFphYm0Wu4g3ZJCOFvwWn8BGDMMD1Kn/OxSqQRQyoT6skRe6S5R9AR/F6tm3BFa6IqbCF8Fdxn8SWnAZnvdX6+d8O7b8nNSs1w7Mg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604465626718288.3145218797333; Tue, 3 Nov 2020 20:53:46 -0800 (PST) Received: from localhost ([::1]:43186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAnp-0001bb-J3 for importer@patchew.org; Tue, 03 Nov 2020 23:53:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAl5-0005KS-1e for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:50:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36797) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAl3-0004JW-9c for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:50:54 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-529-xURp4f9JOyqlChtYdOBphw-1; Tue, 03 Nov 2020 23:50:50 -0500 Received: by mail-wm1-f70.google.com with SMTP id f70so728307wme.7 for ; Tue, 03 Nov 2020 20:50:50 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id p4sm875018wrf.67.2020.11.03.20.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:50:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465452; 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=6mgCjhnq9faNGq2/uhjHeag8wnNyBtF7y3xz069QrTc=; b=Mfb+K0T4X1yqneAls8u2p2sQX5zbOhjI3WzZ21hYx9IJYu/EDTo3VU7L80iWw5wQRimIYl C5US478M/PrjosfHalV7aupC65WPPZDmEbGVMZxS1+XhgwsIfgsN2AJ8amKAW+dRlu3sG7 ijJqqkUDCoGOAXkE+cdq/0QjWL8DwPU= X-MC-Unique: xURp4f9JOyqlChtYdOBphw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6mgCjhnq9faNGq2/uhjHeag8wnNyBtF7y3xz069QrTc=; b=VoUJnYLrobDMMJ6/uPPvIhP4C73xnHIopbwtvjDe+uny2QkkNCezMWlSecQOKEMDKN wsGRi86/suXO0JsF8G6iqJ9HSfEXp1X+5v37QHSTRT5tLF8QLmDHl889ybLREPpR2hhE oo9iedNqf4G5sO5v2Hc2KXRXNN2Aq3o9UbQBCBU3vm7tAq0FTEoVEBgmAFx17XaqIiHk fN4Gf9MvOAr+fstaBX43hO8C1k8E6l+BReemzKf0Dca0wLH65m+8qpl7VkBnDIhKDlAZ +zXKfoVujsJZ2xI6K3CqX7NG3SWfFfJjQxFVuo06uRSY2fuaCs58fZsj0VfBXFYKGd1U 3oQg== X-Gm-Message-State: AOAM533GsOCZMmvZ/CEI14aDiFm/bN+iuFvFAyvmRFew+xJawoEWVW1v KTMOEbjjiG1JoIb7L4gj040QS1UFO7kphvkM1DcyX8sw680YYNLhnva0JW1kzvnvjSLXP4N4sk6 7mqad+eVwmR7rng8= X-Received: by 2002:a1c:1f05:: with SMTP id f5mr2378256wmf.98.1604465448952; Tue, 03 Nov 2020 20:50:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzh0SGYHFP/Z3qNjqEkjNqOznbpzFv8Y+lou3y7D4WNZCPT5TcCKgEgw55ihTcpgdYBpFmHeQ== X-Received: by 2002:a1c:1f05:: with SMTP id f5mr2378246wmf.98.1604465448818; Tue, 03 Nov 2020 20:50:48 -0800 (PST) Date: Tue, 3 Nov 2020 23:50:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 02/38] virtio-mem: Make sure "addr" is always multiples of the block size Message-ID: <20201104044937.226370-3-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Pankaj Gupta , David Hildenbrand , "Dr . David Alan Gilbert" , Wei Yang , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand The spec states: "The device MUST set addr, region_size, usable_region_size, plugged_size, requested_size to multiples of block_size." In some cases, we currently don't guarantee that for "addr": For example, when starting a VM with 4 GiB boot memory and a virtio-mem device with a block size of 2 GiB, "memaddr"/"addr" will be auto-assigned to 0x140000000 (5 GiB). We'll try to improve auto-assignment for memory devices next, to avoid bailing out in case memory device code selects a bad address. Note: The Linux driver doesn't support such big block sizes yet. Reviewed-by: Pankaj Gupta Fixes: 910b25766b33 ("virtio-mem: Paravirtualized memory hot(un)plug") Cc: "Michael S. Tsirkin" Cc: Wei Yang Cc: Dr. David Alan Gilbert Cc: Igor Mammedov Cc: Pankaj Gupta Signed-off-by: David Hildenbrand Message-Id: <20201008083029.9504-2-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 7c8ca9f28b..70200b4eac 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -449,6 +449,11 @@ static void virtio_mem_device_realize(DeviceState *dev= , Error **errp) ")", VIRTIO_MEM_REQUESTED_SIZE_PROP, VIRTIO_MEM_BLOCK_SIZE_PROP, vmem->block_size); return; + } else if (!QEMU_IS_ALIGNED(vmem->addr, vmem->block_size)) { + error_setg(errp, "'%s' property has to be multiples of '%s' (0x%" = PRIx64 + ")", VIRTIO_MEM_ADDR_PROP, VIRTIO_MEM_BLOCK_SIZE_PROP, + vmem->block_size); + return; } else if (!QEMU_IS_ALIGNED(memory_region_size(&vmem->memdev->mr), vmem->block_size)) { error_setg(errp, "'%s' property memdev size has to be multiples of" --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465783; cv=none; d=zohomail.com; s=zohoarc; b=Ho5yBhZVxOBY1VR3dwXBm1mM9EjhG9nZK4Pt4XsUTbK4H14noFATggLETX0VVwSZF6FXBwTmADwLoCAxppqiCRqcy+fLlcQZ9q6SQ+Cl6IvQW5bNpdaNge6RzSj6PBrUssz+z2WE6HrMC6B5AxbC6J+ihY/cza2bEhpYAmDXKO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465783; 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=aiHSSZpWVmtRhYn18w/DUuKk+CQD6Uz5cJmFPDvNuls=; b=Hxf4aX/mTybwOGwLuSOt+4c7jY5PgLLNuSCl07lWazeVULFhLFYPcuIyNdbK8E/48Bb8IT1GsTtv+U52g58AE5mSL4psQu2uQyqFNnyMMrLUwYNwFun3VpdNr89c7u5z8s6ddqTn38P4uzLehze1pAXFen5pgI/gkaXUoRWNG6Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604465783018887.9273179829565; Tue, 3 Nov 2020 20:56:23 -0800 (PST) Received: from localhost ([::1]:51646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAqL-0005BA-SO for importer@patchew.org; Tue, 03 Nov 2020 23:56:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAl9-0005To-Iw for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:50:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34578) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAl7-0004MV-Su for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:50:59 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-80-EXnVke99PNe2PjaGMcoKlg-1; Tue, 03 Nov 2020 23:50:54 -0500 Received: by mail-wr1-f72.google.com with SMTP id e11so1221718wrw.14 for ; Tue, 03 Nov 2020 20:50:52 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id j9sm859958wrp.59.2020.11.03.20.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:50:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465456; 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=aiHSSZpWVmtRhYn18w/DUuKk+CQD6Uz5cJmFPDvNuls=; b=XVdRFqo0Im53KZbAeyZkMjLckdirJs6harZaqtjthTHB/2QHyIDiJWeyM5RUpnjFzC5O/D uGqpszM1iroN2hMZgB6OiulWlnWjSOreTrYr2kuuJh/A3M42Kvk0rTNyTI7FsNoepfibWs I/XwzCv8mm3XUQ0QHB88kkX2TERLmU8= X-MC-Unique: EXnVke99PNe2PjaGMcoKlg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aiHSSZpWVmtRhYn18w/DUuKk+CQD6Uz5cJmFPDvNuls=; b=XyFzSy7CMqfWVjALXCaUpa6qdCYyR+o5LdNFKrA1wG7wVpaD92a3WzCHYSGRPKBrrc yknuVRL/C9ap/In7rXmAaDXsUDxdrY7HK/zmmyY6R+yGJpkOAmt/adGicR4sDlVDXc5W B/Yso+B8bbY0OgG0WYFhiINqRlE0m3h9ouzNUcLgGKQmew0p609VpKe0xsv+dOsDjihX 09Kgxk12+4bFWKgXc8A9/OgcDJWjXIsiUoK7UFx17yfI+SQDaOaOZ8RLrHnlS/wtmChW K3GF2Bs4sCDAstNpWtfwV6gjhKcPw8sLR4vwGweQDlVsIjvro9hQC4c8ikWTgl+I3i7s jm4A== X-Gm-Message-State: AOAM531x1Ks7uTrsQwXbv8feED5NyW5lKuwQjzVFNlpKU13qGbACWzr+ 8IghsAH5W465j+cvvzkxHuUou9CIWxChrL38UZ+R5ygRYpEgqWF5tlCbKGcUcCvI4HFQvACGVMw 7BvphxpVzePmsFCo= X-Received: by 2002:a5d:63cb:: with SMTP id c11mr28127011wrw.243.1604465451615; Tue, 03 Nov 2020 20:50:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWBU6G6H7aKVRlvxEpplsVFD3joQUH1nzVqW7v0tMF4otcMd0D9boa0u1yAv3wzU4S0mgeAg== X-Received: by 2002:a5d:63cb:: with SMTP id c11mr28127005wrw.243.1604465451504; Tue, 03 Nov 2020 20:50:51 -0800 (PST) Date: Tue, 3 Nov 2020 23:50:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 03/38] virtio-mem: Make sure "usable_region_size" is always multiples of the block size Message-ID: <20201104044937.226370-4-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Pankaj Gupta , David Hildenbrand , "Dr . David Alan Gilbert" , Wei Yang , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand The spec states: "The device MUST set addr, region_size, usable_region_size, plugged_size, requested_size to multiples of block_size." With block sizes > 256MB, we currently wouldn't guarantee that for the usable_region_size. Note that we cannot exceed the region_size, as we already enforce the alignment there properly. Fixes: 910b25766b33 ("virtio-mem: Paravirtualized memory hot(un)plug") Cc: "Michael S. Tsirkin" Cc: Wei Yang Cc: Dr. David Alan Gilbert Cc: Igor Mammedov Cc: Pankaj Gupta Signed-off-by: David Hildenbrand Message-Id: <20201008083029.9504-3-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 70200b4eac..461ac68ee8 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -227,6 +227,9 @@ static void virtio_mem_resize_usable_region(VirtIOMEM *= vmem, uint64_t newsize =3D MIN(memory_region_size(&vmem->memdev->mr), requested_size + VIRTIO_MEM_USABLE_EXTENT); =20 + /* The usable region size always has to be multiples of the block size= . */ + newsize =3D QEMU_ALIGN_UP(newsize, vmem->block_size); + if (!requested_size) { newsize =3D 0; } --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465934; cv=none; d=zohomail.com; s=zohoarc; b=Lf3LY8NjzTIWhlOhm/e5U8NEg/nmNCwDuukDq2E0k9C0zfxc5ZR+3+chebahrtdYbEOCUAgr5vi73lBRgzMsGZ4FeY4sE19u2X4yGpgWfo+Unf7v5aoN5LQKqMAqOUqnqUDsamC6WRJe4lH0/bCgYJXcWrs02bdZcfiAD9gLxBY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465934; 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=Bbvtq4HGVJ/wSfBQLsW+iRV9/tlIpRrNFHMItefyjY8=; b=H7MFZra1f+G1Cl5MGBKtsm88zUUeah/EWCTS8Cc6dW8+1lQIoPe3Q+GD/WoNQPnpIM51YrTltU+e8d+mBFpKlUzymxCLl7eyr9AwRYhtWmHHMKEsEifTrkKp4MJ0WnV7vlLyGo1qpZhku3gXrh9MRalGF7+KktkU+lEpB8y3i3k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604465934695680.3571810135837; Tue, 3 Nov 2020 20:58:54 -0800 (PST) Received: from localhost ([::1]:60160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAsn-00009s-Dd for importer@patchew.org; Tue, 03 Nov 2020 23:58:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAlA-0005Va-Ij for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56364) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAl8-0004Mc-Hv for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:00 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-593-_Zba1jBtPzWzgHAE7nkH1g-1; Tue, 03 Nov 2020 23:50:56 -0500 Received: by mail-wr1-f70.google.com with SMTP id m20so8736419wrb.21 for ; Tue, 03 Nov 2020 20:50:56 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id b5sm820732wrs.97.2020.11.03.20.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:50:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465457; 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=Bbvtq4HGVJ/wSfBQLsW+iRV9/tlIpRrNFHMItefyjY8=; b=PFWwhHfiHsBK5mjQvoDtLR0SPDVb+Ex6O7sB3WKGxrk/DeSPMNj4POOBZV8P6KNYarDAEV pIsK910/tw4SyjMzHsA0K/YkzKMzWNzzHZral5Gg5B9J0FCKwjjcpbrWnoQEb+ib4NvgFr bg/zr6QHLdQ7Akxcnh0F894CyUF2L9s= X-MC-Unique: _Zba1jBtPzWzgHAE7nkH1g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Bbvtq4HGVJ/wSfBQLsW+iRV9/tlIpRrNFHMItefyjY8=; b=a32hBMddAtUzGlnPjrXVE+AjWiW/TKL15ITIu9KBbRStBesTID5KctgYDnHoUkaosk v6h6Owh5wgdku8mlUwf37f5MFt9rw/yJwaSo1l1V5RxfZerncGby0eX46x7s9h7LsJOC gLhaC8LMHunIlYTpsX6jJvhrdD8FippreWthyTtdSJutTDCollr/hiOzXbc6gUx1W6h/ 7YeNyTYBPK5b4eUctetB3PJRATAbtT79BXtJCSqyKs5ylMBOYpurzgKCOTzFd3MGyyFz kgLZxB4fut5kYQCma56mOdYq1v3/ZBZ2gfcpCowwYE1NmIfWGsrElxeFUXPBxMMdN3wQ /saw== X-Gm-Message-State: AOAM530y2WToVb8aQfyRIR9FFef1xX40h37giB298XXVPvcTZpekPBdX /aYl5BAr4L+jqcBXS0eLnSQbKJV0YjibXUEqQYTimZ4jJ07Dj/obwQ/Zy8VsrPSJ1SCRQkZ4Hvp 7YJcwsRX+12Q12/U= X-Received: by 2002:a1c:bcd6:: with SMTP id m205mr2364010wmf.47.1604465454957; Tue, 03 Nov 2020 20:50:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOxRbTVqdBUveCQH8FQrRepUEeeNdF1aKWTjm86UoIM4931kx3QFE5sm6Tz1GOxjpK11sGLA== X-Received: by 2002:a1c:bcd6:: with SMTP id m205mr2363998wmf.47.1604465454793; Tue, 03 Nov 2020 20:50:54 -0800 (PST) Date: Tue, 3 Nov 2020 23:50:51 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 04/38] virtio-mem: Probe THP size to determine default block size Message-ID: <20201104044937.226370-5-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Pankaj Gupta , David Hildenbrand , "Dr . David Alan Gilbert" , Wei Yang , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Let's allow a minimum block size of 1 MiB in all configurations. Select the default block size based on - The page size of the memory backend. - The THP size if the memory backend size corresponds to the real host page size. - The global minimum of 1 MiB. and warn if something smaller is configured by the user. VIRTIO_MEM only supports Linux (depends on LINUX), so we can probe the THP size unconditionally. For now we only support virtio-mem on x86-64 - there isn't a user-visible change (x86-64 only supports 2 MiB THP on the PMD level) - the default was, and will be 2 MiB. If we ever have THP on the PUD level (e.g., 1 GiB THP on x86-64), we expect it to be more transparent - e.g., to only optimize fully populated ranges unless explicitly told /configured otherwise (in contrast to PMD THP). Reviewed-by: Pankaj Gupta Cc: "Michael S. Tsirkin" Cc: Wei Yang Cc: Dr. David Alan Gilbert Cc: Igor Mammedov Cc: Pankaj Gupta Signed-off-by: David Hildenbrand Message-Id: <20201008083029.9504-4-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mem.c | 105 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 4 deletions(-) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 461ac68ee8..655824ff81 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -33,10 +33,83 @@ #include "trace.h" =20 /* - * Use QEMU_VMALLOC_ALIGN, so no THP will have to be split when unplugging - * memory (e.g., 2MB on x86_64). + * Let's not allow blocks smaller than 1 MiB, for example, to keep the tra= cking + * bitmap small. */ -#define VIRTIO_MEM_MIN_BLOCK_SIZE ((uint32_t)QEMU_VMALLOC_ALIGN) +#define VIRTIO_MEM_MIN_BLOCK_SIZE ((uint32_t)(1 * MiB)) + +#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ + defined(__powerpc64__) +#define VIRTIO_MEM_DEFAULT_THP_SIZE ((uint32_t)(2 * MiB)) +#else + /* fallback to 1 MiB (e.g., the THP size on s390x) */ +#define VIRTIO_MEM_DEFAULT_THP_SIZE VIRTIO_MEM_MIN_BLOCK_SIZE +#endif + +/* + * We want to have a reasonable default block size such that + * 1. We avoid splitting THPs when unplugging memory, which degrades + * performance. + * 2. We avoid placing THPs for plugged blocks that also cover unplugged + * blocks. + * + * The actual THP size might differ between Linux kernels, so we try to pr= obe + * it. In the future (if we ever run into issues regarding 2.), we might w= ant + * to disable THP in case we fail to properly probe the THP size, or if the + * block size is configured smaller than the THP size. + */ +static uint32_t thp_size; + +#define HPAGE_PMD_SIZE_PATH "/sys/kernel/mm/transparent_hugepage/hpage_pmd= _size" +static uint32_t virtio_mem_thp_size(void) +{ + gchar *content =3D NULL; + const char *endptr; + uint64_t tmp; + + if (thp_size) { + return thp_size; + } + + /* + * Try to probe the actual THP size, fallback to (sane but eventually + * incorrect) default sizes. + */ + if (g_file_get_contents(HPAGE_PMD_SIZE_PATH, &content, NULL, NULL) && + !qemu_strtou64(content, &endptr, 0, &tmp) && + (!endptr || *endptr =3D=3D '\n')) { + /* + * Sanity-check the value, if it's too big (e.g., aarch64 with 64k= base + * pages) or weird, fallback to something smaller. + */ + if (!tmp || !is_power_of_2(tmp) || tmp > 16 * MiB) { + warn_report("Read unsupported THP size: %" PRIx64, tmp); + } else { + thp_size =3D tmp; + } + } + + if (!thp_size) { + thp_size =3D VIRTIO_MEM_DEFAULT_THP_SIZE; + warn_report("Could not detect THP size, falling back to %" PRIx64 + " MiB.", thp_size / MiB); + } + + g_free(content); + return thp_size; +} + +static uint64_t virtio_mem_default_block_size(RAMBlock *rb) +{ + const uint64_t page_size =3D qemu_ram_pagesize(rb); + + /* We can have hugetlbfs with a page size smaller than the THP size. */ + if (page_size =3D=3D qemu_real_host_page_size) { + return MAX(page_size, virtio_mem_thp_size()); + } + return MAX(page_size, VIRTIO_MEM_MIN_BLOCK_SIZE); +} + /* * Size the usable region bigger than the requested size if possible. Esp. * Linux guests will only add (aligned) memory blocks in case they fully @@ -443,10 +516,23 @@ static void virtio_mem_device_realize(DeviceState *de= v, Error **errp) rb =3D vmem->memdev->mr.ram_block; page_size =3D qemu_ram_pagesize(rb); =20 + /* + * 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 + * intervention. + */ + if (!vmem->block_size) { + vmem->block_size =3D virtio_mem_default_block_size(rb); + } + if (vmem->block_size < page_size) { error_setg(errp, "'%s' property has to be at least the page size (= 0x%" PRIx64 ")", VIRTIO_MEM_BLOCK_SIZE_PROP, page_size); return; + } else if (vmem->block_size < virtio_mem_default_block_size(rb)) { + 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)) { error_setg(errp, "'%s' property has to be multiples of '%s' (0x%" = PRIx64 ")", VIRTIO_MEM_REQUESTED_SIZE_PROP, @@ -742,6 +828,18 @@ static void virtio_mem_get_block_size(Object *obj, Vis= itor *v, const char *name, const VirtIOMEM *vmem =3D VIRTIO_MEM(obj); uint64_t value =3D vmem->block_size; =20 + /* + * If not configured by the user (and we're not realized yet), use the + * default block size we would use with the current memory backend. + */ + if (!value) { + if (vmem->memdev && memory_region_is_ram(&vmem->memdev->mr)) { + value =3D virtio_mem_default_block_size(vmem->memdev->mr.ram_b= lock); + } else { + value =3D virtio_mem_thp_size(); + } + } + visit_type_size(v, name, &value, errp); } =20 @@ -821,7 +919,6 @@ static void virtio_mem_instance_init(Object *obj) { VirtIOMEM *vmem =3D VIRTIO_MEM(obj); =20 - vmem->block_size =3D VIRTIO_MEM_MIN_BLOCK_SIZE; notifier_list_init(&vmem->size_change_notifiers); vmem->precopy_notifier.notify =3D virtio_mem_precopy_notify; =20 --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466024; cv=none; d=zohomail.com; s=zohoarc; b=FYYIekkvM3erY9Blhz6NNkHvWDdiuAswMxfvQjjlz4ivIswopQdM/XGND2n0zA8d5dBFCIuBJ37ThRXs+pzSJAWMnMyfnfyiAT4gQr1SVGyrCweDyLUCadpbgWkSX/9N4P7IUVBN0cMfD5qJ/Q1ib4G5zCtJasmvszeIl1GfLrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466024; 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=Sdg1XQq2wWnBWKWHjU6hAJQnpSiiinwLqOwmCIMoYHk=; b=LjjWL8o9qjXLPrkwjbqCmbURFLdIw8lfpH8sczBvv31NB3RsEXMK7k/HiS5dHAtVa0XrOZ+sJLTRgjvYPVU0cgTeTivsHlKdFKSCPObcrgcYtssw1h5f7K4j8rWQixT/ew7kp0y6yZBvaxy3AegDZZOzies2e1b5YomX/uh4wdQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160446602442758.64932957812994; Tue, 3 Nov 2020 21:00:24 -0800 (PST) Received: from localhost ([::1]:40410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAuF-0003b5-1g for importer@patchew.org; Wed, 04 Nov 2020 00:00:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAlE-0005cd-A4 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:23353) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAlC-0004Nj-EZ for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:03 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-274-wR2tFf37MbSCtZ9RjgKgXw-1; Tue, 03 Nov 2020 23:50:59 -0500 Received: by mail-wr1-f71.google.com with SMTP id u1so6473662wri.6 for ; Tue, 03 Nov 2020 20:50:59 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id t11sm803380wmf.35.2020.11.03.20.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:50:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465461; 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=Sdg1XQq2wWnBWKWHjU6hAJQnpSiiinwLqOwmCIMoYHk=; b=FNP+eZGtfevvx84RS8dib/AQTR78nVsb2wOHnS3F81GXPpFLaDK1LTApWItgC7JNt+oSTY ttkVLmnTmQuhr53+fUe3SKSG2ZLPd9VEDKucx16x0udQHFAISdY7J+BnMZaizJT8ZyFUk6 O2MPG5QVtE7N5TzawXwDOj0absMvX2U= X-MC-Unique: wR2tFf37MbSCtZ9RjgKgXw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Sdg1XQq2wWnBWKWHjU6hAJQnpSiiinwLqOwmCIMoYHk=; b=qPP8Ru+IN3aTBAEeZsvs9mg4BTK81rjlU7RgXmLs8piJZeNrcAhKCop/YES4KV2r2S 9MHZXPWgiq3RlJ7/oU1ZcXy9c+iRlJSbsfAH/nzhHmLKsXWk3Rk3Am8wsuBLOHDfDdkF Zhr6Ty+thZVf0vBtRbhZWn2tpF8ryQ9FvqUcpJ4UvqTlyyItzzLFgt9OAayKRXBxf5wh YzdV6CdEG2UPCKnf86CIC7cac7i7wbPr8oZj4rAhwQhC3FSX3tIS9s79RFj1A1JkNdUB wE5LbAA3uDLZIClmKtFwZXh6ccTTUuOjFUR6+9xISHNLfhP1K8cNR0pEtMSixj6YbElM EBfw== X-Gm-Message-State: AOAM531Mp1uzHclvV9AP3x9cbmnWAKbT0qMaeRkIcor8yrAGpuyRXYDu //sEx29qC75yUuBXEIhktCVg2XW/X4KhaPg5Bq9MOEDZCN7hUoo/VcXOOxxj9Gv5hcjwEckDh+S LLVjAYBUdu86F8cM= X-Received: by 2002:adf:e287:: with SMTP id v7mr11744596wri.252.1604465458033; Tue, 03 Nov 2020 20:50:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDJs7OBHgH3OXB8HBckW2FQUU2Yp+YgQhuC5NvTqtTAjZiAo6XCuyAdwzcgwMDC9hlfvW6IQ== X-Received: by 2002:adf:e287:: with SMTP id v7mr11744581wri.252.1604465457923; Tue, 03 Nov 2020 20:50:57 -0800 (PST) Date: Tue, 3 Nov 2020 23:50:55 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 05/38] memory-device: Support big alignment requirements Message-ID: <20201104044937.226370-6-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Pankaj Gupta , David Hildenbrand , "Dr . David Alan Gilbert" , Wei Yang , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Let's warn instead of bailing out - the worst thing that can happen is that we'll fail hot/coldplug later. The user got warned, and this should be rare. This will be necessary for memory devices with rather big (user-defined) alignment requirements - say a virtio-mem device with a 2G block size - which will become important, for example, when supporting vfio in the future. Reviewed-by: Pankaj Gupta Cc: "Michael S. Tsirkin" Cc: Wei Yang Cc: Dr. David Alan Gilbert Cc: Igor Mammedov Cc: Pankaj Gupta Signed-off-by: David Hildenbrand Message-Id: <20201008083029.9504-5-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/memory-device.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c index 4bc9cf0917..8a736f1a26 100644 --- a/hw/mem/memory-device.c +++ b/hw/mem/memory-device.c @@ -119,9 +119,10 @@ static uint64_t memory_device_get_free_addr(MachineSta= te *ms, =20 /* start of address space indicates the maximum alignment we expect */ if (!QEMU_IS_ALIGNED(range_lob(&as), align)) { - error_setg(errp, "the alignment (0x%" PRIx64 ") is not supported", - align); - return 0; + warn_report("the alignment (0x%" PRIx64 ") exceeds the expected" + " maximum alignment, memory will get fragmented and no= t" + " all 'maxmem' might be usable for memory devices.", + align); } =20 memory_device_check_addable(ms, size, &err); @@ -151,7 +152,7 @@ static uint64_t memory_device_get_free_addr(MachineStat= e *ms, return 0; } } else { - if (range_init(&new, range_lob(&as), size)) { + if (range_init(&new, QEMU_ALIGN_UP(range_lob(&as), align), size)) { error_setg(errp, "can't add memory device, device too big"); return 0; } --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465663; cv=none; d=zohomail.com; s=zohoarc; b=NBE9Y42GgPHelDVWXLwGJh7aTiKfnLGhkts20mL6OGHPEJ70l/9y3fSy04sYvZzv4xYfu88x420LlbPsekhaaWC/iYYNpJZe0buPRQTT2hc46402CBnoQy1VvqnlLGiVOKj2UyL6+iZ+YpGsE1GtQPL5kiwZ9NwiQbu37/E8JGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465663; 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=73Mpz3vICh9QEBEOeL5uEWGSphcZBjM+o5MkFyzWxeI=; b=OaGmPr4ahpfvapPO8Y3PG30el6HCAJkuTOBbQV98wLjSwmv68Rmc6UMHPheGCiUXDFgNa90wMZRCZOZQfYNEaUP+i/sXSzU9cHDqrTsFsgVnNxTir6LZ5Fotuei8fqEhON+9OLuIXp6vOBhphmyHIjbkFccLR46TX3JV/k1kr1k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604465663283228.7086759263559; Tue, 3 Nov 2020 20:54:23 -0800 (PST) Received: from localhost ([::1]:45400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAoQ-0002U0-75 for importer@patchew.org; Tue, 03 Nov 2020 23:54:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAlL-0005qF-I4 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48069) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAlG-0004Qd-Mm for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:11 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-189-4eZ7zOzZOuSggcZZcxF_9Q-1; Tue, 03 Nov 2020 23:51:02 -0500 Received: by mail-wr1-f69.google.com with SMTP id w6so1099914wrk.1 for ; Tue, 03 Nov 2020 20:51:02 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id b7sm868891wrp.16.2020.11.03.20.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465466; 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=73Mpz3vICh9QEBEOeL5uEWGSphcZBjM+o5MkFyzWxeI=; b=O/9d5wDVhtyL0lM1kXwrxPJEFl5Ai2C8LZGoGvcMT7L8soHgb7kzoD0dihbil2cHYhtLOi HPzATNdA3+oLGLlBanfSDAT0XNbYmtSbpOTlqRnwMliCnJAoTylrfIoRhqMI7ehSbRuBMK sNsCEaw1OfRsbehIj7gWbHA09gzwGAU= X-MC-Unique: 4eZ7zOzZOuSggcZZcxF_9Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=73Mpz3vICh9QEBEOeL5uEWGSphcZBjM+o5MkFyzWxeI=; b=sFH4bKxKSD9sYzv8H3YJqXhoijpPeVPbMd+HBWAWmOSej/20uTNql6k1rT/JBd42e8 3C4nwdc6aGfrhfe3sg9zI63ilTPFp2zYi1H3doPuf96ee1AWs5FCWY44XeqLAL6THjWF j+qrOa6C0hamwn3xyIv7jBlzoXwlisRu0actUEdVQCJC6FaF7bfdkjswj+aNxVsw4ESV /mEnZbH+xJbyALdPjtRnuWD2HrhoS345LHwquOZveFFrkFu/4vUzRyF7yB1TaJVnRVPb Gcz+Z1tc+4HnZlaZTFyuyjMvRJ3DtYnAnCLCJb4v3sLNE1ci6k3Mo5xdryU1Rd8jcrxX zwEw== X-Gm-Message-State: AOAM533Ku1cdhmRwhyjn8FgBgvluB34GrmW4uAIJ+u2DzE7ep1Rctx6Z T4TqKWrEuYeAQo5Ex45nSBOv12mrP6pyTU7RaMSM3nQPCnEwM+rV4DJppYdp4Dv7JtdnzHIsl9+ /yUWNR0Wx83Reltc= X-Received: by 2002:a1c:1f91:: with SMTP id f139mr2336235wmf.187.1604465460814; Tue, 03 Nov 2020 20:51:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlGTxgt4fQa8bVOXzeewVRGwCjYkKkN/GaCyW25cF43kupxdh/NTQGpck5fieisT+WO4yKbw== X-Received: by 2002:a1c:1f91:: with SMTP id f139mr2336229wmf.187.1604465460681; Tue, 03 Nov 2020 20:51:00 -0800 (PST) Date: Tue, 3 Nov 2020 23:50:58 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 06/38] memory-device: Add get_min_alignment() callback Message-ID: <20201104044937.226370-7-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Pankaj Gupta , David Hildenbrand , "Dr . David Alan Gilbert" , Wei Yang , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Add a callback that can be used to express additional alignment requirements (exceeding the ones from the memory region). Will be used by virtio-mem to express special alignment requirements due to manually configured, big block sizes (e.g., 1GB with an ordinary memory-backend-ram). This avoids failing later when realizing, because auto-detection wasn't able to assign a properly aligned address. Reviewed-by: Pankaj Gupta Cc: "Michael S. Tsirkin" Cc: Wei Yang Cc: Dr. David Alan Gilbert Cc: Igor Mammedov Cc: Pankaj Gupta Signed-off-by: David Hildenbrand Message-Id: <20201008083029.9504-6-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/mem/memory-device.h | 10 ++++++++++ hw/mem/memory-device.c | 11 +++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/hw/mem/memory-device.h b/include/hw/mem/memory-device.h index 30d7e99f52..48d2611fc5 100644 --- a/include/hw/mem/memory-device.h +++ b/include/hw/mem/memory-device.h @@ -88,6 +88,16 @@ struct MemoryDeviceClass { */ MemoryRegion *(*get_memory_region)(MemoryDeviceState *md, Error **errp= ); =20 + /* + * Optional: Return the desired minimum alignment of the device in gue= st + * physical address space. The final alignment is computed based on th= is + * alignment and the alignment requirements of the memory region. + * + * Called when plugging the memory device to detect the required align= ment + * during address assignment. + */ + uint64_t (*get_min_alignment)(const MemoryDeviceState *md); + /* * Translate the memory device into #MemoryDeviceInfo. */ diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c index 8a736f1a26..cf0627fd01 100644 --- a/hw/mem/memory-device.c +++ b/hw/mem/memory-device.c @@ -259,7 +259,7 @@ void memory_device_pre_plug(MemoryDeviceState *md, Mach= ineState *ms, { const MemoryDeviceClass *mdc =3D MEMORY_DEVICE_GET_CLASS(md); Error *local_err =3D NULL; - uint64_t addr, align; + uint64_t addr, align =3D 0; MemoryRegion *mr; =20 mr =3D mdc->get_memory_region(md, &local_err); @@ -267,7 +267,14 @@ void memory_device_pre_plug(MemoryDeviceState *md, Mac= hineState *ms, goto out; } =20 - align =3D legacy_align ? *legacy_align : memory_region_get_alignment(m= r); + if (legacy_align) { + align =3D *legacy_align; + } else { + if (mdc->get_min_alignment) { + align =3D mdc->get_min_alignment(md); + } + align =3D MAX(align, memory_region_get_alignment(mr)); + } addr =3D mdc->get_addr(md); addr =3D memory_device_get_free_addr(ms, !addr ? NULL : &addr, align, memory_region_size(mr), &local_err); --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465561; cv=none; d=zohomail.com; s=zohoarc; b=eK2lJEgi9/sAVAB2hi7pZ7uo+hMsV0euDqpiNf8KYnIo1Tw8oBaO12QnRZ/lGrujfNSy+AzxK11+/RsxxHR92WFklF06wgYL3rFHibav+j5KwgCeUvWb94t9vQTJNYNKDprcY4aAkHblNGRUmemg2tZMqpTq2FIKjOLeGK9BhiA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465561; 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=NLAI6E52qR6iiwo+p5ybiNDvz6sVMxaw+nStvrHSOQ4=; b=mD4VdjabelOlFZNEVpFgTLn6i0z8b2pczt5eRwrX0MIkLse+GLFhu2MBWMl94koC+GdIfDVNYvvn2MramS29qTEP0iZ+XJ0Iwszrb6oawrNeNW410RRSdBEECNfoHZedp+jABCgXvmptHYkv6OOIJQGNEiUVobIfoWEc0gfEMbY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604465561445769.3794046142277; Tue, 3 Nov 2020 20:52:41 -0800 (PST) Received: from localhost ([::1]:36996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAmm-0007We-A0 for importer@patchew.org; Tue, 03 Nov 2020 23:52:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAlK-0005oG-Eg for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48066) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAlH-0004Qm-TL for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:10 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-331-I9CzPratPZWwPqvFGL25Kw-1; Tue, 03 Nov 2020 23:51:05 -0500 Received: by mail-wm1-f71.google.com with SMTP id u207so735235wmu.4 for ; Tue, 03 Nov 2020 20:51:05 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id c17sm830795wml.14.2020.11.03.20.51.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465467; 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=NLAI6E52qR6iiwo+p5ybiNDvz6sVMxaw+nStvrHSOQ4=; b=aCcTaRmxcuMIdARojsaxn8/UaUg1AZeVWdhejNUv972wlAyapd+f5cIkYwB/JXhb7TLgLp /c8hO93Mye7C/iOX8dePpWPY38Q7FNxDKM4+J85+gvMIYr+7XUX8rm5BP8ue/oHOnL/Rxt f+oL6XKD3faDwrKwrThBoO+BrWIzYOU= X-MC-Unique: I9CzPratPZWwPqvFGL25Kw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NLAI6E52qR6iiwo+p5ybiNDvz6sVMxaw+nStvrHSOQ4=; b=K8k0HJuPe/zt2aaRSUA1XcXGJZQjpl1clTPMOUshKTV5K8vMf61tP/m24QMEbwvkG/ fotjZuiXR3U7mr/7+lUH79Sef+2f9Yabm60BqaQkm5g9vyVm44QzA6qRaB0EF3pbwU1U WZihV2840JArB/wUC0uLTg186p++LJ8eqm/vJwYyFDct3qI6zuhuIVBGlRGLqzhTJCbO ykKR7Fl5gzOSMP6eAhBz6l4VbD1O5JYnzXvPts0L3IqAFznFRPpNQ6OxO4Guz6+W8YwZ zixG69LpcIUhwUXWiZOLfBmi2c8XO7TE7TXJh6xsZiiTRU01CADj7iAIoDsmByj2Dspe 0uYw== X-Gm-Message-State: AOAM531Mp8iagBW3fd7j5378GvYRrgHKdBnHdF9OrotPQaNOvPmXLdLX FuvDItDEH35fvwovhFxDdICs163JEDnxQgVCm12tDGcooNZKyKdqLSz6gScuPyZol1eG3MxOJdR aiZbmY7U4jLB9Ezk= X-Received: by 2002:a7b:c932:: with SMTP id h18mr2583557wml.82.1604465463714; Tue, 03 Nov 2020 20:51:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTZDYdDKjxO8pdFdMQPMG7YDCJt1gJ+tEWYZAcIpu9AuxvRNDXUV7c64E4i6mgyp4hmZyBvQ== X-Received: by 2002:a7b:c932:: with SMTP id h18mr2583548wml.82.1604465463588; Tue, 03 Nov 2020 20:51:03 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 07/38] virito-mem: Implement get_min_alignment() Message-ID: <20201104044937.226370-8-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Pankaj Gupta , David Hildenbrand , "Dr . David Alan Gilbert" , Wei Yang , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand The block size determines the alignment requirements. Implement get_min_alignment() of the TYPE_MEMORY_DEVICE interface. This allows auto-assignment of a properly aligned address in guest physical address space. For example, when specifying a 2GB block size for a virtio-mem device with 10GB with a memory setup "-m 4G, 20G", we'll no longer fail when realizing. Reviewed-by: Pankaj Gupta Cc: "Michael S. Tsirkin" Cc: Wei Yang Cc: Dr. David Alan Gilbert Cc: Igor Mammedov Cc: Pankaj Gupta Signed-off-by: David Hildenbrand Message-Id: <20201008083029.9504-7-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mem-pci.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c index 913f4a3326..fa5395cd88 100644 --- a/hw/virtio/virtio-mem-pci.c +++ b/hw/virtio/virtio-mem-pci.c @@ -76,6 +76,12 @@ static void virtio_mem_pci_fill_device_info(const Memory= DeviceState *md, info->type =3D MEMORY_DEVICE_INFO_KIND_VIRTIO_MEM; } =20 +static uint64_t virtio_mem_pci_get_min_alignment(const MemoryDeviceState *= md) +{ + return object_property_get_uint(OBJECT(md), VIRTIO_MEM_BLOCK_SIZE_PROP, + &error_abort); +} + static void virtio_mem_pci_size_change_notify(Notifier *notifier, void *da= ta) { VirtIOMEMPCI *pci_mem =3D container_of(notifier, VirtIOMEMPCI, @@ -110,6 +116,7 @@ static void virtio_mem_pci_class_init(ObjectClass *klas= s, void *data) mdc->get_plugged_size =3D virtio_mem_pci_get_plugged_size; mdc->get_memory_region =3D virtio_mem_pci_get_memory_region; mdc->fill_device_info =3D virtio_mem_pci_fill_device_info; + mdc->get_min_alignment =3D virtio_mem_pci_get_min_alignment; } =20 static void virtio_mem_pci_instance_init(Object *obj) --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466176; cv=none; d=zohomail.com; s=zohoarc; b=a8lzXEUjPUfSs69WT+L9HNFXzPtvdCLJT64st77nJj8IAAuRudhEGNVY2BEkqlJo8rszndkX9VCKRv7qeG+3xBin6dPMOG3qEjEtQ9MWMAOczHxW1nEk1q0a74x5bmKxN+8nkyek60Ls4hN2tf+YYUF0uXdjfTnp5CMSaOkI6a8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466176; 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=ghKT3iuLd9VX4UT4KJCLl/E2c6yAP84MyPy0077dPys=; b=iFxqzr/q3W4sCNonioAQZUEgLBVhg6mfGrC0hTOo2sPD+tbI0ljHIPptjLzte2jz176CF1/RCHGOIE0LO0SwFTPVN8Ca9UlWu6QvXSly7ttkNZ/s+SAQFodv10nDJrK+q91I38nEO1o6rZ05bKAZOHCA5wj9IDQmrBCkk/oRi0Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466176643198.90358403510447; Tue, 3 Nov 2020 21:02:56 -0800 (PST) Received: from localhost ([::1]:48926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAwg-00079I-Ic for importer@patchew.org; Wed, 04 Nov 2020 00:02:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAlN-0005th-E2 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:51953) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAlL-0004SL-Eq for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:12 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-328-ql6yJhAcP8OYZ--o-11vWg-1; Tue, 03 Nov 2020 23:51:08 -0500 Received: by mail-wr1-f72.google.com with SMTP id w3so6590620wrt.11 for ; Tue, 03 Nov 2020 20:51:07 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id n9sm839063wmd.4.2020.11.03.20.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465470; 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=ghKT3iuLd9VX4UT4KJCLl/E2c6yAP84MyPy0077dPys=; b=chXfc4OC9iRuUyxGwo198wAFtEYsMHbZ8mHHulDkdbAVRY45esIYxAuxt5VKGReEKmgPYX cHL70eE0mh+hDLt9hoKjErtflHrP1SX3RS303Rylv4VptpEOHEFmaYhF3smUfoRQEYOrcC 2uIsqCxPwDr8vwrVZf19n1U4evsOfB0= X-MC-Unique: ql6yJhAcP8OYZ--o-11vWg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ghKT3iuLd9VX4UT4KJCLl/E2c6yAP84MyPy0077dPys=; b=UJz1kTj24Ow9hgh/Zex7B1XwvknVSrYKAvABqDPKeUCnCK7BAg/b0ufcrbYsDzAgxM AN4XWb/qwP9DQhqLH4EjzOslW6pCKQ0rQED60833z3l3+LSWXuaM9yyaxCVTChSjilJx dyVNNLCjsztoRhZ96cwg3dWGe55950Ssh8D+SmbOLZM7ANiGyjploCciXQUb6trGqnTH YEnN1PccbXP3M7BRh+vAShZVgtZ2x/dXQ5e/P23c6ERFeNiZyvvZeGGqxV37N+rAFETM Dd0mXR8SCL5jKU1BOSIOzEQiUuTSt13ZY+roRjizvFmkhBrCqsdKoCidzrdayX4kRczy Am7A== X-Gm-Message-State: AOAM5325Rj+9oHBYPQrUP4PfL41c5CtvlXWr5o0HswXOQkwjmFSKBEYE +MFKCZlURREUUsUHc1Awtg3AoKhG6k6T34FcdD4oP5AtMLnr5aoEbLfegzDykT5IJMg1uXIFNEn zHiltNWsheVr0cKQ= X-Received: by 2002:adf:dc4c:: with SMTP id m12mr17153791wrj.177.1604465466360; Tue, 03 Nov 2020 20:51:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXIcSk+yVZMlE7OikzQNXfZbVxhliGPHpwI391y7FlhQdG2HTYuG8SYuRXSHlCaWlS8jCSOw== X-Received: by 2002:adf:dc4c:: with SMTP id m12mr17153771wrj.177.1604465466214; Tue, 03 Nov 2020 20:51:06 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:03 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 08/38] hw/acpi : Don't use '#' flag of printf format Message-ID: <20201104044937.226370-9-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov , Kai Deng , Xiao Guangrong , Xinhao Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xinhao Zhang Fix code style. Don't use '#' flag of printf format ('%#') in format strings, use '0x' prefix instead Signed-off-by: Xinhao Zhang Signed-off-by: Kai Deng Message-Id: <20201103102634.273021-1-zhangxinhao1@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/nvdimm.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 8f7cc16add..8ad5516142 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -556,7 +556,7 @@ static void nvdimm_dsm_func_read_fit(NVDIMMState *state= , NvdimmDsmIn *in, =20 fit =3D fit_buf->fit; =20 - nvdimm_debug("Read FIT: offset %#x FIT size %#x Dirty %s.\n", + nvdimm_debug("Read FIT: offset 0x%x FIT size 0x%x Dirty %s.\n", read_fit->offset, fit->len, fit_buf->dirty ? "Yes" : "No"= ); =20 if (read_fit->offset > fit->len) { @@ -664,7 +664,7 @@ static void nvdimm_dsm_label_size(NVDIMMDevice *nvdimm,= hwaddr dsm_mem_addr) label_size =3D nvdimm->label_size; mxfer =3D nvdimm_get_max_xfer_label_size(); =20 - nvdimm_debug("label_size %#x, max_xfer %#x.\n", label_size, mxfer); + nvdimm_debug("label_size 0x%x, max_xfer 0x%x.\n", label_size, mxfer); =20 label_size_out.func_ret_status =3D cpu_to_le32(NVDIMM_DSM_RET_STATUS_S= UCCESS); label_size_out.label_size =3D cpu_to_le32(label_size); @@ -680,19 +680,19 @@ static uint32_t nvdimm_rw_label_data_check(NVDIMMDevi= ce *nvdimm, uint32_t ret =3D NVDIMM_DSM_RET_STATUS_INVALID; =20 if (offset + length < offset) { - nvdimm_debug("offset %#x + length %#x is overflow.\n", offset, + nvdimm_debug("offset 0x%x + length 0x%x is overflow.\n", offset, length); return ret; } =20 if (nvdimm->label_size < offset + length) { - nvdimm_debug("position %#x is beyond label data (len =3D %" PRIx64= ").\n", + nvdimm_debug("position 0x%x is beyond label data (len =3D %" PRIx6= 4 ").\n", offset + length, nvdimm->label_size); return ret; } =20 if (length > nvdimm_get_max_xfer_label_size()) { - nvdimm_debug("length (%#x) is larger than max_xfer (%#x).\n", + nvdimm_debug("length (0x%x) is larger than max_xfer (0x%x).\n", length, nvdimm_get_max_xfer_label_size()); return ret; } @@ -716,7 +716,7 @@ static void nvdimm_dsm_get_label_data(NVDIMMDevice *nvd= imm, NvdimmDsmIn *in, get_label_data->offset =3D le32_to_cpu(get_label_data->offset); get_label_data->length =3D le32_to_cpu(get_label_data->length); =20 - nvdimm_debug("Read Label Data: offset %#x length %#x.\n", + nvdimm_debug("Read Label Data: offset 0x%x length 0x%x.\n", get_label_data->offset, get_label_data->length); =20 status =3D nvdimm_rw_label_data_check(nvdimm, get_label_data->offset, @@ -755,7 +755,7 @@ static void nvdimm_dsm_set_label_data(NVDIMMDevice *nvd= imm, NvdimmDsmIn *in, set_label_data->offset =3D le32_to_cpu(set_label_data->offset); set_label_data->length =3D le32_to_cpu(set_label_data->length); =20 - nvdimm_debug("Write Label Data: offset %#x length %#x.\n", + nvdimm_debug("Write Label Data: offset 0x%x length 0x%x.\n", set_label_data->offset, set_label_data->length); =20 status =3D nvdimm_rw_label_data_check(nvdimm, set_label_data->offset, @@ -838,7 +838,7 @@ nvdimm_dsm_write(void *opaque, hwaddr addr, uint64_t va= l, unsigned size) NvdimmDsmIn *in; hwaddr dsm_mem_addr =3D val; =20 - nvdimm_debug("dsm memory address %#" HWADDR_PRIx ".\n", dsm_mem_addr); + nvdimm_debug("dsm memory address 0x%" HWADDR_PRIx ".\n", dsm_mem_addr); =20 /* * The DSM memory is mapped to guest address space so an evil guest @@ -852,11 +852,11 @@ nvdimm_dsm_write(void *opaque, hwaddr addr, uint64_t = val, unsigned size) in->function =3D le32_to_cpu(in->function); in->handle =3D le32_to_cpu(in->handle); =20 - nvdimm_debug("Revision %#x Handler %#x Function %#x.\n", in->revision, + nvdimm_debug("Revision 0x%x Handler 0x%x Function 0x%x.\n", in->revisi= on, in->handle, in->function); =20 if (in->revision !=3D 0x1 /* Currently we only support DSM Spec Rev1. = */) { - nvdimm_debug("Revision %#x is not supported, expect %#x.\n", + nvdimm_debug("Revision 0x%x is not supported, expect 0x%x.\n", in->revision, 0x1); nvdimm_dsm_no_payload(NVDIMM_DSM_RET_STATUS_UNSUPPORT, dsm_mem_add= r); goto exit; --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465784; cv=none; d=zohomail.com; s=zohoarc; b=B73e1vBVntDidQZ/JpqkqtYFfATyAZcx8h0pTbg0DwCwxb4chhS5GgcxE1Rs7Re2VD60h205lnjJ1yvYjvOQKP00ditZ4g+74EvKdAsZ1ZlzfeltW4i+PoZMPoGfDiIveUxfaeZ59uYQsoI5o6p4I1P4Drvw1M7bS7Fuxp+ECIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465784; 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=g3L/0LWUS5AALGZ/Ad9jPepioK718BBOf2ilNljz6+w=; b=Rap/voHSRDxg5/bXhi5ISwZNAQpxOromS70yBA4VZDtNVwK6tkdKCh9jVgBCUNx7cXkTst78YyU0RVfZZqUE9gqT4Vr5lzV16u7VZD6+KUoMoZRKLydHbYAwcxzar2hH+qVl6mXuP0MhIQryfV1Frc+5yHXJn8wL46kuujIA0+U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604465784651582.4616560613821; Tue, 3 Nov 2020 20:56:24 -0800 (PST) Received: from localhost ([::1]:51870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAqN-0005Gg-LY for importer@patchew.org; Tue, 03 Nov 2020 23:56:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAm3-0006aF-5r for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:29768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAm1-0004io-CC for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:54 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-94-_KzJ-3paOGuIStQF4wjacQ-1; Tue, 03 Nov 2020 23:51:10 -0500 Received: by mail-wr1-f71.google.com with SMTP id w1so8714959wrr.5 for ; Tue, 03 Nov 2020 20:51:10 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id f17sm838368wmf.41.2020.11.03.20.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465512; 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=g3L/0LWUS5AALGZ/Ad9jPepioK718BBOf2ilNljz6+w=; b=flQxvzM3w4rF0Y9gEaSGx0dD6rYGi47oQQlK9ZoNPV0LpQUdoXV3W5TpBMojJj0SldypGc Yy1CNA4HVcsfo/UecYEoTG6YZL2FiXMZSA9aN74qnGYHLvFT61npktZulS1vADY2ZMfKl+ JzSas7uQDTn7Cu6HncYa1W6MaiZEX0E= X-MC-Unique: _KzJ-3paOGuIStQF4wjacQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=g3L/0LWUS5AALGZ/Ad9jPepioK718BBOf2ilNljz6+w=; b=mblzNz+Vhi23+MtolHvgtojyqJSrzQbvu//HunBYdkblpSu5zEvmuJmlXfPf5adJl2 dnIqbktFJuA43HLEMTqwHiO8RipuxvC7koaOiPTh1V5A8Wwqxcv98NWZ7oGqZFSpqxoK MEGxlkIZqzArI0oZE7HTYOth0hxCnKhwi097VBeEapJhVqW0n3KOiyIkWYVkm2oyehOd KOYDQouTeJ8JGFqF6k6X3kbJq7eDzq/zR/8SUbU5wLYNhwy3nY81NkHtLhzfHCIw+DE2 yQrH2fsJ0xy1IdMJW/8TfZqNvhHP5+cyFPZSjpbYp78OiHMWBWwvMVRn/39bZJspqXAK K7gw== X-Gm-Message-State: AOAM533nTRn3fOeMNsLR3l8oi2ou0OPfyQjdec6SxL2z12tYwKndvbL4 cIvlCZaMF8y1mNfWcBecRc1JwN+88vaMVCvG3HMpKNh14UnfR7r8nk9Rzd6yWq3j5i9MIJXVmix mQiDtHr1iiTdf5iU= X-Received: by 2002:adf:e7c1:: with SMTP id e1mr31495182wrn.247.1604465469271; Tue, 03 Nov 2020 20:51:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRH3fz1EdqaZqIaBRvcNUlor68i3/UCN/rSCzQqduO81twNUfv8PSUMdTc7o/gD/8zO/BIiw== X-Received: by 2002:adf:e7c1:: with SMTP id e1mr31495176wrn.247.1604465469165; Tue, 03 Nov 2020 20:51:09 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:06 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 09/38] hw/acpi : add space before the open parenthesis '(' Message-ID: <20201104044937.226370-10-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov , Kai Deng , Xinhao Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xinhao Zhang Fix code style. Space required before the open parenthesis '('. Signed-off-by: Xinhao Zhang Signed-off-by: Kai Deng Message-Id: <20201103102634.273021-2-zhangxinhao1@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/acpi/core.c b/hw/acpi/core.c index ade9158cbf..2c0c83221f 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -558,7 +558,7 @@ static void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t v= al) if (val & ACPI_BITMASK_SLEEP_ENABLE) { /* change suspend type */ uint16_t sus_typ =3D (val >> 10) & 7; - switch(sus_typ) { + switch (sus_typ) { case 0: /* soft power off */ qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); break; --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604467186; cv=none; d=zohomail.com; s=zohoarc; b=mlrTZRoOl+3UejeBRpd+qyZzY/hwvsVEGxarQtETGOAK9mfFT1Swey5Bal0m+3xyKQb6tZwriNHehTOJLJiYXHoe/JWDL1yDLBFQWDLihG/7210Pm5dlmA0iScmG5/Ki59/5RCMPKZ0RqtbOZccYiSm8Ex9buWxhNJpOcf33Syw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604467186; 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=kxx7KBtrm7vYLNNi8ILRStjcIKIqdM/KqZjCc2FDurE=; b=L+idaY5TF/MVcyQz62vSGP6WG4ESfRzpiVRMURVIoId8VDJC0H83GO8OTWbZZYgwiuWNGt6jMZ2JjiXAmENAAAPpT3a4GRkQuCF3vPAMthNMQSXSjAvRFOHE3+UXISXOmKxP6vuHM9fT5TBQyeOlX5hzmKBbBv3pOEZyBrNz1Lk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604467186213276.6764064445507; Tue, 3 Nov 2020 21:19:46 -0800 (PST) Received: from localhost ([::1]:45678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaBCy-0003pK-VC for importer@patchew.org; Wed, 04 Nov 2020 00:19:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33412) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAxx-0001RO-MP for qemu-devel@nongnu.org; Wed, 04 Nov 2020 00:04:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:31331) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAxv-0000OQ-3V for qemu-devel@nongnu.org; Wed, 04 Nov 2020 00:04:13 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-511-rdD6XZqoMlyucA7B8eusGA-1; Tue, 03 Nov 2020 23:51:13 -0500 Received: by mail-wr1-f70.google.com with SMTP id v5so8788369wrr.0 for ; Tue, 03 Nov 2020 20:51:13 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id 30sm852812wrs.84.2020.11.03.20.51.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604466250; 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=kxx7KBtrm7vYLNNi8ILRStjcIKIqdM/KqZjCc2FDurE=; b=Yorg10/LTSaZKxvoe6KCVCuXKr5F0v2QIzioiMq87D39dXffNt4gTz1q6SOb/kenupqNhL TKRGY8v74CoUpnJXmcds/Ky5JWei0Ol7FmviSH1EZe26OMfCSXedbpMOVvhMps+oZadnJ5 ILCAr6w7GMkeAwTkapN1FyH/r5Oi0UM= X-MC-Unique: rdD6XZqoMlyucA7B8eusGA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kxx7KBtrm7vYLNNi8ILRStjcIKIqdM/KqZjCc2FDurE=; b=eaeMeFAEE1f6wCwB9hUi2A1mrBHxY0Ci0fB6ssDh3wldWyjslrjrjYx32tyY8lUxGE GCbh4nOFzrhmI0086I2R7XuzaJMknva4Mqvuc0OPPwayXJUbuTJ1NYsMsxD7DAcW/5of lrQ1B8DMy3WO9ZkJ555NFNQtkLTxn7TMlzOTSmT2iIWwNurGngeCb/q+RP3RQOKh4iqq fOgdmwqmPK7OaMPpujiyQPp9NZIl8lRpQ21ak/HIaz6SyOQQLHqOpOr2MVT5j/DO4h// cspiXD5X4bzw6H3iWWJf1uwnvlMte1oGPggbYkb/fhoENknkfm9F3Yhye1zI+SitNBIi zSuw== X-Gm-Message-State: AOAM532JFDkjQuJq5+WPz5/KreJ1C8XCaK/Gwh4zluzI+rDHkGm+2MB4 pyHV0wpOb+R3wDR8Iss+YCPiRXvviCZHX00cwX8ku5e6u2Q9P5OANwD9VpBCOZ46Eyav9Cr9ZAZ P0uRmEc13oCaWBgU= X-Received: by 2002:adf:ed4c:: with SMTP id u12mr11675060wro.63.1604465472130; Tue, 03 Nov 2020 20:51:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXS2o5I7NKNl1d9yjYzni7laQE3Lf9kXXMHhjkEApkeyPw5C9iYEyYc/QEW2bghgeZ//t5xQ== X-Received: by 2002:adf:ed4c:: with SMTP id u12mr11675046wro.63.1604465471963; Tue, 03 Nov 2020 20:51:11 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:09 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 10/38] hw/acpi : add spaces around operator Message-ID: <20201104044937.226370-11-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov , Kai Deng , Xinhao Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xinhao Zhang Fix code style. Operator needs spaces both sides. Signed-off-by: Xinhao Zhang Signed-off-by: Kai Deng Message-Id: <20201103102634.273021-3-zhangxinhao1@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/pcihp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 32ae8b2c0a..17c32e0ffd 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -400,7 +400,7 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *s, = PCIBus *root_bus, s->io_len =3D ACPI_PCIHP_SIZE; s->io_base =3D ACPI_PCIHP_ADDR; =20 - s->root=3D root_bus; + s->root =3D root_bus; s->legacy_piix =3D !bridges_enabled; =20 memory_region_init_io(&s->io, owner, &acpi_pcihp_io_ops, s, --=20 MST From nobody Fri May 17 02:03:05 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=1604466629; cv=none; d=zohomail.com; s=zohoarc; b=BuwVh2P5pwmaKlxB1shkxeJVDXtjdK3W7ieyiFF/JqggpQuFdSNIN1VQcE9rVEh1ZuXVXEdN8mNt8VQv/Vk8W9SmfHFaaxBYpdlLqD5IKGbjOGjT/OVygm6JKRGNkLU9UiZEN8erAJOxnF1AU30AyL7j3VBOHPDjoB5+WUYRs7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466629; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4t5NY5zyTFxf5JdPvPR+dRhfn/ny8MSoW1vs+UM3VkI=; b=jNAbRyed28owP4TzgKGNZDB+oO0RaIz0wPcwWDhV4QxJO2Uis/Lrf3MlfdzcIw0XjiG36+ifQQWgB/eXf20n7hmu9gYTVXs23cA6YWwaZkLwq8/WCDvAh22b48vGzry2O7YhUPx/1QauQcf1q9OUtKFFk1CSVM+9BcrOizgXRDA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466629798954.5230409303352; Tue, 3 Nov 2020 21:10:29 -0800 (PST) Received: from localhost ([::1]:44570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaB40-00006O-I0 for importer@patchew.org; Wed, 04 Nov 2020 00:10:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAmI-00070g-Mj for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46188) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAmG-0004oe-0b for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:10 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-103-dPaoXGiPPXuIhfhmU4rDBg-1; Tue, 03 Nov 2020 23:51:16 -0500 Received: by mail-wr1-f69.google.com with SMTP id t11so8747070wrv.10 for ; Tue, 03 Nov 2020 20:51:16 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id v6sm859879wrs.39.2020.11.03.20.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465527; 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=4t5NY5zyTFxf5JdPvPR+dRhfn/ny8MSoW1vs+UM3VkI=; b=O9de0IJ+xfXkT4wuYEBGQsEzzkta3WLIfNqHkyULx13t8SW499sbjVaL8+aLI0ap89YfKG WnKu6G4jGUYK1a8ONqvhvmvz1ltlR/Wru1XDne8Stc6uq1BlTN9hKsoXLQLygnb1cx+iqs B6QT/5gVBjEh2gwUlPN1TZMeLN+udUY= X-MC-Unique: dPaoXGiPPXuIhfhmU4rDBg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=4t5NY5zyTFxf5JdPvPR+dRhfn/ny8MSoW1vs+UM3VkI=; b=YY26dWFZdKTdxJszrfPGg5XIfEEerwTNeA39tQSBn5c292WQIr/WuWFczWAsJS11El tOQ+zPkMEFLMoWyUV1n/vfSLjC36Qkq0Xe1jHhMESU4S4mEuxasQX/ptwylQftsveC37 bIS96stBG447RRM71jRYCU4IWmelP6231s03MPZoTts6xxHZ6eFovZx2tUiPGegdFS/s RZGAHU3TR1X2F0EVASWdaCIFBzf5xoVoo3+jiztyIviVHa+f2NwRHghfNJEMjNVK4FYM JVe5fJUEuOvCRPpMOOTMB8FGKQn7BcIRJE6bFldAQ8/hp6kayNI5c6Mg0J7FNmWHyjRc Iakw== X-Gm-Message-State: AOAM530mgsv0bJ/HUI/Sf5WEZgqI1aIc10D4xRPt6Smdz4EOJrIxTd3k rxb6VUVWcV0GdLWchHieMySI3or3/A/LZEKxKdhRgz5TuD4rMjCJYDi+DGnXvpooDuhy2zeOg9U sgra/XUOJvNLgDFg= X-Received: by 2002:a1c:26c3:: with SMTP id m186mr2308226wmm.115.1604465475000; Tue, 03 Nov 2020 20:51:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzB5LneqeIqlqxcFrlHeD6jODLPG3/6pQPGEz6Ef2D4s/NR30+VTEKZWVqkQ5D2j8GmxfBXRw== X-Received: by 2002:a1c:26c3:: with SMTP id m186mr2308213wmm.115.1604465474810; Tue, 03 Nov 2020 20:51:14 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:12 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 11/38] hw/virtio/vhost-backend: Fix Coverity CID 1432871 Message-ID: <20201104044937.226370-12-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-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=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 Fix uninitialized value issues reported by Coverity: Field 'msg.reserved' is uninitialized when calling write(). While the 'struct vhost_msg' does not have a 'reserved' field, we still initialize it to have the two parts of the function consistent. Reported-by: Coverity (CID 1432864: UNINIT) Fixes: c471ad0e9bd ("vhost_net: device IOTLB support") Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20201103063541.2463363-1-philmd@redhat.com> Reviewed-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-backend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 88c8ecc9e0..222bbcc62d 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -257,7 +257,7 @@ static int vhost_kernel_send_device_iotlb_msg(struct vh= ost_dev *dev, struct vhost_iotlb_msg *imsg) { if (dev->backend_cap & (1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2)) { - struct vhost_msg_v2 msg; + struct vhost_msg_v2 msg =3D {}; =20 msg.type =3D VHOST_IOTLB_MSG_V2; msg.iotlb =3D *imsg; @@ -267,7 +267,7 @@ static int vhost_kernel_send_device_iotlb_msg(struct vh= ost_dev *dev, return -EFAULT; } } else { - struct vhost_msg msg; + struct vhost_msg msg =3D {}; =20 msg.type =3D VHOST_IOTLB_MSG; msg.iotlb =3D *imsg; --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466677; cv=none; d=zohomail.com; s=zohoarc; b=aj0BdBHpENx1ef9ytlBHYyrWVcMxBNc7rM/GCLia8qRRzhgGKBuW59Oso8akG2xRP1gwtzvJErxM2zEqrNiQYssc99OvFqqobwr310cSxdB4HYYYUdZg4yrCcspa+ch0blW7xDV3x4ZajQw/0gppymBefJ5oxpcTJgPgjqFRdSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466677; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QTkwT/HJ1lj3VKT9unaRe9zAEsq3t6jIEnXFjz8fDHg=; b=n39qTOYNt2ekqYLLBuMDuzwHDThkQapyw7vtRt5SPt/Sj4n2OJIFtWOKkndoVLu6hGB+9CUHyxxdtzWs0uCQ/1N6XDmpEcGW57lPxygzepFSgORRSq6n+tYx4hPM2/O//UBAmtom5mWTF0J4/i2J0XpqK7neP45Ag7z7MilJbWU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466677913505.37923418445314; Tue, 3 Nov 2020 21:11:17 -0800 (PST) Received: from localhost ([::1]:47134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaB4m-0001F3-ML for importer@patchew.org; Wed, 04 Nov 2020 00:11:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAmN-0007Bi-1H for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35242) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAmL-0004qL-9o for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:14 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-259-st653kjrMb-laG9vRXT0ag-1; Tue, 03 Nov 2020 23:51:19 -0500 Received: by mail-wr1-f69.google.com with SMTP id h8so8752030wrt.9 for ; Tue, 03 Nov 2020 20:51:18 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id o7sm879237wrp.23.2020.11.03.20.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465532; 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=QTkwT/HJ1lj3VKT9unaRe9zAEsq3t6jIEnXFjz8fDHg=; b=AilTWkv2F+GCR21M0H9WidNTxewPkgV1OIf2lVqY1h0H8t8FDd6gtKok716lQ1ruZosJ3m kQoWCRBOxLbmtUzBcY72aWOTmxJpyg6LEsm/2DftX1eRixI2VhVapDZkztomHBREIor8El kBPwv1Vth3Yapwf8M80Z4MuRRBpAE4k= X-MC-Unique: st653kjrMb-laG9vRXT0ag-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=QTkwT/HJ1lj3VKT9unaRe9zAEsq3t6jIEnXFjz8fDHg=; b=CXeTKNLj+q/tC6Cw6DDqm2AosywDZaiDwgJVdZcEkBWaIzb/gi3DKPaJGslCORAcs8 RJxBOQSNBYVMG5hfwLj40Z+aPfNlL2wgBpK4M293DBAhBiphK43Fj+5UCHrc2oNq4eCS 4NykhNgAT2H0/CMLHmuVVDScK6wPMyNdeMwLhMfxGRAFTj7+O/C/+HR82NSFHT59VJV8 t9kiofITob/u/3fcRhRsPxcff/BP1DbM2vOS+6lB7DRnUkhKgVJP42PFI9+QKKFGnDMf zemV+S30ZpJLC+0Q5Mvn58cWxCOWBAV7rOx1G7/JRJcxktJSYSJz2pFfbNA0gp//pFnq S32A== X-Gm-Message-State: AOAM530liCVAYj09s53JfP2x/LWebEwmbZ4cn1ZgshvZT3ImAizWYriP D9XAyKubIVhRlDWmHdypVET7CTqu0+50WLoUjKI8l9d/N2UiS7tyN2cCbNiolUoyoFJVRXvyhVO a6DpAvRtmntT+CA0= X-Received: by 2002:a5d:54c1:: with SMTP id x1mr31535049wrv.172.1604465477640; Tue, 03 Nov 2020 20:51:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUgsPaveUdfW8VUaAKa0QnpyrEuLakxvhVemX2FGAfbSC5w1+S79jiFtRprGeBjDFfnqL8OQ== X-Received: by 2002:a5d:54c1:: with SMTP id x1mr31535034wrv.172.1604465477476; Tue, 03 Nov 2020 20:51:17 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:15 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 12/38] hw/smbios: Fix leaked fd in save_opt_one() error path Message-ID: <20201104044937.226370-13-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-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=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Laszlo Ersek , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Fix the following Coverity issue (RESOURCE_LEAK): CID 1432879: Resource leak Handle variable fd going out of scope leaks the handle. Replace a close() call by qemu_close() since the handle is opened with qemu_open(). Fixes: bb99f4772f5 ("hw/smbios: support loading OEM strings values from a f= ile") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20201030152742.1553968-1-philmd@redhat.com> Reviewed-by: Stefano Garzarella Reviewed-by: Laszlo Ersek Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/smbios/smbios.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 8b30906e50..6a3d39793b 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -988,16 +988,18 @@ static int save_opt_one(void *opaque, if (ret < 0) { error_setg(errp, "Unable to read from %s: %s", value, strerror(errno)); + qemu_close(fd); return -1; } if (memchr(buf, '\0', ret)) { error_setg(errp, "NUL in OEM strings value in %s", value); + qemu_close(fd); return -1; } g_byte_array_append(data, (guint8 *)buf, ret); } =20 - close(fd); + qemu_close(fd); =20 *opt->dest =3D g_renew(char *, *opt->dest, (*opt->ndest) + 1); (*opt->dest)[*opt->ndest] =3D (char *)g_byte_array_free(data, FAL= SE); --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465830; cv=none; d=zohomail.com; s=zohoarc; b=DRRhtS/2tak+918TVYCiV4wiGMRirk3uUou3WDYA+Hpp3iOUPudSTnMzaX6lektq0Y3hfMVk7SyZ/ui4+k+6KHpu4re+v/5wPVUkNDWmS6Gx0vIFguyNeKZU9qd0Oq5NqexDl84PtS0Wxw6t6qAa8WzAb1pypT3KskwPd49PPT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465830; 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=yb0+hTu/cI4h7Se3wHsf9S5j6pZCfXhlBpQERrIdWig=; b=C6sifx2ZkW0x0w8L276R/Ahg1tw79odf5Yg54KbNCIHYqIwuMYZlZr9sSIFjV3MBHKdBUXuHfsTPWNzzWUAgx2qH8v0R22Ccg7wZClWPPiOLp0fY9/Su+dVUANNq+fkK2B+ujCwAuPEuAkcufr+UQ0XwZGg8gTpViTfDaG4zG8o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604465829999912.8246374218757; Tue, 3 Nov 2020 20:57:09 -0800 (PST) Received: from localhost ([::1]:53866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAr6-00063O-S9 for importer@patchew.org; Tue, 03 Nov 2020 23:57:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAld-00062f-Cl for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58618) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAlZ-0004XT-7b for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:29 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-277-sa79lTsPMouyet9jeOpn4g-1; Tue, 03 Nov 2020 23:51:21 -0500 Received: by mail-wr1-f70.google.com with SMTP id v5so8788509wrr.0 for ; Tue, 03 Nov 2020 20:51:21 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id s12sm839406wmc.6.2020.11.03.20.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465483; 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=yb0+hTu/cI4h7Se3wHsf9S5j6pZCfXhlBpQERrIdWig=; b=bA2879TM+kId/TDhzvzT7iY/+TTHKe35+WxYLPV/BjqnA5+FE9pM8/sS1y1B/8FkUtafLJ XKKwAS7YOBgSCRZT2kWkimqvxRQdxsfT7jZv4iKUUFjlDuSQgYmHuogbW/hyU5S92OZLOm VV5iqKylNrypWbIpM8FYsTwtmSPQn54= X-MC-Unique: sa79lTsPMouyet9jeOpn4g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=yb0+hTu/cI4h7Se3wHsf9S5j6pZCfXhlBpQERrIdWig=; b=IT5HmwRO48utmBytAHynZH0rStpHMR+aFOg3FT99+crIneQ7JesSSCbXsZAx18LIl7 298HaT/d61tCqIzyxezm7lqsR1rlefJB150U+m+ZUQIjPEHB/pWZfXP8HBDJ7iTfS9us kLfDCcAZ1IVZfHUzh+MeJoLa+1asYN4xHGICzckWpqU1u9lROW3DXw4qKad8WCks2fiL pkk2F9VqKUYVtoJ273oTo04cO4JxwzSWMmdzO/84YmyxoGmXwMFJ3eBsvrkl3YbEVaBW W0dwhSpcnyRUl8WEhu01wcam9/j24lUSxkFRxijawt6f0ZuITD+ecrflA5Yvs77y3qIa rp+A== X-Gm-Message-State: AOAM532B6aQu6+/iv0FLP2SiQiZkGxfhhwRAESqVxf/1BL+ynZk+doBW zUiF7WlARf7vULd9/khzmE8YHRaFU/ogXxnisql+S/gQPl/d+lUZpLUTaKerpPU009RCsDBzgKr Yfp2BpOQav3SktdE= X-Received: by 2002:a1c:a145:: with SMTP id k66mr2409639wme.177.1604465480283; Tue, 03 Nov 2020 20:51:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7tJ5ajwMwbMv+jApvK1qMSLLpp6GStq0zFfUuVIYnSbc/9I0aoLydYKboHlyceWdmZmvanQ== X-Received: by 2002:a1c:a145:: with SMTP id k66mr2409626wme.177.1604465480145; Tue, 03 Nov 2020 20:51:20 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 13/38] virtio-iommu: Fix virtio_iommu_mr() Message-ID: <20201104044937.226370-14-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Peter Xu , QEMU Stable , Eric Auger , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker Due to an invalid mask, virtio_iommu_mr() may return the wrong memory region. It hasn't been too problematic so far because the function was only used to test existence of an endpoint, but that is about to change. Fixes: cfb42188b24d ("virtio-iommu: Implement attach/detach command") Cc: QEMU Stable Acked-by: Eric Auger Reviewed-by: Peter Xu Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-2-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 21ec63b108..4c8f3909b7 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -101,7 +101,7 @@ static IOMMUMemoryRegion *virtio_iommu_mr(VirtIOIOMMU *= s, uint32_t sid) bus_n =3D PCI_BUS_NUM(sid); iommu_pci_bus =3D iommu_find_iommu_pcibus(s, bus_n); if (iommu_pci_bus) { - devfn =3D sid & PCI_DEVFN_MAX; + devfn =3D sid & (PCI_DEVFN_MAX - 1); dev =3D iommu_pci_bus->pbdev[devfn]; if (dev) { return &dev->iommu_mr; --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466765; cv=none; d=zohomail.com; s=zohoarc; b=kZQxEvobPmGCLOF2K9vvut+MSB41JBryoC0cLosbgu3BIvTwCuAhAQJRMzuNgf6Y20QhYl16zejpz4UAlwnKSsdzXaUkn/FGmn4G7L7uvdwp0i1ygC5VFOWX7F5TWk5tJ5HqpOLo6sfITcH38Yr2d1WDNz7fRyU+84tds/EFQvA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466765; 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=tvJ0s3bSV9g9bsoYugn7fOSbhCEdSfwOqB79D2kkBqw=; b=XkKKIaNEX/REskP+hxZl9HxONS+TCVW1fQ/ejOKALtUJY85K7N0DiqnPFoh8G+bqQwmfJ9N4PK+vJqpfEsSfunNKtn+NVd5lRsrDmpD/LIg0gCo7ptCunEp7/e5+hojGpcs1JnLXXSFQuLfwUkwDEP4kwE72jqEy09xNxnKY20Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466765807724.3799318487802; Tue, 3 Nov 2020 21:12:45 -0800 (PST) Received: from localhost ([::1]:52978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaB6C-0003cR-M0 for importer@patchew.org; Wed, 04 Nov 2020 00:12:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAmR-0007MZ-8x for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30074) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAmO-0004ra-LT for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:18 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-363-3Ds83iu1MEq-Ii9swDu7qQ-1; Tue, 03 Nov 2020 23:51:24 -0500 Received: by mail-wr1-f69.google.com with SMTP id w3so6590919wrt.11 for ; Tue, 03 Nov 2020 20:51:24 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id y187sm813239wmg.33.2020.11.03.20.51.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465535; 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=tvJ0s3bSV9g9bsoYugn7fOSbhCEdSfwOqB79D2kkBqw=; b=TRfWf/GVv5nWE4XMD5WGwt+C/uN7MQd5EhyCDN0nxc2vkJ4vIkrXn5vb0lkc7h4XciDFq5 o1Q5m9RsUbyY6dhDn8Im+g2y/rMHN6eoMXNm8QFJpDEymSHegccamhEMwhXjbpi4zvImW5 tdoKT3kWuzzpvMnQ7XiKl9B01aCHHIo= X-MC-Unique: 3Ds83iu1MEq-Ii9swDu7qQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tvJ0s3bSV9g9bsoYugn7fOSbhCEdSfwOqB79D2kkBqw=; b=gKcErJ+8xhNrwWR/u/v42mlQ5+AB8oQJSAOZFQwbiAiiFcAgaTakgQ3XF5b4JYPdn0 0P9zhGBvlQypvX+L8vd/S1zAfWNHzaztVd9I3bryejaQwR1hJiIHPs32O2vf7z1GuZIb bZ/f64WRVIgZG9z614jX5XU+nKXn5F0ET6tvpNdtGQPU5nzq23ZCYpQZglrdJP+aoZaD w1naFOn3rb3yc3pNYgBLVPc2rWLPrem4QUEh0lE+fFaY4yeYqfHa2foI1fz3OLBvfqyo zcrm/muUDB2trHgwCwKTLTpdndGXEC3ixbkT1RUdseTuw+kPeNGpi9SNATxzIP5hiBqW BMwA== X-Gm-Message-State: AOAM531xVfehDaxP9y65wmsz2UyQthgoyVvhdlKJXfZDcUCfy/OoohUr tnWv/dEpRa3bloIk61Qtn4NvXmA3tiJqXrR/Q2ae2jzDPc0V/qSwAtQXdWs6tsSMzI4TRTleVhl kX2zHZm64t766vZY= X-Received: by 2002:adf:db44:: with SMTP id f4mr3881025wrj.168.1604465482931; Tue, 03 Nov 2020 20:51:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNJp6EN/fqDWKrMt2U0OWC0ot8m6MY3XbBQ0nz6vZ4E1EgHuzhN+O6RTQKMsZSdOwmIWvn5Q== X-Received: by 2002:adf:db44:: with SMTP id f4mr3881011wrj.168.1604465482822; Tue, 03 Nov 2020 20:51:22 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:20 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 14/38] virtio-iommu: Store memory region in endpoint struct Message-ID: <20201104044937.226370-15-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eric Auger , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker Store the memory region associated to each endpoint into the endpoint structure, to allow efficient memory notification on map/unmap. Acked-by: Eric Auger Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-3-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 4c8f3909b7..a5c2d69aad 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -49,6 +49,7 @@ typedef struct VirtIOIOMMUDomain { typedef struct VirtIOIOMMUEndpoint { uint32_t id; VirtIOIOMMUDomain *domain; + IOMMUMemoryRegion *iommu_mr; QLIST_ENTRY(VirtIOIOMMUEndpoint) next; } VirtIOIOMMUEndpoint; =20 @@ -137,16 +138,19 @@ static VirtIOIOMMUEndpoint *virtio_iommu_get_endpoint= (VirtIOIOMMU *s, uint32_t ep_id) { VirtIOIOMMUEndpoint *ep; + IOMMUMemoryRegion *mr; =20 ep =3D g_tree_lookup(s->endpoints, GUINT_TO_POINTER(ep_id)); if (ep) { return ep; } - if (!virtio_iommu_mr(s, ep_id)) { + mr =3D virtio_iommu_mr(s, ep_id); + if (!mr) { return NULL; } ep =3D g_malloc0(sizeof(*ep)); ep->id =3D ep_id; + ep->iommu_mr =3D mr; trace_virtio_iommu_get_endpoint(ep_id); g_tree_insert(s->endpoints, GUINT_TO_POINTER(ep_id), ep); return ep; @@ -910,9 +914,14 @@ static gboolean reconstruct_endpoints(gpointer key, gp= ointer value, VirtIOIOMMU *s =3D (VirtIOIOMMU *)data; VirtIOIOMMUDomain *d =3D (VirtIOIOMMUDomain *)value; VirtIOIOMMUEndpoint *iter; + IOMMUMemoryRegion *mr; =20 QLIST_FOREACH(iter, &d->endpoint_list, next) { + mr =3D virtio_iommu_mr(s, iter->id); + assert(mr); + iter->domain =3D d; + iter->iommu_mr =3D mr; g_tree_insert(s->endpoints, GUINT_TO_POINTER(iter->id), iter); } return false; /* continue the domain traversal */ --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465955; cv=none; d=zohomail.com; s=zohoarc; b=R0snPcJ5diY1Okt1Zpu9LbnXJGsvvNEQnAqk2wui2+XuZXadjUnrlrSvwjF1UqroAWlKBKz7iBpgi2y+kbxNxeOMPabEXQS1M+99LGfsFvDVicKTbFcjsPFP0LPcE7HIcDUVIm6Xjsqpf3A2l00ggsne8f6qu/7wplmqGCLn4MY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465955; 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=2pTrzfIlEtuFgKli+YZx2cSmkYnPe9QRNfZXCU2zweM=; b=gfBhRo2MpcGBc18IyARpcqKI5Kvu8PzQ3R4xzj9YujOYPc5jtjDI+0dLBFldmhgpnS8Ry9JVHDyrfhSlocK9V8xfHZ50pv7w7qkiUTEWsJCQG4IM2vkfeVTN0KzowF3n24zQSzxVdTla+LdhRJb8PlD7YwwpoAYwPW5O5Jdf70w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604465955239860.8206349420336; Tue, 3 Nov 2020 20:59:15 -0800 (PST) Received: from localhost ([::1]:34076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAt8-00013S-5t for importer@patchew.org; Tue, 03 Nov 2020 23:59:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAlj-00069j-5O for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAlg-0004aR-Ql for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:34 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-278-W2bCENTVN12aa6GuU-eHLw-1; Tue, 03 Nov 2020 23:51:27 -0500 Received: by mail-wm1-f69.google.com with SMTP id u207so735580wmu.4 for ; Tue, 03 Nov 2020 20:51:26 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id z11sm848463wrr.66.2020.11.03.20.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465491; 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=2pTrzfIlEtuFgKli+YZx2cSmkYnPe9QRNfZXCU2zweM=; b=KAF3SUM+RpNMMtQvX4DxqwELOj6AiaB69aT96A7moLUkoouIuKV9mfRxjTc9faZ1VPbmlP hkLfpPkXUb0rLmvczOhfrz/jALAOMuu3mziGgSYgmRcL4mvylHLb12HbjSwZxGJdv0OAoe 4qCVk9LpXcFWgaJ19JVgd4J992YspF8= X-MC-Unique: W2bCENTVN12aa6GuU-eHLw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2pTrzfIlEtuFgKli+YZx2cSmkYnPe9QRNfZXCU2zweM=; b=l2LugV5Yj+4tFMMQVrmAtA9xxR6+1aTQEk39KtXcuyE96i5lE100M9tpobijxXJvuS c+TuOJ5Kt24w9AOrvInPDzK8LRm5QEN72s8jkVMOHSy/o2vlCiXqpbyJ8DZ+IQdvbnX2 k9YPctqF+juvAEbzJQP2fNxoH4AdqpAXbroefMjKuO1HhaVcGGrKMVsWCDOOH9Uu3o2N /d5WV9iBLizZaXXSuBZ/70p5yuRtoL6qfy6W5fij02QSvAWJJzZX5BHM194MNlrAb+Qw Dx1lrcTxZCvkAwKHvUByC0c9vzU2P15EUoCC4UcdpTl7l5cIqSmjtkVU8CqLDa7SfQQi 8NYQ== X-Gm-Message-State: AOAM533R/qWwBMr2zfZIW6HMFp75hJ8nhIxNubotCC6ZRSkTB9/ZeaaZ S18ow94n/b2hyM8CHA02TPQUhtYTAQncIUiC78gcjNbQXqmaTQOcyJ72bQSCe4XSS/kWWTME6N3 5kQrU1l07TdakuPI= X-Received: by 2002:a1c:5585:: with SMTP id j127mr2555723wmb.90.1604465485508; Tue, 03 Nov 2020 20:51:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAqMzYKxy7CXs0nvHxEwzZ34mDQojQEUVKk00cMP7QX/YZ5G5HwEjnbS8aSVR+x3dAc3tuag== X-Received: by 2002:a1c:5585:: with SMTP id j127mr2555712wmb.90.1604465485359; Tue, 03 Nov 2020 20:51:25 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:23 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 15/38] virtio-iommu: Add memory notifiers for map/unmap Message-ID: <20201104044937.226370-16-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Bharat Bhushan , Jean-Philippe Brucker , Eric Auger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bharat Bhushan Extend VIRTIO_IOMMU_T_MAP/UNMAP request to notify memory listeners. It will call VFIO notifier to map/unmap regions in the physical IOMMU. Signed-off-by: Bharat Bhushan Signed-off-by: Eric Auger Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-4-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 56 ++++++++++++++++++++++++++++++++++++++++ hw/virtio/trace-events | 2 ++ 2 files changed, 58 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index a5c2d69aad..7dd15c5eac 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -125,6 +125,51 @@ static gint interval_cmp(gconstpointer a, gconstpointe= r b, gpointer user_data) } } =20 +static void virtio_iommu_notify_map(IOMMUMemoryRegion *mr, hwaddr virt_sta= rt, + hwaddr virt_end, hwaddr paddr, + uint32_t flags) +{ + IOMMUTLBEntry entry; + IOMMUAccessFlags perm =3D IOMMU_ACCESS_FLAG(flags & VIRTIO_IOMMU_MAP_F= _READ, + flags & VIRTIO_IOMMU_MAP_F_W= RITE); + + if (!(mr->iommu_notify_flags & IOMMU_NOTIFIER_MAP) || + (flags & VIRTIO_IOMMU_MAP_F_MMIO) || !perm) { + return; + } + + trace_virtio_iommu_notify_map(mr->parent_obj.name, virt_start, virt_en= d, + paddr, perm); + + entry.target_as =3D &address_space_memory; + entry.addr_mask =3D virt_end - virt_start; + entry.iova =3D virt_start; + entry.perm =3D perm; + entry.translated_addr =3D paddr; + + memory_region_notify_iommu(mr, 0, entry); +} + +static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_s= tart, + hwaddr virt_end) +{ + IOMMUTLBEntry entry; + + if (!(mr->iommu_notify_flags & IOMMU_NOTIFIER_UNMAP)) { + return; + } + + trace_virtio_iommu_notify_unmap(mr->parent_obj.name, virt_start, virt_= end); + + entry.target_as =3D &address_space_memory; + entry.addr_mask =3D virt_end - virt_start; + entry.iova =3D virt_start; + entry.perm =3D IOMMU_NONE; + entry.translated_addr =3D 0; + + memory_region_notify_iommu(mr, 0, entry); +} + static void virtio_iommu_detach_endpoint_from_domain(VirtIOIOMMUEndpoint *= ep) { if (!ep->domain) { @@ -315,6 +360,7 @@ static int virtio_iommu_map(VirtIOIOMMU *s, VirtIOIOMMUDomain *domain; VirtIOIOMMUInterval *interval; VirtIOIOMMUMapping *mapping; + VirtIOIOMMUEndpoint *ep; =20 if (flags & ~VIRTIO_IOMMU_MAP_F_MASK) { return VIRTIO_IOMMU_S_INVAL; @@ -344,6 +390,11 @@ static int virtio_iommu_map(VirtIOIOMMU *s, =20 g_tree_insert(domain->mappings, interval, mapping); =20 + QLIST_FOREACH(ep, &domain->endpoint_list, next) { + virtio_iommu_notify_map(ep->iommu_mr, virt_start, virt_end, phys_s= tart, + flags); + } + return VIRTIO_IOMMU_S_OK; } =20 @@ -356,6 +407,7 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s, VirtIOIOMMUMapping *iter_val; VirtIOIOMMUInterval interval, *iter_key; VirtIOIOMMUDomain *domain; + VirtIOIOMMUEndpoint *ep; int ret =3D VIRTIO_IOMMU_S_OK; =20 trace_virtio_iommu_unmap(domain_id, virt_start, virt_end); @@ -373,6 +425,10 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s, uint64_t current_high =3D iter_key->high; =20 if (interval.low <=3D current_low && interval.high >=3D current_hi= gh) { + QLIST_FOREACH(ep, &domain->endpoint_list, next) { + virtio_iommu_notify_unmap(ep->iommu_mr, current_low, + current_high); + } g_tree_remove(domain->mappings, iter_key); trace_virtio_iommu_unmap_done(domain_id, current_low, current_= high); } else { diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index cf1e59de30..b87a397406 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -106,6 +106,8 @@ virtio_iommu_put_domain(uint32_t domain_id) "Free domai= n=3D%d" virtio_iommu_translate_out(uint64_t virt_addr, uint64_t phys_addr, uint32_= t sid) "0x%"PRIx64" -> 0x%"PRIx64 " for sid=3D%d" virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoin= t, uint64_t addr) "FAULT reason=3D%d flags=3D%d endpoint=3D%d address =3D0x= %"PRIx64 virtio_iommu_fill_resv_property(uint32_t devid, uint8_t subtype, uint64_t = start, uint64_t end) "dev=3D %d, type=3D%d start=3D0x%"PRIx64" end=3D0x%"PR= Ix64 +virtio_iommu_notify_map(const char *name, uint64_t virt_start, uint64_t vi= rt_end, uint64_t phys_start, uint32_t flags) "mr=3D%s virt_start=3D0x%"PRIx= 64" virt_end=3D0x%"PRIx64" phys_start=3D0x%"PRIx64" flags=3D%d" +virtio_iommu_notify_unmap(const char *name, uint64_t virt_start, uint64_t = virt_end) "mr=3D%s virt_start=3D0x%"PRIx64" virt_end=3D0x%"PRIx64 =20 # virtio-mem.c virtio_mem_send_response(uint16_t type) "type=3D%" PRIu16 --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604467056; cv=none; d=zohomail.com; s=zohoarc; b=PagmpL5YmFANsbmESvEXFlNBqjSkuLaP78e3kA7+cQdx+QkwqSfDlL2lMucNTUhxEYh8gHcJK22C9ZOtH1+7vKgis1geUUxtApoGJyhrUG3jOe0u+Jh/kuYgBiK7dDZmzdeJg6NdDvrwtVYo1JXirhPBQMge8cCIE5iv9ICJL2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604467056; 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=CO5kV6TOgl7VkllXO+Cj7QHVQ3FQj45OIYdaYC1hBZU=; b=A9XLvnNZobMGQleRbYsg/b+ZdrtL7GbwZrqxckicUYdnZBFvma/Pgr5fmf8OM1cacZfd78AT+mdWyniy+1ZkYic2ZEYUAhn7hFlb6jBWdKDRwxOc7ef9KIDioJqkHjgE+doviO3EGg/wiqODW2fFRnA4oM0Je+T1ETWcWwF9lCs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604467056846207.61663502327167; Tue, 3 Nov 2020 21:17:36 -0800 (PST) Received: from localhost ([::1]:40158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaBAt-0001Xq-PA for importer@patchew.org; Wed, 04 Nov 2020 00:17:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaApJ-0004R9-12 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:55:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:29079) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaApA-0005oH-Ll for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:55:15 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-32-maGUCr2INZKC-8hmwcHBnQ-1; Tue, 03 Nov 2020 23:51:30 -0500 Received: by mail-wr1-f72.google.com with SMTP id t14so8789124wrs.2 for ; Tue, 03 Nov 2020 20:51:29 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id b14sm907479wrx.35.2020.11.03.20.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465707; 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=CO5kV6TOgl7VkllXO+Cj7QHVQ3FQj45OIYdaYC1hBZU=; b=ald0BJOg2uufUkPLARaWt7iOQvxpWHWrG74+7S+gVTeqcPDshlg8P7pXGy7tN5C1BGNtvk bMC155H8euP56FVYjFi3UDa83a9lfz1pH+M1S/zRn3bOiy+ywiyPtsT2hjenzjeBGeGI0n V66Gj9flVCGCv7ROIb71Dkx3zJYFJ7E= X-MC-Unique: maGUCr2INZKC-8hmwcHBnQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CO5kV6TOgl7VkllXO+Cj7QHVQ3FQj45OIYdaYC1hBZU=; b=bNI64ZUKfYQFMRwJbfhl1PxS/iYjEUiJkZCTzhJZax8Cc6D4cEIHnV7ilEcYG2pmNt HOsKwK0mXkX4f04sTcbdptq7mV+BK44kEG8ipH43KnCFBSXhmqvyUmhhiMC3WNGUflO9 fJjq6aXXcpHv3TmaBWX00j9N/Mk27BliKDZvTYHCyC02afF6k+78xKd0uMwoBJJr5QBa KJm6wrHHxz0IfUp8lFAW/bG2N/R+uYR4DAIuOYjpXHFIzcAF/Tdi9G5PuxpST9IrziDt OsMWw4pZ/yvy5uhQnOM7ryn+QOmNk9VAWpSIUjxAk14pPlHNTcfW7piMqqHmmtmjI0yA LKnQ== X-Gm-Message-State: AOAM530oRd1do1TOQcXuy3ohFxY/fwhWMCxGRqj+HvKfohWa7yUblLWC MFTYTrWqTqEm9RqCiQs0fps8BlWwoH0k8eYhTz4+ADLTHZ5M6PF4LujHB7LsGluLbYu1o5rTE38 ry2+MQubDqkwDRl0= X-Received: by 2002:adf:fb0f:: with SMTP id c15mr28598133wrr.86.1604465488159; Tue, 03 Nov 2020 20:51:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRZPLaryJFJHgZvyaU93cZcFvJtW3aI4hv8+EdSZMLKtsAUr6L2VfA3B/J0sMJZrQFpRpAJw== X-Received: by 2002:adf:fb0f:: with SMTP id c15mr28598127wrr.86.1604465488045; Tue, 03 Nov 2020 20:51:28 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 16/38] virtio-iommu: Call memory notifiers in attach/detach Message-ID: <20201104044937.226370-17-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Bharat Bhushan , Eric Auger , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bharat Bhushan Call the memory notifiers when attaching an endpoint to a domain, to replay existing mappings, and when detaching the endpoint, to remove all mappings. Signed-off-by: Bharat Bhushan Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-5-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 7dd15c5eac..7b64892351 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -170,11 +170,39 @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegi= on *mr, hwaddr virt_start, memory_region_notify_iommu(mr, 0, entry); } =20 +static gboolean virtio_iommu_notify_unmap_cb(gpointer key, gpointer value, + gpointer data) +{ + VirtIOIOMMUInterval *interval =3D (VirtIOIOMMUInterval *) key; + IOMMUMemoryRegion *mr =3D (IOMMUMemoryRegion *) data; + + virtio_iommu_notify_unmap(mr, interval->low, interval->high); + + return false; +} + +static gboolean virtio_iommu_notify_map_cb(gpointer key, gpointer value, + gpointer data) +{ + VirtIOIOMMUMapping *mapping =3D (VirtIOIOMMUMapping *) value; + VirtIOIOMMUInterval *interval =3D (VirtIOIOMMUInterval *) key; + IOMMUMemoryRegion *mr =3D (IOMMUMemoryRegion *) data; + + virtio_iommu_notify_map(mr, interval->low, interval->high, + mapping->phys_addr, mapping->flags); + + return false; +} + static void virtio_iommu_detach_endpoint_from_domain(VirtIOIOMMUEndpoint *= ep) { + VirtIOIOMMUDomain *domain =3D ep->domain; + if (!ep->domain) { return; } + g_tree_foreach(domain->mappings, virtio_iommu_notify_unmap_cb, + ep->iommu_mr); QLIST_REMOVE(ep, next); ep->domain =3D NULL; } @@ -317,6 +345,10 @@ static int virtio_iommu_attach(VirtIOIOMMU *s, =20 ep->domain =3D domain; =20 + /* Replay domain mappings on the associated memory region */ + g_tree_foreach(domain->mappings, virtio_iommu_notify_map_cb, + ep->iommu_mr); + return VIRTIO_IOMMU_S_OK; } =20 --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466059; cv=none; d=zohomail.com; s=zohoarc; b=Mmjlo3FP1zBaGkBybjUw+6jrcTsu0glo9BFgupgxr5d8mjP1lrerwMkQCe6Qfwgl1IKeVU7WWrtuTqHPtZCXdlkRN/cwfo3Mz7XZ/xctXfB0fx7vKBG0Hvk6nfgsLFaI450ty8N4rKM0+3LgiA5yivaWvgNxg+O8aJsbWHbNoHQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466059; 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=Vj2K5KfIjYgXaS/HA+9u99+5hxZOJUDzQMD8f8h61Sg=; b=bR07NCt+HNG9++Fk085V9I9RonAdZxkBnbGguU0/HFwQ8ENsAzgGw2SwLZnYGiEL+JlIfWgESSLXCwKWnRCfjtRgdwvK1u5yP3HAJmx4jl73oqXcW7dhMGoUp0Gi0Mare0XJx8orLosq7yoA1JCqnMYCwmGNHBYWHRDgV1iRWkg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466059338518.5357451352132; Tue, 3 Nov 2020 21:00:59 -0800 (PST) Received: from localhost ([::1]:42494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAuo-0004VQ-6Z for importer@patchew.org; Wed, 04 Nov 2020 00:00:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAln-0006IY-1z for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58515) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAll-0004co-6m for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:38 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-TdhQxQgjO5OcY40vAajX4Q-1; Tue, 03 Nov 2020 23:51:32 -0500 Received: by mail-wm1-f72.google.com with SMTP id y187so737355wmy.3 for ; Tue, 03 Nov 2020 20:51:32 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id l16sm895622wrx.5.2020.11.03.20.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465496; 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=Vj2K5KfIjYgXaS/HA+9u99+5hxZOJUDzQMD8f8h61Sg=; b=HlmwABTDthLEqCT869/1qGu6+AMdLu5w8QWyXI1abwOWBp9g52QB+TZeGQXsH7x7pvbUnE VuphOymjRSGIIyB3SXyPHSx00G5gysBxCesuDNm8b9EpioKjmL0YBHMTrVzbLtP0ZIKBSv oKHwcTD3QPYP4ybygHiFUQGQCUXWNIQ= X-MC-Unique: TdhQxQgjO5OcY40vAajX4Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Vj2K5KfIjYgXaS/HA+9u99+5hxZOJUDzQMD8f8h61Sg=; b=ZmEwzvM+k+CJ0x35EJ5ftw37qZsGWYuItBFV/1rkJLJIcLCHzuBiOHWysZ0O+TPwUj P/hXo1/qZZyvcbyMcbV/rYN6EyAl07Slx/PwcPMxzf8ytkMDS9ZgTmDdHF70e/jwByW6 r845aocyYhq8WdT1D30srM6bZNb1Wf6MpcWFNTMCyYG5XbaoHvPp8sT2qaOAVl4Ud8r2 gE0tCesPAyc+EHck4TaXjp7A9gqfFWZLfZIfRz6HvNNS6tCQlF7Q0INCcHU5rY0yAVTG br7G2ipJkVqH5tNA1/4HXwhMLgLIjkwGaux/oJ44j2hmuhh4hbbk3VmYO20AUrx6j6j+ bz5Q== X-Gm-Message-State: AOAM533s0LJfKAxGkgrVdKBr5U/KP/aXIjg7hAWLNgrHZVXk1HAkX/5B ZEiGHxqcwEAc+MqdQyPHssqDRnHFoyDwDRaQ3nqyL3IpmSG5uNTYymhECJTKEqwmN4qt5fK83Qd ERGxnCNyGKBwCg7A= X-Received: by 2002:adf:e351:: with SMTP id n17mr4770347wrj.308.1604465490689; Tue, 03 Nov 2020 20:51:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+DQZnCtkejDjT38+1iy7yd8lYE/5YTyRA9Bs3ELkJ8Cm7dS4QCEHKCn7g1Ae6g2LFg/6r5A== X-Received: by 2002:adf:e351:: with SMTP id n17mr4770338wrj.308.1604465490569; Tue, 03 Nov 2020 20:51:30 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 17/38] virtio-iommu: Add replay() memory region callback Message-ID: <20201104044937.226370-18-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Bharat Bhushan , Eric Auger , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bharat Bhushan Implement the replay callback to setup all mappings for a new memory region. Signed-off-by: Bharat Bhushan Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-6-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 40 ++++++++++++++++++++++++++++++++++++++++ hw/virtio/trace-events | 1 + 2 files changed, 41 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 7b64892351..985257c88f 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -847,6 +847,45 @@ static gint int_cmp(gconstpointer a, gconstpointer b, = gpointer user_data) return (ua > ub) - (ua < ub); } =20 +static gboolean virtio_iommu_remap(gpointer key, gpointer value, gpointer = data) +{ + VirtIOIOMMUMapping *mapping =3D (VirtIOIOMMUMapping *) value; + VirtIOIOMMUInterval *interval =3D (VirtIOIOMMUInterval *) key; + IOMMUMemoryRegion *mr =3D (IOMMUMemoryRegion *) data; + + trace_virtio_iommu_remap(mr->parent_obj.name, interval->low, interval-= >high, + mapping->phys_addr); + virtio_iommu_notify_map(mr, interval->low, interval->high, + mapping->phys_addr, mapping->flags); + return false; +} + +static void virtio_iommu_replay(IOMMUMemoryRegion *mr, IOMMUNotifier *n) +{ + IOMMUDevice *sdev =3D container_of(mr, IOMMUDevice, iommu_mr); + VirtIOIOMMU *s =3D sdev->viommu; + uint32_t sid; + VirtIOIOMMUEndpoint *ep; + + sid =3D virtio_iommu_get_bdf(sdev); + + qemu_mutex_lock(&s->mutex); + + if (!s->endpoints) { + goto unlock; + } + + ep =3D g_tree_lookup(s->endpoints, GUINT_TO_POINTER(sid)); + if (!ep || !ep->domain) { + goto unlock; + } + + g_tree_foreach(ep->domain->mappings, virtio_iommu_remap, mr); + +unlock: + qemu_mutex_unlock(&s->mutex); +} + static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -1076,6 +1115,7 @@ static void virtio_iommu_memory_region_class_init(Obj= ectClass *klass, IOMMUMemoryRegionClass *imrc =3D IOMMU_MEMORY_REGION_CLASS(klass); =20 imrc->translate =3D virtio_iommu_translate; + imrc->replay =3D virtio_iommu_replay; } =20 static const TypeInfo virtio_iommu_info =3D { diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index b87a397406..ea3c3b25ad 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -108,6 +108,7 @@ virtio_iommu_report_fault(uint8_t reason, uint32_t flag= s, uint32_t endpoint, uin virtio_iommu_fill_resv_property(uint32_t devid, uint8_t subtype, uint64_t = start, uint64_t end) "dev=3D %d, type=3D%d start=3D0x%"PRIx64" end=3D0x%"PR= Ix64 virtio_iommu_notify_map(const char *name, uint64_t virt_start, uint64_t vi= rt_end, uint64_t phys_start, uint32_t flags) "mr=3D%s virt_start=3D0x%"PRIx= 64" virt_end=3D0x%"PRIx64" phys_start=3D0x%"PRIx64" flags=3D%d" virtio_iommu_notify_unmap(const char *name, uint64_t virt_start, uint64_t = virt_end) "mr=3D%s virt_start=3D0x%"PRIx64" virt_end=3D0x%"PRIx64 +virtio_iommu_remap(const char *name, uint64_t virt_start, uint64_t virt_en= d, uint64_t phys_start) "mr=3D%s virt_start=3D0x%"PRIx64" virt_end=3D0x%"PR= Ix64" phys_start=3D0x%"PRIx64 =20 # virtio-mem.c virtio_mem_send_response(uint16_t type) "type=3D%" PRIu16 --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465986; cv=none; d=zohomail.com; s=zohoarc; b=OqJEZgbJN0jJMjpTuk8+0MbIg8ib/ZJ3nWoy+dKXL87bcSE/1OK3zcnnYBHEwBleAefEU2NAgFkHN1gWDw+hdGp7JYZ9bP82llCRm+p+fQS/MTVZcJjWmfoL9hnQfihVNMeMkwpCUiiIklMigJ5Er8VUOsamRXQmho2dihoKiuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465986; 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=FfMG5NPSSgbiHzXp+0EZ66dpqrizcgkZqiSRInNVyXY=; b=GRW5C5p9oLSQUqTtSk+bPePjkFcp6wN+fFlGZ82burfKNcsHztdE+WVke+p3hIlS/JTRTxo0tuBkhTD1hZn0O720yk0RBNUKxb9ENtU+Y0/NW7EWTysNUVekzKwhMhvnf+WY0LfH31FX/8ZjniQCrRZ419dsoQ8jxkAPJfV+63o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604465986592308.42097871121837; Tue, 3 Nov 2020 20:59:46 -0800 (PST) Received: from localhost ([::1]:37368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAtd-0002MP-Af for importer@patchew.org; Tue, 03 Nov 2020 23:59:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAoR-0003Ff-Ip for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:54:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27963) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAoP-0005ZN-Qq for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:54:23 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-488-nO6vikAFPr2n7MszJ0lVdA-1; Tue, 03 Nov 2020 23:51:35 -0500 Received: by mail-wm1-f70.google.com with SMTP id t21so348583wmt.8 for ; Tue, 03 Nov 2020 20:51:34 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id b4sm859043wro.57.2020.11.03.20.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465661; 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=FfMG5NPSSgbiHzXp+0EZ66dpqrizcgkZqiSRInNVyXY=; b=LIMrDMcTtG6ccw5U4RaE6BD21x8hQCLZ+wGGDqBdksYO4U+RbiwkYzTm9NKypz+Qn6NoYy ZqzCcbagMWC2ggVJECNxffeV92YXhGCcLgDSa6hVjOLPVVsLG9pzk/peDejyTMA55TComu 9FQEmpMB5EFdFh0bP8qMBCDonAm/daw= X-MC-Unique: nO6vikAFPr2n7MszJ0lVdA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FfMG5NPSSgbiHzXp+0EZ66dpqrizcgkZqiSRInNVyXY=; b=jdRaGKbw+KWp6ymd8oEi/A1+Tigvpp43mtP7KSqNToo4EFRgtfiWdrQ2mUQapc92t7 PYzpmuS8z+kLC/XEHmcEwVMRDfEx3rRfdaVXhWP4lWymRUyOZ7OpcEwktoStVKqEZ/yb zhKEVYXIcgX+V8wXCCZ2CNE79x4sg9fX++77L4glVsLN7peGNKSUYiY/ppeuI+sfmDMw z7YkY5dYmzIKqnwRiPmMGMFsjZUbFO608jWUW8FnLeDSefKkxKOsXHrbUvIiE6KM2EqV INVDEVFt4HqONclepNxhZxAq+wmme2JDDJmhda1t0BiIAofWMQ67tlcVfmVmbuXIKvtc OKRw== X-Gm-Message-State: AOAM533dIoAscMy2VaJgMWwAZKqZHRYIo/C52TvUJSaEtvxUJ4W/UIBZ YdijAFTLDQpoHYnz7EYZRbcD71ZGwx+4KTuvVdS3ZFMzoWb5n54tnOT/qTDkSzaOetNCuheTYVV psNlXYrMM7JJUs70= X-Received: by 2002:a1c:9c51:: with SMTP id f78mr2538780wme.189.1604465493277; Tue, 03 Nov 2020 20:51:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfm37DJTuT+0bspB635VYK6q311o6nEx6dVRlyDbSkPk9sNUvqdY6sImBnIKAYWRS56SqDNg== X-Received: by 2002:a1c:9c51:: with SMTP id f78mr2538768wme.189.1604465493085; Tue, 03 Nov 2020 20:51:33 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:30 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 18/38] virtio-iommu: Add notify_flag_changed() memory region callback Message-ID: <20201104044937.226370-19-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Bharat Bhushan , Jean-Philippe Brucker , Eric Auger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bharat Bhushan Add notify_flag_changed() to notice when memory listeners are added and removed. Acked-by: Eric Auger Signed-off-by: Bharat Bhushan Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-7-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 14 ++++++++++++++ hw/virtio/trace-events | 2 ++ 2 files changed, 16 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 985257c88f..78e07aa40a 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -886,6 +886,19 @@ unlock: qemu_mutex_unlock(&s->mutex); } =20 +static int virtio_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu_mr, + IOMMUNotifierFlag old, + IOMMUNotifierFlag new, + Error **errp) +{ + if (old =3D=3D IOMMU_NOTIFIER_NONE) { + trace_virtio_iommu_notify_flag_add(iommu_mr->parent_obj.name); + } else if (new =3D=3D IOMMU_NOTIFIER_NONE) { + trace_virtio_iommu_notify_flag_del(iommu_mr->parent_obj.name); + } + return 0; +} + static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -1116,6 +1129,7 @@ static void virtio_iommu_memory_region_class_init(Obj= ectClass *klass, =20 imrc->translate =3D virtio_iommu_translate; imrc->replay =3D virtio_iommu_replay; + imrc->notify_flag_changed =3D virtio_iommu_notify_flag_changed; } =20 static const TypeInfo virtio_iommu_info =3D { diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index ea3c3b25ad..982d0002a6 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -109,6 +109,8 @@ virtio_iommu_fill_resv_property(uint32_t devid, uint8_t= subtype, uint64_t start, virtio_iommu_notify_map(const char *name, uint64_t virt_start, uint64_t vi= rt_end, uint64_t phys_start, uint32_t flags) "mr=3D%s virt_start=3D0x%"PRIx= 64" virt_end=3D0x%"PRIx64" phys_start=3D0x%"PRIx64" flags=3D%d" virtio_iommu_notify_unmap(const char *name, uint64_t virt_start, uint64_t = virt_end) "mr=3D%s virt_start=3D0x%"PRIx64" virt_end=3D0x%"PRIx64 virtio_iommu_remap(const char *name, uint64_t virt_start, uint64_t virt_en= d, uint64_t phys_start) "mr=3D%s virt_start=3D0x%"PRIx64" virt_end=3D0x%"PR= Ix64" phys_start=3D0x%"PRIx64 +virtio_iommu_notify_flag_add(const char *name) "add notifier to mr %s" +virtio_iommu_notify_flag_del(const char *name) "del notifier from mr %s" =20 # virtio-mem.c virtio_mem_send_response(uint16_t type) "type=3D%" PRIu16 --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466194; cv=none; d=zohomail.com; s=zohoarc; b=KyvBiU3ch429EM0lfk7h3QFryBItBvIjqI4lYygeTvn/kDhqE0cwgjbqWCgP9LIbADMwXxsKDS1zXHEE8gEQlyrr9/foKHQw3iBuzIx87Y7PmWqa6mOxMiUl/VYOu2AXqxw8XxrvPd4tye1MO995+qUPpGHchRnoJXGdSf4M6Nc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466194; 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=FzlYUeG8X4vs91S4tquZq9KM016eO3pXrdQjhhAV7O0=; b=GCyobitrIMety66OKms2hp1pIODV7WrErOWY84t1YRsXbuMa9xt7YxeLxBiV32LeVgKC6K+NEtuex2V0HQsEZ5UZcNPPLSUjMD6Yg7uzlbiwdLBTQ4dkPATBIkRF393RxPW8N+ndD9dRXtrhbBWdRwB1FEU69k6SYlFSiwzreUE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466194974270.0550376220557; Tue, 3 Nov 2020 21:03:14 -0800 (PST) Received: from localhost ([::1]:50914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAwz-0007x4-U8 for importer@patchew.org; Wed, 04 Nov 2020 00:03:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAlr-0006OV-4B for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45233) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAlp-0004fB-4L for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:42 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-235-1J3OIQa2N6aVHf2Acg8SRw-1; Tue, 03 Nov 2020 23:51:37 -0500 Received: by mail-wr1-f72.google.com with SMTP id t14so8789228wrs.2 for ; Tue, 03 Nov 2020 20:51:37 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id c2sm793532wmf.47.2020.11.03.20.51.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465500; 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=FzlYUeG8X4vs91S4tquZq9KM016eO3pXrdQjhhAV7O0=; b=YPXPvp09k27SqIkhY7wuAMzEKcr3zkmquEIe7Rh/Ihy7mopj1SOi8DjZPHXlHlPphIbJKS rjrH+ZfdyIFcdKAhj6s1KOX507IrlTxRApUgS/5BMQolf1DEUDr0xdctUiULuFp07CF6x0 wWof07T2I4Mdz6bZiZLUfdBzYNTRjAI= X-MC-Unique: 1J3OIQa2N6aVHf2Acg8SRw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FzlYUeG8X4vs91S4tquZq9KM016eO3pXrdQjhhAV7O0=; b=ky9BuMmB4St7F4gSAUB9OYWi8UADuhdjQHmsHMsRbrlFnYgp6iDzQQ8kEzQdP1sOd+ 6E9qmnQo0xtMsIthSQRtUxN8JfTzFXVi1w0Q3N6PI4zlmXQan+kJQvxkml3Qbu17iGXO 3E27tibW5ccWJv7rDxBhZDeH1ujTvxhzZ6YRva7RHDMHTx8/lUPR08NdKv84cgJ2aFoC e7UsZM41yT68XGtf4Zp6pLrUGtv3tk9mKUkPZYggCp8/q6wLCeKaHiRBEdsQ//Xbunr6 YiCw1DU9Ly360CyQ66vvML8KjVrLFhWAhHLXgR9tarG3CZIpVsYy0rrdwZzCHd2WV0pB OYWQ== X-Gm-Message-State: AOAM5322+lv+8SHSEe++oOF4J3Y3s1EfPa3kiM9FXm1UE7+A+MyQBbnL cAu4q9DJzdSopN5qKM4DILAf6TuH5NMn9IRM17I0uouocj0mFTZQn5qs9HAyKYgYms3QBh9ahJU GVeyOD1pa6q3hs+Y= X-Received: by 2002:a1c:2087:: with SMTP id g129mr2415211wmg.158.1604465496085; Tue, 03 Nov 2020 20:51:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJysWBFSIyYKEG6jpUrYK3pJvYS/CVP/UTpks7SE+B5QQz0HFn48HRexZm4r80M/85++NR9M2Q== X-Received: by 2002:a1c:2087:: with SMTP id g129mr2415197wmg.158.1604465495929; Tue, 03 Nov 2020 20:51:35 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 19/38] memory: Add interface to set iommu page size mask Message-ID: <20201104044937.226370-20-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jean-Philippe Brucker , Peter Xu , Eric Auger , Paolo Bonzini , Bharat Bhushan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bharat Bhushan Allow to set the page size mask supported by an iommu memory region. This enables a vIOMMU to communicate the page size granule supported by an assigned device, on hosts that use page sizes greater than 4kB. Acked-by: Peter Xu Reviewed-by: Eric Auger Signed-off-by: Bharat Bhushan Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-8-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/exec/memory.h | 38 ++++++++++++++++++++++++++++++++++++++ softmmu/memory.c | 13 +++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index aff6ef7605..0f3e6bcd5e 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -397,6 +397,32 @@ struct IOMMUMemoryRegionClass { * @iommu: the IOMMUMemoryRegion */ int (*num_indexes)(IOMMUMemoryRegion *iommu); + + /** + * @iommu_set_page_size_mask: + * + * Restrict the page size mask that can be supported with a given IOMMU + * memory region. Used for example to propagate host physical IOMMU pa= ge + * size mask limitations to the virtual IOMMU. + * + * Optional method: if this method is not provided, then the default g= lobal + * page mask is used. + * + * @iommu: the IOMMUMemoryRegion + * + * @page_size_mask: a bitmask of supported page sizes. At least one bi= t, + * representing the smallest page size, must be set. Additional set bi= ts + * represent supported block sizes. For example a host physical IOMMU = that + * uses page tables with a page size of 4kB, and supports 2MB and 4GB + * blocks, will set mask 0x40201000. A granule of 4kB with indiscrimin= ate + * block sizes is specified with mask 0xfffffffffffff000. + * + * Returns 0 on success, or a negative error. In case of failure, the = error + * object must be created. + */ + int (*iommu_set_page_size_mask)(IOMMUMemoryRegion *iommu, + uint64_t page_size_mask, + Error **errp); }; =20 typedef struct CoalescedMemoryRange CoalescedMemoryRange; @@ -1409,6 +1435,18 @@ int memory_region_iommu_attrs_to_index(IOMMUMemoryRe= gion *iommu_mr, */ int memory_region_iommu_num_indexes(IOMMUMemoryRegion *iommu_mr); =20 +/** + * memory_region_iommu_set_page_size_mask: set the supported page + * sizes for a given IOMMU memory region + * + * @iommu_mr: IOMMU memory region + * @page_size_mask: supported page size mask + * @errp: pointer to Error*, to store an error if it happens. + */ +int memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion *iommu_mr, + uint64_t page_size_mask, + Error **errp); + /** * memory_region_name: get a memory region's name * diff --git a/softmmu/memory.c b/softmmu/memory.c index 21d533d8ed..71951fe4dc 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -1841,6 +1841,19 @@ static int memory_region_update_iommu_notify_flags(I= OMMUMemoryRegion *iommu_mr, return ret; } =20 +int memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion *iommu_mr, + uint64_t page_size_mask, + Error **errp) +{ + IOMMUMemoryRegionClass *imrc =3D IOMMU_MEMORY_REGION_GET_CLASS(iommu_m= r); + int ret =3D 0; + + if (imrc->iommu_set_page_size_mask) { + ret =3D imrc->iommu_set_page_size_mask(iommu_mr, page_size_mask, e= rrp); + } + return ret; +} + int memory_region_register_iommu_notifier(MemoryRegion *mr, IOMMUNotifier *n, Error **errp) { --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466340; cv=none; d=zohomail.com; s=zohoarc; b=aWXeFVwDlE6z2T6sjYc1x435oKmc9IZuRMLZ5YbwGQA4CsHb2Zcvg2IDEzA2/a3MgZurpAiz/FOOVkYrsS9sZtEAkMQXa0ko8Z+9gO3YtYyCHWV3znzWH/cTDKVdQxCOFl/YFETSiazqq8OJDfLxhmuQgqpm10R2D5CwIvGzisE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466340; 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=ERBcIzJjq9q9CekQaOnDD1IPGOplWp3LnON28jdWCRA=; b=jKH6J28MNrms8mx2ngsA4qOHDPzTo9DGZyvSWUPCsbpNwIrCPFehwekW3upG2NWH6l+eO/mUvAlUQRKWPjtCAm40Fq+jiVj6p2Nb8unv1GJ7EVFssmVTB8OpiRWAq6dEAUgBrvudhoom8m5LDpHtO59sbSFklhLKhWao45zVdeo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466340324882.7684611729674; Tue, 3 Nov 2020 21:05:40 -0800 (PST) Received: from localhost ([::1]:57400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAzL-0002B2-83 for importer@patchew.org; Wed, 04 Nov 2020 00:05:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAlu-0006Pq-9D for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAlq-0004fb-QR for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:45 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-250-UkrgpNhrMwmlvpDqmWbqPQ-1; Tue, 03 Nov 2020 23:51:40 -0500 Received: by mail-wr1-f70.google.com with SMTP id q15so8709790wrw.8 for ; Tue, 03 Nov 2020 20:51:40 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id y200sm894471wmc.23.2020.11.03.20.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465501; 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=ERBcIzJjq9q9CekQaOnDD1IPGOplWp3LnON28jdWCRA=; b=C+stbv1o6EIkLykzaL7ieaEjYtKgwD0G/DwfEg3mHDzZCWDiZsukm2Y1BVTZVawqqmQZTU z4+nYAiGcTYgL8T0MxFQi+b7cE4eUVd2Z6f+ZFtWpZjm8BTlX68DEVpGD0t7F9bLvTlrtq uDczm0XvmMww3lhfR3iisNJaz2gjiO4= X-MC-Unique: UkrgpNhrMwmlvpDqmWbqPQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ERBcIzJjq9q9CekQaOnDD1IPGOplWp3LnON28jdWCRA=; b=DipnoZsuPaNPmkFlLnQKvuQtXiWJgdCFngp+PqnpFWB5Lh7v6ZqbI8AYsv65w7bt3Y MKziDbyu69pgcvl2aGVNV62L9fhnHeMEiCnEcfDljvD+T+U1VWcU4UEUFr4pGJwu0paz hrqGZctabapVaWd8o7MIEMZbDD1qS3ftxdzhDQMrQG04qyt88fm7n++zN7szHnUfbjJ5 YzNpPF2KRl6Pcld2pp/KH0JDWVQOhCS7UQO6AmZ759N2VNTGL9a6/ccSlmgsoFGyGOzr QlFe0n/JG8Y7rh/xBb40f6STpcI0KZIs1ShyCV/BWSL3mwYlyhc1MZ6Z/sOA58sFPfco jDXg== X-Gm-Message-State: AOAM530I9VZw6ptpKAE6zWQKhypzRiqv5M5AE2XoA0Pl29crH5q/YFxB vH8La88s8YbKpwROfjNAhb/+RAknfzoNC+aCQ3vnNz7dWw3dzX8r7lmbIt9HU7w7dw/eLB+lEX1 WwVu2ncUbiCU58Fk= X-Received: by 2002:adf:e549:: with SMTP id z9mr22622952wrm.359.1604465498996; Tue, 03 Nov 2020 20:51:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJynNy+x/v/WjC0HLUAAn67O9C3TV5DxhZlQdpja+7vezCSzoHYDheVxdpoDB5+OExfxXPGA5g== X-Received: by 2002:adf:e549:: with SMTP id z9mr22622941wrm.359.1604465498878; Tue, 03 Nov 2020 20:51:38 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:36 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 20/38] vfio: Set IOMMU page size as per host supported page size Message-ID: <20201104044937.226370-21-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jean-Philippe Brucker , Peter Maydell , Bharat Bhushan , Alex Williamson , Eric Auger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bharat Bhushan Set IOMMU supported page size mask same as host Linux supported page size mask. Acked-by: Alex Williamson Reviewed-by: Eric Auger Signed-off-by: Bharat Bhushan Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-9-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/vfio/common.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index e18ea2cf91..35895b18a6 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -789,6 +789,14 @@ static void vfio_listener_region_add(MemoryListener *l= istener, int128_get64(llend), iommu_idx); =20 + ret =3D memory_region_iommu_set_page_size_mask(giommu->iommu, + container->pgsizes, + &err); + if (ret) { + g_free(giommu); + goto fail; + } + ret =3D memory_region_register_iommu_notifier(section->mr, &giommu= ->n, &err); if (ret) { --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466390; cv=none; d=zohomail.com; s=zohoarc; b=ekCUo+M9ZBS/9TzS+ureY4VQVamVdJbIgD4OXg1yqO9LujBzUy171YVpg7Lj43O67f6X7oREKxZLhpxs01z3OXj1xErVyNztldUZkTPfPkbAbYTxNl6Piy+7vjc645A+shk8NvTqlaJjsXRFGx2xQI3GMADXBfsMgbkMfLVCzw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466390; 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=BrWBtHz+T2+mIPkAWH3w+WMghO+0VMpKeuA9wyAHhqM=; b=JHo2ohZgDrTfvg+j+W6Yyh2S7DAMLhE9XZ2o15v5aywtz8CkTI/AHJwfIZUyH6xBtzW5vK1hNvXAD7+NQoOX3i/Qric+bL3/d/AP72xzwzxPqnB1ejJhphm84ns5FdN8NOht4agRnYpu4of2c1vvHYapB5u8fGTD4EdEFXcTeOY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466390417286.15594548798583; Tue, 3 Nov 2020 21:06:30 -0800 (PST) Received: from localhost ([::1]:59412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaB09-0002zY-8b for importer@patchew.org; Wed, 04 Nov 2020 00:06:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAlw-0006Qx-8M for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:43979) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAlt-0004fy-Qf for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:47 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-520-m8IGIHTGMPW80lni1ZCflw-1; Tue, 03 Nov 2020 23:51:43 -0500 Received: by mail-wm1-f71.google.com with SMTP id 13so744730wmf.0 for ; Tue, 03 Nov 2020 20:51:42 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id u6sm790064wmj.40.2020.11.03.20.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465504; 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=BrWBtHz+T2+mIPkAWH3w+WMghO+0VMpKeuA9wyAHhqM=; b=CdMQITVINj1uAlE6J+Lvf+KR5kL94q6hrbbkCc0oU/kEcyRM3WegAMJ+/jSqeoi6zhrhhh XdicCsrW51cwFf5ebsMf21qikpe+gF1Z5G5Ultd8EoK17zm5uSwVHX/se5PKFL9/sEySuI 15hdMOoMd7l20AnCgD/0Yxdbw4WTPps= X-MC-Unique: m8IGIHTGMPW80lni1ZCflw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=BrWBtHz+T2+mIPkAWH3w+WMghO+0VMpKeuA9wyAHhqM=; b=aisO4H4QkbCyf5/G975q05EShohisxlYmVrvxBGILFcny38w/bjBbQxRNQmqm5C+d6 elYvlKkeaGTaUvzl99f/ZIsi7GMTNiSOh7+gisrKNXVvY4miwil3PU4Vf4jiRoITeIho dSjZPD5b7aW7oVRS4tkMQb4nY49arjPM+1ajyU1yj4+88kF+LjT526Korw4WFwmkDwLu 2lDrgsxk1C1sKMJTloEWYMEatjALStf/w5RTIBBhFJKxxa1Dd43waTEsAqAyWk9871jL mS6wcv/OTBhKaebuTeh/BqGIpmRVwQ9FdTNKD1o4WvY5aDvaL/XJ9yu7w+2mmxNOl21y 607A== X-Gm-Message-State: AOAM532gqNonffjqx6GGGIsuap/ZI4GNRFns+Z6tnbwBuUdqFhQXw0Lp ka+RvXVEWPMiMxaTeW2UoK0xqUr37A8E/SuiWIpiNwYcZYYL94JhsCFdW149TBusQXQJXtTBwE5 54ObZZOpdyYrPZxw= X-Received: by 2002:adf:b7c8:: with SMTP id t8mr30967516wre.143.1604465501475; Tue, 03 Nov 2020 20:51:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwe2EdXTETdB6TxowMHOuv+AJ/Md6n6qtBktremJgT6P0gF1idQkNhYGIU1CQ7CBHe4h6NyuQ== X-Received: by 2002:adf:b7c8:: with SMTP id t8mr30967508wre.143.1604465501329; Tue, 03 Nov 2020 20:51:41 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 21/38] virtio-iommu: Set supported page size mask Message-ID: <20201104044937.226370-22-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Bharat Bhushan , Eric Auger , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bharat Bhushan The virtio-iommu device can deal with arbitrary page sizes for virtual endpoints, but for endpoints assigned with VFIO it must follow the page granule used by the host IOMMU driver. Implement the interface to set the vIOMMU page size mask, called by VFIO for each endpoint. We assume that all host IOMMU drivers use the same page granule (the host page granule). Override the page_size_mask field in the virtio config space. Signed-off-by: Bharat Bhushan Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-10-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 50 ++++++++++++++++++++++++++++++++++++++++ hw/virtio/trace-events | 1 + 2 files changed, 51 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 78e07aa40a..fc5c75d693 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -899,6 +899,55 @@ static int virtio_iommu_notify_flag_changed(IOMMUMemor= yRegion *iommu_mr, return 0; } =20 +/* + * The default mask (TARGET_PAGE_MASK) is the smallest supported guest gra= nule, + * for example 0xfffffffffffff000. When an assigned device has page size + * restrictions due to the hardware IOMMU configuration, apply this restri= ction + * to the mask. + */ +static int virtio_iommu_set_page_size_mask(IOMMUMemoryRegion *mr, + uint64_t new_mask, + Error **errp) +{ + IOMMUDevice *sdev =3D container_of(mr, IOMMUDevice, iommu_mr); + VirtIOIOMMU *s =3D sdev->viommu; + uint64_t cur_mask =3D s->config.page_size_mask; + + trace_virtio_iommu_set_page_size_mask(mr->parent_obj.name, cur_mask, + new_mask); + + if ((cur_mask & new_mask) =3D=3D 0) { + error_setg(errp, "virtio-iommu page mask 0x%"PRIx64 + " is incompatible with mask 0x%"PRIx64, cur_mask, new_m= ask); + return -1; + } + + /* + * After the machine is finalized, we can't change the mask anymore. I= f by + * chance the hotplugged device supports the same granule, we can still + * accept it. Having a different masks is possible but the guest will = use + * sub-optimal block sizes, so warn about it. + */ + if (qdev_hotplug) { + int new_granule =3D ctz64(new_mask); + int cur_granule =3D ctz64(cur_mask); + + if (new_granule !=3D cur_granule) { + error_setg(errp, "virtio-iommu page mask 0x%"PRIx64 + " is incompatible with mask 0x%"PRIx64, cur_mask, + new_mask); + return -1; + } else if (new_mask !=3D cur_mask) { + warn_report("virtio-iommu page mask 0x%"PRIx64 + " does not match 0x%"PRIx64, cur_mask, new_mask); + } + return 0; + } + + s->config.page_size_mask &=3D new_mask; + return 0; +} + static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -1130,6 +1179,7 @@ static void virtio_iommu_memory_region_class_init(Obj= ectClass *klass, imrc->translate =3D virtio_iommu_translate; imrc->replay =3D virtio_iommu_replay; imrc->notify_flag_changed =3D virtio_iommu_notify_flag_changed; + imrc->iommu_set_page_size_mask =3D virtio_iommu_set_page_size_mask; } =20 static const TypeInfo virtio_iommu_info =3D { diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 982d0002a6..2060a144a2 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -109,6 +109,7 @@ virtio_iommu_fill_resv_property(uint32_t devid, uint8_t= subtype, uint64_t start, virtio_iommu_notify_map(const char *name, uint64_t virt_start, uint64_t vi= rt_end, uint64_t phys_start, uint32_t flags) "mr=3D%s virt_start=3D0x%"PRIx= 64" virt_end=3D0x%"PRIx64" phys_start=3D0x%"PRIx64" flags=3D%d" virtio_iommu_notify_unmap(const char *name, uint64_t virt_start, uint64_t = virt_end) "mr=3D%s virt_start=3D0x%"PRIx64" virt_end=3D0x%"PRIx64 virtio_iommu_remap(const char *name, uint64_t virt_start, uint64_t virt_en= d, uint64_t phys_start) "mr=3D%s virt_start=3D0x%"PRIx64" virt_end=3D0x%"PR= Ix64" phys_start=3D0x%"PRIx64 +virtio_iommu_set_page_size_mask(const char *name, uint64_t old, uint64_t n= ew) "mr=3D%s old_mask=3D0x%"PRIx64" new_mask=3D0x%"PRIx64 virtio_iommu_notify_flag_add(const char *name) "add notifier to mr %s" virtio_iommu_notify_flag_del(const char *name) "del notifier from mr %s" =20 --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465594; cv=none; d=zohomail.com; s=zohoarc; b=lKJxn6leWEbmhkN3N2X+/N+ny1ht55eLKBlSuWUtVJVjBURqHU0J+XGdiowACVCpjKuCDwE1S+gDCrueP5ok08mfEcJw20RoawOjClQapgm/f7JKNxUcQFSsYb7KD2xQnJCKykWsQX31hH55DXEUXFdJVKG44seSekNzV5te3Ms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465594; 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=aTAjTe4Celzp7fll7OULoNskonibl44hj9qWQyy3thE=; b=FiUE4ttEYdvz4Q5w12HoB9xPj9fQbE3QoWnyD2hwymMyqRd7pLCpb7cBAImrgskNs07ptMeiZA61/jpfLSpSXCP5mvCw1mxlLNYR/XKdVJC+rv/OEAsYJKJobxwBZw5nuopTT+lOWL9ELngDOyWs4ZugVWt1JmC4iKS7xU+Q+QY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604465594288394.12385593804834; Tue, 3 Nov 2020 20:53:14 -0800 (PST) Received: from localhost ([::1]:40298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAnJ-0000Rc-8s for importer@patchew.org; Tue, 03 Nov 2020 23:53:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAm0-0006VS-De for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46105) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAly-0004i4-LF for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:52 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-467-GS7UyUCuN7CjPwzz7BSQSQ-1; Tue, 03 Nov 2020 23:51:45 -0500 Received: by mail-wr1-f72.google.com with SMTP id 33so8658813wrf.22 for ; Tue, 03 Nov 2020 20:51:45 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id e25sm869056wrc.76.2020.11.03.20.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465510; 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=aTAjTe4Celzp7fll7OULoNskonibl44hj9qWQyy3thE=; b=YdnR6JkDKKPiDJIW2IpnMsyjbX1M6GQFog6Y98LcFC00MGtmc/UDedoVaS2d5Lr4roAM6l YO1jr6aqfFkAt8P3BXo2LeVxnF2v7ZQCclc5myr1oWMUi3+nJrsaKO55pXMiGUm55XeYCC 3bVyQjDTiXwUwZA9E05ZTLCgoWZ8JDk= X-MC-Unique: GS7UyUCuN7CjPwzz7BSQSQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aTAjTe4Celzp7fll7OULoNskonibl44hj9qWQyy3thE=; b=Go+hDhP2Ls7uf734CH8AAUnJhBiRJ7aa4aYAWmGrkZ2pI8hj4MqziFcLOl4Jeo6U0A aPaPY3R1rgISYQ7XSNkGC5fvzGDpWUkjm4euwG5BPaGcTm/NktN/DFhI/1qYwZJQBHYV j/g1PbFPcHpQFDkd6XX1fePHZm1CKMsBzd7BurWaVo14TxInUX2Zns6gznSJpRdnxTi3 3zz/B58eowbedqcnGXFD+8GiW51RIPlm4XvjAmZOmAFK0LfRZSAd3468SBcEWznEPJ9O UbssfkA428YpaJgA8du4pBHLOx2YbwbzU1jNWnD9AIzTIZgALfj1oBNEs0wkf3V3yRDq nS3A== X-Gm-Message-State: AOAM5310p+zMEtre9IMElK/tWlQgHO3dkWvQC3yh9bZ54yVdjAHoa489 bIdkDGm5NbF12dHRPGnljQeSB3k0mictW3BY2SsmtX3gIM/q6FGruVdZ5pv+MFhTlg2OpBma0qr a8ampnHiylqNq1j0= X-Received: by 2002:adf:f382:: with SMTP id m2mr1757596wro.342.1604465503876; Tue, 03 Nov 2020 20:51:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzY2gJxY8JhVmYi9SaouHrEWqRyOcSHLY0fG2iZHbRVgmt9X+C6uzN7HvwUBoIDUKqYJve0Yw== X-Received: by 2002:adf:f382:: with SMTP id m2mr1757586wro.342.1604465503750; Tue, 03 Nov 2020 20:51:43 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:41 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 22/38] vfio: Don't issue full 2^64 unmap Message-ID: <20201104044937.226370-23-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Alex Williamson , Eric Auger , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker IOMMUs may declare memory regions spanning from 0 to UINT64_MAX. When attempting to deal with such region, vfio_listener_region_del() passes a size of 2^64 to int128_get64() which throws an assertion failure. Even ignoring this, the VFIO_IOMMU_DMA_MAP ioctl cannot handle this size since the size field is 64-bit. Split the request in two. Acked-by: Alex Williamson Reviewed-by: Eric Auger Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-11-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/vfio/common.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 35895b18a6..c1fdbf17f2 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -950,6 +950,17 @@ static void vfio_listener_region_del(MemoryListener *l= istener, } =20 if (try_unmap) { + if (int128_eq(llsize, int128_2_64())) { + /* The unmap ioctl doesn't accept a full 64-bit span. */ + llsize =3D int128_rshift(llsize, 1); + ret =3D vfio_dma_unmap(container, iova, int128_get64(llsize), = NULL); + if (ret) { + error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", " + "0x%"HWADDR_PRIx") =3D %d (%m)", + container, iova, int128_get64(llsize), ret); + } + iova +=3D int128_get64(llsize); + } ret =3D vfio_dma_unmap(container, iova, int128_get64(llsize), NULL= ); if (ret) { error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", " --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465629; cv=none; d=zohomail.com; s=zohoarc; b=d+TSNTGTLMdaEfDJ0yrDgN/XMBVDbLtf7lubG0UJ5mOYfl9aqAzHeAPUmgvF3jJkJZzdmk4u42A6imONt0gXc5/XciyslVOMj4m1fYsTDLND/D3uCau+cowr6yjEsumuA27g0+ZmAu5j/5wakGjjA2vVTxXR9v9S4gM/vK5eVS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465629; 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=Try6I8+Gzp362j90+uCp08fdMyiL5wC2Bsqj8twh+n4=; b=G72tLOQ5ZSUrP3SEZxRT4xV1O4YjjfGm9/rJLG4+8ayhWbHND/JpLk3LhKS5LVPKJmR/fAnBjAWcS7dK/4Wer29Drr5j2AxWyTuYrqC/7b/v1bmFSX+zUfxhdE8KZZURjN91yhVgtyiR7C5m1yyfq5pXkYhTe+MwqBQG8zbcbqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604465629115326.79988742041644; Tue, 3 Nov 2020 20:53:49 -0800 (PST) Received: from localhost ([::1]:43470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAnr-0001ie-Vj for importer@patchew.org; Tue, 03 Nov 2020 23:53:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAm0-0006Vv-Mt for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47322) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAly-0004i5-Uq for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:52 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-8v1fAzpSPo2bMxLUT_LIdQ-1; Tue, 03 Nov 2020 23:51:48 -0500 Received: by mail-wr1-f71.google.com with SMTP id t14so8789357wrs.2 for ; Tue, 03 Nov 2020 20:51:47 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id l124sm793759wml.48.2020.11.03.20.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465510; 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=Try6I8+Gzp362j90+uCp08fdMyiL5wC2Bsqj8twh+n4=; b=Et04BCcfpAhX8Js1zFMDzE+PxMfDbQsfb7q3/oihujBQvPYE/Vu6XUjkYX+Jc6bLl9XNVy NDrMr1X1qP3F96uv9y27v4CCH6szPUp7KuH01zJLexh66hFW+/9I1aila7+2LlgJ0JHNGE vcxgkaosaPyIHh5fYphR0va6sY4Y47U= X-MC-Unique: 8v1fAzpSPo2bMxLUT_LIdQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Try6I8+Gzp362j90+uCp08fdMyiL5wC2Bsqj8twh+n4=; b=AsWXDeDmCnyUZAU+eKyRaTyW5ftFwaoETghw9p9wTiWLwnpKu2+mRo++99rDzPF1zO UlpVwSKc8KaYdxT06g9l2umDLdeLmCB1sMVDIy7DmqzGrPBF6KaxSKrsVU4DmvlrWJiV FXULFEuCWvm/9eGPaNDzgyQ9A2gwOIGvVfvbipgjml8HPsKKM/1KOg+Bz0NsDsiPmIrx YPrQEat/T75cxOcVuK3LlEJ+3vnd9qyQE7M4O0pZ7z2mI0MPLWoykXid+VXy9N/opyIf ObJzGu81VBU3J8vMXAbUN+6kaCzjQjf3DU0CMFGpMAOHfDG7RMWrt2iAWAlGtimz0aWZ V3/Q== X-Gm-Message-State: AOAM532C0+Lx1XBsMdeE9Ht9MC3eA82AgISRmpxbHIpXSSmBkfY+/Psn 6MxcdpM1l4AQTr44ZZoqehJvbIjUdCtzqqtCIk9ZfBSX7Zpr3T+6ZB7EMkeVP8CqrltDSG9QQRw ID1jQ2xYxnfE6mYQ= X-Received: by 2002:a5d:4ed2:: with SMTP id s18mr29556073wrv.36.1604465506457; Tue, 03 Nov 2020 20:51:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkC41vEDkSjBzdc5GdhMzxiDNqIdGrNXQ+nOWqCwh93E8qMJx3YdMRIzizvN4ZQjUvOvuvRA== X-Received: by 2002:a5d:4ed2:: with SMTP id s18mr29556061wrv.36.1604465506336; Tue, 03 Nov 2020 20:51:46 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:44 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 23/38] vhost-vdpa: Add qemu_close in vhost_vdpa_cleanup Message-ID: <20201104044937.226370-24-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , 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) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu fix the bug that fd will still open after the cleanup Signed-off-by: Cindy Lu Message-Id: <20201016030909.9522-1-lulu@redhat.com> Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 99c476db8c..fe659ec9e2 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -145,6 +145,10 @@ static void vhost_vdpa_cleanup(NetClientState *nc) g_free(s->vhost_net); s->vhost_net =3D NULL; } + if (s->vhost_vdpa.device_fd >=3D 0) { + qemu_close(s->vhost_vdpa.device_fd); + s->vhost_vdpa.device_fd =3D -1; + } } =20 static bool vhost_vdpa_has_vnet_hdr(NetClientState *nc) --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465936; cv=none; d=zohomail.com; s=zohoarc; b=dwicVtSAu1Qwn/A0b2k/nISXnUao5P8Utm5nsM7FUcw32635EJDTMRlKv0EoztrD45yGvYnzEEen6gisgQkmdBtUZ5hnVKDBp+Tugv0MmfdyDec1kqZRmGqXBMLDCnb12m7uhhcIiusECaDROVEirAz13yfMCmAgLOdADInWdOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465936; 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=MaK8aBvBSiaUINk0iflL/mAr7Ti2mM7e4TQ+bKVJ1uk=; b=ez9euOEVx0wf1C2Ha8CKQGHkEbSa90tUUtJedXO+qgKtShC+Zzi8RBMW/nmrKWXWTBwoj9fKuY35bK9G9SFY4nEIuwZr1X/W6bIGe6g/6LNR4mg0R9wqxBXjAVhP/u7XDCs7D89Ccq1caNENFSRud2aAeuGunTioWwMdCfU6sZg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604465936297973.5684187566538; Tue, 3 Nov 2020 20:58:56 -0800 (PST) Received: from localhost ([::1]:60250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAso-0000CC-3H for importer@patchew.org; Tue, 03 Nov 2020 23:58:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAm3-0006ba-NZ for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27417) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAm1-0004j8-HR for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:55 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-556-1nildKkpPVCljtPkapJE9A-1; Tue, 03 Nov 2020 23:51:50 -0500 Received: by mail-wr1-f71.google.com with SMTP id w1so8715547wrr.5 for ; Tue, 03 Nov 2020 20:51:50 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id t7sm854570wrx.42.2020.11.03.20.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465512; 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=MaK8aBvBSiaUINk0iflL/mAr7Ti2mM7e4TQ+bKVJ1uk=; b=K76xfGPUUSbvGvNw5sSXU7YAZu+g1/d3FRLi/ZuBtUb61TUK2T5p4AcAk7kKkPn0hCnOTb qnorTR+5tal2BX/JJjiPRe+PYBPUVB5G6fSQh00m92eY0O2vBwvKBX7JLoIwD7lYNM0SjB ikpaDILNxt+VLksjHt2BMDr+zPlNF3c= X-MC-Unique: 1nildKkpPVCljtPkapJE9A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MaK8aBvBSiaUINk0iflL/mAr7Ti2mM7e4TQ+bKVJ1uk=; b=CdiAjhsLk9IHfztGDbfZXglTEvPVxU06FFZ5soiCbSRjIlHLtVeA4c4Ex+RlqIf34F TH9OcAUo4jKlEuhOMjW53YmLnWWhCW65zJz5oS2IwMv3iePBPXattayiuPu6AmfJGS4S EadxsDqUikLeWD9GBqlIW8nwHaS6GC7nPJvCRKfrE03FpY8MvuTxEZZH1CxCIwLZY8nd iBmOPtiMvSnwu8mlv7ACRIUEZbYCeoaJuaKqOkvMC5J30urNouTrj/3zpytU0+nJNgK3 2/vz95V+vDBGRIh/YJgJzeIz0QhQT4qF8jCdmGIm9IUzaASbjCXzLsREJx4x9g9Ohivb o8qA== X-Gm-Message-State: AOAM530+T0z7jzLjaMP+Qnd1GojIbodLOrxvw/E+tczmLcMBeiedPUqX 7ITH+S8OrwY2TPM/jC6bS9SMsM9+QlYaDV25q1KTanCyTUX8F1/j396O8wQp70axYYqHm7Q9Y4i V8FJHmXoe2AqfJyk= X-Received: by 2002:a7b:cb09:: with SMTP id u9mr2424751wmj.109.1604465509087; Tue, 03 Nov 2020 20:51:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMxLv+JaZiHu4RcPVJRW7FNGOc2a8eHWNjlgmREoTUDgMp7oZVs7xCNvk0cNW+rHNLY9LZoQ== X-Received: by 2002:a7b:cb09:: with SMTP id u9mr2424743wmj.109.1604465508908; Tue, 03 Nov 2020 20:51:48 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 24/38] net: Add vhost-vdpa in show_netdevs() Message-ID: <20201104044937.226370-25-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , 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) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu Fix the bug that while Check qemu supported netdev, there is no vhost-vdpa Signed-off-by: Cindy Lu Message-Id: <20201016030909.9522-2-lulu@redhat.com> Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/net.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/net.c b/net/net.c index 7a2a0fb5ac..794c652282 100644 --- a/net/net.c +++ b/net/net.c @@ -1049,6 +1049,9 @@ static void show_netdevs(void) #endif #ifdef CONFIG_POSIX "vhost-user", +#endif +#ifdef CONFIG_VHOST_VDPA + "vhost-vdpa", #endif }; =20 --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466529; cv=none; d=zohomail.com; s=zohoarc; b=YN23FZKcpmAJ3y1msxYm6Mq4vc9DCf7hN/y1UC4DwGt7/HJAUzDFGkXdjNMw/r9woDf+7SVl8a3qLTexuAftC+ylWExy0rqqBTlbcs+NCZWeNhicekHqKnjYJA8u/G/soiBl1g/FvXV6mGMIbWnTiikaGA4Vr06cvnSD5FK0Mno= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466529; 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=oxFgfij5tGa7wsPJMg6guJqSTCSDLHe43Ge56aYH6Hc=; b=QoXaLeKDnbZF9z+2hbI8fIQpk8HbBfVrtWqyGQbBwN/YslawFBIb2zz2QoXebyJ5B5PUhqwEhFDdFuSnQpChn6P+1mt2GR2uGwB5pgBg3SwetyAotjGi5qfTYADSydnbALzH9PIbWD8BXtWQ2+TmSRgzMvLF+ygtbFuAkaczMLM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466529827641.7717891687892; Tue, 3 Nov 2020 21:08:49 -0800 (PST) Received: from localhost ([::1]:37688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaB2O-0005lQ-Kn for importer@patchew.org; Wed, 04 Nov 2020 00:08:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAm6-0006i4-8H for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:32191) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAm4-0004jU-GJ for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:51:57 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-316-1vIlnRScMhyEgwDSKVMV-A-1; Tue, 03 Nov 2020 23:51:53 -0500 Received: by mail-wr1-f71.google.com with SMTP id v5so8788952wrr.0 for ; Tue, 03 Nov 2020 20:51:53 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id v14sm865180wrq.46.2020.11.03.20.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465515; 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=oxFgfij5tGa7wsPJMg6guJqSTCSDLHe43Ge56aYH6Hc=; b=iS6flMErWKHzOt/HJkraFurL688Q+RIj0J4x/6r5arizv5YJE66Yd40Xzygv7CoDa4rBzm lP5CyjgHVJdw0xvZLuShxgtrWzfUyvvuh4hNeVbpqdz3ZDJDUcwMusxFKRgHCJ+P487QbC KU2hI5B5dYZeTJIj9sygFnPkPI7j0Gg= X-MC-Unique: 1vIlnRScMhyEgwDSKVMV-A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=oxFgfij5tGa7wsPJMg6guJqSTCSDLHe43Ge56aYH6Hc=; b=MbRqIhapM01IA3hszTB7GJStPVkzevgZX3b7rChDnjhBBnHz5mGQWtjoU0b8Hjcdn/ CtVavZ13WGeyvV+leHeCvNwHDoOYod8JOlWhYyvWZwMcIavQX96O0vwPtY0wsYZczrj4 Z4qyqORz04JoLdyEYlZFOb7zza7Olv3ak/SacB+S/uCogvOOUtbBWPYotiajdli1bIcx CEsTlNpWJemCuQmZXSUgR1OtglL6OBjoQyp+vsALreM10m/YjWnFNKTxXC9z/na9/1pk lfqqdJGh6tRvFMHAGG5UzJUxeEWri/R80uY30sMVd2ZicPemCARDAgmDwz6H2moUqzSp 7QKg== X-Gm-Message-State: AOAM533jNpAMKiS2R6sL68uybCrM1ovPluiJNE0SQStsdymYjMe1neRh IfXSbangbLQDgLYYtRKcz/9oZLIAOkpdg7G1xCfZvWwmeiLLGAPiH0ZeEudzRsdTHVx4qttK9nI clSMiPKwUo/3jE74= X-Received: by 2002:adf:f181:: with SMTP id h1mr30596327wro.374.1604465511725; Tue, 03 Nov 2020 20:51:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgE2spbSPxLsDfn+OBVTzrt4S7DgdJp17S/fpE/FAEam4thHp2XPibTLdC5DkvE5WZelVqKQ== X-Received: by 2002:adf:f181:: with SMTP id h1mr30596318wro.374.1604465511605; Tue, 03 Nov 2020 20:51:51 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 25/38] Revert "vhost-blk: set features before setting inflight feature" Message-ID: <20201104044937.226370-26-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Jin Yu , Max Reitz , Stefan Hajnoczi , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi This reverts commit adb29c027341ba095a3ef4beef6aaef86d3a520e. The commit broke -device vhost-user-blk-pci because the vhost_dev_prepare_inflight() function it introduced segfaults in vhost_dev_set_features() when attempting to access struct vhost_dev's vdev pointer before it has been assigned. To reproduce the segfault simply launch a vhost-user-blk device with the contrib vhost-user-blk device backend: $ build/contrib/vhost-user-blk/vhost-user-blk -s /tmp/vhost-user-blk.sock= -r -b /var/tmp/foo.img $ build/qemu-system-x86_64 \ -device vhost-user-blk-pci,id=3Ddrv0,chardev=3Dchar1,addr=3D4.0 \ -object memory-backend-memfd,id=3Dmem,size=3D1G,share=3Don \ -M memory-backend=3Dmem,accel=3Dkvm \ -chardev socket,id=3Dchar1,path=3D/tmp/vhost-user-blk.sock Segmentation fault (core dumped) Cc: Jin Yu Cc: Raphael Norwitz Cc: Michael S. Tsirkin Signed-off-by: Stefan Hajnoczi Message-Id: <20201102165709.232180-1-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost.h | 1 - hw/block/vhost-user-blk.c | 6 ------ hw/virtio/vhost.c | 18 ------------------ 3 files changed, 25 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 839bfb153c..94585067f7 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -141,7 +141,6 @@ void vhost_dev_reset_inflight(struct vhost_inflight *in= flight); void vhost_dev_free_inflight(struct vhost_inflight *inflight); void vhost_dev_save_inflight(struct vhost_inflight *inflight, QEMUFile *f); int vhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f); -int vhost_dev_prepare_inflight(struct vhost_dev *hdev); int vhost_dev_set_inflight(struct vhost_dev *dev, struct vhost_inflight *inflight); int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size, diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index f67b29bbf3..a076b1e54d 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -131,12 +131,6 @@ static int vhost_user_blk_start(VirtIODevice *vdev) =20 s->dev.acked_features =3D vdev->guest_features; =20 - ret =3D vhost_dev_prepare_inflight(&s->dev); - if (ret < 0) { - error_report("Error set inflight format: %d", -ret); - goto err_guest_notifiers; - } - if (!s->inflight->addr) { ret =3D vhost_dev_get_inflight(&s->dev, s->queue_size, s->inflight= ); if (ret < 0) { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index f2482378c6..79b2be20df 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1645,24 +1645,6 @@ int vhost_dev_load_inflight(struct vhost_inflight *i= nflight, QEMUFile *f) return 0; } =20 -int vhost_dev_prepare_inflight(struct vhost_dev *hdev) -{ - int r; -=20 - if (hdev->vhost_ops->vhost_get_inflight_fd =3D=3D NULL || - hdev->vhost_ops->vhost_set_inflight_fd =3D=3D NULL) { - return 0; - } -=20 - r =3D vhost_dev_set_features(hdev, hdev->log_enabled); - if (r < 0) { - VHOST_OPS_DEBUG("vhost_dev_prepare_inflight failed"); - return r; - } - - return 0; -} - int vhost_dev_set_inflight(struct vhost_dev *dev, struct vhost_inflight *inflight) { --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466557; cv=none; d=zohomail.com; s=zohoarc; b=mW7WAUaEubQEs1q8ndz0wUO5pgWH6YtHc5W2wAJNUGGF+es3teo8OGKchpJR3gMEWHQ5LdE7RSqe4/JIhwI1I7PNlG0N//abbh0I7UsFNi4FTb+kM0n+0K5jEU6rz8LcaniTu3frcBGCLafvShltjhOUK4V3dMTKMQI8veVa+Qg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466557; 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=ay6G7kYGtMwl+/IxEdsu272p/jXvwydr69tjR0/ihX0=; b=UapX/2u0UlMtTwqSAr154bSd30VAHaFmWhozpBjCE7oJ+x/nL2bBxhuk0ILv6C1qC8qz6+eOfg8hAhrQtPYTsUocTMnYsl35Zal14dxC4AQaJwFy59S58GB8n0K1cI6uoDDD8Ktx3Ze1dD492QxY62dN/K+wru6JoNkVFf6zfto= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466557729728.3515987443919; Tue, 3 Nov 2020 21:09:17 -0800 (PST) Received: from localhost ([::1]:40352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaB2q-0006qg-MP for importer@patchew.org; Wed, 04 Nov 2020 00:09:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAm9-0006oP-Et for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:20222) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAm7-0004ka-Fs for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:01 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-22K-WlXRNqCywc92m1tfAQ-1; Tue, 03 Nov 2020 23:51:56 -0500 Received: by mail-wr1-f72.google.com with SMTP id 33so8658983wrf.22 for ; Tue, 03 Nov 2020 20:51:56 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id s9sm880369wrf.90.2020.11.03.20.51.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465518; 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=ay6G7kYGtMwl+/IxEdsu272p/jXvwydr69tjR0/ihX0=; b=Jp6f8Ki2IEJbTtoGQyNJItpXLLfjl6iuDlZ+U37cVs2jwInULsNdO/Z1ms8fMH7SkATN/a LTDdOESK/Kt4uVxXeeyoPc8W97K7WPAj8Oxl0PMG/z/U1vxftREKK4aBukX23b2fdsHvhX I/CrrxYw+urVUxuRNpcZdyKFyGF6RO0= X-MC-Unique: 22K-WlXRNqCywc92m1tfAQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ay6G7kYGtMwl+/IxEdsu272p/jXvwydr69tjR0/ihX0=; b=D/MdRe7scREx+D7KpqhRWCorLrvr/j/4UzBhbNCTQqv69Fg17dSevP1XJy/ZnBrY6g aaGer3uXjHF9aW6ESLTCwFhv5v//jEbIZmyUfHRr55mTnsqE+feGvU24IB1r8DemeKBO Nj4Uo1OgO3EJlgaVI+2+Muz0oiRu7/lzMHhHu+JE0kwDrJgfs44APhFwqttrElxC0Zk8 wKXS35dx4Zk0n74dPgfC94WYfnjObMm7LEsHK5n1I4Thr5aznjFQsL8SjDmhsogND5TW mrcMmU+xy34885LhVUssv0UMynw0ZzfVSORTQSYDtIrLoo7OCAB182AgUQtErGAXJR71 yCQA== X-Gm-Message-State: AOAM530AvGfmMeGse1Pun2dZYBUs0h1Yqm5xOp1kcK0HI80mGUBhsHMH bIZzblfA8GSOa8fD0IJ5Rq4cmuQhHELHgBkpTY8F0q9dCoq2qlIotWFjhdCPY1sSSc65o6t+dSa jdW8LDzz4ZY5bSrY= X-Received: by 2002:a7b:cf1a:: with SMTP id l26mr2502240wmg.18.1604465514552; Tue, 03 Nov 2020 20:51:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaV+HNlC7gSFAZlnRC5mQk5GWWYvogD9kRo5K9QJg3virI3EhAYqoPl6o2oVWrj9ujZmLuxg== X-Received: by 2002:a7b:cf1a:: with SMTP id l26mr2502230wmg.18.1604465514434; Tue, 03 Nov 2020 20:51:54 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:52 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 26/38] vhost-blk: set features before setting inflight feature Message-ID: <20201104044937.226370-27-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Jin Yu , Max Reitz , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jin Yu Virtqueue has split and packed, so before setting inflight, you need to inform the back-end virtqueue format. Signed-off-by: Jin Yu Acked-by: Raphael Norwitz Message-Id: <20201103123617.28256-1-jin.yu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost.h | 1 + hw/block/vhost-user-blk.c | 6 ++++++ hw/virtio/vhost.c | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 94585067f7..4a8bc75415 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -141,6 +141,7 @@ void vhost_dev_reset_inflight(struct vhost_inflight *in= flight); void vhost_dev_free_inflight(struct vhost_inflight *inflight); void vhost_dev_save_inflight(struct vhost_inflight *inflight, QEMUFile *f); int vhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f); +int vhost_dev_prepare_inflight(struct vhost_dev *hdev, VirtIODevice *vdev); int vhost_dev_set_inflight(struct vhost_dev *dev, struct vhost_inflight *inflight); int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size, diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index a076b1e54d..2dd3d93ca0 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -131,6 +131,12 @@ static int vhost_user_blk_start(VirtIODevice *vdev) =20 s->dev.acked_features =3D vdev->guest_features; =20 + ret =3D vhost_dev_prepare_inflight(&s->dev, vdev); + if (ret < 0) { + error_report("Error set inflight format: %d", -ret); + goto err_guest_notifiers; + } + if (!s->inflight->addr) { ret =3D vhost_dev_get_inflight(&s->dev, s->queue_size, s->inflight= ); if (ret < 0) { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 79b2be20df..614ccc2bcb 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1645,6 +1645,26 @@ int vhost_dev_load_inflight(struct vhost_inflight *i= nflight, QEMUFile *f) return 0; } =20 +int vhost_dev_prepare_inflight(struct vhost_dev *hdev, VirtIODevice *vdev) +{ + int r; + + if (hdev->vhost_ops->vhost_get_inflight_fd =3D=3D NULL || + hdev->vhost_ops->vhost_set_inflight_fd =3D=3D NULL) { + return 0; + } + + hdev->vdev =3D vdev; + + r =3D vhost_dev_set_features(hdev, hdev->log_enabled); + if (r < 0) { + VHOST_OPS_DEBUG("vhost_dev_prepare_inflight failed"); + return r; + } + + return 0; +} + int vhost_dev_set_inflight(struct vhost_dev *dev, struct vhost_inflight *inflight) { --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466024; cv=none; d=zohomail.com; s=zohoarc; b=Ld3uMhG37M2d3dT4aAQ4Ev8XebCvSbj22HYg7AY3XnPSFvIEfiucg9HJDFMyQc7Mp1QOYNoLd7T0dikD5F6ALgRBIq/+36kDyRyNGzrFHM+KxBR5siCdd5I6YdCljBrJjHgG/jh9pLhrJiyZIBFdkCNektutJJtdCxTyZSwwoLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466024; 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=APdAnMGOimWpi0/lmUkQSWdNUl1kK18oif2GgMOHc/o=; b=lbepJhSuEki4gizWgly9B9KIhpws0tJZGc+VAE/2euxKeWryBc6ARKsEVsdx4lBSwX+kICY5GArbd0p+5D8UAasN/bVtZ/GEgETnA6ReTvOfYnATKp5Q+e/bwIzh19ZS1l27v+JJoVnKh3yi/H7nRXEMaop+OPyYyLtCLxjHd+k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466024410903.6059520633621; Tue, 3 Nov 2020 21:00:24 -0800 (PST) Received: from localhost ([::1]:40390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAuF-0003ac-2t for importer@patchew.org; Wed, 04 Nov 2020 00:00:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAmB-0006rG-RA for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27046) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAm9-0004lY-0U for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:03 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-462-csix4jsrOSyhXyJ-pkTWnw-1; Tue, 03 Nov 2020 23:51:58 -0500 Received: by mail-wm1-f70.google.com with SMTP id 8so353004wmg.6 for ; Tue, 03 Nov 2020 20:51:58 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id y201sm886172wmd.27.2020.11.03.20.51.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465520; 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=APdAnMGOimWpi0/lmUkQSWdNUl1kK18oif2GgMOHc/o=; b=H1b94kJuV5Vb5s06X3SIQnWvvlHy8j190kjcHB5arp2yIHn3oxGRVqqkenMxLiMS7kIvWg E8HdjtLlXR0Xq2cyzix/eNvP65fI3S+SHJNPOKyN0v6UbldefS1RXvWDPzAtPsTDn385ct n3RwFkZkjypFEEdt9ErsGdckG5u5gkI= X-MC-Unique: csix4jsrOSyhXyJ-pkTWnw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=APdAnMGOimWpi0/lmUkQSWdNUl1kK18oif2GgMOHc/o=; b=porg/kgO/AecjkeV6JQqiI0aJzgs3y0+KKJ0g3YUs+zei+E04hN2XhFvFm+DQs6DSD CniwOpCPmTWfGSX6N61tBeAglbx2yVVgyvtRICg/KQ7DQlSPj1JkBbXK6q/6OnUpptlb 16MIRBzepaxkm9RQqAlStchsKaplS/GUBg6vagkl0x9XUD/UNaKTzgH5r0PjwuD3i/6a Ehbz8cDtdt7WVUQwEFAlWQeFnO9eG/nVAuA3keCGaVXxnzKDU+t1Scs7TPh8zoToTFCb iWl9jilDxM5Pl30p2KThFzN1B6WdL07De5qgJfPeyXLLW0lEmPqXiEZP2uW1z/lzNIVn HD+Q== X-Gm-Message-State: AOAM5317i6sK8D7NiafiMxjBelxkiLDpr97VoDn2+ddOeqpx36af2G2k EkFR719xRHotDD7AqEb9YOwtlUKNFyj5SQgj+iBr565KPVrEH8l3O4jOQ6HC4ERxCVyFzw3+Ar3 9y/7wDP8Jql3VLpI= X-Received: by 2002:a7b:cc05:: with SMTP id f5mr318636wmh.123.1604465517128; Tue, 03 Nov 2020 20:51:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVitv4451KFhArVolj6ppqGeiQnZ5Zn6Ci71hiCcrB94xKr7B3Uzrk7dAf6c52g3cGjDRm3A== X-Received: by 2002:a7b:cc05:: with SMTP id f5mr318619wmh.123.1604465516951; Tue, 03 Nov 2020 20:51:56 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:54 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 27/38] libvhost-user: follow QEMU comment style Message-ID: <20201104044937.226370-28-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , "Dr. David Alan Gilbert" , Stefan Hajnoczi , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-2-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/libvhost-user/libvhost-user.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user.h b/contrib/libvhost-user/= libvhost-user.h index 3bbeae8587..a1539dbb69 100644 --- a/contrib/libvhost-user/libvhost-user.h +++ b/contrib/libvhost-user/libvhost-user.h @@ -392,7 +392,8 @@ struct VuDev { bool broken; uint16_t max_queues; =20 - /* @read_msg: custom method to read vhost-user message + /* + * @read_msg: custom method to read vhost-user message * * Read data from vhost_user socket fd and fill up * the passed VhostUserMsg *vmsg struct. @@ -409,15 +410,19 @@ struct VuDev { * */ vu_read_msg_cb read_msg; - /* @set_watch: add or update the given fd to the watch set, - * call cb when condition is met */ + + /* + * @set_watch: add or update the given fd to the watch set, + * call cb when condition is met. + */ vu_set_watch_cb set_watch; =20 /* @remove_watch: remove the given fd from the watch set */ vu_remove_watch_cb remove_watch; =20 - /* @panic: encountered an unrecoverable error, you may try to - * re-initialize */ + /* + * @panic: encountered an unrecoverable error, you may try to re-initi= alize + */ vu_panic_cb panic; const VuDevIface *iface; =20 --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466911; cv=none; d=zohomail.com; s=zohoarc; b=Y/AdT0TEyk3vC5QGvnGOEzd/umANaCQN+drr6MhRSWIzbJldC4F6ZfzjMPVaJYydteHxvEFh7gxwEah2YBb36qumVOXAj7dDrNLhsgQ89aEwVCroMnxc4Xvus2v0/CzJYavViwC0knccwJBW6jFYhV+XIrVrd+oPPK3hAIraiaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466911; 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=FOR/bv25dGPFB9FnzIFOxW/ObDgDZns8YprwAzRry/Y=; b=NUDtllZdfDnwL6B5sOVAArdxlFEOtDNk9WYMonKDpGfSaVMDJvhwWuoHbUS9gjm5HBhBEZvdjatoktzQUYcH+RhyZns8pEC4312UfHR7SRUmB9Z68kdogHOZ6dwrm53sKR0FybKz/bZx6T8hSvsaR90i3pQb/Mq92Gw/J/H17JE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466911046525.5673232427092; Tue, 3 Nov 2020 21:15:11 -0800 (PST) Received: from localhost ([::1]:59642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaB8X-0006Kn-S2 for importer@patchew.org; Wed, 04 Nov 2020 00:15:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAmr-0008QQ-Ke for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:60192) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAmp-0004zJ-Pn for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:45 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-346-A5QjTE7bO--eG2BLY9L3lg-1; Tue, 03 Nov 2020 23:52:01 -0500 Received: by mail-wr1-f69.google.com with SMTP id b6so8660944wrn.17 for ; Tue, 03 Nov 2020 20:52:01 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id n8sm810292wmc.11.2020.11.03.20.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:51:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465562; 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=FOR/bv25dGPFB9FnzIFOxW/ObDgDZns8YprwAzRry/Y=; b=E73w5zNCZTTquuLAcHSZ0q4UvMlpTaWcwE0V0Aw4iUPmNNn9zVTBol0FqaRDuUDUp6AWAJ qQDr7gQSdcrBCApaMWLLnmZflnGVhjQ5wjysxxXflrJU4Z4utheZHUnv1j4sIUvBOxKSTg sTcoGnGfHtvVPE5GV2XRnv2GqQB15OQ= X-MC-Unique: A5QjTE7bO--eG2BLY9L3lg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FOR/bv25dGPFB9FnzIFOxW/ObDgDZns8YprwAzRry/Y=; b=EYDuxUbowdh3POq0uksVpjWFqN1RS90wXcaQWNdvaL5yhF+6epMuhTO93eXQU6qg63 cmzLBm4nDLYqk0HTGx1rOl14GQRi1jCXhz6Yn8Kjmy5L6sko5Vm8MR9vDIiCgmiYcQmZ zBHGv8WbBgHexQ3Nzvx2mguM01xVbGMkaSlvIZGSxqS3Wor60lrG/VLVHaEwaUVC3FBN a/elfhkGdjk9q/ID/zeNF14VmzpbXT8yKNF9RVm6YdxNp8fdtR5MzZGp1FZhLjjmfBHx A7zMhEH5er3Zl5YXhfI37MxdgaI+ZgY9FFpPGp7cOTGhrEZHoblJ9pGSIGK3hA3yk/Kv Awgg== X-Gm-Message-State: AOAM531ylvu6bypTzZVq6w6Ix/leXqQkwps7PlpSfQ1Lz5ZFQ2pJ7QcS wZBAe+ozFsVPBH9QWkwWmgmvBLBdGmBXtlo2KCNAhsHbDDw2GLV/JK5jFQ0zWUHDrgCVPFAOJxb RyyV8aGsxJv0r40o= X-Received: by 2002:a5d:4c4f:: with SMTP id n15mr28976514wrt.137.1604465519814; Tue, 03 Nov 2020 20:51:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxo6ZnRAG/CyyK5D5ryWKX4pbM4rBmKPi8zswxWO1XEaX2+DS4IM7ZCbRexCfz8IaYmzSMvBQ== X-Received: by 2002:a5d:4c4f:: with SMTP id n15mr28976509wrt.137.1604465519682; Tue, 03 Nov 2020 20:51:59 -0800 (PST) Date: Tue, 3 Nov 2020 23:51:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 28/38] configure: introduce --enable-vhost-user-blk-server Message-ID: <20201104044937.226370-29-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Make it possible to compile out the vhost-user-blk server. It is enabled by default on Linux. Note that vhost-user-server.c depends on libvhost-user, which requires CONFIG_LINUX. The CONFIG_VHOST_USER dependency was erroneous since that option controls vhost-user frontends (previously known as "master") and not device backends (previously known as "slave"). Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-3-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- configure | 15 +++++++++++++++ block/export/export.c | 4 ++-- block/export/meson.build | 2 +- util/meson.build | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 2c3c69f118..b5e8f5f72c 100755 --- a/configure +++ b/configure @@ -329,6 +329,7 @@ vhost_crypto=3D"" vhost_scsi=3D"" vhost_vsock=3D"" vhost_user=3D"" +vhost_user_blk_server=3D"" vhost_user_fs=3D"" kvm=3D"auto" hax=3D"auto" @@ -1246,6 +1247,10 @@ for opt do ;; --enable-vhost-vsock) vhost_vsock=3D"yes" ;; + --disable-vhost-user-blk-server) vhost_user_blk_server=3D"no" + ;; + --enable-vhost-user-blk-server) vhost_user_blk_server=3D"yes" + ;; --disable-vhost-user-fs) vhost_user_fs=3D"no" ;; --enable-vhost-user-fs) vhost_user_fs=3D"yes" @@ -1791,6 +1796,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: vhost-crypto vhost-user-crypto backend support vhost-kernel vhost kernel backend support vhost-user vhost-user backend support + vhost-user-blk-server vhost-user-blk server support vhost-vdpa vhost-vdpa kernel backend support spice spice rbd rados block device (rbd) @@ -2382,6 +2388,12 @@ if test "$vhost_net" =3D ""; then test "$vhost_kernel" =3D "yes" && vhost_net=3Dyes fi =20 +# libvhost-user is Linux-only +test "$vhost_user_blk_server" =3D "" && vhost_user_blk_server=3D$linux +if test "$vhost_user_blk_server" =3D "yes" && test "$linux" =3D "no"; then + error_exit "--enable-vhost-user-blk-server is only available on Linux" +fi + ########################################## # pkg-config probe =20 @@ -6275,6 +6287,9 @@ fi if test "$vhost_vdpa" =3D "yes" ; then echo "CONFIG_VHOST_VDPA=3Dy" >> $config_host_mak fi +if test "$vhost_user_blk_server" =3D "yes" ; then + echo "CONFIG_VHOST_USER_BLK_SERVER=3Dy" >> $config_host_mak +fi if test "$vhost_user_fs" =3D "yes" ; then echo "CONFIG_VHOST_USER_FS=3Dy" >> $config_host_mak fi diff --git a/block/export/export.c b/block/export/export.c index c3478c6c97..bad6f21b1c 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -22,13 +22,13 @@ #include "qapi/qapi-commands-block-export.h" #include "qapi/qapi-events-block-export.h" #include "qemu/id.h" -#if defined(CONFIG_LINUX) && defined(CONFIG_VHOST_USER) +#ifdef CONFIG_VHOST_USER_BLK_SERVER #include "vhost-user-blk-server.h" #endif =20 static const BlockExportDriver *blk_exp_drivers[] =3D { &blk_exp_nbd, -#if defined(CONFIG_LINUX) && defined(CONFIG_VHOST_USER) +#ifdef CONFIG_VHOST_USER_BLK_SERVER &blk_exp_vhost_user_blk, #endif }; diff --git a/block/export/meson.build b/block/export/meson.build index 9fb4fbf81d..19526435d8 100644 --- a/block/export/meson.build +++ b/block/export/meson.build @@ -1,2 +1,2 @@ blockdev_ss.add(files('export.c')) -blockdev_ss.add(when: ['CONFIG_LINUX', 'CONFIG_VHOST_USER'], if_true: file= s('vhost-user-blk-server.c')) +blockdev_ss.add(when: 'CONFIG_VHOST_USER_BLK_SERVER', if_true: files('vhos= t-user-blk-server.c')) diff --git a/util/meson.build b/util/meson.build index c5159ad79d..f359af0d46 100644 --- a/util/meson.build +++ b/util/meson.build @@ -66,7 +66,7 @@ if have_block util_ss.add(files('main-loop.c')) util_ss.add(files('nvdimm-utils.c')) util_ss.add(files('qemu-coroutine.c', 'qemu-coroutine-lock.c', 'qemu-cor= outine-io.c')) - util_ss.add(when: ['CONFIG_LINUX', 'CONFIG_VHOST_USER'], if_true: [ + util_ss.add(when: 'CONFIG_LINUX', if_true: [ files('vhost-user-server.c'), vhost_user ]) util_ss.add(files('block-helpers.c')) --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466176; cv=none; d=zohomail.com; s=zohoarc; b=ZENvb9DJGzSy7wwyuYviFWvmAXEOd+3kBvNKvcWlnPZfKxHPl9QqauGdvX40McwKj8d32OL0DEA6uhhrbcBYa266q3uKwWEpCDhqh0ZkCEHhc3nnghD4j9yqExszRT1EzyyijaRlDlPnoEDGrD7soI2ky3CTC361EnxFBinXbYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466176; 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=lgzOL39RvILiPn2GJxc4fQ6TNHjpeFII29h+nk2BQE8=; b=b1pXYeSz8JLDoHPlstKujje/2apYLCkmib1QhmKgaq7cUoz+BrO35we6Ea2KCbKmvZtWGXdZse34Nufb4IXqiO5xLO1bXoD643nGrc/XAElIOmXylCo8QdIsZ+R9T/dw571/GERCic4bBW3/v84YVAwkiWPBQpdb4bju04tga7E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466176459880.507487629509; Tue, 3 Nov 2020 21:02:56 -0800 (PST) Received: from localhost ([::1]:48916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAwg-00078x-5Y for importer@patchew.org; Wed, 04 Nov 2020 00:02:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAmH-0006wu-6I for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43011) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAmF-0004oa-CF for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:08 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-513-F_7sRAEnPaOJbbcuYb50tw-1; Tue, 03 Nov 2020 23:52:04 -0500 Received: by mail-wr1-f70.google.com with SMTP id w1so8715746wrr.5 for ; Tue, 03 Nov 2020 20:52:04 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id c2sm794577wmf.47.2020.11.03.20.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:52:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465526; 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=lgzOL39RvILiPn2GJxc4fQ6TNHjpeFII29h+nk2BQE8=; b=RjjaQe38X7hk9q9I8nfkWRk6TKy8W1ddu4MPpd1WT+BXWs4j6I4YiuYe3zjRkokG4VSU3m Ab1aC/GPkrXUBItAer1KOUUui6qUSE09oaxg8w0Ux8ZTGRqu7MJJhhM6hOEbTeQ8qxPXUL glkHhXZ7ISTiSUu2w1DEJw2xGtszGL4= X-MC-Unique: F_7sRAEnPaOJbbcuYb50tw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=lgzOL39RvILiPn2GJxc4fQ6TNHjpeFII29h+nk2BQE8=; b=maM/5e1M7OgENOKqAzqVTTHGM4ljum1qGFdXQA3KyPlD64+5ri0XZgl3wTXQ5qayko 0cbRU5TOmJ/oC3r1ekh0atbi25eXSnme7ByoIXfnRH51WhnLqO4L0ovTG7xqNWVRFRSD r6iv9LgmyDM20Sl2bnDEobBl8QyehLts1f6YzK69ScgC6lvs+T8N7b5SzISU7MCAk6e7 EImDAlqOV8kkvaT169WkD/QOK43DD8Zsuk9eNAWJ834pn8fDqL4rWrk8cabkYigQYcqn soaJ1c0oGVfYLyw7pPP78u4WUQ+Mlhm5Pn0VDEM4TBMRLs+l/P9K+zXi/ikk5COa5B1V OCBQ== X-Gm-Message-State: AOAM530IkwFNjGpaovoCp4Tplr3klDXjPVG9cp19QscgLVs65UHZGY3b i60+7bwqsheBfj7aeP31+jz/O4s3RdMkcpvHQJAYD3iKRm4tgT9LGhy4IVdXma7WWVJ141ANRJF qp6F/K1gDMlWeuwI= X-Received: by 2002:a1c:7c0e:: with SMTP id x14mr2475926wmc.88.1604465522788; Tue, 03 Nov 2020 20:52:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5DhDAtpcepurpUgZdYPNJw26kJOIbtD7ONwZ0YooCQ7nfCZwZbMFRlvOd/Mw6cR3XBcrJFA== X-Received: by 2002:a1c:7c0e:: with SMTP id x14mr2475911wmc.88.1604465522517; Tue, 03 Nov 2020 20:52:02 -0800 (PST) Date: Tue, 3 Nov 2020 23:52:00 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 29/38] block/export: make vhost-user-blk config space little-endian Message-ID: <20201104044937.226370-30-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Coiby Xu , Max Reitz , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi VIRTIO 1.0 devices have little-endian configuration space. The vhost-user-blk-server.c code already uses little-endian for virtqueue processing but not for the configuration space fields. Fix this so the vhost-user-blk export works on big-endian hosts. Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-4-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- block/export/vhost-user-blk-server.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user= -blk-server.c index 41f4933d6e..33cc0818b8 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -264,7 +264,6 @@ static uint64_t vu_blk_get_protocol_features(VuDev *dev) static int vu_blk_get_config(VuDev *vu_dev, uint8_t *config, uint32_t len) { - /* TODO blkcfg must be little-endian for VIRTIO 1.0 */ VuServer *server =3D container_of(vu_dev, VuServer, vu_dev); VuBlkExport *vexp =3D container_of(server, VuBlkExport, vu_server); memcpy(config, &vexp->blkcfg, len); @@ -343,18 +342,18 @@ vu_blk_initialize_config(BlockDriverState *bs, uint32_t blk_size, uint16_t num_queues) { - config->capacity =3D bdrv_getlength(bs) >> BDRV_SECTOR_BITS; - config->blk_size =3D blk_size; - config->size_max =3D 0; - config->seg_max =3D 128 - 2; - config->min_io_size =3D 1; - config->opt_io_size =3D 1; - config->num_queues =3D num_queues; - config->max_discard_sectors =3D 32768; - config->max_discard_seg =3D 1; - config->discard_sector_alignment =3D config->blk_size >> 9; - config->max_write_zeroes_sectors =3D 32768; - config->max_write_zeroes_seg =3D 1; + config->capacity =3D cpu_to_le64(bdrv_getlength(bs) >> BDRV_SECTOR_BIT= S); + config->blk_size =3D cpu_to_le32(blk_size); + config->size_max =3D cpu_to_le32(0); + config->seg_max =3D cpu_to_le32(128 - 2); + config->min_io_size =3D cpu_to_le16(1); + config->opt_io_size =3D cpu_to_le32(1); + config->num_queues =3D cpu_to_le16(num_queues); + config->max_discard_sectors =3D cpu_to_le32(32768); + config->max_discard_seg =3D cpu_to_le32(1); + config->discard_sector_alignment =3D cpu_to_le32(config->blk_size >> 9= ); + config->max_write_zeroes_sectors =3D cpu_to_le32(32768); + config->max_write_zeroes_seg =3D cpu_to_le32(1); } =20 static void vu_blk_exp_request_shutdown(BlockExport *exp) --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466338; cv=none; d=zohomail.com; s=zohoarc; b=KLMWNqZdW2sY53Jc6+c0O4+t5RsoUDsP6TXBfwdticFdXWlSHr/FQLDUaCbUcOcWj8bgxzCIJ2pXsBkLuUq5AV6L6iyPuJG5B7AUhYH1pOOuohbHEk+0BrziCo6ZW75/hngyW2r6joxYxrUZFlnhby4kfJaPIpGsa5Khsz14KOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466338; 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=cS4KIfPlpUgVDDoFSeX7cKA8yzTJmgIIdFHv/xDSqc0=; b=UekSmbL55BZxxkLbuqeKiN3F/iw/iMsVWB1IWoauuSTOmWU1RIGz8fIbbNwk9RboYTRBp3qmLdPsQyJV94RKFvMsu69zbHAgjx4x/TNTpwaSXAB8ygnRqFuJRpdTsPTq1it2gvcWi/v1V1h1omQ5oadELqfsWRGF0S2U66d/9zM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466338674521.8188493152254; Tue, 3 Nov 2020 21:05:38 -0800 (PST) Received: from localhost ([::1]:57262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAzJ-00027a-HI for importer@patchew.org; Wed, 04 Nov 2020 00:05:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAmK-00075T-Jp for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44596) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAmI-0004pt-RN for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:12 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-218-ATAjRjdtMXio1Y9a8PAHlw-1; Tue, 03 Nov 2020 23:52:07 -0500 Received: by mail-wr1-f71.google.com with SMTP id 31so8704706wrg.12 for ; Tue, 03 Nov 2020 20:52:06 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id p13sm854792wrt.73.2020.11.03.20.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:52:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465529; 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=cS4KIfPlpUgVDDoFSeX7cKA8yzTJmgIIdFHv/xDSqc0=; b=AnhnyU+tTPH9/Dr6EX+eptwtYdGMCxdIqlfFYPbiRZ2IHgNexd5164HtYEfuT/vGc+Ya/M bwm/WSbX/uhu4YmydqHXVLTQ0FLuRJtV6KyzEOJdKZH2anx1Ws7fxIK1SZml+Ckfv8BjMO NE+o/1jFHLbsF5LDKEwIQGRgU6otCsI= X-MC-Unique: ATAjRjdtMXio1Y9a8PAHlw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=cS4KIfPlpUgVDDoFSeX7cKA8yzTJmgIIdFHv/xDSqc0=; b=jzCv/AJu9ElA7V3zMSz2Tg4juhN+Uh+WwOPnd4ykIYGVxEYeebAchq8PlFM1dxeoZl 2znx1ZEXGSrduUKA4eWjRfY3UTy2L9rCHzuPbWWsExNUtAedrLaCTxNTlMgaE+spVF+v UJ4xH2PGOyqe5AbqG6OKSPdYaL1lOCfTn0Jrfr4/t3Co2TSz3fbS1eZ0N4mBOFGyUMZC K9DA+nyqOq15j+EEt6z4BZvZ1SwUfDyluDT025ohdlq/9SlXH2jefTsK4331/SfYtTYB q/9YqTdOybdCkLcoWS7Mojt7KiivgJzLHrpN7KuTHJ7/75rpyt5wZRAyMfaPt4K02rrN bqMQ== X-Gm-Message-State: AOAM532+ghMkbUMpwelHAkCgKpW60zVKuNVg1s2RG0ag7OIZO/y4h09D ZfST4geTavQehsEGlCZQPeFNU3xikg4fFA6oeLMLHWWt3YqujF7vn6yxsQEt+xkn4G8U8ZW7pab ZKcnxoLTICDwTQAU= X-Received: by 2002:a1c:e087:: with SMTP id x129mr2428140wmg.2.1604465525612; Tue, 03 Nov 2020 20:52:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyuqIeBrmrKF6BkldU+V/RGr8/Husc9SuIZSp2u+7EjY6s0Wzyoe8Bms+w7lSWr0oR2TPAkhg== X-Received: by 2002:a1c:e087:: with SMTP id x129mr2428131wmg.2.1604465525474; Tue, 03 Nov 2020 20:52:05 -0800 (PST) Date: Tue, 3 Nov 2020 23:52:03 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 30/38] block/export: fix vhost-user-blk get_config() information leak Message-ID: <20201104044937.226370-31-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Coiby Xu , Max Reitz , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Refuse get_config() requests in excess of sizeof(struct virtio_blk_config). Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-5-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- block/export/vhost-user-blk-server.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user= -blk-server.c index 33cc0818b8..62672d1cb9 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -266,6 +266,9 @@ vu_blk_get_config(VuDev *vu_dev, uint8_t *config, uint3= 2_t len) { VuServer *server =3D container_of(vu_dev, VuServer, vu_dev); VuBlkExport *vexp =3D container_of(server, VuBlkExport, vu_server); + + g_return_val_if_fail(len <=3D sizeof(struct virtio_blk_config), -1); + memcpy(config, &vexp->blkcfg, len); return 0; } --=20 MST From nobody Fri May 17 02:03:05 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=1604467117; cv=none; d=zohomail.com; s=zohoarc; b=V3CTya1o72gd0jCTQYy2AoSUMbovIw24WeiX8S0ObWjW47rMSdOWxMNUfwhNWVh5XpqvQbAAmYwhDlTjLcRyBo26barXwQ0gKm8IGFRSnTb19cBqCp0gYwg5qe2d73lK4ngSIuDjfgp9cjR1/RVPJbNeMFD8UQL3l0UqC/cROu0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604467117; 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=10gqAcInC2hOlA/e3e/PPVyOBwthTxnTi3QFwwaBdNU=; b=ebkkxXUT+4f74AqIJ1KFfvyTJAOwLX39akfrT+iALm92kMjcjNJQxl+1BTqO1OCwPVEuTbgSpFasrAMkDnqImX4CyDm8A5ncL7gotPLl4EuAMqCB27H846pyHcOqsGm1NCcNLXp0bywj2aO3t/oREnu1iCMWudovVYVT+tSNwl8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604467117177206.09133299354482; Tue, 3 Nov 2020 21:18:37 -0800 (PST) Received: from localhost ([::1]:43564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaBBr-0002wU-UE for importer@patchew.org; Wed, 04 Nov 2020 00:18:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAvz-0006cb-MV for qemu-devel@nongnu.org; Wed, 04 Nov 2020 00:02:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40311) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAvx-0008FD-Qb for qemu-devel@nongnu.org; Wed, 04 Nov 2020 00:02:11 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-10-WhqChcbEN6Ccp_DYeAL9Ig-1; Tue, 03 Nov 2020 23:52:09 -0500 Received: by mail-wr1-f69.google.com with SMTP id b6so8661076wrn.17 for ; Tue, 03 Nov 2020 20:52:09 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id n22sm790091wmk.40.2020.11.03.20.52.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:52:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604466129; 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=10gqAcInC2hOlA/e3e/PPVyOBwthTxnTi3QFwwaBdNU=; b=NHeQlit9TKHgeqKZ/sNJBPziujLe64bQDH/iDQ5V5W883r+SbScXp4FaWHb96DGYc+i74P 6l3BB3MWd7y3+uq3porpvcPbBp9TYP5oS9PCwR/ifjO5+gLAwJsmlAmxD3tGJEb1oByJQ/ 8dJzftS09yOjHXpM3UGDGEf1qX0ZDo0= X-MC-Unique: WhqChcbEN6Ccp_DYeAL9Ig-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=10gqAcInC2hOlA/e3e/PPVyOBwthTxnTi3QFwwaBdNU=; b=Os4iKm6rksOTegP4uyZBldEajP8HYae1l4BlZRz4XDLHhIAb7R8DGgWAklNa27prDS jEi/HzC1QNC5hDOSXtwNNJNsN6d3zxhaIFXm2JbHn5Uy6o82j3OaMBgLbjNA1bcy14qb Oo5URHkljQovAvsJxDzRGknbSioi+ArjV3qBASKz6+2CKXjHeZEmJlqhB9/0ADZI5v77 psKIBEeUcWiTqwUXr8ogUkeLx/PBgTnft+4I/ihtq0T+3Lw4xkt7T/jDusSgjSuJEaNt xpswLquudmsjff7ThGw84N80ctDV44jjBEUu4MJPUM1Eyl2WDV7CWVEPI9FppuElWnAi Onlw== X-Gm-Message-State: AOAM532TSbur7HrxwjUlaqTDw8LCEopmAbgiewSxE5D4pHCT6rKllnQV MGpxA1/Xa5NCfJCN33iy6IUa4iqo3aI35UGJh/6MPFLu0/QdHJIN2bliUgqg/CeqBJtjzAdx2ay ZVhnHIz/18rthp7Y= X-Received: by 2002:adf:fc83:: with SMTP id g3mr29712200wrr.200.1604465528200; Tue, 03 Nov 2020 20:52:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZXtbf+FdMMh6jOB0UaSiBhPZIf/pUwS6O64v5Dk/lV2cT25m3sqxDn1m4DjsjY1KdnsG3yA== X-Received: by 2002:adf:fc83:: with SMTP id g3mr29712191wrr.200.1604465528027; Tue, 03 Nov 2020 20:52:08 -0800 (PST) Date: Tue, 3 Nov 2020 23:52:05 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 31/38] contrib/vhost-user-blk: fix get_config() information leak Message-ID: <20201104044937.226370-32-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Refuse get_config() in excess of sizeof(struct virtio_blk_config). Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-6-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/vhost-user-blk/vhost-user-blk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-b= lk/vhost-user-blk.c index 25eccd02b5..caad88637e 100644 --- a/contrib/vhost-user-blk/vhost-user-blk.c +++ b/contrib/vhost-user-blk/vhost-user-blk.c @@ -404,6 +404,8 @@ vub_get_config(VuDev *vu_dev, uint8_t *config, uint32_t= len) VugDev *gdev; VubDev *vdev_blk; =20 + g_return_val_if_fail(len <=3D sizeof(struct virtio_blk_config), -1); + gdev =3D container_of(vu_dev, VugDev, parent); vdev_blk =3D container_of(gdev, VubDev, parent); memcpy(config, &vdev_blk->blkcfg, len); --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466630; cv=none; d=zohomail.com; s=zohoarc; b=J8ed8zvhbQBUB4IvNsUG9Wvqu3AQrJTuNRCs1ojnJNQBiqEa3fbrfHu2EiRgXTrx1Okmkrn5ZWE4aCpwcy02T/D0rckupIWBpXq9gDQrZuuJVmUwu0IEXeIFOO+QcDjgI+0wSheBm6vbc3qJW/pSdccNlifI5HG3YXNmZjsuz5M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466630; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vmZ6U03tiWRzo3OOmOXOEZgB2Q0tAfyx5o0TEqeDgWk=; b=AOptOCAhRNgHai0tSuEr5+RU8mqKHArLg8mmBrgWVBqs0TXZC/4ThU9AlIQjvoYVxRSGj5pZolhoe55T33upO9LzZ4XCprQe4C8bDhZoRkd2yq9jf+NW4Ck67dqJgBC4LFKj0Bia17wSUI+AY88x09g7/1DBoXookD5ETEsbMQQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466630142631.8146692589121; Tue, 3 Nov 2020 21:10:30 -0800 (PST) Received: from localhost ([::1]:44552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaB40-000060-UG for importer@patchew.org; Wed, 04 Nov 2020 00:10:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAnr-0002Ky-02 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:53:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26963) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAnm-0005KO-Ih for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:53:46 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-X8j96TQ0M5uZg0gXErMeIw-1; Tue, 03 Nov 2020 23:52:13 -0500 Received: by mail-wm1-f72.google.com with SMTP id c10so732520wmh.6 for ; Tue, 03 Nov 2020 20:52:13 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id e5sm824670wrw.93.2020.11.03.20.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:52:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465621; 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=vmZ6U03tiWRzo3OOmOXOEZgB2Q0tAfyx5o0TEqeDgWk=; b=KrrpmfNmO/upAYkG3mF3eiIEHaZ/qfq4PUetetwSFMp/sjX9XGJh23KKEM+S9Jt1YbklFJ +US6A6elCqKDZlnP4B4QjL0jkxuQQlUXuVJstnd4gSVvFx67pdIkOPWcznj3b36GqJgotk 2Q4m7y7IVLuVJh8fsjbcX8kaPD77jgY= X-MC-Unique: X8j96TQ0M5uZg0gXErMeIw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=vmZ6U03tiWRzo3OOmOXOEZgB2Q0tAfyx5o0TEqeDgWk=; b=ivuxhVfRCrEopved1/nUwq17u2kSrPcUlOcXZVrE+lV6OqxpuGq5dmCtJbPSIKWyGA bXfquUsja1UhIHhgAC0Ijk6B2y4f35KzvMmgJahknwdz5A/4d6dHnivdpD4zVuZPN/0D Ao4eFSY6LnMJ6RpMqlkLG+5RJETsbyC93OauokdK2Q+w9ndeMKxw0YeLZxEWLrHgeoNR Fm2lGavaWtvUQaVdUl7kK5Hn0wJeVxuxxzWyhZqEPJ6nSPi4LZOTYHeM/8mSMDOKCf1W SRhFeAQmff2GMxd9YE1CVasZfyDVfC0vciJfCNbsZVYylzQN8Tg+7lhZBxiUVe9Gp/R3 j2uw== X-Gm-Message-State: AOAM532k+2R7TQTafhjNEamL7Mu6PZmlpXV4Uz2aH0aR7fnMU7GHbfAG SPLKkI3EE4PzBYREj1oa2OFWaurHiiXKxFvJUiuvuZUPUfEGPOPVmKvOHVJTMTnpTn8rKp08CQ8 HN4gRttB0n/lj/t8= X-Received: by 2002:adf:f3d1:: with SMTP id g17mr3875945wrp.156.1604465531233; Tue, 03 Nov 2020 20:52:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNohMvYYb3biP3f32mMNvuWclMw0gV5JA5qsVB466A57eMVheLhh+WFkyOFdSDT+FO49DI4g== X-Received: by 2002:adf:f3d1:: with SMTP id g17mr3875918wrp.156.1604465530913; Tue, 03 Nov 2020 20:52:10 -0800 (PST) Date: Tue, 3 Nov 2020 23:52:08 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 32/38] test: new qTest case to test the vhost-user-blk-server Message-ID: <20201104044937.226370-33-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Coiby Xu , Stefan Hajnoczi , 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) From: Coiby Xu This test case has the same tests as tests/virtio-blk-test.c except for tests have block_resize. Since vhost-user server can only server one client one time, two instances of vhost-user-blk-server are started by qemu-storage-daemon for the hotplug test. In order to not block scripts/tap-driver.pl, vhost-user-blk-server will send "quit" command to qemu-storage-daemon's QMP monitor. So a function is added to libqtest.c to establish socket connection with socket server. Suggested-by: Thomas Huth Signed-off-by: Coiby Xu Reviewed-by: Stefan Hajnoczi Reviewed-by: Marc-Andr=C3=A9 Lureau Message-id: 20200918080912.321299-7-coiby.xu@gmail.com [Update meson.build to only test when CONFIG_TOOLS has built qemu-storage-daemon. This prevents CI failures with --disable-tools. Also bump RAM to 256 MB because that is the minimum RAM granularity on ppc64 spapr machines. --Stefan] Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-7-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/libqos/libqtest.h | 17 + tests/qtest/libqos/vhost-user-blk.h | 48 ++ tests/qtest/libqos/vhost-user-blk.c | 129 +++++ tests/qtest/libqtest.c | 36 +- tests/qtest/vhost-user-blk-test.c | 751 ++++++++++++++++++++++++++++ tests/qtest/libqos/meson.build | 1 + tests/qtest/meson.build | 2 + 7 files changed, 982 insertions(+), 2 deletions(-) create mode 100644 tests/qtest/libqos/vhost-user-blk.h create mode 100644 tests/qtest/libqos/vhost-user-blk.c create mode 100644 tests/qtest/vhost-user-blk-test.c diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h index 5c959f1853..241b5f89fb 100644 --- a/tests/qtest/libqos/libqtest.h +++ b/tests/qtest/libqos/libqtest.h @@ -132,6 +132,23 @@ void qtest_qmp_send(QTestState *s, const char *fmt, ..= .) void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...) GCC_FMT_ATTR(2, 3); =20 +/** + * qtest_socket_client: + * @server_socket_path: the socket server's path + * + * Connect to a socket server. + */ +int qtest_socket_client(char *server_socket_path); + +/** + * qtest_create_state_with_qmp_fd: + * @fd: socket fd + * + * Wrap socket fd in QTestState to make use of qtest_qmp* + * functions + */ +QTestState *qtest_create_state_with_qmp_fd(int fd); + /** * qtest_vqmp_fds: * @s: #QTestState instance to operate on. diff --git a/tests/qtest/libqos/vhost-user-blk.h b/tests/qtest/libqos/vhost= -user-blk.h new file mode 100644 index 0000000000..2a03456a45 --- /dev/null +++ b/tests/qtest/libqos/vhost-user-blk.h @@ -0,0 +1,48 @@ +/* + * libqos driver framework + * + * Based on tests/qtest/libqos/virtio-blk.c + * + * Copyright (c) 2020 Coiby Xu + * + * Copyright (c) 2018 Emanuele Giuseppe Esposito + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#ifndef TESTS_LIBQOS_VHOST_USER_BLK_H +#define TESTS_LIBQOS_VHOST_USER_BLK_H + +#include "qgraph.h" +#include "virtio.h" +#include "virtio-pci.h" + +typedef struct QVhostUserBlk QVhostUserBlk; +typedef struct QVhostUserBlkPCI QVhostUserBlkPCI; +typedef struct QVhostUserBlkDevice QVhostUserBlkDevice; + +struct QVhostUserBlk { + QVirtioDevice *vdev; +}; + +struct QVhostUserBlkPCI { + QVirtioPCIDevice pci_vdev; + QVhostUserBlk blk; +}; + +struct QVhostUserBlkDevice { + QOSGraphObject obj; + QVhostUserBlk blk; +}; + +#endif diff --git a/tests/qtest/libqos/vhost-user-blk.c b/tests/qtest/libqos/vhost= -user-blk.c new file mode 100644 index 0000000000..58c7e1eb69 --- /dev/null +++ b/tests/qtest/libqos/vhost-user-blk.c @@ -0,0 +1,129 @@ +/* + * libqos driver framework + * + * Based on tests/qtest/libqos/virtio-blk.c + * + * Copyright (c) 2020 Coiby Xu + * + * Copyright (c) 2018 Emanuele Giuseppe Esposito + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#include "qemu/osdep.h" +#include "libqtest.h" +#include "qemu/module.h" +#include "standard-headers/linux/virtio_blk.h" +#include "vhost-user-blk.h" + +#define PCI_SLOT 0x04 +#define PCI_FN 0x00 + +/* virtio-blk-device */ +static void *qvhost_user_blk_get_driver(QVhostUserBlk *v_blk, + const char *interface) +{ + if (!g_strcmp0(interface, "vhost-user-blk")) { + return v_blk; + } + if (!g_strcmp0(interface, "virtio")) { + return v_blk->vdev; + } + + fprintf(stderr, "%s not present in vhost-user-blk-device\n", interface= ); + g_assert_not_reached(); +} + +static void *qvhost_user_blk_device_get_driver(void *object, + const char *interface) +{ + QVhostUserBlkDevice *v_blk =3D object; + return qvhost_user_blk_get_driver(&v_blk->blk, interface); +} + +static void *vhost_user_blk_device_create(void *virtio_dev, + QGuestAllocator *t_alloc, + void *addr) +{ + QVhostUserBlkDevice *vhost_user_blk =3D g_new0(QVhostUserBlkDevice, 1); + QVhostUserBlk *interface =3D &vhost_user_blk->blk; + + interface->vdev =3D virtio_dev; + + vhost_user_blk->obj.get_driver =3D qvhost_user_blk_device_get_driver; + + return &vhost_user_blk->obj; +} + +/* virtio-blk-pci */ +static void *qvhost_user_blk_pci_get_driver(void *object, const char *inte= rface) +{ + QVhostUserBlkPCI *v_blk =3D object; + if (!g_strcmp0(interface, "pci-device")) { + return v_blk->pci_vdev.pdev; + } + return qvhost_user_blk_get_driver(&v_blk->blk, interface); +} + +static void *vhost_user_blk_pci_create(void *pci_bus, QGuestAllocator *t_a= lloc, + void *addr) +{ + QVhostUserBlkPCI *vhost_user_blk =3D g_new0(QVhostUserBlkPCI, 1); + QVhostUserBlk *interface =3D &vhost_user_blk->blk; + QOSGraphObject *obj =3D &vhost_user_blk->pci_vdev.obj; + + virtio_pci_init(&vhost_user_blk->pci_vdev, pci_bus, addr); + interface->vdev =3D &vhost_user_blk->pci_vdev.vdev; + + g_assert_cmphex(interface->vdev->device_type, =3D=3D, VIRTIO_ID_BLOCK); + + obj->get_driver =3D qvhost_user_blk_pci_get_driver; + + return obj; +} + +static void vhost_user_blk_register_nodes(void) +{ + /* + * FIXME: every test using these two nodes needs to setup a + * -drive,id=3Ddrive0 otherwise QEMU is not going to start. + * Therefore, we do not include "produces" edge for virtio + * and pci-device yet. + */ + + char *arg =3D g_strdup_printf("id=3Ddrv0,chardev=3Dchar1,addr=3D%x.%x", + PCI_SLOT, PCI_FN); + + QPCIAddress addr =3D { + .devfn =3D QPCI_DEVFN(PCI_SLOT, PCI_FN), + }; + + QOSGraphEdgeOptions opts =3D { }; + + /* virtio-blk-device */ + /** opts.extra_device_opts =3D "drive=3Ddrive0"; */ + qos_node_create_driver("vhost-user-blk-device", vhost_user_blk_device_= create); + qos_node_consumes("vhost-user-blk-device", "virtio-bus", &opts); + qos_node_produces("vhost-user-blk-device", "vhost-user-blk"); + + /* virtio-blk-pci */ + opts.extra_device_opts =3D arg; + add_qpci_address(&opts, &addr); + qos_node_create_driver("vhost-user-blk-pci", vhost_user_blk_pci_create= ); + qos_node_consumes("vhost-user-blk-pci", "pci-bus", &opts); + qos_node_produces("vhost-user-blk-pci", "vhost-user-blk"); + + g_free(arg); +} + +libqos_init(vhost_user_blk_register_nodes); diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 99deff47ef..ab34075f2b 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -4,11 +4,13 @@ * Copyright IBM, Corp. 2012 * Copyright Red Hat, Inc. 2012 * Copyright SUSE LINUX Products GmbH 2013 + * Copyright Copyright (c) Coiby Xu * * Authors: * Anthony Liguori * Paolo Bonzini * Andreas F=C3=A4rber + * Coiby Xu * * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * See the COPYING file in the top-level directory. @@ -52,8 +54,7 @@ typedef struct QTestClientTransportOps { QTestRecvFn recv_line; /* for receiving qtest command responses */ } QTestTransportOps; =20 -struct QTestState -{ +struct QTestState { int fd; int qmp_fd; pid_t qemu_pid; /* our child QEMU process */ @@ -630,6 +631,37 @@ QDict *qtest_qmp_receive_dict(QTestState *s) return qmp_fd_receive(s->qmp_fd); } =20 +QTestState *qtest_create_state_with_qmp_fd(int fd) +{ + QTestState *qmp_test_state =3D g_new0(QTestState, 1); + qmp_test_state->qmp_fd =3D fd; + return qmp_test_state; +} + +int qtest_socket_client(char *server_socket_path) +{ + struct sockaddr_un serv_addr; + int sock; + int ret; + int retries =3D 0; + sock =3D socket(PF_UNIX, SOCK_STREAM, 0); + g_assert_cmpint(sock, !=3D, -1); + serv_addr.sun_family =3D AF_UNIX; + snprintf(serv_addr.sun_path, sizeof(serv_addr.sun_path), "%s", + server_socket_path); + + for (retries =3D 0; retries < 3; retries++) { + ret =3D connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_a= ddr)); + if (ret =3D=3D 0) { + break; + } + g_usleep(G_USEC_PER_SEC); + } + + g_assert_cmpint(ret, =3D=3D, 0); + return sock; +} + /** * Allow users to send a message without waiting for the reply, * in the case that they choose to discard all replies up until diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c new file mode 100644 index 0000000000..e7e44f9bf0 --- /dev/null +++ b/tests/qtest/vhost-user-blk-test.c @@ -0,0 +1,751 @@ +/* + * QTest testcase for Vhost-user Block Device + * + * Based on tests/qtest//virtio-blk-test.c + + * Copyright (c) 2014 SUSE LINUX Products GmbH + * Copyright (c) 2014 Marc Mar=C3=AD + * Copyright (c) 2020 Coiby Xu + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "libqtest-single.h" +#include "qemu/bswap.h" +#include "qemu/module.h" +#include "standard-headers/linux/virtio_blk.h" +#include "standard-headers/linux/virtio_pci.h" +#include "libqos/qgraph.h" +#include "libqos/vhost-user-blk.h" +#include "libqos/libqos-pc.h" + +#define TEST_IMAGE_SIZE (64 * 1024 * 1024) +#define QVIRTIO_BLK_TIMEOUT_US (30 * 1000 * 1000) +#define PCI_SLOT_HP 0x06 + +typedef struct QVirtioBlkReq { + uint32_t type; + uint32_t ioprio; + uint64_t sector; + char *data; + uint8_t status; +} QVirtioBlkReq; + +#ifdef HOST_WORDS_BIGENDIAN +static const bool host_is_big_endian =3D true; +#else +static const bool host_is_big_endian; /* false */ +#endif + +static inline void virtio_blk_fix_request(QVirtioDevice *d, QVirtioBlkReq = *req) +{ + if (qvirtio_is_big_endian(d) !=3D host_is_big_endian) { + req->type =3D bswap32(req->type); + req->ioprio =3D bswap32(req->ioprio); + req->sector =3D bswap64(req->sector); + } +} + +static inline void virtio_blk_fix_dwz_hdr(QVirtioDevice *d, + struct virtio_blk_discard_write_zeroes *dwz_hdr) +{ + if (qvirtio_is_big_endian(d) !=3D host_is_big_endian) { + dwz_hdr->sector =3D bswap64(dwz_hdr->sector); + dwz_hdr->num_sectors =3D bswap32(dwz_hdr->num_sectors); + dwz_hdr->flags =3D bswap32(dwz_hdr->flags); + } +} + +static uint64_t virtio_blk_request(QGuestAllocator *alloc, QVirtioDevice *= d, + QVirtioBlkReq *req, uint64_t data_size) +{ + uint64_t addr; + uint8_t status =3D 0xFF; + QTestState *qts =3D global_qtest; + + switch (req->type) { + case VIRTIO_BLK_T_IN: + case VIRTIO_BLK_T_OUT: + g_assert_cmpuint(data_size % 512, =3D=3D, 0); + break; + case VIRTIO_BLK_T_DISCARD: + case VIRTIO_BLK_T_WRITE_ZEROES: + g_assert_cmpuint(data_size % + sizeof(struct virtio_blk_discard_write_zeroes), = =3D=3D, 0); + break; + default: + g_assert_cmpuint(data_size, =3D=3D, 0); + } + + addr =3D guest_alloc(alloc, sizeof(*req) + data_size); + + virtio_blk_fix_request(d, req); + + qtest_memwrite(qts, addr, req, 16); + qtest_memwrite(qts, addr + 16, req->data, data_size); + qtest_memwrite(qts, addr + 16 + data_size, &status, sizeof(status)); + + return addr; +} + +/* Returns the request virtqueue so the caller can perform further tests */ +static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc) +{ + QVirtioBlkReq req; + uint64_t req_addr; + uint64_t capacity; + uint64_t features; + uint32_t free_head; + uint8_t status; + char *data; + QTestState *qts =3D global_qtest; + QVirtQueue *vq; + + features =3D qvirtio_get_features(dev); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_INDIRECT_DESC) | + (1u << VIRTIO_RING_F_EVENT_IDX) | + (1u << VIRTIO_BLK_F_SCSI)); + qvirtio_set_features(dev, features); + + capacity =3D qvirtio_config_readq(dev, 0); + g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); + + vq =3D qvirtqueue_setup(dev, alloc, 0); + + qvirtio_set_driver_ok(dev); + + /* Write and read with 3 descriptor layout */ + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(alloc, req_addr); + + /* Read request */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, true, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpstr(data, =3D=3D, "TEST"); + g_free(data); + + guest_free(alloc, req_addr); + + if (features & (1u << VIRTIO_BLK_F_WRITE_ZEROES)) { + struct virtio_blk_discard_write_zeroes dwz_hdr; + void *expected; + + /* + * WRITE_ZEROES request on the same sector of previous test where + * we wrote "TEST". + */ + req.type =3D VIRTIO_BLK_T_WRITE_ZEROES; + req.data =3D (char *) &dwz_hdr; + dwz_hdr.sector =3D 0; + dwz_hdr.num_sectors =3D 1; + dwz_hdr.flags =3D 0; + + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr); + + req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr)); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr), false, tru= e); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr), 1, true, + false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 16 + sizeof(dwz_hdr)); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(alloc, req_addr); + + /* Read request to check if the sector contains all zeroes */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, true, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc(512); + expected =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpmem(data, 512, expected, 512); + g_free(expected); + g_free(data); + + guest_free(alloc, req_addr); + } + + if (features & (1u << VIRTIO_BLK_F_DISCARD)) { + struct virtio_blk_discard_write_zeroes dwz_hdr; + + req.type =3D VIRTIO_BLK_T_DISCARD; + req.data =3D (char *) &dwz_hdr; + dwz_hdr.sector =3D 0; + dwz_hdr.num_sectors =3D 1; + dwz_hdr.flags =3D 0; + + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr); + + req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr)); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr), false, tru= e); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr), + 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 16 + sizeof(dwz_hdr)); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(alloc, req_addr); + } + + if (features & (1u << VIRTIO_F_ANY_LAYOUT)) { + /* Write and read with 2 descriptor layout */ + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 1; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 528, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(alloc, req_addr); + + /* Read request */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 1; + req.data =3D g_malloc0(512); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 513, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpstr(data, =3D=3D, "TEST"); + g_free(data); + + guest_free(alloc, req_addr); + } + + return vq; +} + +static void basic(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVhostUserBlk *blk_if =3D obj; + QVirtQueue *vq; + + vq =3D test_basic(blk_if->vdev, t_alloc); + qvirtqueue_cleanup(blk_if->vdev->bus, vq, t_alloc); + +} + +static void indirect(void *obj, void *u_data, QGuestAllocator *t_alloc) +{ + QVirtQueue *vq; + QVhostUserBlk *blk_if =3D obj; + QVirtioDevice *dev =3D blk_if->vdev; + QVirtioBlkReq req; + QVRingIndirectDesc *indirect; + uint64_t req_addr; + uint64_t capacity; + uint64_t features; + uint32_t free_head; + uint8_t status; + char *data; + QTestState *qts =3D global_qtest; + + features =3D qvirtio_get_features(dev); + g_assert_cmphex(features & (1u << VIRTIO_RING_F_INDIRECT_DESC), !=3D, = 0); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_EVENT_IDX) | + (1u << VIRTIO_BLK_F_SCSI)); + qvirtio_set_features(dev, features); + + capacity =3D qvirtio_config_readq(dev, 0); + g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); + + vq =3D qvirtqueue_setup(dev, t_alloc, 0); + qvirtio_set_driver_ok(dev); + + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + indirect =3D qvring_indirect_desc_setup(qts, dev, t_alloc, 2); + qvring_indirect_desc_add(dev, qts, indirect, req_addr, 528, false); + qvring_indirect_desc_add(dev, qts, indirect, req_addr + 528, 1, true); + free_head =3D qvirtqueue_add_indirect(qts, vq, indirect); + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + g_free(indirect); + guest_free(t_alloc, req_addr); + + /* Read request */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + indirect =3D qvring_indirect_desc_setup(qts, dev, t_alloc, 2); + qvring_indirect_desc_add(dev, qts, indirect, req_addr, 16, false); + qvring_indirect_desc_add(dev, qts, indirect, req_addr + 16, 513, true); + free_head =3D qvirtqueue_add_indirect(qts, vq, indirect); + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpstr(data, =3D=3D, "TEST"); + g_free(data); + + g_free(indirect); + guest_free(t_alloc, req_addr); + qvirtqueue_cleanup(dev->bus, vq, t_alloc); +} + +static void idx(void *obj, void *u_data, QGuestAllocator *t_alloc) +{ + QVirtQueue *vq; + QVhostUserBlkPCI *blk =3D obj; + QVirtioPCIDevice *pdev =3D &blk->pci_vdev; + QVirtioDevice *dev =3D &pdev->vdev; + QVirtioBlkReq req; + uint64_t req_addr; + uint64_t capacity; + uint64_t features; + uint32_t free_head; + uint32_t write_head; + uint32_t desc_idx; + uint8_t status; + char *data; + QOSGraphObject *blk_object =3D obj; + QPCIDevice *pci_dev =3D blk_object->get_driver(blk_object, "pci-device= "); + QTestState *qts =3D global_qtest; + + if (qpci_check_buggy_msi(pci_dev)) { + return; + } + + qpci_msix_enable(pdev->pdev); + qvirtio_pci_set_msix_configuration_vector(pdev, t_alloc, 0); + + features =3D qvirtio_get_features(dev); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_INDIRECT_DESC) | + (1u << VIRTIO_F_NOTIFY_ON_EMPTY) | + (1u << VIRTIO_BLK_F_SCSI)); + qvirtio_set_features(dev, features); + + capacity =3D qvirtio_config_readq(dev, 0); + g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); + + vq =3D qvirtqueue_setup(dev, t_alloc, 0); + qvirtqueue_pci_msix_setup(pdev, (QVirtQueuePCI *)vq, t_alloc, 1); + + qvirtio_set_driver_ok(dev); + + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 1; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + /* Notify after processing the third request */ + qvirtqueue_set_used_event(qts, vq, 2); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); + write_head =3D free_head; + + /* No notification expected */ + status =3D qvirtio_wait_status_byte_no_isr(qts, dev, + vq, req_addr + 528, + QVIRTIO_BLK_TIMEOUT_US); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(t_alloc, req_addr); + + /* Read request */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 1; + req.data =3D g_malloc0(512); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, true, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + /* We get just one notification for both requests */ + qvirtio_wait_used_elem(qts, dev, vq, write_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + g_assert(qvirtqueue_get_buf(qts, vq, &desc_idx, NULL)); + g_assert_cmpint(desc_idx, =3D=3D, free_head); + + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpstr(data, =3D=3D, "TEST"); + g_free(data); + + guest_free(t_alloc, req_addr); + + /* End test */ + qpci_msix_disable(pdev->pdev); + + qvirtqueue_cleanup(dev->bus, vq, t_alloc); +} + +static void pci_hotplug(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVirtioPCIDevice *dev1 =3D obj; + QVirtioPCIDevice *dev; + QTestState *qts =3D dev1->pdev->bus->qts; + + /* plug secondary disk */ + qtest_qmp_device_add(qts, "vhost-user-blk-pci", "drv1", + "{'addr': %s, 'chardev': 'char2'}", + stringify(PCI_SLOT_HP) ".0"); + + dev =3D virtio_pci_new(dev1->pdev->bus, + &(QPCIAddress) { .devfn =3D QPCI_DEVFN(PCI_SLOT_H= P, 0) + }); + g_assert_nonnull(dev); + g_assert_cmpint(dev->vdev.device_type, =3D=3D, VIRTIO_ID_BLOCK); + qvirtio_pci_device_disable(dev); + qos_object_destroy((QOSGraphObject *)dev); + + /* unplug secondary disk */ + qpci_unplug_acpi_device_test(qts, "drv1", PCI_SLOT_HP); +} + +/* + * Check that setting the vring addr on a non-existent virtqueue does + * not crash. + */ +static void test_nonexistent_virtqueue(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVhostUserBlkPCI *blk =3D obj; + QVirtioPCIDevice *pdev =3D &blk->pci_vdev; + QPCIBar bar0; + QPCIDevice *dev; + + dev =3D qpci_device_find(pdev->pdev->bus, QPCI_DEVFN(4, 0)); + g_assert(dev !=3D NULL); + qpci_device_enable(dev); + + bar0 =3D qpci_iomap(dev, 0, NULL); + + qpci_io_writeb(dev, bar0, VIRTIO_PCI_QUEUE_SEL, 2); + qpci_io_writel(dev, bar0, VIRTIO_PCI_QUEUE_PFN, 1); + + g_free(dev); +} + +static const char *qtest_qemu_storage_daemon_binary(void) +{ + const char *qemu_storage_daemon_bin; + + qemu_storage_daemon_bin =3D getenv("QTEST_QEMU_STORAGE_DAEMON_BINARY"); + if (!qemu_storage_daemon_bin) { + fprintf(stderr, "Environment variable " + "QTEST_QEMU_STORAGE_DAEMON_BINARY required\n"); + exit(0); + } + + return qemu_storage_daemon_bin; +} + +static void drive_destroy(void *path) +{ + unlink(path); + g_free(path); + qos_invalidate_command_line(); +} + +static char *drive_create(void) +{ + int fd, ret; + /** vhost-user-blk won't recognize drive located in /tmp */ + char *t_path =3D g_strdup("qtest.XXXXXX"); + + /** Create a temporary raw image */ + fd =3D mkstemp(t_path); + g_assert_cmpint(fd, >=3D, 0); + ret =3D ftruncate(fd, TEST_IMAGE_SIZE); + g_assert_cmpint(ret, =3D=3D, 0); + close(fd); + + g_test_queue_destroy(drive_destroy, t_path); + return t_path; +} + +static char sock_path_tempate[] =3D "/tmp/qtest.vhost_user_blk.XXXXXX"; +static char qmp_sock_path_tempate[] =3D "/tmp/qtest.vhost_user_blk.qmp.XXX= XXX"; + +static void quit_storage_daemon(void *qmp_test_state) +{ + const char quit_str[] =3D "{ 'execute': 'quit' }"; + + /* Before quiting storate-daemon, quit qemu to avoid dubious messages = */ + qobject_unref(qtest_qmp(global_qtest, quit_str)); + + /* + * Give storage-daemon enough time to wake up&terminate + * vu_client_trip coroutine so the Coroutine object could + * be cleaned up. Otherwise LeakSanitizer would complain + * about memory leaks. + */ + g_usleep(1000); + + qobject_unref(qtest_qmp((QTestState *)qmp_test_state, quit_str)); + g_free(qmp_test_state); +} + +static char *start_vhost_user_blk(GString *cmd_line, int vus_instances) +{ + const char *vhost_user_blk_bin =3D qtest_qemu_storage_daemon_binary(); + int fd, qmp_fd, i; + QTestState *qmp_test_state; + gchar *img_path; + char *sock_path =3D NULL; + char *qmp_sock_path =3D g_strdup(qmp_sock_path_tempate); + GString *storage_daemon_command =3D g_string_new(NULL); + + qmp_fd =3D mkstemp(qmp_sock_path); + g_assert_cmpint(qmp_fd, >=3D, 0); + g_test_queue_destroy(drive_destroy, qmp_sock_path); + + g_string_append_printf(storage_daemon_command, + "exec %s " + "--chardev socket,id=3Dqmp,path=3D%s,server,nowait --monitor c= hardev=3Dqmp ", + vhost_user_blk_bin, qmp_sock_path); + + g_string_append_printf(cmd_line, + " -object memory-backend-memfd,id=3Dmem,size=3D256M,share=3Don= -M memory-backend=3Dmem "); + + for (i =3D 0; i < vus_instances; i++) { + sock_path =3D g_strdup(sock_path_tempate); + fd =3D mkstemp(sock_path); + g_assert_cmpint(fd, >=3D, 0); + g_test_queue_destroy(drive_destroy, sock_path); + /* create image file */ + img_path =3D drive_create(); + g_string_append_printf(storage_daemon_command, + "--blockdev driver=3Dfile,node-name=3Ddisk%d,filename=3D%s " + "--export type=3Dvhost-user-blk,id=3Ddisk%d,addr.type=3Dunix,a= ddr.path=3D%s," + "node-name=3Ddisk%i,writable=3Don ", + i, img_path, i, sock_path, i); + + g_string_append_printf(cmd_line, "-chardev socket,id=3Dchar%d,path= =3D%s ", + i + 1, sock_path); + } + + g_test_message("starting vhost-user backend: %s", + storage_daemon_command->str); + pid_t pid =3D fork(); + if (pid =3D=3D 0) { + execlp("/bin/sh", "sh", "-c", storage_daemon_command->str, NULL); + exit(1); + } + g_string_free(storage_daemon_command, true); + + qmp_test_state =3D qtest_create_state_with_qmp_fd( + qtest_socket_client(qmp_sock_path)); + /* + * Ask qemu-storage-daemon to quit so it + * will not block scripts/tap-driver.pl. + */ + g_test_queue_destroy(quit_storage_daemon, qmp_test_state); + + qobject_unref(qtest_qmp(qmp_test_state, "{'execute': 'qmp_capabilities= '}")); + return sock_path; +} + +static void *vhost_user_blk_test_setup(GString *cmd_line, void *arg) +{ + start_vhost_user_blk(cmd_line, 1); + return arg; +} + +/* + * Setup for hotplug. + * + * Since vhost-user server only serves one vhost-user client one time, + * another exprot + * + */ +static void *vhost_user_blk_hotplug_test_setup(GString *cmd_line, void *ar= g) +{ + /* "-chardev socket,id=3Dchar2" is used for pci_hotplug*/ + start_vhost_user_blk(cmd_line, 2); + return arg; +} + +static void register_vhost_user_blk_test(void) +{ + QOSGraphTestOptions opts =3D { + .before =3D vhost_user_blk_test_setup, + }; + + /* + * tests for vhost-user-blk and vhost-user-blk-pci + * The tests are borrowed from tests/virtio-blk-test.c. But some tests + * regarding block_resize don't work for vhost-user-blk. + * vhost-user-blk device doesn't have -drive, so tests containing + * block_resize are also abandoned, + * - config + * - resize + */ + qos_add_test("basic", "vhost-user-blk", basic, &opts); + qos_add_test("indirect", "vhost-user-blk", indirect, &opts); + qos_add_test("idx", "vhost-user-blk-pci", idx, &opts); + qos_add_test("nxvirtq", "vhost-user-blk-pci", + test_nonexistent_virtqueue, &opts); + + opts.before =3D vhost_user_blk_hotplug_test_setup; + qos_add_test("hotplug", "vhost-user-blk-pci", pci_hotplug, &opts); +} + +libqos_init(register_vhost_user_blk_test); diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build index 1cddf5bdaa..1f5c8f1053 100644 --- a/tests/qtest/libqos/meson.build +++ b/tests/qtest/libqos/meson.build @@ -32,6 +32,7 @@ libqos_srcs =3D files('../libqtest.c', 'virtio-9p.c', 'virtio-balloon.c', 'virtio-blk.c', + 'vhost-user-blk.c', 'virtio-mmio.c', 'virtio-net.c', 'virtio-pci.c', diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index c19f1c8503..23a70b4613 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -199,6 +199,7 @@ qos_test_ss.add( ) qos_test_ss.add(when: 'CONFIG_VIRTFS', if_true: files('virtio-9p-test.c')) qos_test_ss.add(when: 'CONFIG_VHOST_USER', if_true: files('vhost-user-test= .c')) +qos_test_ss.add(when: ['CONFIG_LINUX', 'CONFIG_TOOLS'], if_true: files('vh= ost-user-blk-test.c')) =20 tpmemu_files =3D ['tpm-emu.c', 'tpm-util.c', 'tpm-tests.c'] =20 @@ -237,6 +238,7 @@ foreach dir : target_dirs endif qtest_env.set('G_TEST_DBUS_DAEMON', meson.source_root() / 'tests/dbus-vm= state-daemon.sh') qtest_env.set('QTEST_QEMU_BINARY', './qemu-system-' + target_base) + qtest_env.set('QTEST_QEMU_STORAGE_DAEMON_BINARY', './storage-daemon/qemu= -storage-daemon') =20 foreach test : target_qtests # Executables are shared across targets, declare them only the first t= ime we --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466943; cv=none; d=zohomail.com; s=zohoarc; b=oHW4chJUWxjjef6e6+GfooAtneazomIq2qex7GzwM8/Bw0pPW94ZadBGWLBSxKu7KnAWlsVVO1EfKx9HQLDTz5zFjiQIOtbJKqQKiOgFIeZCPxJZZZq9A3u2i0MsUaAIy8f7CG/Ad5Szp1ffV2VxGMfdhmw9W4Ycne1TCkOv+xA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466943; 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=IbXx/en61PP6xw7L1bYEyVwqp2fnuXoDT6+6BHQY4zY=; b=l5HeGZGaKUcpSHTBlC+MNbcR0jjwquZzJWTJtzgbbt2459zZzyfGt3yEf6/vj/6XtCIuJP7nAKmVLWk7mxyicK2XSyQaOpsmF7E5dK1TkvFhDKfK9QRYy3R+KlB/1nCg41/0pI+gRLLBXpIAyB0M8UFFGz9Ce+Uv0BiuRRZm0ug= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466943858999.2886867780944; Tue, 3 Nov 2020 21:15:43 -0800 (PST) Received: from localhost ([::1]:60882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaB94-0006qx-LP for importer@patchew.org; Wed, 04 Nov 2020 00:15:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAnC-0000sK-86 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:53:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20794) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAn9-00057C-A8 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:53:05 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-44-obTMKEvPP0qHUJCV7fxJNA-1; Tue, 03 Nov 2020 23:52:15 -0500 Received: by mail-wm1-f71.google.com with SMTP id o19so740576wme.2 for ; Tue, 03 Nov 2020 20:52:15 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id y11sm790618wmj.36.2020.11.03.20.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:52:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465582; 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=IbXx/en61PP6xw7L1bYEyVwqp2fnuXoDT6+6BHQY4zY=; b=cyh0pX55oKKvv81nHpZUzsj51FWkxfMSOsewD+pA7vUOML5Y5riubtaE7C8Q3zEUbAjm74 LpRi1wiiNTxfSfXiiUnMlWe4SWVgYFbE9h2FUt3hW+gAFzzQJmYDLT1QJqhHoxARGKK3Qu H5qzAP7WjP7pVJTBkC1v8wLecrgdsgw= X-MC-Unique: obTMKEvPP0qHUJCV7fxJNA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=IbXx/en61PP6xw7L1bYEyVwqp2fnuXoDT6+6BHQY4zY=; b=PE8LjYQoKbrO9fVWVlqdWaFkc+mThy534ebldKVjViUZmx4GxPgfva8mTmWk3O5YHl AVLqhqGL0r9dydvcCXjEyjSOy2MrEiV2Kq47q2uFOlHCihPQpTGySVod+p+g4DjOZgnd vxUPoI1f2pB4dLHp2XHsit/aR7OqDWd3B/x50hxcfErH9nx+3wLchYGADoaWNG2F+2os riZWJDCvtvfPOnpPqtnqjVVqx4fUEJrDTqqnHWdo9OBO5lEpmQbiXH/hNqEVaqdBz8AM Z/Z4X50wWpCinNq8ZF+kjfOYv5R8sTi1x5hWDrX1BbVnRZHJHV+D4UAbxK1U9CHj6V/z 5mzQ== X-Gm-Message-State: AOAM533Eu3bpRJfARmCOiQIl9md820tlKv1EKZS/7Uux7MEq1f+mBwtL GOwkwfh4WW4hHbNA7i4nRK+LtEWarYRJ7mWzYTwD6ta9Tk/hiq88LRAUjx4y/2DgT3d05OskQt2 xUCtGRF85FgNnBMs= X-Received: by 2002:a1c:1f91:: with SMTP id f139mr2339632wmf.187.1604465533632; Tue, 03 Nov 2020 20:52:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJHdoe4WImVutJSVXm+ed/c7WdUsDEtjtgNrpmiR//+5yqtddfmQwmG92+m8ccY5GJa/s6Bw== X-Received: by 2002:a1c:1f91:: with SMTP id f139mr2339620wmf.187.1604465533503; Tue, 03 Nov 2020 20:52:13 -0800 (PST) Date: Tue, 3 Nov 2020 23:52:11 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 33/38] tests/qtest: add multi-queue test case to vhost-user-blk-test Message-ID: <20201104044937.226370-34-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi Message-id: 20201001144604.559733-3-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-8-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/vhost-user-blk-test.c | 81 +++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 5 deletions(-) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index e7e44f9bf0..31f2335f97 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -559,6 +559,67 @@ static void pci_hotplug(void *obj, void *data, QGuestA= llocator *t_alloc) qpci_unplug_acpi_device_test(qts, "drv1", PCI_SLOT_HP); } =20 +static void multiqueue(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVirtioPCIDevice *pdev1 =3D obj; + QVirtioDevice *dev1 =3D &pdev1->vdev; + QVirtioPCIDevice *pdev8; + QVirtioDevice *dev8; + QTestState *qts =3D pdev1->pdev->bus->qts; + uint64_t features; + uint16_t num_queues; + + /* + * The primary device has 1 queue and VIRTIO_BLK_F_MQ is not enabled. = The + * VIRTIO specification allows VIRTIO_BLK_F_MQ to be enabled when ther= e is + * only 1 virtqueue, but --device vhost-user-blk-pci doesn't do this (= which + * is also spec-compliant). + */ + features =3D qvirtio_get_features(dev1); + g_assert_cmpint(features & (1u << VIRTIO_BLK_F_MQ), =3D=3D, 0); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_INDIRECT_DESC) | + (1u << VIRTIO_F_NOTIFY_ON_EMPTY) | + (1u << VIRTIO_BLK_F_SCSI)); + qvirtio_set_features(dev1, features); + + /* Hotplug a secondary device with 8 queues */ + qtest_qmp_device_add(qts, "vhost-user-blk-pci", "drv1", + "{'addr': %s, 'chardev': 'char2', 'num-queues': 8= }", + stringify(PCI_SLOT_HP) ".0"); + + pdev8 =3D virtio_pci_new(pdev1->pdev->bus, + &(QPCIAddress) { + .devfn =3D QPCI_DEVFN(PCI_SLOT_HP, 0) + }); + g_assert_nonnull(pdev8); + g_assert_cmpint(pdev8->vdev.device_type, =3D=3D, VIRTIO_ID_BLOCK); + + qos_object_start_hw(&pdev8->obj); + + dev8 =3D &pdev8->vdev; + features =3D qvirtio_get_features(dev8); + g_assert_cmpint(features & (1u << VIRTIO_BLK_F_MQ), + =3D=3D, + (1u << VIRTIO_BLK_F_MQ)); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_INDIRECT_DESC) | + (1u << VIRTIO_F_NOTIFY_ON_EMPTY) | + (1u << VIRTIO_BLK_F_SCSI) | + (1u << VIRTIO_BLK_F_MQ)); + qvirtio_set_features(dev8, features); + + num_queues =3D qvirtio_config_readw(dev8, + offsetof(struct virtio_blk_config, num_queues)); + g_assert_cmpint(num_queues, =3D=3D, 8); + + qvirtio_pci_device_disable(pdev8); + qos_object_destroy(&pdev8->obj); + + /* unplug secondary disk */ + qpci_unplug_acpi_device_test(qts, "drv1", PCI_SLOT_HP); +} + /* * Check that setting the vring addr on a non-existent virtqueue does * not crash. @@ -643,7 +704,8 @@ static void quit_storage_daemon(void *qmp_test_state) g_free(qmp_test_state); } =20 -static char *start_vhost_user_blk(GString *cmd_line, int vus_instances) +static char *start_vhost_user_blk(GString *cmd_line, int vus_instances, + int num_queues) { const char *vhost_user_blk_bin =3D qtest_qemu_storage_daemon_binary(); int fd, qmp_fd, i; @@ -675,8 +737,8 @@ static char *start_vhost_user_blk(GString *cmd_line, in= t vus_instances) g_string_append_printf(storage_daemon_command, "--blockdev driver=3Dfile,node-name=3Ddisk%d,filename=3D%s " "--export type=3Dvhost-user-blk,id=3Ddisk%d,addr.type=3Dunix,a= ddr.path=3D%s," - "node-name=3Ddisk%i,writable=3Don ", - i, img_path, i, sock_path, i); + "node-name=3Ddisk%i,writable=3Don,num-queues=3D%d ", + i, img_path, i, sock_path, i, num_queues); =20 g_string_append_printf(cmd_line, "-chardev socket,id=3Dchar%d,path= =3D%s ", i + 1, sock_path); @@ -705,7 +767,7 @@ static char *start_vhost_user_blk(GString *cmd_line, in= t vus_instances) =20 static void *vhost_user_blk_test_setup(GString *cmd_line, void *arg) { - start_vhost_user_blk(cmd_line, 1); + start_vhost_user_blk(cmd_line, 1, 1); return arg; } =20 @@ -719,7 +781,13 @@ static void *vhost_user_blk_test_setup(GString *cmd_li= ne, void *arg) static void *vhost_user_blk_hotplug_test_setup(GString *cmd_line, void *ar= g) { /* "-chardev socket,id=3Dchar2" is used for pci_hotplug*/ - start_vhost_user_blk(cmd_line, 2); + start_vhost_user_blk(cmd_line, 2, 1); + return arg; +} + +static void *vhost_user_blk_multiqueue_test_setup(GString *cmd_line, void = *arg) +{ + start_vhost_user_blk(cmd_line, 2, 8); return arg; } =20 @@ -746,6 +814,9 @@ static void register_vhost_user_blk_test(void) =20 opts.before =3D vhost_user_blk_hotplug_test_setup; qos_add_test("hotplug", "vhost-user-blk-pci", pci_hotplug, &opts); + + opts.before =3D vhost_user_blk_multiqueue_test_setup; + qos_add_test("multiqueue", "vhost-user-blk-pci", multiqueue, &opts); } =20 libqos_init(register_vhost_user_blk_test); --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465730; cv=none; d=zohomail.com; s=zohoarc; b=POE3+2i20yImblf7XmVt6CIDP9RCIasQSMP+MlROcqWuSVs8C8yxsr34X64jsnUSp8qSk7nBh5n9Qo9E76hatybRjXmpgzmkwkSVhZ7nb1s3xGCHM8DZ/7ib4/EjXMCViUhb9i4QoNJodZIOiO48aTh3Sr2hFacec58nt3dl8XU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465730; 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=TD7SW6oID+mQnZFy+V2Ba30n404JJ+wGVVREK/DvNQg=; b=ZJtNYTfSIO9P4W8Qxv6lc8h9nMKN4VcjyH6MXDt4lr16EO9mxYpu2zF0OvDnNo2eDVcqXsNbdrulSeiw9n9p506kpmlekAl2J2LlX3W++cw1WDBHY28DGJfjDsNWP6oukyfroTqUmx7AQxqLSMv+7b41qh8COUPUHgbnJcpZd+s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604465730867796.2045057086491; Tue, 3 Nov 2020 20:55:30 -0800 (PST) Received: from localhost ([::1]:48770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaApV-0003rB-QJ for importer@patchew.org; Tue, 03 Nov 2020 23:55:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAmU-0007V4-ML for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51547) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAmS-0004t2-OA for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:22 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-433-rl1JBh8nPFyQIOXc3GuTlQ-1; Tue, 03 Nov 2020 23:52:18 -0500 Received: by mail-wm1-f71.google.com with SMTP id 13so745113wmf.0 for ; Tue, 03 Nov 2020 20:52:17 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id x18sm926510wrg.4.2020.11.03.20.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:52:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465540; 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=TD7SW6oID+mQnZFy+V2Ba30n404JJ+wGVVREK/DvNQg=; b=aZCP3jAcMXUKp7xzl4wGCRhPY1pmIPd0O7TT2J8FpshJwgy4PQ36lHSUyFr7QATiKWz1nQ Dk+Na8/3W31OfT3gh6IVVXff8zH6/UM+Js2eD2IheGSeLD+G9fj5gmf9i57RHngRolXR+m v3ng3OJZlx4iTpfTOb0j6ja7GOJDjQc= X-MC-Unique: rl1JBh8nPFyQIOXc3GuTlQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=TD7SW6oID+mQnZFy+V2Ba30n404JJ+wGVVREK/DvNQg=; b=brJpTjVJVufENROetFwUeGYHHqEKLvwWFbTcHO8OcQwLXr3rUDT7+VEaRtNgM5cDS9 IRkg+Zk9fxumpVXr5XopjsC79Gtsj01n9um9rjLN9UeJ0ao9u2Y7sO8wmq4ui51EBiVF IzoxBTXrmr283+mCjSW7gm1pRezFlHTsWw9+zBFRQa1e7DyDUZUy65fAaFhNc8Kk3ovT wg7Npj5RUplgOPzC3CH93RtVMJxqtpumunQ7axTSFxoNFTef3p4FxJUNX/uMTS07B3hC z1iQhDLxZmPrOLRMCDT5HrON4HGG6PWa2FFQoSffW11cQyxahXnJq/1MmnRHb1YFf+6Q LHiw== X-Gm-Message-State: AOAM530rGfSmxOBbnunKH056Etmasi44ixvn5wriiUNrl96A6qv0n542 ki2qCRcOotPHze+wReVP6QD0repP758eiTnFpnjxGpKINAItogXEZOwghcKNXZTbZPcGyw79S0F JjU/Kei35+S7+2ow= X-Received: by 2002:adf:8296:: with SMTP id 22mr30026186wrc.341.1604465536295; Tue, 03 Nov 2020 20:52:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQtGJvRzuJRVkQQaGdOLzVKaIhBMX8O1pz2/91oQjb81dn1jhGsEP/DXOaEi0JSD38ETqDyw== X-Received: by 2002:adf:8296:: with SMTP id 22mr30026174wrc.341.1604465536166; Tue, 03 Nov 2020 20:52:16 -0800 (PST) Date: Tue, 3 Nov 2020 23:52:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 34/38] libqtest: add qtest_socket_server() Message-ID: <20201104044937.226370-35-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi There is a qtest_socket_client() API. Add an equivalent qtest_socket_server() API that returns a new UNIX domain socket in the listen state. The code for this was already there but only used internally in init_socket(). Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-9-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/libqos/libqtest.h | 8 +++++++ tests/qtest/libqtest.c | 40 ++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h index 241b5f89fb..699be8c2a2 100644 --- a/tests/qtest/libqos/libqtest.h +++ b/tests/qtest/libqos/libqtest.h @@ -132,6 +132,14 @@ void qtest_qmp_send(QTestState *s, const char *fmt, ..= .) void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...) GCC_FMT_ATTR(2, 3); =20 +/** + * qtest_socket_server: + * @socket_path: the UNIX domain socket path + * + * Create and return a listen socket file descriptor, or abort on failure. + */ +int qtest_socket_server(const char *socket_path); + /** * qtest_socket_client: * @server_socket_path: the socket server's path diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index ab34075f2b..d652ffc90d 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -82,24 +82,8 @@ static void qtest_client_set_rx_handler(QTestState *s, Q= TestRecvFn recv); =20 static int init_socket(const char *socket_path) { - struct sockaddr_un addr; - int sock; - int ret; - - sock =3D socket(PF_UNIX, SOCK_STREAM, 0); - g_assert_cmpint(sock, !=3D, -1); - - addr.sun_family =3D AF_UNIX; - snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path); + int sock =3D qtest_socket_server(socket_path); qemu_set_cloexec(sock); - - do { - ret =3D bind(sock, (struct sockaddr *)&addr, sizeof(addr)); - } while (ret =3D=3D -1 && errno =3D=3D EINTR); - g_assert_cmpint(ret, !=3D, -1); - ret =3D listen(sock, 1); - g_assert_cmpint(ret, !=3D, -1); - return sock; } =20 @@ -638,6 +622,28 @@ QTestState *qtest_create_state_with_qmp_fd(int fd) return qmp_test_state; } =20 +int qtest_socket_server(const char *socket_path) +{ + struct sockaddr_un addr; + int sock; + int ret; + + sock =3D socket(PF_UNIX, SOCK_STREAM, 0); + g_assert_cmpint(sock, !=3D, -1); + + addr.sun_family =3D AF_UNIX; + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path); + + do { + ret =3D bind(sock, (struct sockaddr *)&addr, sizeof(addr)); + } while (ret =3D=3D -1 && errno =3D=3D EINTR); + g_assert_cmpint(ret, !=3D, -1); + ret =3D listen(sock, 1); + g_assert_cmpint(ret, !=3D, -1); + + return sock; +} + int qtest_socket_client(char *server_socket_path) { struct sockaddr_un serv_addr; --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466777; cv=none; d=zohomail.com; s=zohoarc; b=m9MG9prVEYgVZlEUGp1dpDdOZl6rSoPCySM8rGE1dOPIVI8mlM/y5kFG/BqzudPfxY/ZYf/m/OD6NbHtA4z6AvTiVcqRVW6inv8CHo3t0PF21hyjhRfkDeFLyxVRI/vHIzFiSBySsNldWX4WzcJ+JazxlQb6vaNR1TgdxjxzJcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466777; 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=oAjLZ11EwsHXoMOOACL8j6jIH95zMRiiieEROhG5SCc=; b=CEOZ7s+1igMptWqX4FTSG2qJpalG+q3dQY9yJPoNQtNNAY83s8G++zb3isSIFLlNAESpAHuocnb4l24pZ1DKlZhdsMnevMOfX2inYqC2wlMRkHraoQ09z3qI+fxJcBZTzue4YfCmuCNA2U7w1WMsV9uog8jehaE6jq9uZOl6qCM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466777745202.3122650566488; Tue, 3 Nov 2020 21:12:57 -0800 (PST) Received: from localhost ([::1]:53362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaB6O-0003lq-Fz for importer@patchew.org; Wed, 04 Nov 2020 00:12:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAmW-0007aB-VQ for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAmU-0004tB-Tj for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:24 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-357-tmEaLNRfP86qUFm6ZqeJiw-1; Tue, 03 Nov 2020 23:52:20 -0500 Received: by mail-wr1-f69.google.com with SMTP id 33so8659315wrf.22 for ; Tue, 03 Nov 2020 20:52:20 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id u15sm853127wrm.77.2020.11.03.20.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:52:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465542; 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=oAjLZ11EwsHXoMOOACL8j6jIH95zMRiiieEROhG5SCc=; b=duFbm/0+hrycbDX3+0N2et41xH2XKmjPhbFoVVKtAtI/Tx3j9YCOiaJXJCxxCnfYtMwzRE jKkoj9UwmuHb8ymCilmJ4AX++WOi3vrFyBarIS2ZUCfcZmSJt0rt2HRcG2adAqjy3Qx+6H eJQOkSpu0uGRwTLk4BQfxyMyLGyxeAc= X-MC-Unique: tmEaLNRfP86qUFm6ZqeJiw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=oAjLZ11EwsHXoMOOACL8j6jIH95zMRiiieEROhG5SCc=; b=lzQLPxSjRPg4IENnPsmvEadgQyhRQAHB2esuKLdSuDC5gjns5ZZIEu+P5c3HlkWp8D g8buzEGfcKEKEZ4WfHMuq7hV34xqzfcrCJJjCxCYCMmdk3T08R4EXZOvh8BmeL0Le0sh rLGUfmer5e9h6MjKlEsLxIpwXWsuW0mVe8tKy2WvYN0OaqD/7cXSD6RqwlAT0m88Hudf IBzJW7JhglRhusnEI2OP0ZeDTt8ZBRBRSQr7ZmLemCqNk7oaOdECYJ1qiNrasQOvmaCF +Ue7hZklv9WMzsPwdmxvWyxheWhu4VpIB0RBA8lshCbsnRttDMHNUvVzGqM1OKbUEbL6 RTqQ== X-Gm-Message-State: AOAM533Z7ZqbxyErTza6vXMuif3Yu/8dEYDQJRAIc5Ret5icaZeE6TL8 aZt1Bnd+fHH+F9LIbqKCnT7loZyxUrvX53u6HDupp+iJRYOxFcnqCzLGcpTFz7I+VjgobUwmIYd T0TLealfu8ZJm8hc= X-Received: by 2002:a5d:4581:: with SMTP id p1mr29642591wrq.353.1604465538923; Tue, 03 Nov 2020 20:52:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxigAe3jPW7Tu6L2pCxoUsdnY8FVMxv/V0FS0A0KvMatcvOkpmVmV6WMKV0cyS8drKtRm3csw== X-Received: by 2002:a5d:4581:: with SMTP id p1mr29642576wrq.353.1604465538803; Tue, 03 Nov 2020 20:52:18 -0800 (PST) Date: Tue, 3 Nov 2020 23:52:16 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 35/38] vhost-user-blk-test: rename destroy_drive() to destroy_file() Message-ID: <20201104044937.226370-36-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi The function is used not just for image files but also for UNIX domain sockets (QMP monitor and vhost-user-blk). Reflect that in the name. Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-10-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/vhost-user-blk-test.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index 31f2335f97..f05f14c192 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -658,7 +658,8 @@ static const char *qtest_qemu_storage_daemon_binary(voi= d) return qemu_storage_daemon_bin; } =20 -static void drive_destroy(void *path) +/* g_test_queue_destroy() cleanup function for files */ +static void destroy_file(void *path) { unlink(path); g_free(path); @@ -678,7 +679,7 @@ static char *drive_create(void) g_assert_cmpint(ret, =3D=3D, 0); close(fd); =20 - g_test_queue_destroy(drive_destroy, t_path); + g_test_queue_destroy(destroy_file, t_path); return t_path; } =20 @@ -717,7 +718,7 @@ static char *start_vhost_user_blk(GString *cmd_line, in= t vus_instances, =20 qmp_fd =3D mkstemp(qmp_sock_path); g_assert_cmpint(qmp_fd, >=3D, 0); - g_test_queue_destroy(drive_destroy, qmp_sock_path); + g_test_queue_destroy(destroy_file, qmp_sock_path); =20 g_string_append_printf(storage_daemon_command, "exec %s " @@ -731,7 +732,7 @@ static char *start_vhost_user_blk(GString *cmd_line, in= t vus_instances, sock_path =3D g_strdup(sock_path_tempate); fd =3D mkstemp(sock_path); g_assert_cmpint(fd, >=3D, 0); - g_test_queue_destroy(drive_destroy, sock_path); + g_test_queue_destroy(drive_file, sock_path); /* create image file */ img_path =3D drive_create(); g_string_append_printf(storage_daemon_command, --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604466527; cv=none; d=zohomail.com; s=zohoarc; b=IRKbl5TN6mCYYZMOUBmObP3RjtLZGr7195KTmP9hH9W0LDnjNEAYfLDYU0056Yn/imCP8uFG9qE5A1KP0E5trrbxAWTUYq70oRw7ftVWcdJbrdhQYf9FesrQZylFRd8slwHylE8RsQVnmWL3dWGOWjjwtw37duEGaq7PLjfV5c8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604466527; 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=rcR22V11VaSxRGTj44Apo/6OVNtdiu3pQdLqlX7HYbs=; b=JmRG7N0/wgbkhukdgK7uFApE9Phj4kjWKo55dGkGVhP8lu5Kq7WnXsA0wUP6l8rdxbY1bG0gETZM5rThFHguxAkrWX5B/IFee0D1CdhoWjoOHRcWtoShBMfUftTvQ0YvAooXBB1ib4mKvJo2IMQcqn6G0iUvvLLhHeDv5T/7ZSM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604466527472173.18863543799864; Tue, 3 Nov 2020 21:08:47 -0800 (PST) Received: from localhost ([::1]:37440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaB2M-0005fD-AK for importer@patchew.org; Wed, 04 Nov 2020 00:08:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAma-0007kH-R6 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51070) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAmZ-0004v1-3f for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:52:28 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-539-dN0zGeWMPsOrBADlENQ72g-1; Tue, 03 Nov 2020 23:52:23 -0500 Received: by mail-wr1-f71.google.com with SMTP id p12so1215928wrx.3 for ; Tue, 03 Nov 2020 20:52:22 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id p1sm879970wrx.3.2020.11.03.20.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:52:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465546; 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=rcR22V11VaSxRGTj44Apo/6OVNtdiu3pQdLqlX7HYbs=; b=En01eaT3z5Zv7n3otIT4aGMzteqrIbLJ4naSpEpD+PVRHDlU3JaXd9MwFsKI2cVLzg5xyD tPVibpcmbUyikagnc2XPBvvBbkCO6HKsGt0/boHixaz47fnwuP8XPE8c4bau6W+uWOpAZr rzY6LHgGovOrrr7iZc6uv/WuojGF3MI= X-MC-Unique: dN0zGeWMPsOrBADlENQ72g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rcR22V11VaSxRGTj44Apo/6OVNtdiu3pQdLqlX7HYbs=; b=Kz0sW+2Y4qI6tlVWeYx19QyHXEc4PuljzsHxex8g9P3+7xJabqjFFuqFvBN4OPKLEU e4dlPbQHtKTjOLEdLFFN1NrB9zKc1QcFunOuKc5wm6ZdVDoTjlw5jqtjEhYbCAPYKvoF lTQaQ15eJPH0BN+LXpmGz7y21QridOFFW9hHwvVhvFbiNGKtPAeKdeGg89NcZzx5Laii +Hib0VigG9naFZRTfyeOh/xKWHep7Y/q4WQcxz7RkPOE3DZQtJdsU2hq3GW2o/mTjCpo So4/xCokZupLFW39hmFgaeLRly0C0/vnci4FVQ9N3MMVkNgDWoT9wM0lmnYmK3aNNkXv 6TBA== X-Gm-Message-State: AOAM530dzDVn17GLnh/dxBTEPQEpWI9yG2+9X78vweRxqlLfE77H3gZv R8nebIWtHdHHC7D8E43sydWKWCA5VDb4joUzpdBs/Xhodwn0PYERhPNySnP6rjAtHUUj5mQ9n+c SB+llWv/EV7imoCA= X-Received: by 2002:a1c:bbc4:: with SMTP id l187mr2552462wmf.133.1604465541423; Tue, 03 Nov 2020 20:52:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJz89FKgDJwjyNCQmCPJ8zep1yVsW+cpIsvuaKHETRIKiCLdr/PV7W6QMceflPMxg0b6QN6VOw== X-Received: by 2002:a1c:bbc4:: with SMTP id l187mr2552442wmf.133.1604465541239; Tue, 03 Nov 2020 20:52:21 -0800 (PST) Date: Tue, 3 Nov 2020 23:52:19 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 36/38] vhost-user-blk-test: close fork child file descriptors Message-ID: <20201104044937.226370-37-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Do not leave stdin, stdout, stderr open after fork. stdout is the tap-driver.pl pipe. If we keep the pipe open then tap-driver.pl will not detect that qos-test has terminated and it will hang. Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-11-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/vhost-user-blk-test.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index f05f14c192..15daf8ccbc 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -749,6 +749,17 @@ static char *start_vhost_user_blk(GString *cmd_line, i= nt vus_instances, storage_daemon_command->str); pid_t pid =3D fork(); if (pid =3D=3D 0) { + /* + * Close standard file descriptors so tap-driver.pl pipe detects w= hen + * our parent terminates. + */ + close(0); + close(1); + close(2); + open("/dev/null", O_RDONLY); + open("/dev/null", O_WRONLY); + open("/dev/null", O_WRONLY); + execlp("/bin/sh", "sh", "-c", storage_daemon_command->str, NULL); exit(1); } --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604467262; cv=none; d=zohomail.com; s=zohoarc; b=HBcYufs5YTqXuPBKFFmGd6d4lbykYJDOQ9iKSyeDoqHJyT/ZWzQzm4NX4XTE4tkv8saNeEUNbufIrgWa9PwB+CcmiEbT9SxakNTNSt9sd/01cQb+1zphNyEIUxwiwakaoUmHxsv5szu2PmONHMCsumWjFocryDLQzXwhBP585ZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604467262; 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=L0BE6BIYyp008EuFnEKAYjzMhrYRUbO0ZaRk54gDh4k=; b=X8gfy5DFJUfe1icOzU2Vkqc41W1+ye7lkXVf8uj4JD4Ym8yK423KDbVDpWmFqHdzlmT8OOcBYMsLI75zZihMQvKFHsK98CReQ8EFziYuNvWiKXuQ4tx1p3VrSkCxRQfaWoN6tHrgbAQEpafclaetvKr8BKtelc+mHYFXquueM4Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604467262503937.5152065114535; Tue, 3 Nov 2020 21:21:02 -0800 (PST) Received: from localhost ([::1]:47924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaBED-0004qW-AJ for importer@patchew.org; Wed, 04 Nov 2020 00:21:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaBDQ-0004KN-Bw for qemu-devel@nongnu.org; Wed, 04 Nov 2020 00:20:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:26644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaBDM-0005WF-Et for qemu-devel@nongnu.org; Wed, 04 Nov 2020 00:20:11 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-152-Zb6wPDRtNnyw6gHOrMBcBQ-1; Tue, 03 Nov 2020 23:52:25 -0500 Received: by mail-wm1-f72.google.com with SMTP id u207so736206wmu.4 for ; Tue, 03 Nov 2020 20:52:25 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id k84sm788877wmf.42.2020.11.03.20.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:52:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604467206; 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=L0BE6BIYyp008EuFnEKAYjzMhrYRUbO0ZaRk54gDh4k=; b=Jbn+muaTxzbnttX/jjKyVBjGO1YKf9wDRt4ai2WDUojCOTyQxNy9XtHODPoUpAyis/ODit 14l7BRn0EDgj+qhcSHyMFyrnJObDgcae9bYfkvSaY/AbT4ImhxHYukY2L0rgywaYDpXPfB jOktCxBkvJ7Ah7hkcQneDjfAkReyED8= X-MC-Unique: Zb6wPDRtNnyw6gHOrMBcBQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=L0BE6BIYyp008EuFnEKAYjzMhrYRUbO0ZaRk54gDh4k=; b=aDgWmiOVlTQsLvQAW9LwdzOw/fesxJ7Lh1UE+XV0A3udhPWqRYkjMsBErPJu5P/Hg0 p6g9B0K6QOBd8N5uIMZUdRyR/dvsyX0fY/rWzmDXJFJ2ZU2Pt886eHYigwe+Bz5mNqIU XX67pp3ILDvOOb9Zcwm7HXwc9NB9ImQoNCTV6gT6eH7AGvDLWCcAMtJTJIhlrsqnRF+v 3/VDYxe8LUNTgAwwLJq569qAocc7UEnSE6v6n35kcR56htY9kGO0iug0RdI/z5Nrlreq ZeA41NWcHOf/n5S04AbmfxOdx17c2JpwpFsf2sjPt87/qgnaamzd59GO9P+RBZisKg2A Zu/g== X-Gm-Message-State: AOAM530MNo0/uQWhMXhTfJBJXJqtI1qZ3QV9Qht51/sWHK/r4BxXgRmE n/bU7qPIfgt5VuDsC8RSzv7P5YE7S9AD0aOfv0MKV0wO5bXGXNO8YF+JbnPy7WbDLamIaDWxzmi KIMibixJXhB0SudU= X-Received: by 2002:a1c:9d02:: with SMTP id g2mr2528558wme.110.1604465543959; Tue, 03 Nov 2020 20:52:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwhmU74D82hWVAzg9XgrQQten6rOcQY6AV4flH6GhEmS7ZeopL7z2nIx7/5SCkjQxL2bYFaww== X-Received: by 2002:a1c:9d02:: with SMTP id g2mr2528551wme.110.1604465543839; Tue, 03 Nov 2020 20:52:23 -0800 (PST) Date: Tue, 3 Nov 2020 23:52:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 37/38] vhost-user-blk-test: drop unused return value Message-ID: <20201104044937.226370-38-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi The sock_path return value was unused and bogus (it doesn't make sense when there are multiple drives because only the last path is arbitrarily returned). Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-12-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/vhost-user-blk-test.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index 15daf8ccbc..0d056cc189 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -705,8 +705,8 @@ static void quit_storage_daemon(void *qmp_test_state) g_free(qmp_test_state); } =20 -static char *start_vhost_user_blk(GString *cmd_line, int vus_instances, - int num_queues) +static void start_vhost_user_blk(GString *cmd_line, int vus_instances, + int num_queues) { const char *vhost_user_blk_bin =3D qtest_qemu_storage_daemon_binary(); int fd, qmp_fd, i; @@ -774,7 +774,6 @@ static char *start_vhost_user_blk(GString *cmd_line, in= t vus_instances, g_test_queue_destroy(quit_storage_daemon, qmp_test_state); =20 qobject_unref(qtest_qmp(qmp_test_state, "{'execute': 'qmp_capabilities= '}")); - return sock_path; } =20 static void *vhost_user_blk_test_setup(GString *cmd_line, void *arg) --=20 MST From nobody Fri May 17 02:03:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604465892; cv=none; d=zohomail.com; s=zohoarc; b=KzXiabAeJPv3unR8Lbw6fLi7vnQHQAbGlMn8ksvy4dn9+ZZYOdjM5xX29Ohv8v4X6fShA6o38hicRXiI/PtpcQ+64y+oURW03wKea34ShgmtA8g5aSNi3H/Md+kiXlyuDk5RkCJaE7uM+/IrOiAX1IvztoVXB4/uE/V4gayGIok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604465892; 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=vTElEagYE/6ac5+wAhrYnP4rDr3IItx6R4ENpWim+c0=; b=gAHzfrYLC+3vGX9Ie/iAxOEdenlg/sikmMH9s8PSzcJMWkAIKz0TWQSLDZSLU3uTzYd37RyzEe+TAu5cmYTbJ4m9oqZfDhkU4zcz4fjUkmQez449V9U1P8oI+Q4zzfIm4D31IMMOvCnshD7P5NvcEzGyMuu2ylH1g9NdMGmap/E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604465892445113.54034988424132; Tue, 3 Nov 2020 20:58:12 -0800 (PST) Received: from localhost ([::1]:57218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaAs7-0007PY-A6 for importer@patchew.org; Tue, 03 Nov 2020 23:58:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaAnG-00013J-IV for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:53:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53577) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaAnE-00059T-IU for qemu-devel@nongnu.org; Tue, 03 Nov 2020 23:53:10 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-184-73DlCkPuOiCrp7xYZALQ_w-1; Tue, 03 Nov 2020 23:52:28 -0500 Received: by mail-wr1-f72.google.com with SMTP id 31so8705010wrg.12 for ; Tue, 03 Nov 2020 20:52:27 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id v8sm830659wmg.28.2020.11.03.20.52.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 20:52:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604465588; 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=vTElEagYE/6ac5+wAhrYnP4rDr3IItx6R4ENpWim+c0=; b=BVel3+qcD8bGABB76IKiia+1oS9ud82v/aWjJLavovEkcFg+Z+sSXt32OR76M64OWQSFrO IMx6HXDkIJaN8UwktL8rnhE4U+ccJX6sOtu+akg+YjTnqme6q1xTJYQfYsRZlDYAjsJ/TC QZFBRfMqo0Z5dtMCuUzaUYf8rP0Z7Hs= X-MC-Unique: 73DlCkPuOiCrp7xYZALQ_w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=vTElEagYE/6ac5+wAhrYnP4rDr3IItx6R4ENpWim+c0=; b=QD+NzqknctZj5/tfyC5xGQlPnpq/+rfGkq1Fx+IJk1sEQdzECW09O4UZ0l1o4O35ZG K+jewIFSj58RUTM8Y1vuDjKY7f3uYk0A2yueYxCUl41IvQluiiwYWWD8B4cBiH/1izcA DU/15TN5BD6NSDi5UBpPCBrwqGupO/GumcIyR8i2AHtbrO6nXvC/XiLZueOFKbNRDGc0 8SYAwdjYrL5To5/aqhDMOkfwbjDyz3RgRhChTFuvZ0jKwtdB3BTCQxOahBG9DaMF3ASx EiZ5m8p3ueTJ0uzdXGDhH2eZO9o8Vgz4MDaXMRMYhOXDh1pgyOVU8N6zNccdW5OH5BNP nBlA== X-Gm-Message-State: AOAM532vWNKuUGBb2FFLx/ViBrdG/pNAApIthDZQLJn1AStkTgn3M4y+ Xm0S6zBPKGwaffNBGECz68pOupx/Dj85sPkraeioBg1zGZ7q1KpXVy/CBXuP1//tdVfJKoSFjwv qqZB6gkxJ/Rq3ZLM= X-Received: by 2002:a1c:9e12:: with SMTP id h18mr2416221wme.11.1604465546652; Tue, 03 Nov 2020 20:52:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyB5fJrYJcvdt2gVZYrFdnFKns8iyxs/fmgC7mXHBu7gSHzpe+xqaLyJNwwuulO3JRUyY526A== X-Received: by 2002:a1c:9e12:: with SMTP id h18mr2416203wme.11.1604465546492; Tue, 03 Nov 2020 20:52:26 -0800 (PST) Date: Tue, 3 Nov 2020 23:52:24 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 38/38] vhost-user-blk-test: fix races by using fd passing Message-ID: <20201104044937.226370-39-mst@redhat.com> References: <20201104044937.226370-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104044937.226370-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Pass the QMP and vhost-user-blk server sockets as file descriptors. That way the sockets are already open and in a listen state when the QEMU process is launched. This solves the race with qemu-storage-daemon startup where the UNIX domain sockets may not be ready yet when QEMU attempts to connect. It also saves us sleeping for 1 second if the qemu-storage-daemon QMP socket is not ready yet. Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-13-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/vhost-user-blk-test.c | 42 +++++++++++++++++++------------ 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index 0d056cc189..9589f90b14 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -683,8 +683,22 @@ static char *drive_create(void) return t_path; } =20 -static char sock_path_tempate[] =3D "/tmp/qtest.vhost_user_blk.XXXXXX"; -static char qmp_sock_path_tempate[] =3D "/tmp/qtest.vhost_user_blk.qmp.XXX= XXX"; +static char *create_listen_socket(int *fd) +{ + int tmp_fd; + char *path; + + /* No race because our pid makes the path unique */ + path =3D g_strdup_printf("/tmp/qtest-%d-sock.XXXXXX", getpid()); + tmp_fd =3D mkstemp(path); + g_assert_cmpint(tmp_fd, >=3D, 0); + close(tmp_fd); + unlink(path); + + *fd =3D qtest_socket_server(path); + g_test_queue_destroy(destroy_file, path); + return path; +} =20 static void quit_storage_daemon(void *qmp_test_state) { @@ -709,37 +723,33 @@ static void start_vhost_user_blk(GString *cmd_line, i= nt vus_instances, int num_queues) { const char *vhost_user_blk_bin =3D qtest_qemu_storage_daemon_binary(); - int fd, qmp_fd, i; + int qmp_fd, i; QTestState *qmp_test_state; gchar *img_path; - char *sock_path =3D NULL; - char *qmp_sock_path =3D g_strdup(qmp_sock_path_tempate); + char *qmp_sock_path; GString *storage_daemon_command =3D g_string_new(NULL); =20 - qmp_fd =3D mkstemp(qmp_sock_path); - g_assert_cmpint(qmp_fd, >=3D, 0); - g_test_queue_destroy(destroy_file, qmp_sock_path); + qmp_sock_path =3D create_listen_socket(&qmp_fd); =20 g_string_append_printf(storage_daemon_command, "exec %s " - "--chardev socket,id=3Dqmp,path=3D%s,server,nowait --monitor c= hardev=3Dqmp ", - vhost_user_blk_bin, qmp_sock_path); + "--chardev socket,id=3Dqmp,fd=3D%d,server,nowait --monitor cha= rdev=3Dqmp ", + vhost_user_blk_bin, qmp_fd); =20 g_string_append_printf(cmd_line, " -object memory-backend-memfd,id=3Dmem,size=3D256M,share=3Don= -M memory-backend=3Dmem "); =20 for (i =3D 0; i < vus_instances; i++) { - sock_path =3D g_strdup(sock_path_tempate); - fd =3D mkstemp(sock_path); - g_assert_cmpint(fd, >=3D, 0); - g_test_queue_destroy(drive_file, sock_path); + int fd; + char *sock_path =3D create_listen_socket(&fd); + /* create image file */ img_path =3D drive_create(); g_string_append_printf(storage_daemon_command, "--blockdev driver=3Dfile,node-name=3Ddisk%d,filename=3D%s " - "--export type=3Dvhost-user-blk,id=3Ddisk%d,addr.type=3Dunix,a= ddr.path=3D%s," + "--export type=3Dvhost-user-blk,id=3Ddisk%d,addr.type=3Dfd,add= r.str=3D%d," "node-name=3Ddisk%i,writable=3Don,num-queues=3D%d ", - i, img_path, i, sock_path, i, num_queues); + i, img_path, i, fd, i, num_queues); =20 g_string_append_printf(cmd_line, "-chardev socket,id=3Dchar%d,path= =3D%s ", i + 1, sock_path); --=20 MST