From patchwork Fri Oct 30 12:45:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391019 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HYLKmMv+; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2JK4LWyz9sTf for ; Fri, 30 Oct 2020 23:52:01 +1100 (AEDT) Received: from localhost ([::1]:59510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTss-0007gw-Hg for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:51:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTpG-0003dK-MP for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:48:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25202) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTpE-0001Wb-Nz for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:48:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604062092; 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=zjLk5rYnsVamvL3ZAKIsdxK/c57DAaLzJqbsx6rIiu4=; b=HYLKmMv+c5DFFheqOfkJR0dKpChvtnxBnNKzQd4p5+/GoWCAlhf6QdlCV3VfRc+FhsibXq 3MZufwoiJUkdFyfV+6GWjx1NGlePcP+80I7DmAje/QGJC3NS4hrd4lCIyMob2AhIAn7jAb 76IYNamqqfcFpJnDoj9l8tRxtd6jCI8= 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-458-y7wG7fAOMaKx_wRogQbqBQ-1; Fri, 30 Oct 2020 08:45:10 -0400 X-MC-Unique: y7wG7fAOMaKx_wRogQbqBQ-1 Received: by mail-wr1-f69.google.com with SMTP id v5so2641026wrr.0 for ; Fri, 30 Oct 2020 05:45:09 -0700 (PDT) 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=zjLk5rYnsVamvL3ZAKIsdxK/c57DAaLzJqbsx6rIiu4=; b=X/dNbtqIGnuuuuqU7vTQe7RNeS6qVmcKlk84urr5kcS5BVSuNUZEutHmUNp9bT+CcT 1kyDkVI9hCRfZGwet5DQvhl5rYh7uM7Vo4nAOAhqxXbKbS4bqIcCKZ4mrbOt9Pt9HbF3 ucB9FBhw5B5N3kIxgX9xB7BVWGuAEGZanOqbg0XDDDyGcXPgYSNqGAOxobs5U2h9Ui1U i3Z3DjJdF6VIyLyqs7J8v+XjwKs4xlpZ8AF/BWU6MYpZwZWiq1FNbEUokdQay4Z2L94Z 5ckCpeiZp1Qq8FVirmXCvWM/Mr1+qeaCfeTaha4p4/3n+3P9YrzESF47/48eKxiqA5hK xHZA== X-Gm-Message-State: AOAM5320dpIk1uJ+6lCU6NJ/KhKMKBJeRwq1VMQq4vUVu/34+1cxcLHx BxXMZHEB8NWlIarFtHI5J8kY3UOQOh+p9h9HfhHEfaYwU1ho8KWIJvDLOTWVtbji32XdHavc422 Mcq+y4G6Pihk49OE= X-Received: by 2002:adf:f2c9:: with SMTP id d9mr2902165wrp.319.1604061908635; Fri, 30 Oct 2020 05:45:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhdldf1PLZKGFqfxKTtjrj7dHkgJ7RFpuFpMRrruoYxFrON9PQYYu+iiDQZDJ+XLz7Jr68ig== X-Received: by 2002:adf:f2c9:: with SMTP id d9mr2902143wrp.319.1604061908469; Fri, 30 Oct 2020 05:45:08 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id a199sm4901495wmd.8.2020.10.30.05.45.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:07 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:06 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 01/15] vhost-vdpa: negotiate VIRTIO_NET_F_STATUS with driver Message-ID: <20201030124454.854286-2-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 02:24:40 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: Si-Wei Liu , Peter Maydell , Jason Wang Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Si-Wei Liu Vendor driver may not support or implement config interrupt delivery for link status notifications. In this event, vendor driver is expected to NACK the feature, but guest will keep link always up. Signed-off-by: Si-Wei Liu Message-Id: <1601582985-14944-1-git-send-email-si-wei.liu@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index e2b3ba85bf..99c476db8c 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -55,6 +55,7 @@ const int vdpa_feature_bits[] = { VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, VIRTIO_NET_F_GUEST_ANNOUNCE, + VIRTIO_NET_F_STATUS, VHOST_INVALID_FEATURE_BIT }; From patchwork Fri Oct 30 12:45:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391011 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ekf0EsxG; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2B20W7Yz9sTR for ; Fri, 30 Oct 2020 23:46:34 +1100 (AEDT) Received: from localhost ([::1]:42414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTnb-0000ST-Tr for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:46:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTmR-0000Ra-8T for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38823) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTmO-0000OB-3p for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604061914; 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=3iN6qY5085FKhuB3oQvig3p5w7EA9qYLRFEmWUtLf20=; b=Ekf0EsxGC+CF945+FzV7sQYPjnqFTTvTdUFlRfWFespjWOBVIaYCSOI9us39nvMXrCjIl9 LBWQMBvPGGMFg5kB1mdJXc6bLO3YIJg9BdTFZyovAuNmN2K0NZ/UBzLtkNEU6hfAIVkRyz zfr+wqxXdJH3FNhbqsHNZuxcwt7bcpc= 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-411-Hs-yZCXAOdSozU6uimPVtQ-1; Fri, 30 Oct 2020 08:45:12 -0400 X-MC-Unique: Hs-yZCXAOdSozU6uimPVtQ-1 Received: by mail-wm1-f69.google.com with SMTP id r19so1191234wmh.9 for ; Fri, 30 Oct 2020 05:45:12 -0700 (PDT) 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=3iN6qY5085FKhuB3oQvig3p5w7EA9qYLRFEmWUtLf20=; b=hi2aj6NX0L4zK6l/EtKXONPaGe4vvHL1B9FPMNPoGMauMdY2L4AtFJn2SeqH52vWUn PwSVGLFWRwpApDPZ26QSmp3zw8gSTmL38sEve0sC9JCpVMtNH02ePVAonjtFFHSXXrBO RG3RFeLxcPtHCYN6LlC1hkXWVFqnSU038Q46At4Z5m6VFSvFvDhsK8s2fR5EozhGIeTm WTiSwEpAkY0C5NswktBsqfvpEIQ6sn91bFVQB94Sx2DpwAnA9xlL3M+CnSQ21ba70Nd7 l4wa7zGzyOFzQQ99lydnzPvruT889JHB3LEgVtFCfgV0iXGKyhbaqsUkEM5Bq+Yr+ttV AkVg== X-Gm-Message-State: AOAM532Pv3rnltdcSejOV5NE8UIScrLCMxzr31fxny24Wy0WXppCEyXE 3Iy4XZHo9Nr6Zima6zYaZg+bFKuaCjc8YJdsbcHePftcZ+3SkEtLqsVYjaxnXz4GmNnnCJC6QFT t7o1ZCgXOzVj1BuY= X-Received: by 2002:adf:8b92:: with SMTP id o18mr3048477wra.54.1604061910839; Fri, 30 Oct 2020 05:45:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwG9Rt9d5JmobisJu8EXZDZM6LJOjVNOERpPm9s5cAXkQovbKn8RTzxUxYTit4SfhofXr/lzQ== X-Received: by 2002:adf:8b92:: with SMTP id o18mr3048457wra.54.1604061910668; Fri, 30 Oct 2020 05:45:10 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id h128sm4679767wme.38.2020.10.30.05.45.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:10 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 02/15] vhost-vsock: set vhostfd to non-blocking mode Message-ID: <20201030124454.854286-3-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 02:24:40 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 , Stefano Garzarella Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefano Garzarella vhost IOTLB API uses read()/write() to exchange iotlb messages with the kernel module. The QEMU implementation expects a non-blocking fd, indeed commit c471ad0e9b ("vhost_net: device IOTLB support") set it for vhost-net. Without this patch, if we enable iommu for the vhost-vsock device, QEMU can hang when exchanging IOTLB messages. As commit 894022e616 ("net: check if the file descriptor is valid before using it") did for tap, let's use qemu_try_set_nonblock() when fd is provided by the user. Signed-off-by: Stefano Garzarella Message-Id: <20201029144849.70958-1-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vsock.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index f9db4beb47..8ddfb9abfe 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -16,6 +16,7 @@ #include "qapi/error.h" #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" +#include "qemu/sockets.h" #include "hw/qdev-properties.h" #include "hw/virtio/vhost-vsock.h" #include "monitor/monitor.h" @@ -148,6 +149,13 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp) error_prepend(errp, "vhost-vsock: unable to parse vhostfd: "); return; } + + ret = qemu_try_set_nonblock(vhostfd); + if (ret < 0) { + error_setg_errno(errp, -ret, + "vhost-vsock: unable to set non-blocking mode"); + return; + } } else { vhostfd = open("/dev/vhost-vsock", O_RDWR); if (vhostfd < 0) { @@ -155,6 +163,8 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp) "vhost-vsock: failed to open vhost device"); return; } + + qemu_set_nonblock(vhostfd); } vhost_vsock_common_realize(vdev, "vhost-vsock"); From patchwork Fri Oct 30 12:45:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391015 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Wu26BOEq; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2FC14V3z9sTs for ; Fri, 30 Oct 2020 23:49:18 +1100 (AEDT) Received: from localhost ([::1]:50410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTqG-0003u9-LO for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:49:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTmS-0000Rt-AV for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48652) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTmP-0000Rh-Ke for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604061917; 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=smveN6Rzbijww7fMqUTE3pDIKVjvYutAyE50uFiM4wM=; b=Wu26BOEq1hFX+yeQmadOGe5swZADmGF7OcDju5MET+gco5VdB+Rti/PXeWiJjO4RngON5l KlWZOjF1SwC/wGuc2qBI+E1Oe0iyuhf68vpN5joRHuzJWsQkJeHBlgWMdJogmRw8gti7Ms FRIhwrd8Iz5tmOwDgOyIgnqNbvj0xbY= 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-261-ylUlWg9DPLyAIDBNyiozmg-1; Fri, 30 Oct 2020 08:45:14 -0400 X-MC-Unique: ylUlWg9DPLyAIDBNyiozmg-1 Received: by mail-wm1-f69.google.com with SMTP id t21so583338wmt.8 for ; Fri, 30 Oct 2020 05:45:14 -0700 (PDT) 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=smveN6Rzbijww7fMqUTE3pDIKVjvYutAyE50uFiM4wM=; b=OeQTA3D6+LNTN0d8vZmEHMTKto5M0m4r2DmAgF5aRY8DiqlTOjZrzMiJhfCSPEB1pR ZxfBgJXcAcbef60dIsIExCQZSEnd1Gc8Z77S/6ddwA3VTwRt8dOnALY+j7i5xTvkSQzM cYlN9oxsZso9GFOd4/bdRODoGgz3hRDFZrwiWmZ6nwKWFlVBQerav3RV4ivgmqZWdOs2 aUmnY56Mr+1XgojkquCY+p46ERGCyagAs+mzqrCVGd2hakhPBH7+G+a08DoOFrpIaGEV DUOs2XdSNhlmvJ7YoUpIISX6ZYGGx0UOiWNZ1Cz5bk1g/Jq8SocG4A4Ht7nkWsF3HdI6 DOxw== X-Gm-Message-State: AOAM532C14PNT9TXVOg/Czdc3IMcV2JfBaqaMv7pCOI+aNvguoAAb4Y9 Sqg8Wivsur6dkDWotiHhOJnRm97332H73HPfzZliMRmkrDkGmwW5zzksP5OhpPQFTfFPAZ5oWPT c8CzUUCy9+0FKY0c= X-Received: by 2002:a1c:190:: with SMTP id 138mr2348070wmb.113.1604061913431; Fri, 30 Oct 2020 05:45:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUK2Or34hHYTLReg6pGYXi/hTH0MSt7yDxOZBFmolRsJrR1WASsmn2AWTmub0QRS/C609EAw== X-Received: by 2002:a1c:190:: with SMTP id 138mr2348046wmb.113.1604061913179; Fri, 30 Oct 2020 05:45:13 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id p9sm4466695wma.12.2020.10.30.05.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:12 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 03/15] acpi/crs: Prevent bad ranges for host bridges Message-ID: <20201030124454.854286-4-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 02:24:40 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 , Ben Widawsky , Eduardo Habkost , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Ben Widawsky Prevent _CRS resources being quietly chopped off and instead throw an assertion. _CRS is used by host bridges to declare regions of io and/or memory that they consume. On some (all?) platforms the host bridge doesn't have PCI header space and so they need some way to convey the information. Signed-off-by: Ben Widawsky Message-Id: <20201026193924.985014-1-ben.widawsky@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Igor Mammedov --- hw/i386/acpi-build.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index e3a4bc206c..98ff9f5cef 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -866,6 +866,8 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set) crs_range_merge(temp_range_set.mem_ranges); for (i = 0; i < temp_range_set.mem_ranges->len; i++) { entry = g_ptr_array_index(temp_range_set.mem_ranges, i); + assert(entry->limit <= UINT32_MAX && + (entry->limit - entry->base + 1) <= UINT32_MAX); aml_append(crs, aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED, AML_NON_CACHEABLE, From patchwork Fri Oct 30 12:45:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391018 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GWfLjESr; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2Hn5qTKz9sTR for ; Fri, 30 Oct 2020 23:51:33 +1100 (AEDT) Received: from localhost ([::1]:58814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTsR-0007Pv-R3 for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:51:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTmW-0000TD-Jk for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:41137) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTmU-0000Y0-4R for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604061920; 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=LjrL669fVKay5a5661uPNZ920ikHdDz6ECFPczH1Ej8=; b=GWfLjESrWyeaIiNwsO2yp0NfNgsz9e6PKCAX4CCoMxeuLEiFXebxEGTXWs0UYWFX2AECv4 iRTcF8tCX74XSp94QbdWKQHFX0uPKRiFPqn+qG6vs75l1YVoqdfci73cSVVCWwv9Yuao4O FlyPzLMPzf3U42moI9e+HO2/N4JWMwA= 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-582-HW_7GY4TM-64BDBrW7oDSg-1; Fri, 30 Oct 2020 08:45:18 -0400 X-MC-Unique: HW_7GY4TM-64BDBrW7oDSg-1 Received: by mail-wr1-f70.google.com with SMTP id w1so2613722wrr.5 for ; Fri, 30 Oct 2020 05:45:17 -0700 (PDT) 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=LjrL669fVKay5a5661uPNZ920ikHdDz6ECFPczH1Ej8=; b=p1UC/yKirxZWkwwBPeFVswOg4+7rzG7aKAUcmOAFJGpwmyHlwNB5LF2E14aK4p3Gyh Tq2WsBYWzpOWjLRw5ND3uwD/TEc8N3AtT4UveqTvYxnD14CLUEifVIcBdgzeeh2EmZS7 o5pkX2DJ3y2Gyrtz4JYx+DTXJhvcaF686UL/xzShttn/f70W+f6Jv4lyVijgYYMu2MqH LZxfutPfQpwtyjLUD96LobW/TKxFpxMobmUD/f0Okf02gZZYuNtkT78Rvk4mRGjwOvER jpr/A929kP87rKstSDkbKNx0lyZMBVKEYXHZLExABP26L/V6ycUDCzp2kRjDIo6Zuvs3 y9zg== X-Gm-Message-State: AOAM5339lRBzDokwtEwC2KnQGzphW61orTqMWr4+Qw5GhvdjinMatke4 YkRzTp3SDJYUoqAm1JAVD3NyEfK+1clRnxYO0f1Mp8zZIMLas+1K8F0bkVtCUgAM6J44QXbkoX9 gCtdyt4OiD+4pRMM= X-Received: by 2002:a1c:5545:: with SMTP id j66mr2578812wmb.31.1604061915888; Fri, 30 Oct 2020 05:45:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9qlYBhg8YsvJxKm3VZiyiGOpIGpwHAaxWGhiM2LOLgxqWRSuMS0m/iR3yujXtYMPInGgRPQ== X-Received: by 2002:a1c:5545:: with SMTP id j66mr2578783wmb.31.1604061915671; Fri, 30 Oct 2020 05:45:15 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id i33sm10833100wri.79.2020.10.30.05.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:15 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 04/15] acpi/crs: Support ranges > 32b for hosts Message-ID: <20201030124454.854286-5-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=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/10/30 01:22:25 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 , Ben Widawsky , Eduardo Habkost , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Ben Widawsky According to PCIe spec 5.0 Type 1 header space Base Address Registers are defined by 7.5.1.2.1 Base Address Registers (same as Type 0). The _CRS region should allow for the same range (up to 64b). Prior to this change, any host bridge utilizing more than 32b for the BAR would have the address truncated and likely lead to conflicts when the operating systems reads the _CRS object. Signed-off-by: Ben Widawsky Message-Id: <20201026193924.985014-2-ben.widawsky@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- hw/i386/acpi-build.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 98ff9f5cef..4f66642d88 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -786,8 +786,14 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set) crs_range_insert(temp_range_set.io_ranges, range_base, range_limit); } else { /* "memory" */ - crs_range_insert(temp_range_set.mem_ranges, - range_base, range_limit); + uint64_t length = range_limit - range_base + 1; + if (range_limit <= UINT32_MAX && length <= UINT32_MAX) { + crs_range_insert(temp_range_set.mem_ranges, range_base, + range_limit); + } else { + crs_range_insert(temp_range_set.mem_64bit_ranges, + range_base, range_limit); + } } } From patchwork Fri Oct 30 12:45:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391014 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DbtfP3Pc; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2FB5hJnz9sTq for ; Fri, 30 Oct 2020 23:49:18 +1100 (AEDT) Received: from localhost ([::1]:50306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTqG-0003re-7m for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:49:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTmY-0000VS-1f for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56766) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTmW-0000ZM-5R for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604061921; 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=z+z1Pzm/JUurzVLAFZHFV/vzVTD3l9eIdz7HgpfiM6o=; b=DbtfP3PcDnIS0g4foZfVAmF/XuPZIDHby3/HDXTwmY+YPQAGeAglHpWhDd5Ea0nA2Lgkop XA+z09/JV9dZ0/QCFKu7rnkwHvOWdv7kHCvJiJC/D1VF8InjWzUCCBCKeNhEdwCplDEyKb WrbYZvTC2pLc8Ik8viafhiD/CIPhLqU= 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-142-A84L1iU9MbSXqdFq3q955A-1; Fri, 30 Oct 2020 08:45:19 -0400 X-MC-Unique: A84L1iU9MbSXqdFq3q955A-1 Received: by mail-wr1-f70.google.com with SMTP id j15so2612789wrd.16 for ; Fri, 30 Oct 2020 05:45:19 -0700 (PDT) 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=z+z1Pzm/JUurzVLAFZHFV/vzVTD3l9eIdz7HgpfiM6o=; b=ByLP30mRLSuNqehUGyD1/biClc2IrWRx2aHJfHZ0icAb1ew/YWiQgowhchJH0BX6Xy TNSOtEfEyR9biQ0aV/HIvxOfbKOnUxYptIs2B4MUvDm8WTVrinU4ZR3ujdQftd5ttF0p Jfaz9P5F76uIkN5BDc3irTUDkb5Q52S0JAIOpdziDGm3tTplnG7mPL+WWqoymo4C56Vp QTqXZGG6WubgU4dsF1b4GCsCb4tQeoVzgVoP4bQ4rDNuSCzHsN4tTfIimZASluBkriNO l+v3DYYDvLwq8NYdctXFTagQ9GJRWikJutM+Xoat68nYGNNKxsa9NFl9lS7Krh5E3DtB inUA== X-Gm-Message-State: AOAM530HRCLLj+eBT2sMgKIwBSLNG4g6SxFwt+DTPMhxbpqW0mZyATmu K1QMl+uuxJqE4aOqc42rbQN4vfHbmZbkJyTSuOBXjE4CTEyT02SUGURqJqM+4fsnzEu+YIXo/uM n3znkScaj3Cge9LM= X-Received: by 2002:adf:f10e:: with SMTP id r14mr2783724wro.337.1604061918043; Fri, 30 Oct 2020 05:45:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa4Bglpmk8XSE5mL50swaXXVk7LkktQyXC1wB943GSivsG2JKX0POs0SXtb5blt1JW+jnFbw== X-Received: by 2002:adf:f10e:: with SMTP id r14mr2783705wro.337.1604061917903; Fri, 30 Oct 2020 05:45:17 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id c10sm1960254wrx.13.2020.10.30.05.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:17 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:15 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 05/15] hw/virtio/vhost-vdpa: Fix Coverity CID 1432864 Message-ID: <20201030124454.854286-6-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=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/10/30 01:22:25 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-Dau?= =?utf-8?q?d=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Fix uninitialized value issues reported by Coverity: Field 'msg.reserved' is uninitialized when calling write(). Fixes: a5bd05800f8 ("vhost-vdpa: batch updating IOTLB mappings") Reported-by: Coverity (CID 1432864: UNINIT) Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20201028154004.776760-1-philmd@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vdpa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 4f1039910a..01d2101d09 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -90,7 +90,7 @@ static void vhost_vdpa_listener_begin(MemoryListener *listener) { struct vhost_vdpa *v = container_of(listener, struct vhost_vdpa, listener); struct vhost_dev *dev = v->dev; - struct vhost_msg_v2 msg; + struct vhost_msg_v2 msg = {}; int fd = v->device_fd; if (!(dev->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH))) { @@ -110,7 +110,7 @@ static void vhost_vdpa_listener_commit(MemoryListener *listener) { struct vhost_vdpa *v = container_of(listener, struct vhost_vdpa, listener); struct vhost_dev *dev = v->dev; - struct vhost_msg_v2 msg; + struct vhost_msg_v2 msg = {}; int fd = v->device_fd; if (!(dev->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH))) { From patchwork Fri Oct 30 12:45:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391024 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Mrrf7BSX; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2M3732rz9sTf for ; Fri, 30 Oct 2020 23:54:23 +1100 (AEDT) Received: from localhost ([::1]:38136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTvB-00027n-2X for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:54:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTmY-0000WW-Jn for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36050) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTmW-0000c5-P7 for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604061924; 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=rJH7iZei/FUThhkCklYQGVmfL7OJejtyEbzG9hdsPU0=; b=Mrrf7BSXZkBbLe7k1H0GTp4R6CgRF3oWQs/SsFy56CZGC6hCDgVOHCzQ94uFS/xQF9BAUV fTvNrgfoegr4zn1UTc3jvahcjX4iwnwoXG7Ows+HaYlCxEUepwD3vMrLXjN/K8jweW8gBt zIPrLVxelKT1EPfInjYYAuq1Fm0SRMQ= 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-335-o2RDD5N5N_C6v6AD_mkiBw-1; Fri, 30 Oct 2020 08:45:21 -0400 X-MC-Unique: o2RDD5N5N_C6v6AD_mkiBw-1 Received: by mail-wm1-f69.google.com with SMTP id s25so1198128wmj.7 for ; Fri, 30 Oct 2020 05:45:21 -0700 (PDT) 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=rJH7iZei/FUThhkCklYQGVmfL7OJejtyEbzG9hdsPU0=; b=nblKMgosnTdrtup0cjTs7J3KvkTFnJXUwqxNQp/cdCKBQfrJ47D0x8DoAxK9riQP5s inIrQsuHZ65D7QrbnkTlvBVM4lQdQM0GDmb92RkGpIQFmGjE15yHV1bxnSx7YBFv8fyv NT8+UNe6sDZtXciNFPkH68ogp6o0DOML/CODR9YcUWGjgpvGCWRP+yaw1S9NIlosl26u 3zYLVbPnJrGI4PIdzRX0mjXGwfjlKC1az6+6W4FeA59i58foaIK8KWiPHaHU5QVnLATa K35VfhwL81mTk1cBUEAtbFuzGNDYKe9BGy2zctLU0E2HMU3dK0qW1DLlEvuWPju8KUAn e4sA== X-Gm-Message-State: AOAM532+uGKleCw+JcIdLOWOzS5sJuf0rLGhbR0Zl0la43SFeDZzeq7G rrV12PiLhDsZIk2x2q569GIOzhWLOlGUeENPk8WEkSY0rKRpMfX55Pklny8BCeR5mIU5WO3H483 MzdZ1thHFFkEnjRg= X-Received: by 2002:a1c:9d94:: with SMTP id g142mr2605991wme.66.1604061920273; Fri, 30 Oct 2020 05:45:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRy3wCmSKSHwXqbVM1wWlfuIRoL50WNd4zO8/8TfnQNjcEypmUtoOCZHsGUFI7lovJttc8bw== X-Received: by 2002:a1c:9d94:: with SMTP id g142mr2605972wme.66.1604061920127; Fri, 30 Oct 2020 05:45:20 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id z5sm10530539wrw.87.2020.10.30.05.45.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:19 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:18 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 06/15] hw/pci: Extract pci_bus_change_irq_level() from pci_change_irq_level() Message-ID: <20201030124454.854286-7-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 02:24:40 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 , Mark Cave-Ayland , Philippe =?utf-8?q?Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Extract pci_bus_change_irq_level() from pci_change_irq_level() to make it clearer it operates on the bus. Reported-by: Mark Cave-Ayland Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20201024203900.3619498-2-f4bug@amsat.org> Reviewed-by: Mark Cave-Ayland Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 100c9381c2..081ddcadd1 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -248,6 +248,12 @@ static inline void pci_set_irq_state(PCIDevice *d, int irq_num, int level) d->irq_state |= level << irq_num; } +static void pci_bus_change_irq_level(PCIBus *bus, int irq_num, int change) +{ + bus->irq_count[irq_num] += change; + bus->set_irq(bus->irq_opaque, irq_num, bus->irq_count[irq_num] != 0); +} + static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change) { PCIBus *bus; @@ -258,8 +264,7 @@ static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change) break; pci_dev = bus->parent_dev; } - bus->irq_count[irq_num] += change; - bus->set_irq(bus->irq_opaque, irq_num, bus->irq_count[irq_num] != 0); + pci_bus_change_irq_level(bus, irq_num, change); } int pci_bus_get_irq_level(PCIBus *bus, int irq_num) From patchwork Fri Oct 30 12:45:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391012 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=SNmDLRfh; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2B91ZGjz9sSn for ; Fri, 30 Oct 2020 23:46:41 +1100 (AEDT) Received: from localhost ([::1]:42712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTnj-0000bK-5Q for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:46:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTma-0000Z3-9X for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38809) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTmY-0000eD-I5 for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604061925; 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=B/zT27wrNEHsIn9RPNBpuM2tzqmJYYoAGZySli/obU8=; b=SNmDLRfhcI/9mIAN/dW3pv2og1GGCnIwknyrHmUAbvLGn8Gs94uNcAD/GZXjbRFjF+QuZF BQ0d9G0WLcJITe2UUd5Q3DwhXFRaVVgR0QEH5gLeLB67f5AJes2QZfAHkaR/1+eEOAKlKJ N7CieII13qTliz9rm0ddUNguhrgjOl4= 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-211-p8oNuSqwP32YI3V6yiAn6Q-1; Fri, 30 Oct 2020 08:45:24 -0400 X-MC-Unique: p8oNuSqwP32YI3V6yiAn6Q-1 Received: by mail-wr1-f72.google.com with SMTP id t11so2619051wrv.10 for ; Fri, 30 Oct 2020 05:45:23 -0700 (PDT) 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=B/zT27wrNEHsIn9RPNBpuM2tzqmJYYoAGZySli/obU8=; b=aOB1JVwswe2tt+HC493ChB8sgfhhz4fy45nVYP1hyzPSUyhHyBeVQiIptvGtWZ9tOf HEVPwLa+prpiI0qOQmgNNp3YmpcnjriuHXZKGN4LkljQZ7yVYjXuhSkc1YL/7xU4E/Vl UHq2AHfiPdzxOZqeM2uOK0thLxTGFRA4l1SdiRuX3vXv/VtD6SmB1Wxwh1h6n95Z+PZU 1fW71JCczCQX1HpPk0QxTNX2c++enp55NJwnEk01ERoE0wLEzQ+7gn6YVpd08iUtzdzK +OLSOLpg8i1+/dRHXDbcO8DJT3YhlTdXLs7PIPx8IaIZnlQAX2IW8jaTfQldHXWBk+ST cp6A== X-Gm-Message-State: AOAM530x6WwqFEqFQiKS5e3ANo/VZGEFcMSNqupE+4lCwT37GQjxkVnD tXnzFLHtE/XuSXKeNbk7i2cVeBewrLmz03/vBq1TeWKysF+/8ROBbLMsoOYeSDlVpmbi7aUDNEB qGKY17w9cQ4QYkC0= X-Received: by 2002:a5d:4b12:: with SMTP id v18mr2882661wrq.259.1604061922520; Fri, 30 Oct 2020 05:45:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWpB2dIplVbLMFmPo22CKqNaAudJKkIqAfJ4iUVHWvHAYKi5BTxYxtrGhHTv1hI0sEMBf1IA== X-Received: by 2002:a5d:4b12:: with SMTP id v18mr2882644wrq.259.1604061922375; Fri, 30 Oct 2020 05:45:22 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id g8sm4597291wma.36.2020.10.30.05.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:21 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:20 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 07/15] pci: Assert irqnum is between 0 and bus->nirqs in pci_bus_change_irq_level Message-ID: <20201030124454.854286-8-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 02:24:40 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 , Mark Cave-Ayland , Philippe =?utf-8?q?Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland These assertions similar to those in the adjacent pci_bus_get_irq_level() function ensure that irqnum lies within the valid PCI bus IRQ range. Signed-off-by: Mark Cave-Ayland Message-Id: <20201011082022.3016-1-mark.cave-ayland@ilande.co.uk> Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20201024203900.3619498-3-f4bug@amsat.org> Reviewed-by: Mark Cave-Ayland Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 081ddcadd1..dc4019865b 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -250,6 +250,8 @@ static inline void pci_set_irq_state(PCIDevice *d, int irq_num, int level) static void pci_bus_change_irq_level(PCIBus *bus, int irq_num, int change) { + assert(irq_num >= 0); + assert(irq_num < bus->nirq); bus->irq_count[irq_num] += change; bus->set_irq(bus->irq_opaque, irq_num, bus->irq_count[irq_num] != 0); } From patchwork Fri Oct 30 12:45:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391016 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ReHbLg0N; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2FK74Yfz9sTD for ; Fri, 30 Oct 2020 23:49:25 +1100 (AEDT) Received: from localhost ([::1]:51028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTqN-0004Ax-SB for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:49:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTme-0000h2-2d for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51864) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTmc-0000go-4B for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604061929; 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=hB2moo/cmsKV0TlRa+A5mqgcufQ43ovjOtrGZziNS+A=; b=ReHbLg0Np+QA/UfLiSaTYAtXohhZgo78iP3pHI/f4+RR2h7N4XDmD55zcDEV3nN45NfIZ/ kSk70gUP1sniDm7o1XJ5ltVZCg09FsFRpM578BQT8+sMgnB0UvWQ7ZqvjdxkHA79MeWLMH 0rLzdI4gEUNHAKjD4lkJolqELhZYZig= 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-257-Q0WyB51VNzig-L4ApEol2w-1; Fri, 30 Oct 2020 08:45:26 -0400 X-MC-Unique: Q0WyB51VNzig-L4ApEol2w-1 Received: by mail-wm1-f71.google.com with SMTP id z62so1690704wmb.1 for ; Fri, 30 Oct 2020 05:45:26 -0700 (PDT) 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=hB2moo/cmsKV0TlRa+A5mqgcufQ43ovjOtrGZziNS+A=; b=LExirNLQZcePAZ2Ocq0CLUYbOFlK4mQYJ5apAyNSdU//kZ7YQMuxZDQuapz3b9Buqm hLQIQB5V0k5WPgQrolZXN6iyxKkW45kaih/+oGjejiavT7UDKBRQvnNqil4NnJBbRQzM GRhrIJX+lt3zjudw9Ozm39V7aY+r2mX3YDW0l82ajkMI7/zbW+4BCNkHs3AEAuEsiDpt 5p3WVhtttKW8AMg8C8vNwzL5yVIky/C0PpWj3HV4iUHmBg544gLbhgEp3ZTEnJyxHH9L pVNxm3zKJrnfeWZEIyM2YEm65EP+q76oWd3YPZzBfcSoOGPFdCuVYp+XyC9CghkvKEqg zTdg== X-Gm-Message-State: AOAM5307B25eF4t473hXzb7h4OYcIUfS9fOwDuXIZfQDEaxZwnkbkx5z N44g01smLVcFRQ7hLKQJrjXRUv1CXW1TP8NQ+xU6Otp59BiuPlwInz2Un7zb9DQvmQzOaArY++B XP8su2fbvTpm6rA8= X-Received: by 2002:a5d:5048:: with SMTP id h8mr2972027wrt.135.1604061924728; Fri, 30 Oct 2020 05:45:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwTMh2GF97i4m7rEqXRNrKAAlmTlUpZOCxngKuojpJTXhbwvWlgfAoYdGdSMa3JueV1JBPYg== X-Received: by 2002:a5d:5048:: with SMTP id h8mr2972006wrt.135.1604061924563; Fri, 30 Oct 2020 05:45:24 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id e25sm11530300wrc.76.2020.10.30.05.45.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:23 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:22 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 08/15] vhost: Don't special case vq->used_phys in vhost_get_log_size() Message-ID: <20201030124454.854286-9-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 02:24:40 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 , Jason Wang , Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz The first loop in vhost_get_log_size() computes the size of the dirty log bitmap so that it allows to track changes in the entire guest memory, in terms of GPA. When not using a vIOMMU, the address of the vring's used structure, vq->used_phys, is a GPA. It is thus already covered by the first loop. When using a vIOMMU, vq->used_phys is a GIOVA that will be translated to an HVA when the vhost backend needs to update the used structure. It will log the corresponding GPAs into the bitmap but it certainly won't log the GIOVA. So in any case, vq->used_phys shouldn't be explicitly used to size the bitmap. Drop the second loop. This fixes a crash of the source when migrating a guest using in-kernel vhost-net and iommu_platform=on on POWER, because DMA regions are put over 0x800000000000000ULL. The resulting insanely huge log size causes g_malloc0() to abort. BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1879349 Signed-off-by: Greg Kurz Message-Id: <160208823418.29027.15172801181796272300.stgit@bahia.lan> Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 3077fa6ef5..79b2be20df 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -172,16 +172,6 @@ static uint64_t vhost_get_log_size(struct vhost_dev *dev) reg->memory_size); log_size = MAX(log_size, last / VHOST_LOG_CHUNK + 1); } - for (i = 0; i < dev->nvqs; ++i) { - struct vhost_virtqueue *vq = dev->vqs + i; - - if (!vq->used_phys && !vq->used_size) { - continue; - } - - uint64_t last = vq->used_phys + vq->used_size - 1; - log_size = MAX(log_size, last / VHOST_LOG_CHUNK + 1); - } return log_size; } From patchwork Fri Oct 30 12:45:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AADDCT0C; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2PN1bggz9sTq for ; Fri, 30 Oct 2020 23:56:24 +1100 (AEDT) Received: from localhost ([::1]:43054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTx8-0004ET-8X for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:56:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTmf-0000jD-4a for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:55253) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTmd-0000hI-41 for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604061930; 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=et4yufnnD++h3AJk3UX83J9geIWo0Gn07GUHuuNVBW4=; b=AADDCT0Crmze10IqU30Yi9kl28PqfpjIrcXmFupwe5n2vUjMglrnhumzQgnx9kxyAJDPyL jfwC2ebcyu+EVcwvIGVREZEfcXdgeiiO2Cc75a1QIwc5FxhhSRdiYbqb8Dmh3MaaIB/24P 3LfWIr5HAjRzUMwboGQDyILkwMpWUiM= 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-485-_857mqX_OWSQWxySwSR-DQ-1; Fri, 30 Oct 2020 08:45:28 -0400 X-MC-Unique: _857mqX_OWSQWxySwSR-DQ-1 Received: by mail-wr1-f72.google.com with SMTP id m4so2597017wrq.23 for ; Fri, 30 Oct 2020 05:45:28 -0700 (PDT) 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=et4yufnnD++h3AJk3UX83J9geIWo0Gn07GUHuuNVBW4=; b=UTmPWM1JNJabRGM1k2q7sRyxaBzSje30J6e12qVruX1yt2ytTCOmMObuTf/O4ScDwq 1aK4qNfKJzeU9PTKluBzfsWwkvWONCEkFMPwAilKVIG2M5pz1ajvb+eX5Bp1Zw4ChdqN HjVorzwxcKQuXoCsMmaTWJ9CQsq9incyCyvnTM67ZCA2gnMmdx22E1zjW/ahoI74Kngc diCBD0i0lsuz6XGWHunsVeySvelTAorSJ0Ll2f+3MJA3Mlo8MMv7VjO8b5hN7Y+5bwHw XDVzlunr2peR8utIHokllyrHe6m7CuMIM5Eh5M3tUT9JlNnXPY5KMHygxCGJafeVcKum Q6Sg== X-Gm-Message-State: AOAM532nrpybkjOipNhHbiJkVULu40etWB/F3WxNL7PUJiy9BHARi0Sx nHcCvf5wxRJTpJaS5vsYiQbmPQhPq1U7tjKcqhDeksx5Md3/9mXV7AJ3szqEJgZsjju6eWj9Mk1 KIM8kZXBvFJACQGg= X-Received: by 2002:adf:8296:: with SMTP id 22mr2960841wrc.341.1604061927123; Fri, 30 Oct 2020 05:45:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfgIGDgNXwq/bPKsUiZZTo4tRlxIFyTi8HTCOCbqiHNy4DHap84X9Yn0olk3+duD2NuOwDCw== X-Received: by 2002:adf:8296:: with SMTP id 22mr2960810wrc.341.1604061926931; Fri, 30 Oct 2020 05:45:26 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id m8sm10224612wrw.17.2020.10.30.05.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:26 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 09/15] pc: Implement -no-hpet as sugar for -machine hpet=on Message-ID: <20201030124454.854286-10-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 02:24:40 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 , Richard Henderson , Eduardo Habkost , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eduardo Habkost Get rid of yet another global variable. The default will be hpet=on only if CONFIG_HPET=y. Signed-off-by: Eduardo Habkost Message-Id: <20201021144716.1536388-1-ehabkost@redhat.com> Acked-by: Paolo Bonzini Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/pc.h | 1 + include/hw/i386/x86.h | 3 --- hw/i386/pc.c | 63 +++++++++++++++++++++++++++++-------------- hw/i386/pc_piix.c | 2 +- softmmu/vl.c | 4 +-- 5 files changed, 47 insertions(+), 26 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 84639d0ebc..911e460097 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -43,6 +43,7 @@ typedef struct PCMachineState { bool smbus_enabled; bool sata_enabled; bool pit_enabled; + bool hpet_enabled; /* NUMA information: */ uint64_t numa_nodes; diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index bfa9cb2a25..739fac5087 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -126,7 +126,4 @@ qemu_irq x86_allocate_cpu_irq(void); void gsi_handler(void *opaque, int n, int level); void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name); -/* hpet.c */ -extern int no_hpet; - #endif diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 4e323755d0..416fb0e0f6 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1142,28 +1142,31 @@ void pc_basic_device_init(struct PCMachineState *pcms, * Without KVM_CAP_PIT_STATE2, we cannot switch off the in-kernel PIT * when the HPET wants to take over. Thus we have to disable the latter. */ - if (!no_hpet && (!kvm_irqchip_in_kernel() || kvm_has_pit_state2())) { + if (pcms->hpet_enabled && (!kvm_irqchip_in_kernel() || + kvm_has_pit_state2())) { hpet = qdev_try_new(TYPE_HPET); - if (hpet) { - /* 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 = object_property_get_uint(OBJECT(hpet), - HPET_INTCAP, NULL); - if (!compat) { - qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs); - } - sysbus_realize_and_unref(SYS_BUS_DEVICE(hpet), &error_fatal); - sysbus_mmio_map(SYS_BUS_DEVICE(hpet), 0, HPET_BASE); - - for (i = 0; i < GSI_NUM_PINS; i++) { - sysbus_connect_irq(SYS_BUS_DEVICE(hpet), i, gsi[i]); - } - pit_isa_irq = -1; - pit_alt_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT); - rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT); + if (!hpet) { + 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. + */ + uint8_t compat = object_property_get_uint(OBJECT(hpet), + HPET_INTCAP, NULL); + if (!compat) { + qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs); + } + sysbus_realize_and_unref(SYS_BUS_DEVICE(hpet), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(hpet), 0, HPET_BASE); + + for (i = 0; i < GSI_NUM_PINS; i++) { + sysbus_connect_irq(SYS_BUS_DEVICE(hpet), i, gsi[i]); + } + pit_isa_irq = -1; + pit_alt_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT); + rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT); } *rtc_state = mc146818_rtc_init(isa_bus, 2000, rtc_irq); @@ -1535,6 +1538,20 @@ static void pc_machine_set_pit(Object *obj, bool value, Error **errp) pcms->pit_enabled = value; } +static bool pc_machine_get_hpet(Object *obj, Error **errp) +{ + PCMachineState *pcms = PC_MACHINE(obj); + + return pcms->hpet_enabled; +} + +static void pc_machine_set_hpet(Object *obj, bool value, Error **errp) +{ + PCMachineState *pcms = PC_MACHINE(obj); + + pcms->hpet_enabled = value; +} + static void pc_machine_get_max_ram_below_4g(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -1585,6 +1602,9 @@ static void pc_machine_initfn(Object *obj) pcms->smbus_enabled = true; pcms->sata_enabled = true; pcms->pit_enabled = true; +#ifdef CONFIG_HPET + pcms->hpet_enabled = true; +#endif pc_system_flash_create(pcms); pcms->pcspk = isa_new(TYPE_PC_SPEAKER); @@ -1705,6 +1725,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) object_class_property_add_bool(oc, PC_MACHINE_PIT, pc_machine_get_pit, pc_machine_set_pit); + + object_class_property_add_bool(oc, "hpet", + pc_machine_get_hpet, pc_machine_set_hpet); } static const TypeInfo pc_machine_info = { diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 0cf22a57ad..13d1628f13 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -216,7 +216,7 @@ static void pc_init1(MachineState *machine, i440fx_state = NULL; isa_bus = isa_bus_new(NULL, get_system_memory(), system_io, &error_abort); - no_hpet = 1; + pcms->hpet_enabled = false; } isa_bus_irqs(isa_bus, x86ms->gsi); diff --git a/softmmu/vl.c b/softmmu/vl.c index 7c1c6d37ef..a537a0377f 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -146,7 +146,6 @@ static Chardev **serial_hds; Chardev *parallel_hds[MAX_PARALLEL_PORTS]; int win2k_install_hack = 0; int singlestep = 0; -int no_hpet = 0; int fd_bootchk = 1; static int no_reboot; int no_shutdown = 0; @@ -3562,7 +3561,8 @@ void qemu_init(int argc, char **argv, char **envp) qemu_opts_parse_noisily(olist, "acpi=off", false); break; case QEMU_OPTION_no_hpet: - no_hpet = 1; + olist = qemu_find_opts("machine"); + qemu_opts_parse_noisily(olist, "hpet=off", false); break; case QEMU_OPTION_no_reboot: no_reboot = 1; From patchwork Fri Oct 30 12:45:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JOfrw4Yt; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2BG6n5Qz9sSn for ; Fri, 30 Oct 2020 23:46:46 +1100 (AEDT) Received: from localhost ([::1]:43106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTno-0000nL-Q0 for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:46:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTmi-0000kr-OB for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26020) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTmg-0000iE-OX for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604061933; 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=2qvybBCIE1Zjv+mt4qBhgbngIyzXePj4i5BwfD1rO8Y=; b=JOfrw4Ytd2ULEsuRP+uu0DhK6veIvmbOl8P2wQ8W7adOX0B/QBc8VKYoclgU/bDCQloDjf WOITWGkDNyc64l2FewgZmFNQgwkU3wv0KQttUSZiloKzN8afvlW7j2lO375ztXQl8V1whq vTll8yUJjAfjqhRNP1ZSHlz+o95OXXs= 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-197-88jYwgSCPxWsuyK3OEp0Kw-1; Fri, 30 Oct 2020 08:45:30 -0400 X-MC-Unique: 88jYwgSCPxWsuyK3OEp0Kw-1 Received: by mail-wm1-f69.google.com with SMTP id y21so316163wmi.7 for ; Fri, 30 Oct 2020 05:45:30 -0700 (PDT) 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=2qvybBCIE1Zjv+mt4qBhgbngIyzXePj4i5BwfD1rO8Y=; b=Bj64RkgZN7Cd3oFm3WBmtWaTHkvWpyjnLiDE+5Nm3SYvKcsk5tK3whHqwoPQlVGqDs EpOOgME8pwjUr0VXjvvcDmShIeeKG0kyOBEks2KnVwKuOFiG5Zog9VAf98mwSOwLuS/O jGVBzReNV/zuFj5EZhwBEopoDDYp8Qv5SEdGyCIvUwV2w0HUnDBrMNkkmwJchZBNNaEh u4w9p6IZgdUDVDbrPkbQu3b9245h70TOy1mc/GdrmC9fkWV0eNLLXb2j5XNu3a51FJwj 1JQ951ugS0/SJV18/eBIZ9MdK0YnUQ0LCItTP1ea8OJCi3jPRNNBQIJAUyop5TiG/D5l nOoQ== X-Gm-Message-State: AOAM533SAFn7VDTDXJh3qbyp+HII7CxNRzSTBu1mHTyJzdSM8XbtOFgG xn6ENcYFVJJYagoXxLy8huQtzBCydi35ZqiyvFyoe610JxyQCgNwWIUaWJYrIEopN3nntTW+NMu I79l8ZbAA3EJcCDQ= X-Received: by 2002:a1c:4d14:: with SMTP id o20mr2441791wmh.72.1604061929450; Fri, 30 Oct 2020 05:45:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyocOfMUmDYW7MlCrgP8+STQiAso4Njm5zwNXPERdlLOAvy7spFLjdptL6oXGytgo3z8GZM4g== X-Received: by 2002:a1c:4d14:: with SMTP id o20mr2441779wmh.72.1604061929287; Fri, 30 Oct 2020 05:45:29 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id r18sm11477001wrj.50.2020.10.30.05.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:28 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 10/15] pci: advertise a page aligned ATS Message-ID: <20201030124454.854286-11-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 02:24:40 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 , Jason Wang , qemu-stable@nongnu.org, Peter Xu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jason Wang After Linux kernel commit 61363c1474b1 ("iommu/vt-d: Enable ATS only if the device uses page aligned address."), ATS will be only enabled if device advertises a page aligned request. Unfortunately, vhost-net is the only user and we don't advertise the aligned request capability in the past since both vhost IOTLB and address_space_get_iotlb_entry() can support non page aligned request. Though it's not clear that if the above kernel commit makes sense. Let's advertise a page aligned ATS here to make vhost device IOTLB work with Intel IOMMU again. Note that in the future we may extend pcie_ats_init() to accept parameters like queue depth and page alignment. Cc: qemu-stable@nongnu.org Signed-off-by: Jason Wang Message-Id: <20200909081731.24688-1-jasowang@redhat.com> Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pcie.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 5b48bae0f6..d4010cf8f3 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -971,8 +971,9 @@ void pcie_ats_init(PCIDevice *dev, uint16_t offset) dev->exp.ats_cap = offset; - /* Invalidate Queue Depth 0, Page Aligned Request 0 */ - pci_set_word(dev->config + offset + PCI_ATS_CAP, 0); + /* Invalidate Queue Depth 0, Page Aligned Request 1 */ + pci_set_word(dev->config + offset + PCI_ATS_CAP, + PCI_ATS_CAP_PAGE_ALIGNED); /* STU 0, Disabled by default */ pci_set_word(dev->config + offset + PCI_ATS_CTRL, 0); From patchwork Fri Oct 30 12:45:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391017 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GBiDn9QB; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2FS5JHHz9sTq for ; Fri, 30 Oct 2020 23:49:32 +1100 (AEDT) Received: from localhost ([::1]:51554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTqU-0004O8-L8 for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:49:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTmk-0000mp-ET for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29142) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTmi-0000is-By for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604061935; 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=OQbV+eeH0Jal8wQ3qnCI4bc8h7HSMGkH1TuPaMitNA4=; b=GBiDn9QBqPRRJ/Lib6MpD/DlwFA+xydmAjyi5EGrV4Jf7jYaN05j9hN852IFuDuHhEdX6Z ES3LrqQOdG/c5mTR+XK0mF5yp/s9dnKRaa3acdbJ6QOyPkgowVTbIWgdxxnWLZ+JHuGNPB DhtNAv1tYIOX6Cva/J1FWXd3CBj/hOA= 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-59-y0TTm1enMpuOeqckdSNrcA-1; Fri, 30 Oct 2020 08:45:33 -0400 X-MC-Unique: y0TTm1enMpuOeqckdSNrcA-1 Received: by mail-wr1-f69.google.com with SMTP id 2so2625606wrd.14 for ; Fri, 30 Oct 2020 05:45:32 -0700 (PDT) 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=OQbV+eeH0Jal8wQ3qnCI4bc8h7HSMGkH1TuPaMitNA4=; b=HHcf8OMFnLHaZ38sggNOIMNeLP+Z7AmV5Sk49vhvejn7wFe7xrjf6icmgunExpYlSE 8xyAD23QdBk619CL1IPAOXR55eG5oqOvoFclPUdFroQR1U8tHK5ry6zQ6lbXfacR/urN +OsDPM+4+zyRsXeFgZfPDfpgdkIarzuHsI4P7Qv3mHr2ThMBUsCc+4tevyk2qnZyjlSP XTXpsc3gji2aAn5p3TKbowWrcbemej/FhEu/8rNOlCqnQUuregSH2nxh7G2/TRl95de3 gX87w5wGQ1ujpYK9sL3pjwDvlg4iz08lK1GUSHAc1vpgdZ8z0wOnBgXAE3jBUVvXSebD L1/w== X-Gm-Message-State: AOAM532iw9KWc4Hd4A5UiDbQ2ZJZLToNkMfWaaa7m/xPPcLa8eRFYq6u dmFvbgMmQxSQi0ZE153nLFI5louPJozGSHjEwe3y8Dk/vEaYgMtmVcek1Wywcr8o9bnbf20+zAQ 3aGdIIJP0UCCysEc= X-Received: by 2002:adf:fa4e:: with SMTP id y14mr2838921wrr.377.1604061931747; Fri, 30 Oct 2020 05:45:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZmzFpF57+XWqVg8AINqODziGkq6JddLydZIZsQfLOevVkt4QbThXM8uqJ4myB+LYrHm5NIg== X-Received: by 2002:adf:fa4e:: with SMTP id y14mr2838904wrr.377.1604061931601; Fri, 30 Oct 2020 05:45:31 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id j9sm10601842wrp.59.2020.10.30.05.45.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:30 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 11/15] pci: Change error_report to assert(3) Message-ID: <20201030124454.854286-12-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 02:24:40 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 , Ben Widawsky , Philippe =?utf-8?q?Mathieu-Daud?= =?utf-8?q?=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Ben Widawsky Asserts are used for developer bugs. As registering a bar of the wrong size is not something that should be possible for a user to achieve, this is a developer bug. While here, use the more obvious helper function. Signed-off-by: Ben Widawsky Message-Id: <20201015181411.89104-1-ben.widawsky@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé --- hw/pci/pci.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index dc4019865b..e5b7c9a42b 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1151,11 +1151,7 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num, assert(region_num >= 0); assert(region_num < PCI_NUM_REGIONS); - if (size & (size-1)) { - error_report("ERROR: PCI region size must be pow2 " - "type=0x%x, size=0x%"FMT_PCIBUS"", type, size); - exit(1); - } + assert(is_power_of_2(size)); r = &pci_dev->io_regions[region_num]; r->addr = PCI_BAR_UNMAPPED; From patchwork Fri Oct 30 12:45:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391030 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Rj+dZb1c; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2St1hQ5z9sTD for ; Fri, 30 Oct 2020 23:59:25 +1100 (AEDT) Received: from localhost ([::1]:49902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYU03-00076w-Lj for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:59:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTmm-0000nO-1l for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50086) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTmk-0000k2-4F for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604061937; 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=l6Xr3YozF4IKRpFrhD0A/HyzyCVetEbDlqfMsE4vvfI=; b=Rj+dZb1cnyhHVDVA3llTOQmF8EnC7twtBYZc7lWJxlvS6jlYtEYVDF7DwWHoSE1BnHS7D2 vNr8WwObkSBdt2g2sMNms3zAdfa2+D4Px0pPC24q3g05WfJ65zrs4oFx9y07Pvzw5oR+Eg Chi1Rp0mw3hIOqv5DTNwPuanyW38Fl8= 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-121-1gqGr0d4P6apkzAijwHwhg-1; Fri, 30 Oct 2020 08:45:35 -0400 X-MC-Unique: 1gqGr0d4P6apkzAijwHwhg-1 Received: by mail-wr1-f69.google.com with SMTP id q15so2613928wrw.8 for ; Fri, 30 Oct 2020 05:45:35 -0700 (PDT) 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=l6Xr3YozF4IKRpFrhD0A/HyzyCVetEbDlqfMsE4vvfI=; b=ZkSvUGgaJN4dp5UP+leIInkjWnxtqymjRRRneqFLZiswOT+d4q275QQzEzM3TMSBf6 2XJeAYiR7g/hTmJ5PwyMm+seDP6ISsHka6eBJss994pfjnBpcheNLLbnLvfu9b2BKknE Tbc54fg6oFie3r5BtkPjaUEXv6yhg6hr8aAGUkele5R2narTXi1JSSZXDQxYgJ60CvOl UOHiX6xDokeRT59zb1yYL6CnPYP1NSkRupMqEvaXQUa3Vvm6vNciYM407ivUKNIVFtQE ijBjQCCW4/5ulovtlg7JNwhdxATs+JkeFLdKw39SOz762rItXsF+I7mvOieqExf46Xzv gm8w== X-Gm-Message-State: AOAM531/dfOhKxnjukz0qu+ChvKxTC6g3D6v75PJi5ziYA73i+ebQK86 kCfn2qB00qCeTrbTzfilHKwul0pG2rNvk0DWcFdJ1QaGyXAo0+s60U9+wruVVOyntKXmyM/4qJ5 Cv+uRecwAhG8iHRw= X-Received: by 2002:adf:e4c4:: with SMTP id v4mr2908742wrm.79.1604061933960; Fri, 30 Oct 2020 05:45:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKriC5/odzbgXjmhIsEptvw7i0gYvqxcwi6uAUNEO5v+vf374JoW67otf1/m/0BT9BsSXypA== X-Received: by 2002:adf:e4c4:: with SMTP id v4mr2908729wrm.79.1604061933823; Fri, 30 Oct 2020 05:45:33 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id c8sm9682361wrv.26.2020.10.30.05.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:33 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:31 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 12/15] pci: Disallow improper BAR registration for type 1 Message-ID: <20201030124454.854286-13-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 02:24:40 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 , Ben Widawsky Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Ben Widawsky Prevent future developers working on root complexes, root ports, or bridges that also wish to implement a BAR for those, from shooting themselves in the foot. PCI type 1 headers only support 2 base address registers. It is incorrect and difficult to figure out what is wrong with the device when this mistake is made. With this, it is immediate and obvious what has gone wrong. Signed-off-by: Ben Widawsky Message-Id: <20201015181411.89104-2-ben.widawsky@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e5b7c9a42b..0131d9d02c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1148,11 +1148,17 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num, uint32_t addr; /* offset in pci config space */ uint64_t wmask; pcibus_t size = memory_region_size(memory); + uint8_t hdr_type; assert(region_num >= 0); assert(region_num < PCI_NUM_REGIONS); assert(is_power_of_2(size)); + /* A PCI bridge device (with Type 1 header) may only have at most 2 BARs */ + hdr_type = + pci_dev->config[PCI_HEADER_TYPE] & ~PCI_HEADER_TYPE_MULTI_FUNCTION; + assert(hdr_type != PCI_HEADER_TYPE_BRIDGE || region_num < 2); + r = &pci_dev->io_regions[region_num]; r->addr = PCI_BAR_UNMAPPED; r->size = size; From patchwork Fri Oct 30 12:45:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391020 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Z5m4lyxK; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2JK3CHnz9sTR for ; Fri, 30 Oct 2020 23:52:01 +1100 (AEDT) Received: from localhost ([::1]:59420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTss-0007f1-LI for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:51:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTmr-0000rK-0x for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50022) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTmo-0000lF-Sh for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604061941; 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=gHTVvLyQX/nQL7WIpglC+HzeG7xS+O6ap0K+bTpJUHA=; b=Z5m4lyxKUep1aBIR36mcu9iA0HgO0A6N2Nf1FDzrS97mf96OjAgxdG86mjJUvqoxAWtdhL 291qKfz+OWEzPMhnTftFU1uVR17cQ3rFLQmIxQC2Df1rcrLSCD59YVqiJlu+6baFOR34cn i4St789DWidrraxcJnxvMv26GjC5PFQ= 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-63-fRD7MxgeNv-MJNpKi-34cA-1; Fri, 30 Oct 2020 08:45:38 -0400 X-MC-Unique: fRD7MxgeNv-MJNpKi-34cA-1 Received: by mail-wm1-f72.google.com with SMTP id s25so1198358wmj.7 for ; Fri, 30 Oct 2020 05:45:38 -0700 (PDT) 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=gHTVvLyQX/nQL7WIpglC+HzeG7xS+O6ap0K+bTpJUHA=; b=AfU6DcsKI8EFoRXWLlYL4lX8njwA7o5ojyAgHqQQasxaljo8zhpkP3mJTtYKlrc8vV g7l/hF1XkWJT3Ba2BlisqH87xFu9jN8clLYRV45kLPFd/A97WGoKN/T7GdKlwNhbyXlZ DJqaFhiBd4XXyQ+0SKr6AV6UcKdb5oO6SZihkSepHR2o0zbIn8NG3MrkeyeJ7gwvCOql z048bhrNSVsFZ/mDn4O51fZw39xZCJBunGv1oeCvZEBsOx8KskCmWznkd+ArOKtkjV+l hfYQiXoZiGUgKNWrFlb+f0fd+U1gdfrKHkAtAtouTyoW2v2BtKOdGTp+0YbLtJ4Rzmce yu+Q== X-Gm-Message-State: AOAM531sWuYFQ/mOwKypUkeHJH2tx5fKrFtQrMWGccwB/eRcOHcrp3Sr SV3RzFoNf77NoX3gjN7XfX8eSRgIcsANgcruasrt98+eYEoqSdbkC4TgBwjOFbpSfcM8dMqX+C4 vprn9NpuzZtTVlWI= X-Received: by 2002:a1c:4c05:: with SMTP id z5mr2476049wmf.122.1604061936467; Fri, 30 Oct 2020 05:45:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiy/jQLLTwTiDLjbFQgIW6Cx/VKSJbRoWuSY0x49NlHj7PxlqXZXYAZpOd2l4lHDUgn59c0Q== X-Received: by 2002:a1c:4c05:: with SMTP id z5mr2476031wmf.122.1604061936260; Fri, 30 Oct 2020 05:45:36 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id i33sm10834024wri.79.2020.10.30.05.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:35 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 13/15] vhost-blk: set features before setting inflight feature Message-ID: <20201030124454.854286-14-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 02:24:40 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, Jin Yu , Max Reitz , Raphael Norwitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Message-Id: <20200910134851.7817-1-jin.yu@intel.com> Acked-by: Raphael Norwitz 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 insertions(+) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 94585067f7..839bfb153c 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 *inflight); 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 a076b1e54d..f67b29bbf3 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) s->dev.acked_features = vdev->guest_features; + ret = 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 = 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..f2482378c6 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1645,6 +1645,24 @@ int vhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f) return 0; } +int vhost_dev_prepare_inflight(struct vhost_dev *hdev) +{ + int r; + + if (hdev->vhost_ops->vhost_get_inflight_fd == NULL || + hdev->vhost_ops->vhost_set_inflight_fd == NULL) { + return 0; + } + + r = 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) { From patchwork Fri Oct 30 12:45:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391025 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Kj0fbqhM; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2MB25CRz9sTf for ; Fri, 30 Oct 2020 23:54:30 +1100 (AEDT) Received: from localhost ([::1]:38660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTvI-0002L4-31 for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:54:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTmr-0000rV-JX for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34172) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTmp-0000m1-Sv for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604061942; 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=509YkEUpGBV1ErtRUsNd1psMy3xW+1ruB0fSsKITRuw=; b=Kj0fbqhMbrD8KrQg+FFD++cUXlv5uT7Z6BWDQYzkUI/yzsqH0QkwKH/DmK3Oxp9SqqNayi sjzqB588sChaYseAWJ5oat8oWQBs1cP8Xcf+DOFMyo4K/vkAc6Wzcn66exkyxETdgwGjwq AcmpWbvt7MhiEgJwb4VU7wf/J508UNA= 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-305-XDvEhtB3OUGMLzKGcyWpug-1; Fri, 30 Oct 2020 08:45:40 -0400 X-MC-Unique: XDvEhtB3OUGMLzKGcyWpug-1 Received: by mail-wr1-f69.google.com with SMTP id t11so2619292wrv.10 for ; Fri, 30 Oct 2020 05:45:40 -0700 (PDT) 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=509YkEUpGBV1ErtRUsNd1psMy3xW+1ruB0fSsKITRuw=; b=iOyakfwa3XU7T/pWED7Q9EuDcGuOWtEbqIR23XwWYT9Sy/zNSkeIF0QVxfXuI8yonn avfUlRLORCgWWhnYlaEGguDIyaLpXqBxhmuzuOK29MK1cyW19ac8O47vgRYgOf7jTDB6 75pqvgh+UIfpOfG2KBKyc3YNu9YAyegemK2kbImW4VT2aYUhmpKJGl/7h82N8HOjz3gr q1lkBByJ6+vj1yy4cYgy8Z1E2G4mimrBSWgiLhDQfq5xJYPsidTwnf9BjRgWmmjCe54G zdGy/hhgtHeYC5qa0U49RtLwn3Mj3s3esGqqfbQMLYLjoXCd4bHmCb4/rKDzqHYk6CsW sJcg== X-Gm-Message-State: AOAM531p+JnHSiwo5CVo3MDIz/mPlhgbC+4C3quThzZaRukrnyDdbEEt vh1JD5bfY0pnL+dVQCtrqDZ1HBsVs5bI10SpXtjIVlDcX9onTzzT7S7YsR68t8bRwfhci4at6ae 1MOqtwFDFdF27oXU= X-Received: by 2002:adf:f3c7:: with SMTP id g7mr3150539wrp.394.1604061939079; Fri, 30 Oct 2020 05:45:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxW2gRd5skutD/4hjKT7rnhkZQYjgaIPNjN5aQtq2s6a92ZLCTTAzcrIojcPp7UFH1c3rpOAQ== X-Received: by 2002:adf:f3c7:: with SMTP id g7mr3150520wrp.394.1604061938861; Fri, 30 Oct 2020 05:45:38 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id 71sm11021534wrm.20.2020.10.30.05.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:38 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:36 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 14/15] virtio: skip guest index check on device load Message-ID: <20201030124454.854286-15-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 02:24:40 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 , Jason Wang , Felipe Franciosi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Felipe Franciosi QEMU must be careful when loading device state off migration streams to prevent a malicious source from exploiting the emulator. Overdoing these checks has the side effect of allowing a guest to "pin itself" in cloud environments by messing with state which is entirely in its control. Similarly to what f3081539 achieved in usb_device_post_load(), this commit removes such a check from virtio_load(). Worth noting, the result of a load without this check is the same as if a guest enables a VQ with invalid indexes to begin with. That is, the virtual device is set in a broken state (by the datapath handler) and must be reset. Signed-off-by: Felipe Franciosi Message-Id: <20201028134643.110698-1-felipe@nutanix.com> Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 6f8f865aff..ceb58fda6c 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -17,6 +17,7 @@ #include "trace.h" #include "exec/address-spaces.h" #include "qemu/error-report.h" +#include "qemu/log.h" #include "qemu/main-loop.h" #include "qemu/module.h" #include "hw/virtio/virtio.h" @@ -3160,12 +3161,12 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) nheads = vring_avail_idx(&vdev->vq[i]) - vdev->vq[i].last_avail_idx; /* Check it isn't doing strange things with descriptor numbers. */ if (nheads > vdev->vq[i].vring.num) { - error_report("VQ %d size 0x%x Guest index 0x%x " - "inconsistent with Host index 0x%x: delta 0x%x", - i, vdev->vq[i].vring.num, - vring_avail_idx(&vdev->vq[i]), - vdev->vq[i].last_avail_idx, nheads); - return -1; + qemu_log_mask(LOG_GUEST_ERROR, + "VQ %d size 0x%x Guest index 0x%x " + "inconsistent with Host index 0x%x: delta 0x%x", + i, vdev->vq[i].vring.num, + vring_avail_idx(&vdev->vq[i]), + vdev->vq[i].last_avail_idx, nheads); } vdev->vq[i].used_idx = vring_used_idx(&vdev->vq[i]); vdev->vq[i].shadow_avail_idx = vring_avail_idx(&vdev->vq[i]); From patchwork Fri Oct 30 12:45:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1391028 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FMJe4HzM; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CN2PT3YnCz9sTq for ; Fri, 30 Oct 2020 23:56:29 +1100 (AEDT) Received: from localhost ([::1]:43556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYTxD-0004Qz-Eq for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2020 08:56:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYTmw-0000uT-Lu for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53820) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYTmu-0000nE-Rr for qemu-devel@nongnu.org; Fri, 30 Oct 2020 08:45:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604061948; 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=d0O00/al7cwQGWZwwOP6NLGwTcTYmOVWX7BhS/dcA4E=; b=FMJe4HzMamcQyAOVX0xvjt6Wq4vQ6dvT74D9MhrJ1xVkKe9ex9Zc98QRhjNztcf1Z7S3pe 5alu+SwyzJF1PeJpnRqUK5pw13xdSowRcRW0RvDK2Tiv3GbGw1jO1KDEqS7bvos+NBoJSu I8O9G1l7RtUIdGzQ0uofSkwmI+VZUKo= 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-499-aRqpl91VPpGOWU54nm-07A-1; Fri, 30 Oct 2020 08:45:44 -0400 X-MC-Unique: aRqpl91VPpGOWU54nm-07A-1 Received: by mail-wm1-f69.google.com with SMTP id 13so1212263wmf.0 for ; Fri, 30 Oct 2020 05:45:42 -0700 (PDT) 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=d0O00/al7cwQGWZwwOP6NLGwTcTYmOVWX7BhS/dcA4E=; b=o2Zw/zTm31QPReN+yK25e9EgtouhV8tfoFbT0kWmozeii3saPqTqu7pQlTItNG16t3 o1AiAlTOmZYBzRBkSb4e4afpVKKwie+yWjoZ0yEOopkaZxLbKF90ZRNwwXusAKLSejm/ 1r94p8RAKmlERhMmLbS3SbVW0Mdlf+dAkUqtFjnpHTBTI4wksJisbAZKwYFExEAECRoG qOUvvcqKa2wzXVLDzeJV78aceNW7oAV/7nzF/fdGf3DaGyrHKJfK3weOYwAtXFX1VjZe JvjwYzdQgMR/r6nXhh2LN746wWdIqNUqP919GDf+ragZtlXlllhz6K8EkWtLkquyWzZA +s5w== X-Gm-Message-State: AOAM530CSrYAZx01dBtbOBizsmOmVREgrNrUm+PO7qnNjezy+FWivSEF sc8Tu7wwT/oDXh3yP/TSgHmANCUlBdhGuCjGghfqDpSMY7Y7F8Vubg9FzqUT0MGSnAlbmAI4/wG goY98lk1DsgDWeZ0= X-Received: by 2002:adf:de91:: with SMTP id w17mr2903961wrl.84.1604061941794; Fri, 30 Oct 2020 05:45:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyS1eyLrIV2EGFJ+mVITJxSDEJQ+/befsmFugOUGtNYxicEuDDDD8hlFiybicxx7gTJp+HsKg== X-Received: by 2002:adf:de91:: with SMTP id w17mr2903940wrl.84.1604061941600; Fri, 30 Oct 2020 05:45:41 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id u202sm4784660wmu.23.2020.10.30.05.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 05:45:40 -0700 (PDT) Date: Fri, 30 Oct 2020 08:45:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 15/15] intel_iommu: Fix two misuse of "0x%u" prints Message-ID: <20201030124454.854286-16-mst@redhat.com> References: <20201030124454.854286-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201030124454.854286-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/30 02:24:40 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 , Jason Wang , "Dr . David Alan Gilbert" , Peter Xu , Paolo Bonzini , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Xu Dave magically found this. Fix them with "0x%x". Reported-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20201019173922.100270-1-peterx@redhat.com> Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daudé Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 749eb6ad63..70ac837733 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2665,7 +2665,7 @@ static uint64_t vtd_mem_read(void *opaque, hwaddr addr, unsigned size) if (addr + size > DMAR_REG_SIZE) { error_report_once("%s: MMIO over range: addr=0x%" PRIx64 - " size=0x%u", __func__, addr, size); + " size=0x%x", __func__, addr, size); return (uint64_t)-1; } @@ -2716,7 +2716,7 @@ static void vtd_mem_write(void *opaque, hwaddr addr, if (addr + size > DMAR_REG_SIZE) { error_report_once("%s: MMIO over range: addr=0x%" PRIx64 - " size=0x%u", __func__, addr, size); + " size=0x%x", __func__, addr, size); return; }