From patchwork Sun Mar 8 13:31:11 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: 1251032 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=ZbK58jBn; 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 48b2Mc2sLJz9sPF for ; Mon, 9 Mar 2020 00:32:12 +1100 (AEDT) Received: from localhost ([::1]:57928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAw2M-0004eV-AZ for incoming@patchwork.ozlabs.org; Sun, 08 Mar 2020 09:32:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53002) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAw1b-0004bo-FW for qemu-devel@nongnu.org; Sun, 08 Mar 2020 09:31:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jAw1a-0006XG-2Y for qemu-devel@nongnu.org; Sun, 08 Mar 2020 09:31:23 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:48038 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jAw1Z-0006X6-UP for qemu-devel@nongnu.org; Sun, 08 Mar 2020 09:31:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583674281; 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=Y9veurr0bVAUl9SJ9izzgqs6lZHPE6eFmxhhkeZd96o=; b=ZbK58jBnHAzgVf9IX/yTbscPQxUg99mG/kEiPM52ljk/uSg5DDm8mWNWUHnFIS0N4Bqp16 27hJBm/jHc1rRthbVBkm9bQly9AOhnFrSuozdAI1hYKOcp1ynOGmRjPfnGv3jUfxCFXpWH XpmC4ddNqyqqY5eDUj3jUB7Vdn7zems= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-149-AGlfgTvfN4qKceF-Fk637w-1; Sun, 08 Mar 2020 09:31:17 -0400 X-MC-Unique: AGlfgTvfN4qKceF-Fk637w-1 Received: by mail-qt1-f198.google.com with SMTP id s5so4974462qtn.7 for ; Sun, 08 Mar 2020 06:31: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:content-transfer-encoding :in-reply-to; bh=sPR7bFwttTJ4CS+d9j33a/ao0m9kS2OHt9GwMOGXMPM=; b=OyO2lOHYiwpMFyk/dZw2n9bmfWX2N5f/aj0MUeghd1DawIhu+T0Zu7C5f5lueW52Nh UwhYe+no324hBVblzHHpodiofIltp0pW0Yd4msZCSpiBhEVBZivUXTZa0KoyiykoFk8m eo6RCT28pZ62VipxVb0HZNbwBG81angIfT+gOkVJjHvGFsXYcYbEf2UmBfwQogZx5G7m sL1uNAhXDfJaSAlMrUgCd20xWaSM62ONQ5pFSZ4z6883U9p1yfv90H8rO84brZnHSrMZ gA98OdDvJZuQkmLqjgc68x4B6uh39EYNYD+1tp4kbSZ/NedAi2xYe7JzPpiz2MmoyiOB OZdA== X-Gm-Message-State: ANhLgQ3jLv8JVoQIFK2ipdEVUjOHpzBdsRlo28PL5ELXehJznbrXEBHl 1P2Fi6iY6pAwANFH497skaUS+S0JZDp/hBbwKBPyJE6P97C1/y8qCTBmm+Cm50yVVYIfEuc/tgg wqiau1NnnZ7UsiiU= X-Received: by 2002:ac8:76d7:: with SMTP id q23mr10782870qtr.198.1583674276370; Sun, 08 Mar 2020 06:31:16 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuznm5b81Jzfxd8BY4vqRaKYllxwO8yuVLSvSd3wlzyFVBMmFPFdfEjTyy7zdLPmaBAb07prw== X-Received: by 2002:ac8:76d7:: with SMTP id q23mr10782853qtr.198.1583674276108; Sun, 08 Mar 2020 06:31:16 -0700 (PDT) Received: from redhat.com (bzq-79-178-2-19.red.bezeqint.net. [79.178.2.19]) by smtp.gmail.com with ESMTPSA id o35sm5934707qtk.5.2020.03.08.06.31.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Mar 2020 06:31:15 -0700 (PDT) Date: Sun, 8 Mar 2020 09:31:11 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 1/4] pcie_root_port: Add hotplug disabling option Message-ID: <20200308133054.1563705-2-mst@redhat.com> References: <20200308133054.1563705-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200308133054.1563705-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?utf-8?q?J=C3=A1n?= Tomko , Julia Suvorova Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Julia Suvorova Make hot-plug/hot-unplug on PCIe Root Ports optional to allow libvirt manage it and restrict unplug for the whole machine. This is going to prevent user-initiated unplug in guests (Windows mostly). Hotplug is enabled by default. Usage: -device pcie-root-port,hotplug=off,... If you want to disable hot-unplug on some downstream ports of one switch, disable hot-unplug on PCIe Root Port connected to the upstream port as well as on the selected downstream ports. Discussion related: https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg00530.html Signed-off-by: Julia Suvorova Message-Id: <20200226174607.205941-1-jusual@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Ján Tomko --- include/hw/pci/pcie.h | 2 +- include/hw/pci/pcie_port.h | 3 +++ hw/pci-bridge/pcie_root_port.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 2 +- hw/pci/pcie.c | 11 +++++++---- hw/pci/pcie_port.c | 1 + 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 7064875835..14c58ebdb6 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -104,7 +104,7 @@ void pcie_cap_deverr_reset(PCIDevice *dev); void pcie_cap_lnkctl_init(PCIDevice *dev); void pcie_cap_lnkctl_reset(PCIDevice *dev); -void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot); +void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s); void pcie_cap_slot_reset(PCIDevice *dev); void pcie_cap_slot_get(PCIDevice *dev, uint16_t *slt_ctl, uint16_t *slt_sta); void pcie_cap_slot_write_config(PCIDevice *dev, diff --git a/include/hw/pci/pcie_port.h b/include/hw/pci/pcie_port.h index 4b3d254b08..caae57573b 100644 --- a/include/hw/pci/pcie_port.h +++ b/include/hw/pci/pcie_port.h @@ -55,6 +55,9 @@ struct PCIESlot { /* Disable ACS (really for a pcie_root_port) */ bool disable_acs; + + /* Indicates whether hot-plug is enabled on the slot */ + bool hotplug; QLIST_ENTRY(PCIESlot) next; }; diff --git a/hw/pci-bridge/pcie_root_port.c b/hw/pci-bridge/pcie_root_port.c index 0ba4e4dea4..f1cfe9d14a 100644 --- a/hw/pci-bridge/pcie_root_port.c +++ b/hw/pci-bridge/pcie_root_port.c @@ -94,7 +94,7 @@ static void rp_realize(PCIDevice *d, Error **errp) pcie_cap_arifwd_init(d); pcie_cap_deverr_init(d); - pcie_cap_slot_init(d, s->slot); + pcie_cap_slot_init(d, s); pcie_cap_root_init(d); pcie_chassis_create(s->chassis); diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c index 153a4acad2..04aae72cd6 100644 --- a/hw/pci-bridge/xio3130_downstream.c +++ b/hw/pci-bridge/xio3130_downstream.c @@ -94,7 +94,7 @@ static void xio3130_downstream_realize(PCIDevice *d, Error **errp) } pcie_cap_flr_init(d); pcie_cap_deverr_init(d); - pcie_cap_slot_init(d, s->slot); + pcie_cap_slot_init(d, s); pcie_cap_arifwd_init(d); pcie_chassis_create(s->chassis); diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 08718188bb..0eb3a2a5d2 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -495,7 +495,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, /* pci express slot for pci express root/downstream port PCI express capability slot registers */ -void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot) +void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s) { uint32_t pos = dev->exp.exp_cap; @@ -505,13 +505,16 @@ void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot) pci_long_test_and_clear_mask(dev->config + pos + PCI_EXP_SLTCAP, ~PCI_EXP_SLTCAP_PSN); pci_long_test_and_set_mask(dev->config + pos + PCI_EXP_SLTCAP, - (slot << PCI_EXP_SLTCAP_PSN_SHIFT) | + (s->slot << PCI_EXP_SLTCAP_PSN_SHIFT) | PCI_EXP_SLTCAP_EIP | - PCI_EXP_SLTCAP_HPS | - PCI_EXP_SLTCAP_HPC | PCI_EXP_SLTCAP_PIP | PCI_EXP_SLTCAP_AIP | PCI_EXP_SLTCAP_ABP); + if (s->hotplug) { + pci_long_test_and_set_mask(dev->config + pos + PCI_EXP_SLTCAP, + PCI_EXP_SLTCAP_HPS | + PCI_EXP_SLTCAP_HPC); + } if (dev->cap_present & QEMU_PCIE_SLTCAP_PCP) { pci_long_test_and_set_mask(dev->config + pos + PCI_EXP_SLTCAP, diff --git a/hw/pci/pcie_port.c b/hw/pci/pcie_port.c index f8263cb306..eb563ad435 100644 --- a/hw/pci/pcie_port.c +++ b/hw/pci/pcie_port.c @@ -147,6 +147,7 @@ static const TypeInfo pcie_port_type_info = { static Property pcie_slot_props[] = { DEFINE_PROP_UINT8("chassis", PCIESlot, chassis, 0), DEFINE_PROP_UINT16("slot", PCIESlot, slot, 0), + DEFINE_PROP_BOOL("hotplug", PCIESlot, hotplug, true), DEFINE_PROP_END_OF_LIST() }; From patchwork Sun Mar 8 13:31:16 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: 1251036 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=hVxLRxLZ; 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 48b2QC1SGYz9sPK for ; Mon, 9 Mar 2020 00:34:27 +1100 (AEDT) Received: from localhost ([::1]:57960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAw4X-0007sG-5D for incoming@patchwork.ozlabs.org; Sun, 08 Mar 2020 09:34:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53363) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAw4B-0007kS-Sa for qemu-devel@nongnu.org; Sun, 08 Mar 2020 09:34:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jAw4A-0007jh-Qs for qemu-devel@nongnu.org; Sun, 08 Mar 2020 09:34:03 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:36905 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jAw4A-0007jc-N0 for qemu-devel@nongnu.org; Sun, 08 Mar 2020 09:34:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583674442; 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=ifzc42zHTMgVkuR/YxUmyOgyuaAG9QhAqdBKjpYiBjc=; b=hVxLRxLZA56NOi0rTLLZipqBTv3ttWeKWYQ6BW6YmhWc8wRpID3NDn18WVwXCImpHpuPjZ rm1AUMizKL2n8oItVXnEKuTJ9QlyiveRtEoDgMnpC3MjryrNumoBsm8x0FP1Fw/BtnPmpO KWcfKNEe8W0fffmhyIQlBgi7SxmEoAw= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-444-vYoL68D8MY2dyNpzmQd8-w-1; Sun, 08 Mar 2020 09:31:21 -0400 X-MC-Unique: vYoL68D8MY2dyNpzmQd8-w-1 Received: by mail-qt1-f197.google.com with SMTP id b10so934844qto.21 for ; Sun, 08 Mar 2020 06:31: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:in-reply-to; bh=M+8AooxZJTJvkOY3bMqR0/HozcRDxgE8lr4XPeT8sJ0=; b=CN2EhgV1c44Rdu/QgXvr7XZ0Rqasqx4MMNvLbK9hhSvUs2TNGipnv2VyNUckyTrGvF Cr/PKCEt797Za1ml6E5zxm3B7GYpPfu8Zp/ugUxXN5SPVzBSIYj/yaY7d5AMk5I3Yugg vodez5dYLGqhs3o0iBF2RZ14Rg7V37SXhFZdMX+ZeMGWzGZiCAiB99GrapoKbaTlhaB7 ZDzpcQbBotnrZNNsgvfHm1uKZNXAXiLIZFXSh+ODebIkZ1PJorMWTgFsn5rNafHMurkT +eTQa3ItEBlXi8KkQlmm84qzQAhYbatX3m+LN8MOsurLxGUwhLpLadEJZAhMuPtJf720 JNrg== X-Gm-Message-State: ANhLgQ2Zu0kwCEkzIqLlTdpY4O1WZ3YnDRPDAuFAueo9lKrEbOi/PEbS lqKkgn35iT+Dfsu+LKxUZNFTI0TZzCPfYeJZgBMO8moeVXTXKFJaE8+2NXrCCDYTQC3ECPAxUtP //Sz9Mqn4abrrtwk= X-Received: by 2002:ac8:4985:: with SMTP id f5mr10516690qtq.156.1583674281080; Sun, 08 Mar 2020 06:31:21 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs0gH5JDUgzwOne61A7RzlMqi/JkYzalM5mfvT3srCwvhe93Gk+DeU6upWP5xzMmF1vl6GZ4w== X-Received: by 2002:ac8:4985:: with SMTP id f5mr10516675qtq.156.1583674280871; Sun, 08 Mar 2020 06:31:20 -0700 (PDT) Received: from redhat.com (bzq-79-178-2-19.red.bezeqint.net. [79.178.2.19]) by smtp.gmail.com with ESMTPSA id t3sm19096206qkt.114.2020.03.08.06.31.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Mar 2020 06:31:20 -0700 (PDT) Date: Sun, 8 Mar 2020 09:31:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 2/4] vhost: correctly turn on VIRTIO_F_IOMMU_PLATFORM Message-ID: <20200308133054.1563705-3-mst@redhat.com> References: <20200308133054.1563705-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200308133054.1563705-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Halil Pasic , Peter Maydell , Jason Wang Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jason Wang We turn on device IOTLB via VIRTIO_F_IOMMU_PLATFORM unconditionally on platform without IOMMU support. This can lead unnecessary IOTLB transactions which will damage the performance. Fixing this by check whether the device is backed by IOMMU and disable device IOTLB. Reported-by: Halil Pasic Tested-by: Halil Pasic Reviewed-by: Halil Pasic Signed-off-by: Jason Wang Message-Id: <20200302042454.24814-1-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 0d226dae10..01ebe12f28 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -290,7 +290,14 @@ static int vhost_dev_has_iommu(struct vhost_dev *dev) { VirtIODevice *vdev = dev->vdev; - return virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM); + /* + * For vhost, VIRTIO_F_IOMMU_PLATFORM means the backend support + * incremental memory mapping API via IOTLB API. For platform that + * does not have IOMMU, there's no need to enable this feature + * which may cause unnecessary IOTLB miss/update trnasactions. + */ + return vdev->dma_as != &address_space_memory && + virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM); } static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr, @@ -765,6 +772,9 @@ static int vhost_dev_set_features(struct vhost_dev *dev, if (enable_log) { features |= 0x1ULL << VHOST_F_LOG_ALL; } + if (!vhost_dev_has_iommu(dev)) { + features &= ~(0x1ULL << VIRTIO_F_IOMMU_PLATFORM); + } r = dev->vhost_ops->vhost_set_features(dev, features); if (r < 0) { VHOST_OPS_DEBUG("vhost_set_features failed"); From patchwork Sun Mar 8 13:31:21 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: 1251033 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=G+9ynz7f; 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 48b2Np1KhZz9sPF for ; Mon, 9 Mar 2020 00:33:14 +1100 (AEDT) Received: from localhost ([::1]:57946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAw3M-0006AZ-3U for incoming@patchwork.ozlabs.org; Sun, 08 Mar 2020 09:33:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53027) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAw1h-0004ly-TY for qemu-devel@nongnu.org; Sun, 08 Mar 2020 09:31:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jAw1g-0006a1-Ur for qemu-devel@nongnu.org; Sun, 08 Mar 2020 09:31:29 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:30553 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jAw1g-0006Zu-QD for qemu-devel@nongnu.org; Sun, 08 Mar 2020 09:31:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583674288; 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=+ingQukXqhyYANrIdEMVg6/xA+WiLczxiRmxDnvapgw=; b=G+9ynz7fvQNh6u3jGRbf3kI0/u3N1Bgyn8JCAuHqOvn/aoCCQB3223SwlBROXIyN66JiGE RCPNKJ6Nk+xaYl3vOh7uhyzk85qYTln3j/EG9Y9OJfMnwmU+la9TvlXGz/i3J2feNfMsbh n7auSypze7OVzy+qhJE6p54xvo2hTM0= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-477-x5ViJXElNDKWr5dnoRsVQQ-1; Sun, 08 Mar 2020 09:31:26 -0400 X-MC-Unique: x5ViJXElNDKWr5dnoRsVQQ-1 Received: by mail-qt1-f198.google.com with SMTP id j35so4962938qte.19 for ; Sun, 08 Mar 2020 06:31: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:content-transfer-encoding :in-reply-to; bh=jhaVEc1976vvFcZUoBl4MhVwpmTYuCRTZAxZTDn5INw=; b=EnI5fWqaVyQZALWDMwakPVJUnavej0yRhsxyH1YtgAYNLSIVTCsjK5IahZhv2GLGWP k0z/ISWCq3p4pniqviHp/nHgf00lTo4KSBfOJU2Pp5L4BoxzxbsDbfmqeAAqQ1C/XX/v CxPnQ0JS0YEsRXz7jECiY30KbEKOHAFNVxa63PvjDKTcDDharMBQtJRyrrkqar8ZkjtU bh1kfHifWQzAPlM0OYa/lSXLXEDjsmlRW44s2M4q44PuxSpKpoZE1n1pbnyH3VN1N0lE unQxYjh/k/ZOfebdj/UHmHOO3u9ZGoAaySV9LrBjeZ73WpOlL2LLZ0dqcuR+pfhYE1jo Oswg== X-Gm-Message-State: ANhLgQ05Li7zDn+dMHI5ChHiIX70XRvXjXLRQDZ4yJj6ZAlyG3lSPZp9 MeAV+sae2trZWnVBAEJlWkGwyyK1GmRETKodaaOPYL7AlXnnrX+WC2sBEXTkl1qAI0ggylTu7Zc bY36DyU5DBSiucZA= X-Received: by 2002:a05:620a:22ea:: with SMTP id p10mr10878690qki.75.1583674285827; Sun, 08 Mar 2020 06:31:25 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu7AsYPOMNiAHetUBfiQuC5yn8kSav3lkFgKmSBGtM0nU72/tQS8plS/fnyIBhNtwJorQNgAw== X-Received: by 2002:a05:620a:22ea:: with SMTP id p10mr10878668qki.75.1583674285552; Sun, 08 Mar 2020 06:31:25 -0700 (PDT) Received: from redhat.com (bzq-79-178-2-19.red.bezeqint.net. [79.178.2.19]) by smtp.gmail.com with ESMTPSA id h24sm13891117qkk.3.2020.03.08.06.31.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Mar 2020 06:31:24 -0700 (PDT) Date: Sun, 8 Mar 2020 09:31:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 3/4] vhost-vsock: fix error message output Message-ID: <20200308133054.1563705-4-mst@redhat.com> References: <20200308133054.1563705-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200308133054.1563705-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?utf-8?q?J=C3=A1n?= Tomko , Laurent Vivier , Nick Erdmann , Stefan Hajnoczi , Stefano Garzarella Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Nick Erdmann error_setg_errno takes a positive error number, so we should not invert errno's sign. Signed-off-by: Nick Erdmann Message-Id: <04df3f47-c93b-1d02-d250-f9bda8dbc0fa@nirf.de> Reviewed-by: Ján Tomko Fixes: fc0b9b0e1cbb ("vhost-vsock: add virtio sockets device") Reviewed-by: Laurent Vivier Reviewed-by: Stefano Garzarella Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vsock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 66da96583b..9f9093e196 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -325,7 +325,7 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp) } else { vhostfd = open("/dev/vhost-vsock", O_RDWR); if (vhostfd < 0) { - error_setg_errno(errp, -errno, + error_setg_errno(errp, errno, "vhost-vsock: failed to open vhost device"); return; } From patchwork Sun Mar 8 13:31:26 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: 1251035 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=CDYFBWWZ; 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 48b2PG180pz9sPF for ; Mon, 9 Mar 2020 00:33:38 +1100 (AEDT) Received: from localhost ([::1]:57950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAw3k-0006T3-2f for incoming@patchwork.ozlabs.org; Sun, 08 Mar 2020 09:33:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53087) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAw1s-0004uk-BE for qemu-devel@nongnu.org; Sun, 08 Mar 2020 09:31:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jAw1o-0006hF-QX for qemu-devel@nongnu.org; Sun, 08 Mar 2020 09:31:39 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:51863 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jAw1o-0006gR-MI for qemu-devel@nongnu.org; Sun, 08 Mar 2020 09:31:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583674295; 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=WD83umNxm2ky0VXPPRkxHn9Dl02EzVTi3i3J6pm7IYQ=; b=CDYFBWWZ0iQicSG3JlMQ+CdNzF1oDfW2yZ6/LVoE90nR3thX19KtJiW1CLILYClICDWsnC 9NOq8H9hjdcCdm8Bp6bYUQ4VsXLO5yixsTwZhgtIeqjrN6XhWyKDZrjubstS8LmJ6EMnfN C5SFssv1gp9p01XX3D3EXsorDDO9xuk= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-279-DCS703EIMsCvZ4-e6arM1g-1; Sun, 08 Mar 2020 09:31:32 -0400 X-MC-Unique: DCS703EIMsCvZ4-e6arM1g-1 Received: by mail-qt1-f199.google.com with SMTP id f25so4957431qtp.12 for ; Sun, 08 Mar 2020 06:31: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=hDANYJtJJ6fz/Foo93IRg8oS9InICE/RlX6g+g3k1KI=; b=NDssei9ZI8dHEpfmcP0mHAOsI+yeOLW0QrO8w8uCipARXf3m6+Isb7xrc2pXncD2oY ilQ3nSxpUbD7tUrj4gj9osyG+6uk1sNQJlnMQwNt6oCYpE+vP1aS4E5PXTe28fGi51F3 Hbg3i7VYuDhbGShZnMOZGLaGoGxriCjO9+czUEL/IlpLJQ8H47har72VwF9h6lEADFvF 4LQEaGDubilxulUw6eTlk7DRtl54K8CVNojGqOcyN3IF+eGqiKqay2j+jkW4IQq3dD/7 A2CKTiqs+u67nWrbT3FoAmfOmxDskjVJmabgj2A+jbYIwPOTFzVBDLBq7kkfPc6l0ikI MWrw== X-Gm-Message-State: ANhLgQ0GZj5PERzyl3J4qr2TwEPdpJKkqpqapwVysslfyGpxja1UO8Dt iIIVkxKJ62cFFAqPos3nMO9kFOt0WR0xtSB0gsHUzCOnj+j5Um2zGA4KrDq1pk4IIdR+BbBWOcW Keam2yQbvWqRhaLg= X-Received: by 2002:a05:620a:2209:: with SMTP id m9mr10778077qkh.71.1583674291392; Sun, 08 Mar 2020 06:31:31 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsp4dv1bezoMHrXC/3zAlA2zYBMlRcCbUtQwyB7yUKScheb3XnsU/3yJQQa5uiJRMhsL7tZZA== X-Received: by 2002:a05:620a:2209:: with SMTP id m9mr10778060qkh.71.1583674291069; Sun, 08 Mar 2020 06:31:31 -0700 (PDT) Received: from redhat.com (bzq-79-178-2-19.red.bezeqint.net. [79.178.2.19]) by smtp.gmail.com with ESMTPSA id w41sm21001422qtj.49.2020.03.08.06.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Mar 2020 06:31:30 -0700 (PDT) Date: Sun, 8 Mar 2020 09:31:26 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 4/4] hw/i386/intel_iommu: Simplify vtd_find_as_from_bus_num() logic Message-ID: <20200308133054.1563705-5-mst@redhat.com> References: <20200308133054.1563705-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200308133054.1563705-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Peter Xu , Eric Auger , 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: Philippe Mathieu-Daudé The vtd_find_as_from_bus_num() function was introduced (in commit dbaabb25f) in a code format that could return an incorrect pointer, which was later fixed by commit a2e1cd41ccf. We could have avoided this by writing the if() statement differently. Do it now, in case this function is re-used. The code is easier to review (harder to miss bugs). Reviewed-by: Peter Xu Reviewed-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20200305102702.31512-1-philmd@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 6258c58ac9..204b6841ec 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -987,24 +987,26 @@ static bool vtd_slpte_nonzero_rsvd(uint64_t slpte, uint32_t level) static VTDBus *vtd_find_as_from_bus_num(IntelIOMMUState *s, uint8_t bus_num) { VTDBus *vtd_bus = s->vtd_as_by_bus_num[bus_num]; - if (!vtd_bus) { - /* - * Iterate over the registered buses to find the one which - * currently hold this bus number, and update the bus_num - * lookup table: - */ - GHashTableIter iter; + GHashTableIter iter; - g_hash_table_iter_init(&iter, s->vtd_as_by_busptr); - while (g_hash_table_iter_next(&iter, NULL, (void **)&vtd_bus)) { - if (pci_bus_num(vtd_bus->bus) == bus_num) { - s->vtd_as_by_bus_num[bus_num] = vtd_bus; - return vtd_bus; - } - } - vtd_bus = NULL; + if (vtd_bus) { + return vtd_bus; } - return vtd_bus; + + /* + * Iterate over the registered buses to find the one which + * currently holds this bus number and update the bus_num + * lookup table. + */ + g_hash_table_iter_init(&iter, s->vtd_as_by_busptr); + while (g_hash_table_iter_next(&iter, NULL, (void **)&vtd_bus)) { + if (pci_bus_num(vtd_bus->bus) == bus_num) { + s->vtd_as_by_bus_num[bus_num] = vtd_bus; + return vtd_bus; + } + } + + return NULL; } /* Given the @iova, get relevant @slptep. @slpte_level will be the last level