From nobody Sat Apr 27 01:04:01 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1673513570; cv=pass; d=zohomail.com; s=zohoarc; b=cb7Or7WtRrIC5bexIlg00YNCYhxooUnNhvj3OsnREGTHuHhhBmvXihOzd7ReoYNTp4OfFJiiz0DMl/PLhJtTQuWxhYafHbQ+6pkumGY9Z4Y7eiLTWxwz0LOpx/IZI84nnBLlB/+EVgBbAzkXBDPEddiazSKl97+cYUdrG/XJYXs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673513570; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tUG4deaKAkFAP+AUREDpeGhxFKRVQ2ZXGCxkx28PefI=; b=NaL8WdhaKMEhrVLs36smQEUdkKD1TbJ+asSDTVqx1fOal9w0WDPGzdYJ0NyrlVD7i31y0RCI1JlNmhFyRfhgi2hT2u3qnllGIvrfRe9BoGFh/hRcKnGtFlxnJcaj5KgmR14N/Xrq6pZv6xe/R13kZ3YT9IgJ0CxETTOGiX0xluo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTP id 1673513570455553.6172442951017; Thu, 12 Jan 2023 00:52:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFtIh-0005ez-7v; Thu, 12 Jan 2023 03:51:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtIe-0005dK-E4; Thu, 12 Jan 2023 03:51:04 -0500 Received: from mail-dm6nam12on2085.outbound.protection.outlook.com ([40.107.243.85] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtIX-0007Wt-OD; Thu, 12 Jan 2023 03:51:02 -0500 Received: from MW4PR04CA0376.namprd04.prod.outlook.com (2603:10b6:303:81::21) by PH8PR12MB7328.namprd12.prod.outlook.com (2603:10b6:510:214::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Thu, 12 Jan 2023 08:50:47 +0000 Received: from CO1NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:303:81:cafe::c0) by MW4PR04CA0376.outlook.office365.com (2603:10b6:303:81::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:50:47 +0000 Received: from mail.nvidia.com (216.228.118.233) by CO1NAM11FT005.mail.protection.outlook.com (10.13.174.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:50:46 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:50:34 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:50:34 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 12 Jan 2023 00:50:27 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AdNeAkdPhAN94tHogbEZZYr5Co1L5G9b6lyyUq6UCyH8i7QcaGSKC6OaJVsuSQQM3YbkdKFVKXrbnARsmx7w+fciRGQxZ8jgTXbTZpo/XlksVKEwo6gQaDHOmJkA5/0Y28YnXVnlSpb7SAliA99r7mTPb0USkkb+fKDi51ln/2UHYverubhmgkp1PR82FvH1fn6oiqxlf4UyRmAeGR5FdQdq+JQw3f1wlTjZTx9fQJ8k3yv0R9dhbLaExn1tb/gi+OxG41qOghlmleB53kGG/ylCtebgYJJ4MLjHzM2vAR06Dz1azNM3IZ+TEdb2FAbmRwsws9gPt/aRMLXZ6uzTpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tUG4deaKAkFAP+AUREDpeGhxFKRVQ2ZXGCxkx28PefI=; b=I4gnFJJnKtw1fEZbgYFw4tIdwxAL5oTEeP2WhrMYgZRKSROHbwEGQLiM5SU3PS3vWoRRFUMzqUKUlXrF4b8YyydZCaANAkzcCCJWRRZkGmqSiDSBF3vNcYVotGixdAHya0VOlhIhEA1qE6r3e/lqg3PnbNjqeOvTPeyj0m+enBE6KhXFxvamiWJ4axVKChE0z2j8Wt4o4EH8xKTaiGTf/BlELFnwp6eott1uNGCbsjoT+CrU8KUmc2xTLiUnCefdW0+2MIgRluoPxqwwrspwOwET1y4D2luDJOWgQ7J9Yt0Kq4jOg8z9cY7/f2EbG1tWD8LHSB5sWUmiLtBEriGifg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tUG4deaKAkFAP+AUREDpeGhxFKRVQ2ZXGCxkx28PefI=; b=Q3QMMXLiO7gSo9vZ2eM4VJXBTEsMFTaoN5PuNVeJgz1S2dJySZnHq/mtWmWHYbPuqe5Pa4U+2TmEqDXrOc3tK5odX6X1eLZ5OR4KCDTky9lZh8yVVHJQnwuGmft8eCJ6EiOR6kxhl9+BPPHrws8FEr4cbVAt6nfnZhIvx8p0s2rkHdCQLP5CTrRHef/GByooDzUFUg1nhbod0P/0WOGS+sYyze5DGnFPGrSRUwFcMOu8QdaxnYShUkYVTEmK/UkrznqVoACXnMfCXAjAvNP0lgaS0Ix4gUo0QcH+ADWSwydYPdaAxk+yqYrWRED40RVvYx9EZO4nmhvA+fZ9F9ACEw== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , "Ilya Leoshkevich" , Thomas Huth , "Juan Quintela" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v6 01/13] linux-headers: Update to v6.2-rc1 Date: Thu, 12 Jan 2023 10:50:08 +0200 Message-ID: <20230112085020.15866-2-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230112085020.15866-1-avihaih@nvidia.com> References: <20230112085020.15866-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT005:EE_|PH8PR12MB7328:EE_ X-MS-Office365-Filtering-Correlation-Id: bdff6f66-d14a-4a01-e099-08daf47a18fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TGbAL7CMJl3OGDglWtdZWYZxhUlMDx10eHFigtOC7UQS7gjW9Jfe2RKjT71WVlXXIeZtbc6Ooyz4UDBIr1LgmV7LiH78fy9uGxkHey15zIS+mGgGN0ch/Tkrg+WtqXWdp0k1349wl7GMXfJz7jOUfEZa3dxySVGpHunChb54fJWSqmIUNNnSsURlN5xh+Yo7uL8Q3Zs717nS95cmuxtNt/VyBfcBR9E8E35AwI9Ygm8WtgRgt4wt0jCjw2Xm8LNBujPn2cw89TQjTSXBOtJ0z4UsZekR57xrNN8wrqkRqbCninakTCc0WT4bMJNO3QSpWxr/MQRY0TutgsNAA5XMvasHab2crw1iOyHYKsQcgLME3o2OAPhWP3VVFIp2m+4N7pcnDK/wK3IO6KdR4X9KgIutjsmhPvGTQm04T3fpPrsnF/K5mhmng5btYggUwkqRkeOglawDVKa8arMn2FMi5AKRxToUF8ui/sfjbtxVGtPQgsu9WXnkP3I7lo8lkCQunYEaXgOQlutY2oNNhYTe9Nc8tWq4dDYmg8XQmxkjborVdXGoMkHpzkA88+sTDoE3Mkg16lZBAIVCkdCmLuppqGBYhH2A2UCsF8AwvM1XqFgobacdQDkQl5wXZCqOvptKCddNbE4YyC8Rp8t9NFCieN7s5Xp5/6e0+DmIO92W/WFD24ue+P6fpk+9ZeJZNBpgR8E/4YdsoFoj6jmIwIwed3ydghZN3iS5Sjk5pdWYYig= X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(396003)(136003)(376002)(346002)(39860400002)(451199015)(46966006)(36840700001)(40470700004)(356005)(82740400003)(7636003)(186003)(6916009)(8676002)(86362001)(70206006)(54906003)(4326008)(36860700001)(70586007)(40460700003)(41300700001)(7696005)(1076003)(40480700001)(7416002)(316002)(5660300002)(19627235002)(2616005)(47076005)(83380400001)(2906002)(426003)(8936002)(336012)(478600001)(26005)(82310400005)(6666004)(15650500001)(30864003)(36756003)(579004)(134885004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 08:50:46.7600 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bdff6f66-d14a-4a01-e099-08daf47a18fb X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7328 Received-SPF: softfail client-ip=40.107.243.85; envelope-from=avihaih@nvidia.com; helo=NAM12-DM6-obe.outbound.protection.outlook.com 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_H2=-0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1673513571738100005 Update to commit 1b929c02afd3 ("Linux 6.2-rc1"). Signed-off-by: Avihai Horon --- include/standard-headers/drm/drm_fourcc.h | 63 +++- include/standard-headers/linux/ethtool.h | 81 ++++- include/standard-headers/linux/fuse.h | 20 +- .../linux/input-event-codes.h | 4 + include/standard-headers/linux/pci_regs.h | 2 + include/standard-headers/linux/virtio_blk.h | 19 ++ include/standard-headers/linux/virtio_bt.h | 8 + include/standard-headers/linux/virtio_net.h | 4 + linux-headers/asm-arm64/kvm.h | 1 + linux-headers/asm-generic/hugetlb_encode.h | 26 +- linux-headers/asm-generic/mman-common.h | 2 + linux-headers/asm-mips/mman.h | 2 + linux-headers/asm-riscv/kvm.h | 7 + linux-headers/asm-x86/kvm.h | 11 +- linux-headers/linux/kvm.h | 32 +- linux-headers/linux/psci.h | 14 + linux-headers/linux/userfaultfd.h | 4 + linux-headers/linux/vfio.h | 278 +++++++++++++++++- 18 files changed, 522 insertions(+), 56 deletions(-) diff --git a/include/standard-headers/drm/drm_fourcc.h b/include/standard-h= eaders/drm/drm_fourcc.h index 48b620cbef..69cab17b38 100644 --- a/include/standard-headers/drm/drm_fourcc.h +++ b/include/standard-headers/drm/drm_fourcc.h @@ -98,18 +98,42 @@ extern "C" { #define DRM_FORMAT_INVALID 0 =20 /* color index */ +#define DRM_FORMAT_C1 fourcc_code('C', '1', ' ', ' ') /* [7:0] C0:C1:C2:C= 3:C4:C5:C6:C7 1:1:1:1:1:1:1:1 eight pixels/byte */ +#define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ') /* [7:0] C0:C1:C2:C= 3 2:2:2:2 four pixels/byte */ +#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ') /* [7:0] C0:C1 4:4 = two pixels/byte */ #define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ =20 -/* 8 bpp Red */ +/* 1 bpp Darkness (inverse relationship between channel value and brightne= ss) */ +#define DRM_FORMAT_D1 fourcc_code('D', '1', ' ', ' ') /* [7:0] D0:D1:D2:D= 3:D4:D5:D6:D7 1:1:1:1:1:1:1:1 eight pixels/byte */ + +/* 2 bpp Darkness (inverse relationship between channel value and brightne= ss) */ +#define DRM_FORMAT_D2 fourcc_code('D', '2', ' ', ' ') /* [7:0] D0:D1:D2:D= 3 2:2:2:2 four pixels/byte */ + +/* 4 bpp Darkness (inverse relationship between channel value and brightne= ss) */ +#define DRM_FORMAT_D4 fourcc_code('D', '4', ' ', ' ') /* [7:0] D0:D1 4:4 = two pixels/byte */ + +/* 8 bpp Darkness (inverse relationship between channel value and brightne= ss) */ +#define DRM_FORMAT_D8 fourcc_code('D', '8', ' ', ' ') /* [7:0] D */ + +/* 1 bpp Red (direct relationship between channel value and brightness) */ +#define DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ') /* [7:0] R0:R1:R2:R= 3:R4:R5:R6:R7 1:1:1:1:1:1:1:1 eight pixels/byte */ + +/* 2 bpp Red (direct relationship between channel value and brightness) */ +#define DRM_FORMAT_R2 fourcc_code('R', '2', ' ', ' ') /* [7:0] R0:R1:R2:R= 3 2:2:2:2 four pixels/byte */ + +/* 4 bpp Red (direct relationship between channel value and brightness) */ +#define DRM_FORMAT_R4 fourcc_code('R', '4', ' ', ' ') /* [7:0] R0:R1 4:4 = two pixels/byte */ + +/* 8 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ =20 -/* 10 bpp Red */ +/* 10 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R10 fourcc_code('R', '1', '0', ' ') /* [15:0] x:R 6:10= little endian */ =20 -/* 12 bpp Red */ +/* 12 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R12 fourcc_code('R', '1', '2', ' ') /* [15:0] x:R 4:12= little endian */ =20 -/* 16 bpp Red */ +/* 16 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') /* [15:0] R little= endian */ =20 /* 16 bpp RG */ @@ -204,7 +228,9 @@ extern "C" { #define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:= Y0:Cr0 8:8:8:8 little endian */ =20 #define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:= Cr 8:8:8:8 little endian */ +#define DRM_FORMAT_AVUY8888 fourcc_code('A', 'V', 'U', 'Y') /* [31:0] A:Cr= :Cb:Y 8:8:8:8 little endian */ #define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:= Cb:Cr 8:8:8:8 little endian */ +#define DRM_FORMAT_XVUY8888 fourcc_code('X', 'V', 'U', 'Y') /* [31:0] X:Cr= :Cb:Y 8:8:8:8 little endian */ #define DRM_FORMAT_VUY888 fourcc_code('V', 'U', '2', '4') /* [23:0] Cr:Cb:= Y 8:8:8 little endian */ #define DRM_FORMAT_VUY101010 fourcc_code('V', 'U', '3', '0') /* Y followed= by U then V, 10:10:10. Non-linear modifier only */ =20 @@ -717,6 +743,35 @@ extern "C" { */ #define DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED fourcc_mod_code(VIVANTE, = 4) =20 +/* + * Vivante TS (tile-status) buffer modifiers. They can be combined with al= l of + * the color buffer tiling modifiers defined above. When TS is present it'= s a + * separate buffer containing the clear/compression status of each tile. T= he + * modifiers are defined as VIVANTE_MOD_TS_c_s, where c is the color buffer + * tile size in bytes covered by one entry in the status buffer and s is t= he + * number of status bits per entry. + * We reserve the top 8 bits of the Vivante modifier space for tile status + * clear/compression modifiers, as future cores might add some more TS lay= out + * variations. + */ +#define VIVANTE_MOD_TS_64_4 (1ULL << 48) +#define VIVANTE_MOD_TS_64_2 (2ULL << 48) +#define VIVANTE_MOD_TS_128_4 (3ULL << 48) +#define VIVANTE_MOD_TS_256_4 (4ULL << 48) +#define VIVANTE_MOD_TS_MASK (0xfULL << 48) + +/* + * Vivante compression modifiers. Those depend on a TS modifier being pres= ent + * as the TS bits get reinterpreted as compression tags instead of simple + * clear markers when compression is enabled. + */ +#define VIVANTE_MOD_COMP_DEC400 (1ULL << 52) +#define VIVANTE_MOD_COMP_MASK (0xfULL << 52) + +/* Masking out the extension bits will yield the base modifier. */ +#define VIVANTE_MOD_EXT_MASK (VIVANTE_MOD_TS_MASK | \ + VIVANTE_MOD_COMP_MASK) + /* NVIDIA frame buffer modifiers */ =20 /* diff --git a/include/standard-headers/linux/ethtool.h b/include/standard-he= aders/linux/ethtool.h index 4537da20cc..87176ab075 100644 --- a/include/standard-headers/linux/ethtool.h +++ b/include/standard-headers/linux/ethtool.h @@ -159,8 +159,10 @@ static inline uint32_t ethtool_cmd_speed(const struct = ethtool_cmd *ep) * in its bus driver structure (e.g. pci_driver::name). Must * not be an empty string. * @version: Driver version string; may be an empty string - * @fw_version: Firmware version string; may be an empty string - * @erom_version: Expansion ROM version string; may be an empty string + * @fw_version: Firmware version string; driver defined; may be an + * empty string + * @erom_version: Expansion ROM version string; driver defined; may be + * an empty string * @bus_info: Device bus address. This should match the dev_name() * string for the underlying bus device, if there is one. May be * an empty string. @@ -179,10 +181,6 @@ static inline uint32_t ethtool_cmd_speed(const struct = ethtool_cmd *ep) * * Users can use the %ETHTOOL_GSSET_INFO command to get the number of * strings in any string set (from Linux 2.6.34). - * - * Drivers should set at most @driver, @version, @fw_version and - * @bus_info in their get_drvinfo() implementation. The ethtool - * core fills in the other fields using other driver operations. */ struct ethtool_drvinfo { uint32_t cmd; @@ -736,6 +734,51 @@ enum ethtool_module_power_mode { ETHTOOL_MODULE_POWER_MODE_HIGH, }; =20 +/** + * enum ethtool_podl_pse_admin_state - operational state of the PoDL PSE + * functions. IEEE 802.3-2018 30.15.1.1.2 aPoDLPSEAdminState + * @ETHTOOL_PODL_PSE_ADMIN_STATE_UNKNOWN: state of PoDL PSE functions are + * unknown + * @ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED: PoDL PSE functions are disabled + * @ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED: PoDL PSE functions are enabled + */ +enum ethtool_podl_pse_admin_state { + ETHTOOL_PODL_PSE_ADMIN_STATE_UNKNOWN =3D 1, + ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED, + ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED, +}; + +/** + * enum ethtool_podl_pse_pw_d_status - power detection status of the PoDL = PSE. + * IEEE 802.3-2018 30.15.1.1.3 aPoDLPSEPowerDetectionStatus: + * @ETHTOOL_PODL_PSE_PW_D_STATUS_UNKNOWN: PoDL PSE + * @ETHTOOL_PODL_PSE_PW_D_STATUS_DISABLED: "The enumeration =E2=80=9Cdisab= led=E2=80=9D is + * asserted true when the PoDL PSE state diagram variable mr_pse_enable is + * false" + * @ETHTOOL_PODL_PSE_PW_D_STATUS_SEARCHING: "The enumeration =E2=80=9Csear= ching=E2=80=9D is + * asserted true when either of the PSE state diagram variables + * pi_detecting or pi_classifying is true." + * @ETHTOOL_PODL_PSE_PW_D_STATUS_DELIVERING: "The enumeration =E2=80=9Cdel= iveringPower=E2=80=9D + * is asserted true when the PoDL PSE state diagram variable pi_powered is + * true." + * @ETHTOOL_PODL_PSE_PW_D_STATUS_SLEEP: "The enumeration =E2=80=9Csleep=E2= =80=9D is asserted + * true when the PoDL PSE state diagram variable pi_sleeping is true." + * @ETHTOOL_PODL_PSE_PW_D_STATUS_IDLE: "The enumeration =E2=80=9Cidle=E2= =80=9D is asserted true + * when the logical combination of the PoDL PSE state diagram variables + * pi_prebiased*!pi_sleeping is true." + * @ETHTOOL_PODL_PSE_PW_D_STATUS_ERROR: "The enumeration =E2=80=9Cerror=E2= =80=9D is asserted + * true when the PoDL PSE state diagram variable overload_held is true." + */ +enum ethtool_podl_pse_pw_d_status { + ETHTOOL_PODL_PSE_PW_D_STATUS_UNKNOWN =3D 1, + ETHTOOL_PODL_PSE_PW_D_STATUS_DISABLED, + ETHTOOL_PODL_PSE_PW_D_STATUS_SEARCHING, + ETHTOOL_PODL_PSE_PW_D_STATUS_DELIVERING, + ETHTOOL_PODL_PSE_PW_D_STATUS_SLEEP, + ETHTOOL_PODL_PSE_PW_D_STATUS_IDLE, + ETHTOOL_PODL_PSE_PW_D_STATUS_ERROR, +}; + /** * struct ethtool_gstrings - string set for data tagging * @cmd: Command number =3D %ETHTOOL_GSTRINGS @@ -1692,6 +1735,13 @@ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_100baseFX_Half_BIT =3D 90, ETHTOOL_LINK_MODE_100baseFX_Full_BIT =3D 91, ETHTOOL_LINK_MODE_10baseT1L_Full_BIT =3D 92, + ETHTOOL_LINK_MODE_800000baseCR8_Full_BIT =3D 93, + ETHTOOL_LINK_MODE_800000baseKR8_Full_BIT =3D 94, + ETHTOOL_LINK_MODE_800000baseDR8_Full_BIT =3D 95, + ETHTOOL_LINK_MODE_800000baseDR8_2_Full_BIT =3D 96, + ETHTOOL_LINK_MODE_800000baseSR8_Full_BIT =3D 97, + ETHTOOL_LINK_MODE_800000baseVR8_Full_BIT =3D 98, + /* must be last entry */ __ETHTOOL_LINK_MODE_MASK_NBITS }; @@ -1803,6 +1853,7 @@ enum ethtool_link_mode_bit_indices { #define SPEED_100000 100000 #define SPEED_200000 200000 #define SPEED_400000 400000 +#define SPEED_800000 800000 =20 #define SPEED_UNKNOWN -1 =20 @@ -1840,6 +1891,20 @@ static inline int ethtool_validate_duplex(uint8_t du= plex) #define MASTER_SLAVE_STATE_SLAVE 3 #define MASTER_SLAVE_STATE_ERR 4 =20 +/* These are used to throttle the rate of data on the phy interface when t= he + * native speed of the interface is higher than the link speed. These shou= ld + * not be used for phy interfaces which natively support multiple speeds (= e.g. + * MII or SGMII). + */ +/* No rate matching performed. */ +#define RATE_MATCH_NONE 0 +/* The phy sends pause frames to throttle the MAC. */ +#define RATE_MATCH_PAUSE 1 +/* The phy asserts CRS to prevent the MAC from transmitting. */ +#define RATE_MATCH_CRS 2 +/* The MAC is programmed with a sufficiently-large IPG. */ +#define RATE_MATCH_OPEN_LOOP 3 + /* Which connector port. */ #define PORT_TP 0x00 #define PORT_AUI 0x01 @@ -2033,8 +2098,8 @@ enum ethtool_reset_flags { * reported consistently by PHYLIB. Read-only. * @master_slave_cfg: Master/slave port mode. * @master_slave_state: Master/slave port state. + * @rate_matching: Rate adaptation performed by the PHY * @reserved: Reserved for future use; see the note on reserved space. - * @reserved1: Reserved for future use; see the note on reserved space. * @link_mode_masks: Variable length bitmaps. * * If autonegotiation is disabled, the speed and @duplex represent the @@ -2085,7 +2150,7 @@ struct ethtool_link_settings { uint8_t transceiver; uint8_t master_slave_cfg; uint8_t master_slave_state; - uint8_t reserved1[1]; + uint8_t rate_matching; uint32_t reserved[7]; uint32_t link_mode_masks[]; /* layout of link_mode_masks fields: diff --git a/include/standard-headers/linux/fuse.h b/include/standard-heade= rs/linux/fuse.h index bda06258be..a1af78d989 100644 --- a/include/standard-headers/linux/fuse.h +++ b/include/standard-headers/linux/fuse.h @@ -194,6 +194,13 @@ * - add FUSE_SECURITY_CTX init flag * - add security context to create, mkdir, symlink, and mknod requests * - add FUSE_HAS_INODE_DAX, FUSE_ATTR_DAX + * + * 7.37 + * - add FUSE_TMPFILE + * + * 7.38 + * - add FUSE_EXPIRE_ONLY flag to fuse_notify_inval_entry + * - add FOPEN_PARALLEL_DIRECT_WRITES */ =20 #ifndef _LINUX_FUSE_H @@ -225,7 +232,7 @@ #define FUSE_KERNEL_VERSION 7 =20 /** Minor version number of this interface */ -#define FUSE_KERNEL_MINOR_VERSION 36 +#define FUSE_KERNEL_MINOR_VERSION 38 =20 /** The node ID of the root inode */ #define FUSE_ROOT_ID 1 @@ -297,6 +304,7 @@ struct fuse_file_lock { * FOPEN_CACHE_DIR: allow caching this directory * FOPEN_STREAM: the file is stream-like (no file position at all) * FOPEN_NOFLUSH: don't flush data cache on close (unless FUSE_WRITEBACK_C= ACHE) + * FOPEN_PARALLEL_DIRECT_WRITES: Allow concurrent direct writes on the sam= e inode */ #define FOPEN_DIRECT_IO (1 << 0) #define FOPEN_KEEP_CACHE (1 << 1) @@ -304,6 +312,7 @@ struct fuse_file_lock { #define FOPEN_CACHE_DIR (1 << 3) #define FOPEN_STREAM (1 << 4) #define FOPEN_NOFLUSH (1 << 5) +#define FOPEN_PARALLEL_DIRECT_WRITES (1 << 6) =20 /** * INIT request/reply flags @@ -484,6 +493,12 @@ struct fuse_file_lock { */ #define FUSE_SETXATTR_ACL_KILL_SGID (1 << 0) =20 +/** + * notify_inval_entry flags + * FUSE_EXPIRE_ONLY + */ +#define FUSE_EXPIRE_ONLY (1 << 0) + enum fuse_opcode { FUSE_LOOKUP =3D 1, FUSE_FORGET =3D 2, /* no reply */ @@ -533,6 +548,7 @@ enum fuse_opcode { FUSE_SETUPMAPPING =3D 48, FUSE_REMOVEMAPPING =3D 49, FUSE_SYNCFS =3D 50, + FUSE_TMPFILE =3D 51, =20 /* CUSE specific operations */ CUSE_INIT =3D 4096, @@ -911,7 +927,7 @@ struct fuse_notify_inval_inode_out { struct fuse_notify_inval_entry_out { uint64_t parent; uint32_t namelen; - uint32_t padding; + uint32_t flags; }; =20 struct fuse_notify_delete_out { diff --git a/include/standard-headers/linux/input-event-codes.h b/include/s= tandard-headers/linux/input-event-codes.h index 50790aee5a..f6bab08540 100644 --- a/include/standard-headers/linux/input-event-codes.h +++ b/include/standard-headers/linux/input-event-codes.h @@ -614,6 +614,9 @@ #define KEY_KBD_LAYOUT_NEXT 0x248 /* AC Next Keyboard Layout Select */ #define KEY_EMOJI_PICKER 0x249 /* Show/hide emoji picker (HUTRR101) */ #define KEY_DICTATE 0x24a /* Start or Stop Voice Dictation Session (HUTRR= 99) */ +#define KEY_CAMERA_ACCESS_ENABLE 0x24b /* Enables programmatic access to c= amera devices. (HUTRR72) */ +#define KEY_CAMERA_ACCESS_DISABLE 0x24c /* Disables programmatic access to= camera devices. (HUTRR72) */ +#define KEY_CAMERA_ACCESS_TOGGLE 0x24d /* Toggles the current state of the= camera access control. (HUTRR72) */ =20 #define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ #define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ @@ -862,6 +865,7 @@ #define ABS_TOOL_WIDTH 0x1c =20 #define ABS_VOLUME 0x20 +#define ABS_PROFILE 0x21 =20 #define ABS_MISC 0x28 =20 diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-h= eaders/linux/pci_regs.h index 57b8e2ffb1..85ab127881 100644 --- a/include/standard-headers/linux/pci_regs.h +++ b/include/standard-headers/linux/pci_regs.h @@ -1058,6 +1058,7 @@ /* Precision Time Measurement */ #define PCI_PTM_CAP 0x04 /* PTM Capability */ #define PCI_PTM_CAP_REQ 0x00000001 /* Requester capable */ +#define PCI_PTM_CAP_RES 0x00000002 /* Responder capable */ #define PCI_PTM_CAP_ROOT 0x00000004 /* Root capable */ #define PCI_PTM_GRANULARITY_MASK 0x0000FF00 /* Clock granularity */ #define PCI_PTM_CTRL 0x08 /* PTM Control */ @@ -1119,6 +1120,7 @@ #define PCI_DOE_STATUS_DATA_OBJECT_READY 0x80000000 /* Data Object Ready= */ #define PCI_DOE_WRITE 0x10 /* DOE Write Data Mailbox Register */ #define PCI_DOE_READ 0x14 /* DOE Read Data Mailbox Register */ +#define PCI_DOE_CAP_SIZEOF 0x18 /* Size of DOE register block */ =20 /* DOE Data Object - note not actually registers */ #define PCI_DOE_DATA_OBJECT_HEADER_1_VID 0x0000ffff diff --git a/include/standard-headers/linux/virtio_blk.h b/include/standard= -headers/linux/virtio_blk.h index 2dcc90826a..e81715cd70 100644 --- a/include/standard-headers/linux/virtio_blk.h +++ b/include/standard-headers/linux/virtio_blk.h @@ -40,6 +40,7 @@ #define VIRTIO_BLK_F_MQ 12 /* support more than one vq */ #define VIRTIO_BLK_F_DISCARD 13 /* DISCARD is supported */ #define VIRTIO_BLK_F_WRITE_ZEROES 14 /* WRITE ZEROES is supported */ +#define VIRTIO_BLK_F_SECURE_ERASE 16 /* Secure Erase is supported */ =20 /* Legacy feature bits */ #ifndef VIRTIO_BLK_NO_LEGACY @@ -119,6 +120,21 @@ struct virtio_blk_config { uint8_t write_zeroes_may_unmap; =20 uint8_t unused1[3]; + + /* the next 3 entries are guarded by VIRTIO_BLK_F_SECURE_ERASE */ + /* + * The maximum secure erase sectors (in 512-byte sectors) for + * one segment. + */ + __virtio32 max_secure_erase_sectors; + /* + * The maximum number of secure erase segments in a + * secure erase command. + */ + __virtio32 max_secure_erase_seg; + /* Secure erase commands must be aligned to this number of sectors. */ + __virtio32 secure_erase_sector_alignment; + } QEMU_PACKED; =20 /* @@ -153,6 +169,9 @@ struct virtio_blk_config { /* Write zeroes command */ #define VIRTIO_BLK_T_WRITE_ZEROES 13 =20 +/* Secure erase command */ +#define VIRTIO_BLK_T_SECURE_ERASE 14 + #ifndef VIRTIO_BLK_NO_LEGACY /* Barrier before this op. */ #define VIRTIO_BLK_T_BARRIER 0x80000000 diff --git a/include/standard-headers/linux/virtio_bt.h b/include/standard-= headers/linux/virtio_bt.h index 245e1eff4b..a11ecc3f92 100644 --- a/include/standard-headers/linux/virtio_bt.h +++ b/include/standard-headers/linux/virtio_bt.h @@ -9,6 +9,7 @@ #define VIRTIO_BT_F_VND_HCI 0 /* Indicates vendor command support */ #define VIRTIO_BT_F_MSFT_EXT 1 /* Indicates MSFT vendor support */ #define VIRTIO_BT_F_AOSP_EXT 2 /* Indicates AOSP vendor support */ +#define VIRTIO_BT_F_CONFIG_V2 3 /* Use second version configuration */ =20 enum virtio_bt_config_type { VIRTIO_BT_CONFIG_TYPE_PRIMARY =3D 0, @@ -28,4 +29,11 @@ struct virtio_bt_config { uint16_t msft_opcode; } QEMU_PACKED; =20 +struct virtio_bt_config_v2 { + uint8_t type; + uint8_t alignment; + uint16_t vendor; + uint16_t msft_opcode; +}; + #endif /* _LINUX_VIRTIO_BT_H */ diff --git a/include/standard-headers/linux/virtio_net.h b/include/standard= -headers/linux/virtio_net.h index 42c68caf71..c0e797067a 100644 --- a/include/standard-headers/linux/virtio_net.h +++ b/include/standard-headers/linux/virtio_net.h @@ -57,6 +57,9 @@ * Steering */ #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ #define VIRTIO_NET_F_NOTF_COAL 53 /* Device supports notifications coalesc= ing */ +#define VIRTIO_NET_F_GUEST_USO4 54 /* Guest can handle USOv4 in. */ +#define VIRTIO_NET_F_GUEST_USO6 55 /* Guest can handle USOv6 in. */ +#define VIRTIO_NET_F_HOST_USO 56 /* Host can handle USO in. */ #define VIRTIO_NET_F_HASH_REPORT 57 /* Supports hash report */ #define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */ #define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */ @@ -130,6 +133,7 @@ struct virtio_net_hdr_v1 { #define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */ #define VIRTIO_NET_HDR_GSO_UDP 3 /* GSO frame, IPv4 UDP (UFO) */ #define VIRTIO_NET_HDR_GSO_TCPV6 4 /* GSO frame, IPv6 TCP */ +#define VIRTIO_NET_HDR_GSO_UDP_L4 5 /* GSO frame, IPv4& IPv6 UDP (USO) */ #define VIRTIO_NET_HDR_GSO_ECN 0x80 /* TCP has ECN set */ uint8_t gso_type; __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h index 4bf2d7246e..a7cfefb3a8 100644 --- a/linux-headers/asm-arm64/kvm.h +++ b/linux-headers/asm-arm64/kvm.h @@ -43,6 +43,7 @@ #define __KVM_HAVE_VCPU_EVENTS =20 #define KVM_COALESCED_MMIO_PAGE_OFFSET 1 +#define KVM_DIRTY_LOG_PAGE_OFFSET 64 =20 #define KVM_REG_SIZE(id) \ (1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT)) diff --git a/linux-headers/asm-generic/hugetlb_encode.h b/linux-headers/asm= -generic/hugetlb_encode.h index 4f3d5aaa11..de687009bf 100644 --- a/linux-headers/asm-generic/hugetlb_encode.h +++ b/linux-headers/asm-generic/hugetlb_encode.h @@ -20,18 +20,18 @@ #define HUGETLB_FLAG_ENCODE_SHIFT 26 #define HUGETLB_FLAG_ENCODE_MASK 0x3f =20 -#define HUGETLB_FLAG_ENCODE_16KB (14 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_64KB (16 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_512KB (19 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_1MB (20 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_2MB (21 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_8MB (23 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_16MB (24 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_32MB (25 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_256MB (28 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_512MB (29 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_1GB (30 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_2GB (31 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_16GB (34 << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_16KB (14U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_64KB (16U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_512KB (19U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_1MB (20U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_2MB (21U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_8MB (23U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_16MB (24U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_32MB (25U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_256MB (28U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_512MB (29U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_1GB (30U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_2GB (31U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_16GB (34U << HUGETLB_FLAG_ENCODE_SHIFT) =20 #endif /* _ASM_GENERIC_HUGETLB_ENCODE_H_ */ diff --git a/linux-headers/asm-generic/mman-common.h b/linux-headers/asm-ge= neric/mman-common.h index 6c1aa92a92..6ce1f1ceb4 100644 --- a/linux-headers/asm-generic/mman-common.h +++ b/linux-headers/asm-generic/mman-common.h @@ -77,6 +77,8 @@ =20 #define MADV_DONTNEED_LOCKED 24 /* like DONTNEED, but drop locked pages to= o */ =20 +#define MADV_COLLAPSE 25 /* Synchronous hugepage collapse */ + /* compatibility flags */ #define MAP_FILE 0 =20 diff --git a/linux-headers/asm-mips/mman.h b/linux-headers/asm-mips/mman.h index 1be428663c..c6e1fc77c9 100644 --- a/linux-headers/asm-mips/mman.h +++ b/linux-headers/asm-mips/mman.h @@ -103,6 +103,8 @@ =20 #define MADV_DONTNEED_LOCKED 24 /* like DONTNEED, but drop locked pages to= o */ =20 +#define MADV_COLLAPSE 25 /* Synchronous hugepage collapse */ + /* compatibility flags */ #define MAP_FILE 0 =20 diff --git a/linux-headers/asm-riscv/kvm.h b/linux-headers/asm-riscv/kvm.h index 7351417afd..92af6f3f05 100644 --- a/linux-headers/asm-riscv/kvm.h +++ b/linux-headers/asm-riscv/kvm.h @@ -48,6 +48,10 @@ struct kvm_sregs { /* CONFIG registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */ struct kvm_riscv_config { unsigned long isa; + unsigned long zicbom_block_size; + unsigned long mvendorid; + unsigned long marchid; + unsigned long mimpid; }; =20 /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */ @@ -98,6 +102,9 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_M, KVM_RISCV_ISA_EXT_SVPBMT, KVM_RISCV_ISA_EXT_SSTC, + KVM_RISCV_ISA_EXT_SVINVAL, + KVM_RISCV_ISA_EXT_ZIHINTPAUSE, + KVM_RISCV_ISA_EXT_ZICBOM, KVM_RISCV_ISA_EXT_MAX, }; =20 diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index 46de10a809..2747d2ce14 100644 --- a/linux-headers/asm-x86/kvm.h +++ b/linux-headers/asm-x86/kvm.h @@ -53,14 +53,6 @@ /* Architectural interrupt line count. */ #define KVM_NR_INTERRUPTS 256 =20 -struct kvm_memory_alias { - __u32 slot; /* this has a different namespace than memory slots */ - __u32 flags; - __u64 guest_phys_addr; - __u64 memory_size; - __u64 target_phys_addr; -}; - /* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */ struct kvm_pic_state { __u8 last_irr; /* edge detection */ @@ -214,6 +206,8 @@ struct kvm_msr_list { struct kvm_msr_filter_range { #define KVM_MSR_FILTER_READ (1 << 0) #define KVM_MSR_FILTER_WRITE (1 << 1) +#define KVM_MSR_FILTER_RANGE_VALID_MASK (KVM_MSR_FILTER_READ | \ + KVM_MSR_FILTER_WRITE) __u32 flags; __u32 nmsrs; /* number of msrs in bitmap */ __u32 base; /* MSR index the bitmap starts at */ @@ -224,6 +218,7 @@ struct kvm_msr_filter_range { struct kvm_msr_filter { #define KVM_MSR_FILTER_DEFAULT_ALLOW (0 << 0) #define KVM_MSR_FILTER_DEFAULT_DENY (1 << 0) +#define KVM_MSR_FILTER_VALID_MASK (KVM_MSR_FILTER_DEFAULT_DENY) __u32 flags; struct kvm_msr_filter_range ranges[KVM_MSR_FILTER_MAX_RANGES]; }; diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index ebdafa576d..30b2795d10 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -86,14 +86,6 @@ struct kvm_debug_guest { /* *** End of deprecated interfaces *** */ =20 =20 -/* for KVM_CREATE_MEMORY_REGION */ -struct kvm_memory_region { - __u32 slot; - __u32 flags; - __u64 guest_phys_addr; - __u64 memory_size; /* bytes */ -}; - /* for KVM_SET_USER_MEMORY_REGION */ struct kvm_userspace_memory_region { __u32 slot; @@ -104,9 +96,9 @@ struct kvm_userspace_memory_region { }; =20 /* - * The bit 0 ~ bit 15 of kvm_memory_region::flags are visible for userspac= e, - * other bits are reserved for kvm internal use which are defined in - * include/linux/kvm_host.h. + * The bit 0 ~ bit 15 of kvm_userspace_memory_region::flags are visible for + * userspace, other bits are reserved for kvm internal use which are defin= ed + * in include/linux/kvm_host.h. */ #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) #define KVM_MEM_READONLY (1UL << 1) @@ -483,6 +475,9 @@ struct kvm_run { #define KVM_MSR_EXIT_REASON_INVAL (1 << 0) #define KVM_MSR_EXIT_REASON_UNKNOWN (1 << 1) #define KVM_MSR_EXIT_REASON_FILTER (1 << 2) +#define KVM_MSR_EXIT_REASON_VALID_MASK (KVM_MSR_EXIT_REASON_INVAL | \ + KVM_MSR_EXIT_REASON_UNKNOWN | \ + KVM_MSR_EXIT_REASON_FILTER) __u32 reason; /* kernel -> user */ __u32 index; /* kernel -> user */ __u64 data; /* kernel <-> user */ @@ -1175,6 +1170,9 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220 #define KVM_CAP_S390_ZPCI_OP 221 #define KVM_CAP_S390_CPU_TOPOLOGY 222 +#define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223 +#define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224 +#define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225 =20 #ifdef KVM_CAP_IRQ_ROUTING =20 @@ -1264,6 +1262,7 @@ struct kvm_x86_mce { #define KVM_XEN_HVM_CONFIG_RUNSTATE (1 << 3) #define KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL (1 << 4) #define KVM_XEN_HVM_CONFIG_EVTCHN_SEND (1 << 5) +#define KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG (1 << 6) =20 struct kvm_xen_hvm_config { __u32 flags; @@ -1434,18 +1433,12 @@ struct kvm_vfio_spapr_tce { __s32 tablefd; }; =20 -/* - * ioctls for VM fds - */ -#define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_reg= ion) /* * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns * a vcpu fd. */ #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) -/* KVM_SET_MEMORY_ALIAS is obsolete: */ -#define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_ali= as) #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) #define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \ @@ -1737,6 +1730,8 @@ enum pv_cmd_id { KVM_PV_UNSHARE_ALL, KVM_PV_INFO, KVM_PV_DUMP, + KVM_PV_ASYNC_CLEANUP_PREPARE, + KVM_PV_ASYNC_CLEANUP_PERFORM, }; =20 struct kvm_pv_cmd { @@ -1767,6 +1762,7 @@ struct kvm_xen_hvm_attr { union { __u8 long_mode; __u8 vector; + __u8 runstate_update_flag; struct { __u64 gfn; } shared_info; @@ -1807,6 +1803,8 @@ struct kvm_xen_hvm_attr { /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */ #define KVM_XEN_ATTR_TYPE_EVTCHN 0x3 #define KVM_XEN_ATTR_TYPE_XEN_VERSION 0x4 +/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLA= G */ +#define KVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG 0x5 =20 /* Per-vCPU Xen attributes */ #define KVM_XEN_VCPU_GET_ATTR _IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr) diff --git a/linux-headers/linux/psci.h b/linux-headers/linux/psci.h index 213b2a0f70..e60dfd8907 100644 --- a/linux-headers/linux/psci.h +++ b/linux-headers/linux/psci.h @@ -48,12 +48,26 @@ #define PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU PSCI_0_2_FN64(7) =20 #define PSCI_1_0_FN_PSCI_FEATURES PSCI_0_2_FN(10) +#define PSCI_1_0_FN_CPU_FREEZE PSCI_0_2_FN(11) +#define PSCI_1_0_FN_CPU_DEFAULT_SUSPEND PSCI_0_2_FN(12) +#define PSCI_1_0_FN_NODE_HW_STATE PSCI_0_2_FN(13) #define PSCI_1_0_FN_SYSTEM_SUSPEND PSCI_0_2_FN(14) #define PSCI_1_0_FN_SET_SUSPEND_MODE PSCI_0_2_FN(15) +#define PSCI_1_0_FN_STAT_RESIDENCY PSCI_0_2_FN(16) +#define PSCI_1_0_FN_STAT_COUNT PSCI_0_2_FN(17) + #define PSCI_1_1_FN_SYSTEM_RESET2 PSCI_0_2_FN(18) +#define PSCI_1_1_FN_MEM_PROTECT PSCI_0_2_FN(19) +#define PSCI_1_1_FN_MEM_PROTECT_CHECK_RANGE PSCI_0_2_FN(19) =20 +#define PSCI_1_0_FN64_CPU_DEFAULT_SUSPEND PSCI_0_2_FN64(12) +#define PSCI_1_0_FN64_NODE_HW_STATE PSCI_0_2_FN64(13) #define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14) +#define PSCI_1_0_FN64_STAT_RESIDENCY PSCI_0_2_FN64(16) +#define PSCI_1_0_FN64_STAT_COUNT PSCI_0_2_FN64(17) + #define PSCI_1_1_FN64_SYSTEM_RESET2 PSCI_0_2_FN64(18) +#define PSCI_1_1_FN64_MEM_PROTECT_CHECK_RANGE PSCI_0_2_FN64(19) =20 /* PSCI v0.2 power state encoding for CPU_SUSPEND function */ #define PSCI_0_2_POWER_STATE_ID_MASK 0xffff diff --git a/linux-headers/linux/userfaultfd.h b/linux-headers/linux/userfa= ultfd.h index a3a377cd44..ba5d0df52f 100644 --- a/linux-headers/linux/userfaultfd.h +++ b/linux-headers/linux/userfaultfd.h @@ -12,6 +12,10 @@ =20 #include =20 +/* ioctls for /dev/userfaultfd */ +#define USERFAULTFD_IOC 0xAA +#define USERFAULTFD_IOC_NEW _IO(USERFAULTFD_IOC, 0x00) + /* * If the UFFDIO_API is upgraded someday, the UFFDIO_UNREGISTER and * UFFDIO_WAKE ioctls should be defined as _IOW and not as _IOR. In diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index ede44b5572..c59692ce0b 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -819,12 +819,20 @@ struct vfio_device_feature { * VFIO_MIGRATION_STOP_COPY | VFIO_MIGRATION_P2P means that RUNNING_P2P * is supported in addition to the STOP_COPY states. * + * VFIO_MIGRATION_STOP_COPY | VFIO_MIGRATION_PRE_COPY means that + * PRE_COPY is supported in addition to the STOP_COPY states. + * + * VFIO_MIGRATION_STOP_COPY | VFIO_MIGRATION_P2P | VFIO_MIGRATION_PRE_COPY + * means that RUNNING_P2P, PRE_COPY and PRE_COPY_P2P are supported + * in addition to the STOP_COPY states. + * * Other combinations of flags have behavior to be defined in the future. */ struct vfio_device_feature_migration { __aligned_u64 flags; #define VFIO_MIGRATION_STOP_COPY (1 << 0) #define VFIO_MIGRATION_P2P (1 << 1) +#define VFIO_MIGRATION_PRE_COPY (1 << 2) }; #define VFIO_DEVICE_FEATURE_MIGRATION 1 =20 @@ -875,8 +883,13 @@ struct vfio_device_feature_mig_state { * RESUMING - The device is stopped and is loading a new internal state * ERROR - The device has failed and must be reset * - * And 1 optional state to support VFIO_MIGRATION_P2P: + * And optional states to support VFIO_MIGRATION_P2P: * RUNNING_P2P - RUNNING, except the device cannot do peer to peer DMA + * And VFIO_MIGRATION_PRE_COPY: + * PRE_COPY - The device is running normally but tracking internal state + * changes + * And VFIO_MIGRATION_P2P | VFIO_MIGRATION_PRE_COPY: + * PRE_COPY_P2P - PRE_COPY, except the device cannot do peer to peer DMA * * The FSM takes actions on the arcs between FSM states. The driver implem= ents * the following behavior for the FSM arcs: @@ -908,20 +921,48 @@ struct vfio_device_feature_mig_state { * * To abort a RESUMING session the device must be reset. * + * PRE_COPY -> RUNNING * RUNNING_P2P -> RUNNING * While in RUNNING the device is fully operational, the device may gene= rate * interrupts, DMA, respond to MMIO, all vfio device regions are functio= nal, * and the device may advance its internal state. * + * The PRE_COPY arc will terminate a data transfer session. + * + * PRE_COPY_P2P -> RUNNING_P2P * RUNNING -> RUNNING_P2P * STOP -> RUNNING_P2P * While in RUNNING_P2P the device is partially running in the P2P quies= cent * state defined below. * + * The PRE_COPY_P2P arc will terminate a data transfer session. + * + * RUNNING -> PRE_COPY + * RUNNING_P2P -> PRE_COPY_P2P * STOP -> STOP_COPY - * This arc begin the process of saving the device state and will return= a - * new data_fd. + * PRE_COPY, PRE_COPY_P2P and STOP_COPY form the "saving group" of states + * which share a data transfer session. Moving between these states alte= rs + * what is streamed in session, but does not terminate or otherwise affe= ct + * the associated fd. + * + * These arcs begin the process of saving the device state and will retu= rn a + * new data_fd. The migration driver may perform actions such as enabling + * dirty logging of device state when entering PRE_COPY or PER_COPY_P2P. + * + * Each arc does not change the device operation, the device remains + * RUNNING, P2P quiesced or in STOP. The STOP_COPY state is described be= low + * in PRE_COPY_P2P -> STOP_COPY. + * + * PRE_COPY -> PRE_COPY_P2P + * Entering PRE_COPY_P2P continues all the behaviors of PRE_COPY above. + * However, while in the PRE_COPY_P2P state, the device is partially run= ning + * in the P2P quiescent state defined below, like RUNNING_P2P. + * + * PRE_COPY_P2P -> PRE_COPY + * This arc allows returning the device to a full RUNNING behavior while + * continuing all the behaviors of PRE_COPY. * + * PRE_COPY_P2P -> STOP_COPY * While in the STOP_COPY state the device has the same behavior as STOP * with the addition that the data transfers session continues to stream= the * migration state. End of stream on the FD indicates the entire device @@ -939,6 +980,13 @@ struct vfio_device_feature_mig_state { * device state for this arc if required to prepare the device to receiv= e the * migration data. * + * STOP_COPY -> PRE_COPY + * STOP_COPY -> PRE_COPY_P2P + * These arcs are not permitted and return error if requested. Future + * revisions of this API may define behaviors for these arcs, in this ca= se + * support will be discoverable by a new flag in + * VFIO_DEVICE_FEATURE_MIGRATION. + * * any -> ERROR * ERROR cannot be specified as a device state, however any transition r= equest * can be failed with an errno return and may then move the device_state= into @@ -950,7 +998,7 @@ struct vfio_device_feature_mig_state { * The optional peer to peer (P2P) quiescent state is intended to be a qui= escent * state for the device for the purposes of managing multiple devices with= in a * user context where peer-to-peer DMA between devices may be active. The - * RUNNING_P2P states must prevent the device from initiating + * RUNNING_P2P and PRE_COPY_P2P states must prevent the device from initia= ting * any new P2P DMA transactions. If the device can identify P2P transactio= ns * then it can stop only P2P DMA, otherwise it must stop all DMA. The migr= ation * driver must complete any such outstanding operations prior to completin= g the @@ -963,6 +1011,8 @@ struct vfio_device_feature_mig_state { * above FSM arcs. As there are multiple paths through the FSM arcs the pa= th * should be selected based on the following rules: * - Select the shortest path. + * - The path cannot have saving group states as interior arcs, only + * starting/end states. * Refer to vfio_mig_get_next_state() for the result of the algorithm. * * The automatic transit through the FSM arcs that make up the combination @@ -976,6 +1026,9 @@ struct vfio_device_feature_mig_state { * support them. The user can discover if these states are supported by us= ing * VFIO_DEVICE_FEATURE_MIGRATION. By using combination transitions the use= r can * avoid knowing about these optional states if the kernel driver supports= them. + * + * Arcs touching PRE_COPY and PRE_COPY_P2P are removed if support for PRE_= COPY + * is not present. */ enum vfio_device_mig_state { VFIO_DEVICE_STATE_ERROR =3D 0, @@ -984,8 +1037,225 @@ enum vfio_device_mig_state { VFIO_DEVICE_STATE_STOP_COPY =3D 3, VFIO_DEVICE_STATE_RESUMING =3D 4, VFIO_DEVICE_STATE_RUNNING_P2P =3D 5, + VFIO_DEVICE_STATE_PRE_COPY =3D 6, + VFIO_DEVICE_STATE_PRE_COPY_P2P =3D 7, +}; + +/** + * VFIO_MIG_GET_PRECOPY_INFO - _IO(VFIO_TYPE, VFIO_BASE + 21) + * + * This ioctl is used on the migration data FD in the precopy phase of the + * migration data transfer. It returns an estimate of the current data siz= es + * remaining to be transferred. It allows the user to judge when it is + * appropriate to leave PRE_COPY for STOP_COPY. + * + * This ioctl is valid only in PRE_COPY states and kernel driver should + * return -EINVAL from any other migration state. + * + * The vfio_precopy_info data structure returned by this ioctl provides + * estimates of data available from the device during the PRE_COPY states. + * This estimate is split into two categories, initial_bytes and + * dirty_bytes. + * + * The initial_bytes field indicates the amount of initial precopy + * data available from the device. This field should have a non-zero initi= al + * value and decrease as migration data is read from the device. + * It is recommended to leave PRE_COPY for STOP_COPY only after this field + * reaches zero. Leaving PRE_COPY earlier might make things slower. + * + * The dirty_bytes field tracks device state changes relative to data + * previously retrieved. This field starts at zero and may increase as + * the internal device state is modified or decrease as that modified + * state is read from the device. + * + * Userspace may use the combination of these fields to estimate the + * potential data size available during the PRE_COPY phases, as well as + * trends relative to the rate the device is dirtying its internal + * state, but these fields are not required to have any bearing relative + * to the data size available during the STOP_COPY phase. + * + * Drivers have a lot of flexibility in when and what they transfer during= the + * PRE_COPY phase, and how they report this from VFIO_MIG_GET_PRECOPY_INFO. + * + * During pre-copy the migration data FD has a temporary "end of stream" t= hat is + * reached when both initial_bytes and dirty_byte are zero. For instance, = this + * may indicate that the device is idle and not currently dirtying any int= ernal + * state. When read() is done on this temporary end of stream the kernel d= river + * should return ENOMSG from read(). Userspace can wait for more data (whi= ch may + * never come) by using poll. + * + * Once in STOP_COPY the migration data FD has a permanent end of stream + * signaled in the usual way by read() always returning 0 and poll always + * returning readable. ENOMSG may not be returned in STOP_COPY. + * Support for this ioctl is mandatory if a driver claims to support + * VFIO_MIGRATION_PRE_COPY. + * + * Return: 0 on success, -1 and errno set on failure. + */ +struct vfio_precopy_info { + __u32 argsz; + __u32 flags; + __aligned_u64 initial_bytes; + __aligned_u64 dirty_bytes; +}; + +#define VFIO_MIG_GET_PRECOPY_INFO _IO(VFIO_TYPE, VFIO_BASE + 21) + +/* + * Upon VFIO_DEVICE_FEATURE_SET, allow the device to be moved into a low p= ower + * state with the platform-based power management. Device use of lower po= wer + * states depends on factors managed by the runtime power management core, + * including system level support and coordinating support among dependent + * devices. Enabling device low power entry does not guarantee lower power + * usage by the device, nor is a mechanism provided through this feature to + * know the current power state of the device. If any device access happe= ns + * (either from the host or through the vfio uAPI) when the device is in t= he + * low power state, then the host will move the device out of the low power + * state as necessary prior to the access. Once the access is completed, = the + * device may re-enter the low power state. For single shot low power sup= port + * with wake-up notification, see + * VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP below. Access to mmap'd + * device regions is disabled on LOW_POWER_ENTRY and may only be resumed a= fter + * calling LOW_POWER_EXIT. + */ +#define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY 3 + +/* + * This device feature has the same behavior as + * VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY with the exception that the user + * provides an eventfd for wake-up notification. When the device moves ou= t of + * the low power state for the wake-up, the host will not allow the device= to + * re-enter a low power state without a subsequent user call to one of the= low + * power entry device feature IOCTLs. Access to mmap'd device regions is + * disabled on LOW_POWER_ENTRY_WITH_WAKEUP and may only be resumed after t= he + * low power exit. The low power exit can happen either through LOW_POWER= _EXIT + * or through any other access (where the wake-up notification has been + * generated). The access to mmap'd device regions will not trigger low p= ower + * exit. + * + * The notification through the provided eventfd will be generated only wh= en + * the device has entered and is resumed from a low power state after + * calling this device feature IOCTL. A device that has not entered low p= ower + * state, as managed through the runtime power management core, will not + * generate a notification through the provided eventfd on access. Callin= g the + * LOW_POWER_EXIT feature is optional in the case where notification has b= een + * signaled on the provided eventfd that a resume from low power has occur= red. + */ +struct vfio_device_low_power_entry_with_wakeup { + __s32 wakeup_eventfd; + __u32 reserved; +}; + +#define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP 4 + +/* + * Upon VFIO_DEVICE_FEATURE_SET, disallow use of device low power states as + * previously enabled via VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY or + * VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP device features. + * This device feature IOCTL may itself generate a wakeup eventfd notifica= tion + * in the latter case if the device had previously entered a low power sta= te. + */ +#define VFIO_DEVICE_FEATURE_LOW_POWER_EXIT 5 + +/* + * Upon VFIO_DEVICE_FEATURE_SET start/stop device DMA logging. + * VFIO_DEVICE_FEATURE_PROBE can be used to detect if the device supports + * DMA logging. + * + * DMA logging allows a device to internally record what DMAs the device is + * initiating and report them back to userspace. It is part of the VFIO + * migration infrastructure that allows implementing dirty page tracking + * during the pre copy phase of live migration. Only DMA WRITEs are logged, + * and this API is not connected to VFIO_DEVICE_FEATURE_MIG_DEVICE_STATE. + * + * When DMA logging is started a range of IOVAs to monitor is provided and= the + * device can optimize its logging to cover only the IOVA range given. Each + * DMA that the device initiates inside the range will be logged by the de= vice + * for later retrieval. + * + * page_size is an input that hints what tracking granularity the device + * should try to achieve. If the device cannot do the hinted page size then + * it's the driver choice which page size to pick based on its support. + * On output the device will return the page size it selected. + * + * ranges is a pointer to an array of + * struct vfio_device_feature_dma_logging_range. + * + * The core kernel code guarantees to support by minimum num_ranges that f= it + * into a single kernel page. User space can try higher values but should = give + * up if the above can't be achieved as of some driver limitations. + * + * A single call to start device DMA logging can be issued and a matching = stop + * should follow at the end. Another start is not allowed in the meantime. + */ +struct vfio_device_feature_dma_logging_control { + __aligned_u64 page_size; + __u32 num_ranges; + __u32 __reserved; + __aligned_u64 ranges; }; =20 +struct vfio_device_feature_dma_logging_range { + __aligned_u64 iova; + __aligned_u64 length; +}; + +#define VFIO_DEVICE_FEATURE_DMA_LOGGING_START 6 + +/* + * Upon VFIO_DEVICE_FEATURE_SET stop device DMA logging that was started + * by VFIO_DEVICE_FEATURE_DMA_LOGGING_START + */ +#define VFIO_DEVICE_FEATURE_DMA_LOGGING_STOP 7 + +/* + * Upon VFIO_DEVICE_FEATURE_GET read back and clear the device DMA log + * + * Query the device's DMA log for written pages within the given IOVA rang= e. + * During querying the log is cleared for the IOVA range. + * + * bitmap is a pointer to an array of u64s that will hold the output bitmap + * with 1 bit reporting a page_size unit of IOVA. The mapping of IOVA to b= its + * is given by: + * bitmap[(addr - iova)/page_size] & (1ULL << (addr % 64)) + * + * The input page_size can be any power of two value and does not have to + * match the value given to VFIO_DEVICE_FEATURE_DMA_LOGGING_START. The dri= ver + * will format its internal logging to match the reporting page size, poss= ibly + * by replicating bits if the internal page size is lower than requested. + * + * The LOGGING_REPORT will only set bits in the bitmap and never clear or + * perform any initialization of the user provided bitmap. + * + * If any error is returned userspace should assume that the dirty log is + * corrupted. Error recovery is to consider all memory dirty and try to + * restart the dirty tracking, or to abort/restart the whole migration. + * + * If DMA logging is not enabled, an error will be returned. + * + */ +struct vfio_device_feature_dma_logging_report { + __aligned_u64 iova; + __aligned_u64 length; + __aligned_u64 page_size; + __aligned_u64 bitmap; +}; + +#define VFIO_DEVICE_FEATURE_DMA_LOGGING_REPORT 8 + +/* + * Upon VFIO_DEVICE_FEATURE_GET read back the estimated data length that w= ill + * be required to complete stop copy. + * + * Note: Can be called on each device state. + */ + +struct vfio_device_feature_mig_data_size { + __aligned_u64 stop_copy_length; +}; + +#define VFIO_DEVICE_FEATURE_MIG_DATA_SIZE 9 + /* -------- API for Type1 VFIO IOMMU -------- */ =20 /** --=20 2.26.3 From nobody Sat Apr 27 01:04:01 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1673513586; cv=pass; d=zohomail.com; s=zohoarc; b=Ua6qB9nxgZu9J0ZLo58esUbJUNS1TXTPT11c8nk8Ft3nISA4yUQ+wHAUIvdTISPVc9+Mswf8RcIh13rNiv+DiCRAR48z8PpM9+G99jP1aBvF60KLLI7btAWwTjG3qedylu+NlDmNcWcQKGCu15KbO4j7B3H1NA6KofV2Jg+EG7g= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673513586; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cCAXggWAAw5x+H9R1l/6Zz6M5lu7IldvVJZw9bWHbH0=; b=O26Wtk7BLUseCJy7ghbzpZfmidg61kVyebou8Wt27zOVTZMLUI6rcYYTmDio18VPeFeBaDR/LICKv+7cRRBdVEkp/87vcRGIP/eHgXef3rYvEV1EhqtkTzjMMMpK8r41G64keoRchubdQ+itQZ8B20yBPbkKoK66iyfx2P/beg8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673513586831995.6036851613007; Thu, 12 Jan 2023 00:53:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFtIs-0005hx-Kg; Thu, 12 Jan 2023 03:51:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtIb-0005cz-TN; Thu, 12 Jan 2023 03:51:02 -0500 Received: from mail-dm6nam10on2086.outbound.protection.outlook.com ([40.107.93.86] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtIX-0007Wu-Nb; Thu, 12 Jan 2023 03:50:59 -0500 Received: from MW4PR03CA0350.namprd03.prod.outlook.com (2603:10b6:303:dc::25) by IA1PR12MB6163.namprd12.prod.outlook.com (2603:10b6:208:3e9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Thu, 12 Jan 2023 08:50:51 +0000 Received: from CO1NAM11FT069.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::bd) by MW4PR03CA0350.outlook.office365.com (2603:10b6:303:dc::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:50:51 +0000 Received: from mail.nvidia.com (216.228.118.233) by CO1NAM11FT069.mail.protection.outlook.com (10.13.174.129) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:50:50 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:50:41 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:50:41 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 12 Jan 2023 00:50:34 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bncZ1LoYLbNcttHa5CXOX2FrnoyR+tv6ayQlOh0aHSnkmf/KWZF+rRYqCfhc+dlSUJLhZYedMKnMtY+eoMHwpxadrCMpNzsMB3V8gu5UY8f2NX+v4fD+km25RsysM7twAapePPkR5/WW7UbT9Ilbwf7/EZ+d3XskmHIkCwnv3A5rjAQmTkXXDHi4GYDpFJF03yjpXKUCgDvDpl+p4m68qWGkn7JZ8KlEIqA7Orx/aEqHa+F6N9ZOLc2Fy4c4RnIaumQbu0EWh8hLKZSIx7B3NJRiGfR3XLNPeMOzSeoNfqm+nSrJlZa3CTnycOTLKMoGfo2GuKlET5Wz8B+B1cSEHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cCAXggWAAw5x+H9R1l/6Zz6M5lu7IldvVJZw9bWHbH0=; b=O0BrAyKurmcfJbxn8H/xEXcON4Hlocslsma/9q2iSwm6F6VyKQxvPwppsKZtkQcj942IQ2wVW3bPa6o4NIta0p8ZmQInFimu7hphW5P35Lo/LCJKUohEFkJClePVQ/Flkv3Trk+zFK+Q14mQfLC1nFP3kr2Ilz//KMfFD4+L8TivqLLA6XOqEgi+H8E4BUzODGcvPW4DnE5LwGtTqQrtYkcB51tlMrXUSji04FEjqXtc9YUZsGVsZD3feU3aPi5zSpWhJXr+TR9dm6HjKGxgWQE1PH0kXEid7A5UGe9qYeDXvKMcnytlDUCMy9Pzo6fmoljeBEJhuvLraoF8dRXlOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cCAXggWAAw5x+H9R1l/6Zz6M5lu7IldvVJZw9bWHbH0=; b=DpxBD+NoyeQylfIwZj2pWjpxVuDQHr3r89/kOxee3f3NZED6nhIssjicpnKHtTTpknnNnsCP40k59/vkelL+aF1/ic8+W7z9Lhuqd75Mdn4th4F6qfXg6xMD+8I88r+auyyEvtw9Yqy0y/Km7UAOdMAs3A8mCd0/4iXSX33ar65APMreub39IfdNPrsGGDUQhtwa5jBP4czm7S5ycnrXVvv+drxdmzAC5hIMlEBQbrxfI6pFuSV5ciKcsjE9Ei+xOnYo/cKtCrpZKe8FHEYyfn0VS6V3Xjc9+00LuwcsTLkey8iAyGc24u8gNZP1HKI9wgnIkRe4ebW4zf9c7XSspw== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , "Ilya Leoshkevich" , Thomas Huth , "Juan Quintela" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v6 02/13] migration: No save_live_pending() method uses the QEMUFile parameter Date: Thu, 12 Jan 2023 10:50:09 +0200 Message-ID: <20230112085020.15866-3-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230112085020.15866-1-avihaih@nvidia.com> References: <20230112085020.15866-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT069:EE_|IA1PR12MB6163:EE_ X-MS-Office365-Filtering-Correlation-Id: 16c718bd-c6c4-4ae0-5865-08daf47a1b4a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mshW9eumkqgAG3MgYs146LetOxdRmaue3gIs//1ETwO0/Wz/vC5ilqP66FAP9fZDdm7/5X2kFpqiSGvVl3alxgLlbueAEKvTWhWBKqWsqE+/VR4dY7xy84H40Ml3b+0XL2o17+itggPtI2DSIspM4cjzV7AaDkMdajBA4sW/BL7X9ZhJszphKGUgDLVhHv5xdKmgSG1HoQKTpFkOdRKntyW+BcQ7qy3DOqqBbKNatTqIQiupD279BKOfdYHiblHz7y+KH+WHq/c85jjgTLti0iOUe8qh5fB1hX28ugFWceeqBg870oK2Nlr7XHw/L6+JWpv/Y56pOwnFPIS8dxJhocWTpBnKNEwaqDq5jUwXWDVGEgDyZo1prpUJdNja2wZCwRB5w1C5OHcleUIHKmSRLLncSXUKHAaOmPE1U9i1+aec/TzTtUnyzs5/uEEWfXebtwpd9A8e8psXyOppOpHUaIFtQLqHDOENal81dd3VFrSfd7txtHx442F8NEwfagsqtNfRLUPej9n5XDXdSRfSN2lmA70nVmpBjswTdxudC7OXyBr8mhMjmAe7AW3B6ZDbXQsUY2q+CiXEuGlcMN5VsDzZmrvQWjZOj5g3r6Fzt36rcrG0wiKzF/25I7W2BvoLlkuDUlC/6cQiuQYrXZ18KLlDdDfB4SWVcOa3yNKc6pyI2EGSFoEGF6p3p9npYeWxj2NS6ZFRGU1j417NlvGJcw== X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(376002)(396003)(346002)(136003)(451199015)(36840700001)(40470700004)(46966006)(47076005)(6666004)(40480700001)(2616005)(336012)(186003)(26005)(4326008)(316002)(1076003)(70206006)(7696005)(6916009)(54906003)(478600001)(70586007)(36860700001)(356005)(7636003)(82740400003)(86362001)(426003)(83380400001)(40460700003)(7416002)(82310400005)(41300700001)(8676002)(36756003)(5660300002)(2906002)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 08:50:50.6453 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 16c718bd-c6c4-4ae0-5865-08daf47a1b4a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT069.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6163 Received-SPF: softfail client-ip=40.107.93.86; envelope-from=avihaih@nvidia.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com 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_H2=-0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1673513587765100001 Content-Type: text/plain; charset="utf-8" From: Juan Quintela So remove it everywhere. Signed-off-by: Juan Quintela Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Dr. David Alan Gilbert --- include/migration/register.h | 3 +-- migration/savevm.h | 3 +-- hw/s390x/s390-stattrib.c | 2 +- hw/vfio/migration.c | 3 +-- migration/block-dirty-bitmap.c | 3 +-- migration/block.c | 2 +- migration/migration.c | 4 ++-- migration/ram.c | 2 +- migration/savevm.c | 7 +++---- 9 files changed, 12 insertions(+), 17 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index c1dcff0f90..eb6266a877 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -46,8 +46,7 @@ typedef struct SaveVMHandlers { =20 /* This runs outside the iothread lock! */ int (*save_setup)(QEMUFile *f, void *opaque); - void (*save_live_pending)(QEMUFile *f, void *opaque, - uint64_t threshold_size, + void (*save_live_pending)(void *opaque, uint64_t threshold_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only); diff --git a/migration/savevm.h b/migration/savevm.h index 6461342cb4..6dec468cc3 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -40,8 +40,7 @@ void qemu_savevm_state_cleanup(void); void qemu_savevm_state_complete_postcopy(QEMUFile *f); int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only, bool inactivate_disks); -void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size, - uint64_t *res_precopy_only, +void qemu_savevm_state_pending(uint64_t max_size, uint64_t *res_precopy_on= ly, uint64_t *res_compatible, uint64_t *res_postcopy_only); void qemu_savevm_send_ping(QEMUFile *f, uint32_t value); diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index 9eda1c3b2a..a553a1e850 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -182,7 +182,7 @@ static int cmma_save_setup(QEMUFile *f, void *opaque) return 0; } =20 -static void cmma_save_pending(QEMUFile *f, void *opaque, uint64_t max_size, +static void cmma_save_pending(void *opaque, uint64_t max_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index c74453e0b5..e1413ac90c 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -456,8 +456,7 @@ static void vfio_save_cleanup(void *opaque) trace_vfio_save_cleanup(vbasedev->name); } =20 -static void vfio_save_pending(QEMUFile *f, void *opaque, - uint64_t threshold_size, +static void vfio_save_pending(void *opaque, uint64_t threshold_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 283017d7d3..ffc433cd11 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -761,8 +761,7 @@ static int dirty_bitmap_save_complete(QEMUFile *f, void= *opaque) return 0; } =20 -static void dirty_bitmap_save_pending(QEMUFile *f, void *opaque, - uint64_t max_size, +static void dirty_bitmap_save_pending(void *opaque, uint64_t max_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) diff --git a/migration/block.c b/migration/block.c index 4347da1526..b6a98caf78 100644 --- a/migration/block.c +++ b/migration/block.c @@ -862,7 +862,7 @@ static int block_save_complete(QEMUFile *f, void *opaqu= e) return 0; } =20 -static void block_save_pending(QEMUFile *f, void *opaque, uint64_t max_siz= e, +static void block_save_pending(void *opaque, uint64_t max_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) diff --git a/migration/migration.c b/migration/migration.c index 52b5d39244..9795d0ec5c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3751,8 +3751,8 @@ static MigIterateState migration_iteration_run(Migrat= ionState *s) uint64_t pending_size, pend_pre, pend_compat, pend_post; bool in_postcopy =3D s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE; =20 - qemu_savevm_state_pending(s->to_dst_file, s->threshold_size, &pend_pre, - &pend_compat, &pend_post); + qemu_savevm_state_pending(s->threshold_size, &pend_pre, &pend_compat, + &pend_post); pending_size =3D pend_pre + pend_compat + pend_post; =20 trace_migrate_pending(pending_size, s->threshold_size, diff --git a/migration/ram.c b/migration/ram.c index 334309f1c6..35a251b297 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3392,7 +3392,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) return 0; } =20 -static void ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size, +static void ram_save_pending(void *opaque, uint64_t max_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) diff --git a/migration/savevm.c b/migration/savevm.c index a0cdb714f7..a94e637904 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1471,7 +1471,7 @@ flush: * the result is split into the amount for units that can and * for units that can't do postcopy. */ -void qemu_savevm_state_pending(QEMUFile *f, uint64_t threshold_size, +void qemu_savevm_state_pending(uint64_t threshold_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) @@ -1492,9 +1492,8 @@ void qemu_savevm_state_pending(QEMUFile *f, uint64_t = threshold_size, continue; } } - se->ops->save_live_pending(f, se->opaque, threshold_size, - res_precopy_only, res_compatible, - res_postcopy_only); + se->ops->save_live_pending(se->opaque, threshold_size, res_precopy= _only, + res_compatible, res_postcopy_only); } } =20 --=20 2.26.3 From nobody Sat Apr 27 01:04:01 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1673513708; cv=pass; d=zohomail.com; s=zohoarc; b=PvfxnuNZBUTGB7d0JoowYMrlpmg+5XW5pT/I7pYZb1Ubd4YdrxZVblOtk1S/VZ3astkepN+rq8tZ9cE3eA9K7S6Zx/OsMb0FU48OiBamUwlocn9T7mMN9BTDoe9IqofSu8FyGKIZzRkDDcPinN21rS2u2OG2LT2rriJBzkd0qiw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673513708; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jJkOFNmqZNgWafMrpbwZLIyQY9fQkQPMJwKlAZkkfgk=; b=NgXMreSATFRJ9y6YMoezoOSVtBe1GEuredm+5MYzgP3JFHQN9RXJit6uwqlxflaW87tf1JV1LlpOt954Fm/9MChzH4BIlpF05mwRsgqVDySb2GihZ3WHo5RQS5FGYVfqjADhFwE1ppNPQnPLT9MjutjHjT5ixzbXE9n7sMoSSqE= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673513708071323.48156878954705; Thu, 12 Jan 2023 00:55:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFtK4-0006LC-UL; Thu, 12 Jan 2023 03:52:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtIo-0005fo-EQ; Thu, 12 Jan 2023 03:51:18 -0500 Received: from mail-co1nam11on2080.outbound.protection.outlook.com ([40.107.220.80] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtIh-0007Xq-QY; Thu, 12 Jan 2023 03:51:09 -0500 Received: from DM6PR14CA0043.namprd14.prod.outlook.com (2603:10b6:5:18f::20) by PH7PR12MB7986.namprd12.prod.outlook.com (2603:10b6:510:27d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Thu, 12 Jan 2023 08:51:00 +0000 Received: from DS1PEPF0000E632.namprd02.prod.outlook.com (2603:10b6:5:18f:cafe::bd) by DM6PR14CA0043.outlook.office365.com (2603:10b6:5:18f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:50:59 +0000 Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0000E632.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.11 via Frontend Transport; Thu, 12 Jan 2023 08:50:59 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:50:48 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:50:47 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 12 Jan 2023 00:50:41 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PKxPd4Rrxal3Ey3QWJs2aFHajEDUC6LCd3u/ebCwdc/MPjvdCgtMaepfvfRsLdzqtwP/YqB3BGTFxZbWAJUXcl6cxg9U+tzxC2u1t4Wzvt9qeFCPoN8hQiIJCa074aCDTkXZIBLfr9lCYmShJIyUZ35na7MzffOxwof5JF46/bESKTnDmo8MGD/61VnV7OZn83MDFEYtZhStE1PIHKHNCX8eiiOLZ4tT5CkwjN7qpFDDB/yuOrKQEbTIITcJ+saU6XC4cyCflESiwoeqSBy7v+NeQSseUg1iqTKDL+Cb3tSM4WBy7mXMk2XqOfl7Cn2wuuNDaIEwGBdyaJW5r8Xp2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jJkOFNmqZNgWafMrpbwZLIyQY9fQkQPMJwKlAZkkfgk=; b=fIN5Pom13HRx9d9ByAY7iXMsSW2GNMLhy0lhnEKri0rbsijIRF0oFf/+0fo26EWtVLBCGfTchLzLwjNRBwktIBKxc8TxKBA2FuENZAi/Cpjo1P8ePxrPdXpXymgQ3rwXg0xcIrBn/IUeCdokZgVU8Kxma/WKl+0Bq1tQAUCCHRl+hcU1PAuHeRqY8olGgDHftVKVA+HKzK+29CSp1bbIOKwes5fY1/xKVpvQlI10AFG4uJV98NAnSxT7JzPbAv0FkNCi3LrX11y+AoqwZCX7VeC6HhIRCN84+ZypCfpP0i+PTvZXXnbmDRjC4tdFbQJEk5lvos3t76betReDVrKbcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jJkOFNmqZNgWafMrpbwZLIyQY9fQkQPMJwKlAZkkfgk=; b=LQxZxwCAxqcKfJtK3UdSMxQQMPtS23c46+9MczhHn/4E6811MGnBMdizr+9l8AS7bnh5ZEw86IAZQxUoPHUDEsTMcVhsUuCRxS9aHvLUnQt1AKIV5/2NKIcHrXEd5UocHKd9/UWTfwEoUbhWZItIukwUs6xWrZ08IDmRmTeU6pkDXUoZ0l501naorsmkpT9RSm971lJBxuHNnzctvgNeJAM4IKFbERfMPYw2FeKk7Xupvyv/1rRh1Q5LVV1H36vFt3ZgiWbgnDclhSx+clJXDfbAHM1TGnJyqJ8ElVcKUVeBpUU5e5g4wNjQMKil1lDCsQRSUBcz6JmLw4kRlOupag== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , "Ilya Leoshkevich" , Thomas Huth , "Juan Quintela" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v6 03/13] vfio/migration: Fix NULL pointer dereference bug Date: Thu, 12 Jan 2023 10:50:10 +0200 Message-ID: <20230112085020.15866-4-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230112085020.15866-1-avihaih@nvidia.com> References: <20230112085020.15866-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E632:EE_|PH7PR12MB7986:EE_ X-MS-Office365-Filtering-Correlation-Id: e2d2a6d9-7302-4202-3fb4-08daf47a20a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TB4nhpOVNp9rxc7B6O+Qlcf0Z5k94aq65MhHuZaCBta+mTmRna3C3nuFda1i9fvQPS33ExixlyOFltJOW/I1CAsg1gMiFyGLR8EkM2kXzMxCmdPvINLnH+jse3SixIiwq6bIapf4C2Lb6J9obIwqcXYB9vcFEbjdgdvpX/tjqpCbpXq4Px+ctjgkuQZWF9lG7sViSITynTWJfcp9Ni4swv1aYVhKC7ZfXPS8tN0KodHsGfStQq1gQCVS9qEf4uIzIQYfvN0QWvqco+bPf+gmfcTTkx4udut4OM4YkfJVRBff6GkkwqfN097ig8FYi1NQ80mjaeJD9iA0g6KMIHK/HH/yO4n4yIpctck0jz/eCzOvrhCtIoVHxyfdULCJHlc9DI0BdX8Ty4e11Z3Z4A6rCbDZ73MvN4gbX81puwezPku4+z5X9OcyWkj2d00SD/zumLCv3bRdzIned1ZMp3g9dEfx3byj5/jBsNlYv1gV6HexuvjNuUZr1m4I+0kiaQe+A4UQpt7hR8rJbPUZwtPuG9MqzB0SeXUM//EV6rtcNXtS4L5NIM/lWdBWha1HSXU3lT0cUwSXNXGe2A6lEB+TIObXfxvU/5PAlXuEdNEpm/1isXCwBdZEc2GasIkbOcSfI1cXgMDgk1unsvRV4D5QCgZA5FKXjVF6TFOqvLaEZdus6WptkVdn975AR2dquNYgUMaY+IS2MD0LbfAU9VuNBQ== X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(376002)(346002)(136003)(39860400002)(396003)(451199015)(40470700004)(36840700001)(46966006)(40480700001)(54906003)(186003)(2616005)(82310400005)(1076003)(6666004)(336012)(40460700003)(47076005)(4326008)(86362001)(70586007)(70206006)(7416002)(5660300002)(426003)(478600001)(36756003)(8676002)(6916009)(2906002)(26005)(82740400003)(316002)(8936002)(36860700001)(7636003)(356005)(41300700001)(7696005)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 08:50:59.5959 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2d2a6d9-7302-4202-3fb4-08daf47a20a7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E632.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7986 Received-SPF: softfail client-ip=40.107.220.80; envelope-from=avihaih@nvidia.com; helo=NAM11-CO1-obe.outbound.protection.outlook.com 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_H2=-0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1673513708518100003 Content-Type: text/plain; charset="utf-8" As part of its error flow, vfio_vmstate_change() accesses MigrationState->to_dst_file without any checks. This can cause a NULL pointer dereference if the error flow is taken and MigrationState->to_dst_file is not set. For example, this can happen if VM is started or stopped not during migration and vfio_vmstate_change() error flow is taken, as MigrationState->to_dst_file is not set at that time. Fix it by checking that MigrationState->to_dst_file is set before using it. Fixes: 02a7e71b1e5b ("vfio: Add VM state change handler to know state of VM= ") Signed-off-by: Avihai Horon Reviewed-by: Juan Quintela Reviewed-by: Vladimir Sementsov-Ogievskiy --- hw/vfio/migration.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index e1413ac90c..09fe7c1de2 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -743,7 +743,9 @@ static void vfio_vmstate_change(void *opaque, bool runn= ing, RunState state) */ error_report("%s: Failed to set device state 0x%x", vbasedev->name, (migration->device_state & mask) | value); - qemu_file_set_error(migrate_get_current()->to_dst_file, ret); + if (migrate_get_current()->to_dst_file) { + qemu_file_set_error(migrate_get_current()->to_dst_file, ret); + } } vbasedev->migration->vm_running =3D running; trace_vfio_vmstate_change(vbasedev->name, running, RunState_str(state), --=20 2.26.3 From nobody Sat Apr 27 01:04:01 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1673514390; cv=pass; d=zohomail.com; s=zohoarc; b=LGZ10DON5wFC5bBQM13zYNV/oSP6dkV21h4nCno87yvalUdLZD3MUVp41v9eKNYBZhquuBz9cd8kaAGH6WueQToxJOrtudnwvgiVw84vWg7PpxNTR/Z8xq1dG+OHfQDO9v1MH79oxDc3xALIaTHL/Z0gje3qKwPiHFXARjLmxsg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673514390; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BaJ38liVsUzOA3vHwYlHsSh8cwLPTulKqyW2kq98Nxw=; b=GRqtkB3DpPjOgFTa9/kp4ESNullOqmt3QnwpNEVuf6PnsCnl7m3iR7rfNPn+PPtJ7PtuJxgnou+7q4BCt8aoWuWu9TKjhGtITmkasUYj4HxdAc7iwkiQvvoWoGoistLc4Si3TGEYvi/GohyUdVMsdPAqpseRhQuT25TUVds6cLg= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16735143901172.036718039234529; Thu, 12 Jan 2023 01:06:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFtJX-0005uy-48; Thu, 12 Jan 2023 03:51:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtIq-0005gI-H0; Thu, 12 Jan 2023 03:51:18 -0500 Received: from mail-mw2nam12on2071.outbound.protection.outlook.com ([40.107.244.71] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtIo-0007Z0-9m; Thu, 12 Jan 2023 03:51:16 -0500 Received: from DS7PR03CA0016.namprd03.prod.outlook.com (2603:10b6:5:3b8::21) by DM4PR12MB5086.namprd12.prod.outlook.com (2603:10b6:5:389::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Thu, 12 Jan 2023 08:51:08 +0000 Received: from DS1PEPF0000E635.namprd02.prod.outlook.com (2603:10b6:5:3b8:cafe::73) by DS7PR03CA0016.outlook.office365.com (2603:10b6:5:3b8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:51:08 +0000 Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0000E635.mail.protection.outlook.com (10.167.17.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.11 via Frontend Transport; Thu, 12 Jan 2023 08:51:08 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:50:55 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:50:54 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 12 Jan 2023 00:50:48 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wif2XM9MIJ96/j5ILHMek1fbW0nWBWjiB2yizOnG6maLNPkGwz8jNaY/ndS6X+qapgcp7AV0bRW0h8uvCaAWSHVd4H76ee1YtRAvzvjOkPjktpLW3N4XMOdiXpZVPeS4wAP6xr6sDjDIez15/35jYl40Vt++Y1RqZ5PNuDuY4WFT0Ds+LmKiT3oV5JIZRzEwMoKbZA27enb5I2zGdI3SBDP9gsGfWWATvsn5936jdFU7WH0OYEDfwD7gW9sKpQKaHgrfhPzb/XEGWnMVK7kgiUIIRQG4iQxI8Dy1rodoWxg8baUmjE2SnjZ23jxSrCtYpQk+msW294Engizhpr8Njg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BaJ38liVsUzOA3vHwYlHsSh8cwLPTulKqyW2kq98Nxw=; b=D8Wv2lm7BH9mvtJc0QS6mgybxQQidsiRND1JkgluF5M+M9xQkA0FBKKDs+PJgd8C8Eqix1ZzI2/8/OEcQX9qT6BijCWue99A1878FOLhsunRske/OvxhxN9QiuzS/No0syAf8fLSv0THIZLBdfxaJO2R6rxfoVAJ+PObFKxtNhs3/zLJ7uXjQ2QpoFbopWQHKMqOvixlckul36kXxXSec/nCbLOuNVc/RCecH2s+VFFTuRqwBMy2z2N3qwDHpRyIkGE3VoJnHJN5t7/4l+Te+azmqkz5o3r+/rkJnPSOUijav4nNRBXB7ErkwyXoJ18mn4aioqQrTeNfmvcCc3s8DQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BaJ38liVsUzOA3vHwYlHsSh8cwLPTulKqyW2kq98Nxw=; b=pBBdDaislFyW7BRIryI86xaEkd+dthXbUYFlDI/cwmETgHqGe5d4/HjOaVex5pNDvBYBq6jMPLWuGcxyHMQ3kfjRqNpUxzZhpYacqKoCP0cb3aO97YgOpqIIj3ue9jVYKwr7TmHqtsdgLOOUK7cdMlXlE+aEdAS7qBDBPgd4+xIhPW5J7EN75p9wQSGNBmspFUOepSS6Mure2dDvD2TMfSTpECjDYmC5GsKruYHJfxcrwZti6KusZpXQWTCoS22M1bzRFVSlAUXRX6AOhLHIzbtwbOtCl0SEvD/A7DaV7NUgJ2tyqkh9WUz0HhO4PlBDt3Oj7LEW0Ed9dJ4ALRlxcA== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , "Ilya Leoshkevich" , Thomas Huth , "Juan Quintela" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v6 04/13] vfio/migration: Allow migration without VFIO IOMMU dirty tracking support Date: Thu, 12 Jan 2023 10:50:11 +0200 Message-ID: <20230112085020.15866-5-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230112085020.15866-1-avihaih@nvidia.com> References: <20230112085020.15866-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E635:EE_|DM4PR12MB5086:EE_ X-MS-Office365-Filtering-Correlation-Id: 674d9225-07dd-47ef-8ace-08daf47a25b6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6z2BgzP6ENhGTdUD7zkQfi7oGdEDH5N1T2+tlBIpmdsrfHEY/PuDj94g1f0KOoFyKw3NhALxvPxTUPbWVcQ6/2j3pP2opsiXHAvO78OrHu6fR1ZF82fvhwcuEsrkd+9GU7/Y9ahHpnbjwD11zgMkSA2mh9rY+iap/Cwu6WHMwGyEqY+v1taO875zdV8BlIpuQcg7/YVFvOq35k1WwHrDVbZJHtKcMis8Ey3tkCoZVlTjYyAHSk/aUYa+E4UCu/Hw4qkChMbYm7ZHC6oYEAkrYMwD9QWbD669wif0UB+XsCOGwgloY+UJU03gF7fgOw5oYIqcfpqoOrP96H9hghMFtknTSJ1EIi792L3r8HRTQO4spzsCE50A+ZMQlZcn9ncr1B3Urw427znJpEokVjjB8hje5owg+45Pz0pTz+ooPjutax7b1hTFPBmeI3z9Eip8k0zDAQ48MIIyg0NR3xCtxnisR6rQImgOy1thOWTV8SYtaT08sGzsBjRx4y0IlqNh2Vvwfgtpw0MaG2pJFYt/SovR85830FVRF97qGONtD1Gex7O27qRXKM6L7nLOSibE5LgfwSfkzgheDoJ1eYgQJKh26oB8l/ohBztS14HbypieeIySZQKVv1Fe3eudBbeaHzvXvbxSm6LFvcC/3muw+feE5Jwjqcz0MKWOhE00fozRn2uKQ9QzPjoYjWjfrpTmJyxO2RoJ39O4iS/11e8KOvB+5JdqiYkLAjCEM/2w355g/zIMJgLgByhH8Pp9BF2T8FEBQ2+7NnaParb2PcW9uaitSMVwR+5/AdWhgmKshSCQHKwnhLKXA31YFywtB0Kg X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(376002)(39860400002)(136003)(396003)(346002)(451199015)(46966006)(40470700004)(36840700001)(82740400003)(478600001)(426003)(356005)(966005)(7636003)(47076005)(41300700001)(1076003)(40460700003)(86362001)(316002)(54906003)(2616005)(70586007)(26005)(336012)(40480700001)(186003)(7696005)(82310400005)(4326008)(36756003)(70206006)(5660300002)(7416002)(36860700001)(2906002)(6666004)(8676002)(6916009)(8936002)(83380400001)(14143004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 08:51:08.0847 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 674d9225-07dd-47ef-8ace-08daf47a25b6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E635.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5086 Received-SPF: softfail client-ip=40.107.244.71; envelope-from=avihaih@nvidia.com; helo=NAM12-MW2-obe.outbound.protection.outlook.com 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_H2=-0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1673514391204100001 Content-Type: text/plain; charset="utf-8" Currently, if IOMMU of a VFIO container doesn't support dirty page tracking, migration is blocked. This is because a DMA-able VFIO device can dirty RAM pages without updating QEMU about it, thus breaking the migration. However, this doesn't mean that migration can't be done at all. In such case, allow migration and let QEMU VFIO code mark all pages dirty. This guarantees that all pages that might have gotten dirty are reported back, and thus guarantees a valid migration even without VFIO IOMMU dirty tracking support. The motivation for this patch is the introduction of iommufd [1]. iommufd can directly implement the /dev/vfio/vfio container IOCTLs by mapping them into its internal ops, allowing the usage of these IOCTLs over iommufd. However, VFIO IOMMU dirty tracking is not supported by this VFIO compatibility API. This patch will allow migration by hosts that use the VFIO compatibility API and prevent migration regressions caused by the lack of VFIO IOMMU dirty tracking support. [1] https://lore.kernel.org/kvm/0-v6-a196d26f289e+11787-iommufd_jgg@nvidia.com/ Signed-off-by: Avihai Horon --- hw/vfio/common.c | 20 ++++++++++++++++++-- hw/vfio/migration.c | 3 +-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 130e5d1dc7..f6dd571549 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -488,6 +488,12 @@ static int vfio_dma_unmap(VFIOContainer *container, return -errno; } =20 + if (iotlb && vfio_devices_all_running_and_saving(container)) { + cpu_physical_memory_set_dirty_range(iotlb->translated_addr, size, + tcg_enabled() ? DIRTY_CLIENTS_= ALL : + DIRTY_CLIENTS_NOCODE); + } + return 0; } =20 @@ -1201,6 +1207,10 @@ static void vfio_set_dirty_page_tracking(VFIOContain= er *container, bool start) .argsz =3D sizeof(dirty), }; =20 + if (!container->dirty_pages_supported) { + return; + } + if (start) { dirty.flags =3D VFIO_IOMMU_DIRTY_PAGES_FLAG_START; } else { @@ -1236,6 +1246,13 @@ static int vfio_get_dirty_bitmap(VFIOContainer *cont= ainer, uint64_t iova, uint64_t pages; int ret; =20 + if (!container->dirty_pages_supported) { + cpu_physical_memory_set_dirty_range(ram_addr, size, + tcg_enabled() ? DIRTY_CLIENTS_= ALL : + DIRTY_CLIENTS_NOCODE); + return 0; + } + dbitmap =3D g_malloc0(sizeof(*dbitmap) + sizeof(*range)); =20 dbitmap->argsz =3D sizeof(*dbitmap) + sizeof(*range); @@ -1409,8 +1426,7 @@ static void vfio_listener_log_sync(MemoryListener *li= stener, { VFIOContainer *container =3D container_of(listener, VFIOContainer, lis= tener); =20 - if (vfio_listener_skipped_section(section) || - !container->dirty_pages_supported) { + if (vfio_listener_skipped_section(section)) { return; } =20 diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 09fe7c1de2..552c2313b2 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -860,11 +860,10 @@ int64_t vfio_mig_bytes_transferred(void) =20 int vfio_migration_probe(VFIODevice *vbasedev, Error **errp) { - VFIOContainer *container =3D vbasedev->group->container; struct vfio_region_info *info =3D NULL; int ret =3D -ENOTSUP; =20 - if (!vbasedev->enable_migration || !container->dirty_pages_supported) { + if (!vbasedev->enable_migration) { goto add_blocker; } =20 --=20 2.26.3 From nobody Sat Apr 27 01:04:01 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1673514001; cv=pass; d=zohomail.com; s=zohoarc; b=IVHsKm6D67z/ulUql43tav1qd2hetIf2GEzz1nUl3eRyR7Zfubl5AFHtLYb7ResuGasSMz4T2XHX1CWXjCldf4hieIi3PGjHtlVUzTQ+UOsSTBdt/LjCHkRoE69zQoLwSqSq0lrBIUjkLN0G7A13PYVVTT5OEMHqCrcy++KmbGY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673514001; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ic5jkH1/JBJkiScEMlaPgRajfRUdf9+VW5vsnnDbELI=; b=lnCw2/VmmCHb+iz4K0sFlKG4ZwRGHcdJ1doTA0IDlhNXCJ4r3qp/iwVMqsIv2gPmoSO2Vbq4IDPq5fONreoF+yue3UQoR6HjexhlDhlH6UMz4qjdJNNPWaSZbFI/7WI/zjlNkZiUTglZCuFEQIObVz1y0+3WXDFqKXS6gfSY2vg= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673514001115990.7744135867636; Thu, 12 Jan 2023 01:00:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFtK3-000697-Bt; Thu, 12 Jan 2023 03:52:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtIu-0005jD-PV; Thu, 12 Jan 2023 03:51:29 -0500 Received: from mail-dm3nam02on2069.outbound.protection.outlook.com ([40.107.95.69] helo=NAM02-DM3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtIs-0007ZL-GY; Thu, 12 Jan 2023 03:51:20 -0500 Received: from DS7PR03CA0016.namprd03.prod.outlook.com (2603:10b6:5:3b8::21) by CY8PR12MB7313.namprd12.prod.outlook.com (2603:10b6:930:53::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Thu, 12 Jan 2023 08:51:14 +0000 Received: from DS1PEPF0000E635.namprd02.prod.outlook.com (2603:10b6:5:3b8:cafe::79) by DS7PR03CA0016.outlook.office365.com (2603:10b6:5:3b8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:51:14 +0000 Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0000E635.mail.protection.outlook.com (10.167.17.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.11 via Frontend Transport; Thu, 12 Jan 2023 08:51:13 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:02 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:01 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 12 Jan 2023 00:50:55 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q5MgIxRXIwwmS8TsKCo50GckE+QEDLt4UX4HLmoykg9puysEkeaM7lmDopyaRN8Q+amLMnMN2Z2myplNllnOK4YQbDU2V1LN+f4eGM1Ml6MkzfmMgHZhuGbm15rsgLVZYDh9OMq3xfyyPmIrCGzwie1srShjXvFjoUSDsFp58t9wi8CNX67/I670z5NpkeGbascNDn7Pw2yvf+DyT1qtzA1Wwv+uwFo62HLLSCifgt3qlp7YSv6f89nfVrUKnJUwhYmn/JPidNfjJAx/RGYM813FrZ6W+oQReXnJTm6BAZ6tG4Ask05xDN8+o0VjPQ9d4u7/dsMfhBOySZAJk5A5UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ic5jkH1/JBJkiScEMlaPgRajfRUdf9+VW5vsnnDbELI=; b=VP8HlnJv4h2caTteSzWLEXM3uYIamq5raMdc3hj9bJm0LnAAYI/dbLu4IEK2m3ScdPT8HwBCp/mbeeiHRfwmsacH5r2FVpGEUnpZZIj6YhsKumkwSblCf3hN4RA7Udk6ny9sI4BhMNFzGLItlBoJ62S5lNbaEnbyKmfOesGyU1JJj5wiEMEKOYArINFprlT45LNj4T4JsTQdWGU5VhQRqfBb8CL/ZQY6sx3w8rf9JKXk5D1/snuB54D2ixkn7l3qXLztLnLXOOWkSztOq7IOSPJR0zwFdCzc9vcNCUDJDy9T4md02G5xWMfteG/y83DYTi+KcH8Xescnkro9e3froA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ic5jkH1/JBJkiScEMlaPgRajfRUdf9+VW5vsnnDbELI=; b=rAMYaa2IbkfVU8g0gbRgYd+OymOLx6nuG8W1uNdb/RREIUpNbCYgCy1beOR/psE+mVvrKcRs1yrKIaWK2Kfxa5kWaVSkMzdIMR1tPZFquCGKzyn1Ntm/viTYZKebYRl4PkVmCJEQKaN/SfupB8JJGacFk9+GfvmDzSZEo8RpvdaOHBtKddVNW9lDbkJ5Gb2d4Ldddif2B3QfRYpzibXIRAvNxi+Gxe/LehphmjFqZOETAHP+M+0Ne2amTDG/cGZFzRYSDTGgU4KHpPldAG+X3FmReP/CH4K8qbxrlmmIHJD4BmTeSsJSVGO+HtXPekTDcM8MHETXXTJZ4Nr/ZJfVkw== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , "Ilya Leoshkevich" , Thomas Huth , "Juan Quintela" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v6 05/13] migration/qemu-file: Add qemu_file_get_to_fd() Date: Thu, 12 Jan 2023 10:50:12 +0200 Message-ID: <20230112085020.15866-6-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230112085020.15866-1-avihaih@nvidia.com> References: <20230112085020.15866-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E635:EE_|CY8PR12MB7313:EE_ X-MS-Office365-Filtering-Correlation-Id: 89e396e5-8d0f-4f54-004b-08daf47a2937 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wfvD/LlHBqdFJv6N1nhdpw0vAGd95LQWX8lUmTfsWZN/HoVSU+BYwVwUSWGcJfqR53TfC1nMvUBeGIwfz7/PVdlju6odDy4qyJp6tdpT35N5lz+o8LLUSKkX9YDu3uDw2GqvAj6uzVqsAvu7DPLfkZEI3xOzDKlCCxUcWge0no6Ea1D3ZvlAGB4jNJ+bKmiYdEIOz5JO8GDuCNJN85WImij+s2s7AIpJg7uSJsGVYZ5YRxnw7MAVQUJciC0ci+26Y/6fVbceoRV/XnJNfi+6Cau6t/40dnM2wx7udQIfw4X864q7bjLFz4C6wViBClPPK3skpPmPzOP/LVOPiQzrloN2KBV2s9kb0WhHUXfRCvcGfmj4s9x5CtfC88j4dKsm0dwMXWGDRvzb8u0tTzb09qyAi5yyIchPdH3TAvNr5g6R+yySlMtwv/ZxMRy9kH1vfApHKz/bFMFHkbn/HZGQ3Q2m9Swdh7+NlX4OtOMgnFy9FADYTAQ4yg+n9Da/9pU1rXDK8ZLI3N8JcJrZZkd4sDo+JUupOMG9NpfNOh1HS2RSkhfGM1Q9AVvvDl/opC6yZsRKZBX39snozOILE11PLiEtSWmxEGhmoJVHKWCoD4O1PvZcz0VFtT6fvs8mbisscTHgFDr4gfiyCo+SHsWv63hB/QeYvp+kUgujoNMJEEZX8lo3GB0DsElBghD+lZO84zOKtKSq55eZcqNlrq/3Cg== X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(376002)(39860400002)(136003)(396003)(346002)(451199015)(46966006)(40470700004)(36840700001)(82740400003)(478600001)(426003)(356005)(7636003)(47076005)(41300700001)(1076003)(40460700003)(86362001)(316002)(54906003)(2616005)(70586007)(26005)(336012)(40480700001)(186003)(7696005)(82310400005)(4326008)(36756003)(70206006)(5660300002)(7416002)(36860700001)(2906002)(6666004)(8676002)(6916009)(8936002)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 08:51:13.9598 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 89e396e5-8d0f-4f54-004b-08daf47a2937 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E635.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7313 Received-SPF: softfail client-ip=40.107.95.69; envelope-from=avihaih@nvidia.com; helo=NAM02-DM3-obe.outbound.protection.outlook.com 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_H2=-0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1673514001398100001 Content-Type: text/plain; charset="utf-8" Add new function qemu_file_get_to_fd() that allows reading data from QEMUFile and writing it straight into a given fd. This will be used later in VFIO migration code. Signed-off-by: Avihai Horon Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: C=C3=A9dric Le Goater --- migration/qemu-file.h | 1 + migration/qemu-file.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index fa13d04d78..9d0155a2a1 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -148,6 +148,7 @@ int qemu_file_shutdown(QEMUFile *f); QEMUFile *qemu_file_get_return_path(QEMUFile *f); void qemu_fflush(QEMUFile *f); void qemu_file_set_blocking(QEMUFile *f, bool block); +int qemu_file_get_to_fd(QEMUFile *f, int fd, size_t size); =20 void ram_control_before_iterate(QEMUFile *f, uint64_t flags); void ram_control_after_iterate(QEMUFile *f, uint64_t flags); diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 2d5f74ffc2..102ab3b439 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -940,3 +940,37 @@ QIOChannel *qemu_file_get_ioc(QEMUFile *file) { return file->ioc; } + +/* + * Read size bytes from QEMUFile f and write them to fd. + */ +int qemu_file_get_to_fd(QEMUFile *f, int fd, size_t size) +{ + while (size) { + size_t pending =3D f->buf_size - f->buf_index; + ssize_t rc; + + if (!pending) { + rc =3D qemu_fill_buffer(f); + if (rc < 0) { + return rc; + } + if (rc =3D=3D 0) { + return -EIO; + } + continue; + } + + rc =3D write(fd, f->buf + f->buf_index, MIN(pending, size)); + if (rc < 0) { + return -errno; + } + if (rc =3D=3D 0) { + return -EIO; + } + f->buf_index +=3D rc; + size -=3D rc; + } + + return 0; +} --=20 2.26.3 From nobody Sat Apr 27 01:04:01 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1673513833; cv=pass; d=zohomail.com; s=zohoarc; b=gNXMqrjVrBNDBwlw2lO7F1m5x+uEbY+enymeKQSV4XJCiInegQYfe08BKEaxLRZv/RPoFmwMalTifXYmzxL0nlTshlzL5uhbeAehnujXQ+fn1b6H6UGKN6n1Nv41p/Ib3bPjb103UcOSdWZjb7CduCOAHdHJ2fBaavQ2mV5eih4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673513833; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bben1VXLG/RMcQQ8cjrMqxVhmeSsSOy123chhAe9p+0=; b=KddKjUBZlNvBFV9lHdxykVC9c8Coe1IDeBvVwP5rywRMrGnyGxXvp2loONxGKqloyaV5rvFTcdPKqW0liLdWonYGtXX0rwAR5j90M5/41u3OERaRp18j4s7b/kWgtPn/yeAlvJcza+Pe9YdWrc/+vrfKBA4g6HzyxIpV44Fowuw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673513833193670.6353039963592; Thu, 12 Jan 2023 00:57:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFtK8-0006OI-7g; Thu, 12 Jan 2023 03:52:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJC-0005n2-S5; Thu, 12 Jan 2023 03:51:41 -0500 Received: from mail-dm6nam10on2087.outbound.protection.outlook.com ([40.107.93.87] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJ5-0007bb-KD; Thu, 12 Jan 2023 03:51:37 -0500 Received: from DS7PR03CA0004.namprd03.prod.outlook.com (2603:10b6:5:3b8::9) by DM6PR12MB4499.namprd12.prod.outlook.com (2603:10b6:5:2ab::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Thu, 12 Jan 2023 08:51:24 +0000 Received: from DS1PEPF0000E635.namprd02.prod.outlook.com (2603:10b6:5:3b8:cafe::42) by DS7PR03CA0004.outlook.office365.com (2603:10b6:5:3b8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:51:24 +0000 Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0000E635.mail.protection.outlook.com (10.167.17.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.11 via Frontend Transport; Thu, 12 Jan 2023 08:51:23 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:08 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:08 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 12 Jan 2023 00:51:02 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kga0OF3pB7jJyiDQS0a6VYwNTKo1P7F2ODWOemp2qavYhXYO+XXlhmqrhpjzkQQyZRmoOKSxLWSXg0kfWNfdME0BrnXNlTrqwJvLGbo/LcJKZRhm6e0WXJP+JGzWFkoBjRSyajFbahUz3YNvV9HD8kdrQfY7tPWSOR3qFHnVBY4FrYIMKGZVULwUQkfdntiMg7RfvVEVuDYGB6CCsqYCYoL0st7ZwVI1N3unmJZ+F6zdFVq36l0pQeQ6X3uGP+oVDef8uRVz5ZwnwwXZ7YMxF50WfamD7w39SgeekVZoxizn5yYSAb8hAEFfmBfYNJXhxM3B3nI/8WZRbS2cOFPzeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bben1VXLG/RMcQQ8cjrMqxVhmeSsSOy123chhAe9p+0=; b=gS88biQgDJUEz2pGt/Sl9B9ZbmcWSwRPYgErpbiUuvXX5u5wZ0wJxb2/g0lHwEU6+/O0E/4VfRB4AGXRG1RGnGY9KRgMPgJXFaMD4+b3WTQpk0suS86TLY6cTMwJcLOyj+ylpiZxLZDXFlu/rgG6zWxIG+CoUTXxoigvlaPN50D0CscrShIfYyyMA1Ucy4JCPoQVosuGrL/H2t1MG6kW/Wp3uvKFQ0xKs+uZvBOTPsH+Kruw0AYlD8YMjYZ1rEG1ekrITbNxIN9s4pqyjF6N2IMVtDEYXgdYBu+xCXktcOhUlt2PTaL9wP/fQVkQfjJdGRaVQQfI0k0J/J8t7fTSkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bben1VXLG/RMcQQ8cjrMqxVhmeSsSOy123chhAe9p+0=; b=eI2a2qC0Y/wbsLBNg/rtN8j2e6J0tg8ITYSOd4BSBrSblVXX0sGyE9xbMtE6HhBFs5JlXA1NPco/VZiFpUnJTEJ29yosNZCiufx1OA3wfwZaQjouUeBY8zxnnPRxlUDMyD8RJQvV7D+gONgzoIHASXkZ1tGp6igg3MYDTDHRBehei3Pyy7uBigFMIHJU1qQL27vWGDypesKO6AY757CVTSQtJX532k5DUtN6JiBYBvKcC8K1voaLuZlQT0hsmA4AsK5j+pq/fCUaDBNPKaqwIaq0D9KDawOAdxa4WRz35XUWtHFt/gvKMNA9uw/vUeWwcuu0lLNkE7EE6GK9CR8Y7g== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , "Ilya Leoshkevich" , Thomas Huth , "Juan Quintela" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v6 06/13] vfio/common: Change vfio_devices_all_running_and_saving() logic to equivalent one Date: Thu, 12 Jan 2023 10:50:13 +0200 Message-ID: <20230112085020.15866-7-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230112085020.15866-1-avihaih@nvidia.com> References: <20230112085020.15866-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E635:EE_|DM6PR12MB4499:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e1fc7c9-2a13-4226-80a8-08daf47a2f2a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: smNU9sMz+d4yqZXimxo6aqWdzz0KVUihlZ0wgh59LhVwulvvvkjzEu6+4ZKiPN/tfb5LaC/ieDp+/eYgNAknkPuo62kBgcVE9+l86WvqlB0aWkykvMh02oqt3Cs++TEa6bqUVLy5JYmLfycEmKNOsFlL32oLM8+KXN8Owjp+hZnHYOOU5DMTZgMe+0Vvdcbe2hwzkn25A6GOpHQp6UujeOUKtirHdAjyYOX3txqqagN96f8aAStkpM1BIIRWdmKE7nMaoHWAklOsWT8sXNT6oJWhVxBhC3ezvkZv4s7OR20kAalrahOb6XQsWyrxAiiCvAeEKHPpp1dWtVR/522PkJLyH92ryWKXlC6vPcyReW5Y/1yeFiuIDclBx0yfKXuR1oJ56hvwcB5VMO+CgXddwG8iSvblyKGWf+V61KHUoNjjVkY+9ni22CZUO5MW6Y3Wdx/OJe1xoabuzgToEu6Kb8a1luwxGCPaXSDHFiSdRojATO7hMNzsDMHYImWydSkwdDC/g4qAd+4hL2zvDXJmF06kP3MvUbN2cXJNjB2Axsv/nQcumZXyvaVP6lSupvsdh2w0wWH7tAe6Z2uSTMO2TlkXb5fVCecCJcyZo/b0Nt0wE12FBF7C4AoZVI1NeIPgpvAiqBLKSc1zo2zwNJouyVMUR48nKu6ORqfd15dJSFNWwQzvRTFWuG/IywnVxUvzvfO4NrDlw8lB9rNDhxql3g== X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(376002)(39860400002)(136003)(396003)(346002)(451199015)(36840700001)(40470700004)(46966006)(478600001)(82740400003)(41300700001)(356005)(7636003)(47076005)(1076003)(86362001)(316002)(54906003)(2616005)(40460700003)(70586007)(26005)(336012)(40480700001)(186003)(7696005)(82310400005)(426003)(4326008)(36756003)(70206006)(5660300002)(36860700001)(7416002)(2906002)(6666004)(83380400001)(8676002)(6916009)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 08:51:23.9442 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5e1fc7c9-2a13-4226-80a8-08daf47a2f2a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E635.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4499 Received-SPF: softfail client-ip=40.107.93.87; envelope-from=avihaih@nvidia.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com 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_H2=-0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1673513836251100001 Content-Type: text/plain; charset="utf-8" vfio_devices_all_running_and_saving() is used to check if migration is in pre-copy phase. This is done by checking if migration is in setup or active states and if all VFIO devices are in pre-copy state, i.e. _SAVING | _RUNNING. In VFIO migration protocol v2 pre-copy support is made optional. Hence, a matching v2 protocol pre-copy state can't be used here. As preparation for adding v2 protocol, change vfio_devices_all_running_and_saving() logic such that it doesn't use the VFIO pre-copy state. The new equivalent logic checks if migration is in active state and if all VFIO devices are in running state [1]. No functional changes intended. [1] Note that checking if migration is in setup or active states and if all VFIO devices are in running state doesn't guarantee that we are in pre-copy phase, thus we check if migration is only in active state. Signed-off-by: Avihai Horon Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/common.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index f6dd571549..3a35f4afad 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -40,6 +40,7 @@ #include "trace.h" #include "qapi/error.h" #include "migration/migration.h" +#include "migration/misc.h" #include "sysemu/tpm.h" =20 VFIOGroupList vfio_group_list =3D @@ -363,13 +364,16 @@ static bool vfio_devices_all_dirty_tracking(VFIOConta= iner *container) return true; } =20 -static bool vfio_devices_all_running_and_saving(VFIOContainer *container) +/* + * Check if all VFIO devices are running and migration is active, which is + * essentially equivalent to the migration being in pre-copy phase. + */ +static bool vfio_devices_all_running_and_mig_active(VFIOContainer *contain= er) { VFIOGroup *group; VFIODevice *vbasedev; - MigrationState *ms =3D migrate_get_current(); =20 - if (!migration_is_setup_or_active(ms->state)) { + if (!migration_is_active(migrate_get_current())) { return false; } =20 @@ -381,8 +385,7 @@ static bool vfio_devices_all_running_and_saving(VFIOCon= tainer *container) return false; } =20 - if ((migration->device_state & VFIO_DEVICE_STATE_V1_SAVING) && - (migration->device_state & VFIO_DEVICE_STATE_V1_RUNNING)) { + if (migration->device_state & VFIO_DEVICE_STATE_V1_RUNNING) { continue; } else { return false; @@ -461,7 +464,7 @@ static int vfio_dma_unmap(VFIOContainer *container, }; =20 if (iotlb && container->dirty_pages_supported && - vfio_devices_all_running_and_saving(container)) { + vfio_devices_all_running_and_mig_active(container)) { return vfio_dma_unmap_bitmap(container, iova, size, iotlb); } =20 @@ -488,7 +491,7 @@ static int vfio_dma_unmap(VFIOContainer *container, return -errno; } =20 - if (iotlb && vfio_devices_all_running_and_saving(container)) { + if (iotlb && vfio_devices_all_running_and_mig_active(container)) { cpu_physical_memory_set_dirty_range(iotlb->translated_addr, size, tcg_enabled() ? DIRTY_CLIENTS_= ALL : DIRTY_CLIENTS_NOCODE); --=20 2.26.3 From nobody Sat Apr 27 01:04:01 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1673513696; cv=pass; d=zohomail.com; s=zohoarc; b=BZgidV/GoT7gmrG2Mjd5ZiSvIoXZBfCQRSuMRJKTzXr2Jgz1zPyyqwntpPtY+5gHAdR/n3qe6y3/tnVcgoYjYv4qAvR3ubhxWObO9VhDx9Q5TI0If52zUpO96w4MIuDV2dX9s+WfFwGuEnmTQauyYOJR79t9RNRy01MBLVmicxQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673513696; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+HKL4e9qjWn47bt8QpXMO38xpZA8acaFd0nAKqvDd68=; b=itq1SxwY/NdI8VGgixvje2O5cm0690dJBNhFpwX5IlOBsT3YVC7/rV1IAMRaMjXsSvjZrm8CmEe9BVosS7Oz6SXjA5kPafMZxzNGz+6IeWv5Go1WO6xLxKh8fFK7CQKpgarQ8wdTf71Td9J9Wnu5PU0E2CY4CMNrnW2EgRU+eHc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673513696630112.57636089030541; Thu, 12 Jan 2023 00:54:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFtJg-00068o-MX; Thu, 12 Jan 2023 03:52:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJC-0005n1-Rn; Thu, 12 Jan 2023 03:51:41 -0500 Received: from mail-mw2nam12on2050.outbound.protection.outlook.com ([40.107.244.50] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJ6-0007bn-6V; Thu, 12 Jan 2023 03:51:37 -0500 Received: from DS7PR03CA0004.namprd03.prod.outlook.com (2603:10b6:5:3b8::9) by MN0PR12MB6053.namprd12.prod.outlook.com (2603:10b6:208:3cf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Thu, 12 Jan 2023 08:51:26 +0000 Received: from DS1PEPF0000E635.namprd02.prod.outlook.com (2603:10b6:5:3b8:cafe::42) by DS7PR03CA0004.outlook.office365.com (2603:10b6:5:3b8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:51:26 +0000 Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0000E635.mail.protection.outlook.com (10.167.17.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.11 via Frontend Transport; Thu, 12 Jan 2023 08:51:26 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:15 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:15 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 12 Jan 2023 00:51:08 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HdYHWcvVXs5AhgxzlxUXeb3lDe6Vlr9BBg8wFmR0t8mJmd/N1/YKBNLAb1MhOKcR1eKFcomxh4+h+mlIIuNaz0OdS79EXW+ctZCWz81pEsxw7LJQy8ceTjlS5VcN9e9Msc3OHeBccRLbPDWYWn6MWbcJeX9bM7GX9D2jOYMOkmSrVF9YIBxSzINC+yRGGCQu6146DResZS9HdI8sK+o+1AVjucQnXvSBcuJwrL7ehOdEYOcaiC35BmtfEEVrbwkHUIh65DVjEzWD7JR4kKxpNdzETah3Aas/dird4zk4oUi0PJMHH4SMMXzpU3gf+1bT3bF4F3MDuF24HpvypPN/Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+HKL4e9qjWn47bt8QpXMO38xpZA8acaFd0nAKqvDd68=; b=FcqqWGUOhpRfPTIFURfptYNbMbHJTVM+CsNLefx9vvZfzjcY3z3dH1TxAA3I7ppaB2GkPm1WeLYtaAcpWviq1nyAjPjTzfanc26mMmowKLVTPFMX2JEeG97jJ/FZQ2fXM/0wVXcUlKuwIJmhDyDZ1CfMpK1E5qBHCRUSM6UNvTtMagcmDTNGBkuWK//ptIbMuJi/gV4if/iQ+YAg4o7/Y7/K7BlA/Si/sqtST0Cf+bYe1PBSyAhohQyLBGD1f8Ne4Lg3MPX3njXGFolJ/rq3/3uIGJob7bmT5NfUnPmPrkhF5ROlxVHLK5QrF0L5AUTnBWIketJvT8k9nlx37leffg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+HKL4e9qjWn47bt8QpXMO38xpZA8acaFd0nAKqvDd68=; b=QNT52A+NZ3RTkQnGmUwlqN+0B38Gh8kivrFtAubfMXQFKZ8B82fAYcc9Dlqm5MWOKZi2tO5UnIi7Dbkq65B7tNzbvgPBRxoIuw3i/Yk8GxAB0CN1It5Wg/gcih41aJ0L3hxSQ9ybxSTdk2ENMFOuwozllvCP2LbxmAMqjZAwHy56dGoiQ+Ltd10gFzO8TCPxG4R4mARJcd3cUx/5/Xpu1crh5zHE0Zrzd1RfodWIu9eE9KNVELKokm1r83wnKlOXpi061eTCYdfxsYKoWj6Qbzro7DtU2Kf4TYAJCjqWdvQKvmtqBoDPdUTUiGFS/XLkwk1x2EkgV2GFBb70I0NRBg== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , "Ilya Leoshkevich" , Thomas Huth , "Juan Quintela" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v6 07/13] vfio/migration: Move migration v1 logic to vfio_migration_init() Date: Thu, 12 Jan 2023 10:50:14 +0200 Message-ID: <20230112085020.15866-8-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230112085020.15866-1-avihaih@nvidia.com> References: <20230112085020.15866-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E635:EE_|MN0PR12MB6053:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d7d4262-30b5-458c-95ce-08daf47a30c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vGKXgYMt+jav9M5fMKv9QiH1YNYSVzV1H8CvfRtr2BlxzfOdibqpQ+RYZOEy6nrJA+t9uZWDqWP1qY03Y5ixZBsJ8zNlbRgsQVLBaTeHuHQQ3g7ulJNnv2nQTAGIX0qMB2n9Pex5YdLeWxEM+Z/c04KTE5K4COYqG/uVCFVep7H4gF9JIy1m28I/2deiSVqOvwpbvYn4CfUwjBeypU0DrRwy48nTyZgB7aEEHsNa7wf3Y7coAsuO3JMCv395YFEaMmXzHKIcVmTjvxM+g8EXl55qPmvHImEykdZHa50S+NoC+xEEKXyF0yXkpk4ZAM+BhmnZXqEULOI/Cz9N6P4xf5KfpMMG4GLM9uWIW7s9lItkFaM1/4p4Sred+Q2jX+oakv1LIscPMeFlVfNzB3DtXib4aBZ1B0oDMkSb0hpSBvMNYm/zrmo9qH0jUsxDixaQIs3GnMYwVvM4DzRFsBTYuq4JFtPjOd5247fy9O6QxPtPNUyX0eCdNsuBS/Z3/RelE08Ir2bb4q+HkeAPfFKKuV1ujFMLGEy5dkWkxN4OcpB4rOmA/xtGt81PQTYp+axwRtd8T7tM98B5azBi3kLSwmt9Bl2FukDSWfo43uzxoyfvH4AIud47WJvxOdkGfdf8xla87oNeq295g7KTX5GceaEhyT+sh8BS6DWeQC66577gxMVow9AHJDJqJ9EgAcBcetSHUf5MiQb+iZnAJUcHRQ== X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(396003)(346002)(136003)(376002)(451199015)(36840700001)(40470700004)(46966006)(2906002)(7696005)(478600001)(186003)(6666004)(26005)(2616005)(54906003)(336012)(4326008)(70586007)(36756003)(6916009)(426003)(1076003)(8676002)(40480700001)(316002)(66574015)(40460700003)(36860700001)(41300700001)(47076005)(82310400005)(5660300002)(82740400003)(70206006)(8936002)(83380400001)(7416002)(86362001)(356005)(7636003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 08:51:26.6161 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9d7d4262-30b5-458c-95ce-08daf47a30c4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E635.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6053 Received-SPF: softfail client-ip=40.107.244.50; envelope-from=avihaih@nvidia.com; helo=NAM12-MW2-obe.outbound.protection.outlook.com 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_H2=-0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1673513698437100001 Move vfio_dev_get_region_info() logic from vfio_migration_probe() to vfio_migration_init(). This logic is specific to v1 protocol and moving it will make it easier to add the v2 protocol implementation later. No functional changes intended. Signed-off-by: Avihai Horon Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/migration.c | 30 +++++++++++++++--------------- hw/vfio/trace-events | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 552c2313b2..977da64411 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -788,14 +788,14 @@ static void vfio_migration_exit(VFIODevice *vbasedev) vbasedev->migration =3D NULL; } =20 -static int vfio_migration_init(VFIODevice *vbasedev, - struct vfio_region_info *info) +static int vfio_migration_init(VFIODevice *vbasedev) { int ret; Object *obj; VFIOMigration *migration; char id[256] =3D ""; g_autofree char *path =3D NULL, *oid =3D NULL; + struct vfio_region_info *info; =20 if (!vbasedev->ops->vfio_get_object) { return -EINVAL; @@ -806,6 +806,14 @@ static int vfio_migration_init(VFIODevice *vbasedev, return -EINVAL; } =20 + ret =3D vfio_get_dev_region_info(vbasedev, + VFIO_REGION_TYPE_MIGRATION_DEPRECATED, + VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATE= D, + &info); + if (ret) { + return ret; + } + vbasedev->migration =3D g_new0(VFIOMigration, 1); vbasedev->migration->device_state =3D VFIO_DEVICE_STATE_V1_RUNNING; vbasedev->migration->vm_running =3D runstate_is_running(); @@ -825,6 +833,8 @@ static int vfio_migration_init(VFIODevice *vbasedev, goto err; } =20 + g_free(info); + migration =3D vbasedev->migration; migration->vbasedev =3D vbasedev; =20 @@ -847,6 +857,7 @@ static int vfio_migration_init(VFIODevice *vbasedev, return 0; =20 err: + g_free(info); vfio_migration_exit(vbasedev); return ret; } @@ -860,34 +871,23 @@ int64_t vfio_mig_bytes_transferred(void) =20 int vfio_migration_probe(VFIODevice *vbasedev, Error **errp) { - struct vfio_region_info *info =3D NULL; int ret =3D -ENOTSUP; =20 if (!vbasedev->enable_migration) { goto add_blocker; } =20 - ret =3D vfio_get_dev_region_info(vbasedev, - VFIO_REGION_TYPE_MIGRATION_DEPRECATED, - VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATE= D, - &info); - if (ret) { - goto add_blocker; - } - - ret =3D vfio_migration_init(vbasedev, info); + ret =3D vfio_migration_init(vbasedev); if (ret) { goto add_blocker; } =20 - trace_vfio_migration_probe(vbasedev->name, info->index); - g_free(info); + trace_vfio_migration_probe(vbasedev->name); return 0; =20 add_blocker: error_setg(&vbasedev->migration_blocker, "VFIO device doesn't support migration"); - g_free(info); =20 ret =3D migrate_add_blocker(vbasedev->migration_blocker, errp); if (ret < 0) { diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 73dffe9e00..b259dcc644 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -148,7 +148,7 @@ vfio_display_edid_update(uint32_t prefx, uint32_t prefy= ) "%ux%u" vfio_display_edid_write_error(void) "" =20 # migration.c -vfio_migration_probe(const char *name, uint32_t index) " (%s) Region %d" +vfio_migration_probe(const char *name) " (%s)" vfio_migration_set_state(const char *name, uint32_t state) " (%s) state %d" vfio_vmstate_change(const char *name, int running, const char *reason, uin= t32_t dev_state) " (%s) running %d reason %s device state %d" vfio_migration_state_notifier(const char *name, const char *state) " (%s) = state %s" --=20 2.26.3 From nobody Sat Apr 27 01:04:01 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1673514548; cv=pass; d=zohomail.com; s=zohoarc; b=hirJyWPXGRH7hzmZOBUnbHfSKyx5wdPLxcNcmYgKXaXrSTBzIA3T7ci/qI/Xn2v6cryB2dqnUyWjmetyxSZTVkf6fqbB6u5sRtXn2lP5Tr5wEYydq5JXjPJTErvjdWpxhMMqMcFWAGa4pr2lYSB8qNEEQzpB8M2PTEpueto7N/w= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673514548; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=990RdlHobaKINLfW1v2lE0ON2KORr+9bN5Rb1wYRUCQ=; b=SaoXNfF17bGGCx0fCb8T7avU7XNDps5WoX6W1P36iQGKMWuSrLpXFmKOngKu93V01/Htd2Q6kCmAWO1BcE/jwtjaQNgQp/+GYLr76Iza9aAFTJieNVNUg4Ly9gzuP3MVQ6oROvNoEidIf0lGzNBAR2x8BleVIKuhzbcIorVivfU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673514548168482.47607649039094; Thu, 12 Jan 2023 01:09:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFtK7-0006Nm-5u; Thu, 12 Jan 2023 03:52:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJI-0005pR-25; Thu, 12 Jan 2023 03:51:55 -0500 Received: from mail-dm6nam10on2075.outbound.protection.outlook.com ([40.107.93.75] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJF-0007cV-9D; Thu, 12 Jan 2023 03:51:43 -0500 Received: from MW4PR03CA0207.namprd03.prod.outlook.com (2603:10b6:303:b8::32) by DS0PR12MB7511.namprd12.prod.outlook.com (2603:10b6:8:139::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Thu, 12 Jan 2023 08:51:35 +0000 Received: from CO1NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::61) by MW4PR03CA0207.outlook.office365.com (2603:10b6:303:b8::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:51:35 +0000 Received: from mail.nvidia.com (216.228.118.233) by CO1NAM11FT066.mail.protection.outlook.com (10.13.175.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:51:35 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:22 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:22 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 12 Jan 2023 00:51:15 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V0eHQcYHzaKsxy72aIlbAtWBZfm+LFR9zNybiaejdM9DPWP5SFFvoR4HTUoXNZZDh8qTMDf/78woeiOstcNQMdAaRzKKyWGdtkHT2XS7wlqaC4+wOQdNKi4l3alGv3GYuUc+OE3+HsN0cYRKDar2M7W7yo7HB9lGfCf/ctj7i1GqydfG3PFp7EXD21cz486h0lYIbtt1DThc+x2bT7KYuktwZqs5V3oqugclcvxyGe2FVtbfdxPX5+LMxPd//8Ei+fwVjAPSzRSsZms369QR6xzoOnUeZBWJdkgNY5D2l/qeTg9l6l4Hx6sbV+9hJRgnHp3nOvc1zJsvjk7HEac2gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=990RdlHobaKINLfW1v2lE0ON2KORr+9bN5Rb1wYRUCQ=; b=UvQarX4FWk+Cn4M9x8i7xwrFXEM687QVxPEvB0onLEzndjPdKNcTGEz5Dke9gfjTEyx1CTWcQkGF9L69Upv7AhxuQGlmj8bQBLR7P13EcBEkhpVBoYPuieGzgutl0DXeVJzLVMBgBksXc3fnNIskqB0pmXDqHI223cau2srsVXPeAjHT3Kl4PWjulGxG4zQcY9pd5e02uF/d8Wj0EwfjZ6C53czP7UZRNtFLFhX/DE/oGKgXhwoukzOGG8poiQ6807Sq0gt+6yCAB0ve9S1uknrZCMmdLmARGoI/pIH+gvoccIeigKlYBqZGpvUYMYKB1MGPonUsoprF+o+A5UUHUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=990RdlHobaKINLfW1v2lE0ON2KORr+9bN5Rb1wYRUCQ=; b=dnTxcS4VETN0xElywvhYvuaDFLlHe5zYW1a4y2xjsUUCVHRVwIa01bGY9smK8g5xzbKs070bV2+mWOQ1dLuHemMS+u9rDhakf+heQLf/anUYOWt+Tfgah+S7DtFHkBsSJ1MXFuKTu7kkMyshb+kRoGqtw8ROf16pHe3qsBODpFbKRHpYNUz2yrpLVXWG+EozMslpJMY/Xkwgak4XllsubaQfFvVnDclsUVL8tdBQU5gmw382wugPpTvyle/Hbv0xrygJyClDkaLWwLFnsWWQGEjQbjKp6gez1cPNCRp3oACOtrqfdpeO2M/VrlBUM7m5LnE5LRM3V7AISY2R52jExg== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , "Ilya Leoshkevich" , Thomas Huth , "Juan Quintela" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v6 08/13] vfio/migration: Rename functions/structs related to v1 protocol Date: Thu, 12 Jan 2023 10:50:15 +0200 Message-ID: <20230112085020.15866-9-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230112085020.15866-1-avihaih@nvidia.com> References: <20230112085020.15866-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT066:EE_|DS0PR12MB7511:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a619501-da58-4ea8-a682-08daf47a35c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IUzNf/lSNg9L+7QOrLJ7E4jZZI8P7LE6YEYGwD4okgyer+utswqq4z5B8S3uBH3edfd2M4r/ck1QJekrvU9uuKFOJxhOR1aiehdEcjaH0tcPByDqCbQwCtlZFuxvAarv0yVObYhJy4HfpVTG5PL1paSPKu2Hr2nU/jfw98MD04yW/LTmxMxhNFz+UPXVvYPGnb9hrdmzT6VPskiH8ARzhcJ09Js9/IAD5JWyD3KocMVnWmhiJbmKD+XPf9kI9qGR7HxZt0vJmCOYduspy0o/HMt+dWOResGKWdKyI3Gj3AjwlFl0jxK4iSLCYMHdFUuIdxQoTphWVIIqXUYRuyfMNtKFNRHW9h+drHhNZTazZEMACxB3ksG4XwkkvccyP/rE0nRshPR+WLFhjgzS7l7MHKjFCGw1VNxnye0zNMqTCSXsft0CLeQgen9yBMKKdM9gQxBiY9TtAqECvxRMmnFDZgJ+efWswza3n0y9VB1oGV/9bbrbVG6qSSyei7bu/dKAC4TcCaBL0dmTnR79zrt6x6ErtMo0Eb0QJbJAzo6H1BFRxL8SLiFWVAWzEN8WCWSCRx5KZelI3Yf/Z99PF+SAZnBzQKPBWFEnIKRj1jmJor4hQCey//GtKDpV7nmUqdBV62ulOXq+hqcDGKbCuPrGDXF5oFD3xFYG6MwC06BEcSyO9EQ5c9jnOY413H7Mrqh0qBIWXyk07SVz8CBjeyQ8MQ== X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(396003)(39860400002)(376002)(346002)(136003)(451199015)(36840700001)(40470700004)(46966006)(2906002)(7696005)(26005)(478600001)(186003)(316002)(54906003)(4326008)(36756003)(8676002)(70206006)(70586007)(6916009)(336012)(2616005)(426003)(1076003)(40460700003)(66574015)(41300700001)(36860700001)(30864003)(82740400003)(8936002)(5660300002)(83380400001)(7416002)(40480700001)(47076005)(82310400005)(86362001)(356005)(7636003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 08:51:35.0938 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a619501-da58-4ea8-a682-08daf47a35c8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7511 Received-SPF: softfail client-ip=40.107.93.75; envelope-from=avihaih@nvidia.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com 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_H2=-0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1673514550227100001 To avoid name collisions, rename functions and structs related to VFIO migration protocol v1. This will allow the two protocols to co-exist when v2 protocol is added, until v1 is removed. No functional changes intended. Signed-off-by: Avihai Horon Reviewed-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 2 +- hw/vfio/common.c | 6 +- hw/vfio/migration.c | 106 +++++++++++++++++----------------- hw/vfio/trace-events | 12 ++-- 4 files changed, 63 insertions(+), 63 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index e573f5a9f1..bbaf72ba00 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -62,7 +62,7 @@ typedef struct VFIOMigration { struct VFIODevice *vbasedev; VMChangeStateEntry *vm_state; VFIORegion region; - uint32_t device_state; + uint32_t device_state_v1; int vm_running; Notifier migration_state; uint64_t pending_bytes; diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 3a35f4afad..550b2d7ded 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -355,8 +355,8 @@ static bool vfio_devices_all_dirty_tracking(VFIOContain= er *container) return false; } =20 - if ((vbasedev->pre_copy_dirty_page_tracking =3D=3D ON_OFF_AUTO= _OFF) - && (migration->device_state & VFIO_DEVICE_STATE_V1_RUNNING= )) { + if ((vbasedev->pre_copy_dirty_page_tracking =3D=3D ON_OFF_AUTO= _OFF) && + (migration->device_state_v1 & VFIO_DEVICE_STATE_V1_RUNNING= )) { return false; } } @@ -385,7 +385,7 @@ static bool vfio_devices_all_running_and_mig_active(VFI= OContainer *container) return false; } =20 - if (migration->device_state & VFIO_DEVICE_STATE_V1_RUNNING) { + if (migration->device_state_v1 & VFIO_DEVICE_STATE_V1_RUNNING)= { continue; } else { return false; diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 977da64411..9df859f4d3 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -107,8 +107,8 @@ static int vfio_mig_rw(VFIODevice *vbasedev, __u8 *buf,= size_t count, * an error is returned. */ =20 -static int vfio_migration_set_state(VFIODevice *vbasedev, uint32_t mask, - uint32_t value) +static int vfio_migration_v1_set_state(VFIODevice *vbasedev, uint32_t mask, + uint32_t value) { VFIOMigration *migration =3D vbasedev->migration; VFIORegion *region =3D &migration->region; @@ -145,8 +145,8 @@ static int vfio_migration_set_state(VFIODevice *vbasede= v, uint32_t mask, return ret; } =20 - migration->device_state =3D device_state; - trace_vfio_migration_set_state(vbasedev->name, device_state); + migration->device_state_v1 =3D device_state; + trace_vfio_migration_v1_set_state(vbasedev->name, device_state); return 0; } =20 @@ -260,8 +260,8 @@ static int vfio_save_buffer(QEMUFile *f, VFIODevice *vb= asedev, uint64_t *size) return ret; } =20 -static int vfio_load_buffer(QEMUFile *f, VFIODevice *vbasedev, - uint64_t data_size) +static int vfio_v1_load_buffer(QEMUFile *f, VFIODevice *vbasedev, + uint64_t data_size) { VFIORegion *region =3D &vbasedev->migration->region; uint64_t data_offset =3D 0, size, report_size; @@ -288,7 +288,7 @@ static int vfio_load_buffer(QEMUFile *f, VFIODevice *vb= asedev, data_size =3D 0; } =20 - trace_vfio_load_state_device_data(vbasedev->name, data_offset, siz= e); + trace_vfio_v1_load_state_device_data(vbasedev->name, data_offset, = size); =20 while (size) { void *buf; @@ -394,7 +394,7 @@ static int vfio_load_device_config_state(QEMUFile *f, v= oid *opaque) return qemu_file_get_error(f); } =20 -static void vfio_migration_cleanup(VFIODevice *vbasedev) +static void vfio_migration_v1_cleanup(VFIODevice *vbasedev) { VFIOMigration *migration =3D vbasedev->migration; =20 @@ -405,13 +405,13 @@ static void vfio_migration_cleanup(VFIODevice *vbased= ev) =20 /* ---------------------------------------------------------------------- = */ =20 -static int vfio_save_setup(QEMUFile *f, void *opaque) +static int vfio_v1_save_setup(QEMUFile *f, void *opaque) { VFIODevice *vbasedev =3D opaque; VFIOMigration *migration =3D vbasedev->migration; int ret; =20 - trace_vfio_save_setup(vbasedev->name); + trace_vfio_v1_save_setup(vbasedev->name); =20 qemu_put_be64(f, VFIO_MIG_FLAG_DEV_SETUP_STATE); =20 @@ -431,8 +431,8 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) } } =20 - ret =3D vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_MASK, - VFIO_DEVICE_STATE_V1_SAVING); + ret =3D vfio_migration_v1_set_state(vbasedev, VFIO_DEVICE_STATE_MASK, + VFIO_DEVICE_STATE_V1_SAVING); if (ret) { error_report("%s: Failed to set state SAVING", vbasedev->name); return ret; @@ -448,18 +448,18 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) return 0; } =20 -static void vfio_save_cleanup(void *opaque) +static void vfio_v1_save_cleanup(void *opaque) { VFIODevice *vbasedev =3D opaque; =20 - vfio_migration_cleanup(vbasedev); + vfio_migration_v1_cleanup(vbasedev); trace_vfio_save_cleanup(vbasedev->name); } =20 -static void vfio_save_pending(void *opaque, uint64_t threshold_size, - uint64_t *res_precopy_only, - uint64_t *res_compatible, - uint64_t *res_postcopy_only) +static void vfio_v1_save_pending(void *opaque, uint64_t threshold_size, + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only) { VFIODevice *vbasedev =3D opaque; VFIOMigration *migration =3D vbasedev->migration; @@ -472,8 +472,8 @@ static void vfio_save_pending(void *opaque, uint64_t th= reshold_size, =20 *res_precopy_only +=3D migration->pending_bytes; =20 - trace_vfio_save_pending(vbasedev->name, *res_precopy_only, - *res_postcopy_only, *res_compatible); + trace_vfio_v1_save_pending(vbasedev->name, *res_precopy_only, + *res_postcopy_only, *res_compatible); } =20 static int vfio_save_iterate(QEMUFile *f, void *opaque) @@ -523,15 +523,15 @@ static int vfio_save_iterate(QEMUFile *f, void *opaqu= e) return 0; } =20 -static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) +static int vfio_v1_save_complete_precopy(QEMUFile *f, void *opaque) { VFIODevice *vbasedev =3D opaque; VFIOMigration *migration =3D vbasedev->migration; uint64_t data_size; int ret; =20 - ret =3D vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_V1_RUNNI= NG, - VFIO_DEVICE_STATE_V1_SAVING); + ret =3D vfio_migration_v1_set_state(vbasedev, ~VFIO_DEVICE_STATE_V1_RU= NNING, + VFIO_DEVICE_STATE_V1_SAVING); if (ret) { error_report("%s: Failed to set state STOP and SAVING", vbasedev->name); @@ -568,13 +568,14 @@ static int vfio_save_complete_precopy(QEMUFile *f, vo= id *opaque) return ret; } =20 - ret =3D vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_V1_SAVIN= G, 0); + ret =3D vfio_migration_v1_set_state(vbasedev, ~VFIO_DEVICE_STATE_V1_SA= VING, + 0); if (ret) { error_report("%s: Failed to set state STOPPED", vbasedev->name); return ret; } =20 - trace_vfio_save_complete_precopy(vbasedev->name); + trace_vfio_v1_save_complete_precopy(vbasedev->name); return ret; } =20 @@ -591,7 +592,7 @@ static void vfio_save_state(QEMUFile *f, void *opaque) } } =20 -static int vfio_load_setup(QEMUFile *f, void *opaque) +static int vfio_v1_load_setup(QEMUFile *f, void *opaque) { VFIODevice *vbasedev =3D opaque; VFIOMigration *migration =3D vbasedev->migration; @@ -607,8 +608,8 @@ static int vfio_load_setup(QEMUFile *f, void *opaque) } } =20 - ret =3D vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_MASK, - VFIO_DEVICE_STATE_V1_RESUMING); + ret =3D vfio_migration_v1_set_state(vbasedev, ~VFIO_DEVICE_STATE_MASK, + VFIO_DEVICE_STATE_V1_RESUMING); if (ret) { error_report("%s: Failed to set state RESUMING", vbasedev->name); if (migration->region.mmaps) { @@ -618,11 +619,11 @@ static int vfio_load_setup(QEMUFile *f, void *opaque) return ret; } =20 -static int vfio_load_cleanup(void *opaque) +static int vfio_v1_load_cleanup(void *opaque) { VFIODevice *vbasedev =3D opaque; =20 - vfio_migration_cleanup(vbasedev); + vfio_migration_v1_cleanup(vbasedev); trace_vfio_load_cleanup(vbasedev->name); return 0; } @@ -660,7 +661,7 @@ static int vfio_load_state(QEMUFile *f, void *opaque, i= nt version_id) uint64_t data_size =3D qemu_get_be64(f); =20 if (data_size) { - ret =3D vfio_load_buffer(f, vbasedev, data_size); + ret =3D vfio_v1_load_buffer(f, vbasedev, data_size); if (ret < 0) { return ret; } @@ -681,21 +682,21 @@ static int vfio_load_state(QEMUFile *f, void *opaque,= int version_id) return ret; } =20 -static SaveVMHandlers savevm_vfio_handlers =3D { - .save_setup =3D vfio_save_setup, - .save_cleanup =3D vfio_save_cleanup, - .save_live_pending =3D vfio_save_pending, +static SaveVMHandlers savevm_vfio_v1_handlers =3D { + .save_setup =3D vfio_v1_save_setup, + .save_cleanup =3D vfio_v1_save_cleanup, + .save_live_pending =3D vfio_v1_save_pending, .save_live_iterate =3D vfio_save_iterate, - .save_live_complete_precopy =3D vfio_save_complete_precopy, + .save_live_complete_precopy =3D vfio_v1_save_complete_precopy, .save_state =3D vfio_save_state, - .load_setup =3D vfio_load_setup, - .load_cleanup =3D vfio_load_cleanup, + .load_setup =3D vfio_v1_load_setup, + .load_cleanup =3D vfio_v1_load_cleanup, .load_state =3D vfio_load_state, }; =20 /* ---------------------------------------------------------------------- = */ =20 -static void vfio_vmstate_change(void *opaque, bool running, RunState state) +static void vfio_v1_vmstate_change(void *opaque, bool running, RunState st= ate) { VFIODevice *vbasedev =3D opaque; VFIOMigration *migration =3D vbasedev->migration; @@ -735,21 +736,21 @@ static void vfio_vmstate_change(void *opaque, bool ru= nning, RunState state) } } =20 - ret =3D vfio_migration_set_state(vbasedev, mask, value); + ret =3D vfio_migration_v1_set_state(vbasedev, mask, value); if (ret) { /* * Migration should be aborted in this case, but vm_state_notify() * currently does not support reporting failures. */ error_report("%s: Failed to set device state 0x%x", vbasedev->name, - (migration->device_state & mask) | value); + (migration->device_state_v1 & mask) | value); if (migrate_get_current()->to_dst_file) { qemu_file_set_error(migrate_get_current()->to_dst_file, ret); } } vbasedev->migration->vm_running =3D running; - trace_vfio_vmstate_change(vbasedev->name, running, RunState_str(state), - (migration->device_state & mask) | value); + trace_vfio_v1_vmstate_change(vbasedev->name, running, RunState_str(sta= te), + (migration->device_state_v1 & mask) | value); } =20 static void vfio_migration_state_notifier(Notifier *notifier, void *data) @@ -768,10 +769,10 @@ static void vfio_migration_state_notifier(Notifier *n= otifier, void *data) case MIGRATION_STATUS_CANCELLED: case MIGRATION_STATUS_FAILED: bytes_transferred =3D 0; - ret =3D vfio_migration_set_state(vbasedev, - ~(VFIO_DEVICE_STATE_V1_SAVING | - VFIO_DEVICE_STATE_V1_RESUMING), - VFIO_DEVICE_STATE_V1_RUNNING); + ret =3D vfio_migration_v1_set_state(vbasedev, + ~(VFIO_DEVICE_STATE_V1_SAVING | + VFIO_DEVICE_STATE_V1_RESUMING), + VFIO_DEVICE_STATE_V1_RUNNING); if (ret) { error_report("%s: Failed to set state RUNNING", vbasedev->name= ); } @@ -815,7 +816,7 @@ static int vfio_migration_init(VFIODevice *vbasedev) } =20 vbasedev->migration =3D g_new0(VFIOMigration, 1); - vbasedev->migration->device_state =3D VFIO_DEVICE_STATE_V1_RUNNING; + vbasedev->migration->device_state_v1 =3D VFIO_DEVICE_STATE_V1_RUNNING; vbasedev->migration->vm_running =3D runstate_is_running(); =20 ret =3D vfio_region_setup(obj, vbasedev, &vbasedev->migration->region, @@ -846,12 +847,11 @@ static int vfio_migration_init(VFIODevice *vbasedev) } strpadcpy(id, sizeof(id), path, '\0'); =20 - register_savevm_live(id, VMSTATE_INSTANCE_ID_ANY, 1, &savevm_vfio_hand= lers, - vbasedev); + register_savevm_live(id, VMSTATE_INSTANCE_ID_ANY, 1, + &savevm_vfio_v1_handlers, vbasedev); =20 - migration->vm_state =3D qdev_add_vm_change_state_handler(vbasedev->dev, - vfio_vmstate_ch= ange, - vbasedev); + migration->vm_state =3D qdev_add_vm_change_state_handler( + vbasedev->dev, vfio_v1_vmstate_change, vbasedev); migration->migration_state.notify =3D vfio_migration_state_notifier; add_migration_state_change_notifier(&migration->migration_state); return 0; diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index b259dcc644..9eb9aff295 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -149,20 +149,20 @@ vfio_display_edid_write_error(void) "" =20 # migration.c vfio_migration_probe(const char *name) " (%s)" -vfio_migration_set_state(const char *name, uint32_t state) " (%s) state %d" -vfio_vmstate_change(const char *name, int running, const char *reason, uin= t32_t dev_state) " (%s) running %d reason %s device state %d" +vfio_migration_v1_set_state(const char *name, uint32_t state) " (%s) state= %d" +vfio_v1_vmstate_change(const char *name, int running, const char *reason, = uint32_t dev_state) " (%s) running %d reason %s device state %d" vfio_migration_state_notifier(const char *name, const char *state) " (%s) = state %s" -vfio_save_setup(const char *name) " (%s)" +vfio_v1_save_setup(const char *name) " (%s)" vfio_save_cleanup(const char *name) " (%s)" vfio_save_buffer(const char *name, uint64_t data_offset, uint64_t data_siz= e, uint64_t pending) " (%s) Offset 0x%"PRIx64" size 0x%"PRIx64" pending 0x%= "PRIx64 vfio_update_pending(const char *name, uint64_t pending) " (%s) pending 0x%= "PRIx64 vfio_save_device_config_state(const char *name) " (%s)" -vfio_save_pending(const char *name, uint64_t precopy, uint64_t postcopy, u= int64_t compatible) " (%s) precopy 0x%"PRIx64" postcopy 0x%"PRIx64" compati= ble 0x%"PRIx64 +vfio_v1_save_pending(const char *name, uint64_t precopy, uint64_t postcopy= , uint64_t compatible) " (%s) precopy 0x%"PRIx64" postcopy 0x%"PRIx64" comp= atible 0x%"PRIx64 vfio_save_iterate(const char *name, int data_size) " (%s) data_size %d" -vfio_save_complete_precopy(const char *name) " (%s)" +vfio_v1_save_complete_precopy(const char *name) " (%s)" vfio_load_device_config_state(const char *name) " (%s)" vfio_load_state(const char *name, uint64_t data) " (%s) data 0x%"PRIx64 -vfio_load_state_device_data(const char *name, uint64_t data_offset, uint64= _t data_size) " (%s) Offset 0x%"PRIx64" size 0x%"PRIx64 +vfio_v1_load_state_device_data(const char *name, uint64_t data_offset, uin= t64_t data_size) " (%s) Offset 0x%"PRIx64" size 0x%"PRIx64 vfio_load_cleanup(const char *name) " (%s)" vfio_get_dirty_bitmap(int fd, uint64_t iova, uint64_t size, uint64_t bitma= p_size, uint64_t start) "container fd=3D%d, iova=3D0x%"PRIx64" size=3D 0x%"= PRIx64" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64 vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu= dirty @ 0x%"PRIx64" - 0x%"PRIx64 --=20 2.26.3 From nobody Sat Apr 27 01:04:01 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1673514306; cv=pass; d=zohomail.com; s=zohoarc; b=Ezv3SxgMGQyFxjoq9eeGYYJSHMAEoeCFvCHMzI14HkYW+dCyTbiYd5/F8FCCMEs5aqeTDQubvfDmK3A2bVX+I5MYksvtYn8aFU20s0V6p8Trz4Cbdor3SW/1tMCzzBLHk0nULhrUFw/54qGG324DrMRS1xd8lBsh/292hcr6g+0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673514306; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=n3Sdlf3rwLvlGcj2ujGJ/SE1nStxhTyWrdlyWENrFSQ=; b=HFiiZ3HW9GWrjjKWvV8nrSyMzMc8PHPWogYPaVekffWtqPlvBB+OyTWgodQCd0y3fuFg2kp+mmE4GrhwkPnXRNfnNP8E014LD75IvejGdJCFyFgBh8jPYkxD4QRSba3X3DNC9DHwKmsVQEsHxZNjGSC+Jv0cteMq7LeBykT4GZs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673514306087571.8860457873808; Thu, 12 Jan 2023 01:05:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFtK6-0006NS-IP; Thu, 12 Jan 2023 03:52:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJO-0005rD-07; Thu, 12 Jan 2023 03:51:55 -0500 Received: from mail-mw2nam12on2080.outbound.protection.outlook.com ([40.107.244.80] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJJ-0007cg-Jm; Thu, 12 Jan 2023 03:51:49 -0500 Received: from MW4PR03CA0192.namprd03.prod.outlook.com (2603:10b6:303:b8::17) by CH2PR12MB4860.namprd12.prod.outlook.com (2603:10b6:610:6c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Thu, 12 Jan 2023 08:51:40 +0000 Received: from CO1NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::fd) by MW4PR03CA0192.outlook.office365.com (2603:10b6:303:b8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:51:39 +0000 Received: from mail.nvidia.com (216.228.118.233) by CO1NAM11FT066.mail.protection.outlook.com (10.13.175.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:51:39 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:29 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:29 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 12 Jan 2023 00:51:22 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L+PCJzPd6GJuzFq9HhfFE19NDWTlCX8Y0x5Y+TcLCvSMBa+EvPneih1GxUJJNe7/bwYrrFep26fumSW5uHnFL0Wc/NRj8xu4NsrBaYqxjw7/qvjTEy6tR2xhgg4JyyBjOZKGcKV/YfurWRZJn3ATR9Y08jpMR2oMEVtw5uyFDZ2QGUDsSuFo9PKaQ6fJYex4vW3lmGboh5SFqxNPhOnNZS92GYjvfgheLarXtZUdtCmr9K3Uaclh5N32NevTFVbidd4SI7i6OXJ4XG8LpcuIlJtiEgYub5KChJfKpDsDkIG3O64cazlF1uJ7tqfM1tU7Du/4nG3pYKjyHtSipZ+uew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=n3Sdlf3rwLvlGcj2ujGJ/SE1nStxhTyWrdlyWENrFSQ=; b=cweuJfW2BnmQp1pspmM6AcIckRG87Ejwe2zcPbrI2jxnIBfvm5jza30YsmjArM8TH02Ujst+0U1HOMbvcNSYUZonb/OkH5AY4zoiKhi1Ve83S7IBshjgjTXpmiKJpVsb+Om3MdV3k3JwvRhQTSIGcbdO/ymQuH2ZnDspQDQldGiJo/1S+QBOXIvTJ4hCPSZm2pT00Wu5Kv5RyQy6qBV2ttQgKwr8mGAr6sil7xqWPithK8S6Ww2HYYgI9b/vJM9Jpi/ihuk7UMZQQDr7n/moqhrvuejstYLjDFx/XkltRZ5F9yj+THYv4b8hiV0fRMJovkrKQ+D45i1adUcat/NlUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n3Sdlf3rwLvlGcj2ujGJ/SE1nStxhTyWrdlyWENrFSQ=; b=UkmrIGBKue+Ev1dOEh/1eD9wGHI+Bm0OOoXvgvDXSz2uGS8leZbYdp8jdZ9mJX+gNljwq9kr0b53adhiNXCGztcvJjDz1I0YQx18roNycY8cPdAX0HHDXS75nhCuEEONOGbsHR0A+gQudb0rvw2V9aDzEwPUSR2gLV+GpRmuTbsFGxYNHpsdjfDi+Kh2enIB74GthV3mWlftRFgse8YKTLI9eKVWrQGVzlj19iFQ5MS8GzO45DdB++50xPe5E8E3Yhezo0tcUB5WaaMaZkjKA/r3azvQNB8UVLK/w6eGpM1UfPGfO6CqJ0lNNm2p2vHEayU9SHzD2E0aO6bPlKD3Pg== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , "Ilya Leoshkevich" , Thomas Huth , "Juan Quintela" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v6 09/13] vfio/migration: Implement VFIO migration protocol v2 Date: Thu, 12 Jan 2023 10:50:16 +0200 Message-ID: <20230112085020.15866-10-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230112085020.15866-1-avihaih@nvidia.com> References: <20230112085020.15866-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT066:EE_|CH2PR12MB4860:EE_ X-MS-Office365-Filtering-Correlation-Id: 221209c6-0521-4f09-03c7-08daf47a385d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tzrab3Ycz+mMuU0VpnKWmbslgDZ6Hu2Pno3amMNEwhUDJ6dnJiHnA0FSo3oTw7K7VRvRnos5DRNe6LSKTYMJoQaeSE6niOB7k/ERQwgodl1dijfzhr83o6QT5opYaPh5J01ROnJidnuIbCRiTJSclrrsDdjWnxzAp+7P46heN4XWLK6mnVdIMi2s3Jz40obhMlf+nTMMeX+viG3DJNZOnDyFzwwvu5ls2faopjCgTT7tlXnBUwbOjv6Rhu11GqVfEYNs3c3OykBFaxNq2GfdGxd7L+bRw2NuyCcMSSbjRbHSCLdv4xQJoyt+shi1WpZN5jgyarX27q0ZjhjHd8IcTm1MLfAjPbMKPRGHknWQf64hNeKEVc7isffjpx8jMuvgjnEoaAHqKy9P+KzinKXEca6swDqDfVXj056Y4d52KhWDRBJk0ysT+DXFfwhRyDbiMKl/sZIS7PwbALnbWsuWAxv7CqlUfYWSj9se4CM0f3/MpK2pVlDpfHC/fP8bv8ZgoyvKmjB+1HXQi7eP1Kd/brvab3qL8/d2/VzRdjO9HPeVaWt99/qZnBWB5vahJ1H8RMNIXyAxwGh3zRKKj1KipJAPlcDYrP42+GxqqOeAn250TuC6NuZjXZR1OyxQgdmN5bS6L1qBiMR9JmmqTTpj8fpB5zBEYjb0YrlU2IF4FA+Bf/OfNGiO6ouoyJTXEEuVQ0mEXEq1DFiR9PC3kcc+nMP3DEgu5H/hbSIyXacceGMqi6rBnzDNTcVcHV/AoaqICMTvQtQlKguVKh/hvyzKXSBVn84IFYookxipuJj3h6M= X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(376002)(39860400002)(136003)(396003)(346002)(451199015)(40470700004)(46966006)(36840700001)(966005)(356005)(41300700001)(82740400003)(47076005)(478600001)(426003)(7636003)(1076003)(40460700003)(86362001)(316002)(2616005)(54906003)(26005)(7696005)(82310400005)(186003)(336012)(40480700001)(70206006)(36860700001)(8676002)(6916009)(6666004)(7416002)(5660300002)(30864003)(8936002)(36756003)(70586007)(4326008)(2906002)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 08:51:39.4372 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 221209c6-0521-4f09-03c7-08daf47a385d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4860 Received-SPF: softfail client-ip=40.107.244.80; envelope-from=avihaih@nvidia.com; helo=NAM12-MW2-obe.outbound.protection.outlook.com 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_H2=-0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1673514307193100003 Content-Type: text/plain; charset="utf-8" Implement the basic mandatory part of VFIO migration protocol v2. This includes all functionality that is necessary to support VFIO_MIGRATION_STOP_COPY part of the v2 protocol. The two protocols, v1 and v2, will co-exist and in the following patches v1 protocol code will be removed. There are several main differences between v1 and v2 protocols: - VFIO device state is now represented as a finite state machine instead of a bitmap. - Migration interface with kernel is now done using VFIO_DEVICE_FEATURE ioctl and normal read() and write() instead of the migration region. - Pre-copy is made optional in v2 protocol. Support for pre-copy will be added later on. Detailed information about VFIO migration protocol v2 and its difference compared to v1 protocol can be found here [1]. [1] https://lore.kernel.org/all/20220224142024.147653-10-yishaih@nvidia.com/ Signed-off-by: Avihai Horon Reviewed-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 5 + hw/vfio/common.c | 19 +- hw/vfio/migration.c | 455 +++++++++++++++++++++++++++++++--- hw/vfio/trace-events | 7 + 4 files changed, 447 insertions(+), 39 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index bbaf72ba00..2ec3346fea 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -66,6 +66,11 @@ typedef struct VFIOMigration { int vm_running; Notifier migration_state; uint64_t pending_bytes; + enum vfio_device_mig_state device_state; + int data_fd; + void *data_buffer; + size_t data_buffer_size; + bool v2; } VFIOMigration; =20 typedef struct VFIOAddressSpace { diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 550b2d7ded..dcaa77d2a8 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -355,10 +355,18 @@ static bool vfio_devices_all_dirty_tracking(VFIOConta= iner *container) return false; } =20 - if ((vbasedev->pre_copy_dirty_page_tracking =3D=3D ON_OFF_AUTO= _OFF) && + if (!migration->v2 && + (vbasedev->pre_copy_dirty_page_tracking =3D=3D ON_OFF_AUTO= _OFF) && (migration->device_state_v1 & VFIO_DEVICE_STATE_V1_RUNNING= )) { return false; } + + if (migration->v2 && + (vbasedev->pre_copy_dirty_page_tracking =3D=3D ON_OFF_AUTO= _OFF) && + (migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING = || + migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING_= P2P)) { + return false; + } } } return true; @@ -385,7 +393,14 @@ static bool vfio_devices_all_running_and_mig_active(VF= IOContainer *container) return false; } =20 - if (migration->device_state_v1 & VFIO_DEVICE_STATE_V1_RUNNING)= { + if (!migration->v2 && + migration->device_state_v1 & VFIO_DEVICE_STATE_V1_RUNNING)= { + continue; + } + + if (migration->v2 && + (migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING = || + migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING_= P2P)) { continue; } else { return false; diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 9df859f4d3..08f53189fa 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -10,6 +10,7 @@ #include "qemu/osdep.h" #include "qemu/main-loop.h" #include "qemu/cutils.h" +#include "qemu/units.h" #include #include =20 @@ -44,8 +45,103 @@ #define VFIO_MIG_FLAG_DEV_SETUP_STATE (0xffffffffef100003ULL) #define VFIO_MIG_FLAG_DEV_DATA_STATE (0xffffffffef100004ULL) =20 +/* + * This is an arbitrary size based on migration of mlx5 devices, where typ= ically + * total device migration size is on the order of 100s of MB. Testing with + * larger values, e.g. 128MB and 1GB, did not show a performance improveme= nt. + */ +#define VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE (1 * MiB) + static int64_t bytes_transferred; =20 +static const char *mig_state_to_str(enum vfio_device_mig_state state) +{ + switch (state) { + case VFIO_DEVICE_STATE_ERROR: + return "ERROR"; + case VFIO_DEVICE_STATE_STOP: + return "STOP"; + case VFIO_DEVICE_STATE_RUNNING: + return "RUNNING"; + case VFIO_DEVICE_STATE_STOP_COPY: + return "STOP_COPY"; + case VFIO_DEVICE_STATE_RESUMING: + return "RESUMING"; + case VFIO_DEVICE_STATE_RUNNING_P2P: + return "RUNNING_P2P"; + default: + return "UNKNOWN STATE"; + } +} + +static int vfio_migration_set_state(VFIODevice *vbasedev, + enum vfio_device_mig_state new_state, + enum vfio_device_mig_state recover_sta= te) +{ + VFIOMigration *migration =3D vbasedev->migration; + uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) + + sizeof(struct vfio_device_feature_mig_state), + sizeof(uint64_t))] =3D {}; + struct vfio_device_feature *feature =3D (struct vfio_device_feature *)= buf; + struct vfio_device_feature_mig_state *mig_state =3D + (struct vfio_device_feature_mig_state *)feature->data; + + feature->argsz =3D sizeof(buf); + feature->flags =3D + VFIO_DEVICE_FEATURE_SET | VFIO_DEVICE_FEATURE_MIG_DEVICE_STATE; + mig_state->device_state =3D new_state; + if (ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature)) { + /* Try to set the device in some good state */ + int err =3D -errno; + + error_report( + "%s: Failed setting device state to %s, err: %s. Setting devic= e in recover state %s", + vbasedev->name, mig_state_to_str(new_state), + strerror(errno), mig_state_to_str(recover_state)); + + mig_state->device_state =3D recover_state; + if (ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature)) { + err =3D -errno; + error_report( + "%s: Failed setting device in recover state, err: %s. Rese= tting device", + vbasedev->name, strerror(errno)); + + if (ioctl(vbasedev->fd, VFIO_DEVICE_RESET)) { + hw_error("%s: Failed resetting device, err: %s", vbasedev-= >name, + strerror(errno)); + } + + migration->device_state =3D VFIO_DEVICE_STATE_RUNNING; + + return err; + } + + migration->device_state =3D recover_state; + + return err; + } + + migration->device_state =3D new_state; + if (mig_state->data_fd !=3D -1) { + if (migration->data_fd !=3D -1) { + /* + * This can happen if the device is asynchronously reset and + * terminates a data transfer. + */ + error_report("%s: data_fd out of sync", vbasedev->name); + close(mig_state->data_fd); + + return -EBADF; + } + + migration->data_fd =3D mig_state->data_fd; + } + + trace_vfio_migration_set_state(vbasedev->name, mig_state_to_str(new_st= ate)); + + return 0; +} + static inline int vfio_mig_access(VFIODevice *vbasedev, void *val, int cou= nt, off_t off, bool iswrite) { @@ -260,6 +356,18 @@ static int vfio_save_buffer(QEMUFile *f, VFIODevice *v= basedev, uint64_t *size) return ret; } =20 +static int vfio_load_buffer(QEMUFile *f, VFIODevice *vbasedev, + uint64_t data_size) +{ + VFIOMigration *migration =3D vbasedev->migration; + int ret; + + ret =3D qemu_file_get_to_fd(f, migration->data_fd, data_size); + trace_vfio_load_state_device_data(vbasedev->name, data_size, ret); + + return ret; +} + static int vfio_v1_load_buffer(QEMUFile *f, VFIODevice *vbasedev, uint64_t data_size) { @@ -394,6 +502,14 @@ static int vfio_load_device_config_state(QEMUFile *f, = void *opaque) return qemu_file_get_error(f); } =20 +static void vfio_migration_cleanup(VFIODevice *vbasedev) +{ + VFIOMigration *migration =3D vbasedev->migration; + + close(migration->data_fd); + migration->data_fd =3D -1; +} + static void vfio_migration_v1_cleanup(VFIODevice *vbasedev) { VFIOMigration *migration =3D vbasedev->migration; @@ -403,8 +519,80 @@ static void vfio_migration_v1_cleanup(VFIODevice *vbas= edev) } } =20 +static int vfio_query_stop_copy_size(VFIODevice *vbasedev, + uint64_t *stop_copy_size) +{ + uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) + + sizeof(struct vfio_device_feature_mig_data_s= ize), + sizeof(uint64_t))] =3D {}; + struct vfio_device_feature *feature =3D (struct vfio_device_feature *)= buf; + struct vfio_device_feature_mig_data_size *mig_data_size =3D + (struct vfio_device_feature_mig_data_size *)feature->data; + + feature->argsz =3D sizeof(buf); + feature->flags =3D + VFIO_DEVICE_FEATURE_GET | VFIO_DEVICE_FEATURE_MIG_DATA_SIZE; + + if (ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature)) { + return -errno; + } + + *stop_copy_size =3D mig_data_size->stop_copy_length; + + return 0; +} + +/* Returns 1 if end-of-stream is reached, 0 if more data and -1 if error */ +static int vfio_save_block(QEMUFile *f, VFIOMigration *migration) +{ + ssize_t data_size; + + data_size =3D read(migration->data_fd, migration->data_buffer, + migration->data_buffer_size); + if (data_size < 0) { + return -errno; + } + if (data_size =3D=3D 0) { + return 1; + } + + qemu_put_be64(f, VFIO_MIG_FLAG_DEV_DATA_STATE); + qemu_put_be64(f, data_size); + qemu_put_buffer(f, migration->data_buffer, data_size); + bytes_transferred +=3D data_size; + + trace_vfio_save_block(migration->vbasedev->name, data_size); + + return qemu_file_get_error(f); +} + /* ---------------------------------------------------------------------- = */ =20 +static int vfio_save_setup(QEMUFile *f, void *opaque) +{ + VFIODevice *vbasedev =3D opaque; + VFIOMigration *migration =3D vbasedev->migration; + uint64_t stop_copy_size =3D VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE; + + qemu_put_be64(f, VFIO_MIG_FLAG_DEV_SETUP_STATE); + + vfio_query_stop_copy_size(vbasedev, &stop_copy_size); + migration->data_buffer_size =3D MIN(VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE, + stop_copy_size); + migration->data_buffer =3D g_try_malloc0(migration->data_buffer_size); + if (!migration->data_buffer) { + error_report("%s: Failed to allocate migration data buffer", + vbasedev->name); + return -ENOMEM; + } + + trace_vfio_save_setup(vbasedev->name, migration->data_buffer_size); + + qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); + + return qemu_file_get_error(f); +} + static int vfio_v1_save_setup(QEMUFile *f, void *opaque) { VFIODevice *vbasedev =3D opaque; @@ -448,6 +636,17 @@ static int vfio_v1_save_setup(QEMUFile *f, void *opaqu= e) return 0; } =20 +static void vfio_save_cleanup(void *opaque) +{ + VFIODevice *vbasedev =3D opaque; + VFIOMigration *migration =3D vbasedev->migration; + + g_free(migration->data_buffer); + migration->data_buffer =3D NULL; + vfio_migration_cleanup(vbasedev); + trace_vfio_save_cleanup(vbasedev->name); +} + static void vfio_v1_save_cleanup(void *opaque) { VFIODevice *vbasedev =3D opaque; @@ -456,6 +655,31 @@ static void vfio_v1_save_cleanup(void *opaque) trace_vfio_save_cleanup(vbasedev->name); } =20 +/* + * Migration size of VFIO devices can be as little as a few KBs or as big = as + * many GBs. This value should be big enough to cover the worst case. + */ +#define VFIO_MIG_STOP_COPY_SIZE (100 * GiB) +static void vfio_save_pending(void *opaque, uint64_t threshold_size, + uint64_t *res_precopy_only, + uint64_t *res_compatible, + uint64_t *res_postcopy_only) +{ + VFIODevice *vbasedev =3D opaque; + uint64_t stop_copy_size =3D VFIO_MIG_STOP_COPY_SIZE; + + /* + * If getting pending migration size fails, VFIO_MIG_STOP_COPY_SIZE is + * reported so downtime limit won't be violated. + */ + vfio_query_stop_copy_size(vbasedev, &stop_copy_size); + *res_precopy_only +=3D stop_copy_size; + + trace_vfio_save_pending(vbasedev->name, *res_precopy_only, + *res_postcopy_only, *res_compatible, + stop_copy_size); +} + static void vfio_v1_save_pending(void *opaque, uint64_t threshold_size, uint64_t *res_precopy_only, uint64_t *res_compatible, @@ -523,6 +747,41 @@ static int vfio_save_iterate(QEMUFile *f, void *opaque) return 0; } =20 +static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) +{ + VFIODevice *vbasedev =3D opaque; + enum vfio_device_mig_state recover_state; + int ret; + + /* We reach here with device state STOP only */ + recover_state =3D VFIO_DEVICE_STATE_STOP; + ret =3D vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_STOP_COPY, + recover_state); + if (ret) { + return ret; + } + + do { + ret =3D vfio_save_block(f, vbasedev->migration); + if (ret < 0) { + return ret; + } + } while (!ret); + + qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); + ret =3D qemu_file_get_error(f); + if (ret) { + return ret; + } + + recover_state =3D VFIO_DEVICE_STATE_ERROR; + ret =3D vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_STOP, + recover_state); + trace_vfio_save_complete_precopy(vbasedev->name, ret); + + return ret; +} + static int vfio_v1_save_complete_precopy(QEMUFile *f, void *opaque) { VFIODevice *vbasedev =3D opaque; @@ -592,6 +851,14 @@ static void vfio_save_state(QEMUFile *f, void *opaque) } } =20 +static int vfio_load_setup(QEMUFile *f, void *opaque) +{ + VFIODevice *vbasedev =3D opaque; + + return vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_RESUMING, + vbasedev->migration->device_state); +} + static int vfio_v1_load_setup(QEMUFile *f, void *opaque) { VFIODevice *vbasedev =3D opaque; @@ -619,6 +886,16 @@ static int vfio_v1_load_setup(QEMUFile *f, void *opaqu= e) return ret; } =20 +static int vfio_load_cleanup(void *opaque) +{ + VFIODevice *vbasedev =3D opaque; + + vfio_migration_cleanup(vbasedev); + trace_vfio_load_cleanup(vbasedev->name); + + return 0; +} + static int vfio_v1_load_cleanup(void *opaque) { VFIODevice *vbasedev =3D opaque; @@ -661,7 +938,11 @@ static int vfio_load_state(QEMUFile *f, void *opaque, = int version_id) uint64_t data_size =3D qemu_get_be64(f); =20 if (data_size) { - ret =3D vfio_v1_load_buffer(f, vbasedev, data_size); + if (vbasedev->migration->v2) { + ret =3D vfio_load_buffer(f, vbasedev, data_size); + } else { + ret =3D vfio_v1_load_buffer(f, vbasedev, data_size); + } if (ret < 0) { return ret; } @@ -682,6 +963,17 @@ static int vfio_load_state(QEMUFile *f, void *opaque, = int version_id) return ret; } =20 +static const SaveVMHandlers savevm_vfio_handlers =3D { + .save_setup =3D vfio_save_setup, + .save_cleanup =3D vfio_save_cleanup, + .save_live_pending =3D vfio_save_pending, + .save_live_complete_precopy =3D vfio_save_complete_precopy, + .save_state =3D vfio_save_state, + .load_setup =3D vfio_load_setup, + .load_cleanup =3D vfio_load_cleanup, + .load_state =3D vfio_load_state, +}; + static SaveVMHandlers savevm_vfio_v1_handlers =3D { .save_setup =3D vfio_v1_save_setup, .save_cleanup =3D vfio_v1_save_cleanup, @@ -696,6 +988,34 @@ static SaveVMHandlers savevm_vfio_v1_handlers =3D { =20 /* ---------------------------------------------------------------------- = */ =20 +static void vfio_vmstate_change(void *opaque, bool running, RunState state) +{ + VFIODevice *vbasedev =3D opaque; + enum vfio_device_mig_state new_state; + int ret; + + if (running) { + new_state =3D VFIO_DEVICE_STATE_RUNNING; + } else { + new_state =3D VFIO_DEVICE_STATE_STOP; + } + + ret =3D vfio_migration_set_state(vbasedev, new_state, + VFIO_DEVICE_STATE_ERROR); + if (ret) { + /* + * Migration should be aborted in this case, but vm_state_notify() + * currently does not support reporting failures. + */ + if (migrate_get_current()->to_dst_file) { + qemu_file_set_error(migrate_get_current()->to_dst_file, ret); + } + } + + trace_vfio_vmstate_change(vbasedev->name, running, RunState_str(state), + mig_state_to_str(new_state)); +} + static void vfio_v1_vmstate_change(void *opaque, bool running, RunState st= ate) { VFIODevice *vbasedev =3D opaque; @@ -769,12 +1089,17 @@ static void vfio_migration_state_notifier(Notifier *= notifier, void *data) case MIGRATION_STATUS_CANCELLED: case MIGRATION_STATUS_FAILED: bytes_transferred =3D 0; - ret =3D vfio_migration_v1_set_state(vbasedev, - ~(VFIO_DEVICE_STATE_V1_SAVING | - VFIO_DEVICE_STATE_V1_RESUMING), - VFIO_DEVICE_STATE_V1_RUNNING); - if (ret) { - error_report("%s: Failed to set state RUNNING", vbasedev->name= ); + if (migration->v2) { + vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_RUNNING, + VFIO_DEVICE_STATE_ERROR); + } else { + ret =3D vfio_migration_v1_set_state(vbasedev, + ~(VFIO_DEVICE_STATE_V1_SAVIN= G | + VFIO_DEVICE_STATE_V1_RESUM= ING), + VFIO_DEVICE_STATE_V1_RUNNING= ); + if (ret) { + error_report("%s: Failed to set state RUNNING", vbasedev->= name); + } } } } @@ -783,12 +1108,42 @@ static void vfio_migration_exit(VFIODevice *vbasedev) { VFIOMigration *migration =3D vbasedev->migration; =20 - vfio_region_exit(&migration->region); - vfio_region_finalize(&migration->region); + if (!migration->v2) { + vfio_region_exit(&migration->region); + vfio_region_finalize(&migration->region); + } g_free(vbasedev->migration); vbasedev->migration =3D NULL; } =20 +static int vfio_migration_query_flags(VFIODevice *vbasedev, uint64_t *mig_= flags) +{ + uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) + + sizeof(struct vfio_device_feature_migrat= ion), + sizeof(uint64_t))] =3D {}; + struct vfio_device_feature *feature =3D (struct vfio_device_feature *)= buf; + struct vfio_device_feature_migration *mig =3D + (struct vfio_device_feature_migration *)feature->data; + + feature->argsz =3D sizeof(buf); + feature->flags =3D VFIO_DEVICE_FEATURE_GET | VFIO_DEVICE_FEATURE_MIGRA= TION; + if (ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature)) { + if (errno =3D=3D ENOTTY) { + error_report("%s: VFIO migration is not supported in kernel", + vbasedev->name); + } else { + error_report("%s: Failed to query VFIO migration support, err:= %s", + vbasedev->name, strerror(errno)); + } + + return -errno; + } + + *mig_flags =3D mig->flags; + + return 0; +} + static int vfio_migration_init(VFIODevice *vbasedev) { int ret; @@ -797,6 +1152,7 @@ static int vfio_migration_init(VFIODevice *vbasedev) char id[256] =3D ""; g_autofree char *path =3D NULL, *oid =3D NULL; struct vfio_region_info *info; + uint64_t mig_flags; =20 if (!vbasedev->ops->vfio_get_object) { return -EINVAL; @@ -807,34 +1163,50 @@ static int vfio_migration_init(VFIODevice *vbasedev) return -EINVAL; } =20 - ret =3D vfio_get_dev_region_info(vbasedev, - VFIO_REGION_TYPE_MIGRATION_DEPRECATED, - VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATE= D, - &info); - if (ret) { - return ret; - } + ret =3D vfio_migration_query_flags(vbasedev, &mig_flags); + if (!ret) { + /* Migration v2 */ + /* Basic migration functionality must be supported */ + if (!(mig_flags & VFIO_MIGRATION_STOP_COPY)) { + return -EOPNOTSUPP; + } + vbasedev->migration =3D g_new0(VFIOMigration, 1); + vbasedev->migration->device_state =3D VFIO_DEVICE_STATE_RUNNING; + vbasedev->migration->data_fd =3D -1; + vbasedev->migration->v2 =3D true; + } else if (ret =3D=3D -ENOTTY) { + /* Migration v1 */ + ret =3D vfio_get_dev_region_info(vbasedev, + VFIO_REGION_TYPE_MIGRATION_DEPRECAT= ED, + VFIO_REGION_SUBTYPE_MIGRATION_DEPRE= CATED, + &info); + if (ret) { + return ret; + } =20 - vbasedev->migration =3D g_new0(VFIOMigration, 1); - vbasedev->migration->device_state_v1 =3D VFIO_DEVICE_STATE_V1_RUNNING; - vbasedev->migration->vm_running =3D runstate_is_running(); + vbasedev->migration =3D g_new0(VFIOMigration, 1); + vbasedev->migration->device_state_v1 =3D VFIO_DEVICE_STATE_V1_RUNN= ING; + vbasedev->migration->vm_running =3D runstate_is_running(); =20 - ret =3D vfio_region_setup(obj, vbasedev, &vbasedev->migration->region, - info->index, "migration"); - if (ret) { - error_report("%s: Failed to setup VFIO migration region %d: %s", - vbasedev->name, info->index, strerror(-ret)); - goto err; - } + ret =3D vfio_region_setup(obj, vbasedev, &vbasedev->migration->reg= ion, + info->index, "migration"); + if (ret) { + error_report("%s: Failed to setup VFIO migration region %d: %s= ", + vbasedev->name, info->index, strerror(-ret)); + goto err; + } =20 - if (!vbasedev->migration->region.size) { - error_report("%s: Invalid zero-sized VFIO migration region %d", - vbasedev->name, info->index); - ret =3D -EINVAL; - goto err; - } + if (!vbasedev->migration->region.size) { + error_report("%s: Invalid zero-sized VFIO migration region %d", + vbasedev->name, info->index); + ret =3D -EINVAL; + goto err; + } =20 - g_free(info); + g_free(info); + } else { + return ret; + } =20 migration =3D vbasedev->migration; migration->vbasedev =3D vbasedev; @@ -847,11 +1219,20 @@ static int vfio_migration_init(VFIODevice *vbasedev) } strpadcpy(id, sizeof(id), path, '\0'); =20 - register_savevm_live(id, VMSTATE_INSTANCE_ID_ANY, 1, - &savevm_vfio_v1_handlers, vbasedev); + if (migration->v2) { + register_savevm_live(id, VMSTATE_INSTANCE_ID_ANY, 1, + &savevm_vfio_handlers, vbasedev); + + migration->vm_state =3D qdev_add_vm_change_state_handler( + vbasedev->dev, vfio_vmstate_change, vbasedev); + } else { + register_savevm_live(id, VMSTATE_INSTANCE_ID_ANY, 1, + &savevm_vfio_v1_handlers, vbasedev); + + migration->vm_state =3D qdev_add_vm_change_state_handler( + vbasedev->dev, vfio_v1_vmstate_change, vbasedev); + } =20 - migration->vm_state =3D qdev_add_vm_change_state_handler( - vbasedev->dev, vfio_v1_vmstate_change, vbasedev); migration->migration_state.notify =3D vfio_migration_state_notifier; add_migration_state_change_notifier(&migration->migration_state); return 0; diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 9eb9aff295..e7b3b4658c 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -149,20 +149,27 @@ vfio_display_edid_write_error(void) "" =20 # migration.c vfio_migration_probe(const char *name) " (%s)" +vfio_migration_set_state(const char *name, const char *state) " (%s) state= %s" vfio_migration_v1_set_state(const char *name, uint32_t state) " (%s) state= %d" +vfio_vmstate_change(const char *name, int running, const char *reason, con= st char *dev_state) " (%s) running %d reason %s device state %s" vfio_v1_vmstate_change(const char *name, int running, const char *reason, = uint32_t dev_state) " (%s) running %d reason %s device state %d" vfio_migration_state_notifier(const char *name, const char *state) " (%s) = state %s" +vfio_save_setup(const char *name, uint64_t data_buffer_size) " (%s) data b= uffer size 0x%"PRIx64 vfio_v1_save_setup(const char *name) " (%s)" vfio_save_cleanup(const char *name) " (%s)" vfio_save_buffer(const char *name, uint64_t data_offset, uint64_t data_siz= e, uint64_t pending) " (%s) Offset 0x%"PRIx64" size 0x%"PRIx64" pending 0x%= "PRIx64 vfio_update_pending(const char *name, uint64_t pending) " (%s) pending 0x%= "PRIx64 vfio_save_device_config_state(const char *name) " (%s)" +vfio_save_pending(const char *name, uint64_t precopy, uint64_t postcopy, u= int64_t compatible, uint64_t stopcopy_size) " (%s) precopy 0x%"PRIx64" post= copy 0x%"PRIx64" compatible 0x%"PRIx64" stopcopy size 0x%"PRIx64 vfio_v1_save_pending(const char *name, uint64_t precopy, uint64_t postcopy= , uint64_t compatible) " (%s) precopy 0x%"PRIx64" postcopy 0x%"PRIx64" comp= atible 0x%"PRIx64 vfio_save_iterate(const char *name, int data_size) " (%s) data_size %d" +vfio_save_complete_precopy(const char *name, int ret) " (%s) ret %d" vfio_v1_save_complete_precopy(const char *name) " (%s)" vfio_load_device_config_state(const char *name) " (%s)" vfio_load_state(const char *name, uint64_t data) " (%s) data 0x%"PRIx64 vfio_v1_load_state_device_data(const char *name, uint64_t data_offset, uin= t64_t data_size) " (%s) Offset 0x%"PRIx64" size 0x%"PRIx64 +vfio_load_state_device_data(const char *name, uint64_t data_size, int ret)= " (%s) size 0x%"PRIx64" ret %d" vfio_load_cleanup(const char *name) " (%s)" vfio_get_dirty_bitmap(int fd, uint64_t iova, uint64_t size, uint64_t bitma= p_size, uint64_t start) "container fd=3D%d, iova=3D0x%"PRIx64" size=3D 0x%"= PRIx64" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64 vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu= dirty @ 0x%"PRIx64" - 0x%"PRIx64 +vfio_save_block(const char *name, int data_size) " (%s) data_size %d" --=20 2.26.3 From nobody Sat Apr 27 01:04:01 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1673514519; cv=pass; d=zohomail.com; s=zohoarc; b=eedECqEyQs1e0Qv0pOo9QbvVfDta9Rso1TYTHfrZs0inl67uzQV60Psi5aIiiceJ9frRWxUNstgS3tFJGHIp9dyACFgzUGtgd4KDJX0eOkYKXp8s1petfWb47kmLnlfhrqj8v7sBQNBfqcW4RCfHs8Mh4ubrPLOwtYA12LStN1w= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673514519; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hqxp47D1axONfpF66psW6OPVmTyJD/URYLTnxyzgbF0=; b=MU0tepQJYYe2mvgUY8rLl8qUO52xLJ1z/f/M7pyXoWGiI/OCdIKij0ufkpKuXy7UQP8v295mbcuDz/Rd2XyyJVO9T8zlL1T1Qe2DEWUVpuUjSd/cVyREA9+e9k3GPjuvHJMj+4YaEocUZDXg04bPMSv++B4eQ73bl2zGS8Ypq1c= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16735145192711005.0760261639848; Thu, 12 Jan 2023 01:08:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFtK7-0006Nt-KJ; Thu, 12 Jan 2023 03:52:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJM-0005qX-HV; Thu, 12 Jan 2023 03:51:55 -0500 Received: from mail-co1nam11on2044.outbound.protection.outlook.com ([40.107.220.44] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJJ-0007ch-By; Thu, 12 Jan 2023 03:51:47 -0500 Received: from DM6PR14CA0062.namprd14.prod.outlook.com (2603:10b6:5:18f::39) by BN9PR12MB5098.namprd12.prod.outlook.com (2603:10b6:408:137::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Thu, 12 Jan 2023 08:51:41 +0000 Received: from DS1PEPF0000E632.namprd02.prod.outlook.com (2603:10b6:5:18f:cafe::3f) by DM6PR14CA0062.outlook.office365.com (2603:10b6:5:18f::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:51:40 +0000 Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0000E632.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.11 via Frontend Transport; Thu, 12 Jan 2023 08:51:40 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:36 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:35 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 12 Jan 2023 00:51:29 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mISJbJL7I5exq4uHpSEKVksBnJZVq/7z7HhUco7D7Enw7UOYuBzbnauNXjpeQmLlMAGIZFtUv9JQQhRl0Lcgt8npW0M4EpW/jrcH7xZZLSjEprSognYNtON6FR2W919UaegoLNHq3Evn6/IwuvPm6reoD/q46ujn07SDFKRTB2XP7b2YNvXDyAcPIrG3QYi4maoeJ1/T8fvsTfZ+Pyj/LAzve+PP5MU0j1r1pMimnGLQF6pzcsdZyPDA3+Y3Bb1gw3IiATBL02Fxo6yFGuPDHE5lkYL7UtBepNUMxsyQDz5dkoQUIfwm/zwwO/u+bHWFzn0CHz8kq68j3l7YWZ7ebA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hqxp47D1axONfpF66psW6OPVmTyJD/URYLTnxyzgbF0=; b=kYQ2tYFgx3h4120Epai+2CQ2Mp2iXnGp6BN94lrAegmPUvzHF8rFrhClUD0Es0wse6wciHuQB3PKDfqk4vlnBpsrg7hgqSxphiMsDaOugUYlYcmHNpkxaEomEyvCV5zYHeJ0FK8kdKdf4GTXexy4jLstpPARicyIinq4VBeZg5W1453JFw4ycqrG1kubjoCG3N9m96WdHW2ej3VYJcA4MTruRH3TpqBh4td4/MHNF/SwM0ZErcY6YZKh2CULZX6TW2t4VN6+C9+8h6CtfnzyZCbTSnzHLdU7HKVZjx+vPDvV2Pt9EfkRJWdEymhS9yiqalrpoZdwZLtxUmAdbD5k8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hqxp47D1axONfpF66psW6OPVmTyJD/URYLTnxyzgbF0=; b=pW1MqFSdo/4F5k6H3epXNYIKsNCrX+F2PnqV39VD4qaU/ko6232kwsRhSHA5IMGio6swl0hbqAtG4/D6J4N5rXqCKM99FlnvmLgbGNEjt342izZyDXwoWZ804hbymio1G4PhuVpEu93x0H3oubRxrRF9yZuhF1OUroFm1uwCnJcoqnr2pWkG/h+kWNd6T3f9rTZKKJuqqr+BVJW45lx1Kq37NiaIiYFRKI5CnOC/07bxj5pjU84vBHvGUcXrw6aNHNBbiAaLqGqEIbcKKIOXJO/CZUpUD9AE6Ig5sXX3Z8bgaYkCcpbk1/W4huLAy4vnfcHN0lps4tT9MTPiD9eXlw== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , "Ilya Leoshkevich" , Thomas Huth , "Juan Quintela" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v6 10/13] vfio/migration: Optimize vfio_save_pending() Date: Thu, 12 Jan 2023 10:50:17 +0200 Message-ID: <20230112085020.15866-11-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230112085020.15866-1-avihaih@nvidia.com> References: <20230112085020.15866-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E632:EE_|BN9PR12MB5098:EE_ X-MS-Office365-Filtering-Correlation-Id: d3b5f90e-121c-4ad6-6c12-08daf47a390b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZhWrDQ7TrFmT/RhNah4s4WYP/TaJcGrXMp4VQzh6uXiKETXqJ6QJd+2+v8j6QyMNTb840mOQYKHdwD1k0WkaYR0gyd+81m/PpbGcoMl7lYbck4vJwmuOa6AwUuTVKdMt1d1DkMPoGk72aMTJkROaEz3k07q+Rv27GdIG5H8qbuBqkcRSvRNnOxNcVLgioEu748d7k1jNRW4RJjQ9Wwx1PLdRARngGUsEPdqu4QnZ1Zl7rPubE4lR2IHeex9ZgijelndNou/U5xAFQNz1X2pCsyVRhn1DTVkD+heKzUMjHTLe18rZWarVpu4/NQuHJBHW1sXQLU+gMkZV4GRhBMhK4MNxmxyMELDbq+69ARecectkKj/mPxb+fVra2DCySSCSfRdXYd78dfUmi36ETbe93C/y0peb2UXpF3bdMSdnxhXcbhQ4OksiEOMGePfyiHQc+Py3YbcfMJ+mbDFGEzTzH+Op7W02OhVPamChmmjB8DMfNCMoSP7nO6GgZgk/DcML01MBfWjICf3tz/HkrfttOfxaqiqQVfAuQ0Pn3xzip1fEebZBRJc0QEUoEBgCCd5+ONrsifqNtnihA10Ht+dTgdH/vFirr7W8ijrJkSeP9kHjnUcqjOZDl+fpyxtrHnZv3y6Yvc9CGILMdRfbXZraQNZAAsBfrZ1KW6+4EAZRYjf4QZGlh4QokerHER0y74L033Ohtt1+Rv9zGKdvCul6qA== X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(376002)(39860400002)(136003)(396003)(346002)(451199015)(46966006)(40470700004)(36840700001)(82740400003)(478600001)(426003)(356005)(7636003)(47076005)(41300700001)(1076003)(40460700003)(86362001)(316002)(54906003)(2616005)(70586007)(26005)(336012)(40480700001)(186003)(7696005)(82310400005)(4326008)(36756003)(70206006)(5660300002)(7416002)(36860700001)(2906002)(6666004)(8676002)(6916009)(8936002)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 08:51:40.5021 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d3b5f90e-121c-4ad6-6c12-08daf47a390b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E632.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5098 Received-SPF: softfail client-ip=40.107.220.44; envelope-from=avihaih@nvidia.com; helo=NAM11-CO1-obe.outbound.protection.outlook.com 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_H2=-0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1673514520251100001 Content-Type: text/plain; charset="utf-8" During pre-copy phase of migration vfio_save_pending() is called repeatedly and queries the VFIO device for its pending data size. As long as pending RAM size is over the threshold, migration can't converge and be completed. Therefore, during this time there is no point in querying the VFIO device pending data size. Avoid these unnecessary queries by issuing them in a RAM pre-copy notifier instead of vfio_save_pending(). This way the VFIO device is queried only when RAM pending data is below the threshold, when there is an actual chance for migration to converge. Signed-off-by: Avihai Horon Reviewed-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 2 ++ hw/vfio/migration.c | 56 +++++++++++++++++++++++++++-------- hw/vfio/trace-events | 1 + 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 2ec3346fea..113f8d9208 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -65,11 +65,13 @@ typedef struct VFIOMigration { uint32_t device_state_v1; int vm_running; Notifier migration_state; + NotifierWithReturn migration_data; uint64_t pending_bytes; enum vfio_device_mig_state device_state; int data_fd; void *data_buffer; size_t data_buffer_size; + uint64_t stop_copy_size; bool v2; } VFIOMigration; =20 diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 08f53189fa..04f4397212 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -655,29 +655,19 @@ static void vfio_v1_save_cleanup(void *opaque) trace_vfio_save_cleanup(vbasedev->name); } =20 -/* - * Migration size of VFIO devices can be as little as a few KBs or as big = as - * many GBs. This value should be big enough to cover the worst case. - */ -#define VFIO_MIG_STOP_COPY_SIZE (100 * GiB) static void vfio_save_pending(void *opaque, uint64_t threshold_size, uint64_t *res_precopy_only, uint64_t *res_compatible, uint64_t *res_postcopy_only) { VFIODevice *vbasedev =3D opaque; - uint64_t stop_copy_size =3D VFIO_MIG_STOP_COPY_SIZE; + VFIOMigration *migration =3D vbasedev->migration; =20 - /* - * If getting pending migration size fails, VFIO_MIG_STOP_COPY_SIZE is - * reported so downtime limit won't be violated. - */ - vfio_query_stop_copy_size(vbasedev, &stop_copy_size); - *res_precopy_only +=3D stop_copy_size; + *res_precopy_only +=3D migration->stop_copy_size; =20 trace_vfio_save_pending(vbasedev->name, *res_precopy_only, *res_postcopy_only, *res_compatible, - stop_copy_size); + migration->stop_copy_size); } =20 static void vfio_v1_save_pending(void *opaque, uint64_t threshold_size, @@ -1104,6 +1094,40 @@ static void vfio_migration_state_notifier(Notifier *= notifier, void *data) } } =20 +/* + * Migration size of VFIO devices can be as little as a few KBs or as big = as + * many GBs. This value should be big enough to cover the worst case. + */ +#define VFIO_MIG_STOP_COPY_SIZE (100 * GiB) +static int vfio_migration_data_notifier(NotifierWithReturn *n, void *data) +{ + VFIOMigration *migration =3D container_of(n, VFIOMigration, migration_= data); + VFIODevice *vbasedev =3D migration->vbasedev; + PrecopyNotifyData *pnd =3D data; + + if (pnd->reason !=3D PRECOPY_NOTIFY_AFTER_BITMAP_SYNC) { + return 0; + } + + /* No need to get pending size when finishing migration */ + if (runstate_check(RUN_STATE_FINISH_MIGRATE)) { + return 0; + } + + if (vfio_query_stop_copy_size(vbasedev, &migration->stop_copy_size)) { + /* + * Failed to get pending migration size. Report big pending size so + * downtime limit won't be violated. + */ + migration->stop_copy_size =3D VFIO_MIG_STOP_COPY_SIZE; + } + + trace_vfio_migration_data_notifier(vbasedev->name, + migration->stop_copy_size); + + return 0; +} + static void vfio_migration_exit(VFIODevice *vbasedev) { VFIOMigration *migration =3D vbasedev->migration; @@ -1225,6 +1249,9 @@ static int vfio_migration_init(VFIODevice *vbasedev) =20 migration->vm_state =3D qdev_add_vm_change_state_handler( vbasedev->dev, vfio_vmstate_change, vbasedev); + + migration->migration_data.notify =3D vfio_migration_data_notifier; + precopy_add_notifier(&migration->migration_data); } else { register_savevm_live(id, VMSTATE_INSTANCE_ID_ANY, 1, &savevm_vfio_v1_handlers, vbasedev); @@ -1283,6 +1310,9 @@ void vfio_migration_finalize(VFIODevice *vbasedev) if (vbasedev->migration) { VFIOMigration *migration =3D vbasedev->migration; =20 + if (migration->v2) { + precopy_remove_notifier(&migration->migration_data); + } remove_migration_state_change_notifier(&migration->migration_state= ); qemu_del_vm_change_state_handler(migration->vm_state); unregister_savevm(VMSTATE_IF(vbasedev->dev), "vfio", vbasedev); diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index e7b3b4658c..a8a64f0627 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -173,3 +173,4 @@ vfio_load_cleanup(const char *name) " (%s)" vfio_get_dirty_bitmap(int fd, uint64_t iova, uint64_t size, uint64_t bitma= p_size, uint64_t start) "container fd=3D%d, iova=3D0x%"PRIx64" size=3D 0x%"= PRIx64" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64 vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu= dirty @ 0x%"PRIx64" - 0x%"PRIx64 vfio_save_block(const char *name, int data_size) " (%s) data_size %d" +vfio_migration_data_notifier(const char *name, uint64_t stopcopy_size) " (= %s) stopcopy size 0x%"PRIx64 --=20 2.26.3 From nobody Sat Apr 27 01:04:01 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1673514081; cv=pass; d=zohomail.com; s=zohoarc; b=Wz2Ccx4Kt4R9+g1qgQ1DsMytVGrTHfI8U3VwWBUWe0xpZqUVFAGL20Av3af/wRPp78oDYqX3SUOTglqeJ4r0h5gMp/Um79qIsIaOzApTzDGfVb7dxDyY2ihd/pTO1xq0zv1s6AoxMS6nzFODyUHeyPJ2mA+n1x5EypTTh1UkWEw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673514081; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=USkbyXJxVvMZxIEExU1KcTBqmT+HjwzK85j11dzxpEM=; b=VgpOLALyRlRF3hWjElgoNSylN6+BhuJPScvfF7o8+L2fOTgt2lkjMxH0hRbm5Nv8uEN3NOoLn/gC1FBsZzyim2JkfTx+lH7oGm4U6tT0hkiibv5fiHkAwR5Vx0J6omgO6GdNR725ojZYrXtPYF3xaS64rdxDbZ5JZ4sdQrFZEFw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673514081557664.2364478142695; Thu, 12 Jan 2023 01:01:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFtKK-0006Vt-1M; Thu, 12 Jan 2023 03:52:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJe-00068V-EK; Thu, 12 Jan 2023 03:52:06 -0500 Received: from mail-mw2nam12on2052.outbound.protection.outlook.com ([40.107.244.52] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJa-0007hl-6w; Thu, 12 Jan 2023 03:52:06 -0500 Received: from DM6PR14CA0042.namprd14.prod.outlook.com (2603:10b6:5:18f::19) by PH0PR12MB8007.namprd12.prod.outlook.com (2603:10b6:510:28e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Thu, 12 Jan 2023 08:51:54 +0000 Received: from DS1PEPF0000E632.namprd02.prod.outlook.com (2603:10b6:5:18f:cafe::27) by DM6PR14CA0042.outlook.office365.com (2603:10b6:5:18f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:51:53 +0000 Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0000E632.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.11 via Frontend Transport; Thu, 12 Jan 2023 08:51:53 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:43 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:42 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 12 Jan 2023 00:51:36 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dYXHo1URySEwPW/IdPY7ulE9aGJvoEdBoB7jYfTTCF8SKplJHfykBNYVO+urjzG8fdpLJnvUztEKfyBfCYjiyW14EPVpFXzWFx1i2K02VL/KtHadR6dth+sBlf1KBEXvz7UTaQ5WxNnj4v34+MXLkXJ+xA3IHpYCBj1vqrOWVsDnORRRqcswlh2ggsK3U7K75OjD0M2arWQ6kwgvA/oNSp8Jo5tcWkhXxKcZUIllN6krQ2U1SzV2G197HrmBsOt9LwLGJnrLwAbpBThyXhIN2Tid3Zqw7RaGsFaI0ZcQ74JNuPvsZc5g6omxG7dIzcq+x1tMhvIbTFph4HhB4Ebj3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=USkbyXJxVvMZxIEExU1KcTBqmT+HjwzK85j11dzxpEM=; b=LBRqfmHFGpU2nUmY2Lz4VYiirNzCctXdlJ0dguG6EzOlSR3r/rxud4vVT9b4YcgGe9Kqu/7uaPpZvPfHSGUbSJGT97HKGgucm7fgv1Xc3GVqBy7x8FFHsQXebj4kvZnhtSmssNLmdClmjbPEXgGZ8ytJa/NjSrDSynD/w8+FPSz4rPpM/8lkOGWqzkjj1VG5w3Y6A96p0V4ibmnokSeQemy3wuK2EXWtht4AXz17B1oGoYLENifPcO7CmPULsHqwnrSHmQjGAXTB7cg24CfbZ7KqgkS7oS3Lp3shRKu47+rin1PfBNkX/VtdJ9/JLlMNBkkdRwRQRSjjc45BuWpWQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=USkbyXJxVvMZxIEExU1KcTBqmT+HjwzK85j11dzxpEM=; b=XpbhxCJt3EN8SYmlM6KQrzZjjyHLl1Q5A84hFgL9e47QDuTFbEuW3fjItnyb63ZfQ72fxycUVV5g9YSoVJRbcQGBcy4rNLwomCyenrm7TG5q8xGi0e/Phgv+TwHv4mI6XmU/ZyEVi62dHAlUGprDZDlap5n3lQwZpV8d+6ogaye7JzVyQLjTgDqB34nbGU4/AjTbS158eTA7XDoNfQ0QNyzVVQGlXO1QYsVRb7/iDxWM0CCz3cDzSNgeiGgeGQcZDAzBT8JRdOBshh6Y2S77ff7Ld1pbLOGcIM7dvFOKr7hxaHkCulCMfPpxcPa0l01xj6SmVG1kaiDKKtapoypj6Q== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , "Ilya Leoshkevich" , Thomas Huth , "Juan Quintela" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v6 11/13] vfio/migration: Remove VFIO migration protocol v1 Date: Thu, 12 Jan 2023 10:50:18 +0200 Message-ID: <20230112085020.15866-12-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230112085020.15866-1-avihaih@nvidia.com> References: <20230112085020.15866-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E632:EE_|PH0PR12MB8007:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a002a3f-cdbd-40e8-e840-08daf47a40e2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VKOogKdLvX6Im2j0cTnso/KplRk0FiyeO2QohSuoA3kEBgDdgFRU+EH5v+SYkOrb4So/JOo2IVfOKNzBQRqh0ysBik5BclWZsfHHJO455DESlTGOU8yHr/ySnrtAMkLxbeL0zvDcq4Mfft8DJqn1rjM+7YS70/OEsfeMLqYjNr6aejrHQ9kd4UjCXLDBIo1ODJSEcm/JHHX5hWfNVUvZMUzizbl73y8Xnfr6iKVeuLbVTCatXu/bAVCs8WDMyCn6ojSbKkGC0vXJJ2yR8OJ8gnoU9fLLDA0GR1o+pXSz3O/l0JRMKsDlOihnPSuEptAbswyShLHqcEfqELsXfK7/BTCjSFxasus3vukx7GAn46uJGB3XY4HeYne4Ch/KA7zpW/ebBiSX0A7bGk/pmbmd/Ht0bas64ELthTZDZIiqidf6aLKvQ6BnGufJhhD+AIQnUGh49cZ2+wIPNBjwC5pNCdd13wOUhpD5YE4h4uqSUH6WLZ/Gp4kp4kcjCyRswvuuvW4lyAuWGubr3atexiu7wvV+pOOsFnQNng1nPnRtSiMxhegZWSSMCjGQakvQ7SWXJX0/fCv5ZuJDJs9teKa2IBFRCsUYM6/fTnDMU+G0EykGo2Ez8n3xPkslMRRPFLhcS46IOqC6efKmRM3PxdaizxDha3hpWTst8NFO5y1TejY8Mvg7Pt+AGW/qBfUhG5O3q5Bekho0hpuHt1DeOSwGZA== X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(376002)(136003)(346002)(396003)(39860400002)(451199015)(46966006)(36840700001)(40470700004)(70206006)(40460700003)(41300700001)(47076005)(40480700001)(426003)(4326008)(1076003)(70586007)(2616005)(83380400001)(8676002)(336012)(6916009)(36756003)(54906003)(316002)(86362001)(36860700001)(7416002)(7636003)(8936002)(5660300002)(356005)(82310400005)(30864003)(82740400003)(2906002)(478600001)(6666004)(186003)(26005)(7696005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 08:51:53.6896 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4a002a3f-cdbd-40e8-e840-08daf47a40e2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E632.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8007 Received-SPF: softfail client-ip=40.107.244.52; envelope-from=avihaih@nvidia.com; helo=NAM12-MW2-obe.outbound.protection.outlook.com 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_H2=-0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1673514082310100001 Content-Type: text/plain; charset="utf-8" Now that v2 protocol implementation has been added, remove the deprecated v1 implementation. Signed-off-by: Avihai Horon Reviewed-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-common.h | 5 - hw/vfio/common.c | 19 +- hw/vfio/migration.c | 703 +--------------------------------- hw/vfio/trace-events | 9 - 4 files changed, 24 insertions(+), 712 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 113f8d9208..2aba45887c 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -61,18 +61,13 @@ typedef struct VFIORegion { typedef struct VFIOMigration { struct VFIODevice *vbasedev; VMChangeStateEntry *vm_state; - VFIORegion region; - uint32_t device_state_v1; - int vm_running; Notifier migration_state; NotifierWithReturn migration_data; - uint64_t pending_bytes; enum vfio_device_mig_state device_state; int data_fd; void *data_buffer; size_t data_buffer_size; uint64_t stop_copy_size; - bool v2; } VFIOMigration; =20 typedef struct VFIOAddressSpace { diff --git a/hw/vfio/common.c b/hw/vfio/common.c index dcaa77d2a8..9a0dbee6b4 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -355,14 +355,7 @@ static bool vfio_devices_all_dirty_tracking(VFIOContai= ner *container) return false; } =20 - if (!migration->v2 && - (vbasedev->pre_copy_dirty_page_tracking =3D=3D ON_OFF_AUTO= _OFF) && - (migration->device_state_v1 & VFIO_DEVICE_STATE_V1_RUNNING= )) { - return false; - } - - if (migration->v2 && - (vbasedev->pre_copy_dirty_page_tracking =3D=3D ON_OFF_AUTO= _OFF) && + if ((vbasedev->pre_copy_dirty_page_tracking =3D=3D ON_OFF_AUTO= _OFF) && (migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING = || migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING_= P2P)) { return false; @@ -393,14 +386,8 @@ static bool vfio_devices_all_running_and_mig_active(VF= IOContainer *container) return false; } =20 - if (!migration->v2 && - migration->device_state_v1 & VFIO_DEVICE_STATE_V1_RUNNING)= { - continue; - } - - if (migration->v2 && - (migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING = || - migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING_= P2P)) { + if (migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING || + migration->device_state =3D=3D VFIO_DEVICE_STATE_RUNNING_P= 2P) { continue; } else { return false; diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 04f4397212..7688c83127 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -142,220 +142,6 @@ static int vfio_migration_set_state(VFIODevice *vbase= dev, return 0; } =20 -static inline int vfio_mig_access(VFIODevice *vbasedev, void *val, int cou= nt, - off_t off, bool iswrite) -{ - int ret; - - ret =3D iswrite ? pwrite(vbasedev->fd, val, count, off) : - pread(vbasedev->fd, val, count, off); - if (ret < count) { - error_report("vfio_mig_%s %d byte %s: failed at offset 0x%" - HWADDR_PRIx", err: %s", iswrite ? "write" : "read", c= ount, - vbasedev->name, off, strerror(errno)); - return (ret < 0) ? ret : -EINVAL; - } - return 0; -} - -static int vfio_mig_rw(VFIODevice *vbasedev, __u8 *buf, size_t count, - off_t off, bool iswrite) -{ - int ret, done =3D 0; - __u8 *tbuf =3D buf; - - while (count) { - int bytes =3D 0; - - if (count >=3D 8 && !(off % 8)) { - bytes =3D 8; - } else if (count >=3D 4 && !(off % 4)) { - bytes =3D 4; - } else if (count >=3D 2 && !(off % 2)) { - bytes =3D 2; - } else { - bytes =3D 1; - } - - ret =3D vfio_mig_access(vbasedev, tbuf, bytes, off, iswrite); - if (ret) { - return ret; - } - - count -=3D bytes; - done +=3D bytes; - off +=3D bytes; - tbuf +=3D bytes; - } - return done; -} - -#define vfio_mig_read(f, v, c, o) vfio_mig_rw(f, (__u8 *)v, c, o, fa= lse) -#define vfio_mig_write(f, v, c, o) vfio_mig_rw(f, (__u8 *)v, c, o, tr= ue) - -#define VFIO_MIG_STRUCT_OFFSET(f) \ - offsetof(struct vfio_device_migration_inf= o, f) -/* - * Change the device_state register for device @vbasedev. Bits set in @mask - * are preserved, bits set in @value are set, and bits not set in either @= mask - * or @value are cleared in device_state. If the register cannot be access= ed, - * the resulting state would be invalid, or the device enters an error sta= te, - * an error is returned. - */ - -static int vfio_migration_v1_set_state(VFIODevice *vbasedev, uint32_t mask, - uint32_t value) -{ - VFIOMigration *migration =3D vbasedev->migration; - VFIORegion *region =3D &migration->region; - off_t dev_state_off =3D region->fd_offset + - VFIO_MIG_STRUCT_OFFSET(device_state); - uint32_t device_state; - int ret; - - ret =3D vfio_mig_read(vbasedev, &device_state, sizeof(device_state), - dev_state_off); - if (ret < 0) { - return ret; - } - - device_state =3D (device_state & mask) | value; - - if (!VFIO_DEVICE_STATE_VALID(device_state)) { - return -EINVAL; - } - - ret =3D vfio_mig_write(vbasedev, &device_state, sizeof(device_state), - dev_state_off); - if (ret < 0) { - int rret; - - rret =3D vfio_mig_read(vbasedev, &device_state, sizeof(device_stat= e), - dev_state_off); - - if ((rret < 0) || (VFIO_DEVICE_STATE_IS_ERROR(device_state))) { - hw_error("%s: Device in error state 0x%x", vbasedev->name, - device_state); - return rret ? rret : -EIO; - } - return ret; - } - - migration->device_state_v1 =3D device_state; - trace_vfio_migration_v1_set_state(vbasedev->name, device_state); - return 0; -} - -static void *get_data_section_size(VFIORegion *region, uint64_t data_offse= t, - uint64_t data_size, uint64_t *size) -{ - void *ptr =3D NULL; - uint64_t limit =3D 0; - int i; - - if (!region->mmaps) { - if (size) { - *size =3D MIN(data_size, region->size - data_offset); - } - return ptr; - } - - for (i =3D 0; i < region->nr_mmaps; i++) { - VFIOMmap *map =3D region->mmaps + i; - - if ((data_offset >=3D map->offset) && - (data_offset < map->offset + map->size)) { - - /* check if data_offset is within sparse mmap areas */ - ptr =3D map->mmap + data_offset - map->offset; - if (size) { - *size =3D MIN(data_size, map->offset + map->size - data_of= fset); - } - break; - } else if ((data_offset < map->offset) && - (!limit || limit > map->offset)) { - /* - * data_offset is not within sparse mmap areas, find size of - * non-mapped area. Check through all list since region->mmaps= list - * is not sorted. - */ - limit =3D map->offset; - } - } - - if (!ptr && size) { - *size =3D limit ? MIN(data_size, limit - data_offset) : data_size; - } - return ptr; -} - -static int vfio_save_buffer(QEMUFile *f, VFIODevice *vbasedev, uint64_t *s= ize) -{ - VFIOMigration *migration =3D vbasedev->migration; - VFIORegion *region =3D &migration->region; - uint64_t data_offset =3D 0, data_size =3D 0, sz; - int ret; - - ret =3D vfio_mig_read(vbasedev, &data_offset, sizeof(data_offset), - region->fd_offset + VFIO_MIG_STRUCT_OFFSET(data_offs= et)); - if (ret < 0) { - return ret; - } - - ret =3D vfio_mig_read(vbasedev, &data_size, sizeof(data_size), - region->fd_offset + VFIO_MIG_STRUCT_OFFSET(data_si= ze)); - if (ret < 0) { - return ret; - } - - trace_vfio_save_buffer(vbasedev->name, data_offset, data_size, - migration->pending_bytes); - - qemu_put_be64(f, data_size); - sz =3D data_size; - - while (sz) { - void *buf; - uint64_t sec_size; - bool buf_allocated =3D false; - - buf =3D get_data_section_size(region, data_offset, sz, &sec_size); - - if (!buf) { - buf =3D g_try_malloc(sec_size); - if (!buf) { - error_report("%s: Error allocating buffer ", __func__); - return -ENOMEM; - } - buf_allocated =3D true; - - ret =3D vfio_mig_read(vbasedev, buf, sec_size, - region->fd_offset + data_offset); - if (ret < 0) { - g_free(buf); - return ret; - } - } - - qemu_put_buffer(f, buf, sec_size); - - if (buf_allocated) { - g_free(buf); - } - sz -=3D sec_size; - data_offset +=3D sec_size; - } - - ret =3D qemu_file_get_error(f); - - if (!ret && size) { - *size =3D data_size; - } - - bytes_transferred +=3D data_size; - return ret; -} - static int vfio_load_buffer(QEMUFile *f, VFIODevice *vbasedev, uint64_t data_size) { @@ -368,96 +154,6 @@ static int vfio_load_buffer(QEMUFile *f, VFIODevice *v= basedev, return ret; } =20 -static int vfio_v1_load_buffer(QEMUFile *f, VFIODevice *vbasedev, - uint64_t data_size) -{ - VFIORegion *region =3D &vbasedev->migration->region; - uint64_t data_offset =3D 0, size, report_size; - int ret; - - do { - ret =3D vfio_mig_read(vbasedev, &data_offset, sizeof(data_offset), - region->fd_offset + VFIO_MIG_STRUCT_OFFSET(data_offs= et)); - if (ret < 0) { - return ret; - } - - if (data_offset + data_size > region->size) { - /* - * If data_size is greater than the data section of migration = region - * then iterate the write buffer operation. This case can occu= r if - * size of migration region at destination is smaller than siz= e of - * migration region at source. - */ - report_size =3D size =3D region->size - data_offset; - data_size -=3D size; - } else { - report_size =3D size =3D data_size; - data_size =3D 0; - } - - trace_vfio_v1_load_state_device_data(vbasedev->name, data_offset, = size); - - while (size) { - void *buf; - uint64_t sec_size; - bool buf_alloc =3D false; - - buf =3D get_data_section_size(region, data_offset, size, &sec_= size); - - if (!buf) { - buf =3D g_try_malloc(sec_size); - if (!buf) { - error_report("%s: Error allocating buffer ", __func__); - return -ENOMEM; - } - buf_alloc =3D true; - } - - qemu_get_buffer(f, buf, sec_size); - - if (buf_alloc) { - ret =3D vfio_mig_write(vbasedev, buf, sec_size, - region->fd_offset + data_offset); - g_free(buf); - - if (ret < 0) { - return ret; - } - } - size -=3D sec_size; - data_offset +=3D sec_size; - } - - ret =3D vfio_mig_write(vbasedev, &report_size, sizeof(report_size), - region->fd_offset + VFIO_MIG_STRUCT_OFFSET(data_si= ze)); - if (ret < 0) { - return ret; - } - } while (data_size); - - return 0; -} - -static int vfio_update_pending(VFIODevice *vbasedev) -{ - VFIOMigration *migration =3D vbasedev->migration; - VFIORegion *region =3D &migration->region; - uint64_t pending_bytes =3D 0; - int ret; - - ret =3D vfio_mig_read(vbasedev, &pending_bytes, sizeof(pending_bytes), - region->fd_offset + VFIO_MIG_STRUCT_OFFSET(pending_byt= es)); - if (ret < 0) { - migration->pending_bytes =3D 0; - return ret; - } - - migration->pending_bytes =3D pending_bytes; - trace_vfio_update_pending(vbasedev->name, pending_bytes); - return 0; -} - static int vfio_save_device_config_state(QEMUFile *f, void *opaque) { VFIODevice *vbasedev =3D opaque; @@ -510,15 +206,6 @@ static void vfio_migration_cleanup(VFIODevice *vbasede= v) migration->data_fd =3D -1; } =20 -static void vfio_migration_v1_cleanup(VFIODevice *vbasedev) -{ - VFIOMigration *migration =3D vbasedev->migration; - - if (migration->region.mmaps) { - vfio_region_unmap(&migration->region); - } -} - static int vfio_query_stop_copy_size(VFIODevice *vbasedev, uint64_t *stop_copy_size) { @@ -593,49 +280,6 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) return qemu_file_get_error(f); } =20 -static int vfio_v1_save_setup(QEMUFile *f, void *opaque) -{ - VFIODevice *vbasedev =3D opaque; - VFIOMigration *migration =3D vbasedev->migration; - int ret; - - trace_vfio_v1_save_setup(vbasedev->name); - - qemu_put_be64(f, VFIO_MIG_FLAG_DEV_SETUP_STATE); - - if (migration->region.mmaps) { - /* - * Calling vfio_region_mmap() from migration thread. Memory API ca= lled - * from this function require locking the iothread when called from - * outside the main loop thread. - */ - qemu_mutex_lock_iothread(); - ret =3D vfio_region_mmap(&migration->region); - qemu_mutex_unlock_iothread(); - if (ret) { - error_report("%s: Failed to mmap VFIO migration region: %s", - vbasedev->name, strerror(-ret)); - error_report("%s: Falling back to slow path", vbasedev->name); - } - } - - ret =3D vfio_migration_v1_set_state(vbasedev, VFIO_DEVICE_STATE_MASK, - VFIO_DEVICE_STATE_V1_SAVING); - if (ret) { - error_report("%s: Failed to set state SAVING", vbasedev->name); - return ret; - } - - qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); - - ret =3D qemu_file_get_error(f); - if (ret) { - return ret; - } - - return 0; -} - static void vfio_save_cleanup(void *opaque) { VFIODevice *vbasedev =3D opaque; @@ -647,14 +291,6 @@ static void vfio_save_cleanup(void *opaque) trace_vfio_save_cleanup(vbasedev->name); } =20 -static void vfio_v1_save_cleanup(void *opaque) -{ - VFIODevice *vbasedev =3D opaque; - - vfio_migration_v1_cleanup(vbasedev); - trace_vfio_save_cleanup(vbasedev->name); -} - static void vfio_save_pending(void *opaque, uint64_t threshold_size, uint64_t *res_precopy_only, uint64_t *res_compatible, @@ -670,73 +306,6 @@ static void vfio_save_pending(void *opaque, uint64_t t= hreshold_size, migration->stop_copy_size); } =20 -static void vfio_v1_save_pending(void *opaque, uint64_t threshold_size, - uint64_t *res_precopy_only, - uint64_t *res_compatible, - uint64_t *res_postcopy_only) -{ - VFIODevice *vbasedev =3D opaque; - VFIOMigration *migration =3D vbasedev->migration; - int ret; - - ret =3D vfio_update_pending(vbasedev); - if (ret) { - return; - } - - *res_precopy_only +=3D migration->pending_bytes; - - trace_vfio_v1_save_pending(vbasedev->name, *res_precopy_only, - *res_postcopy_only, *res_compatible); -} - -static int vfio_save_iterate(QEMUFile *f, void *opaque) -{ - VFIODevice *vbasedev =3D opaque; - VFIOMigration *migration =3D vbasedev->migration; - uint64_t data_size; - int ret; - - qemu_put_be64(f, VFIO_MIG_FLAG_DEV_DATA_STATE); - - if (migration->pending_bytes =3D=3D 0) { - ret =3D vfio_update_pending(vbasedev); - if (ret) { - return ret; - } - - if (migration->pending_bytes =3D=3D 0) { - qemu_put_be64(f, 0); - qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); - /* indicates data finished, goto complete phase */ - return 1; - } - } - - ret =3D vfio_save_buffer(f, vbasedev, &data_size); - if (ret) { - error_report("%s: vfio_save_buffer failed %s", vbasedev->name, - strerror(errno)); - return ret; - } - - qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); - - ret =3D qemu_file_get_error(f); - if (ret) { - return ret; - } - - /* - * Reset pending_bytes as .save_live_pending is not called during save= vm or - * snapshot case, in such case vfio_update_pending() at the start of t= his - * function updates pending_bytes. - */ - migration->pending_bytes =3D 0; - trace_vfio_save_iterate(vbasedev->name, data_size); - return 0; -} - static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) { VFIODevice *vbasedev =3D opaque; @@ -772,62 +341,6 @@ static int vfio_save_complete_precopy(QEMUFile *f, voi= d *opaque) return ret; } =20 -static int vfio_v1_save_complete_precopy(QEMUFile *f, void *opaque) -{ - VFIODevice *vbasedev =3D opaque; - VFIOMigration *migration =3D vbasedev->migration; - uint64_t data_size; - int ret; - - ret =3D vfio_migration_v1_set_state(vbasedev, ~VFIO_DEVICE_STATE_V1_RU= NNING, - VFIO_DEVICE_STATE_V1_SAVING); - if (ret) { - error_report("%s: Failed to set state STOP and SAVING", - vbasedev->name); - return ret; - } - - ret =3D vfio_update_pending(vbasedev); - if (ret) { - return ret; - } - - while (migration->pending_bytes > 0) { - qemu_put_be64(f, VFIO_MIG_FLAG_DEV_DATA_STATE); - ret =3D vfio_save_buffer(f, vbasedev, &data_size); - if (ret < 0) { - error_report("%s: Failed to save buffer", vbasedev->name); - return ret; - } - - if (data_size =3D=3D 0) { - break; - } - - ret =3D vfio_update_pending(vbasedev); - if (ret) { - return ret; - } - } - - qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); - - ret =3D qemu_file_get_error(f); - if (ret) { - return ret; - } - - ret =3D vfio_migration_v1_set_state(vbasedev, ~VFIO_DEVICE_STATE_V1_SA= VING, - 0); - if (ret) { - error_report("%s: Failed to set state STOPPED", vbasedev->name); - return ret; - } - - trace_vfio_v1_save_complete_precopy(vbasedev->name); - return ret; -} - static void vfio_save_state(QEMUFile *f, void *opaque) { VFIODevice *vbasedev =3D opaque; @@ -849,33 +362,6 @@ static int vfio_load_setup(QEMUFile *f, void *opaque) vbasedev->migration->device_state); } =20 -static int vfio_v1_load_setup(QEMUFile *f, void *opaque) -{ - VFIODevice *vbasedev =3D opaque; - VFIOMigration *migration =3D vbasedev->migration; - int ret =3D 0; - - if (migration->region.mmaps) { - ret =3D vfio_region_mmap(&migration->region); - if (ret) { - error_report("%s: Failed to mmap VFIO migration region %d: %s", - vbasedev->name, migration->region.nr, - strerror(-ret)); - error_report("%s: Falling back to slow path", vbasedev->name); - } - } - - ret =3D vfio_migration_v1_set_state(vbasedev, ~VFIO_DEVICE_STATE_MASK, - VFIO_DEVICE_STATE_V1_RESUMING); - if (ret) { - error_report("%s: Failed to set state RESUMING", vbasedev->name); - if (migration->region.mmaps) { - vfio_region_unmap(&migration->region); - } - } - return ret; -} - static int vfio_load_cleanup(void *opaque) { VFIODevice *vbasedev =3D opaque; @@ -886,15 +372,6 @@ static int vfio_load_cleanup(void *opaque) return 0; } =20 -static int vfio_v1_load_cleanup(void *opaque) -{ - VFIODevice *vbasedev =3D opaque; - - vfio_migration_v1_cleanup(vbasedev); - trace_vfio_load_cleanup(vbasedev->name); - return 0; -} - static int vfio_load_state(QEMUFile *f, void *opaque, int version_id) { VFIODevice *vbasedev =3D opaque; @@ -928,11 +405,7 @@ static int vfio_load_state(QEMUFile *f, void *opaque, = int version_id) uint64_t data_size =3D qemu_get_be64(f); =20 if (data_size) { - if (vbasedev->migration->v2) { - ret =3D vfio_load_buffer(f, vbasedev, data_size); - } else { - ret =3D vfio_v1_load_buffer(f, vbasedev, data_size); - } + ret =3D vfio_load_buffer(f, vbasedev, data_size); if (ret < 0) { return ret; } @@ -964,18 +437,6 @@ static const SaveVMHandlers savevm_vfio_handlers =3D { .load_state =3D vfio_load_state, }; =20 -static SaveVMHandlers savevm_vfio_v1_handlers =3D { - .save_setup =3D vfio_v1_save_setup, - .save_cleanup =3D vfio_v1_save_cleanup, - .save_live_pending =3D vfio_v1_save_pending, - .save_live_iterate =3D vfio_save_iterate, - .save_live_complete_precopy =3D vfio_v1_save_complete_precopy, - .save_state =3D vfio_save_state, - .load_setup =3D vfio_v1_load_setup, - .load_cleanup =3D vfio_v1_load_cleanup, - .load_state =3D vfio_load_state, -}; - /* ---------------------------------------------------------------------- = */ =20 static void vfio_vmstate_change(void *opaque, bool running, RunState state) @@ -1006,70 +467,12 @@ static void vfio_vmstate_change(void *opaque, bool r= unning, RunState state) mig_state_to_str(new_state)); } =20 -static void vfio_v1_vmstate_change(void *opaque, bool running, RunState st= ate) -{ - VFIODevice *vbasedev =3D opaque; - VFIOMigration *migration =3D vbasedev->migration; - uint32_t value, mask; - int ret; - - if (vbasedev->migration->vm_running =3D=3D running) { - return; - } - - if (running) { - /* - * Here device state can have one of _SAVING, _RESUMING or _STOP b= it. - * Transition from _SAVING to _RUNNING can happen if there is migr= ation - * failure, in that case clear _SAVING bit. - * Transition from _RESUMING to _RUNNING occurs during resuming - * phase, in that case clear _RESUMING bit. - * In both the above cases, set _RUNNING bit. - */ - mask =3D ~VFIO_DEVICE_STATE_MASK; - value =3D VFIO_DEVICE_STATE_V1_RUNNING; - } else { - /* - * Here device state could be either _RUNNING or _SAVING|_RUNNING.= Reset - * _RUNNING bit - */ - mask =3D ~VFIO_DEVICE_STATE_V1_RUNNING; - - /* - * When VM state transition to stop for savevm command, device sho= uld - * start saving data. - */ - if (state =3D=3D RUN_STATE_SAVE_VM) { - value =3D VFIO_DEVICE_STATE_V1_SAVING; - } else { - value =3D 0; - } - } - - ret =3D vfio_migration_v1_set_state(vbasedev, mask, value); - if (ret) { - /* - * Migration should be aborted in this case, but vm_state_notify() - * currently does not support reporting failures. - */ - error_report("%s: Failed to set device state 0x%x", vbasedev->name, - (migration->device_state_v1 & mask) | value); - if (migrate_get_current()->to_dst_file) { - qemu_file_set_error(migrate_get_current()->to_dst_file, ret); - } - } - vbasedev->migration->vm_running =3D running; - trace_vfio_v1_vmstate_change(vbasedev->name, running, RunState_str(sta= te), - (migration->device_state_v1 & mask) | value); -} - static void vfio_migration_state_notifier(Notifier *notifier, void *data) { MigrationState *s =3D data; VFIOMigration *migration =3D container_of(notifier, VFIOMigration, migration_state); VFIODevice *vbasedev =3D migration->vbasedev; - int ret; =20 trace_vfio_migration_state_notifier(vbasedev->name, MigrationStatus_str(s->state)); @@ -1079,18 +482,8 @@ static void vfio_migration_state_notifier(Notifier *n= otifier, void *data) case MIGRATION_STATUS_CANCELLED: case MIGRATION_STATUS_FAILED: bytes_transferred =3D 0; - if (migration->v2) { - vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_RUNNING, - VFIO_DEVICE_STATE_ERROR); - } else { - ret =3D vfio_migration_v1_set_state(vbasedev, - ~(VFIO_DEVICE_STATE_V1_SAVIN= G | - VFIO_DEVICE_STATE_V1_RESUM= ING), - VFIO_DEVICE_STATE_V1_RUNNING= ); - if (ret) { - error_report("%s: Failed to set state RUNNING", vbasedev->= name); - } - } + vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_RUNNING, + VFIO_DEVICE_STATE_ERROR); } } =20 @@ -1130,12 +523,6 @@ static int vfio_migration_data_notifier(NotifierWithR= eturn *n, void *data) =20 static void vfio_migration_exit(VFIODevice *vbasedev) { - VFIOMigration *migration =3D vbasedev->migration; - - if (!migration->v2) { - vfio_region_exit(&migration->region); - vfio_region_finalize(&migration->region); - } g_free(vbasedev->migration); vbasedev->migration =3D NULL; } @@ -1175,7 +562,6 @@ static int vfio_migration_init(VFIODevice *vbasedev) VFIOMigration *migration; char id[256] =3D ""; g_autofree char *path =3D NULL, *oid =3D NULL; - struct vfio_region_info *info; uint64_t mig_flags; =20 if (!vbasedev->ops->vfio_get_object) { @@ -1188,52 +574,20 @@ static int vfio_migration_init(VFIODevice *vbasedev) } =20 ret =3D vfio_migration_query_flags(vbasedev, &mig_flags); - if (!ret) { - /* Migration v2 */ - /* Basic migration functionality must be supported */ - if (!(mig_flags & VFIO_MIGRATION_STOP_COPY)) { - return -EOPNOTSUPP; - } - vbasedev->migration =3D g_new0(VFIOMigration, 1); - vbasedev->migration->device_state =3D VFIO_DEVICE_STATE_RUNNING; - vbasedev->migration->data_fd =3D -1; - vbasedev->migration->v2 =3D true; - } else if (ret =3D=3D -ENOTTY) { - /* Migration v1 */ - ret =3D vfio_get_dev_region_info(vbasedev, - VFIO_REGION_TYPE_MIGRATION_DEPRECAT= ED, - VFIO_REGION_SUBTYPE_MIGRATION_DEPRE= CATED, - &info); - if (ret) { - return ret; - } - - vbasedev->migration =3D g_new0(VFIOMigration, 1); - vbasedev->migration->device_state_v1 =3D VFIO_DEVICE_STATE_V1_RUNN= ING; - vbasedev->migration->vm_running =3D runstate_is_running(); - - ret =3D vfio_region_setup(obj, vbasedev, &vbasedev->migration->reg= ion, - info->index, "migration"); - if (ret) { - error_report("%s: Failed to setup VFIO migration region %d: %s= ", - vbasedev->name, info->index, strerror(-ret)); - goto err; - } - - if (!vbasedev->migration->region.size) { - error_report("%s: Invalid zero-sized VFIO migration region %d", - vbasedev->name, info->index); - ret =3D -EINVAL; - goto err; - } - - g_free(info); - } else { + if (ret) { return ret; } =20 + /* Basic migration functionality must be supported */ + if (!(mig_flags & VFIO_MIGRATION_STOP_COPY)) { + return -EOPNOTSUPP; + } + + vbasedev->migration =3D g_new0(VFIOMigration, 1); migration =3D vbasedev->migration; migration->vbasedev =3D vbasedev; + migration->device_state =3D VFIO_DEVICE_STATE_RUNNING; + migration->data_fd =3D -1; =20 oid =3D vmstate_if_get_id(VMSTATE_IF(DEVICE(obj))); if (oid) { @@ -1243,31 +597,18 @@ static int vfio_migration_init(VFIODevice *vbasedev) } strpadcpy(id, sizeof(id), path, '\0'); =20 - if (migration->v2) { - register_savevm_live(id, VMSTATE_INSTANCE_ID_ANY, 1, - &savevm_vfio_handlers, vbasedev); - - migration->vm_state =3D qdev_add_vm_change_state_handler( - vbasedev->dev, vfio_vmstate_change, vbasedev); - - migration->migration_data.notify =3D vfio_migration_data_notifier; - precopy_add_notifier(&migration->migration_data); - } else { - register_savevm_live(id, VMSTATE_INSTANCE_ID_ANY, 1, - &savevm_vfio_v1_handlers, vbasedev); - - migration->vm_state =3D qdev_add_vm_change_state_handler( - vbasedev->dev, vfio_v1_vmstate_change, vbasedev); - } + register_savevm_live(id, VMSTATE_INSTANCE_ID_ANY, 1, &savevm_vfio_hand= lers, + vbasedev); =20 + migration->vm_state =3D qdev_add_vm_change_state_handler(vbasedev->dev, + vfio_vmstate_ch= ange, + vbasedev); migration->migration_state.notify =3D vfio_migration_state_notifier; add_migration_state_change_notifier(&migration->migration_state); - return 0; + migration->migration_data.notify =3D vfio_migration_data_notifier; + precopy_add_notifier(&migration->migration_data); =20 -err: - g_free(info); - vfio_migration_exit(vbasedev); - return ret; + return 0; } =20 /* ---------------------------------------------------------------------- = */ @@ -1310,9 +651,7 @@ void vfio_migration_finalize(VFIODevice *vbasedev) if (vbasedev->migration) { VFIOMigration *migration =3D vbasedev->migration; =20 - if (migration->v2) { - precopy_remove_notifier(&migration->migration_data); - } + precopy_remove_notifier(&migration->migration_data); remove_migration_state_change_notifier(&migration->migration_state= ); qemu_del_vm_change_state_handler(migration->vm_state); unregister_savevm(VMSTATE_IF(vbasedev->dev), "vfio", vbasedev); diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index a8a64f0627..60c49b2ecf 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -150,24 +150,15 @@ vfio_display_edid_write_error(void) "" # migration.c vfio_migration_probe(const char *name) " (%s)" vfio_migration_set_state(const char *name, const char *state) " (%s) state= %s" -vfio_migration_v1_set_state(const char *name, uint32_t state) " (%s) state= %d" vfio_vmstate_change(const char *name, int running, const char *reason, con= st char *dev_state) " (%s) running %d reason %s device state %s" -vfio_v1_vmstate_change(const char *name, int running, const char *reason, = uint32_t dev_state) " (%s) running %d reason %s device state %d" vfio_migration_state_notifier(const char *name, const char *state) " (%s) = state %s" vfio_save_setup(const char *name, uint64_t data_buffer_size) " (%s) data b= uffer size 0x%"PRIx64 -vfio_v1_save_setup(const char *name) " (%s)" vfio_save_cleanup(const char *name) " (%s)" -vfio_save_buffer(const char *name, uint64_t data_offset, uint64_t data_siz= e, uint64_t pending) " (%s) Offset 0x%"PRIx64" size 0x%"PRIx64" pending 0x%= "PRIx64 -vfio_update_pending(const char *name, uint64_t pending) " (%s) pending 0x%= "PRIx64 vfio_save_device_config_state(const char *name) " (%s)" vfio_save_pending(const char *name, uint64_t precopy, uint64_t postcopy, u= int64_t compatible, uint64_t stopcopy_size) " (%s) precopy 0x%"PRIx64" post= copy 0x%"PRIx64" compatible 0x%"PRIx64" stopcopy size 0x%"PRIx64 -vfio_v1_save_pending(const char *name, uint64_t precopy, uint64_t postcopy= , uint64_t compatible) " (%s) precopy 0x%"PRIx64" postcopy 0x%"PRIx64" comp= atible 0x%"PRIx64 -vfio_save_iterate(const char *name, int data_size) " (%s) data_size %d" vfio_save_complete_precopy(const char *name, int ret) " (%s) ret %d" -vfio_v1_save_complete_precopy(const char *name) " (%s)" vfio_load_device_config_state(const char *name) " (%s)" vfio_load_state(const char *name, uint64_t data) " (%s) data 0x%"PRIx64 -vfio_v1_load_state_device_data(const char *name, uint64_t data_offset, uin= t64_t data_size) " (%s) Offset 0x%"PRIx64" size 0x%"PRIx64 vfio_load_state_device_data(const char *name, uint64_t data_size, int ret)= " (%s) size 0x%"PRIx64" ret %d" vfio_load_cleanup(const char *name) " (%s)" vfio_get_dirty_bitmap(int fd, uint64_t iova, uint64_t size, uint64_t bitma= p_size, uint64_t start) "container fd=3D%d, iova=3D0x%"PRIx64" size=3D 0x%"= PRIx64" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64 --=20 2.26.3 From nobody Sat Apr 27 01:04:01 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1673513756; cv=pass; d=zohomail.com; s=zohoarc; b=OVzbdKRmRr6BWQhIz2i7a8JgQKfv8GyE8UZQMZ995FFR2R+vmdgwziusozt4wae+uU9yD/IhlpkovhveDzQfG8c/KljhtVV1OG+c8z0SVPCBks8+OQDlqvRdK2iK8QU2t9zoJ13B9/ANpg4KsapvBKolZAuke6m1EZALsgIGGNk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673513756; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=V9pyseSCeg3hoEOq/g2C1c18gpMiWspe6EUPmeNY8/U=; b=FTeZ1160e05Go3dhNohpoqduWlzhXGmTo5a82oR1mYy/RSunT/N34vbVz6aFbIc3vtWGgYkR/AjYFeUqEpb8eTYQgpWlbSZD4tx4z/0HkiFbj3fYw+aydY6kodEJUIqFcy+Y8ruHcqlKEe8k1EX+WC/3y7BDzvqvJ4iI4BaMSUY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673513756821264.3295149891826; Thu, 12 Jan 2023 00:55:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFtKP-0006dr-VX; Thu, 12 Jan 2023 03:52:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJh-00069T-ME; Thu, 12 Jan 2023 03:52:24 -0500 Received: from mail-mw2nam12on2084.outbound.protection.outlook.com ([40.107.244.84] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJe-0007in-5p; Thu, 12 Jan 2023 03:52:07 -0500 Received: from DM6PR14CA0054.namprd14.prod.outlook.com (2603:10b6:5:18f::31) by IA1PR12MB8287.namprd12.prod.outlook.com (2603:10b6:208:3f5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Thu, 12 Jan 2023 08:51:59 +0000 Received: from DS1PEPF0000E632.namprd02.prod.outlook.com (2603:10b6:5:18f:cafe::2e) by DM6PR14CA0054.outlook.office365.com (2603:10b6:5:18f::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:51:58 +0000 Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0000E632.mail.protection.outlook.com (10.167.17.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.11 via Frontend Transport; Thu, 12 Jan 2023 08:51:58 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:50 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:49 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 12 Jan 2023 00:51:43 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k0gyDerC56NQEqxUmjm26QBGble2VwD2GIeDoKhPixAT/KSPuTcl39rF7rkJjmZIn1lVYV8u7le74tq7pgqP697BYaFmZgcWSXS6nOI1BKvJitNYPev6lJ/q36NOvGJutsAHSfaiPhSGBfZuR/PmuOjEAg+XnSr2QS6V7XUDb0LZUS3M4mj38mTVQb5adT+gLAgVZgXnEeh25uBPgSj2B98R7SulF33yw3zpXpLUcdudvJ/DdS20TISefcbXTHiyxfq6FkeL32d2Xpe47QzVWFf3Wwd82oYR0SwHiJ9rPbhUNW7xEKTPxBV+JOvs0z05NDH2cIPajQmC5IX8kS7isA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=V9pyseSCeg3hoEOq/g2C1c18gpMiWspe6EUPmeNY8/U=; b=QleXmr9dNtgvorzZoE07e3feiqc33YX7vQkHE3d3Wa6uGfKtNsmgG9gQwz43PG2QJoFkqLcOO3dKaSi67ifa0vfv38SxM/uw+UpasmywHCab7CZdzv85xJ2h4E/c5iazcur7ODvMtZsaxVmWm7fe8oHjGZAKOwkIDRnqPfOZXFckBATG+srJbcEC2usUJnbKryjEgaQsQnFfGwFHaEHwTaMCL5bZeZVseA2H4QwOZB0h3dBVnlJGmgp6nboUOEDzJzEq2kohLpGIbQf9MFsjy+w6eEpXP87G2HjTXSMBKBTz1FGA7+WzXe5HJ5xpE8G8Fcg5V/Ke6+fdQlfQUdtuAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V9pyseSCeg3hoEOq/g2C1c18gpMiWspe6EUPmeNY8/U=; b=h4AOPCSq84xRMu/e2BJyZwaj3IbwBuKBfq+/fbZYqWpNn9l9Q8+R5ryTZHh3jUpgoYENgDV8SewfaXDN8MlboOzm5I+jm3qn29j4wn8e/D30/c0AbrZI/gqw4xf1PT/xhNZvlbbT+D4q7+0ST6Xcu9YekA1zlWHiOPkDqeoqSz58Vt2mbFbcEtOX6Cguxav/VrUuMWEftZkaMNPDOJl6K3WxjADfdNCWxVAOccjA1LLNp7g9dHFIYlN2a5ORFTVBlN7Yn8foS5Pm4pXV78p123tMQiqTi9KB6U1bsD/zP96/p/F7FpOZlxCrNd5waJqfn8QuROP+n8F/2/cBADFJpw== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , "Ilya Leoshkevich" , Thomas Huth , "Juan Quintela" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v6 12/13] vfio: Alphabetize migration section of VFIO trace-events file Date: Thu, 12 Jan 2023 10:50:19 +0200 Message-ID: <20230112085020.15866-13-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230112085020.15866-1-avihaih@nvidia.com> References: <20230112085020.15866-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E632:EE_|IA1PR12MB8287:EE_ X-MS-Office365-Filtering-Correlation-Id: 746f9ce8-1099-465a-ea1d-08daf47a43f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oorq/YvAwh50dZr130CWtGvpQ61BMHSTBGiQLhDVT5XVrsCRoIkquVED0JAD7gdwXkj8DmsrWdDoa/g1ez+uAmgT7t0hMLwhrCLikaksAJcIjVeXIiYJ/HiXAqnjdBBcQ0gKcc6pgy3LkR0qwu6xbycNMtm6htx3OfupbH+0S0KuvKwAut1VC7AwT57LIgSURis9eGCPkX0eRihmaRqR7lVVM5nrHTy6E86DyKHkCMQ+HM1Qu6xcFHExLZVM+6vuXD7RjR5xZN4QcDNqsCp3ObWySY8cn+L7pS6pIgGqf9NShlBBE97d/pQStSrcW8LxvyFAcoRSgWaTPvBmdP4ZFyGiiY7UhYAajQzA/ZmNgfkYJv9oAlbjhR6cyWpxgNsg1xX+i2O23UKofq2AMQUl+oX6QT9xuHWKp9kcMTX7dxWLHi4fITlBVwI1UnujamuwCppnJEUJUmpYPU9PG0MVoZZz4qLkaI/QdCKJRhsEM6+ZWv477jZN8luiMqSEbWCh3TRCO7CL2cc4ssINZamXw3ccAWFrnIlno7xpKZkW0kCLWZS+7Dk6AefYDSbpmu7kVvDqHYZgLO21OurJ0gpX8/6+UvUc76KbfViV4DehfVmcVMSdcgx/Pq4eK3kFXpsuK+ZEmrUbhj0/4XfMSNVuWGcMyauOgdusLORcvrheNd4xM0aaHdTprPbzR+JoQO20/9ytb2EcPyzB+Z4PL3E7vA== X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(376002)(396003)(346002)(136003)(451199015)(36840700001)(40470700004)(46966006)(47076005)(6666004)(40480700001)(2616005)(336012)(186003)(26005)(4326008)(316002)(1076003)(70206006)(7696005)(6916009)(54906003)(478600001)(70586007)(36860700001)(356005)(7636003)(82740400003)(86362001)(426003)(83380400001)(40460700003)(7416002)(82310400005)(41300700001)(8676002)(36756003)(5660300002)(2906002)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 08:51:58.7989 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 746f9ce8-1099-465a-ea1d-08daf47a43f0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E632.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8287 Received-SPF: softfail client-ip=40.107.244.84; envelope-from=avihaih@nvidia.com; helo=NAM12-MW2-obe.outbound.protection.outlook.com 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_H2=-0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1673513758711100003 Content-Type: text/plain; charset="utf-8" Sort the migration section of VFIO trace events file alphabetically and move two misplaced traces to common.c section. Signed-off-by: Avihai Horon Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/trace-events | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 60c49b2ecf..db9cb94952 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -119,6 +119,8 @@ vfio_region_sparse_mmap_header(const char *name, int in= dex, int nr_areas) "Devic vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long en= d) "sparse entry %d [0x%lx - 0x%lx]" vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t s= ubtype) "%s index %d, %08x/%0x8" vfio_dma_unmap_overflow_workaround(void) "" +vfio_get_dirty_bitmap(int fd, uint64_t iova, uint64_t size, uint64_t bitma= p_size, uint64_t start) "container fd=3D%d, iova=3D0x%"PRIx64" size=3D 0x%"= PRIx64" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64 +vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu= dirty @ 0x%"PRIx64" - 0x%"PRIx64 =20 # platform.c vfio_platform_base_device_init(char *name, int groupid) "%s belongs to gro= up #%d" @@ -148,20 +150,18 @@ vfio_display_edid_update(uint32_t prefx, uint32_t pre= fy) "%ux%u" vfio_display_edid_write_error(void) "" =20 # migration.c +vfio_load_cleanup(const char *name) " (%s)" +vfio_load_device_config_state(const char *name) " (%s)" +vfio_load_state(const char *name, uint64_t data) " (%s) data 0x%"PRIx64 +vfio_load_state_device_data(const char *name, uint64_t data_size, int ret)= " (%s) size 0x%"PRIx64" ret %d" +vfio_migration_data_notifier(const char *name, uint64_t stopcopy_size) " (= %s) stopcopy size 0x%"PRIx64 vfio_migration_probe(const char *name) " (%s)" vfio_migration_set_state(const char *name, const char *state) " (%s) state= %s" -vfio_vmstate_change(const char *name, int running, const char *reason, con= st char *dev_state) " (%s) running %d reason %s device state %s" vfio_migration_state_notifier(const char *name, const char *state) " (%s) = state %s" -vfio_save_setup(const char *name, uint64_t data_buffer_size) " (%s) data b= uffer size 0x%"PRIx64 +vfio_save_block(const char *name, int data_size) " (%s) data_size %d" vfio_save_cleanup(const char *name) " (%s)" +vfio_save_complete_precopy(const char *name, int ret) " (%s) ret %d" vfio_save_device_config_state(const char *name) " (%s)" vfio_save_pending(const char *name, uint64_t precopy, uint64_t postcopy, u= int64_t compatible, uint64_t stopcopy_size) " (%s) precopy 0x%"PRIx64" post= copy 0x%"PRIx64" compatible 0x%"PRIx64" stopcopy size 0x%"PRIx64 -vfio_save_complete_precopy(const char *name, int ret) " (%s) ret %d" -vfio_load_device_config_state(const char *name) " (%s)" -vfio_load_state(const char *name, uint64_t data) " (%s) data 0x%"PRIx64 -vfio_load_state_device_data(const char *name, uint64_t data_size, int ret)= " (%s) size 0x%"PRIx64" ret %d" -vfio_load_cleanup(const char *name) " (%s)" -vfio_get_dirty_bitmap(int fd, uint64_t iova, uint64_t size, uint64_t bitma= p_size, uint64_t start) "container fd=3D%d, iova=3D0x%"PRIx64" size=3D 0x%"= PRIx64" bitmap_size=3D0x%"PRIx64" start=3D0x%"PRIx64 -vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu= dirty @ 0x%"PRIx64" - 0x%"PRIx64 -vfio_save_block(const char *name, int data_size) " (%s) data_size %d" -vfio_migration_data_notifier(const char *name, uint64_t stopcopy_size) " (= %s) stopcopy size 0x%"PRIx64 +vfio_save_setup(const char *name, uint64_t data_buffer_size) " (%s) data b= uffer size 0x%"PRIx64 +vfio_vmstate_change(const char *name, int running, const char *reason, con= st char *dev_state) " (%s) running %d reason %s device state %s" --=20 2.26.3 From nobody Sat Apr 27 01:04:01 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass(p=reject dis=none) header.from=nvidia.com ARC-Seal: i=2; a=rsa-sha256; t=1673513610; cv=pass; d=zohomail.com; s=zohoarc; b=OfltRRq5Q+GdNljFjKDfc6DCEtuEHR1R+5zIeDbREoFL7b/3nwpCgV9bUCXTwoLh4buzlJF1Whdmm7dG/aqeNx3mN4xqcRQe/COFjC/17ewnQlCha0dSa1clANfzCyvY5LDw11DAZwGCWne2Ef4XIL8hOYw5a0JmYwlrzlvrEo8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673513610; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y3dnTxRNbzchM98MvirUzpSLvA2I7wBPStoecrc95h0=; b=E63nr0I0D99tUJ69aQ7wIfrFVWXPnAHAztNlDuiZnrlZPLsbF+dv1+gxlDQsTzzmJw/BKwmq8LP5TyUuqRvBrEED57pLTCAuv0eFmzxCEHfDrSfZ3zaWhehyIoYmtoIFmuUpleV+TXxE8p4damnyNgWfSdycgWyrBeauSVgX+xk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nvidia.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTP id 1673513610855769.1880439363808; Thu, 12 Jan 2023 00:53:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFtK9-0006PN-HO; Thu, 12 Jan 2023 03:52:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJq-0006Gw-57; Thu, 12 Jan 2023 03:52:28 -0500 Received: from mail-dm6nam10on2073.outbound.protection.outlook.com ([40.107.93.73] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFtJk-0007jR-3I; Thu, 12 Jan 2023 03:52:15 -0500 Received: from DM6PR05CA0053.namprd05.prod.outlook.com (2603:10b6:5:335::22) by BY5PR12MB4147.namprd12.prod.outlook.com (2603:10b6:a03:205::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Thu, 12 Jan 2023 08:52:07 +0000 Received: from DS1PEPF0000E633.namprd02.prod.outlook.com (2603:10b6:5:335:cafe::33) by DM6PR05CA0053.outlook.office365.com (2603:10b6:5:335::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Thu, 12 Jan 2023 08:52:07 +0000 Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0000E633.mail.protection.outlook.com (10.167.17.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.11 via Frontend Transport; Thu, 12 Jan 2023 08:52:07 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:56 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 12 Jan 2023 00:51:56 -0800 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Thu, 12 Jan 2023 00:51:50 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IOAfMWDbbyPguUGf3oD2/J01qx2WGLK9rbXXG7DdxSj+gdZi9q68/51asQTMikwWVZyc8wu9sc5Suh3NDgV+D5VrT/7gdIzGGlCY748WHVXuc/B8s1Z9uufmOs+KILxPcPUN95J0vGcvC7cf3xRiv4A2IHcMmhmXtQRLAh7VIbalysG7U+Pi5yE1kTwEYAB64wGv3ISqXtb1Rg/I4yZrpQ0EmsbiZYpASZjGwDiCOxHzMnkYtxkq1NmDEPh2zipCySXsGI3zSRZhXaV6165Pti4G1yz+IQ90khySt4CaG2mjYDx5chK1tiLdZ+I0UKKTiXUP6gg0Xu0/VR+KA7uOrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Y3dnTxRNbzchM98MvirUzpSLvA2I7wBPStoecrc95h0=; b=i+5lBtQddnYD1oZSLU5nCAFa3oaYRhx2CadtsmQX3EeFJmuKnocadpLAmeEQued0Nmej+K1F9Kg9s7qByD/8g0rzUCj1K/7hUWBccAfGqyJui0Q8MF+3Qx4Csdvss9Fu2Q5VutrBnfMRDpYn5BWHOxMC5TsqvJGpbw+jHYXj3d2bVOVBqhjKgCjIHOvfRxcqPgF/AtFCVodMznbYtkltWlm/Sk6Zt6vNiflHI57t/mWYa0B9Pmp9Zogxf37f3CsVZpW2GhuuSAIbwz+U/AzDAKfZJP2nD1aYYTMVdXka1SF8R81HgKy+IiVBfeyJUDGV3tAR5qCowxRIUAG8+Th24g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y3dnTxRNbzchM98MvirUzpSLvA2I7wBPStoecrc95h0=; b=iRPBYVrf0ZMRcAiYMJIc8f0nnT69p3qkH8XvR5SK86bVHWPUdlnw6x9AO9pOj+Ii3dY3eXcpH+/MsSWolIctqe8smsxLmuGJo+UMtciT2ynHkMEXRci2pISSldQ4PT4Tvht4XkSJo/yUM8EeWJQXAIeEIxjYIlVhuf0bPS9eMuVCp4W7pJoVYRP1KiICiocqEF8TvNTcJZLrW9JNzCVKVZfVZy2MqktJPw1G2SzETyHVEo3Du4O5d3MDVimBfSLl1pKz2DrlfWUw06BRXopCm0LG4Jo5wlXTKgxsTUn1K+K5moFXJeUZJD7ffuu/wmTb/w1seO+RKSVRKaHVzBazew== X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C From: Avihai Horon To: CC: Alex Williamson , Halil Pasic , Christian Borntraeger , Eric Farman , Richard Henderson , David Hildenbrand , "Ilya Leoshkevich" , Thomas Huth , "Juan Quintela" , "Dr. David Alan Gilbert" , "Michael S. Tsirkin" , Cornelia Huck , Paolo Bonzini , Stefan Hajnoczi , Fam Zheng , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , , , Yishai Hadas , Jason Gunthorpe , Maor Gottlieb , Avihai Horon , Kirti Wankhede , Tarun Gupta , Joao Martins Subject: [PATCH v6 13/13] docs/devel: Align VFIO migration docs to v2 protocol Date: Thu, 12 Jan 2023 10:50:20 +0200 Message-ID: <20230112085020.15866-14-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230112085020.15866-1-avihaih@nvidia.com> References: <20230112085020.15866-1-avihaih@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E633:EE_|BY5PR12MB4147:EE_ X-MS-Office365-Filtering-Correlation-Id: 9dd7e72a-1ff3-4f87-1dbf-08daf47a48fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BIoUSfoDKjTs5q5yi4IHxbVn4FozTZR31K38zrK2MI0pbR4X7+NkUWf3YkWeVAjNuSIymABQC2qUa/gg4f5ccYptymDyR6avj/Io949ys2EOI0JVFfzX3fZeneNKpmcxv43dfXoillVerN65wsKAKtF1ouAsdBIjCmZPvRb5gLwAEMVMef9cJtw2a4xq34FI1YknmZQWni412CfC8brg6vzwOCzmblxB5Un9J9ckjBcyPXNriZQz1nTd4bU1aecjGHkhzqKzrpQMCQNFCwyoQweRrcWJ/RncQHblSVOiKKWex+Us7IzhIZLRi5E15ljVkQUcmxwgyD5ZnwETlh1p+rSfNOAoRIUa8VqAVLMti9KL/mDydq0R7YjfEywCw+wIYBVYLNy6RXl7IpNwMs9xfIoRBb4a1ISS0x43uUml/Ea+jyF9s+uQZp+oY7DXaSQ5GAD/HAdRxvydH+Nmdofn7/OPjmRNcnGFHRGAdNI2P9qHqxchsIg3I2kwRAnOX2hgGks9HyOjxZxX1jWLt/caqQLiBRRGAZS5uRSKXq7zjGgIHGT/W9KoqOhSUe8mAuw+F4sz2nylOmo+iueDLrvgRdXQo5hh9t+lWWUSL+LeSwnKYeKPrES+D2UGOt9aFBdo5Gt1W2kVDW0a0tv6jQSPR8dx2YURJdJBpLulNH9JreKPI9f+9j4hxgBAcHNOHWPmkzHJ8/9AjPeq32cZ+WufeQ== X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(376002)(136003)(346002)(396003)(451199015)(40470700004)(36840700001)(46966006)(36756003)(82740400003)(7636003)(70586007)(6916009)(70206006)(8676002)(336012)(4326008)(82310400005)(186003)(86362001)(26005)(40460700003)(1076003)(316002)(356005)(2616005)(40480700001)(54906003)(7696005)(478600001)(5660300002)(6666004)(2906002)(41300700001)(47076005)(8936002)(426003)(7416002)(83380400001)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 08:52:07.2609 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9dd7e72a-1ff3-4f87-1dbf-08daf47a48fc X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E633.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4147 Received-SPF: softfail client-ip=40.107.93.73; envelope-from=avihaih@nvidia.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com 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_H2=-0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @Nvidia.com) X-ZM-MESSAGEID: 1673513611958100001 Content-Type: text/plain; charset="utf-8" Now that VFIO migration protocol v2 has been implemented and v1 protocol has been removed, update the documentation according to v2 protocol. Signed-off-by: Avihai Horon Reviewed-by: C=C3=A9dric Le Goater --- docs/devel/vfio-migration.rst | 68 ++++++++++++++++------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/docs/devel/vfio-migration.rst b/docs/devel/vfio-migration.rst index 9ff6163c88..1d50c2fe5f 100644 --- a/docs/devel/vfio-migration.rst +++ b/docs/devel/vfio-migration.rst @@ -7,46 +7,39 @@ the guest is running on source host and restoring this sa= ved state on the destination host. This document details how saving and restoring of VFIO devices is done in QEMU. =20 -Migration of VFIO devices consists of two phases: the optional pre-copy ph= ase, -and the stop-and-copy phase. The pre-copy phase is iterative and allows to -accommodate VFIO devices that have a large amount of data that needs to be -transferred. The iterative pre-copy phase of migration allows for the gues= t to -continue whilst the VFIO device state is transferred to the destination, t= his -helps to reduce the total downtime of the VM. VFIO devices can choose to s= kip -the pre-copy phase of migration by returning pending_bytes as zero during = the -pre-copy phase. +Migration of VFIO devices currently consists of a single stop-and-copy pha= se. +During the stop-and-copy phase the guest is stopped and the entire VFIO de= vice +data is transferred to the destination. + +The pre-copy phase of migration is currently not supported for VFIO device= s. +Support for VFIO pre-copy will be added later on. =20 A detailed description of the UAPI for VFIO device migration can be found = in -the comment for the ``vfio_device_migration_info`` structure in the header -file linux-headers/linux/vfio.h. +the comment for the ``vfio_device_mig_state`` structure in the header file +linux-headers/linux/vfio.h. =20 VFIO implements the device hooks for the iterative approach as follows: =20 -* A ``save_setup`` function that sets up the migration region and sets _SA= VING - flag in the VFIO device state. +* A ``save_setup`` function that sets up migration on the source. =20 -* A ``load_setup`` function that sets up the migration region on the - destination and sets _RESUMING flag in the VFIO device state. +* A ``load_setup`` function that sets the VFIO device on the destination in + _RESUMING state. =20 * A ``save_live_pending`` function that reads pending_bytes from the vendor driver, which indicates the amount of data that the vendor driver has ye= t to save for the VFIO device. =20 -* A ``save_live_iterate`` function that reads the VFIO device's data from = the - vendor driver through the migration region during iterative phase. - * A ``save_state`` function to save the device config space if it is prese= nt. =20 -* A ``save_live_complete_precopy`` function that resets _RUNNING flag from= the - VFIO device state and iteratively copies the remaining data for the VFIO - device until the vendor driver indicates that no data remains (pending b= ytes - is zero). +* A ``save_live_complete_precopy`` function that sets the VFIO device in + _STOP_COPY state and iteratively copies the data for the VFIO device unt= il + the vendor driver indicates that no data remains. =20 * A ``load_state`` function that loads the config section and the data - sections that are generated by the save functions above + sections that are generated by the save functions above. =20 * ``cleanup`` functions for both save and load that perform any migration - related cleanup, including unmapping the migration region + related cleanup. =20 =20 The VFIO migration code uses a VM state change handler to change the VFIO @@ -71,13 +64,13 @@ tracking can identify dirtied pages, but any page pinne= d by the vendor driver can also be written by the device. There is currently no device or IOMMU support for dirty page tracking in hardware. =20 -By default, dirty pages are tracked when the device is in pre-copy as well= as -stop-and-copy phase. So, a page pinned by the vendor driver will be copied= to -the destination in both phases. Copying dirty pages in pre-copy phase helps -QEMU to predict if it can achieve its downtime tolerances. If QEMU during -pre-copy phase keeps finding dirty pages continuously, then it understands -that even in stop-and-copy phase, it is likely to find dirty pages and can -predict the downtime accordingly. +By default, dirty pages are tracked during pre-copy as well as stop-and-co= py +phase. So, a page pinned by the vendor driver will be copied to the destin= ation +in both phases. Copying dirty pages in pre-copy phase helps QEMU to predic= t if +it can achieve its downtime tolerances. If QEMU during pre-copy phase keeps +finding dirty pages continuously, then it understands that even in stop-an= d-copy +phase, it is likely to find dirty pages and can predict the downtime +accordingly. =20 QEMU also provides a per device opt-out option ``pre-copy-dirty-page-track= ing`` which disables querying the dirty bitmap during pre-copy phase. If it is s= et to @@ -111,23 +104,22 @@ Live migration save path | migrate_init spawns migration_thread Migration thread then calls each device's .save_setup() - (RUNNING, _SETUP, _RUNNING|_SAVING) + (RUNNING, _SETUP, _RUNNING) | - (RUNNING, _ACTIVE, _RUNNING|_SAVING) + (RUNNING, _ACTIVE, _RUNNING) If device is active, get pending_bytes by .save_live_pending() If total pending_bytes >=3D threshold_size, call .save_live_iter= ate() - Data of VFIO device for pre-copy phase is copied Iterate till total pending bytes converge and are less than thresh= old | On migration completion, vCPU stops and calls .save_live_complete_precop= y for - each active device. The VFIO device is then transitioned into _SAVING s= tate - (FINISH_MIGRATE, _DEVICE, _SAVING) + each active device. The VFIO device is then transitioned into _STOP_COPY= state + (FINISH_MIGRATE, _DEVICE, _STOP_COPY) | For the VFIO device, iterate in .save_live_complete_precopy until pending data is 0 - (FINISH_MIGRATE, _DEVICE, _STOPPED) + (FINISH_MIGRATE, _DEVICE, _STOP) | - (FINISH_MIGRATE, _COMPLETED, _STOPPED) + (FINISH_MIGRATE, _COMPLETED, _STOP) Migraton thread schedules cleanup bottom half and exits =20 Live migration resume path @@ -136,7 +128,7 @@ Live migration resume path :: =20 Incoming migration calls .load_setup for each device - (RESTORE_VM, _ACTIVE, _STOPPED) + (RESTORE_VM, _ACTIVE, _STOP) | For each device, .load_state is called for that device section data (RESTORE_VM, _ACTIVE, _RESUMING) --=20 2.26.3