From patchwork Wed Nov 4 18:41:18 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: 318585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F7E6C4741F for ; Wed, 4 Nov 2020 18:43:03 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D5C73206C1 for ; Wed, 4 Nov 2020 18:43:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UYj3p6vp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5C73206C1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNkL-0001nW-MB for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 13:43:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNio-0008S3-LV for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:41:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42164) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNin-0001tT-4C for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:41:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515284; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=h0heXC8AZt7eXzCvDvOmqsibMEQ+v+zzRIJ+pXZVz+w=; b=UYj3p6vp5wGaqKt6OlmC/pOnHu311n4YiHOqKgWfEyqOXg04DbmuiM1DdDz6Wxw0WvdAMi rLswqNlbShbH2TsyFga0BUpXQHM+7b+ShGZKIanuWMYGnulh7ma8Nj/dFZYhu3eAGumcHR 0X/AkSuRSg5VE5VET1CjeK472aAvZeU= 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-141-IklPdRX6MU2Hg-kjgBdfrg-1; Wed, 04 Nov 2020 13:41:22 -0500 X-MC-Unique: IklPdRX6MU2Hg-kjgBdfrg-1 Received: by mail-wr1-f69.google.com with SMTP id w1so9592950wrr.5 for ; Wed, 04 Nov 2020 10:41:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=h0heXC8AZt7eXzCvDvOmqsibMEQ+v+zzRIJ+pXZVz+w=; b=c1cLLUcULUxHwBkbrxmQ9y+cg2pzITWIZC0PzVK9TsS+UuWrhGr3g93TtjwMWjP6ZO yeNX5AHjwCEjNcxg2wD8NSFpEliNlLGOmhPCUwXvKQ6O01bPA/b6li3eJOhzD+E2LwDr geDJXJUOA/R4gI0M8eBzadipGH7yP6kf99SBqvCMcM/AHt8hpi1rTNIeD2AMzqFOJJ83 DPTGHmDO6VsdNpvj3ZTtcXvSTjuY57swRdyuuL4Rcp4Rtgp6/5nkuAuez9hRAKv7Zlpr VLYle0C1BQ2n6ebMzAmMBpjGTN2cL+xuAwEHIcHJWC+JHEBx7ffU/5W9oaszCJMdhNu8 RdKw== X-Gm-Message-State: AOAM533u4Jx9gvJ81zHrw0JxerZm1YJFx6Xr6j2D65WXKbm6u92+MGoc XfE8uRzvutjFenWM1xnn+EyRBj9NSCuQKrjflwb7ejxxCiBNCctjZbTzys7uZTkR9PN7YwfHhL7 2qMs/qJ0cmeR0m7E= X-Received: by 2002:a7b:c7d3:: with SMTP id z19mr6292073wmk.4.1604515281174; Wed, 04 Nov 2020 10:41:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzY4NM5GG1s2kd45AUSVpLRtzPwV5xiwPkOxdXhGMNLQb1fJEhFxgf0C2RBgOD4lVfKbstkhw== X-Received: by 2002:a7b:c7d3:: with SMTP id z19mr6292060wmk.4.1604515281033; Wed, 04 Nov 2020 10:41:21 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id h81sm3437209wmf.44.2020.11.04.10.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:41:20 -0800 (PST) Date: Wed, 4 Nov 2020 13:41:18 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 01/31] pc: comment style fixup Message-ID: <20201104184040.285057-2-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Chen Qun , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Fix up checkpatch comment style warnings. Signed-off-by: Michael S. Tsirkin Reviewed-by: Chen Qun --- hw/i386/pc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 5e6c0023e0..17b514d1da 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1149,10 +1149,11 @@ void pc_basic_device_init(struct PCMachineState *pcms, error_report("couldn't create HPET device"); exit(1); } - /* For pc-piix-*, hpet's intcap is always IRQ2. For pc-q35-1.7 - * and earlier, use IRQ2 for compat. Otherwise, use IRQ16~23, - * IRQ8 and IRQ2. - */ + /* + * For pc-piix-*, hpet's intcap is always IRQ2. For pc-q35-1.7 and + * earlier, use IRQ2 for compat. Otherwise, use IRQ16~23, IRQ8 and + * IRQ2. + */ uint8_t compat = object_property_get_uint(OBJECT(hpet), HPET_INTCAP, NULL); if (!compat) { From patchwork Wed Nov 4 18:41: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: 318584 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D67AC2D0A3 for ; Wed, 4 Nov 2020 18:43:47 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A3BD020719 for ; Wed, 4 Nov 2020 18:43:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WWfHPIjo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A3BD020719 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNl3-000383-LY for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 13:43:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNiy-0000Le-Fl for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:41:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30447) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNiw-0001vC-BJ for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:41:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515293; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Bbvtq4HGVJ/wSfBQLsW+iRV9/tlIpRrNFHMItefyjY8=; b=WWfHPIjojMCjmUtjYeYdbU9mXru40iIW9/OUoMHDsDgpRSnpmxFGtJrOu6GALEqOXCwItY jCC5sWJwIDXDHl7o005lirjhTEUMZ7uf4uPoL72ceh2MksTcJPl5j/IB39Q+t0pok0H28K 0eJZsQWnrzVBvFOHoabyPPZOnZ0Z2Uk= 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-393-4Q02eU6ZN7iZpRWXr7w_1g-1; Wed, 04 Nov 2020 13:41:31 -0500 X-MC-Unique: 4Q02eU6ZN7iZpRWXr7w_1g-1 Received: by mail-wr1-f72.google.com with SMTP id x16so9538457wrg.7 for ; Wed, 04 Nov 2020 10:41:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Bbvtq4HGVJ/wSfBQLsW+iRV9/tlIpRrNFHMItefyjY8=; b=RW+VZtnj64lKtS9NqWSAQt6yGPrZqiTjS2aH1w+oeqv2xdi7dGaUEXyt3AvvczzV9k rJRwH7/kKMktuyKtCfCMiVGTW78yo/gyCnK1uARittTLekXsHRq/olfMyMJoqbbDo9nq y+7+SccT7BilQ2zWpO/KJnSugDdWjIjk/pgwIRVn7y+uInFznwouaoKWPaT983eYtcbJ HoVy2/dwWtYAuCl93ynQtQpqUl+VuW9GYqlGjzrcvFP6o71bPjjmoTSuggzqTfdKOm5f UYiSiBtdznD/ZZV55PQ8kTR/1J5QpC2CauUxfn6ANWvGVyRIAhlNhnhrysM+AKYQ1h9B Tw7A== X-Gm-Message-State: AOAM531C6aItG/eFRaffctou8FqURkL8snhlypv5ucimtt95dVXIR/HJ /XnKLjESHYDpEnfUdc6AziVEng2eD2JlczhClJVuYK/eZZ8BZV/sLMdQ7BOjm1Xcpmel2vYJDvZ /1uoueVa319AgWZ0= X-Received: by 2002:adf:ed92:: with SMTP id c18mr35868472wro.363.1604515290154; Wed, 04 Nov 2020 10:41:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwoQMfoMrpNtZzxRLAnt2kUrChcGDlsUqG4t535zxfYCl2X/yRE+l9JGzwxzUzPVDj0zdCPUA== X-Received: by 2002:adf:ed92:: with SMTP id c18mr35868453wro.363.1604515289987; Wed, 04 Nov 2020 10:41:29 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id b4sm3723480wro.57.2020.11.04.10.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:41:29 -0800 (PST) Date: Wed, 4 Nov 2020 13:41:27 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 04/31] virtio-mem: Probe THP size to determine default block size Message-ID: <20201104184040.285057-5-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Pankaj Gupta , David Hildenbrand , "Dr . David Alan Gilbert" , Wei Yang , Igor Mammedov Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Let's allow a minimum block size of 1 MiB in all configurations. Select the default block size based on - The page size of the memory backend. - The THP size if the memory backend size corresponds to the real host page size. - The global minimum of 1 MiB. and warn if something smaller is configured by the user. VIRTIO_MEM only supports Linux (depends on LINUX), so we can probe the THP size unconditionally. For now we only support virtio-mem on x86-64 - there isn't a user-visible change (x86-64 only supports 2 MiB THP on the PMD level) - the default was, and will be 2 MiB. If we ever have THP on the PUD level (e.g., 1 GiB THP on x86-64), we expect it to be more transparent - e.g., to only optimize fully populated ranges unless explicitly told /configured otherwise (in contrast to PMD THP). Reviewed-by: Pankaj Gupta Cc: "Michael S. Tsirkin" Cc: Wei Yang Cc: Dr. David Alan Gilbert Cc: Igor Mammedov Cc: Pankaj Gupta Signed-off-by: David Hildenbrand Message-Id: <20201008083029.9504-4-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mem.c | 105 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 4 deletions(-) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 461ac68ee8..655824ff81 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -33,10 +33,83 @@ #include "trace.h" /* - * Use QEMU_VMALLOC_ALIGN, so no THP will have to be split when unplugging - * memory (e.g., 2MB on x86_64). + * Let's not allow blocks smaller than 1 MiB, for example, to keep the tracking + * bitmap small. */ -#define VIRTIO_MEM_MIN_BLOCK_SIZE ((uint32_t)QEMU_VMALLOC_ALIGN) +#define VIRTIO_MEM_MIN_BLOCK_SIZE ((uint32_t)(1 * MiB)) + +#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ + defined(__powerpc64__) +#define VIRTIO_MEM_DEFAULT_THP_SIZE ((uint32_t)(2 * MiB)) +#else + /* fallback to 1 MiB (e.g., the THP size on s390x) */ +#define VIRTIO_MEM_DEFAULT_THP_SIZE VIRTIO_MEM_MIN_BLOCK_SIZE +#endif + +/* + * We want to have a reasonable default block size such that + * 1. We avoid splitting THPs when unplugging memory, which degrades + * performance. + * 2. We avoid placing THPs for plugged blocks that also cover unplugged + * blocks. + * + * The actual THP size might differ between Linux kernels, so we try to probe + * it. In the future (if we ever run into issues regarding 2.), we might want + * to disable THP in case we fail to properly probe the THP size, or if the + * block size is configured smaller than the THP size. + */ +static uint32_t thp_size; + +#define HPAGE_PMD_SIZE_PATH "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size" +static uint32_t virtio_mem_thp_size(void) +{ + gchar *content = NULL; + const char *endptr; + uint64_t tmp; + + if (thp_size) { + return thp_size; + } + + /* + * Try to probe the actual THP size, fallback to (sane but eventually + * incorrect) default sizes. + */ + if (g_file_get_contents(HPAGE_PMD_SIZE_PATH, &content, NULL, NULL) && + !qemu_strtou64(content, &endptr, 0, &tmp) && + (!endptr || *endptr == '\n')) { + /* + * Sanity-check the value, if it's too big (e.g., aarch64 with 64k base + * pages) or weird, fallback to something smaller. + */ + if (!tmp || !is_power_of_2(tmp) || tmp > 16 * MiB) { + warn_report("Read unsupported THP size: %" PRIx64, tmp); + } else { + thp_size = tmp; + } + } + + if (!thp_size) { + thp_size = VIRTIO_MEM_DEFAULT_THP_SIZE; + warn_report("Could not detect THP size, falling back to %" PRIx64 + " MiB.", thp_size / MiB); + } + + g_free(content); + return thp_size; +} + +static uint64_t virtio_mem_default_block_size(RAMBlock *rb) +{ + const uint64_t page_size = qemu_ram_pagesize(rb); + + /* We can have hugetlbfs with a page size smaller than the THP size. */ + if (page_size == qemu_real_host_page_size) { + return MAX(page_size, virtio_mem_thp_size()); + } + return MAX(page_size, VIRTIO_MEM_MIN_BLOCK_SIZE); +} + /* * Size the usable region bigger than the requested size if possible. Esp. * Linux guests will only add (aligned) memory blocks in case they fully @@ -443,10 +516,23 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp) rb = vmem->memdev->mr.ram_block; page_size = qemu_ram_pagesize(rb); + /* + * If the block size wasn't configured by the user, use a sane default. This + * allows using hugetlbfs backends of any page size without manual + * intervention. + */ + if (!vmem->block_size) { + vmem->block_size = virtio_mem_default_block_size(rb); + } + if (vmem->block_size < page_size) { error_setg(errp, "'%s' property has to be at least the page size (0x%" PRIx64 ")", VIRTIO_MEM_BLOCK_SIZE_PROP, page_size); return; + } else if (vmem->block_size < virtio_mem_default_block_size(rb)) { + warn_report("'%s' property is smaller than the default block size (%" + PRIx64 " MiB)", VIRTIO_MEM_BLOCK_SIZE_PROP, + virtio_mem_default_block_size(rb) / MiB); } else if (!QEMU_IS_ALIGNED(vmem->requested_size, vmem->block_size)) { error_setg(errp, "'%s' property has to be multiples of '%s' (0x%" PRIx64 ")", VIRTIO_MEM_REQUESTED_SIZE_PROP, @@ -742,6 +828,18 @@ static void virtio_mem_get_block_size(Object *obj, Visitor *v, const char *name, const VirtIOMEM *vmem = VIRTIO_MEM(obj); uint64_t value = vmem->block_size; + /* + * If not configured by the user (and we're not realized yet), use the + * default block size we would use with the current memory backend. + */ + if (!value) { + if (vmem->memdev && memory_region_is_ram(&vmem->memdev->mr)) { + value = virtio_mem_default_block_size(vmem->memdev->mr.ram_block); + } else { + value = virtio_mem_thp_size(); + } + } + visit_type_size(v, name, &value, errp); } @@ -821,7 +919,6 @@ static void virtio_mem_instance_init(Object *obj) { VirtIOMEM *vmem = VIRTIO_MEM(obj); - vmem->block_size = VIRTIO_MEM_MIN_BLOCK_SIZE; notifier_list_init(&vmem->size_change_notifiers); vmem->precopy_notifier.notify = virtio_mem_precopy_notify; From patchwork Wed Nov 4 18:41:39 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: 318583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEE8BC2D0A3 for ; Wed, 4 Nov 2020 18:44:58 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4934B206C1 for ; Wed, 4 Nov 2020 18:44:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UBHV/ITG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4934B206C1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNmD-0005Ho-9I for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 13:44:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNj9-0000kY-Td for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:41:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41004) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNj7-0001x3-Uk for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:41:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ghKT3iuLd9VX4UT4KJCLl/E2c6yAP84MyPy0077dPys=; b=UBHV/ITGGZbZ79gl0aqGPnUtfTmvnWRipU+wMx5NcocpON0HsX78i+1O1s0x+VewzgZE7O 1Q6nzQHOwQEnamw87YEa+MpG+ASLuAH1WiTS7zUCPENnykQ2VV27+rJlmbUHFfk4M4Gcma 1E7ql44f4tj169umjEv+fH/kIcppgrI= 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-255-VrMxgYn-PEO-vyUiwayFlg-1; Wed, 04 Nov 2020 13:41:43 -0500 X-MC-Unique: VrMxgYn-PEO-vyUiwayFlg-1 Received: by mail-wr1-f72.google.com with SMTP id j13so9674426wrn.4 for ; Wed, 04 Nov 2020 10:41:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ghKT3iuLd9VX4UT4KJCLl/E2c6yAP84MyPy0077dPys=; b=tWwSt5+17kHJsPmlIh6PJpPNxWPzTwPsTs7DaT3fHao30ihheH7R/u71zPBzy6xiCU fHdcs5SisODXx+hf8S7p4T4mYAIKXeIKnm3Xy5Epx1Z+vbzpb8CG4p5rdBS5iTB0s0GK EDioAKtOfZRc6cyVES31itWLYetE7JDlyaMB9Cc2NNiAEjL1AEMYSrPf/ZFFCUSp+CYk zh3p/PaWYXTBrj37jZ9tk95I5XTNnOV24Z7I1wvdaNP+jGpu2PgKja/kizaSxcQb7JC5 7eNPnIXTGq5je7NWcKKk32U3QBGVINc0s0LuVvgP+gdd3mQURcRJ5x92P/2H04kuHuIk cbXQ== X-Gm-Message-State: AOAM532NeTWI2yUlqYQCzoH3K3Ri6ttdWtuedg3hfKYMlx+Jn8Si3jLs bSLpIo4IRP0Tvvm6320StKOpWbPZVel/rX5DJ7kez5kKRdEFkiQJiCXIIYToQBqu0LaBg9i9Hkq oDHSU2xBs7UpwakY= X-Received: by 2002:adf:e7c1:: with SMTP id e1mr35629813wrn.247.1604515302264; Wed, 04 Nov 2020 10:41:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxc+jwNfmhHFJqp/PTDe9owKAjiynSCwtH2vOTe79Z6+4lgB0tLojWQjlTq0LjTg6+kyVHc+w== X-Received: by 2002:adf:e7c1:: with SMTP id e1mr35629796wrn.247.1604515302091; Wed, 04 Nov 2020 10:41:42 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id o63sm3565900wmo.2.2020.11.04.10.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:41:41 -0800 (PST) Date: Wed, 4 Nov 2020 13:41:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 08/31] hw/acpi : Don't use '#' flag of printf format Message-ID: <20201104184040.285057-9-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov , Kai Deng , Xiao Guangrong , Xinhao Zhang Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Xinhao Zhang Fix code style. Don't use '#' flag of printf format ('%#') in format strings, use '0x' prefix instead Signed-off-by: Xinhao Zhang Signed-off-by: Kai Deng Message-Id: <20201103102634.273021-1-zhangxinhao1@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/nvdimm.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 8f7cc16add..8ad5516142 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -556,7 +556,7 @@ static void nvdimm_dsm_func_read_fit(NVDIMMState *state, NvdimmDsmIn *in, fit = fit_buf->fit; - nvdimm_debug("Read FIT: offset %#x FIT size %#x Dirty %s.\n", + nvdimm_debug("Read FIT: offset 0x%x FIT size 0x%x Dirty %s.\n", read_fit->offset, fit->len, fit_buf->dirty ? "Yes" : "No"); if (read_fit->offset > fit->len) { @@ -664,7 +664,7 @@ static void nvdimm_dsm_label_size(NVDIMMDevice *nvdimm, hwaddr dsm_mem_addr) label_size = nvdimm->label_size; mxfer = nvdimm_get_max_xfer_label_size(); - nvdimm_debug("label_size %#x, max_xfer %#x.\n", label_size, mxfer); + nvdimm_debug("label_size 0x%x, max_xfer 0x%x.\n", label_size, mxfer); label_size_out.func_ret_status = cpu_to_le32(NVDIMM_DSM_RET_STATUS_SUCCESS); label_size_out.label_size = cpu_to_le32(label_size); @@ -680,19 +680,19 @@ static uint32_t nvdimm_rw_label_data_check(NVDIMMDevice *nvdimm, uint32_t ret = NVDIMM_DSM_RET_STATUS_INVALID; if (offset + length < offset) { - nvdimm_debug("offset %#x + length %#x is overflow.\n", offset, + nvdimm_debug("offset 0x%x + length 0x%x is overflow.\n", offset, length); return ret; } if (nvdimm->label_size < offset + length) { - nvdimm_debug("position %#x is beyond label data (len = %" PRIx64 ").\n", + nvdimm_debug("position 0x%x is beyond label data (len = %" PRIx64 ").\n", offset + length, nvdimm->label_size); return ret; } if (length > nvdimm_get_max_xfer_label_size()) { - nvdimm_debug("length (%#x) is larger than max_xfer (%#x).\n", + nvdimm_debug("length (0x%x) is larger than max_xfer (0x%x).\n", length, nvdimm_get_max_xfer_label_size()); return ret; } @@ -716,7 +716,7 @@ static void nvdimm_dsm_get_label_data(NVDIMMDevice *nvdimm, NvdimmDsmIn *in, get_label_data->offset = le32_to_cpu(get_label_data->offset); get_label_data->length = le32_to_cpu(get_label_data->length); - nvdimm_debug("Read Label Data: offset %#x length %#x.\n", + nvdimm_debug("Read Label Data: offset 0x%x length 0x%x.\n", get_label_data->offset, get_label_data->length); status = nvdimm_rw_label_data_check(nvdimm, get_label_data->offset, @@ -755,7 +755,7 @@ static void nvdimm_dsm_set_label_data(NVDIMMDevice *nvdimm, NvdimmDsmIn *in, set_label_data->offset = le32_to_cpu(set_label_data->offset); set_label_data->length = le32_to_cpu(set_label_data->length); - nvdimm_debug("Write Label Data: offset %#x length %#x.\n", + nvdimm_debug("Write Label Data: offset 0x%x length 0x%x.\n", set_label_data->offset, set_label_data->length); status = nvdimm_rw_label_data_check(nvdimm, set_label_data->offset, @@ -838,7 +838,7 @@ nvdimm_dsm_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) NvdimmDsmIn *in; hwaddr dsm_mem_addr = val; - nvdimm_debug("dsm memory address %#" HWADDR_PRIx ".\n", dsm_mem_addr); + nvdimm_debug("dsm memory address 0x%" HWADDR_PRIx ".\n", dsm_mem_addr); /* * The DSM memory is mapped to guest address space so an evil guest @@ -852,11 +852,11 @@ nvdimm_dsm_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) in->function = le32_to_cpu(in->function); in->handle = le32_to_cpu(in->handle); - nvdimm_debug("Revision %#x Handler %#x Function %#x.\n", in->revision, + nvdimm_debug("Revision 0x%x Handler 0x%x Function 0x%x.\n", in->revision, in->handle, in->function); if (in->revision != 0x1 /* Currently we only support DSM Spec Rev1. */) { - nvdimm_debug("Revision %#x is not supported, expect %#x.\n", + nvdimm_debug("Revision 0x%x is not supported, expect 0x%x.\n", in->revision, 0x1); nvdimm_dsm_no_payload(NVDIMM_DSM_RET_STATUS_UNSUPPORT, dsm_mem_addr); goto exit; From patchwork Wed Nov 4 18:41:42 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: 318581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D0FAC2D0A3 for ; Wed, 4 Nov 2020 18:47:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E7AB320780 for ; Wed, 4 Nov 2020 18:47:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CwNLRFq2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7AB320780 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNoT-0000Ph-Jn for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 13:47:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNjE-0000pU-CZ for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:41:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:26091) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNjC-0001zc-50 for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:41:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515309; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=g3L/0LWUS5AALGZ/Ad9jPepioK718BBOf2ilNljz6+w=; b=CwNLRFq2jBRXn1GQaqQoPjpboTeC0LwGi6bgVisasExz3u0PbvvYXq3T0pvvREI8ixs/h/ j6YkpXaHKRaXspgAG6FN3NIYPRylCgYWvMKq1q3I5kY+YWPKPvB4p5Vfwc2ur2MCv0MS6I 9P2liqt0Foq1xeeVzE5jpyp/WvlB8+U= 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-84-mOA9BdrNOou9dsrtTiMTfQ-1; Wed, 04 Nov 2020 13:41:47 -0500 X-MC-Unique: mOA9BdrNOou9dsrtTiMTfQ-1 Received: by mail-wm1-f71.google.com with SMTP id z62so1477676wmb.1 for ; Wed, 04 Nov 2020 10:41:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=g3L/0LWUS5AALGZ/Ad9jPepioK718BBOf2ilNljz6+w=; b=teY7jz0/GJ8rctxiGwY0qCuDqvYVDxZpsLduIs3HtTNF5g7C2E3eRx3pGnr4rIMCOR fb2pGDiGeZCRjAOJkNZYjCey/ssA9EozDiVMX5RrxDzgDQ82Xq/nBXSz/xVCj7uzoxvR ISL1cJwRifM77J9qCxCXxkWh6qoGLDWMZdqoh55KPhyEzex82dYxJH8WYzCPWV7Zdd5a yoPm1tyLoNCLqysCpQUiZCADRGLCmWJEr3+Ukj4u4O4QkN392Kn0NJgxOufGH2UDD5v7 5xq7nuIg5Xf1wQ/xwhngOR8I2fD1yGYz9LEwKzEvVhYHrT339S/01lhtqJFkvNJE7yy1 71RA== X-Gm-Message-State: AOAM5316YjEuyeI2WdPFGWY2OzTEdBuGk5WI8XliW1t98vmsAF9iK6o5 Fl4S6zNEHew008XzsK0mWU4URJkxthGG68dHybm/7lw1SQuAoBHn6mqEqHwV7JXPeSkuoh/uplw 2xpxNzLfyOzXP8kg= X-Received: by 2002:adf:9544:: with SMTP id 62mr233340wrs.223.1604515305333; Wed, 04 Nov 2020 10:41:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzp2XWJ38E9Qo5hR9cTdSGT4LK1JpFCnexGRxULJDLq8MeYQBdTbr5V2Rq6qIOCsEvZIJ26iQ== X-Received: by 2002:adf:9544:: with SMTP id 62mr233329wrs.223.1604515305194; Wed, 04 Nov 2020 10:41:45 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id g190sm165104wmg.29.2020.11.04.10.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:41:44 -0800 (PST) Date: Wed, 4 Nov 2020 13:41:42 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 09/31] hw/acpi : add space before the open parenthesis '(' Message-ID: <20201104184040.285057-10-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov , Kai Deng , Xinhao Zhang Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Xinhao Zhang Fix code style. Space required before the open parenthesis '('. Signed-off-by: Xinhao Zhang Signed-off-by: Kai Deng Message-Id: <20201103102634.273021-2-zhangxinhao1@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/acpi/core.c b/hw/acpi/core.c index ade9158cbf..2c0c83221f 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -558,7 +558,7 @@ static void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val) if (val & ACPI_BITMASK_SLEEP_ENABLE) { /* change suspend type */ uint16_t sus_typ = (val >> 10) & 7; - switch(sus_typ) { + switch (sus_typ) { case 0: /* soft power off */ qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); break; From patchwork Wed Nov 4 18:41:45 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: 318568 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53AF1C2D0A3 for ; Wed, 4 Nov 2020 19:03:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A1884206D9 for ; Wed, 4 Nov 2020 19:03:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TdqkMUuw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A1884206D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaO3y-0000ps-KP for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 14:03:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNmW-0006Oi-8v for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:45:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47405) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNmU-0002Lk-Fb for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:45:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515513; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kxx7KBtrm7vYLNNi8ILRStjcIKIqdM/KqZjCc2FDurE=; b=TdqkMUuwHa3BSofhcpwNkMHW+2L3g84agcwxrfxRK9OaqqHPtedilpKxOf3fujiWEn2xp/ 25AKQ5B6zU3NVxOn1FZH7M6ZjPAlUaVX7AhBZnI1kIUis4GmEl2VR2zfDlFjuhOQDZS1RV Gt9FQXx4P1gSucvNVfSsl3sIZx5xK6g= 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-256-e6qEdUAWNMelND6yoi6pnQ-1; Wed, 04 Nov 2020 13:41:49 -0500 X-MC-Unique: e6qEdUAWNMelND6yoi6pnQ-1 Received: by mail-wr1-f70.google.com with SMTP id w3so7464224wrt.11 for ; Wed, 04 Nov 2020 10:41:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kxx7KBtrm7vYLNNi8ILRStjcIKIqdM/KqZjCc2FDurE=; b=TvnFwjqRG2X0szWqq3I0tX1lZfeEwzVHb73RRWfzMxTsVlsNO457P4oVzixEUi79DJ v1nQkGkQeIne7pqPCTDWKWFVz9JPBgFaUw70FOYESyzBjAaAQ8ymbOQ2I3ULwqY3gSuP wbh1UFE2CbeSs9jz8LIXLC1wW3XdwPodjm3wH5mmxWO1wtRgotO0atcdstta9h9cJ1ha KDVWZFDG5qBwDoP153imaPOctXyIB4LSaXJfGH+0WjBoG07VoDgBJHAtQtSl1bboxKUJ XlE8KUx3e0B0449cKchzqWD9b4e5U4tC7D78OViITq6E4vorB2ojFEdiqTnPMhuEuW7m ZVew== X-Gm-Message-State: AOAM530jEr9CnnG/dtU1zp12nR4pnGnFOvkbL1RRCygY3RZ+x9TD3zzg z5jTjbZ4gBAeUvd9pwlxdFNbYFY6+Ic9nMKc7sqDdudUARHBoPkgfG+AI7RkFL0ACyIldR7l/d7 I/u2zVxlcEqY7Kxg= X-Received: by 2002:a5d:4a4b:: with SMTP id v11mr4991421wrs.364.1604515308323; Wed, 04 Nov 2020 10:41:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfwnDOViGTq5wQ3OuZ0qzf8RSJNybaKD314ntar/NDYKJx3NbK1KJRPQZKq/HvZaRGWJAgEA== X-Received: by 2002:a5d:4a4b:: with SMTP id v11mr4991398wrs.364.1604515308126; Wed, 04 Nov 2020 10:41:48 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id e25sm4060413wrc.76.2020.11.04.10.41.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:41:47 -0800 (PST) Date: Wed, 4 Nov 2020 13:41:45 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 10/31] hw/acpi : add spaces around operator Message-ID: <20201104184040.285057-11-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov , Kai Deng , Xinhao Zhang Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Xinhao Zhang Fix code style. Operator needs spaces both sides. Signed-off-by: Xinhao Zhang Signed-off-by: Kai Deng Message-Id: <20201103102634.273021-3-zhangxinhao1@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/pcihp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 32ae8b2c0a..17c32e0ffd 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -400,7 +400,7 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *s, PCIBus *root_bus, s->io_len = ACPI_PCIHP_SIZE; s->io_base = ACPI_PCIHP_ADDR; - s->root= root_bus; + s->root = root_bus; s->legacy_piix = !bridges_enabled; memory_region_init_io(&s->io, owner, &acpi_pcihp_io_ops, s, From patchwork Wed Nov 4 18:41:51 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: 318575 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF4F3C2D0A3 for ; Wed, 4 Nov 2020 18:53:15 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2A4ED2087D for ; Wed, 4 Nov 2020 18:53:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="R8tZFxyC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2A4ED2087D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNuE-0002UK-3l for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 13:53:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNjM-0000wU-4F for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:51578) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNjK-00020a-Az for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:41:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515317; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QTkwT/HJ1lj3VKT9unaRe9zAEsq3t6jIEnXFjz8fDHg=; b=R8tZFxyCgwj9VbBQSeTQi7E7yxR1t39mEAvYv09OSIp+R4EtnDfxTCjWIRu3oklhRi8iXI lFjZUCgzchgWpmT1IUtY515WzleC2ACArl5QdeNQzb0OxmiLynxGq8ZEe4n0AVb8A60oI7 mrqOBeJWtbeJn2PiZFR33VmYQo3u8NY= 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-518-jCDQI1k2MeS7ZPbyRftYug-1; Wed, 04 Nov 2020 13:41:55 -0500 X-MC-Unique: jCDQI1k2MeS7ZPbyRftYug-1 Received: by mail-wr1-f69.google.com with SMTP id y6so333920wrt.22 for ; Wed, 04 Nov 2020 10:41:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=QTkwT/HJ1lj3VKT9unaRe9zAEsq3t6jIEnXFjz8fDHg=; b=Jh4Xgct+b8iM+LI/9D+FA5pw/5wQu2rQdoVtHA0CXa2ZfqNzeZBStnlsIw2YU/+PNR 8AYwfVo1cP/29K//t/zv2ju3OFSpbXOBwosctltvGD2FgBTmTxfAf0RQ9TPv8gPr+XRp 8+HSfvYlGhuHckVevyXh1Jp1VJYFra7LajllNQD0xPbMSqfkJrjXQ/C2ybN07BsBfYvV J1ae9J+2VkbYPGGlS5yKhc2Bt7XlGNb3ZWZZOAjdSss8Xpg9gFuE93LeX/BeKI+NspB6 fA6hoUmjqymhjC+lk39E7EOP1GKDtGdsKHulZrZZlkldgErCf7lpr2SI5NqsBhjLWgoG Xi5Q== X-Gm-Message-State: AOAM530573cH5BiN7o4NvSTQHBr6Dmgc57eBus9s4lo8SNugMJFoKj+U h4jiF17WC1SrUBUPiSnYa1QIiSR/IQ2H821x2X70nHPALbRqEoNVEBpNPpfHorvp5be87B17Y1U Kwr8KhOfUBWd+iPw= X-Received: by 2002:a7b:c94d:: with SMTP id i13mr6019966wml.130.1604515314002; Wed, 04 Nov 2020 10:41:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFR7fPeQqqsaG9WxompWLgjuhwXhyM5RHygM2F5QD4TQDWTWvj/J4JhM76QDAdioSNR0HahA== X-Received: by 2002:a7b:c94d:: with SMTP id i13mr6019955wml.130.1604515313871; Wed, 04 Nov 2020 10:41:53 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id n9sm3311248wmd.4.2020.11.04.10.41.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:41:53 -0800 (PST) Date: Wed, 4 Nov 2020 13:41:51 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 12/31] hw/smbios: Fix leaked fd in save_opt_one() error path Message-ID: <20201104184040.285057-13-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Laszlo Ersek , Stefano Garzarella Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Fix the following Coverity issue (RESOURCE_LEAK): CID 1432879: Resource leak Handle variable fd going out of scope leaks the handle. Replace a close() call by qemu_close() since the handle is opened with qemu_open(). Fixes: bb99f4772f5 ("hw/smbios: support loading OEM strings values from a file") Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20201030152742.1553968-1-philmd@redhat.com> Reviewed-by: Stefano Garzarella Reviewed-by: Laszlo Ersek Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/smbios/smbios.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 8b30906e50..6a3d39793b 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -988,16 +988,18 @@ static int save_opt_one(void *opaque, if (ret < 0) { error_setg(errp, "Unable to read from %s: %s", value, strerror(errno)); + qemu_close(fd); return -1; } if (memchr(buf, '\0', ret)) { error_setg(errp, "NUL in OEM strings value in %s", value); + qemu_close(fd); return -1; } g_byte_array_append(data, (guint8 *)buf, ret); } - close(fd); + qemu_close(fd); *opt->dest = g_renew(char *, *opt->dest, (*opt->ndest) + 1); (*opt->dest)[*opt->ndest] = (char *)g_byte_array_free(data, FALSE); From patchwork Wed Nov 4 18:41:54 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: 320561 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp5665830ilc; Wed, 4 Nov 2020 10:46:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/PIIg3aTL8kdgKVOnjjZo2Aqdlv9vRuSiAv7D1Cweyuy14rd2izH/vdxd+LA21Ne7G5rC X-Received: by 2002:a25:4085:: with SMTP id n127mr37000001yba.342.1604515600635; Wed, 04 Nov 2020 10:46:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604515600; cv=none; d=google.com; s=arc-20160816; b=qTtD/a7UrGovgfe5Yrt6/xhW/4z63Mt4O7vQYaXHz6rFUCZa8CgR2y0exJ02S/M2fw 8FrtNwxLdkJHVkmVM19Jnf70hrWhy69jdYk2CGUNssquzFFNAvZb8/xN8dyPHmG/3aCo cbNt5hkml5vNp3GivVW/5CBmnrMo2Lhk7fZeR1jYlTPto2N+GrQNHP5aAzgZdUoj068F m0+R7L9WQOlrsF32K77mhV92M78VKnkPb86F/vTYZOqg0FhiCoXSqTucc35N4A+OSSIt 6CtT+wJE+1mOI5/gFMwRL8B62Dq6zvGUQIR/ehSBd7lrtKzARdtk3La/iyZAJJCcShBS DCeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition:in-reply-to :mime-version:references:message-id:subject:to:from:date :dkim-signature; bh=yb0+hTu/cI4h7Se3wHsf9S5j6pZCfXhlBpQERrIdWig=; b=Ajfv+4vIJOfk98urhIAoRu/12dnpoTSCl5dKCVEhFPh2rcuuMPmNpcDg8KS9Vq7y0V tvxoThvXrXQJlr78kqniBg44mqA//hTuQxewZoEedbIO2TORUcmI7H1BvHKvf6G4pSmV F712yIWtuuLWlLnHQJ/UgnlCHWp0ORt59Uu8pvTXcE0oHVOgKcMNw6BmIUlZLJcp+Sc/ IZRBgby8rmPgJt/91OZ8LVqikpweD/7APMqnKNDJDkF3WmzN42tsLO1vXJ27ecirq43p pmbpg0Wk666qdW0pV5CGUCfNYyFDcvqOMKlsaHTkB2ihbe2hC7HyAvoSsP/H7vlRB2B3 TZEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=MRbU3cYV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u63si526735ybb.61.2020.11.04.10.46.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Nov 2020 10:46:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=MRbU3cYV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:60754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNns-00076K-48 for patch@linaro.org; Wed, 04 Nov 2020 13:46:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNjQ-00013X-3O for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51785) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNjN-00021Y-JY for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515320; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yb0+hTu/cI4h7Se3wHsf9S5j6pZCfXhlBpQERrIdWig=; b=MRbU3cYVzV0jXCS9m2CfwP8f7C5/Cy1I6OKsGO1zcsL690eKhcqAsf4iKsnt5SKsF2DVJ2 4kZ+pRTIE+MHKQ5cWWI5DjBae4dyQNudkCEWFEpcpdqHB3JtxDMsfEypqaOVq2KPwPsI2K Ke2hLCSM6G/iyN3cwdx/x4ZkaqFseII= 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-225-IyBkSYblOSmNp14Ouqg0Pw-1; Wed, 04 Nov 2020 13:41:58 -0500 X-MC-Unique: IyBkSYblOSmNp14Ouqg0Pw-1 Received: by mail-wr1-f72.google.com with SMTP id h8so9633835wrt.9 for ; Wed, 04 Nov 2020 10:41:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=yb0+hTu/cI4h7Se3wHsf9S5j6pZCfXhlBpQERrIdWig=; b=ltzwDKvMtSb7uLM0yDVKE4d0yhlI150eW7WG9a1gBCysDISR8qYFjHpiHC6Kkghzku fFBQHaFfaGvXMzLpzhKPXHU2L8K0x2rpcGcV/DUZnYverjHx1amLL3JgjRzfUqH3xMi4 lVZgIHhFWMKXmMvs8IidqzPIhT+gmEYwexcxqOAh0L8SFqFxgASGcYrEQgxefmVw2j8M QmsOCQqhIN8e6dzn0bBpYkKJO7Ev8CAV9GNvuV/E75COu/6CN4RhsObhsoYX3ZmZ3Tl5 yizTpiezPd5G81ZtWErd/u2CjwEqKMZJEPUIgFUNT79bHzSem4s3wgWNcRQZ2yzWCGXl nwmw== X-Gm-Message-State: AOAM53184gSD2fZyjy35paVJIA1NIo/i14WV3wbnusGDNrpuH+tEnfHW BJUjrK3vYBJ8o81zR9AZ1M11zWuJXntjNHl5pzAzfNbXWGNCvDM4mkqwADORI6WZ7lJ4W+dxEaj uFuViuf7Tsi96In0= X-Received: by 2002:adf:a551:: with SMTP id j17mr35913506wrb.217.1604515317026; Wed, 04 Nov 2020 10:41:57 -0800 (PST) X-Received: by 2002:adf:a551:: with SMTP id j17mr35913491wrb.217.1604515316845; Wed, 04 Nov 2020 10:41:56 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id u23sm3158102wmc.22.2020.11.04.10.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:41:56 -0800 (PST) Date: Wed, 4 Nov 2020 13:41:54 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 13/31] virtio-iommu: Fix virtio_iommu_mr() Message-ID: <20201104184040.285057-14-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Peter Xu , QEMU Stable , Eric Auger , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Jean-Philippe Brucker Due to an invalid mask, virtio_iommu_mr() may return the wrong memory region. It hasn't been too problematic so far because the function was only used to test existence of an endpoint, but that is about to change. Fixes: cfb42188b24d ("virtio-iommu: Implement attach/detach command") Cc: QEMU Stable Acked-by: Eric Auger Reviewed-by: Peter Xu Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-2-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- MST diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 21ec63b108..4c8f3909b7 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -101,7 +101,7 @@ static IOMMUMemoryRegion *virtio_iommu_mr(VirtIOIOMMU *s, uint32_t sid) bus_n = PCI_BUS_NUM(sid); iommu_pci_bus = iommu_find_iommu_pcibus(s, bus_n); if (iommu_pci_bus) { - devfn = sid & PCI_DEVFN_MAX; + devfn = sid & (PCI_DEVFN_MAX - 1); dev = iommu_pci_bus->pbdev[devfn]; if (dev) { return &dev->iommu_mr; From patchwork Wed Nov 4 18:41:57 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: 320562 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp5667113ilc; Wed, 4 Nov 2020 10:49:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJylgQveusRJXbyfmDQv7LyIRL/QN1fbWhHEsX/S0JdXR/fWz8rT315qd4QLe2OUqLHddpec X-Received: by 2002:a5b:f4f:: with SMTP id y15mr7654462ybr.226.1604515741932; Wed, 04 Nov 2020 10:49:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604515741; cv=none; d=google.com; s=arc-20160816; b=z0ZP3zg3PbmfXTDYrAJJcGI1qPY++2myoL6uWdpwBSSM3+bMq3KGoRcIhrtyLIck6U sTnidcfsfUL0Ju0+GOeXYgbIB9LkziW+ye/2xdFFx3JNZnbAF5I1o1XvON+kHinM+fjl LLU5bHcYozMTskszl6Eyy07ND8UlXVGgE6rHl1ZHnyTs2ms2sUbeJ5xoMTkeKwK9clFf OJu8Z6vwFbMWV0TVMsHeYLQpIKuDd9Qxd8gtnAENpOtJtbO2bkjOATuIjGrDft/kIAnk Ri4NRsCQMKDWwWZ3rnYzmBpoMlfI080kXaNU6KGlgh9BG9ZhVmAX5dtD5dbFxvwgATgl dldQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition:in-reply-to :mime-version:references:message-id:subject:to:from:date :dkim-signature; bh=tvJ0s3bSV9g9bsoYugn7fOSbhCEdSfwOqB79D2kkBqw=; b=ntt6GZZgFvovMobpEyOpJPBU+Epg3pe6cR7YL0jfJuk7IneOUCXngxrlA5saDSU18T PUmU4fXLNn52mBu3aJTKabxS7NxxbJj6pvmFT6MWUrJn9Hje/kNlMuH9V1QdVZdK0oZi C49dt7/wCi+sUYXmK8Qwiz91ebxkiwFqbyMPmhTLYvM2T7RM41NByuHB9crMLHl39Yvg ipz8T3XoHbhLz+3dwYO/D/XKNQJkUAerzBf+HUIFL0Kp8kpGnO01f9+u5kXzXZsYo4cg BYU8gv57gnEoh2RNGZ2lBV64Foi3DGHke4veChK0sCFasOvsBGlgG++P/ubv4geAeoyU joZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=QSSLW0JQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j18si3001138ybm.276.2020.11.04.10.49.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Nov 2020 10:49:01 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=QSSLW0JQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:41010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNq9-00029N-BB for patch@linaro.org; Wed, 04 Nov 2020 13:49:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNjS-00016X-E0 for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:23010) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNjP-00022Y-Vt for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515323; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tvJ0s3bSV9g9bsoYugn7fOSbhCEdSfwOqB79D2kkBqw=; b=QSSLW0JQcsLfV8t2b3++I3hq+uDC/IKOJKXXSda0HJaXrATW5hVFxLHzt3OUMY00WuHpST yqV7TvuwdxPZG5lW3RJ5K8Bvz9gKf1z6BL4s83ys9bwwjMri1ZYtBeaptT9fyOv0a3cvrW QOVvHa+drUCmXuhvo+o5hGvB1xrH0c8= 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-306-feUFggKJNGSwbSMd1jKBSA-1; Wed, 04 Nov 2020 13:42:01 -0500 X-MC-Unique: feUFggKJNGSwbSMd1jKBSA-1 Received: by mail-wr1-f72.google.com with SMTP id h8so9633889wrt.9 for ; Wed, 04 Nov 2020 10:42:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tvJ0s3bSV9g9bsoYugn7fOSbhCEdSfwOqB79D2kkBqw=; b=lm9vumkS8YTvaYJ6kvp8vbkIbzCe7QT6Aag2kXzAg1WWyeloW30E6rDgj7urmCCBJq tQwVE5LBIEe1UG9wHtBxQA0I/caxoP0j1mbfMlVUd6ifvPq0s55DC9MgIVwzwxlRuqlq u6SSDOfSOD0Wtugji8i41Kfn1UoNDVFg6fIGECaWw2DFjbE6IiVkN5VuNdj4bO5mUXHu M+vhPqtOqimNBd7lZVfkA9Wcqgta/d/Ms+OnyPQ9UkSDv4sFSyFUE8r6Gw0S8lvBLvWq gHSI0ZchTPSc2EFn63DtXYJ0RVEp4RWESvPyQaZ4Hf9KSk3Lrf3k9xAuwuVxzBfObuVp lXdw== X-Gm-Message-State: AOAM531ou/HpITKp4FDbHNYuuCYbqqoNPce06aBn5EAxxPWvsg00a69+ coTfin80YKA/DZVEJOl6qFYI1rw1j+2pCjaYgBNS4R+q3wuGavJEogBg1koLvttoTOiO6W1Qov6 l+PN+wtDVL9oyjwQ= X-Received: by 2002:a05:6000:1109:: with SMTP id z9mr31002987wrw.388.1604515319654; Wed, 04 Nov 2020 10:41:59 -0800 (PST) X-Received: by 2002:a05:6000:1109:: with SMTP id z9mr31002970wrw.388.1604515319464; Wed, 04 Nov 2020 10:41:59 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id z5sm3862094wrw.87.2020.11.04.10.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:41:58 -0800 (PST) Date: Wed, 4 Nov 2020 13:41:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 14/31] virtio-iommu: Store memory region in endpoint struct Message-ID: <20201104184040.285057-15-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eric Auger , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Jean-Philippe Brucker Store the memory region associated to each endpoint into the endpoint structure, to allow efficient memory notification on map/unmap. Acked-by: Eric Auger Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-3-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) -- MST diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 4c8f3909b7..a5c2d69aad 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -49,6 +49,7 @@ typedef struct VirtIOIOMMUDomain { typedef struct VirtIOIOMMUEndpoint { uint32_t id; VirtIOIOMMUDomain *domain; + IOMMUMemoryRegion *iommu_mr; QLIST_ENTRY(VirtIOIOMMUEndpoint) next; } VirtIOIOMMUEndpoint; @@ -137,16 +138,19 @@ static VirtIOIOMMUEndpoint *virtio_iommu_get_endpoint(VirtIOIOMMU *s, uint32_t ep_id) { VirtIOIOMMUEndpoint *ep; + IOMMUMemoryRegion *mr; ep = g_tree_lookup(s->endpoints, GUINT_TO_POINTER(ep_id)); if (ep) { return ep; } - if (!virtio_iommu_mr(s, ep_id)) { + mr = virtio_iommu_mr(s, ep_id); + if (!mr) { return NULL; } ep = g_malloc0(sizeof(*ep)); ep->id = ep_id; + ep->iommu_mr = mr; trace_virtio_iommu_get_endpoint(ep_id); g_tree_insert(s->endpoints, GUINT_TO_POINTER(ep_id), ep); return ep; @@ -910,9 +914,14 @@ static gboolean reconstruct_endpoints(gpointer key, gpointer value, VirtIOIOMMU *s = (VirtIOIOMMU *)data; VirtIOIOMMUDomain *d = (VirtIOIOMMUDomain *)value; VirtIOIOMMUEndpoint *iter; + IOMMUMemoryRegion *mr; QLIST_FOREACH(iter, &d->endpoint_list, next) { + mr = virtio_iommu_mr(s, iter->id); + assert(mr); + iter->domain = d; + iter->iommu_mr = mr; g_tree_insert(s->endpoints, GUINT_TO_POINTER(iter->id), iter); } return false; /* continue the domain traversal */ From patchwork Wed Nov 4 18:41:59 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: 318582 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10110C2D0A3 for ; Wed, 4 Nov 2020 18:45:58 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 589C320780 for ; Wed, 4 Nov 2020 18:45:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cZ3vF2HC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 589C320780 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNn7-00075K-3h for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 13:45:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNjV-0001B0-AJ for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54295) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNjT-00022q-3X for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515326; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2pTrzfIlEtuFgKli+YZx2cSmkYnPe9QRNfZXCU2zweM=; b=cZ3vF2HCKtQntqgCDd5vb+EWifsF0jNsCZ3AwB64ZufiSgPujdseq/0zE5A7hGko1vBMG6 lIEF++iIjkxUWqnFjEaTITN0L2qYelrTDQDU5w5Qw3AUgtH7ClMsDA+wBfoOO5le1mn1nh WokKejqZrOimigG6e7zJ86HV0yv9MJQ= 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-573-srUypeYDPhu4YyjNO7UwNQ-1; Wed, 04 Nov 2020 13:42:04 -0500 X-MC-Unique: srUypeYDPhu4YyjNO7UwNQ-1 Received: by mail-wm1-f69.google.com with SMTP id b68so935657wme.5 for ; Wed, 04 Nov 2020 10:42:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2pTrzfIlEtuFgKli+YZx2cSmkYnPe9QRNfZXCU2zweM=; b=Igyc8atdaKHHoOfvvpxg2Y5G0qSDQIYWncOMFyz8uvIKiRz4SpR4PiRqJ3A/sQuKyP dyAF6ROFWY2tIsFdCIq4/7nqU3A0oqg2nIJENEZ2hNXh0JrKNnlDYkO23noBsmuL4anV NFSh8kw06T2FINBcr/k0AaOOEixGauZz9kDMknM5Bo0h4FORCRIh1ePgmMrBobFdHYNY eVwOFKNtiOD4JIK+Xka8ZbbSVvnCqxSltBBpSBUfeY8h4HNm2MtEXQCK1IuqsQy+W9xg 8Db3S8eDkv5pSIQKdllsxlkt9XrRNh/+Id2VPuiDn0ZwZ0jkVbLzAWXlj26uex/PD9pb xFtA== X-Gm-Message-State: AOAM533eYAzBk5pRxTEjAAtF5OlFqA/rIO8ZVw35dzL7nafJ+andIs0L kZRyFyK/PynNtloAAHhjvzhgwbWcnVZyk5str+T3QQYi7vO1ghAt1BzXuwmy1rLOBOV2/wXGjLj +VE9QnUo7BxBQijc= X-Received: by 2002:a7b:cf1a:: with SMTP id l26mr6130271wmg.18.1604515322415; Wed, 04 Nov 2020 10:42:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9alEUfDA2spCSmp2WbOKx3dYz18jI494EiudIwOA/3w9Ccp/B6z3/vUoruwqPU2EsQjclkQ== X-Received: by 2002:a7b:cf1a:: with SMTP id l26mr6130253wmg.18.1604515322242; Wed, 04 Nov 2020 10:42:02 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id 90sm3953924wrl.30.2020.11.04.10.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:42:01 -0800 (PST) Date: Wed, 4 Nov 2020 13:41:59 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 15/31] virtio-iommu: Add memory notifiers for map/unmap Message-ID: <20201104184040.285057-16-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Bharat Bhushan , Jean-Philippe Brucker , Eric Auger Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bharat Bhushan Extend VIRTIO_IOMMU_T_MAP/UNMAP request to notify memory listeners. It will call VFIO notifier to map/unmap regions in the physical IOMMU. Signed-off-by: Bharat Bhushan Signed-off-by: Eric Auger Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-4-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 56 ++++++++++++++++++++++++++++++++++++++++ hw/virtio/trace-events | 2 ++ 2 files changed, 58 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index a5c2d69aad..7dd15c5eac 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -125,6 +125,51 @@ static gint interval_cmp(gconstpointer a, gconstpointer b, gpointer user_data) } } +static void virtio_iommu_notify_map(IOMMUMemoryRegion *mr, hwaddr virt_start, + hwaddr virt_end, hwaddr paddr, + uint32_t flags) +{ + IOMMUTLBEntry entry; + IOMMUAccessFlags perm = IOMMU_ACCESS_FLAG(flags & VIRTIO_IOMMU_MAP_F_READ, + flags & VIRTIO_IOMMU_MAP_F_WRITE); + + if (!(mr->iommu_notify_flags & IOMMU_NOTIFIER_MAP) || + (flags & VIRTIO_IOMMU_MAP_F_MMIO) || !perm) { + return; + } + + trace_virtio_iommu_notify_map(mr->parent_obj.name, virt_start, virt_end, + paddr, perm); + + entry.target_as = &address_space_memory; + entry.addr_mask = virt_end - virt_start; + entry.iova = virt_start; + entry.perm = perm; + entry.translated_addr = paddr; + + memory_region_notify_iommu(mr, 0, entry); +} + +static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start, + hwaddr virt_end) +{ + IOMMUTLBEntry entry; + + if (!(mr->iommu_notify_flags & IOMMU_NOTIFIER_UNMAP)) { + return; + } + + trace_virtio_iommu_notify_unmap(mr->parent_obj.name, virt_start, virt_end); + + entry.target_as = &address_space_memory; + entry.addr_mask = virt_end - virt_start; + entry.iova = virt_start; + entry.perm = IOMMU_NONE; + entry.translated_addr = 0; + + memory_region_notify_iommu(mr, 0, entry); +} + static void virtio_iommu_detach_endpoint_from_domain(VirtIOIOMMUEndpoint *ep) { if (!ep->domain) { @@ -315,6 +360,7 @@ static int virtio_iommu_map(VirtIOIOMMU *s, VirtIOIOMMUDomain *domain; VirtIOIOMMUInterval *interval; VirtIOIOMMUMapping *mapping; + VirtIOIOMMUEndpoint *ep; if (flags & ~VIRTIO_IOMMU_MAP_F_MASK) { return VIRTIO_IOMMU_S_INVAL; @@ -344,6 +390,11 @@ static int virtio_iommu_map(VirtIOIOMMU *s, g_tree_insert(domain->mappings, interval, mapping); + QLIST_FOREACH(ep, &domain->endpoint_list, next) { + virtio_iommu_notify_map(ep->iommu_mr, virt_start, virt_end, phys_start, + flags); + } + return VIRTIO_IOMMU_S_OK; } @@ -356,6 +407,7 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s, VirtIOIOMMUMapping *iter_val; VirtIOIOMMUInterval interval, *iter_key; VirtIOIOMMUDomain *domain; + VirtIOIOMMUEndpoint *ep; int ret = VIRTIO_IOMMU_S_OK; trace_virtio_iommu_unmap(domain_id, virt_start, virt_end); @@ -373,6 +425,10 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s, uint64_t current_high = iter_key->high; if (interval.low <= current_low && interval.high >= current_high) { + QLIST_FOREACH(ep, &domain->endpoint_list, next) { + virtio_iommu_notify_unmap(ep->iommu_mr, current_low, + current_high); + } g_tree_remove(domain->mappings, iter_key); trace_virtio_iommu_unmap_done(domain_id, current_low, current_high); } else { diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index cf1e59de30..b87a397406 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -106,6 +106,8 @@ virtio_iommu_put_domain(uint32_t domain_id) "Free domain=%d" virtio_iommu_translate_out(uint64_t virt_addr, uint64_t phys_addr, uint32_t sid) "0x%"PRIx64" -> 0x%"PRIx64 " for sid=%d" virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoint, uint64_t addr) "FAULT reason=%d flags=%d endpoint=%d address =0x%"PRIx64 virtio_iommu_fill_resv_property(uint32_t devid, uint8_t subtype, uint64_t start, uint64_t end) "dev= %d, type=%d start=0x%"PRIx64" end=0x%"PRIx64 +virtio_iommu_notify_map(const char *name, uint64_t virt_start, uint64_t virt_end, uint64_t phys_start, uint32_t flags) "mr=%s virt_start=0x%"PRIx64" virt_end=0x%"PRIx64" phys_start=0x%"PRIx64" flags=%d" +virtio_iommu_notify_unmap(const char *name, uint64_t virt_start, uint64_t virt_end) "mr=%s virt_start=0x%"PRIx64" virt_end=0x%"PRIx64 # virtio-mem.c virtio_mem_send_response(uint16_t type) "type=%" PRIu16 From patchwork Wed Nov 4 18:42:02 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: 318579 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95CB5C4741F for ; Wed, 4 Nov 2020 18:49:26 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 10F6420782 for ; Wed, 4 Nov 2020 18:49:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DUDnYRb5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 10F6420782 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNqW-0003tC-S3 for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 13:49:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNjW-0001Ey-Qx for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59399) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNjV-00024L-2i for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515328; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=CO5kV6TOgl7VkllXO+Cj7QHVQ3FQj45OIYdaYC1hBZU=; b=DUDnYRb5dlNZEUo1kejlk8cKALQkv4EIJ/XM61VULaaDkssG1pGJZRFqujvzeYX9JJANHA dDiJpW+sRxt+8P0eb1LrB7OMig0nj3hVvvwdcJeKyL9ghdDs48GWLcYLS0MFxvWxJSLpI4 VBWrKSids7I4xmt9+oivVXpcqgAFnn8= 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-249-aXbbKZ2lOfWTzlk-zCGouQ-1; Wed, 04 Nov 2020 13:42:06 -0500 X-MC-Unique: aXbbKZ2lOfWTzlk-zCGouQ-1 Received: by mail-wr1-f69.google.com with SMTP id i1so9580059wrb.18 for ; Wed, 04 Nov 2020 10:42:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CO5kV6TOgl7VkllXO+Cj7QHVQ3FQj45OIYdaYC1hBZU=; b=md0nMy27Y6IjYzpvPLG6+U9sFZFg3/5p9nxdKv22NRrI0p+3JqXcmxmRlcXfTGTrKR ZSVN4Y/xZEsAQa3ehQv4TGcpaJNv3Tc1+cD9S2Vt3qz1LPgXXL51ED7N5+KY9rocYSk7 gJpJBwUV1n+3wd2rN5+NwCOBYEWYhJwF5EBvCpHY095IxJxzstJ5q2aSqsdb3czAzxgo HQV06J0Jrel/4ZvXH/X9/HDBOHNoBRLKj7AZ+RcoSpJxk2TuEvkX1/W4w2t0/YWdTPkA PJ6CJqGmA8Sn1pJQv2TzKSwX1/YnPKoNJyxozTWI9IrRlr08PB1It1xCpKWCEGmbJ9Rc KtUQ== X-Gm-Message-State: AOAM532rzNVAZSyG7mdPKlwr9qCjU4EWO19DbkYeTT60VLn8LScnEeKd ewLR7dn8GCV11gHBxKgXpVjoPt6oc3UIt5Tu05T7Qkm43iav+PbtD8SP9i7faqNmhflaDoL210t zRw4urVHGX+Q4oLA= X-Received: by 2002:a5d:60c4:: with SMTP id x4mr35830536wrt.175.1604515325236; Wed, 04 Nov 2020 10:42:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6Dy0F6GR6UnqLZn65rM3HddEm7KF9VRexPdu3AzmNkvreR//Gh71T88/RO8sqh10JPmWtog== X-Received: by 2002:a5d:60c4:: with SMTP id x4mr35830517wrt.175.1604515325041; Wed, 04 Nov 2020 10:42:05 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id l1sm4146616wrb.1.2020.11.04.10.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:42:04 -0800 (PST) Date: Wed, 4 Nov 2020 13:42:02 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 16/31] virtio-iommu: Call memory notifiers in attach/detach Message-ID: <20201104184040.285057-17-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Bharat Bhushan , Eric Auger , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bharat Bhushan Call the memory notifiers when attaching an endpoint to a domain, to replay existing mappings, and when detaching the endpoint, to remove all mappings. Signed-off-by: Bharat Bhushan Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-5-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 7dd15c5eac..7b64892351 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -170,11 +170,39 @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start, memory_region_notify_iommu(mr, 0, entry); } +static gboolean virtio_iommu_notify_unmap_cb(gpointer key, gpointer value, + gpointer data) +{ + VirtIOIOMMUInterval *interval = (VirtIOIOMMUInterval *) key; + IOMMUMemoryRegion *mr = (IOMMUMemoryRegion *) data; + + virtio_iommu_notify_unmap(mr, interval->low, interval->high); + + return false; +} + +static gboolean virtio_iommu_notify_map_cb(gpointer key, gpointer value, + gpointer data) +{ + VirtIOIOMMUMapping *mapping = (VirtIOIOMMUMapping *) value; + VirtIOIOMMUInterval *interval = (VirtIOIOMMUInterval *) key; + IOMMUMemoryRegion *mr = (IOMMUMemoryRegion *) data; + + virtio_iommu_notify_map(mr, interval->low, interval->high, + mapping->phys_addr, mapping->flags); + + return false; +} + static void virtio_iommu_detach_endpoint_from_domain(VirtIOIOMMUEndpoint *ep) { + VirtIOIOMMUDomain *domain = ep->domain; + if (!ep->domain) { return; } + g_tree_foreach(domain->mappings, virtio_iommu_notify_unmap_cb, + ep->iommu_mr); QLIST_REMOVE(ep, next); ep->domain = NULL; } @@ -317,6 +345,10 @@ static int virtio_iommu_attach(VirtIOIOMMU *s, ep->domain = domain; + /* Replay domain mappings on the associated memory region */ + g_tree_foreach(domain->mappings, virtio_iommu_notify_map_cb, + ep->iommu_mr); + return VIRTIO_IOMMU_S_OK; } From patchwork Wed Nov 4 18:42:05 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: 318577 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03BF4C2D0A3 for ; Wed, 4 Nov 2020 18:51:13 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 67D1120780 for ; Wed, 4 Nov 2020 18:51:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MUEsKFTC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 67D1120780 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNsF-0007N2-Da for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 13:51:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNjb-0001R0-SO for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:20663) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNjZ-00024z-Vl for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515333; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Vj2K5KfIjYgXaS/HA+9u99+5hxZOJUDzQMD8f8h61Sg=; b=MUEsKFTCL/rcxWBF43Z3+y7/rssEBtRUJxzxXtesoiLERF1rRnSipC9n0JY6RvyEiQojpS zOAxuBngB3Tg5C12bxS9hKOksuL2RU4qBK3S0vtbbBh3E8s09koeM9FyLSqrWmmJyYFnfk 1OyUITQ6OKq58H12C4KHHcj9FdE/xA4= 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-6-S_RWgsFPNTOzkJWRRt81hw-1; Wed, 04 Nov 2020 13:42:11 -0500 X-MC-Unique: S_RWgsFPNTOzkJWRRt81hw-1 Received: by mail-wm1-f71.google.com with SMTP id h2so244629wmm.0 for ; Wed, 04 Nov 2020 10:42:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Vj2K5KfIjYgXaS/HA+9u99+5hxZOJUDzQMD8f8h61Sg=; b=bZUWeUlHsHsP4rh0smW9QemJe22rdL0YR1CjN5o0vmOvhxtRwEtrbkzxJEqiKAh2G7 l2UxSKomnRvLeBoNG3TZFK0SIU/Jl2EoumieuNq+OcTySraLdYnirwSD7S4YgYKHTI9F kuAW2Gwy6JnM2nFZRwfhBt0K2MJTYjP6i9vzv2gHb1j3xpvLA2Vhc2yWuMFQOxmVNoFV M+wt/7b8ijdV5NwxW+LOdDztGxcI+Zw2k3FeTcKiV1OwxDHuBy3PUdc/oOjjTmjHaXkP uz4d5Xu5GOJ015WNZ5EBcZZPQ33ucKLImEUGPZK+U5RqSuSLLZWuANclWUNSYkH4Q9oB OlvQ== X-Gm-Message-State: AOAM531BOew0ZdWl42I88NXB0Jy361iPt7R6sXMLaJYbQvOI/1GNe8hH T9g82TtF52MhGg7mOFiNJ43E9dTjlHi/ngokppDOsVBNQFVsfIlxKGlpcKAxIlXXyE9MuuYaAJe v004QfG+64m8Op1k= X-Received: by 2002:a1c:6484:: with SMTP id y126mr5783450wmb.141.1604515328315; Wed, 04 Nov 2020 10:42:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyETqU7jriIrUGsEzO4NqKeLs3NeylEWNekcUqojm5WU2hKvOUPsHgFOZPXjqQOBip5rlA9Dg== X-Received: by 2002:a1c:6484:: with SMTP id y126mr5783433wmb.141.1604515328141; Wed, 04 Nov 2020 10:42:08 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id u5sm3261102wml.13.2020.11.04.10.42.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:42:07 -0800 (PST) Date: Wed, 4 Nov 2020 13:42:05 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 17/31] virtio-iommu: Add replay() memory region callback Message-ID: <20201104184040.285057-18-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Bharat Bhushan , Eric Auger , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bharat Bhushan Implement the replay callback to setup all mappings for a new memory region. Signed-off-by: Bharat Bhushan Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-6-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 40 ++++++++++++++++++++++++++++++++++++++++ hw/virtio/trace-events | 1 + 2 files changed, 41 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 7b64892351..985257c88f 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -847,6 +847,45 @@ static gint int_cmp(gconstpointer a, gconstpointer b, gpointer user_data) return (ua > ub) - (ua < ub); } +static gboolean virtio_iommu_remap(gpointer key, gpointer value, gpointer data) +{ + VirtIOIOMMUMapping *mapping = (VirtIOIOMMUMapping *) value; + VirtIOIOMMUInterval *interval = (VirtIOIOMMUInterval *) key; + IOMMUMemoryRegion *mr = (IOMMUMemoryRegion *) data; + + trace_virtio_iommu_remap(mr->parent_obj.name, interval->low, interval->high, + mapping->phys_addr); + virtio_iommu_notify_map(mr, interval->low, interval->high, + mapping->phys_addr, mapping->flags); + return false; +} + +static void virtio_iommu_replay(IOMMUMemoryRegion *mr, IOMMUNotifier *n) +{ + IOMMUDevice *sdev = container_of(mr, IOMMUDevice, iommu_mr); + VirtIOIOMMU *s = sdev->viommu; + uint32_t sid; + VirtIOIOMMUEndpoint *ep; + + sid = virtio_iommu_get_bdf(sdev); + + qemu_mutex_lock(&s->mutex); + + if (!s->endpoints) { + goto unlock; + } + + ep = g_tree_lookup(s->endpoints, GUINT_TO_POINTER(sid)); + if (!ep || !ep->domain) { + goto unlock; + } + + g_tree_foreach(ep->domain->mappings, virtio_iommu_remap, mr); + +unlock: + qemu_mutex_unlock(&s->mutex); +} + static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); @@ -1076,6 +1115,7 @@ static void virtio_iommu_memory_region_class_init(ObjectClass *klass, IOMMUMemoryRegionClass *imrc = IOMMU_MEMORY_REGION_CLASS(klass); imrc->translate = virtio_iommu_translate; + imrc->replay = virtio_iommu_replay; } static const TypeInfo virtio_iommu_info = { diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index b87a397406..ea3c3b25ad 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -108,6 +108,7 @@ virtio_iommu_report_fault(uint8_t reason, uint32_t flags, uint32_t endpoint, uin virtio_iommu_fill_resv_property(uint32_t devid, uint8_t subtype, uint64_t start, uint64_t end) "dev= %d, type=%d start=0x%"PRIx64" end=0x%"PRIx64 virtio_iommu_notify_map(const char *name, uint64_t virt_start, uint64_t virt_end, uint64_t phys_start, uint32_t flags) "mr=%s virt_start=0x%"PRIx64" virt_end=0x%"PRIx64" phys_start=0x%"PRIx64" flags=%d" virtio_iommu_notify_unmap(const char *name, uint64_t virt_start, uint64_t virt_end) "mr=%s virt_start=0x%"PRIx64" virt_end=0x%"PRIx64 +virtio_iommu_remap(const char *name, uint64_t virt_start, uint64_t virt_end, uint64_t phys_start) "mr=%s virt_start=0x%"PRIx64" virt_end=0x%"PRIx64" phys_start=0x%"PRIx64 # virtio-mem.c virtio_mem_send_response(uint16_t type) "type=%" PRIu16 From patchwork Wed Nov 4 18:42:11 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: 318580 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8FBFC2D0A3 for ; Wed, 4 Nov 2020 18:48:33 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3E57820782 for ; Wed, 4 Nov 2020 18:48:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Y/BS1Svx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E57820782 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNpg-0002Bz-5r for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 13:48:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNjh-0001Yl-Cq for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21015) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNje-00025N-2A for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FzlYUeG8X4vs91S4tquZq9KM016eO3pXrdQjhhAV7O0=; b=Y/BS1SvxMlNp63ccwx7ZkMuUCwJD3HTnvLtPOfP9i18CrGDnW71Zyd90NpAtac2rvrhwrq kd4EYjW32bDmijxTnshzV6bu2PX86LG09/lWrctHYWmXMesLSfzH1wPVgfbiqwhtm39juV eA/s5j68AKXK2uPAR+AUNMg17nAAXyU= 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-175-ZhgvCt1XO5qEgG1wKt7mgQ-1; Wed, 04 Nov 2020 13:42:15 -0500 X-MC-Unique: ZhgvCt1XO5qEgG1wKt7mgQ-1 Received: by mail-wr1-f69.google.com with SMTP id x16so9539148wrg.7 for ; Wed, 04 Nov 2020 10:42:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FzlYUeG8X4vs91S4tquZq9KM016eO3pXrdQjhhAV7O0=; b=to+RpdUjsl1N++yPHeYrgoR3Vc4VgtQm9I0KVAaXr1ScxPmU4Fa1vnN6ZhfPzdvea7 eNggGaW4rXilbUeSux2X3f9R0pHxZt0oXTsr+Bhj45scPqe3jbk+RIfEyfFtEl9qS+QK 8tpCLGmCXcbDp332niPksb362+E2XfXiJr2Wa3Lp04fJ21dQeyeytnV1zUi4a+oAz/lq CDOkF9KuoY1Q+R0DyjDgUEzWJJPuBH0iRTvDKxkQZXmJCsNDYTjNfatpJqNBQbLfnqcJ kgjBqE6WLw2K2zgAh4jEFtK4YsyMNG4q0O9/k53FM2Y3NRLKnqqOz+NHBqKkoyi2Gp6c s1bQ== X-Gm-Message-State: AOAM530KoNqdDl89ssMfg8tyEFOqLYC+f9iPmFvmorrxsHbFb9L0wtJH SxtB8WE3KimYPk9SXoDt9l37LL4u9NG8U3w5OtzQe5csORnTi+DlKK+n1aCmKZALK7AZr8gMQpf sZeF5bDpfdPfixQY= X-Received: by 2002:adf:9043:: with SMTP id h61mr34692968wrh.237.1604515334160; Wed, 04 Nov 2020 10:42:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJywgtVR83s0UZ+9szyVXJqzQNOBMo98hfMOyetBpwpun6d9XC2pFB0aFARlrM7ypjPaX+i5pA== X-Received: by 2002:adf:9043:: with SMTP id h61mr34692950wrh.237.1604515333987; Wed, 04 Nov 2020 10:42:13 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id f17sm4098067wrm.27.2020.11.04.10.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:42:13 -0800 (PST) Date: Wed, 4 Nov 2020 13:42:11 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 19/31] memory: Add interface to set iommu page size mask Message-ID: <20201104184040.285057-20-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jean-Philippe Brucker , Peter Xu , Eric Auger , Paolo Bonzini , Bharat Bhushan Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bharat Bhushan Allow to set the page size mask supported by an iommu memory region. This enables a vIOMMU to communicate the page size granule supported by an assigned device, on hosts that use page sizes greater than 4kB. Acked-by: Peter Xu Reviewed-by: Eric Auger Signed-off-by: Bharat Bhushan Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-8-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/exec/memory.h | 38 ++++++++++++++++++++++++++++++++++++++ softmmu/memory.c | 13 +++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index aff6ef7605..0f3e6bcd5e 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -397,6 +397,32 @@ struct IOMMUMemoryRegionClass { * @iommu: the IOMMUMemoryRegion */ int (*num_indexes)(IOMMUMemoryRegion *iommu); + + /** + * @iommu_set_page_size_mask: + * + * Restrict the page size mask that can be supported with a given IOMMU + * memory region. Used for example to propagate host physical IOMMU page + * size mask limitations to the virtual IOMMU. + * + * Optional method: if this method is not provided, then the default global + * page mask is used. + * + * @iommu: the IOMMUMemoryRegion + * + * @page_size_mask: a bitmask of supported page sizes. At least one bit, + * representing the smallest page size, must be set. Additional set bits + * represent supported block sizes. For example a host physical IOMMU that + * uses page tables with a page size of 4kB, and supports 2MB and 4GB + * blocks, will set mask 0x40201000. A granule of 4kB with indiscriminate + * block sizes is specified with mask 0xfffffffffffff000. + * + * Returns 0 on success, or a negative error. In case of failure, the error + * object must be created. + */ + int (*iommu_set_page_size_mask)(IOMMUMemoryRegion *iommu, + uint64_t page_size_mask, + Error **errp); }; typedef struct CoalescedMemoryRange CoalescedMemoryRange; @@ -1409,6 +1435,18 @@ int memory_region_iommu_attrs_to_index(IOMMUMemoryRegion *iommu_mr, */ int memory_region_iommu_num_indexes(IOMMUMemoryRegion *iommu_mr); +/** + * memory_region_iommu_set_page_size_mask: set the supported page + * sizes for a given IOMMU memory region + * + * @iommu_mr: IOMMU memory region + * @page_size_mask: supported page size mask + * @errp: pointer to Error*, to store an error if it happens. + */ +int memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion *iommu_mr, + uint64_t page_size_mask, + Error **errp); + /** * memory_region_name: get a memory region's name * diff --git a/softmmu/memory.c b/softmmu/memory.c index 21d533d8ed..71951fe4dc 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -1841,6 +1841,19 @@ static int memory_region_update_iommu_notify_flags(IOMMUMemoryRegion *iommu_mr, return ret; } +int memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion *iommu_mr, + uint64_t page_size_mask, + Error **errp) +{ + IOMMUMemoryRegionClass *imrc = IOMMU_MEMORY_REGION_GET_CLASS(iommu_mr); + int ret = 0; + + if (imrc->iommu_set_page_size_mask) { + ret = imrc->iommu_set_page_size_mask(iommu_mr, page_size_mask, errp); + } + return ret; +} + int memory_region_register_iommu_notifier(MemoryRegion *mr, IOMMUNotifier *n, Error **errp) { From patchwork Wed Nov 4 18:42:19 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: 320563 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp5670116ilc; Wed, 4 Nov 2020 10:54:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJympGMrnIgd/ugdsr0GwG6UPss7xDlHtqsjsgFOU0dC1vFOjqi9KLgaYdoEcZXGvuVPWUXp X-Received: by 2002:a25:d081:: with SMTP id h123mr39018732ybg.160.1604516071386; Wed, 04 Nov 2020 10:54:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604516071; cv=none; d=google.com; s=arc-20160816; b=NhwPBwD0OuOPyKLnxnMK1GbXhmVgwaYL2ggUxuu5t7UzxL3lFiDGC9IREUsx32pm52 WiYmm8EH/7owkmHZJout2qYk9z7FRfMRlHTtLiSJGNotCo+uxdYNh0xC+n/hAyMBm+MC x3uxGQ/OlVkkFwC203DoDTL8ztlIxgJmUW3LnH1VYNb3/WigYQm08qSbokJV+s2CE+e9 G+leVsuGdabEHaBHdsnzMStFSJ0ucIych2p3Hn5/gOv7stTlvExElOYr7lLmKLsmpfcK tBAq8W/i0aH1GF7F1klxnFTGKjwHo1/86YqPRwKrEd9RbpGGNU9DE+OLeNTLfenhFFUj v5iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition:in-reply-to :mime-version:references:message-id:subject:to:from:date :dkim-signature; bh=aTAjTe4Celzp7fll7OULoNskonibl44hj9qWQyy3thE=; b=BjkN9kRTIMs1sCWwf4Z+Z3IkaNtdw264iL+fymDWdFPHUZ1HVAyx9Xyz5fTW14mImA wEFBXRnL5W2dCHvitm62VNm8vaPp5s+aziNwnZdIv/v9jwTkhi/P9TVv/UOjKtr40KVq X62tN6tDfEqDPyGaEO1g+GSwhVcjwHlcV7GOObb3cSN+QwkIo/spbc6CbUOZpQXyGv3v TRkqk3jePHA/B8Oz1N6KjGNjQkpKVSx8dxa4L3VYB2qS0pgnHvBAXNrYsGCUNJA2kgOw c7Xh5tYeFqaURjMgcbGnt2RQ0jMneIhgKesioTUxb53E5DVXb6gmam0hYLLHQep4LDWw jeHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=SQoIjRXb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e188si2708028ybe.120.2020.11.04.10.54.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Nov 2020 10:54:31 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=SQoIjRXb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:38216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNvS-0004Gf-Pg for patch@linaro.org; Wed, 04 Nov 2020 13:54:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNjq-0001hS-Jg for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34898) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNjo-00026L-SH for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515346; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aTAjTe4Celzp7fll7OULoNskonibl44hj9qWQyy3thE=; b=SQoIjRXbQ6Uh/8XWadbgGEUveuDhsE8SB+2ln6aIIzOCk73zE68xlPIpEhxfJCS57MLHuG 6rs57VTGCpAvfJaoTfK97Y/qT0sYus9cW6gBvjxdFM5YwufnMAAwPFpuCQihun+fr6n5FL Ebo7kPh6Qktn9GZR7T2WS7oQD0H448s= 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-191-1MVJBzloPo6tdpQ6epLBcA-1; Wed, 04 Nov 2020 13:42:24 -0500 X-MC-Unique: 1MVJBzloPo6tdpQ6epLBcA-1 Received: by mail-wm1-f72.google.com with SMTP id t201so1564981wmt.1 for ; Wed, 04 Nov 2020 10:42:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aTAjTe4Celzp7fll7OULoNskonibl44hj9qWQyy3thE=; b=pKppiBxpbgttSCLLghSXzhc0b/iIZ9/JRAhpdpoLbIhLMgurR9xjXqt+MWflds6Noq vHTaGD1lvfC3B7GZ2usnMy02b8dSyQKk2Z6LlGEiQBBdlMFqp5AzwP092QEqeTnMP181 L8G/hWzmsXHv18uFxa/mDHgZVehFPil8+OP/l2PzMvZhv3Fg889YKo0DfBSqXGotAiFq WfOJI/DNNN9Uo+ijVljMzta7jt9dwuqCxBwToCF2NLAWFknDU+IW6sajffOM9veXU0Tu llF1QkhlDcSjffzhKzScZBYsZIHtjWir2VSdWX3X0HgJ+hyL92WMkxBTomMy7LgYQo3w LPUQ== X-Gm-Message-State: AOAM533JfL3qxzFI8hSqMwiGzdPdkOE07PZzR9E9ZNhLKj0rI6IIa/lX xr1drqBTLRQkO+TNEKlFx9Ap5nUcAromGGpKfDo+vRjEIy2yg32BMrXitPs5IqpvOgmOjuaW/11 q8SUZR8k5QToBryY= X-Received: by 2002:adf:f10e:: with SMTP id r14mr32276638wro.337.1604515342311; Wed, 04 Nov 2020 10:42:22 -0800 (PST) X-Received: by 2002:adf:f10e:: with SMTP id r14mr32276620wro.337.1604515342162; Wed, 04 Nov 2020 10:42:22 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id t23sm3284378wmn.13.2020.11.04.10.42.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:42:21 -0800 (PST) Date: Wed, 4 Nov 2020 13:42:19 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 22/31] vfio: Don't issue full 2^64 unmap Message-ID: <20201104184040.285057-23-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Alex Williamson , Eric Auger , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Jean-Philippe Brucker IOMMUs may declare memory regions spanning from 0 to UINT64_MAX. When attempting to deal with such region, vfio_listener_region_del() passes a size of 2^64 to int128_get64() which throws an assertion failure. Even ignoring this, the VFIO_IOMMU_DMA_MAP ioctl cannot handle this size since the size field is 64-bit. Split the request in two. Acked-by: Alex Williamson Reviewed-by: Eric Auger Signed-off-by: Jean-Philippe Brucker Message-Id: <20201030180510.747225-11-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/vfio/common.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- MST diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 35895b18a6..c1fdbf17f2 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -950,6 +950,17 @@ static void vfio_listener_region_del(MemoryListener *listener, } if (try_unmap) { + if (int128_eq(llsize, int128_2_64())) { + /* The unmap ioctl doesn't accept a full 64-bit span. */ + llsize = int128_rshift(llsize, 1); + ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL); + if (ret) { + error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", " + "0x%"HWADDR_PRIx") = %d (%m)", + container, iova, int128_get64(llsize), ret); + } + iova += int128_get64(llsize); + } ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL); if (ret) { error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", " From patchwork Wed Nov 4 18:42:25 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: 318578 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2DA6C2D0A3 for ; Wed, 4 Nov 2020 18:50:22 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4859C20780 for ; Wed, 4 Nov 2020 18:50:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KlSBwW8v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4859C20780 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNrR-0005ah-2J for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 13:50:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNjv-0001kM-Vl for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNjr-00026l-FU for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515350; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MaK8aBvBSiaUINk0iflL/mAr7Ti2mM7e4TQ+bKVJ1uk=; b=KlSBwW8vx7VfclMQ44+315m/pIXsLfy7IBUGVxgc7faXyHy/7jWB6QiSqtXW+lsOBhbJvc 5ZaCpO5sC3GDWjCTdfyh4M7f3wF+wkhvG4S+Iw8Dz9O3P+Pvsa3EWOphogTBUl6dnMAKxy 0cLcJC2qYXNsQvmHamu4jatzRnHxsd4= 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-569-qmCnUhrTMh2nt2-w5ODMNg-1; Wed, 04 Nov 2020 13:42:29 -0500 X-MC-Unique: qmCnUhrTMh2nt2-w5ODMNg-1 Received: by mail-wm1-f72.google.com with SMTP id z62so1478268wmb.1 for ; Wed, 04 Nov 2020 10:42:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MaK8aBvBSiaUINk0iflL/mAr7Ti2mM7e4TQ+bKVJ1uk=; b=YuaICchngMntRdPiQNbGH0rVQ88NfgeEpflbUn1LBGVPN0hoSc6XVN6BiL1srUvodF ny7CYlifsnaeDmRo3okshOxq1V2rwm566T8bl4+AYVttNOcpj7RVGBzeQo/sy6znZ4ci UMzi3kSVCeOUWQSjNjszcFaejtbylemcqwUdXaGX3rcCoowAYUFMfXQ/hibv4MdyEE7y /olVFxu4Ma5jXZDtyzarpnE8h3VyeoYLv9ZY2EN9+yToXcxDzm1pUctFbGLDRcwI6g3+ WhE0sce5QSOeEachdLpSJkKlpW7EcNE2PPcjucPgpsy4OE5KexIcWw0ssuFXj7Nlzq+1 GXKQ== X-Gm-Message-State: AOAM530z8G0oUVPpTxluxEzHw6K5+YFu1M72ZyAP31TdLyETnUq+RVrT I4zn2Yn1iOp8jx/krJ0ZQV8MhUHEiKtE9+9GyAlE0+pm9hZmtu0R44l1b5jjdJR1CNIbTgXRsuY 1IZOv0fytb2laEGI= X-Received: by 2002:a5d:6944:: with SMTP id r4mr33796059wrw.151.1604515347462; Wed, 04 Nov 2020 10:42:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJyG9y7VPtZpvzwUoKhVpPyXwx7Hp+NtZ8K+2uCxEy9i0V+D2HqYBbnxL8Shd+aYWGcK4jYFHg== X-Received: by 2002:a5d:6944:: with SMTP id r4mr33796042wrw.151.1604515347283; Wed, 04 Nov 2020 10:42:27 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id r10sm3415293wmg.16.2020.11.04.10.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:42:26 -0800 (PST) Date: Wed, 4 Nov 2020 13:42:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 24/31] net: Add vhost-vdpa in show_netdevs() Message-ID: <20201104184040.285057-25-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Cindy Lu Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Cindy Lu Fix the bug that while Check qemu supported netdev, there is no vhost-vdpa Signed-off-by: Cindy Lu Message-Id: <20201016030909.9522-2-lulu@redhat.com> Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/net.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/net.c b/net/net.c index 7a2a0fb5ac..794c652282 100644 --- a/net/net.c +++ b/net/net.c @@ -1049,6 +1049,9 @@ static void show_netdevs(void) #endif #ifdef CONFIG_POSIX "vhost-user", +#endif +#ifdef CONFIG_VHOST_VDPA + "vhost-vdpa", #endif }; From patchwork Wed Nov 4 18:42: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: 318571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7946C2D0A3 for ; Wed, 4 Nov 2020 18:57:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3AE962083B for ; Wed, 4 Nov 2020 18:57:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jDZ7aKrG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3AE962083B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNyo-0002GM-3V for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 13:57:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNjz-0001oN-9M for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42766) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNjw-00027C-Ln for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515355; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=oxFgfij5tGa7wsPJMg6guJqSTCSDLHe43Ge56aYH6Hc=; b=jDZ7aKrGcgVupUsF9fzDznKuoDEm3St4QbCTQaupLKl/irtaYMrZaoiCJmJbFlK7L9XXBR VyrlPAFq5cXogbot6RPHqU3VErI5cU6m8G9Ut7B6f/AKlMEtbM0lAXhfVU/j12L9R391YA Zpnhgr1k1VgNAcd3mTg900uJOEN11c8= 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-22-HVOaFZ-aOu2ucifVhDvNxg-1; Wed, 04 Nov 2020 13:42:33 -0500 X-MC-Unique: HVOaFZ-aOu2ucifVhDvNxg-1 Received: by mail-wr1-f70.google.com with SMTP id w3so7464845wrt.11 for ; Wed, 04 Nov 2020 10:42:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=oxFgfij5tGa7wsPJMg6guJqSTCSDLHe43Ge56aYH6Hc=; b=kaQoFaHWh5qPAAc7DgU/PFwYBTPQ5Zr/QF176GK1AG7WbyOBIdhhr7iOikOLTT/28d 60fPYPz4vN9N7/flKUs0nqRb+bdSg5EoGEPW+BUzog8cm/LzCRbBK11muqKWrOysSjtA mZvg9vNLVf/U/u90aDEdYJx9WTCnGxXSnnNNx6qVr8GwvAyh9oZS6YEuKTrWiGf2g9lO 2L4RyEWm8GDo4IYQoqe86aRQaTqtK5mQ6boLaX2PoEvvbCJWkuWzkTv4VtpcwZDw2rzI XyOgMFwo/14/1PKtAHXiXgVLb3qbnV8F/jDYYhX9A4d0g8CXOtDpXNiWXe2Tzhs8I4ZP 40fQ== X-Gm-Message-State: AOAM5304PZ4sBHgDuNxsYVcFisct7lR81rhWq3k5GroPuQatNtcQZjPb L6RWHpSjN5Ra/Ls3X4Y9ucW8uyQfCPx7J/YWLmFrtrgBKt7h0U4XEeXo7Ap5CQKq35BZbH786pg FQDuIkJAIe05qsP0= X-Received: by 2002:a1c:7515:: with SMTP id o21mr6347699wmc.5.1604515350345; Wed, 04 Nov 2020 10:42:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJ+MtWzOeCSDWX1Ng4qI0kEXCCGzfdpfEVm6KjZ0Ay+F+zvB1KLChbk95V3wCscSDkRwqhIg== X-Received: by 2002:a1c:7515:: with SMTP id o21mr6347686wmc.5.1604515350200; Wed, 04 Nov 2020 10:42:30 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id z5sm3864231wrw.87.2020.11.04.10.42.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:42:29 -0800 (PST) Date: Wed, 4 Nov 2020 13:42:27 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 25/31] Revert "vhost-blk: set features before setting inflight feature" Message-ID: <20201104184040.285057-26-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Jin Yu , Max Reitz , Stefan Hajnoczi , Raphael Norwitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Stefan Hajnoczi This reverts commit adb29c027341ba095a3ef4beef6aaef86d3a520e. The commit broke -device vhost-user-blk-pci because the vhost_dev_prepare_inflight() function it introduced segfaults in vhost_dev_set_features() when attempting to access struct vhost_dev's vdev pointer before it has been assigned. To reproduce the segfault simply launch a vhost-user-blk device with the contrib vhost-user-blk device backend: $ build/contrib/vhost-user-blk/vhost-user-blk -s /tmp/vhost-user-blk.sock -r -b /var/tmp/foo.img $ build/qemu-system-x86_64 \ -device vhost-user-blk-pci,id=drv0,chardev=char1,addr=4.0 \ -object memory-backend-memfd,id=mem,size=1G,share=on \ -M memory-backend=mem,accel=kvm \ -chardev socket,id=char1,path=/tmp/vhost-user-blk.sock Segmentation fault (core dumped) Cc: Jin Yu Cc: Raphael Norwitz Cc: Michael S. Tsirkin Signed-off-by: Stefan Hajnoczi Message-Id: <20201102165709.232180-1-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost.h | 1 - hw/block/vhost-user-blk.c | 6 ------ hw/virtio/vhost.c | 18 ------------------ 3 files changed, 25 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 839bfb153c..94585067f7 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -141,7 +141,6 @@ void vhost_dev_reset_inflight(struct vhost_inflight *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 f67b29bbf3..a076b1e54d 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -131,12 +131,6 @@ static int vhost_user_blk_start(VirtIODevice *vdev) 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 f2482378c6..79b2be20df 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1645,24 +1645,6 @@ int vhost_dev_load_inflight(struct vhost_inflight *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 Wed Nov 4 18:42:30 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: 318572 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD030C4742C for ; Wed, 4 Nov 2020 18:57:02 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0B4E622228 for ; Wed, 4 Nov 2020 18:57:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PU4Xn2Hd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B4E622228 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNxs-00016G-Tq for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 13:57:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNk0-0001px-KV for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36882) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNjz-00027Z-3F for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515358; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ay6G7kYGtMwl+/IxEdsu272p/jXvwydr69tjR0/ihX0=; b=PU4Xn2Hdj0y/8jueB+noMuUrYu+psXSGPu8peyw9BdJIGTAGtkfzCirRPgFWgfnnDE54ei C1yuPtP9Eqokk2LSAvM9tc3H3w0a/H9bOga7UfgJKL2g/avNg6jBiMCLq7UZdBp8iPb2po xjMZdw7MjapWIGwWHLNNsgWjrIVs1+8= 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-59-lX5IxxSFO0mQzDQJWYHGHw-1; Wed, 04 Nov 2020 13:42:35 -0500 X-MC-Unique: lX5IxxSFO0mQzDQJWYHGHw-1 Received: by mail-wm1-f71.google.com with SMTP id u207so1557107wmu.4 for ; Wed, 04 Nov 2020 10:42:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ay6G7kYGtMwl+/IxEdsu272p/jXvwydr69tjR0/ihX0=; b=mWrqeqGwRVOO8Mj9Nn+TSQxGbJWxGafNoADLKessGDJBf5+zdAc2zsX0kfiOkERejm jCP1nkdbdtjYH5yzVwGcpLTvHxw/ZSEeoCZcDyimX7R0ACxA625EnTIGg6CKiAYFU/Ue KGkvfFQnZUYz8qjFvOIcBEunh0oSFSckY/ls9uHzt5S3JSgwWiIIVjLUZ6J6jXOjla2b NsMh/azvNTVazMYkONMjYKnb/ROSFPU4lUmDD5UJyXsmU29bqNH82HWFgQqrrCjCKQO9 odbHcpPnwHJFTR3xWaYKePzaIVpDpmHXWptJYxNk64xAtNgawy2on4qN9R4q8ojjO55g 6EcA== X-Gm-Message-State: AOAM530oIaMpiYVz4GujtREFdCIZBg0W3+BISPrk5/yZ0adu+QpUfItX I7NzflGnXOxhbRRlo3boU5h5NGczARO9yCdENruA237bmqmcicWkqxqsOK5qGYhhIokNEOtA5KY Q348FGA5040zEMDU= X-Received: by 2002:a5d:6591:: with SMTP id q17mr33550208wru.173.1604515353167; Wed, 04 Nov 2020 10:42:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXECzrQuVn9IfSdJ+vYUw+quDcsRPWouSCF0TH4H2d19YITkdlRxK7JRP8Gymv92ujn254FQ== X-Received: by 2002:a5d:6591:: with SMTP id q17mr33550196wru.173.1604515352961; Wed, 04 Nov 2020 10:42:32 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id v8sm3486040wmg.28.2020.11.04.10.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:42:32 -0800 (PST) Date: Wed, 4 Nov 2020 13:42:30 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 26/31] vhost-blk: set features before setting inflight feature Message-ID: <20201104184040.285057-27-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Jin Yu , Max Reitz , Raphael Norwitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.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 Acked-by: Raphael Norwitz Message-Id: <20201103123617.28256-1-jin.yu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost.h | 1 + hw/block/vhost-user-blk.c | 6 ++++++ hw/virtio/vhost.c | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 94585067f7..4a8bc75415 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -141,6 +141,7 @@ void vhost_dev_reset_inflight(struct vhost_inflight *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, VirtIODevice *vdev); int vhost_dev_set_inflight(struct vhost_dev *dev, struct vhost_inflight *inflight); int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size, diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index a076b1e54d..2dd3d93ca0 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -131,6 +131,12 @@ static int vhost_user_blk_start(VirtIODevice *vdev) s->dev.acked_features = vdev->guest_features; + ret = vhost_dev_prepare_inflight(&s->dev, vdev); + if (ret < 0) { + error_report("Error set inflight format: %d", -ret); + goto err_guest_notifiers; + } + if (!s->inflight->addr) { ret = vhost_dev_get_inflight(&s->dev, s->queue_size, s->inflight); if (ret < 0) { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 79b2be20df..614ccc2bcb 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1645,6 +1645,26 @@ int vhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f) return 0; } +int vhost_dev_prepare_inflight(struct vhost_dev *hdev, VirtIODevice *vdev) +{ + int r; + + if (hdev->vhost_ops->vhost_get_inflight_fd == NULL || + hdev->vhost_ops->vhost_set_inflight_fd == NULL) { + return 0; + } + + hdev->vdev = vdev; + + 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 Wed Nov 4 18:42:33 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: 318570 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 888A0C2D0A3 for ; Wed, 4 Nov 2020 18:59:29 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0366D2080D for ; Wed, 4 Nov 2020 18:59:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NRLOApDU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0366D2080D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaO0G-0004vn-0L for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 13:59:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNk3-0001sH-Ln for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:28633) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNk0-00027k-ES for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515359; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=APdAnMGOimWpi0/lmUkQSWdNUl1kK18oif2GgMOHc/o=; b=NRLOApDUTXXL3d2OoLx+zmEeycwJN7SU2kkERM9RLBv0v7LlkCxMCsGKezrPn/ZURUgwbS 29y00RHh9lfEr8IbZi+6t60UJq9LEXQTSAns6GQTFkqTKO4dY+GbUQgOSPoHxRLmtSQ8s/ +SewSdBAuUEg4qkTJWcAyqDss8jISpQ= 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-460-vkVddHj6N12VlGpBlPwKrA-1; Wed, 04 Nov 2020 13:42:37 -0500 X-MC-Unique: vkVddHj6N12VlGpBlPwKrA-1 Received: by mail-wr1-f69.google.com with SMTP id w3so7464924wrt.11 for ; Wed, 04 Nov 2020 10:42:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=APdAnMGOimWpi0/lmUkQSWdNUl1kK18oif2GgMOHc/o=; b=oy6ZR0bVlaarSiCiq6bLiXzh6VwcV5Sqb1n0kVCghasvjS3H4wyENDoTFjTDrex9CH LpZvejCfcxuPfXtfUNvH12WxTJa2kBw3vejAgLAuyz1+/NzIF85rVcBnx3GGwZAMwF7l JBc0WSCXIS097c3f1AuzYTs6pJKO0V2DVxt6192Sjagh6aiQGzjxplV9s+66A8gEaQiV rpaO4Xt4dqek6WLepPhgVeKmMLbqDW0nbmbOS2QKqYcRS5NWQQPRkxqB7syTq0Ezl0ry w9zNbZQ5tFfocnwFjVLuJpbMEAxEpHew3pnADh+TIQs5eOwLqLY/2KLLFH/QE19xzzY0 FWAQ== X-Gm-Message-State: AOAM531OmDtYVbdi9V0W+btBpdMpxU5PASQeyC9BmLWYYNTBSduM/hwf gWyVCBX0+RdvUlWRBd/IcGEPnWezxGxg0g4tbpeTlQ21qMir+xP/XjO+H4wwdJrI5cYbY+o1nI+ 8btvnTqOl9CArnDo= X-Received: by 2002:a5d:420d:: with SMTP id n13mr33529118wrq.196.1604515356215; Wed, 04 Nov 2020 10:42:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsWobb6UbmptgnJ36rO278I6Xt4A1ZR8tLSRPtW8ULqMxqPLGerJGXWJFVjO2shv8QwQH+PA== X-Received: by 2002:a5d:420d:: with SMTP id n13mr33529110wrq.196.1604515356081; Wed, 04 Nov 2020 10:42:36 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id z14sm3634058wmc.15.2020.11.04.10.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:42:35 -0800 (PST) Date: Wed, 4 Nov 2020 13:42:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 27/31] libvhost-user: follow QEMU comment style Message-ID: <20201104184040.285057-28-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , "Dr. David Alan Gilbert" , Stefan Hajnoczi , Raphael Norwitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-2-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/libvhost-user/libvhost-user.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user.h b/contrib/libvhost-user/libvhost-user.h index 3bbeae8587..a1539dbb69 100644 --- a/contrib/libvhost-user/libvhost-user.h +++ b/contrib/libvhost-user/libvhost-user.h @@ -392,7 +392,8 @@ struct VuDev { bool broken; uint16_t max_queues; - /* @read_msg: custom method to read vhost-user message + /* + * @read_msg: custom method to read vhost-user message * * Read data from vhost_user socket fd and fill up * the passed VhostUserMsg *vmsg struct. @@ -409,15 +410,19 @@ struct VuDev { * */ vu_read_msg_cb read_msg; - /* @set_watch: add or update the given fd to the watch set, - * call cb when condition is met */ + + /* + * @set_watch: add or update the given fd to the watch set, + * call cb when condition is met. + */ vu_set_watch_cb set_watch; /* @remove_watch: remove the given fd from the watch set */ vu_remove_watch_cb remove_watch; - /* @panic: encountered an unrecoverable error, you may try to - * re-initialize */ + /* + * @panic: encountered an unrecoverable error, you may try to re-initialize + */ vu_panic_cb panic; const VuDevIface *iface; From patchwork Wed Nov 4 18:42:41 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: 318576 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3D4BC2D0A3 for ; Wed, 4 Nov 2020 18:52:26 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 21FF220780 for ; Wed, 4 Nov 2020 18:52:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NTxfkq/O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 21FF220780 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaNtR-0001IM-2I for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 13:52:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNkC-00026y-8l for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:41586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNkA-00028u-Fr for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cS4KIfPlpUgVDDoFSeX7cKA8yzTJmgIIdFHv/xDSqc0=; b=NTxfkq/Ov9DAdRdkKaWMXrI4feW6bmBSC+ZsJXnWvD9+SP+plEx/WW9pysmhZ47J+7Mb2v CvNPjTfbzf/KB6nIwWDGjoOx1VVyWRKPJys5sYV2BgWut+1cHPWPohmtFRq6+eG9vKK4Th VQ6QeHKJ01sP9hhuvn4bqajyY6PUHTM= 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-244-_kIg8_mSM6y-YO_QhsmIRw-1; Wed, 04 Nov 2020 13:42:46 -0500 X-MC-Unique: _kIg8_mSM6y-YO_QhsmIRw-1 Received: by mail-wm1-f72.google.com with SMTP id s85so937450wme.3 for ; Wed, 04 Nov 2020 10:42:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=cS4KIfPlpUgVDDoFSeX7cKA8yzTJmgIIdFHv/xDSqc0=; b=oVvvtgH4s/4wc4sfEyq0cmA4/agNlv0uRezl5fkA2rWyG/y3JH0UxbcmbrYr/XUYYc OzKoxXl6vDv/+0A2BWjsIQSe/jSUgw23BRYD4hLuGz9KBcGr+5hfwUxN23V/8oYwuNdF /pE4l2OTfeuo/bFUUnKJJXRn+dn8p4M4WFByDpWzkYwM7u4q2GVlIB92vS5FWk9YLp+j CQ+tz9mhth2EhzBeQA9ktHZRRf7+1bmRz9Iljjgo2DlNO311ClbjNTGAjKOXUExRD5YK UCXDxX9rAqhFjS1MKStc5X8YsX/OAgmdw5ubbWNTKFiLkdVWckmjPhICdZHvSKYqRvar vMKA== X-Gm-Message-State: AOAM531TTiiR1BotFriyoSIdhD8MUE0HRyxb45SdsgsUkEBNM+2OUVaf Mo6qGhQqB+gDnn+qTWXF9kc5fEoAjMgIXD/EwtE7h4MBwFm9/vIvN+zrax0uovgIK+QBAMOBDJv 5wsUYVhPwaPhevSs= X-Received: by 2002:adf:e9c9:: with SMTP id l9mr8431819wrn.124.1604515364576; Wed, 04 Nov 2020 10:42:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxCiUmSyJM7wWGHb04L1f/thUiVYmbfsoZ6xudGz3Ugz46gi0nwGiODkgvYdjDFrOyHeutHcQ== X-Received: by 2002:adf:e9c9:: with SMTP id l9mr8431810wrn.124.1604515364389; Wed, 04 Nov 2020 10:42:44 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id s11sm3681961wrm.56.2020.11.04.10.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:42:43 -0800 (PST) Date: Wed, 4 Nov 2020 13:42:41 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 30/31] block/export: fix vhost-user-blk get_config() information leak Message-ID: <20201104184040.285057-31-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Coiby Xu , Max Reitz , Stefan Hajnoczi Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Stefan Hajnoczi Refuse get_config() requests in excess of sizeof(struct virtio_blk_config). Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-5-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- block/export/vhost-user-blk-server.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user-blk-server.c index 33cc0818b8..62672d1cb9 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -266,6 +266,9 @@ vu_blk_get_config(VuDev *vu_dev, uint8_t *config, uint32_t len) { VuServer *server = container_of(vu_dev, VuServer, vu_dev); VuBlkExport *vexp = container_of(server, VuBlkExport, vu_server); + + g_return_val_if_fail(len <= sizeof(struct virtio_blk_config), -1); + memcpy(config, &vexp->blkcfg, len); return 0; } From patchwork Wed Nov 4 18:42:44 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: 318569 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 702C4C2D0A3 for ; Wed, 4 Nov 2020 19:01:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C3187206D9 for ; Wed, 4 Nov 2020 19:01:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gpcTUNRE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3187206D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaO2O-0007Kk-Qh for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 14:01:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaNkC-00028t-Rw for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59450) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaNkB-000291-5W for qemu-devel@nongnu.org; Wed, 04 Nov 2020 13:42:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604515370; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=10gqAcInC2hOlA/e3e/PPVyOBwthTxnTi3QFwwaBdNU=; b=gpcTUNREbhLHnVa3wrXNuX78xYDD7tFnmEZ2YL7KfyhDbL6sm35KDk3SM4GzLZCkq33EBc K92i0MzWeZltFr6wHTbufQ8aUWa+auRRzzXO1OLv6x8juBIIORcq49oGTOwI5XsyEzL5iV HFnP6djE4OSdJISmcCCOciU5xzoZJ7A= 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-554-wmDXX12bMzuFzT82cDPpFg-1; Wed, 04 Nov 2020 13:42:48 -0500 X-MC-Unique: wmDXX12bMzuFzT82cDPpFg-1 Received: by mail-wr1-f69.google.com with SMTP id w1so9594257wrr.5 for ; Wed, 04 Nov 2020 10:42:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=10gqAcInC2hOlA/e3e/PPVyOBwthTxnTi3QFwwaBdNU=; b=Z9KA05QXshSH9UigjoG6bI2a4nXUGuSOWptFt/BmPKDP7jqN3gRAhatCPums92SP/e SuISNPhidvr+8obWQU5B3/KQ4nSJXYEUGR1H83qa17vdqNchEBGpnbFQG7pLnDY3T7QR 3GLEMO/3fcLgUkvVArZBv/LaUw3iB9mLbh4AH4lwHgSJfOxuoLBjafuVE5tbbI3sOjmA qi+I+l6TXVHw2U9ApJgj8YeyCNp1FGSrl/SqMGcMRBdSHgDGJd2qz41BKYQuDa+ASXKD Us6/Wg9gdqotWGiK9+fnTOBqq2JAyyCZL8hv5O+ge/Yj7D26JOPGlivNJNab7qVkPdjT P//w== X-Gm-Message-State: AOAM530fPXs5OEFbjvBv7DyGJqo89AMk2bNQXswbWmsPNQ/GSlcqgJOj ahP4Da5rxTFNAS5fd10e731nahEohMP2RYt3/M7PqN0sBHxuqgAe0N5XTMUrS4FZu4M0mdhWh39 Y7VoOKFa7ACxwbO0= X-Received: by 2002:a1c:20d0:: with SMTP id g199mr6488096wmg.68.1604515367069; Wed, 04 Nov 2020 10:42:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYjeEZrlPB6gzGmFYU5J4hvnzvNDc2oj+A4RBPyE1adRDO6GnrTv3RuaLz509yRUpUAPjf/A== X-Received: by 2002:a1c:20d0:: with SMTP id g199mr6488088wmg.68.1604515366928; Wed, 04 Nov 2020 10:42:46 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id y2sm4031859wrh.0.2020.11.04.10.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2020 10:42:46 -0800 (PST) Date: Wed, 4 Nov 2020 13:42:44 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 31/31] contrib/vhost-user-blk: fix get_config() information leak Message-ID: <20201104184040.285057-32-mst@redhat.com> References: <20201104184040.285057-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201104184040.285057-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/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi , Raphael Norwitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Stefan Hajnoczi Refuse get_config() in excess of sizeof(struct virtio_blk_config). Signed-off-by: Stefan Hajnoczi Message-Id: <20201027173528.213464-6-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/vhost-user-blk/vhost-user-blk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c index 25eccd02b5..caad88637e 100644 --- a/contrib/vhost-user-blk/vhost-user-blk.c +++ b/contrib/vhost-user-blk/vhost-user-blk.c @@ -404,6 +404,8 @@ vub_get_config(VuDev *vu_dev, uint8_t *config, uint32_t len) VugDev *gdev; VubDev *vdev_blk; + g_return_val_if_fail(len <= sizeof(struct virtio_blk_config), -1); + gdev = container_of(vu_dev, VugDev, parent); vdev_blk = container_of(gdev, VubDev, parent); memcpy(config, &vdev_blk->blkcfg, len);