From patchwork Wed Jul 22 12:09:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 277579 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.8 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=unavailable 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 F21DFC433E5 for ; Wed, 22 Jul 2020 12:10:48 +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 BBB7F20771 for ; Wed, 22 Jul 2020 12:10:48 +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="Xeb/gik5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BBB7F20771 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]:53214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jyDaC-0007CB-01 for qemu-devel@archiver.kernel.org; Wed, 22 Jul 2020 08:10:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jyDYk-0005OV-3b for qemu-devel@nongnu.org; Wed, 22 Jul 2020 08:09:18 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:51912 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jyDYi-0006ZE-Bm for qemu-devel@nongnu.org; Wed, 22 Jul 2020 08:09:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595419755; 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=/9YW6K8+jtBdnSbdO+Q9oFDtvItrtur2iZwhghw1mqc=; b=Xeb/gik5m7PQ2gbf/c2vOOOwmg3qqce8hr+lJgTUfgLp5EguAAwo4M7Jji2/ajgc3otI8c 0V4tmqjw42ILAolv4683zqjy5Wne2T9yxken8mPC9Go8OesmN8wyo93Z/hhkdgyv1lOyMB DH3DKmgzHAnniGOVXfO1iHQEbSe7760= 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-381-GJoeoM3MNVmnpsfBSB7EUw-1; Wed, 22 Jul 2020 08:09:12 -0400 X-MC-Unique: GJoeoM3MNVmnpsfBSB7EUw-1 Received: by mail-wr1-f70.google.com with SMTP id t12so555289wrp.0 for ; Wed, 22 Jul 2020 05:09:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/9YW6K8+jtBdnSbdO+Q9oFDtvItrtur2iZwhghw1mqc=; b=W9ZkgYUuonxPpuRypP8JNPEBJcLtb0qNQ73o34NTRu1UeU9ZXWzV7MaWpXMF2xawHO +/wxJxbu/kY8e0p5+6zU/2qcGgdixjn1NSbvsWPo+YCYHUFIl5LRS+2rewR/3a9F2etC DOuFvFm/id6vyEdq337m2B6nOC6UbGn0iWoifwGitjW94nMawRDhsNWh/6JrzW+DavBu KR/wfRJjC1sAGlmpTn/a/rIp+HdkxSqC6APrIkUkGESaPPtN9iSNwMhCYhfIVLqlm05G yA4MLmy/sKXh/btgVZb/y9+Gg/mBqqZNjFSDbPYClC/pDVHEQqkWo8EO04NwGEBW5oRo JT8Q== X-Gm-Message-State: AOAM533udXqQMK+1BtLL/+qWbjc9oEsqQ8K9CS492J7Jgo2fPMrXRIp/ eFHhyjFqVrmVsmH9LOLPndzaSP1iwRATD0lSMXRKB2zMpraWs3Vm+/3gMBLe+UCWrj8JBDmsulE z9m+hRXZUSRbws+Y= X-Received: by 2002:a1c:27c1:: with SMTP id n184mr8741907wmn.6.1595419750760; Wed, 22 Jul 2020 05:09:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfJnsv60NWLAY6CpOwKF2nDjeLmGeyF0puGnN737dNdp1aGisd8T8TjzAYIVhDY+sDvfhy/g== X-Received: by 2002:a1c:27c1:: with SMTP id n184mr8741885wmn.6.1595419750484; Wed, 22 Jul 2020 05:09:10 -0700 (PDT) Received: from redhat.com (bzq-79-182-82-99.red.bezeqint.net. [79.182.82.99]) by smtp.gmail.com with ESMTPSA id k14sm39983301wrn.76.2020.07.22.05.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 05:09:09 -0700 (PDT) Date: Wed, 22 Jul 2020 08:09:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 1/9] acpi: accept byte and word access to core ACPI registers Message-ID: <20200722120853.9144-2-mst@redhat.com> References: <20200722120853.9144-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200722120853.9144-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=207.211.31.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/22 00:40:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Simon John , Peter Maydell , Michael Tokarev , qemu-stable@nongnu.org, Igor Mammedov Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Michael Tokarev All ISA registers should be accessible as bytes, words or dwords (if wide enough). Fix the access constraints for acpi-pm-evt, acpi-pm-tmr & acpi-cnt registers. Fixes: 5d971f9e67 (memory: Revert "memory: accept mismatching sizes in memory_region_access_valid") Fixes: afafe4bbe0 (apci: switch cnt to memory api) Fixes: 77d58b1e47 (apci: switch timer to memory api) Fixes: b5a7c024d2 (apci: switch evt to memory api) Buglink: https://lore.kernel.org/xen-devel/20200630170913.123646-1-anthony.perard@citrix.com/T/ Buglink: https://bugs.debian.org/964793 BugLink: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=964247 BugLink: https://bugs.launchpad.net/bugs/1886318 Reported-By: Simon John Signed-off-by: Michael Tokarev Message-Id: <20200720160627.15491-1-mjt@msgid.tls.msk.ru> Cc: qemu-stable@nongnu.org Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/acpi/core.c b/hw/acpi/core.c index f6d9ec4f13..ac06db3450 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -458,7 +458,8 @@ static void acpi_pm_evt_write(void *opaque, hwaddr addr, uint64_t val, static const MemoryRegionOps acpi_pm_evt_ops = { .read = acpi_pm_evt_read, .write = acpi_pm_evt_write, - .valid.min_access_size = 2, + .impl.min_access_size = 2, + .valid.min_access_size = 1, .valid.max_access_size = 2, .endianness = DEVICE_LITTLE_ENDIAN, }; @@ -527,7 +528,8 @@ static void acpi_pm_tmr_write(void *opaque, hwaddr addr, uint64_t val, static const MemoryRegionOps acpi_pm_tmr_ops = { .read = acpi_pm_tmr_read, .write = acpi_pm_tmr_write, - .valid.min_access_size = 4, + .impl.min_access_size = 4, + .valid.min_access_size = 1, .valid.max_access_size = 4, .endianness = DEVICE_LITTLE_ENDIAN, }; @@ -599,7 +601,8 @@ static void acpi_pm_cnt_write(void *opaque, hwaddr addr, uint64_t val, static const MemoryRegionOps acpi_pm_cnt_ops = { .read = acpi_pm_cnt_read, .write = acpi_pm_cnt_write, - .valid.min_access_size = 2, + .impl.min_access_size = 2, + .valid.min_access_size = 1, .valid.max_access_size = 2, .endianness = DEVICE_LITTLE_ENDIAN, }; From patchwork Wed Jul 22 12:09: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: 277577 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.8 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=unavailable 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 2B68FC433E2 for ; Wed, 22 Jul 2020 12:12:45 +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 EA73E20771 for ; Wed, 22 Jul 2020 12:12:44 +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="RAomaseg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA73E20771 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]:33604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jyDc4-0002MZ-7l for qemu-devel@archiver.kernel.org; Wed, 22 Jul 2020 08:12:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jyDYt-0005mn-Py for qemu-devel@nongnu.org; Wed, 22 Jul 2020 08:09:27 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:29068 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jyDYs-0006Zq-6H for qemu-devel@nongnu.org; Wed, 22 Jul 2020 08:09:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595419765; 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=Ir1mQoDZtpCFjemMlgBAUOy/k9rxHtJelilQmy3Q970=; b=RAomasegoyjdtXJfDmRNS38qOg0LNPTvAipJLutRNEDCeAtt6cLMtkHGyAghozi7UUUEPq VYqsJEHT+bdJaHP9yKBU6DHRMfWhE3V7aoyOTNtr/naul4g0qSGmgPpIf+Yo1mKRMy0N94 c+EAW84JKH/Qv8Lc+9HRZFaqk8OBn+Y= 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-362-qJhZDVm0OUeX_JBPBfcIEQ-1; Wed, 22 Jul 2020 08:09:23 -0400 X-MC-Unique: qJhZDVm0OUeX_JBPBfcIEQ-1 Received: by mail-wr1-f70.google.com with SMTP id w7so549766wrt.9 for ; Wed, 22 Jul 2020 05:09:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ir1mQoDZtpCFjemMlgBAUOy/k9rxHtJelilQmy3Q970=; b=Mr1bKiZkiJu7WYfV6LOfdLpzQdfmw7ckYYKk03gZ2w7laYQacv8iUr7iT5I3naepsR Q+PmlFV3XuUqgozvR7UsIOSGX328jJmPha6iZtiLcaPpNCxK7lXoiLQnh5zZ8Rq37lex nBtUOhIGuTqk4NRB+kaC1RD4ndvgWtgxK6Ej257LAuqs/5oxu10CzllIv5AHzRX/3sXO gUkAx8ftSZs4ZAqFnxrn5XLf1kOj40cN2MaV4IjMatOTjwYYV5dDuyU94dvK3fYAGPKR 0tqvpM26Vwz5rpwOvl5eoZGwE0LsCDNGyO+ttTtuiRugRMTL9kkVeWaj45gIuqYVBmHC AN6w== X-Gm-Message-State: AOAM530UvQ+SkEdeAuGE90izyuF5VUAs+N4fQwWVC/og7p2GM+9G+Nu8 l/Pu5aXPZ/iy0UBZy3QthMeXZNjNxqqzwgUvMByYZ0BdhmxIqGdsiQGGDOzBU+arR6anAOpo9Vf Y776phpA0x4joRf4= X-Received: by 2002:a05:600c:2907:: with SMTP id i7mr8035514wmd.40.1595419761630; Wed, 22 Jul 2020 05:09:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHYfJo3ILHK3pe9Ds7U7OQuEX9nm9YVgEFeh9KCfcXuJ7ardN7LFIOYjqRWumZw4wxoRoAwg== X-Received: by 2002:a05:600c:2907:: with SMTP id i7mr8035500wmd.40.1595419761451; Wed, 22 Jul 2020 05:09:21 -0700 (PDT) Received: from redhat.com (bzq-79-182-82-99.red.bezeqint.net. [79.182.82.99]) by smtp.gmail.com with ESMTPSA id u17sm41322377wrp.70.2020.07.22.05.09.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 05:09:20 -0700 (PDT) Date: Wed, 22 Jul 2020 08:09:19 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 3/9] virtio-balloon: Prevent guest from starting a report when we didn't request one Message-ID: <20200722120853.9144-4-mst@redhat.com> References: <20200722120853.9144-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200722120853.9144-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=205.139.110.61; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/21 21:28:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H2=-1, 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 , Alexander Duyck , qemu-stable@nongnu.org, David Hildenbrand Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Alexander Duyck Based on code review it appears possible for the driver to force the device out of a stopped state when hinting by repeating the last ID it was provided. Prevent this by only allowing a transition to the start state when we are in the requested state. This way the driver is only allowed to send one descriptor that will transition the device into the start state. All others will leave it in the stop state once it has finished. Fixes: c13c4153f76d ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT") Acked-by: David Hildenbrand Signed-off-by: Alexander Duyck Message-Id: <20200720175115.21935.99563.stgit@localhost.localdomain> Cc: qemu-stable@nongnu.org Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-balloon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index e670f1e595..ce70adcc69 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -526,7 +526,8 @@ static bool get_free_page_hints(VirtIOBalloon *dev) ret = false; goto out; } - if (id == dev->free_page_report_cmd_id) { + if (dev->free_page_report_status == FREE_PAGE_REPORT_S_REQUESTED && + id == dev->free_page_report_cmd_id) { dev->free_page_report_status = FREE_PAGE_REPORT_S_START; } else { /* From patchwork Wed Jul 22 12:09:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 277576 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.8 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=unavailable 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 E248CC433E1 for ; Wed, 22 Jul 2020 12:14:25 +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 9CC9320771 for ; Wed, 22 Jul 2020 12:14:25 +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="Grsmpuex" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9CC9320771 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]:40174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jyDdg-00058H-SJ for qemu-devel@archiver.kernel.org; Wed, 22 Jul 2020 08:14:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jyDZ1-00063a-2z for qemu-devel@nongnu.org; Wed, 22 Jul 2020 08:09:35 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:53210 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jyDYx-0006ba-VF for qemu-devel@nongnu.org; Wed, 22 Jul 2020 08:09:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595419771; 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=bs9U4hN5LSg+hi0OgxYHSZVVHSVgqOpBXsAdJksJ8EE=; b=Grsmpuex2sE40bkKaiUjVlSLrTdpRtPeN2g9VQlTsJnQ4dEk6M4l3f9LmyoELVEBhFPpJx nJRmmQMfbTdTcgXWbEBkXEqoedEf2sgCzLn3F3myAoOUlucRWRyE2y8HcDagVQaD17Hp8p +yHbTq+nYnB3UjnAv3a++W0dmDyjki4= 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-342-pgEWp5JGMFGYzmXlqOffxg-1; Wed, 22 Jul 2020 08:09:29 -0400 X-MC-Unique: pgEWp5JGMFGYzmXlqOffxg-1 Received: by mail-wr1-f72.google.com with SMTP id m7so542769wrb.20 for ; Wed, 22 Jul 2020 05:09:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bs9U4hN5LSg+hi0OgxYHSZVVHSVgqOpBXsAdJksJ8EE=; b=svgWXCigkZM85iQVYTYpavfcYaImbeKKIMIbRIuHOu4nDFX2LEkwdeCYZP9ih9Z0IS fGe5yHrAXQe8gdkSzARuC3pl3glIW0TfYBrXAJGgflNPoYVvNuCYdZzBPTv9+Bz5uxf3 sYJsgVQewpBnqsyd9WOIUn8Wa5k5N833ec4n+Vq4gWzf6oedyr8+J1+MrWn75V7V+WMn pgZwAFOiw47ffO+KpLIiojbvBe0nVWrSnGr7oTVvT9dm9n1qy2DJkh2dS3cQT/PEbFQT 0LKqmAZf9x1lZ5aWDTgU0dGkYSjz2QidRV+LVTcnHsqd02zi5W53nhMp7vvTapLYfvhZ 18kw== X-Gm-Message-State: AOAM530S5tpetS3n68SDNbmPU5G/S3yydJujvPmQkHnxFJl2GRt5xiqz dxYJH2jq/B7nzPxwIZxPT9/oKN65oWSD2JR3fqOpLJfNXW+EF+8kDoF3Rre8t70BSCbt/UeuZTq 10mlHrwPyXF7rRbk= X-Received: by 2002:a5d:544f:: with SMTP id w15mr22055143wrv.208.1595419767825; Wed, 22 Jul 2020 05:09:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIutnvsjbzzgXH8Ge010I4iR38v+pBYGFL+CAZnc0/QOcy3S7NIu8S/zi8Zocj9s4aDkK8wg== X-Received: by 2002:a5d:544f:: with SMTP id w15mr22055116wrv.208.1595419767515; Wed, 22 Jul 2020 05:09:27 -0700 (PDT) Received: from redhat.com (bzq-79-182-82-99.red.bezeqint.net. [79.182.82.99]) by smtp.gmail.com with ESMTPSA id n3sm31650879wre.29.2020.07.22.05.09.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 05:09:26 -0700 (PDT) Date: Wed, 22 Jul 2020 08:09:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 5/9] virtio-balloon: Replace free page hinting references to 'report' with 'hint' Message-ID: <20200722120853.9144-6-mst@redhat.com> References: <20200722120853.9144-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200722120853.9144-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=205.139.110.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/21 23:27:14 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H2=-1, 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 , Alexander Duyck , qemu-stable@nongnu.org, David Hildenbrand Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Alexander Duyck Recently a feature named Free Page Reporting was added to the virtio balloon. In order to avoid any confusion we should drop the use of the word 'report' when referring to Free Page Hinting. So what this patch does is go through and replace all instances of 'report' with 'hint" when we are referring to free page hinting. Acked-by: David Hildenbrand Signed-off-by: Alexander Duyck Message-Id: <20200720175128.21935.93927.stgit@localhost.localdomain> Cc: qemu-stable@nongnu.org Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-balloon.h | 20 ++++---- hw/virtio/virtio-balloon.c | 76 +++++++++++++++--------------- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/include/hw/virtio/virtio-balloon.h b/include/hw/virtio/virtio-balloon.h index d49fef00ce..28fd2b3960 100644 --- a/include/hw/virtio/virtio-balloon.h +++ b/include/hw/virtio/virtio-balloon.h @@ -23,7 +23,7 @@ #define VIRTIO_BALLOON(obj) \ OBJECT_CHECK(VirtIOBalloon, (obj), TYPE_VIRTIO_BALLOON) -#define VIRTIO_BALLOON_FREE_PAGE_REPORT_CMD_ID_MIN 0x80000000 +#define VIRTIO_BALLOON_FREE_PAGE_HINT_CMD_ID_MIN 0x80000000 typedef struct virtio_balloon_stat VirtIOBalloonStat; @@ -33,20 +33,20 @@ typedef struct virtio_balloon_stat_modern { uint64_t val; } VirtIOBalloonStatModern; -enum virtio_balloon_free_page_report_status { - FREE_PAGE_REPORT_S_STOP = 0, - FREE_PAGE_REPORT_S_REQUESTED = 1, - FREE_PAGE_REPORT_S_START = 2, - FREE_PAGE_REPORT_S_DONE = 3, +enum virtio_balloon_free_page_hint_status { + FREE_PAGE_HINT_S_STOP = 0, + FREE_PAGE_HINT_S_REQUESTED = 1, + FREE_PAGE_HINT_S_START = 2, + FREE_PAGE_HINT_S_DONE = 3, }; typedef struct VirtIOBalloon { VirtIODevice parent_obj; VirtQueue *ivq, *dvq, *svq, *free_page_vq, *reporting_vq; - uint32_t free_page_report_status; + uint32_t free_page_hint_status; uint32_t num_pages; uint32_t actual; - uint32_t free_page_report_cmd_id; + uint32_t free_page_hint_cmd_id; uint64_t stats[VIRTIO_BALLOON_S_NR]; VirtQueueElement *stats_vq_elem; size_t stats_vq_offset; @@ -55,7 +55,7 @@ typedef struct VirtIOBalloon { QEMUBH *free_page_bh; /* * Lock to synchronize threads to access the free page reporting related - * fields (e.g. free_page_report_status). + * fields (e.g. free_page_hint_status). */ QemuMutex free_page_lock; QemuCond free_page_cond; @@ -64,7 +64,7 @@ typedef struct VirtIOBalloon { * stopped. */ bool block_iothread; - NotifierWithReturn free_page_report_notify; + NotifierWithReturn free_page_hint_notify; int64_t stats_last_update; int64_t stats_poll_interval; uint32_t host_features; diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 6e2d129340..22cb5df717 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -526,22 +526,22 @@ static bool get_free_page_hints(VirtIOBalloon *dev) ret = false; goto out; } - if (dev->free_page_report_status == FREE_PAGE_REPORT_S_REQUESTED && - id == dev->free_page_report_cmd_id) { - dev->free_page_report_status = FREE_PAGE_REPORT_S_START; + if (dev->free_page_hint_status == FREE_PAGE_HINT_S_REQUESTED && + id == dev->free_page_hint_cmd_id) { + dev->free_page_hint_status = FREE_PAGE_HINT_S_START; } else { /* * Stop the optimization only when it has started. This * avoids a stale stop sign for the previous command. */ - if (dev->free_page_report_status == FREE_PAGE_REPORT_S_START) { - dev->free_page_report_status = FREE_PAGE_REPORT_S_STOP; + if (dev->free_page_hint_status == FREE_PAGE_HINT_S_START) { + dev->free_page_hint_status = FREE_PAGE_HINT_S_STOP; } } } if (elem->in_num) { - if (dev->free_page_report_status == FREE_PAGE_REPORT_S_START) { + if (dev->free_page_hint_status == FREE_PAGE_HINT_S_START) { qemu_guest_free_page_hint(elem->in_sg[0].iov_base, elem->in_sg[0].iov_len); } @@ -567,11 +567,11 @@ static void virtio_ballloon_get_free_page_hints(void *opaque) qemu_mutex_unlock(&dev->free_page_lock); virtio_notify(vdev, vq); /* - * Start to poll the vq once the reporting started. Otherwise, continue + * Start to poll the vq once the hinting started. Otherwise, continue * only when there are entries on the vq, which need to be given back. */ } while (continue_to_get_hints || - dev->free_page_report_status == FREE_PAGE_REPORT_S_START); + dev->free_page_hint_status == FREE_PAGE_HINT_S_START); virtio_queue_set_notification(vq, 1); } @@ -594,14 +594,14 @@ static void virtio_balloon_free_page_start(VirtIOBalloon *s) qemu_mutex_lock(&s->free_page_lock); - if (s->free_page_report_cmd_id == UINT_MAX) { - s->free_page_report_cmd_id = - VIRTIO_BALLOON_FREE_PAGE_REPORT_CMD_ID_MIN; + if (s->free_page_hint_cmd_id == UINT_MAX) { + s->free_page_hint_cmd_id = + VIRTIO_BALLOON_FREE_PAGE_HINT_CMD_ID_MIN; } else { - s->free_page_report_cmd_id++; + s->free_page_hint_cmd_id++; } - s->free_page_report_status = FREE_PAGE_REPORT_S_REQUESTED; + s->free_page_hint_status = FREE_PAGE_HINT_S_REQUESTED; qemu_mutex_unlock(&s->free_page_lock); virtio_notify_config(vdev); @@ -611,18 +611,18 @@ static void virtio_balloon_free_page_stop(VirtIOBalloon *s) { VirtIODevice *vdev = VIRTIO_DEVICE(s); - if (s->free_page_report_status != FREE_PAGE_REPORT_S_STOP) { + if (s->free_page_hint_status != FREE_PAGE_HINT_S_STOP) { /* * The lock also guarantees us that the * virtio_ballloon_get_free_page_hints exits after the - * free_page_report_status is set to S_STOP. + * free_page_hint_status is set to S_STOP. */ qemu_mutex_lock(&s->free_page_lock); /* - * The guest hasn't done the reporting, so host sends a notification - * to the guest to actively stop the reporting. + * The guest isn't done hinting, so send a notification + * to the guest to actively stop the hinting. */ - s->free_page_report_status = FREE_PAGE_REPORT_S_STOP; + s->free_page_hint_status = FREE_PAGE_HINT_S_STOP; qemu_mutex_unlock(&s->free_page_lock); virtio_notify_config(vdev); } @@ -632,20 +632,20 @@ static void virtio_balloon_free_page_done(VirtIOBalloon *s) { VirtIODevice *vdev = VIRTIO_DEVICE(s); - if (s->free_page_report_status != FREE_PAGE_REPORT_S_DONE) { + if (s->free_page_hint_status != FREE_PAGE_HINT_S_DONE) { /* See virtio_balloon_free_page_stop() */ qemu_mutex_lock(&s->free_page_lock); - s->free_page_report_status = FREE_PAGE_REPORT_S_DONE; + s->free_page_hint_status = FREE_PAGE_HINT_S_DONE; qemu_mutex_unlock(&s->free_page_lock); virtio_notify_config(vdev); } } static int -virtio_balloon_free_page_report_notify(NotifierWithReturn *n, void *data) +virtio_balloon_free_page_hint_notify(NotifierWithReturn *n, void *data) { VirtIOBalloon *dev = container_of(n, VirtIOBalloon, - free_page_report_notify); + free_page_hint_notify); VirtIODevice *vdev = VIRTIO_DEVICE(dev); PrecopyNotifyData *pnd = data; @@ -703,7 +703,7 @@ static size_t virtio_balloon_config_size(VirtIOBalloon *s) if (virtio_has_feature(features, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) { return offsetof(struct virtio_balloon_config, poison_val); } - return offsetof(struct virtio_balloon_config, free_page_report_cmd_id); + return offsetof(struct virtio_balloon_config, free_page_hint_cmd_id); } static void virtio_balloon_get_config(VirtIODevice *vdev, uint8_t *config_data) @@ -715,14 +715,14 @@ static void virtio_balloon_get_config(VirtIODevice *vdev, uint8_t *config_data) config.actual = cpu_to_le32(dev->actual); config.poison_val = cpu_to_le32(dev->poison_val); - if (dev->free_page_report_status == FREE_PAGE_REPORT_S_REQUESTED) { - config.free_page_report_cmd_id = - cpu_to_le32(dev->free_page_report_cmd_id); - } else if (dev->free_page_report_status == FREE_PAGE_REPORT_S_STOP) { - config.free_page_report_cmd_id = + if (dev->free_page_hint_status == FREE_PAGE_HINT_S_REQUESTED) { + config.free_page_hint_cmd_id = + cpu_to_le32(dev->free_page_hint_cmd_id); + } else if (dev->free_page_hint_status == FREE_PAGE_HINT_S_STOP) { + config.free_page_hint_cmd_id = cpu_to_le32(VIRTIO_BALLOON_CMD_ID_STOP); - } else if (dev->free_page_report_status == FREE_PAGE_REPORT_S_DONE) { - config.free_page_report_cmd_id = + } else if (dev->free_page_hint_status == FREE_PAGE_HINT_S_DONE) { + config.free_page_hint_cmd_id = cpu_to_le32(VIRTIO_BALLOON_CMD_ID_DONE); } @@ -835,14 +835,14 @@ static int virtio_balloon_post_load_device(void *opaque, int version_id) return 0; } -static const VMStateDescription vmstate_virtio_balloon_free_page_report = { +static const VMStateDescription vmstate_virtio_balloon_free_page_hint = { .name = "virtio-balloon-device/free-page-report", .version_id = 1, .minimum_version_id = 1, .needed = virtio_balloon_free_page_support, .fields = (VMStateField[]) { - VMSTATE_UINT32(free_page_report_cmd_id, VirtIOBalloon), - VMSTATE_UINT32(free_page_report_status, VirtIOBalloon), + VMSTATE_UINT32(free_page_hint_cmd_id, VirtIOBalloon), + VMSTATE_UINT32(free_page_hint_status, VirtIOBalloon), VMSTATE_END_OF_LIST() } }; @@ -869,7 +869,7 @@ static const VMStateDescription vmstate_virtio_balloon_device = { VMSTATE_END_OF_LIST() }, .subsections = (const VMStateDescription * []) { - &vmstate_virtio_balloon_free_page_report, + &vmstate_virtio_balloon_free_page_hint, &vmstate_virtio_balloon_page_poison, NULL } @@ -908,7 +908,7 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp) VIRTIO_BALLOON_F_FREE_PAGE_HINT)) { s->free_page_vq = virtio_add_queue(vdev, VIRTQUEUE_MAX_SIZE, virtio_balloon_handle_free_page_vq); - precopy_add_notifier(&s->free_page_report_notify); + precopy_add_notifier(&s->free_page_hint_notify); object_ref(OBJECT(s->iothread)); s->free_page_bh = aio_bh_new(iothread_get_aio_context(s->iothread), @@ -932,7 +932,7 @@ static void virtio_balloon_device_unrealize(DeviceState *dev) qemu_bh_delete(s->free_page_bh); object_unref(OBJECT(s->iothread)); virtio_balloon_free_page_stop(s); - precopy_remove_notifier(&s->free_page_report_notify); + precopy_remove_notifier(&s->free_page_hint_notify); } balloon_stats_destroy_timer(s); qemu_remove_balloon_handler(s); @@ -1004,8 +1004,8 @@ static void virtio_balloon_instance_init(Object *obj) qemu_mutex_init(&s->free_page_lock); qemu_cond_init(&s->free_page_cond); - s->free_page_report_cmd_id = VIRTIO_BALLOON_FREE_PAGE_REPORT_CMD_ID_MIN; - s->free_page_report_notify.notify = virtio_balloon_free_page_report_notify; + s->free_page_hint_cmd_id = VIRTIO_BALLOON_FREE_PAGE_HINT_CMD_ID_MIN; + s->free_page_hint_notify.notify = virtio_balloon_free_page_hint_notify; object_property_add(obj, "guest-stats", "guest statistics", balloon_stats_get_all, NULL, NULL, s); From patchwork Wed Jul 22 12:09: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: 277575 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.8 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=unavailable 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 CD0DBC433E0 for ; Wed, 22 Jul 2020 12:16:14 +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 9AA2A20787 for ; Wed, 22 Jul 2020 12:16:14 +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="PX3L34on" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9AA2A20787 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]:45324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jyDfR-0007Ob-TC for qemu-devel@archiver.kernel.org; Wed, 22 Jul 2020 08:16:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jyDZ2-00065I-So for qemu-devel@nongnu.org; Wed, 22 Jul 2020 08:09:36 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:32957 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jyDZ1-0006bu-C1 for qemu-devel@nongnu.org; Wed, 22 Jul 2020 08:09:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595419774; 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=nCEOZP6B1lWOOd8FiK7LTx/qy5GESWgBrYMgTCL8coc=; b=PX3L34onG1uMprc00GRXCeSABPFLJ4nh/lfxZHp8jW5A5fK90kUD6saN1LMiz159Zr6Zl7 +9cSQdq+uGh0cLo/TtYF2R/c7OUiyDB79bV/gylbOpWRMi7Y/TNSeqcIckJXeKOLAaOptv mpMnQ4qNVS7smwtFywxfFiuKocN7ze0= 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-463-zKtS2YTBO3SBLALWwTxmsA-1; Wed, 22 Jul 2020 08:09:32 -0400 X-MC-Unique: zKtS2YTBO3SBLALWwTxmsA-1 Received: by mail-wr1-f70.google.com with SMTP id a18so548264wrm.14 for ; Wed, 22 Jul 2020 05:09:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=nCEOZP6B1lWOOd8FiK7LTx/qy5GESWgBrYMgTCL8coc=; b=q4a0jhJClUXACeKfHhXkA7w2eDZkcROBPck5ynkT7se6ISvLq3hIzYWASjBNXhDquK x4AVUr/qgRSrLW9fjZWWhUf66bSDgxUE5enG8ipFO30bh45q+AaF9KFS5uRch8PB2Uut FLjwC+/uuI9pvclYeaHo9bBoAPDSNeucVPlJMBo7xMpFKDkX0QS8Q5ZMTZZVYjW30yXI FN8i8NfG/lNGo05KnYIc98jpeSvTC859xRz4AmjcRKzeYPWFTgVnIF4Xb+bKUSYcN1CP 1/A6HGJq6Hf7zyOH2qUAaOe41tVp3yI9TDhJMyKwhWIIsetqgJ3pEYHAPrPI68JpZjDL 5wrg== X-Gm-Message-State: AOAM532yIE5EcPm2SCqWOTJWPCQOu/o8ktivlMnmstilRlhu6L2Jz8R7 PtL1Kyod+Z9M0kbQ0pQ40KUqo5FiOg/g7hwEk/kVS4naYtNx7OIuHD1PAtM7l2HFebN1s7nRkG1 56Yl2g5qYviX1/6c= X-Received: by 2002:adf:a351:: with SMTP id d17mr5346391wrb.111.1595419770797; Wed, 22 Jul 2020 05:09:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzs2RXXrkj1wCwHt7f7ieiuuMd88rSEUw6c7z5Gixub12VESK+W10JpwmjC/Nt2e0Bc1Kwzeg== X-Received: by 2002:adf:a351:: with SMTP id d17mr5346378wrb.111.1595419770542; Wed, 22 Jul 2020 05:09:30 -0700 (PDT) Received: from redhat.com ([192.117.173.58]) by smtp.gmail.com with ESMTPSA id f186sm6997734wmf.29.2020.07.22.05.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 05:09:29 -0700 (PDT) Date: Wed, 22 Jul 2020 08:09:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 6/9] virtio: list legacy-capable devices Message-ID: <20200722120853.9144-7-mst@redhat.com> References: <20200722120853.9144-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200722120853.9144-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=207.211.31.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/22 00:40:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Halil Pasic , Peter Maydell , Cornelia Huck , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Cornelia Huck Several types of virtio devices had already been around before the virtio standard was specified. These devices support virtio in legacy (and transitional) mode. Devices that have been added in the virtio standard are considered non-transitional (i.e. with no support for legacy virtio). Provide a helper function so virtio transports can figure that out easily. Signed-off-by: Cornelia Huck Message-Id: <20200707105446.677966-2-cohuck@redhat.com> Cc: qemu-stable@nongnu.org Acked-by: Halil Pasic Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 2 ++ hw/virtio/virtio.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b69d517496..198ffc7626 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -396,4 +396,6 @@ static inline bool virtio_device_disabled(VirtIODevice *vdev) return unlikely(vdev->disabled || vdev->broken); } +bool virtio_legacy_allowed(VirtIODevice *vdev); + #endif diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 5bd2a2f621..546a198e79 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -27,6 +27,7 @@ #include "hw/virtio/virtio-access.h" #include "sysemu/dma.h" #include "sysemu/runstate.h" +#include "standard-headers/linux/virtio_ids.h" /* * The alignment to use between consumer and producer parts of vring. @@ -3279,6 +3280,30 @@ void virtio_init(VirtIODevice *vdev, const char *name, vdev->use_guest_notifier_mask = true; } +/* + * Only devices that have already been around prior to defining the virtio + * standard support legacy mode; this includes devices not specified in the + * standard. All newer devices conform to the virtio standard only. + */ +bool virtio_legacy_allowed(VirtIODevice *vdev) +{ + switch (vdev->device_id) { + case VIRTIO_ID_NET: + case VIRTIO_ID_BLOCK: + case VIRTIO_ID_CONSOLE: + case VIRTIO_ID_RNG: + case VIRTIO_ID_BALLOON: + case VIRTIO_ID_RPMSG: + case VIRTIO_ID_SCSI: + case VIRTIO_ID_9P: + case VIRTIO_ID_RPROC_SERIAL: + case VIRTIO_ID_CAIF: + return true; + default: + return false; + } +} + hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n) { return vdev->vq[n].vring.desc; From patchwork Wed Jul 22 12:09: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: 277578 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.8 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=unavailable 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 22075C433E0 for ; Wed, 22 Jul 2020 12:12:06 +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 DEC1F20771 for ; Wed, 22 Jul 2020 12:12:05 +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="ic/Kpffp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DEC1F20771 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]:58774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jyDbR-00017M-50 for qemu-devel@archiver.kernel.org; Wed, 22 Jul 2020 08:12:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jyDZ8-0006El-H7 for qemu-devel@nongnu.org; Wed, 22 Jul 2020 08:09:42 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:26712 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jyDZ6-0006cD-3I for qemu-devel@nongnu.org; Wed, 22 Jul 2020 08:09:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595419779; 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=zJUEiAuh/w0ZZykpZGg+27nY/rwRTIsctuEMd8wdLQg=; b=ic/Kpffp8cchdWG9ZtHyK7Xo9FjaGZFuuIY19MCIsAqWZMnY3ay5gkE5S4aPng+UVagnXC VDKrwNYvN81T29YgKxzQ7VdoIja4q3ckuHRrBrhchR0PdEScDDli/LHIyfDio4+z2WwFAX U9kOI/GHcKrqPRaAMZzm1h9TVmkezZ0= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-513-eHtGRuo_MWmZvR0KB1OS7Q-1; Wed, 22 Jul 2020 08:09:35 -0400 X-MC-Unique: eHtGRuo_MWmZvR0KB1OS7Q-1 Received: by mail-wr1-f70.google.com with SMTP id a18so548328wrm.14 for ; Wed, 22 Jul 2020 05:09:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=zJUEiAuh/w0ZZykpZGg+27nY/rwRTIsctuEMd8wdLQg=; b=nFz/+zbAvvDex3VLOj129+MDCUXAI1ipjETiB7+nL5YYzOyyYSKooaV9Hz8A37vfrn OhKYWwxBuSjCxXHvEofKTM1FCvbhtiaq+1k1Isqlm2W+mlkQZDij42xvwVMDPrlph6GG NIjkzMqbSr9DLn4HceO/wh/wBRNKyEVu31Tvku7gnyPlZ6Rlb1f/jVsRSbMpQ9xw+0Ku S/TQCVSXUK86UIn5+Ir5R0e7M6ntaSVGsVawfLXvKymE79zBM0Chh9KUUUfu0pL1NDxZ 5yuSDfUXeb7s9KljqTkTjnnrFvSZh+PtQFjpMDtDFdPDOtPpb1i2BaDTKFBxa6wk4dOF jauw== X-Gm-Message-State: AOAM532VGFA+jRAaYFp9mP+DpjKpuIAcdVWxHNPYA14Xe1aNnLzuOhIP t46hat50nT/7kXIuXIWuCnJ321mO+LG4zSsfcYeBk1SKPcD/R11t0DwoDEi1e0cTF+AZvnQD6ai me93n/BBOAqyTFpM= X-Received: by 2002:adf:de07:: with SMTP id b7mr33042586wrm.302.1595419773970; Wed, 22 Jul 2020 05:09:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwChp1o5boBbHmbfF2ipGhhGhnTkDBfTg1D8qRCAGKUDHbPGSqs+g7m/OgYBJfGe1IiAQSiBQ== X-Received: by 2002:adf:de07:: with SMTP id b7mr33042570wrm.302.1595419773809; Wed, 22 Jul 2020 05:09:33 -0700 (PDT) Received: from redhat.com (bzq-79-182-82-99.red.bezeqint.net. [79.182.82.99]) by smtp.gmail.com with ESMTPSA id o9sm41165104wrs.1.2020.07.22.05.09.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 05:09:33 -0700 (PDT) Date: Wed, 22 Jul 2020 08:09:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 7/9] virtio: verify that legacy support is not accidentally on Message-ID: <20200722120853.9144-8-mst@redhat.com> References: <20200722120853.9144-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200722120853.9144-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=207.211.31.120; envelope-from=mst@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/22 00:40:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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 , Thomas Huth , David Hildenbrand , Cornelia Huck , qemu-stable@nongnu.org, Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Cornelia Huck If a virtio device does not have legacy support, make sure that it is actually off, and bail out if not. For virtio-pci, this means that any device without legacy support that has been specified to modern-only (or that has been forced to it) will work. For virtio-ccw, this duplicates the check that is currently done prior to realization for any device that explicitly specified no support for legacy. This catches devices that have not been fenced properly. Signed-off-by: Cornelia Huck Message-Id: <20200707105446.677966-3-cohuck@redhat.com> Cc: qemu-stable@nongnu.org Acked-by: Halil Pasic Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/s390x/virtio-ccw.c | 6 ++++++ hw/virtio/virtio-pci.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 3c988a000b..0e60270297 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1121,6 +1121,12 @@ static void virtio_ccw_device_plugged(DeviceState *d, Error **errp) dev->max_rev = 0; } + if (!virtio_ccw_rev_max(dev) && !virtio_legacy_allowed(vdev)) { + error_setg(errp, "Invalid value of property max_rev " + "(is %d expected >= 1)", virtio_ccw_rev_max(dev)); + return; + } + if (virtio_get_num_queues(vdev) > VIRTIO_QUEUE_MAX) { error_setg(errp, "The number of virtqueues %d " "exceeds virtio limit %d", n, diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 8554cf2a03..db8b711b35 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1581,6 +1581,10 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) } if (legacy) { + if (!virtio_legacy_allowed(vdev)) { + error_setg(errp, "device is modern-only, use disable-legacy=on"); + return; + } if (virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM)) { error_setg(errp, "VIRTIO_F_IOMMU_PLATFORM was supported by" " neither legacy nor transitional device");