From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449078; cv=none; d=zohomail.com; s=zohoarc; b=eMYVtkf/3WVDbnHymPOkuGY7Wi8OYjG+TYX3pWikwT3HjeWWsV473fG15d+K5PBtb2r9MbFq5Je65eLm2l4uKTTHe1sfXjwVZfq84TC2PjpCyiss9/8fx+CWS7sKz7890pOHde8AlddzIVy2LjLAc+e6vQoF2LLdmFIgLj2z/8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449078; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9x2xBqXLvD3TD22ZGiq+KsjrIorcQc7dSOkJFfUH7FU=; b=bgd9O6sZhkKdsDV7w7zrCovePx9npowMEXg3hanwFJF9jrrHinhxEWSjoM8z4nEwWVFUSaJeQDJmMu8xsy/rR/oe15CNLgwoJREglEjeDhzzN1WyLcPVUsZEkycLLXAS8b31BAO1rDwasvR/SyE9l0ojJPB0STIH8A6NYwXxVWU= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449078848252.32860852017882; Tue, 14 Oct 2025 06:37:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fDU-0004rB-F6; Tue, 14 Oct 2025 09:37:31 -0400 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 1v8fDS-0004pd-Au for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fDP-0000xq-Ot for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:25 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-639-_X79uieCOlKeeGGDtZD6NA-1; Tue, 14 Oct 2025 09:37:17 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3ed9557f976so5770357f8f.3 for ; Tue, 14 Oct 2025 06:37:17 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e13b6sm23800764f8f.44.2025.10.14.06.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9x2xBqXLvD3TD22ZGiq+KsjrIorcQc7dSOkJFfUH7FU=; b=V6YgnszRMFTJ4Pw7jTzQeR9LRaJ2tKDlEDkytUKnsHr9ecgQ6wz4xccP5OR7bjAK6Bn/41 PWbKz63YKdypaNwwJAEifJ7V9HRh8deYndB7N8WqUyOsxXw2ZgRFMy304bCqpRydYlKmyW zR1Q/nfi0RRzViKHT6gXWKZIIRc8NIU= X-MC-Unique: _X79uieCOlKeeGGDtZD6NA-1 X-Mimecast-MFC-AGG-ID: _X79uieCOlKeeGGDtZD6NA_1760449036 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449035; x=1761053835; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9x2xBqXLvD3TD22ZGiq+KsjrIorcQc7dSOkJFfUH7FU=; b=Ncb3yCS4oUBvwxRehcfXiBfoZHC2wa3ToOWpSXI4PvYsP/AnR4wgqFuZmFJOVm36j2 Sfmhtzf9DP5+wznvpjKqBnsnYIlksiniLDsD+HjsVdL4CRFSERKJmGGCrGetyflfvUpw 8rkG2Rp04fdbiy6L1LtZ/hlAjWe1wx/zhcWllzo+meZvkUZ56pf+hPjzNI37mHDgjVHb 8tIzKPWxvClDROh4tQlt427SEslkbIiETH5zHxdz511Ovnt8xZQCuvML0IRXVTnJ9/We 4NglE6mxYw2hHkbwgp746+JqX9JcYAcR5A6YY7nxl35TE16hx2+1dsOd2eY0Uc9iL2Aa NmSg== X-Gm-Message-State: AOJu0YwWqEUPt3HLdxcM5wLfIbQ6lNMxhMuypNEMyVnWLO8z9od4GZ77 J8ySqAUQGb7xq/ll4xo/1qk4UrEVaAtWxQLLw4yIvPs2hfddCnYJFZJZdwPBVgL19xxMDc91AOc b/0wsgA9MsCBNHKDnOMY8eTCXe5pcVbxYzVWxlc5AC9WeZnsCuERgLAuRO5xWZwJS5x3j9G7mYV 7Be+MfgsqPxC5YjyVpiY/60QsyU2RSmrBm9qt5pI26 X-Gm-Gg: ASbGncvy/W4VP+nZMDbsaXxhnFL42+hwRPC5e/EzTfVEjNdHAFXQBhG557oqxPnF7oc TycIKSMxFVI/2qakoJC1mdcZWDzDwXxR9HR2imTXqKcWQmUVwjJqFBqnvci2PcQZqyklnI8aI0o pYhf/ovOQBngPoZu0Fn8YeS8U+iuNr2yXfYHi3iziEfn4FUjpZ/7OuNG6IbXw9DXmsMbtokFIAA B1GZIhc4ryD9TuUJBQeEtRehCMCmp9KFmjfwW+tLvQ4MITnG9BNvL34XOaFvLLSPdx4FAHOZJfY wsPkcblQSw3Ne5Qk1xZKasJ2rki86XMSUMSwYiY0cd3XE20xfvfyLrzwacgFZjfn1zgh4it+sXH fBhD8YO2X3NBbi+7tK/kteK2Adc7mEp1uA2Cs1uWDU70= X-Received: by 2002:a5d:5c8a:0:b0:3e0:2a95:dc90 with SMTP id ffacd0b85a97d-4266e7e1438mr16446142f8f.35.1760449035054; Tue, 14 Oct 2025 06:37:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+DOgeWJPw+2zO4YmZJy5Tyw9ra26azI7iTBQiCuOjeJpkADdEmJuSgZijPwN/VzK1XguE5A== X-Received: by 2002:a5d:5c8a:0:b0:3e0:2a95:dc90 with SMTP id ffacd0b85a97d-4266e7e1438mr16446123f8f.35.1760449034584; Tue, 14 Oct 2025 06:37:14 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 01/28] rust: pl011: fix warning with new clippy Date: Tue, 14 Oct 2025 15:36:46 +0200 Message-ID: <20251014133713.1103695-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449085355158500 Content-Type: text/plain; charset="utf-8" Newer versions of clippy are able to see that all the variants in the PL011 word length enum end with "Bits", and complain about it. Allow it. Reported-by: Richard Henderson Signed-off-by: Paolo Bonzini --- rust/hw/char/pl011/src/registers.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/hw/char/pl011/src/registers.rs b/rust/hw/char/pl011/src/r= egisters.rs index 0c3a4d7d214..fa572811b29 100644 --- a/rust/hw/char/pl011/src/registers.rs +++ b/rust/hw/char/pl011/src/registers.rs @@ -255,6 +255,7 @@ pub enum Mode { =20 #[bitsize(2)] #[derive(Clone, Copy, Debug, Eq, FromBits, PartialEq)] +#[allow(clippy::enum_variant_names)] /// `WLEN` Word length, field of [Line Control register](LineControl). /// /// These bits indicate the number of data bits transmitted or received in= a --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449133; cv=none; d=zohomail.com; s=zohoarc; b=iLbzj7bqurFy9/BC/POLyxt9vUX6uQi32DGVtv9IzC0JEMDAhAHqRinkT0+wok+nybLwPksFjCP2gg2EmBH0VkJthT4/yExTzDy5m7T4TaWnx16ixyzzFyp8D3KjXdy2vSQi1huZYRa2PA7Y+7DsEgoVVi6MG2YpIT/bYFb5HcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449133; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mS+v14KcHsr+muZI98IFf3wSVAEOdlp3uBgp4JAsLiM=; b=CFONoLJbclP7RPjIxDvOGg7Li8K3HWXHXrIOt27gR30mVjlvWhSBSJAG28kyLAkhgKH4f85n/wuKICrhk/QV1whV0QGYfzNZFOEJ2HVMpKfZrQrgGZ+ZWrM8Z0L7M86J6SqG4BLDefR1UfcMQwc9WQ6ei5HD0+m0kFZjyXuc//0= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449133626880.8597469430534; Tue, 14 Oct 2025 06:38:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fDb-00052l-0p; Tue, 14 Oct 2025 09:37:35 -0400 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 1v8fDT-0004qC-GL for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fDP-0000xu-Pz for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:26 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-15-wbeHQ7O4PLyLPemlWDktQA-1; Tue, 14 Oct 2025 09:37:19 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e3e177893so38373125e9.2 for ; Tue, 14 Oct 2025 06:37:19 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce57d404sm23972223f8f.3.2025.10.14.06.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449041; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mS+v14KcHsr+muZI98IFf3wSVAEOdlp3uBgp4JAsLiM=; b=TT71WzleJ8mDxJuiHt48CluDwg31HiUjIa99oAHruVoNntaoioKzd9IsDRQj4+IMBR+rYt LZs8HtQMlDxPLTj1PTmRc8L8z4wcn17kqETBkEbmKX86RQ+jNHDTH8tWM1sc688axo/WUA VWuXM+6psd4swcOGU6TgquRkQ74sZKI= X-MC-Unique: wbeHQ7O4PLyLPemlWDktQA-1 X-Mimecast-MFC-AGG-ID: wbeHQ7O4PLyLPemlWDktQA_1760449039 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449038; x=1761053838; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mS+v14KcHsr+muZI98IFf3wSVAEOdlp3uBgp4JAsLiM=; b=N80AgnKDeUMXjdglHWWn5xm7KqPN6atX9oqGEsvnWH2WflIRrs9cmW/lDOmLLRAfog K3KBZn8GsPM9mMceldY/XivhWh2d7iLKoAPulR3/o3OWbn0ArSG+35UcH72JoZMC7HOJ IF0HXVAsny/FE4q9IEYLMn/WxnKovkW8f2zUZtx9FPRT/4m0M+kgT9dGqQPo4UyeePD0 wdfOL8PQF1OyR6Qdf7nZWr7TItL4CzJTMn4253+/GMjvcZ6NRCPm/4+F4K9CO0RzM0Q0 L8gtmGXXvMpcw/59ZtJt6S3skCuStZStwgCAgiLe6Tc4/Q3VGLJx2zXwtZ8K9rXFanYc +NoQ== X-Gm-Message-State: AOJu0YweJyicVWKFhgcitr/UDB4YsasDktxAgDiYR0GjrZugb1vNMQ9X Aa4xFA1R0IwYRslQjiGNJ4Y+fZ2/jZspAiZtBQXZnDDaiKD1deyCAlqQi2miFRNF92tlvEoP7Bt 30Of0ntSJhC/HO4bhS563wXExtWvmTa6C7MWrqCtoofT2v1WA1ZRxpI34GDpVUeEDuguXL6srq8 wBM1jBgsbBUlE2hEM8GLDe9SbHqAVQrglargWQMTsq X-Gm-Gg: ASbGnctj7Xk9Ni8h7GcvQ2acItht8os+Pn07cxXxz/s/JKDjvUstWB/diDoj0AgkB9x ic8V+4bndlUC6qUcE4e4Dk5uHjkZziDAPG7GFvkTTpgxbTDmiQFqJEnG8i85mtFi5BI3j+0xSx+ xCC8r84pqeOh7MtOeeL/dlYwx0H9GwQrqchA5hj9XaeAXoF5GctosawrMV1rxLBv9UqkEJpCPQD IlIYZgINnNfrTRpjX2uajqKnh56o5wnxFwSNMhok6ayinh3Bgq8hMH1mfabVR3dlJxvixpCSDW2 Rl5PPFvjMoeqVI7I36JdJiPYdVIjruqb/EZIB1Ct2L1ZwC1aoDoUE+eUhzXHSKNpwD1r1uZ8Swf qPtYPMVbpJjN3iI3nHJxNnzt044UsZUjbBnrLZApRtaE= X-Received: by 2002:a05:600c:c08f:b0:46f:b327:ecfb with SMTP id 5b1f17b1804b1-46fb327ef42mr98968325e9.9.1760449037698; Tue, 14 Oct 2025 06:37:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOzzYvEZNYIU+xDwcqH4jE17d+dcWVQh5lXMnUdRGNsOdgt6Ri/yG9FfVWWzg0+3PwgCnDLQ== X-Received: by 2002:a05:600c:c08f:b0:46f:b327:ecfb with SMTP id 5b1f17b1804b1-46fb327ef42mr98968095e9.9.1760449037187; Tue, 14 Oct 2025 06:37:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Manos Pitsidianakis Subject: [PULL 02/28] rust: bits: disable double_parens check Date: Tue, 14 Oct 2025 15:36:47 +0200 Message-ID: <20251014133713.1103695-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449135129154100 Content-Type: text/plain; charset="utf-8" It is showing in the output of the bits! macro when using the nightly toolchain, though it's not clear if it is intentional or a bug. Shut it up for now. Link: https://github.com/rust-lang/rust-clippy/issues/15852 Reported-by: Richard Henderson Suggested-by: Manos Pitsidianakis Signed-off-by: Paolo Bonzini Link: https://lore.kernel.org/r/20251010145756.787800-1-pbonzini@redhat.com Signed-off-by: Paolo Bonzini --- rust/qemu-macros/src/lib.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rust/qemu-macros/src/lib.rs b/rust/qemu-macros/src/lib.rs index 3e21b67b471..3bf315c4c0a 100644 --- a/rust/qemu-macros/src/lib.rs +++ b/rust/qemu-macros/src/lib.rs @@ -401,7 +401,14 @@ pub fn bits_const_internal(ts: TokenStream) -> TokenSt= ream { let ts =3D proc_macro2::TokenStream::from(ts); let mut it =3D ts.into_iter(); =20 - BitsConstInternal::parse(&mut it) - .unwrap_or_else(syn::Error::into_compile_error) - .into() + let out =3D BitsConstInternal::parse(&mut it).unwrap_or_else(syn::Erro= r::into_compile_error); + + // https://github.com/rust-lang/rust-clippy/issues/15852 + quote! { + { + #[allow(clippy::double_parens)] + #out + } + } + .into() } --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449154; cv=none; d=zohomail.com; s=zohoarc; b=IMHW18FAXNOFPgiQSf2MjwvNOnd9Ngmd1krcrQ+y/lQO6aGiFFfWZ1U+0o/GHbnKptxyOyBm5jVpKfE03VZr7ygnpkwlNCgdojBSg1NR5ar646+GQECe+WSW2ANZH6zxBMwDJTMab3n+kVI/hn0ODFf3MCXR2MrJ91uFlkHZjHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449154; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cqzK4xMOj6Z3D/xSJ9Ykj+zTwkBuUmwR3JfwFDRx8Yw=; b=b+ENjehLJPWA9mAD7u86kknbRh/YOwLnAMNnnV3JiF6AuyoKb2z31yhP59wNf5ZHVdz8TT+1Z6INU2aTkQroar3A8U/jHnTHaArWIaUmA7Zo5CtabdR9hCyMnVLnM6T3NMeYYFreBaRQ6FT/Jbvcqaa7/gOFrtK+/zdFbB0gt50= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176044915427562.58286913428083; Tue, 14 Oct 2025 06:39:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fDY-0004w3-Fw; Tue, 14 Oct 2025 09:37:33 -0400 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 1v8fDU-0004qy-6S for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fDS-0000y4-4U for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:27 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-6p1dHaMxOsWt7fZaGW_4JA-1; Tue, 14 Oct 2025 09:37:22 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-401dbafbcfaso4319905f8f.1 for ; Tue, 14 Oct 2025 06:37:22 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5cf6b4sm23838242f8f.25.2025.10.14.06.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cqzK4xMOj6Z3D/xSJ9Ykj+zTwkBuUmwR3JfwFDRx8Yw=; b=Z3SLEOWON4QFtTixQ6ZPo/NXRlXeSHhrum4PF9XtxyADitWJZwRnodoEaoeCT2rNhDLvHh fVahObKur8x/kKZ80y9PauYEB37Om8FZSr6np9EuQd8j9LAThDxkLWwY1aOYMEOPhE8LUY m06t8xJvsrA7JorWQdLwwFoiArVUYUM= X-MC-Unique: 6p1dHaMxOsWt7fZaGW_4JA-1 X-Mimecast-MFC-AGG-ID: 6p1dHaMxOsWt7fZaGW_4JA_1760449041 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449040; x=1761053840; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cqzK4xMOj6Z3D/xSJ9Ykj+zTwkBuUmwR3JfwFDRx8Yw=; b=YQt4LLhOy6mZXOdh264zenTPIlv/F4vJgxd/DygPVtcI7HEMzX/t/YIkqkb5VrEXf/ 7optiKcLIXlweZNAEFQpUmstoKMwOFRusdRtWhN0uuYteikeGTYRg+sti7csDqag0kUs Z1VnAfnMSXf09522wGRFnVRXRWFRAiDQrqBxbw31XbIvBthed2l21L7TOHp7+Ym8WvDH FWGJrCeylN9fjnIHrzY5jgtLRDkF6Y6+PlEKxdsOZQ8ShUp/o60asf4Z5pYUf8kfcL8+ dsWmVySRlZdFL4gVyUdpqDmkbXArNKgtr4cII0AcoPskGbJ26gn4SeN3sVZPD/vkrsRU Osow== X-Gm-Message-State: AOJu0YzQBZvCTnS9Vkvj9F4g65rIWbro50tI+mLdQcPbbQCYVsb9W56y a53f8ES80NGRKSSWKXfAPwN/3i7ceA/CqZn/mgIlCN83pVQ5CMQ3bSbzVT7f57E+y6UnTUPBIXH 6NmdVCQ8xezWxicqx8KIMK0yLV8xBuobQnNi+FLjhwNgB68FYaYhEOgxz3ZCraN0t/hXYMaiFB0 D0XAtaG6yxHYhqnspcCLR6lDTiJH+JzCKOYvzQK3uE X-Gm-Gg: ASbGncujtgr74joUpiubni2ajeVkq4zcXbg/bD/urhTusOGORHF1KOG9Pm35hS5yjIN THKwT9D7LrNWOk4RkNfsvbSIsnJBMCCZkUyl8urDkVX67Hc8LVK33rVoWIMx0bxlbDTv6rzUSBb XMx7KSnDBSq5CCznydTpmMI6uVR7N46FRVwoqtLINtCYXZr7+LizgPD4GEMue2Gp8+w/KvXX50R g6OfjgV63nJZnFLR0F1Ylo1VkWTAqrGHI7o5gIa1SgBGr7QPCvq2Qb07rQ/U4E4CVROdoQzOutB HNJDzUS737/aeLdSGWFgOpMjBGNVeSeAT30oH/O/1F7AophIcHVkW6+IBfS0vP94lJLr0fbG8JJ Fm326K4Std7aLjEEIgZMALNAq+dUvsiFLb9tqru3krGA= X-Received: by 2002:a05:6000:2305:b0:425:7e45:aaa8 with SMTP id ffacd0b85a97d-42667178050mr16077084f8f.19.1760449040306; Tue, 14 Oct 2025 06:37:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzU29JgVkFZ4W8Q1tBLT/IamVpxQegmGCOEfrVnNf9pJSjt0bkMB0AlhOpJxeaQq7KBSafIg== X-Received: by 2002:a05:6000:2305:b0:425:7e45:aaa8 with SMTP id ffacd0b85a97d-42667178050mr16077057f8f.19.1760449039837; Tue, 14 Oct 2025 06:37:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 03/28] rust: migration: hide more warnings from call_func_with_field! Date: Tue, 14 Oct 2025 15:36:48 +0200 Message-ID: <20251014133713.1103695-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449162128158500 Content-Type: text/plain; charset="utf-8" The call_func_with_field! macro uses dead code willingly to infer the appropriate type. This has started adding a new warning: error: unused variable: `value__` 79 | break phantom__(&{ let value__: $typ; value__.$($field).+= }) So shut it up together with the existing unreachable_code warning. Signed-off-by: Paolo Bonzini --- rust/migration/src/vmstate.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index e04b19b3c9f..5f5708ad39e 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -72,6 +72,7 @@ macro_rules! call_func_with_field { ($func:expr, $typ:ty, $($field:tt).+) =3D> { $func(loop { #![allow(unreachable_code)] + #![allow(unused_variables)] const fn phantom__(_: &T) -> ::core::marker::PhantomData= { ::core::marker::PhantomData } // Unreachable code is exempt from checks on uninitialized val= ues. // Use that trick to infer the type of this PhantomData. --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449093; cv=none; d=zohomail.com; s=zohoarc; b=EJnp/FQUZutpKpSdsaQl65U/uchSozhzfDeGGAf5X5NEwY1hScuojhD1+M8URbFrdITV7vRag2rA8QGnuH2KYsBCner6kmSYqxXfnCmYgWRHt/tKVTXHAMRRrOfQsISZJsuwj6YEkcHaglSHjWJqCcSa7vPunS3VUpkPNC/JbV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449093; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BjuuT5ps9Dfi0wcjSzFfW+GOqbh1dg4/Hs0SayeiIrQ=; b=jzdTjB02KbR0T8SYXdCR4SoNAD7MRIkEsc+PhiKZY18Q9ABbGFKOwCHMSWDK6PF8ci7Yep04+TT5KW2jVEnIpSBzngpK1B2KsMrdw2STwDI23Y2NgRYe7tytqs7vkfynoAkhz6u0Seiu7e0gND/vfCb0hYX9ngYgikH/ZAW9hPA= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449093188106.13141802821065; Tue, 14 Oct 2025 06:38:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fDb-00055C-KV; Tue, 14 Oct 2025 09:37:36 -0400 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 1v8fDX-0004rw-3d for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fDT-0000yR-PP for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:30 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-m020g0RuNYeHTRlk2LDHgw-1; Tue, 14 Oct 2025 09:37:24 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e47d14dceso30829595e9.2 for ; Tue, 14 Oct 2025 06:37:24 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ed61d31esm4697479f8f.52.2025.10.14.06.37.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449046; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BjuuT5ps9Dfi0wcjSzFfW+GOqbh1dg4/Hs0SayeiIrQ=; b=GcXlvhnl3Rurz/OqJ1+MRm9JQnzm5ub5l3ugEi9Sz9Dg8Sgjpql9cRwlds7D+jkY4yoc8l WjDUHg8zGhhFFJtNPmoGxTOGfTgbeAlx2gpFiYjVQFXzrp9R5V1M6J3ijthIV1j9b8LEuq aX1/Y95eQ+4NfByJZK+QxO9rWbDWoL8= X-MC-Unique: m020g0RuNYeHTRlk2LDHgw-1 X-Mimecast-MFC-AGG-ID: m020g0RuNYeHTRlk2LDHgw_1760449044 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449042; x=1761053842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BjuuT5ps9Dfi0wcjSzFfW+GOqbh1dg4/Hs0SayeiIrQ=; b=CaPoKkpYAPs8ot1orJk49uaHxQNFUYJfqTwFkclp55O3XycVs6MFiNAvy++tVaCer0 wRW04n4fUc5z1XpFKRiL3FIIVXAf0JJmmq6WrnQnD38x8OQWHSZFEeYwlBdQMFM8j0SI VokQB2w63YhgTtw50DS0nDchqvVwmrFv6RfUpz0hAr604u541YzmFFAMUOoDvNJuUBsv xl39HomaLhzIyC6We8z4Ml5YBByUKCPYmM/gniajMrH27ietbFZ2j0vmlTQOR1EZZ7xB vJuhnZ1H2F+/AcAetfA9IfZFZCoC+KJGWyX2qH05Zq/FlGCvYMI+OBM2YZj/TQr+XsbO EhsA== X-Gm-Message-State: AOJu0YwDy13orWeMqhcO2b3La3NSXoqk2WZhlAWuuBVH7/0CSCumyvAl tubVfyt1tdOHREejgDsXChILn6ive4yFVQkc9WVA65F1JN7FJRZCBGQIzuSI66CPCriOGERq9DK Rjokw+jnVS+kpus5YLw57SwRhv1i/LzX+3CjjnjDQM8ji4YghoZzlVNQD6wfMgTr23Z+vQVYVo1 9fkzn5pn7rQss1W7umb9NMPRn5Xh0/W0tto8Kwhb2M X-Gm-Gg: ASbGncsAtdNWBOL2U65SetLqHw4rG7Eyjt6oS7Unub/MemZVfSyn+TEFmr7Poa+uBJH aWFcjxC2ziWWkT6gWfQv/ImN4N2x31mKo2bUOQ/bkHH89Bo41hj30/8O1Gowt7qKIhw0SVqjsWF LSfXAwg9v4S9/KlZJxU97aIF2B3AG2h5MTCJdtFqdyjyMnkQB3nFVS46qig/mqvUTpyp9CL812h PQrBQdTnButYYtbv4o/6f6hX7KZWoikKsgrkoDB1lDROe2nsm2YysFcCnHPPe7hpNxVRvs2GK8M ev0esvxKyjxL3wbHmWzt/51wrGq7abPeWKRGtTdSvVAS7Slp4I1FrX1s/g1iR6pkK+iCXk4ozYf wGbrdElRKTVW+cOyH+wjKyFStO1Gb0Z6Jp88tFH00btI= X-Received: by 2002:a05:600c:6487:b0:46e:39e1:fc27 with SMTP id 5b1f17b1804b1-46fa9a8f0cemr160858255e9.5.1760449042458; Tue, 14 Oct 2025 06:37:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGz9AQzpHhBkTuqISA71C/vLz0QatAKj7rneETun4Wd4LAeAmU2VW/RUC3bf8fCj5r+f9ysxQ== X-Received: by 2002:a05:600c:6487:b0:46e:39e1:fc27 with SMTP id 5b1f17b1804b1-46fa9a8f0cemr160858095e9.5.1760449042048; Tue, 14 Oct 2025 06:37:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Zhao Liu Subject: [PULL 04/28] rust: hpet: fix fw_cfg handling Date: Tue, 14 Oct 2025 15:36:49 +0200 Message-ID: <20251014133713.1103695-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449107556158500 Content-Type: text/plain; charset="utf-8" HPET ids for fw_cfg are not assigned correctly, because there is a read but no write. This is caught by nightly Rust as an unused-assignments warning, so fix it. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/hw/timer/hpet/src/fw_cfg.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/hw/timer/hpet/src/fw_cfg.rs b/rust/hw/timer/hpet/src/fw_c= fg.rs index e569b57b93b..bb4ea8909ad 100644 --- a/rust/hw/timer/hpet/src/fw_cfg.rs +++ b/rust/hw/timer/hpet/src/fw_cfg.rs @@ -40,7 +40,7 @@ pub(crate) fn assign_hpet_id() -> Result { assert!(bql::is_locked()); // SAFETY: all accesses go through these methods, which guarantee // that the accesses are protected by the BQL. - let mut fw_cfg =3D unsafe { *addr_of_mut!(hpet_fw_cfg) }; + let fw_cfg =3D unsafe { &mut *addr_of_mut!(hpet_fw_cfg) }; =20 if fw_cfg.count =3D=3D u8::MAX { // first instance @@ -60,7 +60,7 @@ pub(crate) fn update_hpet_cfg(hpet_id: usize, timer_block= _id: u32, address: u64) assert!(bql::is_locked()); // SAFETY: all accesses go through these methods, which guarantee // that the accesses are protected by the BQL. - let mut fw_cfg =3D unsafe { *addr_of_mut!(hpet_fw_cfg) }; + let fw_cfg =3D unsafe { &mut *addr_of_mut!(hpet_fw_cfg) }; =20 fw_cfg.hpet[hpet_id].event_timer_block_id =3D timer_block_id; fw_cfg.hpet[hpet_id].address =3D address; --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449394; cv=none; d=zohomail.com; s=zohoarc; b=bJCJXS+VJHoDmr04/aFEZvcXdwLc4iPq77v0ffcpTxhqF643KoCPJVSa5VoiHMnkg8TkGYagHH0JYo6oDk2Soq66/awkHj0viGFF6cpcMgsNh7nWFEmiS0Zo2JX+2gKThjzqwZszEqbwXm+cU/GIPvw6PsQHTu4uc8Ni1wIgoLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449394; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2dTSUgN6s0KeJhRecE9yb8BWINQmHI2btxAHd/ryNlM=; b=EmGKqrxP/7YXrqqiUc8rclpyBt3P18bh32Ky7e+z5X6JTAMmgLKiID0BLEHmx6PaFXXKMmjJv5fLSNMYptOCGzCKdivcAqetEliOrZvV4z9N8TTFmyY+zJHCDUYu18PnHvC9rhJ6ZQBghSUVIz/Qy/o1O1voaToJaxaDsjX1y/0= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449394202674.325739174938; Tue, 14 Oct 2025 06:43:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fDd-0005B2-A5; Tue, 14 Oct 2025 09:37:37 -0400 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 1v8fDa-00053V-B3 for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fDX-0000yq-Ek for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:34 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-ZAe6Z7VxO-uXwqy_FRKljw-1; Tue, 14 Oct 2025 09:37:27 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3f3c118cbb3so5322091f8f.3 for ; Tue, 14 Oct 2025 06:37:26 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e10e8sm23711721f8f.39.2025.10.14.06.37.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2dTSUgN6s0KeJhRecE9yb8BWINQmHI2btxAHd/ryNlM=; b=CWoGHdZOGP9PvznGNpBNzeLhXEMsR8dAW2/F63ltmxLkND4SR7F1QdOhdz3bTvIYx/3H/3 foexSgHotbOBycHWQC1X/YINAZ8KqkBYFVavuZ6yAkCHfCNPDzjeMTtkCkUB6j6U2q2nVc JkiFk4j1BwIdmeBJkunSKX40gyZI3+g= X-MC-Unique: ZAe6Z7VxO-uXwqy_FRKljw-1 X-Mimecast-MFC-AGG-ID: ZAe6Z7VxO-uXwqy_FRKljw_1760449046 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449045; x=1761053845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2dTSUgN6s0KeJhRecE9yb8BWINQmHI2btxAHd/ryNlM=; b=ELedXJUWTCU44wojWtkzTJZaSYQuz+PSUHkbSEtMiX/qU2AKRD5vf0P3uReQLFbNy2 4c3WIJMnIZxY3dhAk5nmCU//XuqcWbXhTCjeWmlv5Oz2gwWiwMYX7SmKMmltrfhEI2NV DnXflo5p3h/9AyiUf12uLtBcEqg0jAV7LBoK58s6sQmTCZYzTbQwPQ38NEHuwuo5xjAe 1cUw3eJxMCjtTaUmWoI9Kj3jFxl64/G/OmCwTaBOaYFMi1n5BPIHhnjFvWwszLYOsLXu Bcn6KWF+YdrXC/jZfjEBFhd2xmBIfaMyv3Y7lVRwovFnqyiaClhNpDcrWyGihHD+62ao pVZg== X-Gm-Message-State: AOJu0YyM1WDY+V8Z2YuKoNDDOLv/0z4UC5eUyzh17Bb7OK79WVQCpJgI 8WkRWmJkKZMmd7oTFEYy+j7ES04iEm3r2bXx+cTFOu1+l/zBP4zBrx0CW8/9qBV28tMewd1ECdC oWF1bLfOnA+iSPzHw1qLGXb7rmEM77r3hZB2mn/vNnM53eD+yD3HQsdV7BkdR01EPvEtBQP1BL0 pyGPMkC0QGWzrr4kUo/zdAIzTk/c0y0Wc3eexsDnfy X-Gm-Gg: ASbGnct4N3Ilbj8XUSHb4s6OdU+uBuItGFQLUbJGiVnzoXfBZibGtVmqDHCUcDtrPrM BMugMUq2GjKjqOa1bb32/fzqxQ1QG+0c+MNUcryg3AoIiVf5bVVD5xi0IBysb/jAbUMmisP0g1o 9Ftq0l4JA4ZogKP+a74ZFowyrvWTzKmejYbjEbOaEiwrcsWC74+7nqPGQh/PCyWaerc108qSG4Z 8Uq5hNd2v+karpkvFu9TXF19byfGZptty1IF8lgsdMcBYucQLDkAVWuGa8QzW2gdhzb18YJ8fMg rHELElDD+tTPRFMe8dV16fO1NuX1RDMJKiauuJn2qep2O3PIQLa7gX/kS4XKcZyj5H+/pQvVOBR vMpNs2neZtSkT+X4Qb7c56wbmkzKWojaTAzyGnF4E4cc= X-Received: by 2002:a05:6000:4301:b0:3d8:3eca:a978 with SMTP id ffacd0b85a97d-4266726d56emr13886053f8f.21.1760449045309; Tue, 14 Oct 2025 06:37:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0SVpkY2U+zhsIzEUgJ96Q+xlYML5tmtcgU3ycYAC2h/ax0YTcD4wgsXLc+v+AV67Yl718Bg== X-Received: by 2002:a05:6000:4301:b0:3d8:3eca:a978 with SMTP id ffacd0b85a97d-4266726d56emr13886035f8f.21.1760449044869; Tue, 14 Oct 2025 06:37:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Babu Moger , "Borislav Petkov (AMD)" , Xiaoyao Li , Zhao Liu Subject: [PULL 05/28] target/i386: Add TSA attack variants TSA-SQ and TSA-L1 Date: Tue, 14 Oct 2025 15:36:50 +0200 Message-ID: <20251014133713.1103695-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449396321154100 Content-Type: text/plain; charset="utf-8" From: Babu Moger Transient Scheduler Attacks (TSA) are new speculative side channel attacks related to the execution timing of instructions under specific microarchitectural conditions. In some cases, an attacker may be able to use this timing information to infer data from other contexts, resulting in information leakage. AMD has identified two sub-variants two variants of TSA. CPUID Fn8000_0021 ECX[1] (TSA_SQ_NO). If this bit is 1, the CPU is not vulnerable to TSA-SQ. CPUID Fn8000_0021 ECX[2] (TSA_L1_NO). If this bit is 1, the CPU is not vulnerable to TSA-L1. Add the new feature word FEAT_8000_0021_ECX and corresponding bits to detect TSA variants. Link: https://www.amd.com/content/dam/amd/en/documents/resources/bulletin/t= echnical-guidance-for-mitigating-transient-scheduler-attacks.pdf Co-developed-by: Borislav Petkov (AMD) Signed-off-by: Borislav Petkov (AMD) Signed-off-by: Babu Moger Reviewed-by: Xiaoyao Li Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini Link: https://lore.kernel.org/r/12881b2c03fa351316057ddc5f39c011074b4549.17= 52176771.git.babu.moger@amd.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 6 ++++++ target/i386/cpu.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 8b7c173838e..f74f13534e7 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -643,6 +643,7 @@ typedef enum FeatureWord { FEAT_8000_0008_EBX, /* CPUID[8000_0008].EBX */ FEAT_8000_0021_EAX, /* CPUID[8000_0021].EAX */ FEAT_8000_0021_EBX, /* CPUID[8000_0021].EBX */ + FEAT_8000_0021_ECX, /* CPUID[8000_0021].ECX */ FEAT_8000_0022_EAX, /* CPUID[8000_0022].EAX */ FEAT_C000_0001_EDX, /* CPUID[C000_0001].EDX */ FEAT_KVM, /* CPUID[4000_0001].EAX (KVM_CPUID_FEATURES) */ @@ -1126,6 +1127,11 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *= cpu, FeatureWord w); */ #define CPUID_8000_0021_EBX_RAPSIZE (8U << 16) =20 +/* CPU is not vulnerable TSA SA-SQ attack */ +#define CPUID_8000_0021_ECX_TSA_SQ_NO (1U << 1) +/* CPU is not vulnerable TSA SA-L1 attack */ +#define CPUID_8000_0021_ECX_TSA_L1_NO (1U << 2) + /* Performance Monitoring Version 2 */ #define CPUID_8000_0022_EAX_PERFMON_V2 (1U << 0) =20 diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ab18de894e4..339881b40f8 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1415,6 +1415,22 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D= { .tcg_features =3D 0, .unmigratable_flags =3D 0, }, + [FEAT_8000_0021_ECX] =3D { + .type =3D CPUID_FEATURE_WORD, + .feat_names =3D { + NULL, "tsa-sq-no", "tsa-l1-no", NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + }, + .cpuid =3D { .eax =3D 0x80000021, .reg =3D R_ECX, }, + .tcg_features =3D 0, + .unmigratable_flags =3D 0, + }, [FEAT_8000_0022_EAX] =3D { .type =3D CPUID_FEATURE_WORD, .feat_names =3D { @@ -8526,6 +8542,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, *eax =3D *ebx =3D *ecx =3D *edx =3D 0; *eax =3D env->features[FEAT_8000_0021_EAX]; *ebx =3D env->features[FEAT_8000_0021_EBX]; + *ecx =3D env->features[FEAT_8000_0021_ECX]; break; case 0x80000022: *eax =3D *ebx =3D *ecx =3D *edx =3D 0; --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449136; cv=none; d=zohomail.com; s=zohoarc; b=K2j7AZpM7ivurIhODULXGXDHBEsU2N4ySh3pxpUatGKJyd5/gfG3a9kKXJmpdeUv3s4+KCzBdRGjzCTVK5h4dfVB/tFCdKGoeVAs+JD1W5HUqYTK5q8mT1YGjIMqPv+Hu5V75ydfylTLq7RRBSi+N4QzsOyFWfkdht/r99/mgic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449136; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uB1cEppwLCqDji7ECAgcmqsbb83VNwGMahtfkyO/muU=; b=SsiSwvJ9w3M5KWyaSWdPRB4uFKW/MCDwgLo6bIGpqkyseuk4rXS9kYMTBWz2ML9r7HtTtmYjpodEWET8GL7Wj5wx6N/x4mra/LKpEeupnny1h0WlymC4K9eEfqWOl8JD/boU8G/vJ2L7bPotGTQEXL05mK3IU3pPXC4d9Ly4SVM= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176044913604010.070199683776423; Tue, 14 Oct 2025 06:38:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fDk-0005OC-4u; Tue, 14 Oct 2025 09:37:44 -0400 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 1v8fDi-0005NX-VQ for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fDf-00011G-Qy for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:42 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-682-DHyHZyzwOl-FRxo2IexCDQ-1; Tue, 14 Oct 2025 09:37:30 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-46e31191379so39306795e9.3 for ; Tue, 14 Oct 2025 06:37:29 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fb48a60b8sm243488485e9.19.2025.10.14.06.37.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449054; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uB1cEppwLCqDji7ECAgcmqsbb83VNwGMahtfkyO/muU=; b=iZqVEm/B98VA1JvS0sMqw5QW2nEDZ+NbNbtAUs8eqDE3LcSa38/pEYK0Q3a/vFC+ojo2VC Jk/CQeNtNUZmgizNEgcnCJweDopcQ9Xc8o8h/dcRqluC3XYw8DLIh0+nDzveqFrh/RSoHP U8FxHIt23cqtKhW1lN4B3VbdB/LA4yQ= X-MC-Unique: DHyHZyzwOl-FRxo2IexCDQ-1 X-Mimecast-MFC-AGG-ID: DHyHZyzwOl-FRxo2IexCDQ_1760449049 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449048; x=1761053848; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uB1cEppwLCqDji7ECAgcmqsbb83VNwGMahtfkyO/muU=; b=EQa5JnalE/f5Ilw009vz2n0cboEHz0c7NUsr90Nim0N+hVJccPFOeA95+T4Utl1ae9 BdZeES3aXa2gsueXTR1zFxA/jNpDj43r2NJ1yc87XKuJfhV4hjAMMABPViX6Z+jaMgbX mG090Eu27t99xK1NfKKPEcGeq2K/uA+52oTJxdePc+fF+rDOeJ2kpj5BS8yq4urJ9mMO 6IvZdPaJGE9//rV0uYtH8yVaZJEx8ZKn+RKE+qrpoy2YCIxCrII4Z48rvkRw6kUsbr2f h8kcePk7Bd5KBlDb8GwmpzOZ0/bhwpOMDBF1a0OdaB4qwL+x1aNC4cyoTBDukrBmBCB5 COfw== X-Gm-Message-State: AOJu0Yzn69Z/knAw/MWOlEHB4y44//PAsiO3sJDrVzmLf2xsimJvTk2D nod3ecT0HKSiSGEkh7aLtYt6F1AMGgQDntyHCkRP7NSpm+d5teMGnKAMhVSBRHqn6aqvoV3T9Z0 kUhSK9e3by5kq/rbG6wZLG0AnfJ0227xlhLvm2Nd8Ffl+2j6lMszEKfjzXbv0uLGENT9O+DhvQa Wx5dc/3sNb9OnsQZRa73LICAowzKqsuxCK3xLLwClp X-Gm-Gg: ASbGncu/ZcMMP/nHbJ3DDxeSqbLe1/0dSG5XmoE8IRzdkS2bo/0/tCEtVE20dYIKUAD TIajKI7EZhlb9QXM/qpM5uZHHXMuMh7xlqmXw9uepX4EI3rXp2E+we8SVZADcIBYrFT3PckMGHx 9IWLln+20OiwlxOBLmm3GQnT690zblueJB7/E0maPVdKt4ElMyAwgYkqS5qVzZwmImiHuj5mkoU RRrhItFUzSPa345Mdy1k9P/4vhfdwgO6s81nnIVUgo0D7RoZheJjBfHDum+zrG6KpER+EdYbbaV nHc+g630Zqt/+5epmGrb/8Q5JYzF+KqS9RGoK4BOkirV3Ux1yXyOmQSSFTWau5uXYq8OdX01Gjk j9SIvdn1ivLkTFNX2ASuQw6WyMA01hRItvZEjCHkuPqw= X-Received: by 2002:a05:600c:5248:b0:45b:88d6:8ddb with SMTP id 5b1f17b1804b1-46fa9b1968dmr182733005e9.37.1760449047849; Tue, 14 Oct 2025 06:37:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/PLwuDlRs89C2Oasp7RH2ymVPKoR+ghQxTz11/pik7JgNjVryzuNOxLzeq4nGxdsE7JUYqQ== X-Received: by 2002:a05:600c:5248:b0:45b:88d6:8ddb with SMTP id 5b1f17b1804b1-46fa9b1968dmr182732725e9.37.1760449047406; Tue, 14 Oct 2025 06:37:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Babu Moger , "Borislav Petkov (AMD)" , Xiaoyao Li , Zhao Liu Subject: [PULL 06/28] target/i386: Add TSA feature flag verw-clear Date: Tue, 14 Oct 2025 15:36:51 +0200 Message-ID: <20251014133713.1103695-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449150117154100 Content-Type: text/plain; charset="utf-8" From: Babu Moger Transient Scheduler Attacks (TSA) are new speculative side channel attacks related to the execution timing of instructions under specific microarchitectural conditions. In some cases, an attacker may be able to use this timing information to infer data from other contexts, resulting in information leakage CPUID Fn8000_0021 EAX[5] (VERW_CLEAR). If this bit is 1, the memory form of the VERW instruction may be used to help mitigate TSA. Link: https://www.amd.com/content/dam/amd/en/documents/resources/bulletin/t= echnical-guidance-for-mitigating-transient-scheduler-attacks.pdf Co-developed-by: Borislav Petkov (AMD) Signed-off-by: Borislav Petkov (AMD) Signed-off-by: Babu Moger Reviewed-by: Xiaoyao Li Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini Link: https://lore.kernel.org/r/e6362672e3a67a9df661a8f46598335a1a2d2754.17= 52176771.git.babu.moger@amd.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 2 ++ target/i386/cpu.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index f74f13534e7..ce948861a76 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1104,6 +1104,8 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *c= pu, FeatureWord w); #define CPUID_8000_0021_EAX_FS_GS_BASE_NS (1U << 1) /* LFENCE is always serializing */ #define CPUID_8000_0021_EAX_LFENCE_ALWAYS_SERIALIZING (1U << 2) +/* Memory form of VERW mitigates TSA */ +#define CPUID_8000_0021_EAX_VERW_CLEAR (1U << 5) /* Null Selector Clears Base */ #define CPUID_8000_0021_EAX_NULL_SEL_CLR_BASE (1U << 6) /* Automatic IBRS */ diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 339881b40f8..4f99cbc5c0b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1397,7 +1397,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { .type =3D CPUID_FEATURE_WORD, .feat_names =3D { "no-nested-data-bp", "fs-gs-base-ns", "lfence-always-serializi= ng", NULL, - NULL, NULL, "null-sel-clr-base", NULL, + NULL, "verw-clear", "null-sel-clr-base", NULL, "auto-ibrs", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449092; cv=none; d=zohomail.com; s=zohoarc; b=DiiwPidQ8y0P8v+1A7SQDgdxmJ3TJ8V4+CNuf8ERAvh0jBG/k0H71kl4n3qsozKWp0MVPsMgFrdb3ZohW/ACxGLHYA2bi5ilE+ayaU6D036BwWwaDCOlaISr2HtPTP1PXP8MCGH7w2XXj+vAeg7C5Uc3wopPoQTnmpICpyjF+xs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449092; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LfpYXKeThudHsYbBI1p5Y6IAia2GV9M0i2k7RLhVCJc=; b=ZkpKLgSfWTEFxs/HPaVA8ivq5H+VHXePOTCjPuQKFVfS58MMAkbeICaZLBB7wbAxcOTGYYJdtN/Ozy8rpu7hhp4HoZzjRd5gjH9+B5OkK1XWJI59sPpho3cGo0TpdD+64CbcBPFE8urQP01AaGVQRLLOyhw9XDbU+grUkD6FAM4= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449092606182.12748768062022; Tue, 14 Oct 2025 06:38:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fDk-0005OT-Ec; Tue, 14 Oct 2025 09:37:44 -0400 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 1v8fDi-0005NM-Jc for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fDe-00011N-Oo for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:42 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-496-puDYPegMMpCtKHc5abHQOQ-1; Tue, 14 Oct 2025 09:37:32 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-401dbafbcfaso4320099f8f.1 for ; Tue, 14 Oct 2025 06:37:32 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e1024sm23585131f8f.42.2025.10.14.06.37.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449054; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LfpYXKeThudHsYbBI1p5Y6IAia2GV9M0i2k7RLhVCJc=; b=CyAb45UNTc5wZtDKw/K63dGBNgru4Zo641oAmBNXe9GE4XMOLI5yZ/0X+R078WRtvYz0/5 HRvwIKeLvn4JhrqkB34J7wbrE1POvw4SM7OONrfB2tk4jWZ7fXsZfg1fgxIPdcB91/b/e9 th35O1wN6DlfAxcvjYMKqQOBsJhhnHk= X-MC-Unique: puDYPegMMpCtKHc5abHQOQ-1 X-Mimecast-MFC-AGG-ID: puDYPegMMpCtKHc5abHQOQ_1760449052 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449050; x=1761053850; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LfpYXKeThudHsYbBI1p5Y6IAia2GV9M0i2k7RLhVCJc=; b=tPOEwaEYByA7NMm++T7KPTZvm56b+xgluJei96QWZYcSyNWsO2Y/nnUqxaJimy5vTW oqtp0uXo+SQfwxb6rEm+siUaPn0Vm2Ccu9H4m9DbGoJXyUqRPEUnpLEcAuOgyZE/5rsO FBEywyZN8v74euuG2ElEs7CtJbBJ6X9kzSBnW76T1/xxPYfE7Wc/ko3umDi/iuZHzTHA Y3y2dhXrc1ah6yLilof6F8oqHqr+iDprBAQOjt1OZIXZ8+kKbxNQFMZmB1yd9/28oRRG 22zJNomSruqUNF8wEUu63jFTSsQuKVj8e85EJ2LzNLCN8CKoOStKmckkYmSylUPLMfas j3uw== X-Gm-Message-State: AOJu0YxjrCtjEe4PhObc0b9MCpF0mD4UwLUVtZj9rC3lkoiciOtZOAyR 4QHAk2EmI73mnuA/m0OpUbDkoNu5JhKn8k1WIJosk7m82/ARCHgC8PPKQgSEk2rTN165Hx9AWnc op8MimlWxWVumZFZ3epoVPXnQfyPnx8Mk2PgCmvo+9njUpE/nGvLk7EBCo4Xl5my9KWixEbbnVu /u2MOWn9HOikAAHYi1bzO+93HlNTMAwrPAkUJyTBWd X-Gm-Gg: ASbGnctx0JN11ux84IsP6Fm1qRnmvvMXvBp0EkZELF0k3tPNoGgaa4vCsry/Ng+3Ojz sj6uYyohDQTj5Rr4FuNImsSKu3Mkr5UFOv0hRjMaW2Kxy0Bx4cpbdSrAVA8wA0dD2Xjo2mZHMqg cSWWFBC6Q9n5YhApqJTHVQK/Q6u+TMUJO75Usp32ikvxPjhQK99BvhYaUTwkK3BMVDlnVfueFCx X8dS0/i3Fb0J5L15A1ZtFUqeAIv3p3b9stnrReA8y2jQG2RTzrAlIx6TMUEFDfqty+KmJSrpofz CdoZSIKnkZl8aSz7lys5lrJmQscr1dH05r/bQFNwtUPmqf95DM/hnm5SOvgHaIiTpOGq26AteFS 8In6XMT2entRP1aoSMKXy3uG4tcS/GclklXzaSjM310o= X-Received: by 2002:a05:6000:420c:b0:411:f07a:67ff with SMTP id ffacd0b85a97d-4266e8de19dmr17312474f8f.42.1760449050481; Tue, 14 Oct 2025 06:37:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJMXdr4xgukabgdGHaoZnSD9ZlHKVGuhhxfFDtFRQRpo18ts2ch8mbf+0uAit5k5IuiPzbiA== X-Received: by 2002:a05:6000:420c:b0:411:f07a:67ff with SMTP id ffacd0b85a97d-4266e8de19dmr17312443f8f.42.1760449050048; Tue, 14 Oct 2025 06:37:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Mathias Krause , qemu-stable@nongnu.org Subject: [PULL 07/28] target/i386: Fix CR2 handling for non-canonical addresses Date: Tue, 14 Oct 2025 15:36:52 +0200 Message-ID: <20251014133713.1103695-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449094783154100 Content-Type: text/plain; charset="utf-8" From: Mathias Krause Commit 3563362ddfae ("target/i386: Introduce structures for mmu_translate") accidentally modified CR2 for non-canonical address exceptions while these should lead to a #GP / #SS instead -- without changing CR2. Fix that. A KUT test for this was submitted as [1]. [1] https://lore.kernel.org/kvm/20250612141637.131314-1-minipli@grsecurity.= net/ Fixes: 3563362ddfae ("target/i386: Introduce structures for mmu_translate") Signed-off-by: Mathias Krause Link: https://lore.kernel.org/r/20250612142155.132175-1-minipli@grsecurity.= net Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/tcg/system/excp_helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/i386/tcg/system/excp_helper.c b/target/i386/tcg/system/= excp_helper.c index 50040f6fcaf..f622b5d588e 100644 --- a/target/i386/tcg/system/excp_helper.c +++ b/target/i386/tcg/system/excp_helper.c @@ -592,7 +592,8 @@ static bool get_physical_address(CPUX86State *env, vadd= r addr, if (sext !=3D 0 && sext !=3D -1) { *err =3D (TranslateFault){ .exception_index =3D EXCP0D_GPF, - .cr2 =3D addr, + /* non-canonical #GP doesn't change CR2 */ + .cr2 =3D env->cr[2], }; return false; } --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449159; cv=none; d=zohomail.com; s=zohoarc; b=jMSMlHfUu+vYz9Aw9KpRN6mze//5gSp3k44nWzAnNjmQgujqNOEH1T4CKT/q1XRMTGqp6br4dJ6jgRHvK72Hy5XvatjzAJ7/imdYmvvRu0C0EhWG9xs+VmFpCuXPBE0qGeRQMW/HhQok7YUrzRmKCB9XBcCmGdgGVHQR/WY5cTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449159; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Qb+w2Eh2JL0o4/v0hD4mR2Bl33h8FgZ1hMmCI2Aaztc=; b=CNHYPMMire7CNOzjN8DPKdqvfEnf5YRlUYjNu2K7GFjUY1jXwFvd0EtFa7ZZq0jRbZapssrxwbHcUgel41UGYL5eYKh0/0B42Iie0c1htIrJxPeoZKfA+AQLTMmq2pNKPXV56rZDSz3jwfm6Ld+DlWlDSwG7dH6Y72exfNcKX4o= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449159581944.9813978407522; Tue, 14 Oct 2025 06:39:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fDl-0005Oh-7d; Tue, 14 Oct 2025 09:37:45 -0400 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 1v8fDj-0005Nu-ID for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fDf-00011l-66 for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:43 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-449-CuJvJzLeNniH6Eqv7gHZwg-1; Tue, 14 Oct 2025 09:37:35 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e32eb4798so27756055e9.2 for ; Tue, 14 Oct 2025 06:37:35 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fb497af18sm242164095e9.3.2025.10.14.06.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449056; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Qb+w2Eh2JL0o4/v0hD4mR2Bl33h8FgZ1hMmCI2Aaztc=; b=jJl6WveYYP9nrN2rdOJS8KEid1B2k29fUaPn+9cR7s50w8cgyxcuFw6rA4AciLBPLrfceU yDepHWGLx4XCvmBIBBv09LRX7Bt8KaJnVxQ4qFPJi29T95nYS3ad04oDuMxaSk2hEgyBNB XlW2k4Qzm3QzgAOkP50hETqdvrHLTWU= X-MC-Unique: CuJvJzLeNniH6Eqv7gHZwg-1 X-Mimecast-MFC-AGG-ID: CuJvJzLeNniH6Eqv7gHZwg_1760449054 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449053; x=1761053853; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qb+w2Eh2JL0o4/v0hD4mR2Bl33h8FgZ1hMmCI2Aaztc=; b=uEtbjWhrvHKAsbS+9C+4ZfIEzvOOKSDou+/UhY+2vbSpQiaHOzbdgRh8UAzn0RT4Y+ AlwkSbmPNP3lhYVuHt68aQzVQCkhFVb7RgpADFs0XBbzrv79l5DvZUoTgw/vkLL9H7Hw vEmb/ZeDCV/lJI1ger2pxVuaDeIdNeXYQpb+i+BMgXpUc/0Yj8PK5a8qpRDBGHoI3W1V a7siaUcsdtWxtLtSDTK8TfeBKKGaDg4/Sl3PMwE3qKddRThv+bYXtOgysE8NITpKewkU Ijm7J3jIW2uLkaxjMJktvZ778ynHVJwV7KomVRS1+3YqwFFwJTwZKaQ6dHVwLUd/oHg0 ScgA== X-Gm-Message-State: AOJu0YyGAklpjH077zQzaAboOqGX7KKUOcHZpKl2txp6R6hx7yjbYemx BHkJygfRy+Dkshn49ob7V3HwaoVjeANUR3GNuvEj+GpGqMrFi6hRRV9hIjmqHUFi69qjhbWhz5H lrBk1qng1f0HEgVrjCth4a42VbxFyO7KdWST1UTa5ed7btyOkjs1aIquJlbwWOiCKueDD6Qktjj 2LaIFLrysTd0DbdCvV02vHZqQuR4bAPr7KH2rFOIwd X-Gm-Gg: ASbGnctg35qZ4CKFEP1fpt2+PkVQiy1YRVCRAWjGobi8SMy7ayA4xXOwhRIMtIkhNYH wR2xsxUN4youL4IXrPav2e+8Db5lryl6g5yJRPL1LlUJD16Dn9irFVKR9wFzW6i9u7kdGv/SbpS p/0stWhQG38YaLH5PbSLKYMI4DxLywZkLInkrQ8seXB77+yBsWY/MNJVT3qb3iISAVIj9KvhFQe G/6vbdz+IOHwCBCAyhSnIAd2P5AD/+h2zoO/pAMk9wxdV2uUWIkfD0jHnD3BnuxSGsEMP3Sk+Ua BZ/JJqQAybXdqlBdIWGXPTnJ6kOTcJUGp9W8vg6/NM19gCNfEhk6+N7PIHKDCmfelaRt2kb+QBj 5WbSpaYXuG/JwbgB3DBn5Oov/0vb4f6heFUOqgSpTZCA= X-Received: by 2002:a05:600d:416a:b0:46e:3f75:da49 with SMTP id 5b1f17b1804b1-46fa9b11794mr176638365e9.37.1760449053222; Tue, 14 Oct 2025 06:37:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGahZnaCHbiP1ZAhAAulCTNUjphIuxxm7ZG6Z7vq8wAX20/lhsmcyI17LvVpgh6mHqGUJ2oVw== X-Received: by 2002:a05:600d:416a:b0:46e:3f75:da49 with SMTP id 5b1f17b1804b1-46fa9b11794mr176638175e9.37.1760449052742; Tue, 14 Oct 2025 06:37:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Jon Kohler , Pawan Gupta , Sean Christopherson , qemu-stable@nongnu.org Subject: [PULL 08/28] i386/kvm: Expose ARCH_CAP_FB_CLEAR when invulnerable to MDS Date: Tue, 14 Oct 2025 15:36:53 +0200 Message-ID: <20251014133713.1103695-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449184384158500 Content-Type: text/plain; charset="utf-8" From: Jon Kohler Newer Intel hardware (Sapphire Rapids and higher) sets multiple MDS immunity bits in MSR_IA32_ARCH_CAPABILITIES but lacks the hardware-level MSR_ARCH_CAP_FB_CLEAR (bit 17): ARCH_CAP_MDS_NO ARCH_CAP_TAA_NO ARCH_CAP_PSDP_NO ARCH_CAP_FBSDP_NO ARCH_CAP_SBDR_SSDP_NO This prevents VMs with fb-clear=3Don from migrating from older hardware (Cascade Lake, Ice Lake) to newer hardware, limiting live migration capabilities. Note fb-clear was first introduced in v8.1.0 [1]. Expose MSR_ARCH_CAP_FB_CLEAR for MDS-invulnerable systems to enable seamless migration between hardware generations. Note: There is no impact when a guest migrates to newer hardware as the existing bit combinations already mark the host as MMIO-immune and disable FB_CLEAR operations in the kernel (see Linux's arch_cap_mmio_immune() and vmx_update_fb_clear_dis()). See kernel side discussion for [2] for additional context. [1] 22e1094ca82 ("target/i386: add support for FB_CLEAR feature") [2] https://patchwork.kernel.org/project/kvm/patch/20250401044931.793203-1-= jon@nutanix.com/ Cc: Pawan Gupta Suggested-by: Sean Christopherson Signed-off-by: Jon Kohler Link: https://lore.kernel.org/r/20251008202557.4141285-1-jon@nutanix.com Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index db40caa3412..e40e374b046 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -653,6 +653,23 @@ uint64_t kvm_arch_get_supported_msr_feature(KVMState *= s, uint32_t index) must_be_one =3D (uint32_t)value; can_be_one =3D (uint32_t)(value >> 32); return can_be_one & ~must_be_one; + case MSR_IA32_ARCH_CAPABILITIES: + /* + * Special handling for fb-clear bit in ARCH_CAPABILITIES MSR. + * KVM will only report the bit if it is enabled in the host, + * but, for live migration capability purposes, we want to + * expose the bit to the guest even if it is disabled in the + * host, as long as the host itself is not vulnerable to + * the issue that the fb-clear bit is meant to mitigate. + */ + if ((value & MSR_ARCH_CAP_MDS_NO) && + (value & MSR_ARCH_CAP_TAA_NO) && + (value & MSR_ARCH_CAP_SBDR_SSDP_NO) && + (value & MSR_ARCH_CAP_FBSDP_NO) && + (value & MSR_ARCH_CAP_PSDP_NO)) { + value |=3D MSR_ARCH_CAP_FB_CLEAR; + } + return value; =20 default: return value; --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449088; cv=none; d=zohomail.com; s=zohoarc; b=RzLMdoQCLPfArLe0ZCBtjIG4FfciYxMe8C3xvBD5OBhHiIBDrk/NdxIhtBdcLJ4Tv5sNI0J7keJWvISUTUy65Z6A5nXXPgC4vEgl3Dy4VBnDVxbbIZF9b+tjrWpf2wEzzfquxKvis3Yc822lt+V7kofLHqAHaSMwolqetRFmwbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449088; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mcXOtGCJG85v6h4eMGG6AGwj7Or+cs6XO5lrd3qjyfQ=; b=fg1K57ZhA0Ecg5a5/sGT4X3xTD1aotNqnjw2y+htnAN4Xn1dCEbvhallD6j6BSWu0e2XfsdB+g+miM6fXiIVeUYKhazkIh8V7PwgrutmSpSHVoM2/Sdw0NMh2HQsc8ALqJzi7lLN4W7CNeeHcBtZ8x2nGLuEMyLWrL4lTQj5L60= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449088155974.3384145241722; Tue, 14 Oct 2025 06:38:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fDn-0005RE-Mn; Tue, 14 Oct 2025 09:37:47 -0400 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 1v8fDl-0005OX-Mn for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fDh-00012E-8e for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:44 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-440-szmnl48DMgSBxFmrs8FZmg-1; Tue, 14 Oct 2025 09:37:38 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e3dcb36a1so41257335e9.2 for ; Tue, 14 Oct 2025 06:37:38 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fab3d2c1asm153624005e9.1.2025.10.14.06.37.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449059; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mcXOtGCJG85v6h4eMGG6AGwj7Or+cs6XO5lrd3qjyfQ=; b=Ka5W+fmTUGm+XjghkkiHo/QwVLOOkwuFdaE6uZxwRbym8GDLck18QZzzPZN6RzjiUu8dDA EmhOsd5utRYrrYdU5ITcl/19YClKXK6L5Z94SbqF8mo1xTa3g+nSf403aPGhH+vaYvklgV 3pib2vuslSBrFTkP5fpuucCN8W/tmy4= X-MC-Unique: szmnl48DMgSBxFmrs8FZmg-1 X-Mimecast-MFC-AGG-ID: szmnl48DMgSBxFmrs8FZmg_1760449057 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449056; x=1761053856; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mcXOtGCJG85v6h4eMGG6AGwj7Or+cs6XO5lrd3qjyfQ=; b=CQQUW2oCzJ92m5U2SAeB9OgFrUtbp3bJLXsPLIStoIJHPLTHsb3tFPcXQ/oovYIjB4 gmJFWq0qLYbdzmgOzUa+H1dBumnO6jYtLTnGtUvhBuC2Ux6PJf5XjpMH1iDhIvtNuXXc /SL11ZF60ZBBeQ2ijpQDkB9RRXfFH3U3/fiGpbFgyCpYSvt4TPx7JJ5BawaI2AMN5yjN HW5XjH373MKlmYQ6CFd47Aj0owYQEgFytqZLJ1gs/6OfYRkX3GnhCV5KE0sqon/FRFRY Y3EWY9g+eAZgz3u24vPbaeFPTZUrNdQzWZZScbp8WN+iXkphrnG+tvFqPCTVmTowJqrN lRtA== X-Gm-Message-State: AOJu0YwYxE5wOdVK5NeCyLNDMdbrYhuc9Q9xpTPDm/jIRIspPENrj4CT SFDsvJAFotOG65XcmD6YwxirsuT8dh5E3eSaQ8Zuo33l6j21Czk+LO+9atuoyOHu7n80sMioO5z bw77lMuZoNfTJnygkuyg5AK4lnjJskI5YB53NXNoHsPyHxBXhLDJHcE2Mp+gaNwP/FFzOjxcvfJ VrsKto8L9I7Hf9cYoqayokQNYVK905DjlmrX8/BdDB X-Gm-Gg: ASbGncv1FzAYxpBt1UD4rCeypFePWnaprPGswMeDvPvak6uQiihwEXK4E+qrUftGibp fNtju7QQKmmcEwtmIKyQF1xajUzHbLcjJbKBgV/6q5HqBfpAGt0BRvnTt8ho/U2NR7feYjWrius M9vb8kdgJ5tTs1wKr1/3S1bP6tF44nAGV9CIajx6dmGKToCxBFgBEkYL3QxS1n6TYB1hBR5qmto ZfhW7QLzAeTmL/LTXXBMn4iOhpkyQ0DsR0nZnA+H7JN832rJYiH7sGqc4ZSHitdBA4Fry1lQBpj NU3Fo5eY10yqu6SBd6WotMbbqgiAM3Ea5kkf4X3hHL2IXbELLJkPz7CyCSfDd2AkNr7itrAeFUa E7QGt8KbwF4TS8V6a6ZCjciYjgH3a/OKWT7/9VrlmDMU= X-Received: by 2002:a05:600c:1990:b0:46e:1b89:77f1 with SMTP id 5b1f17b1804b1-46fa9aa1c74mr161430125e9.9.1760449056321; Tue, 14 Oct 2025 06:37:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHT6gVzJVpjGdhx2u0HyF0oGE3u9zULzZ+ZaeFhJKibdFmf6I2v4AbpO6pGPx1wkcPX4ifKQQ== X-Received: by 2002:a05:600c:1990:b0:46e:1b89:77f1 with SMTP id 5b1f17b1804b1-46fa9aa1c74mr161429865e9.9.1760449055793; Tue, 14 Oct 2025 06:37:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , YiFei Zhu , qemu-stable@nongnu.org Subject: [PULL 09/28] i386/cpu: Prevent delivering SIPI during SMM in TCG mode Date: Tue, 14 Oct 2025 15:36:54 +0200 Message-ID: <20251014133713.1103695-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449095424158500 Content-Type: text/plain; charset="utf-8" [commit message by YiFei Zhu] A malicious kernel may control the instruction pointer in SMM in a multi-processor VM by sending a sequence of IPIs via APIC: CPU0 CPU1 IPI(CPU1, MODE_INIT) x86_cpu_exec_reset() apic_init_reset() s->wait_for_sipi =3D true IPI(CPU1, MODE_SMI) do_smm_enter() env->hflags |=3D HF_SMM_MASK; IPI(CPU1, MODE_STARTUP, vector) do_cpu_sipi() apic_sipi() /* s->wait_for_sipi check passes */ cpu_x86_load_seg_cache_sipi(vector) A different sequence, SMI INIT SIPI, is also buggy in TCG because INIT is not blocked or latched during SMM. However, it is not vulnerable to an instruction pointer control in the same way because x86_cpu_exec_reset clears env->hflags, exiting SMM. Fixes: a9bad65d2c1f ("target-i386: wake up processors that receive an SMI") Analyzed-by: YiFei Zhu Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- hw/intc/apic.c | 2 -- target/i386/helper.c | 4 ++++ target/i386/tcg/system/seg_helper.c | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/intc/apic.c b/hw/intc/apic.c index 6d7859640c2..c7680338563 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -646,8 +646,6 @@ void apic_sipi(DeviceState *dev) { APICCommonState *s =3D APIC(dev); =20 - cpu_reset_interrupt(CPU(s->cpu), CPU_INTERRUPT_SIPI); - if (!s->wait_for_sipi) return; cpu_x86_load_seg_cache_sipi(s->cpu, s->sipi_vector); diff --git a/target/i386/helper.c b/target/i386/helper.c index 651041ccfa6..72b2e195a31 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -621,6 +621,10 @@ void do_cpu_init(X86CPU *cpu) =20 void do_cpu_sipi(X86CPU *cpu) { + CPUX86State *env =3D &cpu->env; + if (env->hflags & HF_SMM_MASK) { + return; + } apic_sipi(cpu->apic_state); } =20 diff --git a/target/i386/tcg/system/seg_helper.c b/target/i386/tcg/system/s= eg_helper.c index 38072e51d72..8c7856be81e 100644 --- a/target/i386/tcg/system/seg_helper.c +++ b/target/i386/tcg/system/seg_helper.c @@ -182,6 +182,7 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interrupt= _request) apic_poll_irq(cpu->apic_state); break; case CPU_INTERRUPT_SIPI: + cpu_reset_interrupt(cs, CPU_INTERRUPT_SIPI); do_cpu_sipi(cpu); break; case CPU_INTERRUPT_SMI: --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449230; cv=none; d=zohomail.com; s=zohoarc; b=OX/0xeSzKY84cTuSnLx4E5muLDlyUY+ln6ChptxHCQu1iyFcvZk+B+u7S3o7eeoeSGuSXl3bcOYgQEE6Z9wzJhQDu7p5j65fXbA03rql2G/15xXLrrQUf1GOooyrxsx6LKyPcvTUxnxjHcFKZYmc1NucSMGvkKlG7+X4chVhwR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449230; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=e32N7ZSB2saMjOPTEs5cXNXBo4U73cVipS9h91Ip8+Y=; b=imKc0iP7+HyWYg8KfuvXbo+M351VTKdZZbmMymfGoIQzLlCZdrOpUdCOTcZaauObkuyX3XTJ9kEkhP0m9x3216rJ1A3QZGjMCeIPIADDmvx1l5c5fLXKGvPuwoODQzMnIPmKPcmb1dgVXps1ZtbeIV2LAH/QyikuyyWWWlQThm8= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449230748602.2601213617472; Tue, 14 Oct 2025 06:40:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fE3-0005TI-8P; Tue, 14 Oct 2025 09:38:06 -0400 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 1v8fDo-0005Rl-Im for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fDl-00013B-FL for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:48 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-67-oFwZ6s8tOc2Y1EvSzKvKNQ-1; Tue, 14 Oct 2025 09:37:41 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3ee1365964cso5309381f8f.2 for ; Tue, 14 Oct 2025 06:37:41 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e8141sm23553472f8f.48.2025.10.14.06.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449064; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e32N7ZSB2saMjOPTEs5cXNXBo4U73cVipS9h91Ip8+Y=; b=i37sqciaIIBiDMlr1z5RYAKWFzkYATypExdqR8ZHhdjJ95lV+MM0NyYOAheCjAG5b9+L/E KBlggWYsMga6zRRHlwewBRpTLyCqiIZhIFH2TmaLp0Ayy/4zHh4ebaIa2917633vTCyBJn MZ4P2Z0nl0mdXh1O7+gpc0hKDihNrkM= X-MC-Unique: oFwZ6s8tOc2Y1EvSzKvKNQ-1 X-Mimecast-MFC-AGG-ID: oFwZ6s8tOc2Y1EvSzKvKNQ_1760449061 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449059; x=1761053859; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e32N7ZSB2saMjOPTEs5cXNXBo4U73cVipS9h91Ip8+Y=; b=PessiixYZH7s5QJv0+zZfnDOgu0qYFRQlB++wvMU+50TT827p0EAhJrukIOhZo4RAu kSO7VdzdbTbRAduf6JxgUOdzJpzgVUfhjoccM/WbGAvhcAgYuX7JtpA3cjb9EU83j8Bf oOlcIofprwtLVQvEdHJtAdgKQY/MTT/nRx+zuk0kewPAABPA6hvVRtYYlVI3H5SPAZ+1 pFUIpkqKAJxNoZA+8ywYmIE4pMhd6OH2bp2SmfmUwGswV0mY1R/wTEfJqU35AgS0A57Q 2+ydlVqSU/LALa8oFD0UV+04b/ksuhw7SWaDIiaSjwQPa1kF6eM+idzhF2WpySMiN2X7 AjOQ== X-Gm-Message-State: AOJu0YyHW8HCwarAR4Gb/M5C59noTRmwR5VsirK3s8q9LqPZa+oDbOTl MjPM7RXzQGK3Suc8zvqe2W7Dehxp9uwI2iHza58gWZ3VJd+1SMIdSOuNkJR+IqzGfsCxbCBra9g BhE8XtuXi20VqSFY70eWCQkimIyhHgbAqr4wyfxvMvQFs7ltD3dcd1T9IGXEFHqBc2E3cQaYgd2 ce706pnMmBbAl6xJey5VOOwM/wX2ud8/njJsiy1UFs X-Gm-Gg: ASbGncsy2v2UhkgryCRNBT3hal3jM6wmQKZqdt6Ao20A0505AGQYHhKxiWxxxJ67+Qf +HqOXE3tk3tFQC2OEoRqHS6GspGf8qGXyxGNBNZOsNVFrcd++pHRZI53k+dmzXgDB4AoqYwUVsr c9k9lFOJ7x+rg2v1o+NB2r68LtD4eHRJthkQfpsalFT/G8YwenGQ2Pn/VDbcPg6f03dkoYrgdDs /wGhuCkdQta31GXnovEeHMYpAdfgD5gthgz3UeMfenDQss67ithd9FqhCsJTWAjLPyvMohptwKU SUDCzgxAtKGYZVEtDw3lIqe8zrAm/s7uhsYhM74qOJ8POg+9mEFKYB4coaUK8zryzuzLZhcDSLm VCqngEneQPsb65qLzaVsEf3u/1leSMUemexizXRLM1Vo= X-Received: by 2002:a05:6000:430e:b0:3e7:d199:7889 with SMTP id ffacd0b85a97d-4266e7c4ed5mr18807325f8f.27.1760449059399; Tue, 14 Oct 2025 06:37:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEICUlNgOSBk2ILbWFjuCrM2q3JRkIPYPwMDYwrTG2ujJznQy0cE01VFRryWowL5W5l6DKqng== X-Received: by 2002:a05:6000:430e:b0:3e7:d199:7889 with SMTP id ffacd0b85a97d-4266e7c4ed5mr18807300f8f.27.1760449058848; Tue, 14 Oct 2025 06:37:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , YiFei Zhu , unvariant.winter@gmail.com, qemu-stable@nongnu.org Subject: [PULL 10/28] i386/tcg/smm_helper: Properly apply DR values on SMM entry / exit Date: Tue, 14 Oct 2025 15:36:55 +0200 Message-ID: <20251014133713.1103695-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449234982158500 Content-Type: text/plain; charset="utf-8" From: YiFei Zhu do_smm_enter and helper_rsm sets the env->dr, but does not sync the values with cpu_x86_update_dr7. A malicious kernel may control the instruction pointer in SMM by setting a breakpoint on the SMI entry point, and after do_smm_enter cpu->breakpoints contains the stale breakpoint; and because IDT is not reloaded upon SMI entry, the debug exception handler controlled by the malicious kernel is invoked. Fixes: 01df040b5247 ("x86: Debug register emulation (Jan Kiszka)") Reported-by: unvariant.winter@gmail.com Signed-off-by: YiFei Zhu Link: https://lore.kernel.org/r/2bacb9b24e9d337dbe48791aa25d349eb9c52c3a.17= 58794468.git.zhuyifei@google.com Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/tcg/system/smm_helper.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target/i386/tcg/system/smm_helper.c b/target/i386/tcg/system/s= mm_helper.c index 251eb7856ce..fb028a8272f 100644 --- a/target/i386/tcg/system/smm_helper.c +++ b/target/i386/tcg/system/smm_helper.c @@ -168,7 +168,7 @@ void do_smm_enter(X86CPU *cpu) env->cr[0] & ~(CR0_PE_MASK | CR0_EM_MASK | CR0_TS_M= ASK | CR0_PG_MASK)); cpu_x86_update_cr4(env, 0); - env->dr[7] =3D 0x00000400; + helper_set_dr(env, 7, 0x00000400); =20 cpu_x86_load_seg_cache(env, R_CS, (env->smbase >> 4) & 0xffff, env->sm= base, 0xffffffff, @@ -233,8 +233,8 @@ void helper_rsm(CPUX86State *env) env->eip =3D x86_ldq_phys(cs, sm_state + 0x7f78); cpu_load_eflags(env, x86_ldl_phys(cs, sm_state + 0x7f70), ~(CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C | DF_MASK)); - env->dr[6] =3D x86_ldl_phys(cs, sm_state + 0x7f68); - env->dr[7] =3D x86_ldl_phys(cs, sm_state + 0x7f60); + helper_set_dr(env, 6, x86_ldl_phys(cs, sm_state + 0x7f68)); + helper_set_dr(env, 7, x86_ldl_phys(cs, sm_state + 0x7f60)); =20 cpu_x86_update_cr4(env, x86_ldl_phys(cs, sm_state + 0x7f48)); cpu_x86_update_cr3(env, x86_ldq_phys(cs, sm_state + 0x7f50)); @@ -268,8 +268,8 @@ void helper_rsm(CPUX86State *env) env->regs[R_EDX] =3D x86_ldl_phys(cs, sm_state + 0x7fd8); env->regs[R_ECX] =3D x86_ldl_phys(cs, sm_state + 0x7fd4); env->regs[R_EAX] =3D x86_ldl_phys(cs, sm_state + 0x7fd0); - env->dr[6] =3D x86_ldl_phys(cs, sm_state + 0x7fcc); - env->dr[7] =3D x86_ldl_phys(cs, sm_state + 0x7fc8); + helper_set_dr(env, 6, x86_ldl_phys(cs, sm_state + 0x7fcc)); + helper_set_dr(env, 7, x86_ldl_phys(cs, sm_state + 0x7fc8)); =20 env->tr.selector =3D x86_ldl_phys(cs, sm_state + 0x7fc4) & 0xffff; env->tr.base =3D x86_ldl_phys(cs, sm_state + 0x7f64); --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449202; cv=none; d=zohomail.com; s=zohoarc; b=ZArYOXMvDIsF7UCxNBxlUDop6GU8oe89TiQGQJJoJ2rNJn1bxJD9TdnoXJYSDnbMOW8x61e4hfue6WDaT6deSedLU2inBR8sOFmsRj0rmeEFufKm0e4LYCN9kz9GnEsOUcqWHDajhE3N8lsL0BhQ3RkW6lIY5+21Xk7DIMrmNcU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449202; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iA0bDEBxJgjEmhhlL5wXkh2D/VoTpIzJgtkxrAf3WUE=; b=nsV9BCKRGAqKqDGVElTZfJLce41ILNfJk7NFiKNqLr33g7aePBQneWTbB7qazlTehaofEdGnwGR4v3ma6Qg1z+bbnFtzKNbSdryMkrtuDlSxSBQMeuHzKAui4HBkOQXqT3mtJGIA+HMN6jP6jQJ9sHarsO61PzlM4eA9PiboGGA= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449202215877.6005167498025; Tue, 14 Oct 2025 06:40:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEF-0005hX-TA; Tue, 14 Oct 2025 09:38:16 -0400 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 1v8fDr-0005ST-Ku for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fDo-00013U-OC for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:51 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-395-WrITmq4bML-ACdWp-sraoA-1; Tue, 14 Oct 2025 09:37:45 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e3a049abaso38646665e9.0 for ; Tue, 14 Oct 2025 06:37:45 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fb4989601sm236079775e9.9.2025.10.14.06.37.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iA0bDEBxJgjEmhhlL5wXkh2D/VoTpIzJgtkxrAf3WUE=; b=Qn0EQO1Uul0YnKFOM0CzIE/vi/te9/EEHe03D72oOm8kRXaLnBqNTN8vD3Qc8z9mv56Nw5 BNe8ygNqmUy9vKIoNvYPRCOY2eRcK7AE0CDbVYaVmIEvdxjIaYiTaO5NRSg+fsI1MeA0Ui /IELkDUXH5l/OH/OB8LDfG50wfHajCM= X-MC-Unique: WrITmq4bML-ACdWp-sraoA-1 X-Mimecast-MFC-AGG-ID: WrITmq4bML-ACdWp-sraoA_1760449064 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449062; x=1761053862; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iA0bDEBxJgjEmhhlL5wXkh2D/VoTpIzJgtkxrAf3WUE=; b=E/10Y3UclsrTPB48kpKaM6U+1j+f+Rc07Iwp7GtLQAgBo/frm/g4ZfIhmiOEfs8XqM QJfRD4fvOaCemgYbHJuUM80IXJ3SidaNUsk3euXM+yXKCRM/x8w9RTPrjMylTuRnTG3Q 4UEjYx2dWhh1dxR1JfhBIPmi/yPSDFMrbAvxowiOelgbrVEzys++6+/t6FdE3o1WCSEd GN/mvPQ9cLEb63RQzeY5HMW7Dv9omWIgfhHZA/JyiRzC+EhLJTW7C2Frf70HjzrxLe8x eg1+c9pm+hlWb1I0O3UcfqZUfr7UqDQ5rUN1uncr84/LmeFb8BX4X+AFW9WPXYPgPwuk c4Dg== X-Gm-Message-State: AOJu0Yz2wxZydGbnQvqhotGmEiHUvELD+OZfBaBf+qyzkuFYVCOBvQim nMuzmBRk3X2B178WPb753pFXBFaWDr2luoU2pJrD6bQ6EN4XZKB9xZMfTg14iEZ3q31kHWijnaL 7ogfT5mkNU7epgztwVZfm6rKZTtElv+3kFsAgYY2mWxZwEBILs4Lzx8kZmCkdAdxSniDdTFjtzC ihMi4PEx4JNPa1eCBkF74j3SrpKtHGyuO1aQnZED21 X-Gm-Gg: ASbGncu6mZeyAF+Y9CrZkbJ8pfdaujmJ22qZvCnajjSYBwHj5HgyMIztGdjxh+Gumi5 sa4uakdUvY6lr7mvUH5dY7CYbinGa1wV9sut6sbWPFs5ck3aoiIfqRygLdJoVkj+Kqh87lDBR64 UqEPvlgD6tnRwmN+E7ohtmNvN7erjgPD5sxbSqsC+lWNRsS/IMTshkmqotSgg552Oorawo7pvJ/ NC7Cb4IWQOeYNc6OgfhTjk3rURW27Hw/oH8J325UtkFgKV1jF8I0qhOvn4t25GCPbh2Z0UmuVWf VtJv8TDy9Csd0WBqn6PnJszX9ZFLj/7EyoA/hexHvc7Rl6xn5dpb8OHS+TIuf+FmKnVoKvBvD6S VSbJBcdM8nSBikRO2moDUn5O3Lb/Z9BAxzuRFQqkwhIA= X-Received: by 2002:a05:600c:8b6a:b0:46f:b42e:ed88 with SMTP id 5b1f17b1804b1-46fb42eee4fmr132671855e9.41.1760449062401; Tue, 14 Oct 2025 06:37:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiyLGx/XOXKn7gRuHhlmN4j1M0MNnfyE1WU7UUmxZsiMQsjpqt43Gp8uHWcMVkis96pQUQVg== X-Received: by 2002:a05:600c:8b6a:b0:46f:b42e:ed88 with SMTP id 5b1f17b1804b1-46fb42eee4fmr132671605e9.41.1760449061913; Tue, 14 Oct 2025 06:37:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Thomas Ogrisegg , qemu-stable@nongnu.org Subject: [PULL 11/28] target/i386: fix x86_64 pushw op Date: Tue, 14 Oct 2025 15:36:56 +0200 Message-ID: <20251014133713.1103695-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449206933158500 Content-Type: text/plain; charset="utf-8" From: Thomas Ogrisegg For x86_64 a 16 bit push op (pushw) of a memory address would generate a 64 bit store on the stack instead of a 16 bit store. For example: pushw (%rax) behaves like pushq (%rax) which is incorrect. This patch fixes that. Signed-off-by: Thomas Ogrisegg Link: https://lore.kernel.org/r/20250715210307.GA1115@x1.fnord.at Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/tcg/decode-new.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 51038657f0f..a50f57dbaab 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -1541,7 +1541,7 @@ static void decode_group4_5(DisasContext *s, CPUX86St= ate *env, X86OpEntry *entry [0x0b] =3D X86_OP_ENTRYr(CALLF_m, M,p), [0x0c] =3D X86_OP_ENTRYr(JMP_m, E,f64, z= extT0), [0x0d] =3D X86_OP_ENTRYr(JMPF_m, M,p), - [0x0e] =3D X86_OP_ENTRYr(PUSH, E,f64), + [0x0e] =3D X86_OP_ENTRYr(PUSH, E,d64), }; =20 int w =3D (*b & 1); --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449161; cv=none; d=zohomail.com; s=zohoarc; b=UAy3u8KuxuJMVbTMvJUG9dtp54qGJxxInJZpWt9gH055BDfOVW9EE/a/iFRiYrtNdesu8uI9bfk7nfjpwlRnLCb8HmRRl+8mBnEPoYEysRg6mjGhiDsPkAQx6asGIbke2uiEAuFwH7IZeuqJ/hl3azLgx31aERDCr6a9TKqolJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449161; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=p7FvYGDrbnzpa7OItG1//SbTNo4zP2HPygbU6jXz7UU=; b=k26tvU2TUlr0PPn3yWkSyPqc/jCyu229X1a5GqBL5VsdNEA+ojd1/kG2WtZ5swHzTomGT1Y65hgu91vRApqGPFKJNelPAnRld2NqE84PTtu5zSsxm8xTM3aTWLuBm1zhhvFQYp08ue7P9vTF1LQ16mrQ4shAGjCPotGzLYuhPKk= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449161481501.79743684941957; Tue, 14 Oct 2025 06:39:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEG-0005lz-9v; Tue, 14 Oct 2025 09:38:16 -0400 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 1v8fDw-0005TT-AC for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fDt-00013r-Am for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:55 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-3Vz6BQRHPkCLv_5LCZEUHw-1; Tue, 14 Oct 2025 09:37:48 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-426d314d0deso2307224f8f.1 for ; Tue, 14 Oct 2025 06:37:47 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ed61d31esm4698970f8f.52.2025.10.14.06.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449070; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p7FvYGDrbnzpa7OItG1//SbTNo4zP2HPygbU6jXz7UU=; b=A1gMw1KbIjZiRkpCoJTd1iwxPHOt+fUbT/SLUAPU/FfUfr5NojYww1NOXa5T3fGjd9oQ+K zify7386umIbNuK5PPelLLm81q9C+koy/FVn9/wBdoJ+VkRaF0m5ytRlNw7Q3JXizoRD0z URKUGI2uxhodl5fdZvMLsiy/rEs8r18= X-MC-Unique: 3Vz6BQRHPkCLv_5LCZEUHw-1 X-Mimecast-MFC-AGG-ID: 3Vz6BQRHPkCLv_5LCZEUHw_1760449066 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449065; x=1761053865; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p7FvYGDrbnzpa7OItG1//SbTNo4zP2HPygbU6jXz7UU=; b=K5V9PaN/yhaVMeocW0HbTyzCOs+UBuArFjsg0c4C7qfCoCWeGd76RK5drPPCodQZ1D d7JIIpNi/Qu0C69MMSyPYKHXaWfi3RVK1xsrtuuzh1vkb1eoOwFLcsYY1pne3hIT5092 JWf6iOopBaH0vii063LNFWPl8WdFNk4GFr0xVN/If2JsAvahMh34JZ9KQjViguXrtUgZ b5oXALviuBXXtD/5pv49j5wL3X/dwzzMyLcGXLDT5Ixym9uwulnd3O8l/IPjJ8AIzQ5j GDT/5RyDUftnHJO3Qj5fKObIRWFhJSOYCVNHzbRVoOQSrv3W3Hb/BycbJiRgCR6EYitZ /oyw== X-Gm-Message-State: AOJu0YzHJItkHf116XzYejFp4fZ4GplXsyR5mzTXseZ78nUlpmULG9Uj Cod0FRHAxIr7zjI+vK9UlrSAHrFcdhSp07F/958jnUV+gHSoCgioV8VrndkEqhYlYIVzF9lwtwX wAWgXu2G1bwUva/kkh6JCP8ScOiuaL1g1KmRXetD6HpxKSKzpc+pGRV18koPHwHkq/qCbUSmJhi LKN3ABpwv2BnqwlifGOz3Ypkwi/4JaFGoQMspjoExg X-Gm-Gg: ASbGncubDnkjJrGX5Csq85QETlkaE5VvW9DpfId863FDfa2nEnaZ/kVCSRG8tLgwrpL kJhssqs8KNstJ3fX1AQJRNRtPD9gJs1X5hirCR8+cHrqRLP0NJweS6U5okUY4t0waRk0JZgqgXO ntz/alfwLOhUXe/lpJwdEZT+X5QHCaFS13zomK9X7hmFERt1KX4orRV8XfVaizE1BvBQq8cTTVe 0agKKl0GXnhNhTJE7yKne3NlrHIdgo67Q+/zUbRJrUOlyAsvvlFrHYnEdGr0F/4hX+K42sEsPX5 i55DeWCREsmQcXpZpad7W7hkmL/Sf/zytdelZZfBudeMYduEzaETi76zGfp4xB4SwdZB1kcHUgK FQuPOPrQC7bHbWg0J4BUkZdlA66obuusWSprByncb/tk= X-Received: by 2002:a5d:64e5:0:b0:426:dbef:acb9 with SMTP id ffacd0b85a97d-426dbefae8cmr6225659f8f.59.1760449065289; Tue, 14 Oct 2025 06:37:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEplO1pLbjZe1RBpX4n9mG3SzMFiTOsTTJ6T496fJkUx9SSh/t0dSNlIbQw9ibWdORIcge1sg== X-Received: by 2002:a5d:64e5:0:b0:426:dbef:acb9 with SMTP id ffacd0b85a97d-426dbefae8cmr6225641f8f.59.1760449064873; Tue, 14 Oct 2025 06:37:44 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , qemu-stable@nongnu.org, Thomas Huth Subject: [PULL 12/28] target/i386: fix access to the T bit of the TSS Date: Tue, 14 Oct 2025 15:36:57 +0200 Message-ID: <20251014133713.1103695-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449174256158500 Content-Type: text/plain; charset="utf-8" The T bit is bit 0 of the 16-bit word at offset 100 of the TSS. However, accessing it with a 32-bit word is not really correct, because bytes 102-103 contain the I/O map base address (relative to the base of the TSS) and bits 1-15 are reserved. In particular, any task switch to a TSS t= hat has a nonzero I/O map base address is broken. This fixes the eventinj and taskswitch tests in kvm-unit-tests. Cc: qemu-stable@nongnu.org Fixes: ad441b8b791 ("target/i386: implement TSS trap bit", 2025-05-12) Reported-by: Thomas Huth Closes: https://gitlab.com/qemu-project/qemu/-/issues/3101 Tested-by: Thomas Huth Signed-off-by: Paolo Bonzini --- target/i386/tcg/seg_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index 071f3fbd83d..f49fe851cdf 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -456,7 +456,7 @@ static void switch_tss_ra(CPUX86State *env, int tss_sel= ector, new_segs[i] =3D access_ldw(&new, tss_base + (0x48 + i * 4)); } new_ldt =3D access_ldw(&new, tss_base + 0x60); - new_trap =3D access_ldl(&new, tss_base + 0x64); + new_trap =3D access_ldw(&new, tss_base + 0x64) & 1; } else { /* 16 bit */ new_cr3 =3D 0; --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449255; cv=none; d=zohomail.com; s=zohoarc; b=CGDtdZJYPOuHUkRhFPTts+ZGbu7INM3Y59vIVVqDMQD/9an+Kop+ERZcHwsx1wY7BnyO6dzcD2wgFrp9wUz5JnsaelVwBAeRlP+XXBmFXBnrhjqURpCkCQpxcAzzNPIW0wPzLDpMrv7JPdxDmM0YGts53BchBcVYFLn9y2Tf91g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449255; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sTZ3ClnJQMXJF+JfzAzYWShwr2lG5rC7REx/EFEbJ/o=; b=np9hd6b7ETsvuP9nBQy6lCtkFEf+M4qW4Cxj5vuqSpZdsHjI3LIOyhFhEvGwbc8CULU4/GJ92GzhsV3CxhsK6j0YYY7TlXtFhBZA85XhUbLixGpEWCSJLnzvQNLbwY0KfYCMJPrCFuxkpftA6gXJsAaI4WFhQUiE3nCwQNfy1Vw= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449255365348.30070223698; Tue, 14 Oct 2025 06:40:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEG-0005mf-MU; Tue, 14 Oct 2025 09:38:16 -0400 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 1v8fDz-0005VN-GP for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fDt-000144-IZ for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:37:58 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-9ryCwmJ0NvWVIyrkRMJNig-1; Tue, 14 Oct 2025 09:37:50 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3efe4fcc9ccso4616596f8f.3 for ; Tue, 14 Oct 2025 06:37:50 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5cf6b4sm23840092f8f.25.2025.10.14.06.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449071; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sTZ3ClnJQMXJF+JfzAzYWShwr2lG5rC7REx/EFEbJ/o=; b=icK/Y4W8U1kjTn1b0l2+AQvW6CfEQFMCMNci1q3RG2M1T0tYwqUMAdD2a0CjMW9ePjBpim jbMAobEALNZYIrjF3v2H5AQh0GSyUo+xY+0IBavnFFoPVuep/7TUbnsCJ3xVsaFaP+Aq01 tBr5GECSIq/9vRbxdhRIElDVz8EXkoU= X-MC-Unique: 9ryCwmJ0NvWVIyrkRMJNig-1 X-Mimecast-MFC-AGG-ID: 9ryCwmJ0NvWVIyrkRMJNig_1760449069 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449068; x=1761053868; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sTZ3ClnJQMXJF+JfzAzYWShwr2lG5rC7REx/EFEbJ/o=; b=OXYell6hYO15WU3qHoeRAg9dYz9e1RyaLFZUz+VAd+OLqnVUvlHe6q3mXWUWrzRPg3 TyN09GZQtcy4bZGDWPIXx6WtbNURDPFCd1ov7w/vp5eiGnmsO43VGrJLJTJUwD8gVTbQ R4zIesPzbcejyufFnO1oepLKylkck5/IVa/87HBh4dPHJCw/lIvrAtyGH7xLJGE8m9N9 BjRydytMsJhyxJADfCswVnypFdtkgYbf2vTxHIdpSR8OwysIL/9CpcuwhcesknjhhiK+ mfF72TR9tJdZze99mTEcFbOgnwXdvpDROPy9pOKaE3NW71HVFhUccPh4Qbmf9eZg9sYJ bbzA== X-Gm-Message-State: AOJu0YwB/MPQ2jDs0qopT6ldMlUlVHEBl4jZwyEArefiunQjQCgZQppW nqMGZW2D6D2KoxN7J6GfBWgpzvrmndpZ3Lj6H5Q1JSBfNY0FMfQVrAOnqcY1kAc6jopY3HTIshj CUEQOv/HIPim9bgow8oKtG8stZV4b6H/0QV9jgNc7ToXj76OH7z0I63ONfdC9MYI21pk5fBoykG S2XFGDCkQthVJkwCyhb24Tsb2criQHcqO4T79YNVAI X-Gm-Gg: ASbGncsLq7FFjhfrLV0EJJGah0rXeSU95XDHi/aU9zYJuGtNtpk6avoU8heyPArC6vO FF54xpvkvUfQP4aE75M8ctgJDqE2D/xU1sDK578U0tj87HnKmwsxTRc2Dxyoi5TWVhijzLKw9E8 KDj+xJva1SQbE0GspbMUM0OjfYcvNBb10q1Lh+QGJDn/2MtOCmqIB/rhgqlHM5Eym2SW+wlhpWT b4n8rUBudl4DsfZ4zJT2kMjvXwFgNWWGl5mhp2yTEBMrHZphUbrMyI8BL32ddrI6S9a4UWBaElh 8V0Y+m7QmoEg8NJ9lk+ZiLKfr68+5mRMpfj03v9AkGna+CF3tuNTsYGV1giHkL9RpbJYVUUE2aM 3AGHKWoqg4lF6S3NwD9RrW95wqwQ8oTvsVe8IMEGR0Co= X-Received: by 2002:a05:6000:288c:b0:3dc:eb5:51ea with SMTP id ffacd0b85a97d-4266e8e0995mr16141079f8f.49.1760449067983; Tue, 14 Oct 2025 06:37:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6Kym2GKQ7rcZhfbWeNFBgZwNZxuBLv0dpUpiOxebr3mC2GbjKhbJx5KGk90AyKaQBtUAASg== X-Received: by 2002:a05:6000:288c:b0:3dc:eb5:51ea with SMTP id ffacd0b85a97d-4266e8e0995mr16141051f8f.49.1760449067534; Tue, 14 Oct 2025 06:37:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , qemu-stable@nongnu.org Subject: [PULL 13/28] async: access bottom half flags with qatomic_read Date: Tue, 14 Oct 2025 15:36:58 +0200 Message-ID: <20251014133713.1103695-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449256468154100 Content-Type: text/plain; charset="utf-8" Running test-aio-multithread under TSAN reveals data races on bh->flags. Because bottom halves may be scheduled or canceled asynchronously, without taking a lock, adjust aio_compute_bh_timeout() and aio_ctx_check() to use a relaxed read to access the flags. Use an acquire load to ensure that anything that was written prior to qemu_bh_schedule() is visible. Closes: https://gitlab.com/qemu-project/qemu/-/issues/2749 Closes: https://gitlab.com/qemu-project/qemu/-/issues/851 Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- util/async.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/util/async.c b/util/async.c index 2719c629ae9..a736d2cd0d0 100644 --- a/util/async.c +++ b/util/async.c @@ -256,8 +256,9 @@ static int64_t aio_compute_bh_timeout(BHList *head, int= timeout) QEMUBH *bh; =20 QSLIST_FOREACH_RCU(bh, head, next) { - if ((bh->flags & (BH_SCHEDULED | BH_DELETED)) =3D=3D BH_SCHEDULED)= { - if (bh->flags & BH_IDLE) { + int flags =3D qatomic_load_acquire(&bh->flags); + if ((flags & (BH_SCHEDULED | BH_DELETED)) =3D=3D BH_SCHEDULED) { + if (flags & BH_IDLE) { /* idle bottom halves will be polled at least * every 10ms */ timeout =3D 10000000; @@ -335,14 +336,16 @@ aio_ctx_check(GSource *source) aio_notify_accept(ctx); =20 QSLIST_FOREACH_RCU(bh, &ctx->bh_list, next) { - if ((bh->flags & (BH_SCHEDULED | BH_DELETED)) =3D=3D BH_SCHEDULED)= { + int flags =3D qatomic_load_acquire(&bh->flags); + if ((flags & (BH_SCHEDULED | BH_DELETED)) =3D=3D BH_SCHEDULED) { return true; } } =20 QSIMPLEQ_FOREACH(s, &ctx->bh_slice_list, next) { QSLIST_FOREACH_RCU(bh, &s->bh_list, next) { - if ((bh->flags & (BH_SCHEDULED | BH_DELETED)) =3D=3D BH_SCHEDU= LED) { + int flags =3D qatomic_load_acquire(&bh->flags); + if ((flags & (BH_SCHEDULED | BH_DELETED)) =3D=3D BH_SCHEDULED)= { return true; } } --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449322; cv=none; d=zohomail.com; s=zohoarc; b=Nyw2mrJs9dQ7vsw44G31pHuPOZnC4vCricw6wkUYBabtvO4iCHIaxhVoiFSRbURKuNb+YVQJvgqmUS/zS08sT8qCuQFsp1MjjFCVCJ4I2HHWaPKqbI0tR2pMMQ2RdbAyWQ/4FS3R/wZE0Zb4f79aa2BSEPbBq0A0vajUwM5C0NU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449322; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=M4PpLZCIcS/TWHP7SQYNUMpLS4jIGwyW9HPY7SpN9RU=; b=n9ofGZfZV0QU2MBb5h07P4cdajx+k99tbhF1iOg2RO7bVzv7ntBbljeMpJ7OB8ZMz2tmt5J2GHXAYvxWtX/ex7kIy/qvDtGAEHkyTS9PtnBhnbXyUA+bUREx+RiTzte80gPSAxtZztUnwgJdP4xBjDz0HQEuAhGHLpUIQ0yaZKc= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176044932220038.54507668243889; Tue, 14 Oct 2025 06:42:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEL-0005sj-G7; Tue, 14 Oct 2025 09:38:21 -0400 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 1v8fE4-0005XJ-48 for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fDz-00014i-J9 for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:02 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-IL8OpvtWPqiqtAZqUnO4_w-1; Tue, 14 Oct 2025 09:37:53 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e3a049abaso38647385e9.0 for ; Tue, 14 Oct 2025 06:37:53 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fab524f92sm150156755e9.7.2025.10.14.06.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M4PpLZCIcS/TWHP7SQYNUMpLS4jIGwyW9HPY7SpN9RU=; b=brq8RrCkfh7wyTCOc+bXGEvuFCVCqJjEQuDRYWzj/0x3bGWb0Kqmv9cLq0CiJi6G9Uqo9a Rfo5LqLQE3T41uM/dPK5w1cksaTeDjfcLA372KksaXOGhL0euCw7qQsd3Ynv+SU3zPXLxx dgD3gqSXa9UTMG03mht4HjY6IXukrNs= X-MC-Unique: IL8OpvtWPqiqtAZqUnO4_w-1 X-Mimecast-MFC-AGG-ID: IL8OpvtWPqiqtAZqUnO4_w_1760449072 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449071; x=1761053871; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M4PpLZCIcS/TWHP7SQYNUMpLS4jIGwyW9HPY7SpN9RU=; b=dZNEcl+FUPyjMAjrOl0hC2lLjbJoyKzCfhKWjlukP5vK7Hk10P5TCCqspguOW+XgZ5 pbSTEFf64WUsS5Tdp6PaielReYWbzEZp8k8juXvi9BFIGhqlDmIC8tlt+yBDFVKuHXuv 0ShIsiR6bpTKkVpu8ZDAm41AD6xob23xstq41NzO+7tjDprs1uZcHskywUtLasNnW144 AxH+g5lAhVuYjudWNfyBTpWJNWJviHoY5C4s66Zj7URDkrJXv/OOKnHD4XpN/WjQaSrs oxNwicXMi30GJx5tPbUQREFFp62uSjqkUJCCvfBltZvYVZJe1X3bke1JuBSI5LU5Re80 WnEA== X-Gm-Message-State: AOJu0Yxc7ELNoiK2wqbUjvthpf443jfo41AA+qPt0Yrog6aIGyuvALfI 80IOFbTpiu3BGgi6k0Tz3EGdqM3Y4sx3vHESZfFhEoxoBw/DfCuk76J7jAsUmHZu5NuAg8/d5av SSxG2C1BhsC/3GhO2ohKMVo7bY4zz3n8IixB+axtvDVFBfBoeZ+ABgMeJDYbnwWPpB89JfUoZ9/ iTbeVkvntoHcBi6cSIX1iZhQnl0VpXP478SyMiapMC X-Gm-Gg: ASbGncuOshYNd04b27iXHdN5m0KiqYtoOLMMCa/U+si3/Ud89vsWcDWn0mdnyw8Z26K 6+8NIgtEQ8uqTTI9VF1Eisglzm9+Wf5KdPTIQji7Z4sOhm9T2bFxASLgUzDo3WWERlWqO8Yte+H 10YwtadTHBHAdNuBkVGu7MbrR66sDfD7/i+BPbrKA+GxxNY1x9XCbtacWMtLJgWbbePGWrX1FlE mGXkP2eeuhwcKBE2dd2FbsQ6cXaE0LNhBKZ8m4YuMy0J7SOaF0rrI/AYUNpAU2SeUl7RlYfdynk vQMaSackFeaZX9fMGMrSn0siUZtkuR3Uee8mRfd8S15MgEsPNt5wkpkmitBPfHEgddRm0bSMleO GfRfNUirygIk+7XegjP+cgcOAK28zRAsfOoTfUsypsRw= X-Received: by 2002:a05:600c:8b41:b0:46e:4b8b:75f2 with SMTP id 5b1f17b1804b1-46fa9aa2209mr178663565e9.16.1760449070969; Tue, 14 Oct 2025 06:37:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTsWrd5e3mkFYaptflG8bQe4QuGl5qvratYD+/UegofuzuPh3tlYwcW0VfSB2SEztlHC2xkA== X-Received: by 2002:a05:600c:8b41:b0:46e:4b8b:75f2 with SMTP id 5b1f17b1804b1-46fa9aa2209mr178663305e9.16.1760449070434; Tue, 14 Oct 2025 06:37:50 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , qemu-stable@nongnu.org Subject: [PULL 14/28] target/i386: user: do not set up a valid LDT on reset Date: Tue, 14 Oct 2025 15:36:59 +0200 Message-ID: <20251014133713.1103695-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449328132158500 Content-Type: text/plain; charset="utf-8" In user-mode emulation, QEMU uses the default setting of the LDT base and limit, which places it at the bottom 64K of virtual address space. However, by default there is no LDT at all in Linux processes, and therefore the limit should be 0. This is visible as a NULL pointer dereference in LSL and LAR instructions when they try to read the LDT at an unmapped address. Resolves: #1376 Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4f99cbc5c0b..455caff6b23 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -8649,7 +8649,11 @@ static void x86_cpu_reset_hold(Object *obj, ResetTyp= e type) =20 env->idt.limit =3D 0xffff; env->gdt.limit =3D 0xffff; +#if defined(CONFIG_USER_ONLY) + env->ldt.limit =3D 0; +#else env->ldt.limit =3D 0xffff; +#endif env->ldt.flags =3D DESC_P_MASK | (2 << DESC_TYPE_SHIFT); env->tr.limit =3D 0xffff; env->tr.flags =3D DESC_P_MASK | (11 << DESC_TYPE_SHIFT); --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449191; cv=none; d=zohomail.com; s=zohoarc; b=a0c8cQqT8Dnai0k7MvjvKY+PJYFoOG+//0pgvBTvuUvJuTNo8EKAsKUg73Gw4hX3WjnrJ5XvCDYGcA/PZLRatMPjiBfJ5IpRpuKlIQO7PcRJQOl8gSEvg/HV5pTle/QeTcFiBvxIB0nqOGy1MsEPvPO8LnQLY18TYo+to1OIwD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449191; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PuR7JKiNJ5s528urmAgX4g6HhfGe6vzMJkniXLSA/FU=; b=iJe/fcaguX/42sfohURla9AtGWVx1w1jmnaMDXwrxdIz0uK+xA0992kuF58Z2mrLmssTITwRfSrUmlaR9FtpgsvEdw7f+ZqITIV9iLMyc7lVxP0i6O+5wpRN6AXqny1z8ncSnA4bwVoDtHVcz+facJ5d2pswutfRKq5LTM6V420= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176044919175114.631470942458122; Tue, 14 Oct 2025 06:39:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEJ-0005qr-4b; Tue, 14 Oct 2025 09:38:19 -0400 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 1v8fE6-0005Y1-Jj for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fE0-000151-DE for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:06 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-152-nCe0YvFfPJiOyprMBpRSpg-1; Tue, 14 Oct 2025 09:37:56 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46e38957979so29727275e9.3 for ; Tue, 14 Oct 2025 06:37:55 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce57d404sm23974497f8f.3.2025.10.14.06.37.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PuR7JKiNJ5s528urmAgX4g6HhfGe6vzMJkniXLSA/FU=; b=XOOEhVAeEvlCgZv0BZi7Bq3suxOXZtPNCEV0ZdcmX1gaDFutW/vzHUCQ9kmFedwvr9mzLN TP8BWNqpZL0OWzRFPdwq6dtA5g27gR5lT+Q4wv6hgxjT6s+5ZyxgGUt7if9g1tjM3Hsmpl XsPuLKvGgx6WB4Ejz7gdPf2lqb4Mtj8= X-MC-Unique: nCe0YvFfPJiOyprMBpRSpg-1 X-Mimecast-MFC-AGG-ID: nCe0YvFfPJiOyprMBpRSpg_1760449074 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449073; x=1761053873; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PuR7JKiNJ5s528urmAgX4g6HhfGe6vzMJkniXLSA/FU=; b=ANIpRJJsukRGE2UJLlzT84Ck+9UPuUnPWvm3UN2lWUYCLBKu0mTr+gO01L1J0vMK9G IKozz1QuWyHwzKxvS8a57tuPrHCAzJjMpNgSrpbkEMlPtjQywUtO70s6P40dMfXXRv+v GSK+JgRH8oHViYYdtuhLeByWL2eRsBmCd8I5l/Pi2n0sL3kmpQ4wbhfn/NkGjFSBsvKW J5RK0SqFbq2q14psjIwpI+wNAoYf4mZfr/RnvmrkLlDivIMI4Dz9EWrBIcKnIV5oklIg jhraTbEnlEDHHgLsdG3U0kn/zghaXkJsR3Tk+ssjYEquTUmkjsdlIOi2kpzf7DrubydB 2FAQ== X-Gm-Message-State: AOJu0YyxUnWlvssPGbQbBsxXDDDKgziBHq6e0vHVrYX6cIikuV13Bcs/ PNIziJopxQZJxGNO+Q4s6WEOuwE6yjr9XnAjx1AApaKdWZiEa2sosF9BGHNdPpoeckKPH9u9zib v+YLiW0/Imn7+XIQfqqORFOvUF6DBwRqTQDaAeGuTdsn8ifZaaaAeigOx6k9uq2l0wjb3xbGJKP V/vGFCQK4fLeCNRNoTeI+pHEMiU61AoS5ZcRk9YuAC X-Gm-Gg: ASbGncuF/CqBFVdlm1rk8zGI4ooVIokqfkgTVmYfHwMg3+prUDWBxS7JnBzBkl48gLW 7G58Sb4r+w/vE/gKZymtQSKY6Evvo1dgVEw5D3K/1S4ZOh0GsXuLUjWvBXBWSKPT4J+g/AiKRMQ 9L1iKK2xvUA/JUambkyZ4H13M89KhM/S966klyWMfiQQbnSe94LESungU1cvVMJi/ZS7FvWVpZx 0nuIzq5IjqMz0AKUJiJuffQpBrgZZbt+bKfXN6xpsNIice8Wt4/cPih7SAhqpVi04vjKPC803tk XF0ERbL0kTl69zT2Xu1CvWY7bzuZ6f1j9vsWRfIoatY1cDu60KM8OsSwTwosnhZg6fjaMkcu0at +8JvckbPwQ6+0qIeuCavyTcfMGHKTPudmTwe3GwohetE= X-Received: by 2002:a05:600d:42f2:b0:46e:4341:7302 with SMTP id 5b1f17b1804b1-46fb15396d6mr120879455e9.34.1760449073192; Tue, 14 Oct 2025 06:37:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH50wa3Ls8wNEDNx3XBTk9SAL/tgppq/FP1cP7gsNmob0qLIM10/LrZ+4w1UKdT+/LbZtAuLQ== X-Received: by 2002:a05:600d:42f2:b0:46e:4341:7302 with SMTP id 5b1f17b1804b1-46fb15396d6mr120879245e9.34.1760449072779; Tue, 14 Oct 2025 06:37:52 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 15/28] monitor: clarify "info accel" help message Date: Tue, 14 Oct 2025 15:37:00 +0200 Message-ID: <20251014133713.1103695-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449193799154100 In preparation for adding "info accelerators", explain that this command is about runtime statistics. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- hmp-commands-info.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index eaaa880c1b3..c2aa40056bb 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -271,12 +271,12 @@ ERST .name =3D "accel", .args_type =3D "", .params =3D "", - .help =3D "show accelerator info", + .help =3D "show accelerator statistics", }, =20 SRST ``info accel`` - Show accelerator info. + Show accelerator statistics. ERST =20 SRST --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449403; cv=none; d=zohomail.com; s=zohoarc; b=FR6R0Y0njGrC05WH6pn+AcUdSinFv6SW51Cl2fms32FF6TGqrQTQ/LXRVvJdbcxfUQomgcbHJimnyC4PTW6Th8GTZEw2mYubCJlXx9FN9VEWyc+pG9IhLlP+OYrpMOGZyEiPmNS1BMgvcprELw7BEGhigyMbk6WSWLDnVsvQTEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449403; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zsMuvNyPFddR1kWpBU6ZgTh6DaoZvqds7yRzYkfuz60=; b=ZRs+HNxLVsfWu07pjLU/kYzPMArsKA7Mw3J7e/qZNutIs8Fj5oxSWCnUYtGKbpo1UpNI5AmaIOd2S96fWcLjEnP0arjAWFAblu6LdgIdEpJa1nKGj9MJQtoihW+lKIx+vojKLRpvgHvpoUgEM00sBhllH3p1oGYSCfeK2iH+0Q0= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17604494035081002.9916565987365; Tue, 14 Oct 2025 06:43:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEL-0005si-1g; Tue, 14 Oct 2025 09:38:21 -0400 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 1v8fEC-0005aX-Ib for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fE4-00015J-DC for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:10 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-657-WQlcH_d_NRiYqPgtuGH01g-1; Tue, 14 Oct 2025 09:37:58 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-426d314d0deso2307408f8f.1 for ; Tue, 14 Oct 2025 06:37:58 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e0e70sm23740164f8f.40.2025.10.14.06.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zsMuvNyPFddR1kWpBU6ZgTh6DaoZvqds7yRzYkfuz60=; b=LZBU9RxUJbsQBZisW8fjc+bB8l553KoZUXu4S09vH9/CNDNj8CjN147nzcgo/NQehvGjns kEG0CQg8MWcnmScvQLZ68AeLdHyqxvD76wNDetC273Bvz2DcvkO8Yq4/C64BLMV9je2R7c vaDjKF16zN62UoA2YxYprIXOelwDPPM= X-MC-Unique: WQlcH_d_NRiYqPgtuGH01g-1 X-Mimecast-MFC-AGG-ID: WQlcH_d_NRiYqPgtuGH01g_1760449077 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449076; x=1761053876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zsMuvNyPFddR1kWpBU6ZgTh6DaoZvqds7yRzYkfuz60=; b=P+6fNZyjidy8VXbLD8sRqmpCBy93gq0BU4U9SppBRcUfntgm9pRc5Y5XJ0NEvd8eMy 2/rLvLqvSScsUJxrsqoor9tNtxoj8IrQ5yzHJjZIKh0Ekdb/NuTQI9Lyz6xWmbyj9iFR A1hOEZurQc9utfHvqMULYpWb1AiRUHeRyb4mqJor6DUnnApUc4u1ABoHHg+GQRSMGih5 ck22DefkdEoE2hMTIpOgNJ54cO6SOpIiR+c9K5F/uotFsMjR01jwe1UljLZ2KvU+z+To 4+jzivU1sccIM5fCKHvs1cjWlC9yCZmkw1dytTlM5umXZ6+rdFtg6A+1WXZYJT7ETCTq XfgQ== X-Gm-Message-State: AOJu0YxdxshAqT70d/EXGYWD0XYfOEBWkSj6v6yVTHAZO9NyQwn4ZnpE 9fqb86HQoxL3PNyS4vON9eeU4al0QPFI86a2+RUhnp3QjllrR3Gw5T3ab9xij8Z2oN2ZPptxZc/ 3GTdcKsMPz8IO9RmYtI/KbaDPwM8HBqBKkRjiGy+CPwKPcK92Zwx0XHK/1AHK4tEua/w1AZiQJy vsUl5v7Soki/oJwsW4a5UTl9kgzdbQrLhc3gIOHJZP X-Gm-Gg: ASbGnctouX4q42b3dlxrgPzhTh8RVSTVKJuhptuJx3fNXnzZNxSIZeI5ATcKmfSzk03 E5BEdKymnZhkxgmXLo5X0EjFgFH7uK6wxOrWr1j1HDekxZ3VeGEBNkm5hiGzlka2R5mfbjNBtuN cwO1J5haLTr/K7TEdVufsVn9Kj1WFxPRs6fBh840Sp76H+eFoofcleGA7eZvRVSTTlBOKYumGm2 B/BonDlv1/2NjIrtE+b3s8Fhyn9oPlX/HAzXsYHZgNUKS0b6/lDO2yvJ7TssrXMLJNl5pq3lzGp CT+koXIlOBeS95FT9sFy0U+skH2vm1dByYjjBZou0ibNN1tm+k7PnyBkm/Z3Nl0xn/AFZjrF4mA fVMyUjYTGm5BQKCchMQLe3LIymFWTKy5ySuVKt6zDpN4= X-Received: by 2002:a5d:5d03:0:b0:3ec:e0d0:60e5 with SMTP id ffacd0b85a97d-42667177bd4mr16027466f8f.15.1760449075785; Tue, 14 Oct 2025 06:37:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqhGgqfSe7PXM5B5eAmw1yMJvFZmH2dwtsJgR80jLk1hjOFFaqvAcaOX129R+RNOG10GJ67Q== X-Received: by 2002:a5d:5d03:0:b0:3ec:e0d0:60e5 with SMTP id ffacd0b85a97d-42667177bd4mr16027439f8f.15.1760449075240; Tue, 14 Oct 2025 06:37:55 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Praveen K Paladugu , Magnus Kulke , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 16/28] monitor: generalize query-mshv/"info mshv" to query-accelerators/"info accelerators" Date: Tue, 14 Oct 2025 15:37:01 +0200 Message-ID: <20251014133713.1103695-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449417160158500 The recently-introduced query-mshv command is a duplicate of query-kvm, and neither provides a full view of which accelerators are supported by a particular binary of QEMU and which is in use. KVM was the first accelerator added to QEMU, predating QOM and TYPE_ACCEL, so it got a pass. But now, instead of adding a badly designed copy, solve the problem completely for all accelerators with a command that provides the whole picture: >> {"execute": "query-accelerators"} << {"return": {"enabled": "tcg", "present": ["kvm", "mshv", "qtest", "t= cg", "xen"]}} Cc: Praveen K Paladugu Cc: Magnus Kulke Suggested-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- qapi/accelerator.json | 47 +++++++++++++++++++++++++++++--------- include/monitor/hmp.h | 2 +- hw/core/machine-hmp-cmds.c | 21 +++++++++-------- hw/core/machine-qmp-cmds.c | 20 ++++++++++++---- hmp-commands-info.hx | 15 ++++++++---- 5 files changed, 74 insertions(+), 31 deletions(-) diff --git a/qapi/accelerator.json b/qapi/accelerator.json index 664e0272465..2b920608847 100644 --- a/qapi/accelerator.json +++ b/qapi/accelerator.json @@ -56,30 +56,55 @@ 'features': [ 'unstable' ] } =20 ## -# @MshvInfo: +# @Accelerator: # # Information about support for MSHV acceleration # -# @enabled: true if MSHV acceleration is active +# @hvf: Apple Hypervisor.framework # -# @present: true if MSHV acceleration is built into this executable +# @kvm: KVM +# +# @mshv: Hyper-V +# +# @nvmm: NetBSD NVMM +# +# @qtest: QTest (dummy accelerator) +# +# @tcg: TCG (dynamic translation) +# +# @whpx: Windows Hypervisor Platform +# +# @xen: Xen # # Since: 10.2.0 ## -{ 'struct': 'MshvInfo', 'data': {'enabled': 'bool', 'present': 'bool'} } +{ 'enum': 'Accelerator', 'data': ['hvf', 'kvm', 'mshv', 'nvmm', 'qtest', '= tcg', 'whpx', 'xen'] } =20 ## -# @query-mshv: +# @AcceleratorInfo: # -# Return information about MSHV acceleration +# Information about support for various accelerators # -# Returns: @MshvInfo +# @enabled: the accelerator that is in use # -# Since: 10.0.92 +# @present: the list of accelerators that are built into this executable +# +# Since: 10.2.0 +## +{ 'struct': 'AcceleratorInfo', 'data': {'enabled': 'Accelerator', 'present= ': ['Accelerator']} } + +## +# @query-accelerators: +# +# Return information about accelerators +# +# Returns: @AcceleratorInfo +# +# Since: 10.2.0 # # .. qmp-example:: # -# -> { "execute": "query-mshv" } -# <- { "return": { "enabled": true, "present": true } } +# -> { "execute": "query-accelerators" } +# <- { "return": { "enabled": "mshv", "present": ["kvm", "mshv", "qtes= t", "tcg"] } } ## -{ 'command': 'query-mshv', 'returns': 'MshvInfo' } +{ 'command': 'query-accelerators', 'returns': 'AcceleratorInfo' } diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 31bd812e5f4..897dfaa2b6d 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -24,7 +24,7 @@ strList *hmp_split_at_comma(const char *str); void hmp_info_name(Monitor *mon, const QDict *qdict); void hmp_info_version(Monitor *mon, const QDict *qdict); void hmp_info_kvm(Monitor *mon, const QDict *qdict); -void hmp_info_mshv(Monitor *mon, const QDict *qdict); +void hmp_info_accelerators(Monitor *mon, const QDict *qdict); void hmp_info_status(Monitor *mon, const QDict *qdict); void hmp_info_uuid(Monitor *mon, const QDict *qdict); void hmp_info_chardev(Monitor *mon, const QDict *qdict); diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c index 682ed9f49b8..74a56600be8 100644 --- a/hw/core/machine-hmp-cmds.c +++ b/hw/core/machine-hmp-cmds.c @@ -163,19 +163,22 @@ void hmp_info_kvm(Monitor *mon, const QDict *qdict) qapi_free_KvmInfo(info); } =20 -void hmp_info_mshv(Monitor *mon, const QDict *qdict) +void hmp_info_accelerators(Monitor *mon, const QDict *qdict) { - MshvInfo *info; + AcceleratorInfo *info; + AcceleratorList *accel; =20 - info =3D qmp_query_mshv(NULL); - monitor_printf(mon, "mshv support: "); - if (info->present) { - monitor_printf(mon, "%s\n", info->enabled ? "enabled" : "disabled"= ); - } else { - monitor_printf(mon, "not compiled\n"); + info =3D qmp_query_accelerators(NULL); + for (accel =3D info->present; accel; accel =3D accel->next) { + char trail =3D accel->next ? ' ' : '\n'; + if (info->enabled =3D=3D accel->value) { + monitor_printf(mon, "[%s]%c", Accelerator_str(accel->value), t= rail); + } else { + monitor_printf(mon, "%s%c", Accelerator_str(accel->value), tra= il); + } } =20 - qapi_free_MshvInfo(info); + qapi_free_AcceleratorInfo(info); } =20 void hmp_info_uuid(Monitor *mon, const QDict *qdict) diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index e24bf0d97bf..51d5c230f7e 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -31,15 +31,25 @@ #include =20 /* - * QMP query for MSHV + * QMP query for enabled and present accelerators */ -MshvInfo *qmp_query_mshv(Error **errp) +AcceleratorInfo *qmp_query_accelerators(Error **errp) { - MshvInfo *info =3D g_malloc0(sizeof(*info)); + AcceleratorInfo *info =3D g_malloc0(sizeof(*info)); + AccelClass *current_class =3D ACCEL_GET_CLASS(current_accel()); + int i; =20 - info->enabled =3D mshv_enabled(); - info->present =3D accel_find("mshv"); + for (i =3D ACCELERATOR__MAX; i-- > 0; ) { + const char *s =3D Accelerator_str(i); + AccelClass *this_class =3D accel_find(s); =20 + if (this_class) { + QAPI_LIST_PREPEND(info->present, i); + if (this_class =3D=3D current_class) { + info->enabled =3D i; + } + } + } return info; } =20 diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index c2aa40056bb..25b4aed51f5 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -308,16 +308,21 @@ SRST ERST =20 { - .name =3D "mshv", + .name =3D "accelerators", .args_type =3D "", .params =3D "", - .help =3D "show MSHV information", - .cmd =3D hmp_info_mshv, + .help =3D "show present and enabled information", + .cmd =3D hmp_info_accelerators, }, =20 SRST - ``info mshv`` - Show MSHV information. + ``info accelerators`` + Show which accelerators are compiled into a QEMU binary, and what acce= lerator + is in use. For example:: + + kvm qtest [tcg] + + indicates that TCG in use, and that KVM and qtest are also available. ERST =20 { --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449132; cv=none; d=zohomail.com; s=zohoarc; b=evWwphiNuWOYd5hMF5N9rYAjz5beiLeddSCVo2UimCqy42X6q0G4qqcdAgWgOtUe+6Rt98zGprRBu2/pGUQ3uUq8HvJBzkPBFkM09xxgG38xYuMEgQqklwi3CSDqHncdxVa+etSA9j2HBnX07grkvHZFCug7pCkgTNWaxAKrWpQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449132; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dyuYNDptE1X3br74u8yj+JhbDubWHYMBwAIHGS1MK8M=; b=mcTmijZH9TAs7TOs+cV6UuPOk90e2+2+8Tx3VuesidupBGb+zbyDpUi7QR7f+lSu9BMtIx5JX0I9GFgruvSM41+BdSjyWg5o61Cfva4rojmZTyjkYd7Yu3vqpPpU/ujiiXlZ2cw/6BJgR2/EUSZZGlXzmTxG4YotZdgX8/gZ300= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449132812379.06318990994146; Tue, 14 Oct 2025 06:38:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEJ-0005pZ-4J; Tue, 14 Oct 2025 09:38:19 -0400 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 1v8fEA-0005aS-B5 for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fE4-00015X-D0 for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:09 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-531-TDxXBIdkMVSAAzPyVJJm6g-1; Tue, 14 Oct 2025 09:38:00 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e3e177893so38378185e9.2 for ; Tue, 14 Oct 2025 06:38:00 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ed61d31esm4699912f8f.52.2025.10.14.06.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449082; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dyuYNDptE1X3br74u8yj+JhbDubWHYMBwAIHGS1MK8M=; b=PJEpG+smihl5wyibnjtYEB5EfO6XTjB1IekiSr8KtzaL2uuj9HxHfrD8dk8dnODpcqSWmK v7u5QU0q2a4gqyKsd0mNIclI5AVD3+HY5eCbStIt53YRtm6tyRXzCaZD/QYVFzbJ81TDGp GJ3xpyp9zqb8TSejIKZAhZMkGAyBXAY= X-MC-Unique: TDxXBIdkMVSAAzPyVJJm6g-1 X-Mimecast-MFC-AGG-ID: TDxXBIdkMVSAAzPyVJJm6g_1760449080 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449079; x=1761053879; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dyuYNDptE1X3br74u8yj+JhbDubWHYMBwAIHGS1MK8M=; b=OiK5x6YSp0TZ/aMg4/kDoBdTWogiAHJ8BaO50j6GbuBi3xHnyN63wcw2BX/ri7cy/L MSPDmvJs0jw3TR1T43EGilaveF8TY4vr/wGDEyTOmNDVbP5BQ8yDKfUXyfmYS92lJVRC 1zWMxEEJv4JB0e1tcqG38rERD6l6rAzEn8m56ZjVCKweSF62H3TWr8JGXTa87je4r/SN IbYXwuelZlpUt4DdfAY63BSPIkgbRKo/Pj8aVM2kSIayyLQLnQr5E4/aA84ZLRAwXy2J 3ye/IeLiRInSmGwDiICyefpTAPoNY/xg9HPefpalSG5pMKn0thaH8wJtjlkFTzEHTNJL Ps8A== X-Gm-Message-State: AOJu0YyneFElcuqKYEs8qIdzxUyeMvLAB2AVUOpoWOTQsU3OOzvuw1gm oEIvWbtZrOyrHvEBNGjWDbfyPpePG1eg1Wv6OzBzRe6HsucnEicsi/c960eix7/mG8hT2aSjHhN VEX+1bRt4MUF/9aLUMasnW3TC05Mq+W1KCwbi3OZM+97dG6WWKaJhmrHzbmFni6d4KYMaeBqq59 9mT4uHaEH1JB2n4SRJZjdO2moUJ/BrlLV40OEIQnzI X-Gm-Gg: ASbGncu8s3rNuX/ZK5xZ8+XpUJkJRN1aLY08nqRzGppASlfgplP5775JcwJvlBLkKiq jILrbYfBzNTTnk6E+ImZL9CrzTyQanp4SFGOXLF24QCtZO/XE9dMkdtQMWe4kBP2HrdREg3now/ ip7ALoh/M9O0x8noGeYhmjj7oKZp+jqa8xdHw15vHs8oQQ7JT+FhPPqBxFN7SmdP7SEYElW+UGn gTdfotXTzD1bR2Qhxykt1jJcCSWyB6rVrL+/gIr1enRGiSpkj+PQM8toCUMTjvyqNUZc5rcphT+ gPSXuokGMjFGrPuAwfgwgXP/9YMLyGd+Zn4T9EDkc0fZ7yEQyEPpvRrefFk62Ev1EGq9/cpOKWW xUtmINe6/u9zw54r745Fl9lEyqQuMIrvKUGmfMTA9HRs= X-Received: by 2002:a05:600c:c4a4:b0:46e:1d01:11dd with SMTP id 5b1f17b1804b1-46fa9a89444mr165533315e9.2.1760449078850; Tue, 14 Oct 2025 06:37:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0mXnc7Uhl/zrYbfERjIBE+xu0/1nlV1pk5lPrIDIPhNddB18aN/evf7Txni5uVcOMYGZy1g== X-Received: by 2002:a05:600c:c4a4:b0:46e:1d01:11dd with SMTP id 5b1f17b1804b1-46fa9a89444mr165532995e9.2.1760449078338; Tue, 14 Oct 2025 06:37:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Harsh Prateek Bora Subject: [PULL 17/28] accel/kvm: Introduce KvmPutState enum Date: Tue, 14 Oct 2025 15:37:02 +0200 Message-ID: <20251014133713.1103695-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449135191154100 From: Philippe Mathieu-Daud=C3=A9 Join the 3 KVM_PUT_*_STATE definitions in a single enum. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Harsh Prateek Bora Link: https://lore.kernel.org/r/20251008040715.81513-3-philmd@linaro.org Signed-off-by: Paolo Bonzini --- include/system/kvm.h | 16 +++++++++------- target/arm/kvm.c | 2 +- target/i386/kvm/kvm.c | 6 +++--- target/loongarch/kvm/kvm.c | 4 ++-- target/mips/kvm.c | 6 +++--- target/ppc/kvm.c | 2 +- target/riscv/kvm/kvm-cpu.c | 2 +- target/s390x/kvm/kvm.c | 2 +- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/include/system/kvm.h b/include/system/kvm.h index 4fc09e38910..8f9eecf044c 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -340,14 +340,16 @@ int kvm_arch_process_async_events(CPUState *cpu); =20 int kvm_arch_get_registers(CPUState *cpu, Error **errp); =20 -/* state subset only touched by the VCPU itself during runtime */ -#define KVM_PUT_RUNTIME_STATE 1 -/* state subset modified during VCPU reset */ -#define KVM_PUT_RESET_STATE 2 -/* full state set, modified during initialization or on vmload */ -#define KVM_PUT_FULL_STATE 3 +typedef enum kvm_put_state { + /* state subset only touched by the VCPU itself during runtime */ + KVM_PUT_RUNTIME_STATE =3D 1, + /* state subset modified during VCPU reset */ + KVM_PUT_RESET_STATE =3D 2, + /* full state set, modified during initialization or on vmload */ + KVM_PUT_FULL_STATE =3D 3, +} KvmPutState; =20 -int kvm_arch_put_registers(CPUState *cpu, int level, Error **errp); +int kvm_arch_put_registers(CPUState *cpu, KvmPutState level, Error **errp); =20 int kvm_arch_get_default_type(MachineState *ms); =20 diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 4f769d69b38..0d57081e69f 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -2123,7 +2123,7 @@ static int kvm_arch_put_sve(CPUState *cs) return 0; } =20 -int kvm_arch_put_registers(CPUState *cs, int level, Error **errp) +int kvm_arch_put_registers(CPUState *cs, KvmPutState level, Error **errp) { uint64_t val; uint32_t fpr; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index e40e374b046..309f043373c 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -3924,7 +3924,7 @@ static void kvm_init_msrs(X86CPU *cpu) assert(kvm_buf_set_msrs(cpu) =3D=3D 0); } =20 -static int kvm_put_msrs(X86CPU *cpu, int level) +static int kvm_put_msrs(X86CPU *cpu, KvmPutState level) { CPUX86State *env =3D &cpu->env; int i; @@ -5044,7 +5044,7 @@ static int kvm_get_apic(X86CPU *cpu) return 0; } =20 -static int kvm_put_vcpu_events(X86CPU *cpu, int level) +static int kvm_put_vcpu_events(X86CPU *cpu, KvmPutState level) { CPUState *cs =3D CPU(cpu); CPUX86State *env =3D &cpu->env; @@ -5287,7 +5287,7 @@ static int kvm_get_nested_state(X86CPU *cpu) return ret; } =20 -int kvm_arch_put_registers(CPUState *cpu, int level, Error **errp) +int kvm_arch_put_registers(CPUState *cpu, KvmPutState level, Error **errp) { X86CPU *x86_cpu =3D X86_CPU(cpu); int ret; diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c index e5ea2dba9da..4e4f4e79f64 100644 --- a/target/loongarch/kvm/kvm.c +++ b/target/loongarch/kvm/kvm.c @@ -325,7 +325,7 @@ static int kvm_loongarch_get_csr(CPUState *cs) return ret; } =20 -static int kvm_loongarch_put_csr(CPUState *cs, int level) +static int kvm_loongarch_put_csr(CPUState *cs, KvmPutState level) { int ret =3D 0; CPULoongArchState *env =3D cpu_env(cs); @@ -763,7 +763,7 @@ int kvm_arch_get_registers(CPUState *cs, Error **errp) return ret; } =20 -int kvm_arch_put_registers(CPUState *cs, int level, Error **errp) +int kvm_arch_put_registers(CPUState *cs, KvmPutState level, Error **errp) { int ret; static int once; diff --git a/target/mips/kvm.c b/target/mips/kvm.c index 450947c3fa5..912cd5dfa0e 100644 --- a/target/mips/kvm.c +++ b/target/mips/kvm.c @@ -590,7 +590,7 @@ static void kvm_mips_update_state(void *opaque, bool ru= nning, RunState state) } } =20 -static int kvm_mips_put_fpu_registers(CPUState *cs, int level) +static int kvm_mips_put_fpu_registers(CPUState *cs, KvmPutState level) { CPUMIPSState *env =3D cpu_env(cs); int err, ret =3D 0; @@ -749,7 +749,7 @@ static int kvm_mips_get_fpu_registers(CPUState *cs) } =20 =20 -static int kvm_mips_put_cp0_registers(CPUState *cs, int level) +static int kvm_mips_put_cp0_registers(CPUState *cs, KvmPutState level) { CPUMIPSState *env =3D cpu_env(cs); int err, ret =3D 0; @@ -1177,7 +1177,7 @@ static int kvm_mips_get_cp0_registers(CPUState *cs) return ret; } =20 -int kvm_arch_put_registers(CPUState *cs, int level, Error **errp) +int kvm_arch_put_registers(CPUState *cs, KvmPutState level, Error **errp) { CPUMIPSState *env =3D cpu_env(cs); struct kvm_regs regs; diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 2521ff65c6c..cd60893a17d 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -907,7 +907,7 @@ int kvmppc_put_books_sregs(PowerPCCPU *cpu) return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_SREGS, &sregs); } =20 -int kvm_arch_put_registers(CPUState *cs, int level, Error **errp) +int kvm_arch_put_registers(CPUState *cs, KvmPutState level, Error **errp) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 187c2c9501e..75ca3fb9fd9 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1369,7 +1369,7 @@ int kvm_riscv_sync_mpstate_to_kvm(RISCVCPU *cpu, int = state) return 0; } =20 -int kvm_arch_put_registers(CPUState *cs, int level, Error **errp) +int kvm_arch_put_registers(CPUState *cs, KvmPutState level, Error **errp) { int ret =3D 0; =20 diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 491cc5f9756..916dac1f14e 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -468,7 +468,7 @@ static int can_sync_regs(CPUState *cs, int regs) #define KVM_SYNC_REQUIRED_REGS (KVM_SYNC_GPRS | KVM_SYNC_ACRS | \ KVM_SYNC_CRS | KVM_SYNC_PREFIX) =20 -int kvm_arch_put_registers(CPUState *cs, int level, Error **errp) +int kvm_arch_put_registers(CPUState *cs, KvmPutState level, Error **errp) { CPUS390XState *env =3D cpu_env(cs); struct kvm_fpu fpu =3D {}; --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449252; cv=none; d=zohomail.com; s=zohoarc; b=eGISGUUiqDLheM5GLcsMMs1Pjp+ffdsFkqoewPSfnSI3d+D9ogaWhSRhB8KFkoe37JeGxYKbeZU4FSZWksMne1X2P6HTyGqz/OW2zQOA8m/VAmYQxZ0JTgI20kgII3G+8croWkRoaCYXon+80lNwNEn8f3ql7O9lXVgjAVeELJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449252; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RqD/1IAJB4FUzAxd+H8ERosOQw0rg1wSHVlzec/yl84=; b=ngC2OGt0USilF70/2Nh+Zq3Fy7YhSFUSRPLMSsvph5Wg/6gagScqCuDfbAaZXFrhi0rjQlqAwXqjh+YzcMiaY8ie6qJgBbUq/oFpOXRjR9d/Ua8yWL4q8QWDz1e9E4hGjWa5m0azheBSvOV2gI8XOTdcJ9a1JpkOFgWy4cKBFx0= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449252332283.7095771187601; Tue, 14 Oct 2025 06:40:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEM-0005ss-Aa; Tue, 14 Oct 2025 09:38:22 -0400 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 1v8fEC-0005e4-Vs for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fE7-00015s-QK for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:12 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-JEAksl3HPeq7Z53Nlf5oxQ-1; Tue, 14 Oct 2025 09:38:03 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-46e3d43bbc7so31581815e9.2 for ; Tue, 14 Oct 2025 06:38:03 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fb49d03e2sm243126265e9.19.2025.10.14.06.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RqD/1IAJB4FUzAxd+H8ERosOQw0rg1wSHVlzec/yl84=; b=f1vBUh6UH399utPxJHJF+tXLf4X4Hqo5V5krMrPAVoFwZ4WDq/F6z3CAWtojoSh2a0C+Rx qNKcSpeiM6RI+0klHbHkDGYpazxsLQM5mNMFsAoq57ln4LQlHJDRZZbbRPfggXn2XwNV12 SUQIPoW/zbTpgx5O5aBkGdruoItJUHE= X-MC-Unique: JEAksl3HPeq7Z53Nlf5oxQ-1 X-Mimecast-MFC-AGG-ID: JEAksl3HPeq7Z53Nlf5oxQ_1760449082 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449081; x=1761053881; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RqD/1IAJB4FUzAxd+H8ERosOQw0rg1wSHVlzec/yl84=; b=Pmw9j3916kaO1u63r1Gl1QbiQru1LCRNJ9KzH3+YVqBL+QjspJ1NUYdvrDuasrytj1 WV7pS5c8n4vAeainK0Ao4oFeNeITwCD6GhiSft6IJCgAMfD11vrdZOqfc+lnMbX58hDw 7blQ7ET9zXTX2fQeXB1kG/bsnmRD0zyNbJ9Zv+2yACaF2D6+bEoY8gsy3u2Sl2mOLdUZ GxcvmaG2RP4IfdiGc09X8ClxfAjyI0J7WZVKdNXjRlRkbDVUzID/ou8rh77ZxPB7ZkH+ UtFuikO22f+WnvUQnmw7oXSmCsJrbYfhFgEpyKgEB0ITKDxNwLQ445fqQm6F3DkdxcXl VIGw== X-Gm-Message-State: AOJu0YyOqh4RoRj97Yf6MzdgEEp498QDZSXMm8S7kjYbK2jEdT1kEjE1 eENdHYfgKoxncmzDG5iKCZ98BqYeCOf73SypAoc2QtZtMRvPW0qoIJXxVcOVp6r99ntTeSNTGx+ OK77yrS45rbnec54LmkJGfFLvNTT8muNyYDZxjJaTHdMlsAWLVsNaKYDMRxblRMVdwdoJXX9mhS ywKGD4gHGesqFHXUHTib/8Tv3AiiQ359pF9oNISxT8 X-Gm-Gg: ASbGncsrQV1KI4np1HBh4K+mmXfhAUsKtNLzuxp8cobCWmA/33226ax68WWF8NDZrYL XkzBLB2INj0y/Rpk2Q0FUGp7KgCPsnNAAdQWOROHGUBbiR0mIz9QeV+0Xz8NjDENdKo0R1MgmRB c6kvYQL3xid+nRm/EQ2f6nSWc6o1ZOHRSg7IemrXrphjQtsn+JIlmgZob0Liusz2o2UCh7tn1Gr NRgmZaVEOFcq+z34Z868DvDuOmbKkcfzdDTuUuKSpjbjJxAovpCBiJlcJffaotcwcqaFEGhLdDC kf06+undwPfgtRmqSkyu8cpwr3+w0jWyQyfwLHYjsXPCNvaSuuBE31ObufoauJio7qtXVHHOJSR FJOz/CMHgb4TrctRWezjGeji2At6qd8CtLQ03CKo8fU8= X-Received: by 2002:a05:600c:19d2:b0:45d:84ca:8a7 with SMTP id 5b1f17b1804b1-46fa9a96712mr158389015e9.14.1760449081054; Tue, 14 Oct 2025 06:38:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUIyhryfSs+RE6qwpAkvKUb5CHomkwwPjEP8qM2wMByAzDu26dIUB1nqsXCUJArXjKWPa0PA== X-Received: by 2002:a05:600c:19d2:b0:45d:84ca:8a7 with SMTP id 5b1f17b1804b1-46fa9a96712mr158388765e9.14.1760449080632; Tue, 14 Oct 2025 06:38:00 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 18/28] accel/kvm: Factor kvm_cpu_synchronize_put() out Date: Tue, 14 Oct 2025 15:37:03 +0200 Message-ID: <20251014133713.1103695-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449259253158500 From: Philippe Mathieu-Daud=C3=A9 The same code is duplicated 3 times: factor a common method. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Link: https://lore.kernel.org/r/20251008040715.81513-4-philmd@linaro.org Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 47 ++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 58802f7c3cc..56031925c4e 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2937,22 +2937,32 @@ void kvm_cpu_synchronize_state(CPUState *cpu) } } =20 -static void do_kvm_cpu_synchronize_post_reset(CPUState *cpu, run_on_cpu_da= ta arg) +static bool kvm_cpu_synchronize_put(CPUState *cpu, KvmPutState state, + const char *desc) { Error *err =3D NULL; - int ret =3D kvm_arch_put_registers(cpu, KVM_PUT_RESET_STATE, &err); + int ret =3D kvm_arch_put_registers(cpu, state, &err); if (ret) { if (err) { - error_reportf_err(err, "Restoring resisters after reset: "); + error_reportf_err(err, "Restoring resisters %s: ", desc); } else { - error_report("Failed to put registers after reset: %s", + error_report("Failed to put registers %s: %s", desc, strerror(-ret)); } - cpu_dump_state(cpu, stderr, CPU_DUMP_CODE); - vm_stop(RUN_STATE_INTERNAL_ERROR); + return false; } =20 cpu->vcpu_dirty =3D false; + + return true; +} + +static void do_kvm_cpu_synchronize_post_reset(CPUState *cpu, run_on_cpu_da= ta arg) +{ + if (!kvm_cpu_synchronize_put(cpu, KVM_PUT_RESET_STATE, "after reset"))= { + cpu_dump_state(cpu, stderr, CPU_DUMP_CODE); + vm_stop(RUN_STATE_INTERNAL_ERROR); + } } =20 void kvm_cpu_synchronize_post_reset(CPUState *cpu) @@ -2966,19 +2976,9 @@ void kvm_cpu_synchronize_post_reset(CPUState *cpu) =20 static void do_kvm_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_dat= a arg) { - Error *err =3D NULL; - int ret =3D kvm_arch_put_registers(cpu, KVM_PUT_FULL_STATE, &err); - if (ret) { - if (err) { - error_reportf_err(err, "Putting registers after init: "); - } else { - error_report("Failed to put registers after init: %s", - strerror(-ret)); - } + if (!kvm_cpu_synchronize_put(cpu, KVM_PUT_FULL_STATE, "after init")) { exit(1); } - - cpu->vcpu_dirty =3D false; } =20 void kvm_cpu_synchronize_post_init(CPUState *cpu) @@ -3168,20 +3168,11 @@ int kvm_cpu_exec(CPUState *cpu) MemTxAttrs attrs; =20 if (cpu->vcpu_dirty) { - Error *err =3D NULL; - ret =3D kvm_arch_put_registers(cpu, KVM_PUT_RUNTIME_STATE, &er= r); - if (ret) { - if (err) { - error_reportf_err(err, "Putting registers after init: = "); - } else { - error_report("Failed to put registers after init: %s", - strerror(-ret)); - } + if (!kvm_cpu_synchronize_put(cpu, KVM_PUT_RUNTIME_STATE, + "at runtime")) { ret =3D -1; break; } - - cpu->vcpu_dirty =3D false; } =20 kvm_arch_pre_run(cpu, run); --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449291; cv=none; d=zohomail.com; s=zohoarc; b=Jfkho4t2kqGPBHciFr6EPOV2ZGHGFH3IOGRCbvej1SqDqboJsV3QlluPY38R8greENmSnIkmopnT72swEx4/VS2aC/TW7QTw2S3sSqrLQ/XP6Z5CJfQVBXB3EgkSK2yD7bp2Sxde3G67hl87PkOBtYO38NQ55++bwGxVqTwo5fg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449291; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kBi6nmZqJdl0va4wx3o6PVk2Le5zxB7N8Bp43lI1p0c=; b=iz6r3zA+l9h55jKhoO89SY1GNYaUqNVNdoStrLXdk+gr7gYf/exEvxJ4SVgG4rY0sMdYnlVonpeqwPsLZcI7Zpf/HNX+Bp4y+1kG1oLTzictlmTPGeX4zPQIZTAy2XCVBiFhc95aUByOsevC3kTKiV4pUh/pmnBg8fk+ISPxf+I= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449291566150.79547777976927; Tue, 14 Oct 2025 06:41:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEZ-0005wz-Hi; Tue, 14 Oct 2025 09:38:36 -0400 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 1v8fEQ-0005v2-6g for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fEG-00016j-7d for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:25 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-63-LxZcPUZeMAudoUD4ElL2vA-1; Tue, 14 Oct 2025 09:38:11 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3f7b5c27d41so3568922f8f.0 for ; Tue, 14 Oct 2025 06:38:10 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426e6f03a76sm8232563f8f.36.2025.10.14.06.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449092; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kBi6nmZqJdl0va4wx3o6PVk2Le5zxB7N8Bp43lI1p0c=; b=OonwqXN0Vb/ZuQIkI6VPZa30tQUesJ0lAeB/9wdw4FkeDujDxSlF4grcw5YCQ017SaKnk2 WLDJzMlC/khnAW2apOjks/DyTJ98BQMmJBe6iolG5/WjrHvNxijeQ0+hHg6R7t27k97/Oc paMYf5kIHprf5j0esfbzUlqA1hBZsxo= X-MC-Unique: LxZcPUZeMAudoUD4ElL2vA-1 X-Mimecast-MFC-AGG-ID: LxZcPUZeMAudoUD4ElL2vA_1760449090 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449089; x=1761053889; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kBi6nmZqJdl0va4wx3o6PVk2Le5zxB7N8Bp43lI1p0c=; b=maZQn18A+xPTtAdfbqYnGUJv0FDgojfoSpwIfGu4b95nEda/L8Lm+inJjQxjl6kae2 K7pVU0rJSw+vheHIlMHABmJkHW3rrH2ZWUYO9qGodAbKISPI3R8ebRSUYkdO1vkTnfum wRLWGfJnQdLr7YYb5HNL9JYhUtM6+ucJDvJsKWlh45dCdQJhR54przx8Um6idq5mBkGJ mG+JVYrA/wYQ0KYDZ51A1rN53O29DD/EWtYGM+RHKxD9TUAkL+WMTQpouEvcqYcRVBYl vCcqOVc53s+E8CFv/gdR9Rf4izV+d7pr/UHK+OshN3zj5PO14OfCSwp+tJiPjhQXDbbK Yhew== X-Gm-Message-State: AOJu0YyKKve83HwpBd7UbkwJWZM392Qww3aVDy1TaU77mgOAN4g6Dtzp 3R+HdLNKvGk0AZRkSmrkKXiABwIjIuAGQFbHr6OdYY7rXzsECRNRHoID8M3oM0eDlckSGno5hbN cA1ngm2aHnGJbdml5SJUqNsfNojrXv8+4/mOaPHQ/3LUMS68Xcp2qzwjYjoccNSmHtFAPYmA1iz ItJqNj9byk4ofloBHc/RlkWQ3gYVnfNwMWmIFZEcV4 X-Gm-Gg: ASbGncu7reZI1y1VYhZ5+2yy0Jah3RAYwDM0bFCAJStJg815hpiJxPJH1+r1x2YDhDG UipMqaO4sVRflzTUI/EAEbckCUO1qfhJ9l6NlQII97u2uCV72yPnZR6bMIA5XFfOm5/OUmlRVvj n4sBd3etT6WTjCBBokqDj/xvAhAA7Wq0NREh8sQK9rwEjrfT44/znICF2JKDB2pkAwu+IEVEIMu KYzPQVdm/PbQwDXtKlROZizcihXnFCvfnNY+5I4tHxkZqvCr4Of38unlu7nqY7Mt4N5ep9XEPzh zqlBIW+3PEVchOy8s4PgsQ23qi/Y+hIOWEODTpnQ2H+ZKPGPG7PikZKPmWhKeUYXUSyAT9BY8Yx 97DfOt35KYI0rROkaZNfVp2dvOIXvNtu8lw0dlNrx6rU= X-Received: by 2002:a5d:5f53:0:b0:426:f4b4:f0fb with SMTP id ffacd0b85a97d-426f4b4f100mr42772f8f.2.1760449089230; Tue, 14 Oct 2025 06:38:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExh928QlKDojRECS/IuS2gYFM/lyLxAFd/QuloiaqyyRe7Ns/6uwaNv8KHSkWFvNaaf8LvTA== X-Received: by 2002:a5d:5f53:0:b0:426:f4b4:f0fb with SMTP id ffacd0b85a97d-426f4b4f100mr42406f8f.2.1760449082967; Tue, 14 Oct 2025 06:38:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 19/28] rust: bql: add BqlRefCell::get_mut() Date: Tue, 14 Oct 2025 15:37:04 +0200 Message-ID: <20251014133713.1103695-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449295653158500 Content-Type: text/plain; charset="utf-8" This method is rarely useful in QEMU due to the pervasiveness of shared references, but add it for when a &mut BqlRefCell<> is used. Signed-off-by: Paolo Bonzini --- rust/bql/src/cell.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rust/bql/src/cell.rs b/rust/bql/src/cell.rs index 24ab294b60d..54cfe6145c5 100644 --- a/rust/bql/src/cell.rs +++ b/rust/bql/src/cell.rs @@ -580,6 +580,23 @@ pub fn borrow_mut(&self) -> BqlRefMut<'_, T> { } } =20 + /// Returns a mutable reference to the underlying data in this cell, + /// while the owner already has a mutable reference to the cell. + /// + /// # Examples + /// + /// ``` + /// use bql::BqlRefCell; + /// + /// let mut c =3D BqlRefCell::new(5); + /// + /// *c.get_mut() =3D 10; + /// ``` + #[inline] + pub const fn get_mut(&mut self) -> &mut T { + self.value.get_mut() + } + /// Returns a raw pointer to the underlying data in this cell. /// /// # Examples --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449257; cv=none; d=zohomail.com; s=zohoarc; b=Cdc9diJG6iCj7P2YSRhyBpMQ4yvtM3GULfh1Of6BGvHAjAxWdpiY5zogoN6CUS4OZUS8w0CsjTGDZtZvI2vXc+92fB76j3BRoNMChOiV/gwpFjGegOtGGxM0bl37uR9aHnmt0paNLHa9AQjOEfeGJa7EESuxlwyb6B8Nm6x1DgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449257; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xa/WqT0YQ5aqnmYvdDBWwUo/98Zjo9UlKye5iKQIlwk=; b=V60j693OtgIKGOPzYUdntPf8gqaNYf0gtQyKGYrZM76Y/t9+wI2b5wMebpBkyQs7oQqtbpoPpRJXkVXKwtHiXvMbA4RSUmppm5PCwweVt9j8c6IwCvwmdKUrJ719Q5oueO9E03uLdwqQtyakJCKRMC0dVWf4sX6xk35ktVcj4q4= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449257067691.3623639104468; Tue, 14 Oct 2025 06:40:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEP-0005tX-S0; Tue, 14 Oct 2025 09:38:25 -0400 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 1v8fEN-0005t6-3B for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fEG-00016y-NL for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:22 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-684-PHH_l4XpOfypFNMXdrorng-1; Tue, 14 Oct 2025 09:38:14 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46e47d14dceso30834625e9.2 for ; Tue, 14 Oct 2025 06:38:13 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e1024sm23587864f8f.42.2025.10.14.06.38.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:38:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449095; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xa/WqT0YQ5aqnmYvdDBWwUo/98Zjo9UlKye5iKQIlwk=; b=IgU3QsHf2U4ifurPBqR9WuSz7xg9lXKVHVZkC1mUctalrS1/IIOt524csLuZeCPtADlhJW P5s7bTQdQIYqJhh5cWf2FBy2M+Ap5iVOnHe1mLxD0n2yusEcRoI2Bf3KKfpoFJNmaHZY3N r7VFXDKxZwxHIiFpiNAYzN13391PY9c= X-MC-Unique: PHH_l4XpOfypFNMXdrorng-1 X-Mimecast-MFC-AGG-ID: PHH_l4XpOfypFNMXdrorng_1760449093 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449091; x=1761053891; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xa/WqT0YQ5aqnmYvdDBWwUo/98Zjo9UlKye5iKQIlwk=; b=fCIcXHnqU8S2o/jibicl9qsTHVFI5jKck0e70zR3Pwbnttgg5/wf9Lp0P/1DfNQ91y pFc14nKbKhVA5XQX1m7mSrdEXwzzUieSx2WEDD67l/bZSd9N+k1WRGr02dctNt5/B4pk oSOvui3sSSnKvKc4updyioswBUHybbx3Pd9Ukgn9RTd58H8AZUegVDI5sKShpdk/Ugyf 0/+TqOtcYZSLZsVvXD1Zr5O+kiPlLgZmHzKXiwraUTrPK3GxTDh7TIWkZ80bnNs6xFxo zCo5FezO8LdKza149JCtqaI/+OWuOPWVTWT1O1NeoBxG+ptsJedv8izKFtmtcsdPOjBa QRhw== X-Gm-Message-State: AOJu0YzCtDi81F7eDFFIV7sWopuaGAa8RlYiDOfX3Qnz+j92UIVMUH3b ByX9dwHwtDiLLiXmp4fRanpKemiLXL+knFqpqUu/9ulhJ8hJ36hOENK1i2w2U48bP8st3LdRigH x6J1Ju+GwcElBeA4q8g/MCY24QJh3u/+0y7zh3+BGAE5pUgJWph8+/sDqCk85ISC7CdZOv8AEfl o242QtLnFXkDmQ0r6ZauBpt+1NSUEc41GJPwWxWfFE X-Gm-Gg: ASbGncvNstQNzjWNHcYLlu1GN9+cK3TyzbR8WJaCW9pTsFmhIMZKr72vvO0DqjpWS8q 1o8EX814PiWyiRFQ20pRmS25ZTDnWhI0FN/7cfcbYWH2rDqmfxIAg2xLbm1PFOePl2S+eJem+K9 2NLdcnoz2XW8B1ajcRujIqCeW7W/V2f4Kj0QWMQJes2cxPLd0w3eaU6UQXGOBylrHBRxNkWDz88 JsF0+xhvL+ogdKeGaJrI780UagmGxjLba5xlPhF+dZfmW3KpgMy8NzwX3h7mFWqGxiacWOvDZmY +vPuIaoef/WQ7ccVQ/z/JqAmYaSvTSNth1O4g7KJTYBpYAMdb+9PAEpsiQ65XoVb/Ky+8iUvXd9 w5AOjU176LPQycu2m6t+b5V/RgFqop7EfMtfYbcrRfaU= X-Received: by 2002:a05:600c:6487:b0:46e:39e1:fc27 with SMTP id 5b1f17b1804b1-46fa9a8f0cemr160878715e9.5.1760449090997; Tue, 14 Oct 2025 06:38:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEmnR9yxFYmZ+ykpFC86rSk7rhuXi1POD3hloDWO1FImA+qcYW83S8RGrFU2CHfGy7/L1FIw== X-Received: by 2002:a05:600c:6487:b0:46e:39e1:fc27 with SMTP id 5b1f17b1804b1-46fa9a8f0cemr160878475e9.5.1760449090516; Tue, 14 Oct 2025 06:38:10 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Zhao Liu Subject: [PULL 20/28] rust: migration: do not pass raw pointer to VMStateDescription::fields Date: Tue, 14 Oct 2025 15:37:05 +0200 Message-ID: <20251014133713.1103695-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449263247158500 Content-Type: text/plain; charset="utf-8" Pass a slice instead; a function that accepts a raw pointer should arguably be declared as unsafe. But since it is now much easier to forget vmstate_fields!, validate the value (at least to some extent) before passing it to C. (Unfortunately, doing the same for subsections would require const ptr::is_null(), which is only stable in Rust 1.84). Suggested-by: Zhao Liu Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/migration/src/vmstate.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index 5f5708ad39e..2e320262f06 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -425,7 +425,7 @@ macro_rules! vmstate_fields { ..::common::zeroable::Zeroable::ZERO } ]; - _FIELDS.as_ptr() + _FIELDS }} } =20 @@ -677,8 +677,11 @@ pub const fn unplug_pending FnCall<(&'a T,)= , bool>>(mut self, _f: &F) } =20 #[must_use] - pub const fn fields(mut self, fields: *const VMStateField) -> Self { - self.0.fields =3D fields; + pub const fn fields(mut self, fields: &'static [VMStateField]) -> Self= { + if fields[fields.len() - 1].flags.0 !=3D VMStateFlags::VMS_END.0 { + panic!("fields are not terminated, use vmstate_fields!"); + } + self.0.fields =3D fields.as_ptr(); self } =20 --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449327; cv=none; d=zohomail.com; s=zohoarc; b=bYRMo0eTi/az5lLBw8oNPUjUOFcD76SZrOl0LyjCqnYi3uSmr7vF/aJsBX3K1IxrYZ6suC7zHO2d7MfWmS6HAM+FUbwVP6ZnnvWHqCmUlimjAxIUm8ZhFVtd5HlzhUm5jWfbQWGKCpi7cAg3um71xyrW2cNCkIl0Jpo9HfMf7rg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449327; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2MMGynjhv4WBBo4X3LLy26Qc6OUsNSBvfImlI2mQ1Zo=; b=X8aZD9QD0H7laFA1VanFTbnTjZQYXJ9O/Kb49Pk8j1sy8DWp9mmFhqDdhjv1Qrhluf/7Wdagx/nU064Tq9/TG3seufQvDviaehcNUhf7geTavb8QqErvrgtVAgx7Wg6bD2np1CDgkGsnns9P60WAgq0TDK/n2KXmHgLuV848q2E= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176044932735282.3595880421866; Tue, 14 Oct 2025 06:42:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEc-000649-V7; Tue, 14 Oct 2025 09:38:39 -0400 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 1v8fES-0005vu-Ud for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fEP-00017i-Uw for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:28 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-269-Yh28bZIyOPae2M_lwAxBfQ-1; Tue, 14 Oct 2025 09:38:17 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3f924ae2a89so6288381f8f.3 for ; Tue, 14 Oct 2025 06:38:16 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5cf71dsm22921264f8f.29.2025.10.14.06.38.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2MMGynjhv4WBBo4X3LLy26Qc6OUsNSBvfImlI2mQ1Zo=; b=YmywTNhQzuCM6mziiy/qSFULs8xDke3EHAJStC6B3qMvNXsM+ijGFUTmFwkVG2xHlwAeJO eCv/o+DpyadHhLdjFmbjeAD0z4PYkPqdxkI+NmZ6hFPY+4ybVRtLlxJNpLQIQzExiJEDUf RpTQ6TM8NB37hy06lX1MmrAQXawt10s= X-MC-Unique: Yh28bZIyOPae2M_lwAxBfQ-1 X-Mimecast-MFC-AGG-ID: Yh28bZIyOPae2M_lwAxBfQ_1760449096 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449095; x=1761053895; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2MMGynjhv4WBBo4X3LLy26Qc6OUsNSBvfImlI2mQ1Zo=; b=R2pD7qk7EsjomlV9NhHEUBAWtW4imPdQ22acVP6pQMg/EmBVgnvdzY3n/XroTJXmZg v4NfRFtHN7OJBblbCwizw5yzHDVcfjBSuaKkEKEs3AqG+Lh67FJh6pFvAROuwuTz/8mJ aj9rJP6PfGmxgY5zRPfgv0ZHNNgeRF9OvH0NcWQ5mlMZIwElDYjdZUeRa3ycE1OkwLm7 9twXGF1KX1o3SC5NoWwmKYs1VApcl/BTSBJC5nOQEmOW7MGsLRC6+O063DNI87au4XJ5 KpPoWPgEoCvexINmg8yD8f4Td02p8gJyPzjC1+9We2yrd//kSFlrHbBOVvckkhp0bx+2 g+qg== X-Gm-Message-State: AOJu0YzK6SCJ1YCB37x8mHWstOJwd4aKn/OYgpHO1D4UMY4UOQTlLJEI FV2YTVMDIFtnDtlYOY+ZyNZ7L3o9V6gK3C/SlbUzbQOAd9/NtUTM/nU0urm+zBt2bv1iSRanhdb R7WqKVbuPwrK/ZziVFrpsOakdKimZD9WB94W4yhtpG8fR5L6Ta1EWnvNpdsQBtTxeKwY0T04vdw 1UvmISnb43gvy2rvXg1g+9w9GJWRWwedJZyjtRx/jd X-Gm-Gg: ASbGnctsa7kGcApW6CQ6nnrXkW+/SCECniTpFiwTN4+UCBCAr2Gokn7VAs4QiFwq3qb G+fmGzp1IB3UUNVkasb0tQ6APrRLMa30V8ZrVfY7uNypwNQjI/sVDmiJaQI/P1gRlyyUBc3R4sd E3zgYYyRPPdaLUkVkTgmw1oKBPm3uxA0P+1mbVWucGUbpp5sXVrwz4zCqKsILalShp0qsgqbyX+ 7o64cQU6UNx0O9JxW4ioYJxA7zXVVknKBRoAsMSWebe54VwcjQBWPUK449rRV/7aEqeqCkuwWg+ deCufQX1BbRNhDFSHIcZbl3ySaDW3sNCtPV3yAcoOYa26ddSgEBngM6M4Vk+zaKlFlBf2ZftoM7 I5VNHEIv3vmGxtbzQo4lqxGq9uHsjYKQcYEygX3HIN/Q= X-Received: by 2002:a05:6000:2305:b0:3e9:b7a5:5dc9 with SMTP id ffacd0b85a97d-4266e7d6bb2mr15176857f8f.23.1760449094742; Tue, 14 Oct 2025 06:38:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdoYEj4wak2TUf2VQqLGs++zrvAZKV8Pl801kp0Bfg4H90QZFAghMtUeaDV2ZzYb8hWULXaQ== X-Received: by 2002:a05:6000:2305:b0:3e9:b7a5:5dc9 with SMTP id ffacd0b85a97d-4266e7d6bb2mr15176842f8f.23.1760449094265; Tue, 14 Oct 2025 06:38:14 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Zhao Liu Subject: [PULL 21/28] rust: migration: do not store raw pointers into VMStateSubsectionsWrapper Date: Tue, 14 Oct 2025 15:37:06 +0200 Message-ID: <20251014133713.1103695-21-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449329346154100 Content-Type: text/plain; charset="utf-8" Raw pointers were used to insert a NULL one at the end of the array. However, Option<&...> has the same layout and does not remove Sync from the type of the array. As an extra benefit, this enables validation of the terminator of the subsection array, because is_null() in const context would not be stable until Rust 1.84. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/migration/src/vmstate.rs | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index 2e320262f06..a6ee7e93853 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -470,33 +470,21 @@ unsafe impl $crate::vmstate::VMState for $type { }; } =20 -/// A transparent wrapper type for the `subsections` field of -/// [`VMStateDescription`]. -/// -/// This is necessary to be able to declare subsection descriptions as sta= tics, -/// because the only way to implement `Sync` for a foreign type (and `*con= st` -/// pointers are foreign types in Rust) is to create a wrapper struct and -/// `unsafe impl Sync` for it. -/// -/// This struct is used in the -/// [`vm_state_subsections`](crate::vmstate_subsections) macro implementat= ion. -#[repr(transparent)] -pub struct VMStateSubsectionsWrapper(pub &'static [*const crate::bindings:= :VMStateDescription]); - -unsafe impl Sync for VMStateSubsectionsWrapper {} +/// The type returned by [`vmstate_subsections!`](crate::vmstate_subsectio= ns). +pub type VMStateSubsections =3D &'static [Option<&'static crate::bindings:= :VMStateDescription>]; =20 /// Helper macro to declare a list of subsections ([`VMStateDescription`]) /// into a static and return a pointer to the array of pointers it created. #[macro_export] macro_rules! vmstate_subsections { ($($subsection:expr),*$(,)*) =3D> {{ - static _SUBSECTIONS: $crate::vmstate::VMStateSubsectionsWrapper = =3D $crate::vmstate::VMStateSubsectionsWrapper(&[ + static _SUBSECTIONS: $crate::vmstate::VMStateSubsections =3D &[ $({ static _SUBSECTION: $crate::bindings::VMStateDescription = =3D $subsection.get(); - ::core::ptr::addr_of!(_SUBSECTION) + Some(&_SUBSECTION) }),*, - ::core::ptr::null() - ]); + None, + ]; &_SUBSECTIONS }} } @@ -686,8 +674,9 @@ pub const fn fields(mut self, fields: &'static [VMState= Field]) -> Self { } =20 #[must_use] - pub const fn subsections(mut self, subs: &'static VMStateSubsectionsWr= apper) -> Self { - self.0.subsections =3D subs.0.as_ptr(); + pub const fn subsections(mut self, subs: &'static VMStateSubsections) = -> Self { + let subs: *const Option<&bindings::VMStateDescription> =3D subs.as= _ptr(); + self.0.subsections =3D subs.cast::<*const bindings::VMStateDescrip= tion>(); self } =20 --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449221; cv=none; d=zohomail.com; s=zohoarc; b=nzOQ3MMemFDZMNlwixsRHFJ1OO3mTw19p0pGnMXo3KbtK6dIGwuDPlKCnmPI5ylhT/4F+Ah6SfVoPombazBjivwOBBmnA6VJT1zmKtMDLpxSiGWzlNo1ZkiuTPBSgnlkvM4BLwx8pn2x71OyN/N7eIdcQRa1TtztXt+2La12xKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449221; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DH1bizREULH/WG9xuqrDeS8NQ+ogE+YNguyt7l1zqcg=; b=N44OhOieJAW/7ZEqMkO5HLtqx7/q+e3ZaQ/F5vAtgaqGXA3roZG+zZwBvq7rKnAZPqa4wKuB8LEZjsCYpOzmUP15499ovvJ8ERXE0ZDRmDBJek1Hg1712zpk+q9JxDCWwLwed82bxxblbVFxzXjjlOBxTdeAmmsBs5eVgNeBqTg= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449221852628.2455505148591; Tue, 14 Oct 2025 06:40:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEz-0006rl-AA; Tue, 14 Oct 2025 09:39:01 -0400 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 1v8fEf-0006AH-Ng for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fEV-00018v-AX for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:40 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-38-n59sMFHnNRuoO7IkcmHoxQ-1; Tue, 14 Oct 2025 09:38:22 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e3af78819so27849765e9.1 for ; Tue, 14 Oct 2025 06:38:19 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce583424sm23447160f8f.21.2025.10.14.06.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449107; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DH1bizREULH/WG9xuqrDeS8NQ+ogE+YNguyt7l1zqcg=; b=Lh8/JBh6z6t6SDHz7dyuH6iv5BEFmEBOSsEkAh65STnnZ4ZGkYhtg3EUbWbt6IW0TlR77z H299qm4ZZdv53WFPwUadAtlS0gWJdyxdt7GuE4av/lhw93YmO9ZRnPWPOvKOie8Nmbi+O0 luoQP5p3mHu15QAAaVP+pdLv4eWHLSI= X-MC-Unique: n59sMFHnNRuoO7IkcmHoxQ-1 X-Mimecast-MFC-AGG-ID: n59sMFHnNRuoO7IkcmHoxQ_1760449098 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449097; x=1761053897; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DH1bizREULH/WG9xuqrDeS8NQ+ogE+YNguyt7l1zqcg=; b=YBkMGSbFtrIE/jZmKS0swlpMNuTCXBj7Rc7w9TjRmG5HRXv0RDpJy/mvTDQ6MMss0f RfDX87dPfn5XFC49k0rLNIWt6vIxVRn9upuA9y9DZNnBx5Srx/ErhBQd3EWeinv2A/U7 hwcduRLrrmlpMn+f20OtXyAJ22b7LQbp2zqX6e6bJGfui/mJJUzTAexj+RTJU67j4RY3 AHJed4DKL1onOv8k8PSj2Pc2OTWt8A0xUBzkedUjvv5hFUIrMnApLPNI2upCO6zzJ8SI fRFKDwj7b58R4zxvzEah3fDhGnUFw9axb9B4Re4kODvyD0ubEFimOtJe33d2a0hPq9fY rLiw== X-Gm-Message-State: AOJu0YwFTtEhsZ9feUeR3hLBvA7PCB/GpJ8cBaXl6ovjwTJyRh2bdcn6 Rl3WnulggNjfOcDeyZcB8hf6H0WvWOqRyBXgOD/LuGvHdcqOHHH71+ZAw0pSVvWpvOqEgxSAkJQ NrNNXvoMC23yRa+I7nJ3eOzKzn1PvsVrpOTKc/WI/g0BCe5f1fAUnVyIaP7YNn8wnmRJieHBAfZ G+kyw/NdFINP+c/Q+N1jYHi1YgyU0RxjhM+n/qxDL7 X-Gm-Gg: ASbGncts4VniYrh0Ndryrf4WMUR5wXTOHXKiMYY+rAfsz0AdKr+yiMfpXKdqOXRFGVT FIhbOo9p7n9i+cJ26X+8YUJyKbMeMd+FdKyu11NUvZEbyPaWv9oi4R2kbpqacUBHm6gy+0a4W5z shuTviXyPtwKGqbEax8aIY6iELajdmXQEUjcvNutMyfwHuYo+zqsdQ466xnSDEeQm0ZRHCmmcbk BvvuvYIQmBy+69rs3GkMj/s2ZHgboTLmeT0gWlE1UCXALmQg8LwL0m7P70DsuOmwkF6hRHEN3qO IGF2sUtk9DTwvBaRhKvvB7rA/aMyjRunQPf+zYjUnKo4efMJtU8JOLWw5zGD+DEdrlb63pdGeUJ fvrVixUlCFVoVGtjNJsaZ6XRRYTHnjggwWs7OBbtcf7U= X-Received: by 2002:a05:600c:8505:b0:46e:67c8:729f with SMTP id 5b1f17b1804b1-46fa9a9447cmr171105315e9.7.1760449097312; Tue, 14 Oct 2025 06:38:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYOztwgOT13rvHE2mf5PxBGljnRR/9sEXVPvfu/1TCK5dYzLqcGyUVoCC7ZxX21bxQcSXbfQ== X-Received: by 2002:a05:600c:8505:b0:46e:67c8:729f with SMTP id 5b1f17b1804b1-46fa9a9447cmr171105175e9.7.1760449096929; Tue, 14 Oct 2025 06:38:16 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Zhao Liu Subject: [PULL 22/28] rust: migration: validate termination of subsection arrays Date: Tue, 14 Oct 2025 15:37:07 +0200 Message-ID: <20251014133713.1103695-22-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449233043158500 Content-Type: text/plain; charset="utf-8" For consistency with fields(), validate the value (at least to some extent) before passing it to C. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/migration/src/vmstate.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index a6ee7e93853..6b0f96c4da8 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -675,6 +675,9 @@ pub const fn fields(mut self, fields: &'static [VMState= Field]) -> Self { =20 #[must_use] pub const fn subsections(mut self, subs: &'static VMStateSubsections) = -> Self { + if subs[subs.len() - 1].is_some() { + panic!("subsections are not terminated, use vmstate_subsection= s!"); + } let subs: *const Option<&bindings::VMStateDescription> =3D subs.as= _ptr(); self.0.subsections =3D subs.cast::<*const bindings::VMStateDescrip= tion>(); self --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449195; cv=none; d=zohomail.com; s=zohoarc; b=Hptjt7UQvtMiUT9a6smqheCV//M+ZPP0vrTZU1ACDTTGEvX1JMataFtbZGYsqno2fnvtBVurtuWbHEcdKBQ10MJXQ6raF1YmDMmZrkS403zIAiROi/vs5rpFznhCz5C2j9akTc7KaCumViCibv0mtRH+0czyLj/L2PvPnbputC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449195; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XEG6T/J+GXYTGRUDDa6Uq81qUc1bn8Yy9qgoJUqKqdY=; b=MYU3+KJeJsFBqLMoGZ8dRT3GLZX+GBIKj9B0QK5m9/U9G23tO93jwwBh05HvKTWFCa9QvzulKYfcq9yBxpr/U3aRbIDxJq8jx7M2/NQtlwr7qIXzSYBDGOPHvJXHWgPcw5KPJEH0xMeFKgFgn+1d2zovngnB332sWz3e2GFBZtA= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449195462300.8281732101931; Tue, 14 Oct 2025 06:39:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEw-0006Sy-F0; Tue, 14 Oct 2025 09:38:58 -0400 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 1v8fEW-0005yo-TZ for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fEP-00017p-Ux for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:32 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-81-fLVKrTtqPQigEHydnBO77g-1; Tue, 14 Oct 2025 09:38:21 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-426ce339084so3990461f8f.0 for ; Tue, 14 Oct 2025 06:38:21 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426f2f72e18sm2451882f8f.0.2025.10.14.06.38.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449103; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XEG6T/J+GXYTGRUDDa6Uq81qUc1bn8Yy9qgoJUqKqdY=; b=N6fZQ6UoCB140bSOQNnO2HIZN9n8SHgdikazEf3R07KWUzq1NPELwum4weU3w1Gl2XxIqz qJf+xDLPtxujb9JmrOVdkF4/I6X1icR02GDicun1ZNrYjEEO3aAI6FcklDbR7eGWVSsEHA rYrqwtD4bka+4Wd9nYuEdLFwUAAt31I= X-MC-Unique: fLVKrTtqPQigEHydnBO77g-1 X-Mimecast-MFC-AGG-ID: fLVKrTtqPQigEHydnBO77g_1760449101 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449100; x=1761053900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XEG6T/J+GXYTGRUDDa6Uq81qUc1bn8Yy9qgoJUqKqdY=; b=IymsIWQ8skL3F343935hXtSHr9UkgpIJb6Q+LvzwEj+S9uDQOM5DzoGkz0SKbO1B46 x2OSrXKiTnSAR7VMz9P26qTaqKHYSL+Q5eTT7WPVEfRNifbNJTBNTmST51B3StEwOQ0I RPzmCfU2toCiTQOrfSqrlh8WX3P39k4EmKtwpivqZOi9cP6vIEm3plbYAKq4bAJeEtzH 72B1iNVThCGFMSTipULwbqXwJn6XytMukmLYXHdgIxVATvfFAs8nhujQ47aiNn7FY9d9 V4Cn3UZCWdyOVug8t4Gd20mHU9hcvcDZvu4n4iAf7OpcJzmqUDpwlwYX36BhOTpGntNF 2kLQ== X-Gm-Message-State: AOJu0YxR3EskeIL3NnaFrwXWnuzFoUYzI00CZuUkYPkxT+wNr/G0RWIb 9RkgF/ooTiI1lFQiBh5+7btDX/3oSqVAEe/xSUzZJYpwPXpx3HEl+JHtprzUrZXmKqbiQI6FTdD AhkRaZAJDsqCtTig9YfwznmScOAwtqqCsOj1pKR+u5OBlPMCyKwwUTkY2kycRBb221DvMCW79+2 ssuoFkmKzit0ugOYl8kiqfRVK/X0me4ZhFdlgEcQgx X-Gm-Gg: ASbGnctxuEaJ6OYW2c6TWDypWHYe9p/R+yH58BppapaQgK2eWFmEANkOKeLni3s69B+ KUgz2jg21Ki7oGAyL8vXUJBcsR3Gm0+aYP5MOWBZp9hLWpjrKeR1rsOtMwil8Y4YGUCF8s7M6bO nLx4iUqRE7uTBk+TN5XgNs1KOLLM5nPFMKAjFLExPX3OejqqCLOyqELi61nvX6zMP1A3M5STYLN lgtbD8AsKWdByWExPitA5D0ErKSvTyWhdsSSRsCWwcKalERThu9znDBBnaMbnMDJvqB9OtfTPtq NWzfqTuR0Q0Qlq7SLADRcofHVxZnN7PLi4dJX0dxPbdT9lF94gve+yjeBxAx0CjtNxQlD4RA6jx 1A8+rdIqQLJ+nSLP4ekDu0ul8KCsAN/fmxwOlSlb/yvY= X-Received: by 2002:a05:6000:2906:b0:3eb:c276:a347 with SMTP id ffacd0b85a97d-42666a9700fmr14230901f8f.0.1760449099645; Tue, 14 Oct 2025 06:38:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTr4/jOIqoVUg6CIZOSz1yoksWQovr0g4YZjumlQG5UIWUrzcM99ZEu+9ytfXFqlAVh6Yw1A== X-Received: by 2002:a05:6000:2906:b0:3eb:c276:a347 with SMTP id ffacd0b85a97d-42666a9700fmr14230879f8f.0.1760449099090; Tue, 14 Oct 2025 06:38:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Zhao Liu Subject: [PULL 23/28] rust: migration: extract vmstate_fields_ref Date: Tue, 14 Oct 2025 15:37:08 +0200 Message-ID: <20251014133713.1103695-23-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449197926154100 Content-Type: text/plain; charset="utf-8" This is useful when building a VMState for generic structs, because you have to avoid nested statics. Using vmstate_fields! will fail in the likely case where the _FIELDS static uses Self from an outer item, because that is forbidden. The separate macros are needed because you cannot just do .fields(vmstate_fields_ref! { vmstate_of!(PL011State, clock), }) The value returned by vmstate_fields_ref! is not promoted to static, which = is unfortunate but intentional (https://github.com/rust-lang/rust/issues/60502= ): error[E0716]: temporary value dropped while borrowed --> rust/hw/char/pl011/libpl011.rlib.p/structured/device.rs:743:17 | 738 | / VMStateDescriptionBuilder::::new() 739 | | .name(c"pl011/clock") 740 | | .version_id(1) 741 | | .minimum_version_id(1) 742 | | .needed(&PL011State::clock_needed) 743 | | .fields(vmstate_fields_ref! { | | _________________^ 744 | || vmstate_of!(PL011State, clock), 745 | || }) | ||_________^- argument requires that borrow lasts for `'static` | |_________| | creates a temporary value which is freed while still in use 746 | .build(); | - temporary value is freed at the end of this state= ment Thus it is necessary to use the "static", whether explicitly or hidden by vmstate_fields. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/migration/src/vmstate.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index 6b0f96c4da8..59e665f6c3a 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -412,19 +412,30 @@ const fn phantom__(_: &T) -> ::core::marker::Phant= omData { }}; } =20 +/// Add a terminator to the fields in the arguments, and return +/// a reference to the resulting array of values. +#[macro_export] +macro_rules! vmstate_fields_ref { + ($($field:expr),*$(,)*) =3D> { + &[ + $($field),*, + $crate::bindings::VMStateField { + flags: $crate::bindings::VMStateFlags::VMS_END, + ..::common::zeroable::Zeroable::ZERO + } + ] + } +} + /// Helper macro to declare a list of /// ([`VMStateField`](`crate::bindings::VMStateField`)) into a static and = return /// a pointer to the array of values it created. #[macro_export] macro_rules! vmstate_fields { ($($field:expr),*$(,)*) =3D> {{ - static _FIELDS: &[$crate::bindings::VMStateField] =3D &[ + static _FIELDS: &[$crate::bindings::VMStateField] =3D $crate::vmst= ate_fields_ref!( $($field),*, - $crate::bindings::VMStateField { - flags: $crate::bindings::VMStateFlags::VMS_END, - ..::common::zeroable::Zeroable::ZERO - } - ]; + ); _FIELDS }} } --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449147; cv=none; d=zohomail.com; s=zohoarc; b=UnvwmCPnMSJtnJX3WZAfi6Nl5Lnwn8dYTZTZR7lC70+qq0Dhe6zmX3qLjIb9XElHEq6rdw0cV0jmRPAOAYp3BEresdZaJCu6OosFihENwIvzRi6tsKRjYb4VILjZDOrECez535tJQV5SXvOOWYaJPGLHaN3GHCiYrlzwJEi/zts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449147; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3h9CREHD+hrW6wzadkBuc/EvwxUe2yLhbknJ1TxTLXA=; b=TswxNlaeqrg/cGqCQufrV7zKwTJdcOVQvar8HZJboiMDVFPRdcn2qFa/QsDK5HqLZsKs6llLj+bbEdWg0ueFeKZi9WlsB/kkoaODSf6jcEccoYyGzKXrKTqwYHcweTbk7hOO5DbIxCbiNw1b0GdJMJvVCRtxufFzWfnezqe7Kik= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176044914752015.125786416179267; Tue, 14 Oct 2025 06:39:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEg-0006AG-Dd; Tue, 14 Oct 2025 09:38:43 -0400 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 1v8fEW-0005yX-5k for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fES-00018G-N5 for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:31 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-BJX1KTtsNB2uDEBMzUI7Hg-1; Tue, 14 Oct 2025 09:38:25 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46e4fa584e7so30805625e9.0 for ; Tue, 14 Oct 2025 06:38:24 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fb489197dsm248535045e9.10.2025.10.14.06.38.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:38:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449106; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3h9CREHD+hrW6wzadkBuc/EvwxUe2yLhbknJ1TxTLXA=; b=iplVChRAxuTnV4kuWWxb+0Uh66+1ZggSEVmy5k6tFo9WcIZc/9/zrQtjJMyIXoNq/TyfA+ TduWb9PcG+xzDf0yDlWzEsVY4aTLPDDzqtMWMivz/1CjmMGWa5nmR9zayxu05GU6B0jf9D b5Thkjfkz7yRNbwu2to6IvascihaEew= X-MC-Unique: BJX1KTtsNB2uDEBMzUI7Hg-1 X-Mimecast-MFC-AGG-ID: BJX1KTtsNB2uDEBMzUI7Hg_1760449104 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449102; x=1761053902; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3h9CREHD+hrW6wzadkBuc/EvwxUe2yLhbknJ1TxTLXA=; b=gMWQlzz2AzyL0B19RWRFglKyuUyT575E5V/HSI/MUEal6LcEi+6FtKd5DvVzmgFoP7 m3rRvLFkcVdInqXd+c23LC7oGqEz3M1LgaP2/j5e/XseFvyfW2czcvdmwt3V/bXPBQQH OpKebPL6KLdm6/6fYDQ+kll6U2X/0IHWPtoQQ32cvZXy5oCTJ1vCwIGOdRhbANPNps/z 6Afa2bW3ltZUUJlQy0RRksNuX0BqF4ywwYwnv007Hko8/n8V4jkVOQTux5uEW6Ww7S/P Ncbnd0r/Bib49czOLCLl/eKZXefQs83EZyWmXh2nNynBlfdWpG+6ZBnJXgIFfqZJUr2g iLAw== X-Gm-Message-State: AOJu0Yyhi//Q2Dc4b0yaDSYxxz/02ESH+8qq6z0l56KguN2FnQW/WD61 /jrtSaAt0S55nsvOBxQDwmNyrlxnqMvri5e/GKSSSa3sIU1zVPXRX9Zs7QFnpbKysVMM226bwhU iYBLojVzAfPCQPrWi+W6EIPtvURXKJy8A5Vok6rs0QoHHOwy4UB0qC6DCayA5TjiKiTtel/BQyt e2f3GAuQ8io17/SLCkps/5g62jZkoNQc3uGrZUm/S7 X-Gm-Gg: ASbGnctt8GwLFtXxh0h3m3V2XxEKzSkiUYmKY2PD6HeuKSrrFlUat0pxr0yAYVvXmky W51TbPyWsr1eDTYtS9Ej83Yl7MtQVEjZ97foEMD/VEyX5GGRbw6FFfxGSJQkYDXHvhlirI4KTWv 3tDhUJShFIBwXO9a5BepjymCd0P5OlsOdnv6hvH4TiZc1oT8AzcTO5H+MWmySzTb4nfdVobZIVi YrUm/U3R1GlyrH5M5uBk0alDaU2kozN2EYKTHvWU/C/0JE2MIzoGjwnZpiwyf0AF1OMnCd4aN8u 8tVfJoIKUWMUEMykq1EoMsqW5BcBjDCTzzqELr6XPiotS0874/rL1Y+AjFmvyfFuYEJHnJ9G5kJ 3AOjZm40YrBbPJt+Pnp/8UQyRNivD70ejTUdZ85YZmTU= X-Received: by 2002:a05:600c:3e8d:b0:46d:3a07:73cd with SMTP id 5b1f17b1804b1-46fb409ca81mr127678915e9.23.1760449102381; Tue, 14 Oct 2025 06:38:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGoS9vzCdmARSwdIzPe5BolLkwlUjOwzLaetbBRCGQ4qkcAzfQyfhAo/WzkSDK6omQ2+3hbmg== X-Received: by 2002:a05:600c:3e8d:b0:46d:3a07:73cd with SMTP id 5b1f17b1804b1-46fb409ca81mr127678645e9.23.1760449101797; Tue, 14 Oct 2025 06:38:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Zhao Liu Subject: [PULL 24/28] rust: move VMState from bql to migration Date: Tue, 14 Oct 2025 15:37:09 +0200 Message-ID: <20251014133713.1103695-24-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449154111158500 Content-Type: text/plain; charset="utf-8" The high-level wrapper Migratable will contain a BqlCell, which would introduce a circular dependency betwen the bql and migration crates. Move the implementation of VMState for cells to "migration", together with the implementation for std types. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/Cargo.lock | 2 +- rust/bql/Cargo.toml | 1 - rust/bql/meson.build | 1 - rust/bql/src/cell.rs | 6 ------ rust/meson.build | 2 +- rust/migration/Cargo.toml | 1 + rust/migration/meson.build | 4 ++-- rust/migration/src/vmstate.rs | 2 ++ 8 files changed, 7 insertions(+), 12 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 11085133490..5c2f8ea9240 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -59,7 +59,6 @@ name =3D "bql" version =3D "0.1.0" dependencies =3D [ "glib-sys", - "migration", ] =20 [[package]] @@ -198,6 +197,7 @@ checksum =3D "f52b00d39961fc5b2736ea853c9cc86238e165017= a493d1d5c8eac6bdc4cc273" name =3D "migration" version =3D "0.1.0" dependencies =3D [ + "bql", "common", "glib-sys", "util", diff --git a/rust/bql/Cargo.toml b/rust/bql/Cargo.toml index d5177e5f8e2..8fd81311028 100644 --- a/rust/bql/Cargo.toml +++ b/rust/bql/Cargo.toml @@ -13,7 +13,6 @@ repository.workspace =3D true rust-version.workspace =3D true =20 [dependencies] -migration =3D { path =3D "../migration" } glib-sys.workspace =3D true =20 [features] diff --git a/rust/bql/meson.build b/rust/bql/meson.build index 22d7c9b8776..091372dd7b6 100644 --- a/rust/bql/meson.build +++ b/rust/bql/meson.build @@ -37,7 +37,6 @@ _bql_rs =3D static_library( override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', rust_args: _bql_cfg, - link_with: [_migration_rs], dependencies: [glib_sys_rs], ) =20 diff --git a/rust/bql/src/cell.rs b/rust/bql/src/cell.rs index 54cfe6145c5..8ade7db629c 100644 --- a/rust/bql/src/cell.rs +++ b/rust/bql/src/cell.rs @@ -151,8 +151,6 @@ ptr::NonNull, }; =20 -use migration::impl_vmstate_transparent; - /// A mutable memory location that is protected by the Big QEMU Lock. /// /// # Memory layout @@ -364,8 +362,6 @@ pub fn take(&self) -> T { } } =20 -impl_vmstate_transparent!(crate::cell::BqlCell where T: VMState); - /// A mutable memory location with dynamically checked borrow rules, /// protected by the Big QEMU Lock. /// @@ -691,8 +687,6 @@ fn from(t: T) -> BqlRefCell { } } =20 -impl_vmstate_transparent!(crate::cell::BqlRefCell where T: VMState); - struct BorrowRef<'b> { borrow: &'b Cell, } diff --git a/rust/meson.build b/rust/meson.build index 6ba075c8c71..76e10699b37 100644 --- a/rust/meson.build +++ b/rust/meson.build @@ -29,8 +29,8 @@ subdir('qemu-macros') subdir('common') subdir('bits') subdir('util') -subdir('migration') subdir('bql') +subdir('migration') subdir('qom') subdir('system') subdir('chardev') diff --git a/rust/migration/Cargo.toml b/rust/migration/Cargo.toml index 94504f3625c..b995c4c8c88 100644 --- a/rust/migration/Cargo.toml +++ b/rust/migration/Cargo.toml @@ -13,6 +13,7 @@ repository.workspace =3D true rust-version.workspace =3D true =20 [dependencies] +bql =3D { path =3D "../bql" } common =3D { path =3D "../common" } util =3D { path =3D "../util" } glib-sys.workspace =3D true diff --git a/rust/migration/meson.build b/rust/migration/meson.build index 18be65c92cf..845136239e8 100644 --- a/rust/migration/meson.build +++ b/rust/migration/meson.build @@ -37,12 +37,12 @@ _migration_rs =3D static_library( ), override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', - link_with: [_util_rs], + link_with: [_util_rs, _bql_rs], dependencies: [common_rs, glib_sys_rs], ) =20 migration_rs =3D declare_dependency(link_with: [_migration_rs], - dependencies: [migration, qemuutil]) + dependencies: [bql_rs, migration, qemuutil]) =20 # Doctests are essentially integration tests, so they need the same depend= encies. # Note that running them requires the object files for C code, so place th= em diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index 59e665f6c3a..445fe7fbc08 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -276,6 +276,8 @@ unsafe impl<$base> $crate::vmstate::VMState for $type w= here $base: $crate::vmsta }; } =20 +impl_vmstate_transparent!(bql::BqlCell where T: VMState); +impl_vmstate_transparent!(bql::BqlRefCell where T: VMState); impl_vmstate_transparent!(std::cell::Cell where T: VMState); impl_vmstate_transparent!(std::cell::UnsafeCell where T: VMState); impl_vmstate_transparent!(std::pin::Pin where T: VMState); --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449395; cv=none; d=zohomail.com; s=zohoarc; b=CjaarkD5As/BMI7ubWwv8iUn7wAso/oF+PknHleDOpqUCx39fLBfYHUOcaQMnA0ClETzONX63Gefw6D7YJ6ZGb8NClCCaC5X+73MgaRVyYBMF2QbzuzkTZ6vdO8xEdt2G56ElYZfUs4N9TK44t0C3aedpdgVn4ujgASoGe29bEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449395; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FzUz/mq1FeuVZGezXV2EvmZry8cXIX74rPUo2Mb+6VI=; b=mfFbVYTtd7mkVw3EvBlGEnCOj+V+AH5foHtXg9Mg22MFS/y1Qtog3yxcQMQ/km7D50vPb00dnohMiDvyzT04QzL0xjr85g/B61ZWde3m9FuggKt6v+YDvIMpa0q1VQSF3/JrsnOJOp05CpU3ecwoDgxlp+CCa+QziMMdIPAjWqE= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449395952143.06827301127976; Tue, 14 Oct 2025 06:43:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fF0-0006tA-2w; Tue, 14 Oct 2025 09:39:02 -0400 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 1v8fEm-0006Iq-PN for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fEa-00019t-AW for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:46 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-360-u00ybXajOXWDCyMdLBSe7Q-1; Tue, 14 Oct 2025 09:38:29 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3ece14b9231so4624885f8f.0 for ; Tue, 14 Oct 2025 06:38:28 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5d0011sm23890415f8f.31.2025.10.14.06.38.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:38:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FzUz/mq1FeuVZGezXV2EvmZry8cXIX74rPUo2Mb+6VI=; b=SwsKjuUpcKMlz+rsrM8jzi6+x1XLTWc9DJnQQuWMs1dBfawLr2Qez5+AIat39fNdGsFSfb U8VIGeYj24xUjWfw7m/ylisiVae5xg+UtJ6mg3Uz5kxdDCiBqKK4Bw4Hm8t4RsSHnRjud/ eFebcDJAnvwWEJkDirT/mLApk9ZfPUA= X-MC-Unique: u00ybXajOXWDCyMdLBSe7Q-1 X-Mimecast-MFC-AGG-ID: u00ybXajOXWDCyMdLBSe7Q_1760449107 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449106; x=1761053906; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FzUz/mq1FeuVZGezXV2EvmZry8cXIX74rPUo2Mb+6VI=; b=scz8hXDyGyk+mu7pvaEPuKs5OQX7r4eSiVzudwNDVM8g3B62P9BZsdsCjXsx2NFmdE Wl1Wbz2BbEEqypU2UQsUpO2/1zPkSB5Y5aRqu7IKzlUVaNNwS/MUE+4byn6NRNwwd/Ns g55hgAG63snzE7L5DSyesirszTvS/pDBaZsw8M2JdJmKkFhFMkoQKYL+JLo7ypmc2gRg fkP2DrEpuGGosEr5FxlwIK92W64EP8aFqfpZJ3YWavbXJzACMaLEz4xW8MwZPaFLkDo8 jfj0EY1OUouGNn2ZiCCf3inBgzez9uu57bGkKD5dFG9/CR4azlNkGJBnaBicEE5/SrvD 5dMA== X-Gm-Message-State: AOJu0Yzlz6wJicdTTqzpc0slwI3B/2OBGg6rUMAPeVG0//9UNZS/crPy AOi/N4G6XaRX4n9vC0IFNVhu0q1EA+StKhqfjTZnCd9YYAoymBMPs++9gtJQkl0twVYjuNuD4++ MQeOlIJ2Dno1YBMVQgbKasIDGAVp0H9N/lbtza/hM7iVa2u6+LY3gA6yJ65wHkJq/wECyoLzCQV uJVsqyHro9KzjCSxbL0u5EBdXXNA9kZjQul3sB40xv X-Gm-Gg: ASbGnctsGUxPNRkVQf9zIES/GKY6bJIvYE18S0JOZkSDyZAWGQ0t2ZqCrSgwNi4lE3P MtxMYIwrNew+oCiW9pZyTwa4rrl/s7W3ZEmMI0QPbUV6miBkAjM5MFGc0KHtG/CqxFuBgz+6s56 JRPG4K/Eph7tH+HpkCeP0H8p4/KHq8hN1QTKztPU4pthfIFA21gtRv5CZ6tLOVYPeL3YO9Lg4JZ jhxrKd/bN9quyYT93rzcl4yV0g8paWg4usACKlQdpuxfe+G/oN6jZDVnylT/H6/TITOjzM238v5 nM3MB2xDSkitb1cIoqUob6Ajk7nVziKe7fQLjxCYXiTBjbAaQspLP2sgc9MbvNhMBxiLcfEc7/T sQESQZ7kVCXTSK/WnXqEVgzNs4LccGEDQ1o6GcIY7Xv0= X-Received: by 2002:a05:6000:438a:b0:425:75c6:7125 with SMTP id ffacd0b85a97d-4266e7bee7fmr17202136f8f.16.1760449105444; Tue, 14 Oct 2025 06:38:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXtd7xLXEA1/89bgiKKACbWfVtvo9o98DyxfADIhXlspS3nt7oUSev5gX47WuzM35SKFF07w== X-Received: by 2002:a05:6000:438a:b0:425:75c6:7125 with SMTP id ffacd0b85a97d-4266e7bee7fmr17202112f8f.16.1760449104848; Tue, 14 Oct 2025 06:38:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Zhao Liu Subject: [PULL 25/28] rust: migration: add high-level migration wrappers Date: Tue, 14 Oct 2025 15:37:10 +0200 Message-ID: <20251014133713.1103695-25-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449398319154100 Content-Type: text/plain; charset="utf-8" Instead of dealing with pre/post callbacks, allow devices to implement a snapshot/restore mechanism; this has two main advantages: - it can be easily implemented via procedural macros - there can be generic implementations to deal with various kinds of interior-mutable containers, from BqlRefCell to Mutex, so that C code does not see Rust concepts such as Mutex<>. Using it is easy; you can implement the snapshot/restore trait ToMigrationState and declare your state like: regs: Migratable> Migratable<> allows dereferencing to the underlying object with no run-time cost. Note that Migratable<> actually does not accept ToMigrationState, only the similar ToMigrationStateShared trait that the user will mostly not care about. This is required by the fact that pre/post callbacks take a &self, and ensures that the argument is a Mutex or BqlRefCell (including an array or Arc<> thereof). Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- docs/devel/rust.rst | 1 + rust/migration/meson.build | 1 + rust/migration/src/lib.rs | 3 + rust/migration/src/migratable.rs | 434 +++++++++++++++++++++++++++++++ 4 files changed, 439 insertions(+) create mode 100644 rust/migration/src/migratable.rs diff --git a/docs/devel/rust.rst b/docs/devel/rust.rst index 2f0ab2e2821..79c26d9d165 100644 --- a/docs/devel/rust.rst +++ b/docs/devel/rust.rst @@ -155,6 +155,7 @@ module status ``hwcore::irq`` complete ``hwcore::qdev`` stable ``hwcore::sysbus`` stable +``migration::migratable`` proof of concept ``migration::vmstate`` stable ``qom`` stable ``system::memory`` stable diff --git a/rust/migration/meson.build b/rust/migration/meson.build index 845136239e8..0d25455baa9 100644 --- a/rust/migration/meson.build +++ b/rust/migration/meson.build @@ -31,6 +31,7 @@ _migration_rs =3D static_library( [ 'src/lib.rs', 'src/bindings.rs', + 'src/migratable.rs', 'src/vmstate.rs', ], {'.' : _migration_bindings_inc_rs}, diff --git a/rust/migration/src/lib.rs b/rust/migration/src/lib.rs index 5f51dde4406..efe9896b619 100644 --- a/rust/migration/src/lib.rs +++ b/rust/migration/src/lib.rs @@ -2,5 +2,8 @@ =20 pub mod bindings; =20 +pub mod migratable; +pub use migratable::*; + pub mod vmstate; pub use vmstate::*; diff --git a/rust/migration/src/migratable.rs b/rust/migration/src/migratab= le.rs new file mode 100644 index 00000000000..46e533c16d1 --- /dev/null +++ b/rust/migration/src/migratable.rs @@ -0,0 +1,434 @@ +// Copyright 2025 Red Hat, Inc. +// Author(s): Paolo Bonzini +// SPDX-License-Identifier: GPL-2.0-or-later + +use std::{ + fmt, + mem::size_of, + ptr::{self, addr_of, NonNull}, + sync::{Arc, Mutex}, +}; + +use bql::{BqlCell, BqlRefCell}; +use common::Zeroable; + +use crate::{ + bindings, vmstate_fields_ref, vmstate_of, InvalidError, VMState, VMSta= teDescriptionBuilder, +}; + +/// Enables QEMU migration support even when a type is wrapped with +/// synchronization primitives (like `Mutex`) that the C migration +/// code cannot directly handle. The trait provides methods to +/// extract essential state for migration and restore it after +/// migration completes. +/// +/// On top of extracting data from synchronization wrappers during save +/// and restoring it during load, it's also possible to use `ToMigrationSt= ate` +/// to convert runtime representations to migration-safe formats. +/// +/// # Examples +/// +/// ``` +/// use bql::BqlCell; +/// use migration::{InvalidError, ToMigrationState, VMState}; +/// # use migration::VMStateField; +/// +/// # #[derive(Debug, PartialEq, Eq)] +/// struct DeviceState { +/// counter: BqlCell, +/// enabled: bool, +/// } +/// +/// # #[derive(Debug)] +/// #[derive(Default)] +/// struct DeviceMigrationState { +/// counter: u32, +/// enabled: bool, +/// } +/// +/// # unsafe impl VMState for DeviceMigrationState { +/// # const BASE: VMStateField =3D ::common::Zeroable::ZERO; +/// # } +/// impl ToMigrationState for DeviceState { +/// type Migrated =3D DeviceMigrationState; +/// +/// fn snapshot_migration_state( +/// &self, +/// target: &mut Self::Migrated, +/// ) -> Result<(), InvalidError> { +/// target.counter =3D self.counter.get(); +/// target.enabled =3D self.enabled; +/// Ok(()) +/// } +/// +/// fn restore_migrated_state_mut( +/// &mut self, +/// source: Self::Migrated, +/// _version_id: u8, +/// ) -> Result<(), InvalidError> { +/// self.counter.set(source.counter); +/// self.enabled =3D source.enabled; +/// Ok(()) +/// } +/// } +/// # bql::start_test(); +/// # let dev =3D DeviceState { counter: 10.into(), enabled: true }; +/// # let mig =3D dev.to_migration_state().unwrap(); +/// # assert!(matches!(*mig, DeviceMigrationState { counter: 10, enabled: = true })); +/// # let mut dev2 =3D DeviceState { counter: 42.into(), enabled: false }; +/// # dev2.restore_migrated_state_mut(*mig, 1).unwrap(); +/// # assert_eq!(dev2, dev); +/// ``` +pub trait ToMigrationState { + /// The type used to represent the migrated state. + type Migrated: Default + VMState; + + /// Capture the current state into a migration-safe format, failing + /// if the state cannot be migrated. + fn snapshot_migration_state(&self, target: &mut Self::Migrated) -> Res= ult<(), InvalidError>; + + /// Restores state from a migrated representation, failing if the + /// state cannot be restored. + fn restore_migrated_state_mut( + &mut self, + source: Self::Migrated, + version_id: u8, + ) -> Result<(), InvalidError>; + + /// Convenience method to combine allocation and state capture + /// into a single operation. + fn to_migration_state(&self) -> Result, InvalidErr= or> { + let mut migrated =3D Box::::default(); + self.snapshot_migration_state(&mut migrated)?; + Ok(migrated) + } +} + +// Implementations for primitive types. Do not use a blanket implementati= on +// for all Copy types, because [T; N] is Copy if T is Copy; that would con= flict +// with the below implementation for arrays. +macro_rules! impl_for_primitive { + ($($t:ty),*) =3D> { + $( + impl ToMigrationState for $t { + type Migrated =3D Self; + + fn snapshot_migration_state( + &self, + target: &mut Self::Migrated, + ) -> Result<(), InvalidError> { + *target =3D *self; + Ok(()) + } + + fn restore_migrated_state_mut( + &mut self, + source: Self::Migrated, + _version_id: u8, + ) -> Result<(), InvalidError> { + *self =3D source; + Ok(()) + } + } + )* + }; +} + +impl_for_primitive!(u8, u16, u32, u64, i8, i16, i32, i64, bool); + +impl ToMigrationState for [T; N] +where + [T::Migrated; N]: Default, +{ + type Migrated =3D [T::Migrated; N]; + + fn snapshot_migration_state(&self, target: &mut Self::Migrated) -> Res= ult<(), InvalidError> { + for (item, target_item) in self.iter().zip(target.iter_mut()) { + item.snapshot_migration_state(target_item)?; + } + Ok(()) + } + + fn restore_migrated_state_mut( + &mut self, + source: Self::Migrated, + version_id: u8, + ) -> Result<(), InvalidError> { + for (item, source_item) in self.iter_mut().zip(source) { + item.restore_migrated_state_mut(source_item, version_id)?; + } + Ok(()) + } +} + +impl ToMigrationState for Mutex { + type Migrated =3D T::Migrated; + + fn snapshot_migration_state(&self, target: &mut Self::Migrated) -> Res= ult<(), InvalidError> { + self.lock().unwrap().snapshot_migration_state(target) + } + + fn restore_migrated_state_mut( + &mut self, + source: Self::Migrated, + version_id: u8, + ) -> Result<(), InvalidError> { + self.get_mut() + .unwrap() + .restore_migrated_state_mut(source, version_id) + } +} + +impl ToMigrationState for BqlRefCell { + type Migrated =3D T::Migrated; + + fn snapshot_migration_state(&self, target: &mut Self::Migrated) -> Res= ult<(), InvalidError> { + self.borrow().snapshot_migration_state(target) + } + + fn restore_migrated_state_mut( + &mut self, + source: Self::Migrated, + version_id: u8, + ) -> Result<(), InvalidError> { + self.get_mut() + .restore_migrated_state_mut(source, version_id) + } +} + +/// Extension trait for types that support migration state restoration +/// through interior mutability. +/// +/// This trait extends [`ToMigrationState`] for types that can restore +/// their state without requiring mutable access. While user structs +/// will generally use `ToMigrationState`, the device will have multiple +/// references and therefore the device struct has to employ an interior +/// mutability wrapper like [`Mutex`] or [`BqlRefCell`]. +/// +/// Anything that implements this trait can in turn be used within +/// [`Migratable`], which makes no assumptions on how to achieve mutable +/// access to the runtime state. +/// +/// # Examples +/// +/// ``` +/// use std::sync::Mutex; +/// +/// use migration::ToMigrationStateShared; +/// +/// let device_state =3D Mutex::new(42); +/// // Can restore without &mut access +/// device_state.restore_migrated_state(100, 1).unwrap(); +/// assert_eq!(*device_state.lock().unwrap(), 100); +/// ``` +pub trait ToMigrationStateShared: ToMigrationState { + /// Restores state from a migrated representation to an interior-mutab= le + /// object. Similar to `restore_migrated_state_mut`, but requires a + /// shared reference; therefore it can be used to restore a device's + /// state even though devices have multiple references to them. + fn restore_migrated_state( + &self, + source: Self::Migrated, + version_id: u8, + ) -> Result<(), InvalidError>; +} + +impl ToMigrationStateShared for= [T; N] +where + [T::Migrated; N]: Default, +{ + fn restore_migrated_state( + &self, + source: Self::Migrated, + version_id: u8, + ) -> Result<(), InvalidError> { + for (item, source_item) in self.iter().zip(source) { + item.restore_migrated_state(source_item, version_id)?; + } + Ok(()) + } +} + +// Arc requires the contained object to be interior-mutable +impl ToMigrationState for Arc { + type Migrated =3D T::Migrated; + + fn snapshot_migration_state(&self, target: &mut Self::Migrated) -> Res= ult<(), InvalidError> { + (**self).snapshot_migration_state(target) + } + + fn restore_migrated_state_mut( + &mut self, + source: Self::Migrated, + version_id: u8, + ) -> Result<(), InvalidError> { + (**self).restore_migrated_state(source, version_id) + } +} + +impl ToMigrationStateShared for Arc { + fn restore_migrated_state( + &self, + source: Self::Migrated, + version_id: u8, + ) -> Result<(), InvalidError> { + (**self).restore_migrated_state(source, version_id) + } +} + +// Interior-mutable types. Note how they only require ToMigrationState for +// the inner type! + +impl ToMigrationStateShared for Mutex { + fn restore_migrated_state( + &self, + source: Self::Migrated, + version_id: u8, + ) -> Result<(), InvalidError> { + self.lock() + .unwrap() + .restore_migrated_state_mut(source, version_id) + } +} + +impl ToMigrationStateShared for BqlRefCell { + fn restore_migrated_state( + &self, + source: Self::Migrated, + version_id: u8, + ) -> Result<(), InvalidError> { + self.borrow_mut() + .restore_migrated_state_mut(source, version_id) + } +} + +/// A wrapper that enables QEMU migration for types with shared state. +/// +/// `Migratable` provides a bridge between Rust types that use interior +/// mutability (like `Mutex`) and QEMU's C-based migration infrastructu= re. +/// It manages the lifecycle of migration state and provides automatic +/// conversion between runtime and migration representations. +/// +/// ```ignore +/// # use std::sync::Mutex; +/// # use migration::Migratable; +/// +/// pub struct DeviceRegs { +/// status: u32, +/// } +/// +/// pub struct SomeDevice { +/// // ... +/// registers: Migratable>, +/// } +/// ``` +#[repr(C)] +pub struct Migratable { + /// Pointer to migration state, valid only during migration operations. + /// C vmstate does not support NULL pointers, so no `Option>`. + migration_state: BqlCell<*mut T::Migrated>, + + /// The runtime state that can be accessed during normal operation + runtime_state: T, +} + +impl std::ops::Deref for Migratable { + type Target =3D T; + + fn deref(&self) -> &Self::Target { + &self.runtime_state + } +} + +impl std::ops::DerefMut for Migratable { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.runtime_state + } +} + +impl Migratable { + /// Creates a new `Migratable` wrapper around the given runtime state. + /// + /// # Returns + /// A new `Migratable` instance ready for use and migration + pub fn new(runtime_state: T) -> Self { + Self { + migration_state: BqlCell::new(ptr::null_mut()), + runtime_state, + } + } + + fn pre_save(&self) -> Result<(), InvalidError> { + let state =3D self.runtime_state.to_migration_state()?; + self.migration_state.set(Box::into_raw(state)); + Ok(()) + } + + fn post_save(&self) -> Result<(), InvalidError> { + let state =3D unsafe { Box::from_raw(self.migration_state.replace(= ptr::null_mut())) }; + drop(state); + Ok(()) + } + + fn pre_load(&self) -> Result<(), InvalidError> { + self.migration_state + .set(Box::into_raw(Box::::default())); + Ok(()) + } + + fn post_load(&self, version_id: u8) -> Result<(), InvalidError> { + let state =3D unsafe { Box::from_raw(self.migration_state.replace(= ptr::null_mut())) }; + self.runtime_state + .restore_migrated_state(*state, version_id) + } +} + +impl fmt::Debug for Migratable +where + T::Migrated: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut struct_f =3D f.debug_struct("Migratable"); + struct_f.field("runtime_state", &self.runtime_state); + + let state =3D NonNull::new(self.migration_state.get()).map(|x| uns= afe { x.as_ref() }); + struct_f.field("migration_state", &state); + struct_f.finish() + } +} + +impl Default for Migratable { + fn default() -> Self { + Self::new(T::default()) + } +} + +impl Migratable { + const FIELD: bindings::VMStateField =3D vmstate_of!(Self, migration_st= ate); + + const FIELDS: &[bindings::VMStateField] =3D vmstate_fields_ref! { + Migratable::::FIELD + }; + + const VMSD: &'static bindings::VMStateDescription =3D VMStateDescripti= onBuilder::::new() + .version_id(1) + .minimum_version_id(1) + .pre_save(&Self::pre_save) + .pre_load(&Self::pre_load) + .post_save(&Self::post_save) + .post_load(&Self::post_load) + .fields(Self::FIELDS) + .build() + .as_ref(); +} + +unsafe impl VMState for Migratable= { + const BASE: bindings::VMStateField =3D { + bindings::VMStateField { + vmsd: addr_of!(*Self::VMSD), + size: size_of::(), + flags: bindings::VMStateFlags::VMS_STRUCT, + ..Zeroable::ZERO + } + }; +} --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449215; cv=none; d=zohomail.com; s=zohoarc; b=XOZu5FBvSPFHi/pwkR+gBpEIskb31HpDJ6XMUKz/SHQ5rJzlQlphh66n6vL4RJBsrJI/o2I6aD7R6Rcd5UMiofu4vMyYqq0FHrUwlt4mQSVfOUlTrWo4OBrj7dZ+KVp/F0jOqMcOPvNF734sDHQaawYZb/DqYBt07it68ljxicM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449215; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gfwPKGXabfBR6MmuW9QJ+K7xOy6N1f+kvD5D0uk7tg8=; b=erCx6NAA5qOfsBInQkKA3SZegUaagWpuFg5DA2JQLOCkozZR0nAv/IZBesEBfRlc1mQ1c5PJNu5mBxTnsBwm2DbgTa81fZG6Vi4lnm6VqUCJPO37HNkXDdfK+womPX0h4G8qCZ/Q4EXNlhHpyUb/fuozDLhJK8toAT9IKMMux2s= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449215501877.2550758117034; Tue, 14 Oct 2025 06:40:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEw-0006T9-EZ; Tue, 14 Oct 2025 09:38:59 -0400 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 1v8fEi-0006G9-Nw for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fEZ-0001Ac-Nj for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:44 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-85-pnmxVIHkPqiLQS3tLuREdQ-1; Tue, 14 Oct 2025 09:38:30 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46b303f6c9cso4450025e9.2 for ; Tue, 14 Oct 2025 06:38:30 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fb49d03e2sm243143775e9.19.2025.10.14.06.38.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:38:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449113; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gfwPKGXabfBR6MmuW9QJ+K7xOy6N1f+kvD5D0uk7tg8=; b=Lks2p1vBprD2eWzOhIptk8bKUMc9NiW6MwN/F5DUMuj1tuI9ekISvHdobmkKk2Aia4ubHJ Mzy1uyDM2KQUQQn61d5dS2IG0iTyRYeDPCJPu5UuafK5b/6BtJGzkEJStev3SQs9XoLyOL Iqx28nt6m08Ykv5JY518P9qA6nhySTw= X-MC-Unique: pnmxVIHkPqiLQS3tLuREdQ-1 X-Mimecast-MFC-AGG-ID: pnmxVIHkPqiLQS3tLuREdQ_1760449109 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449107; x=1761053907; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gfwPKGXabfBR6MmuW9QJ+K7xOy6N1f+kvD5D0uk7tg8=; b=ORRxemKQa2ZaViOXXONVWy35mlKKLrgB1v/VXeZYQF8N2ddo6YQViXQQUQTTqqQnrR Gk1j5b6+1d830gVUIztQUO84wGtySVF3xoITx0/3Vzzth7nZyUCJPgh3QFIhuX05OPdE vNKf2Z0usJjG7qTooxiRk6oswYaH83k+vZdD++0hmG2+2GH6AEF/k/mPNmfMAyzaf4z/ NdTP/6NfACS9kKZ4BmBO0+xBBs/iSZQq+xS0dlAhDq7oz7hjMuizVcJrdUkKxWF8z279 FeF8DU/P0JfLmQ1FSJ+Oe+Youl5jhc+hMnCD7FLPW0tuas2z1JU75vFJkUclLxJfUMjE 1xUA== X-Gm-Message-State: AOJu0YwFHaSlN6Igx4PxfxUtjSU73OgNOva/dP0EQ/T1T05LbGohvJpw 8K2DkOtKGWDnJtpoypZd1I2kNQaDOqlGnN8CMWDRRbBM5Wlou9IMhv1Qsw0LAF9IRRd9T0EkpPd PmN4x3TlmDwntSCHUo9617c6vkEZDO67BHxLsWVi1a+4JfNmTEDtXgdSWuq0KD3x52DmkgSZ/l6 aIvgsO6VBbSOEcdC+riPXcdOxOWzfVs7XpScG4B3O1 X-Gm-Gg: ASbGnctE5F1dN2GHBtDxPez6kFFJYWAzMxdXes1IigiO7XA96dwVCWBxEjThE8GbEVs D1/GEszwSJNw/KzIq85yeiSQ3B+JDudwBTY9uHZhRIcY+YYrYMHK3xvu+mZR7dY+USAiDGAdsPe L0ReAJse+fpwiUbIqYufmEJ0IrJdmz1w650Yq+OtwwYPrp9YNwdr7eVMy9v024gNTAilzfl+Wzm whSJUQk6TMZM1E7DG39QLracV95Wzp3yxK86UlseJiC92Y1TX/o5ZX2J5jH4/awivj45V8rCuQv HKjjTw36tIYRnqPB2DfAitg+vam/PsN64/upPrtHDdasUKZR/SOdLpfOVVlF2wddKHlSIg0pIds 33Vt9sbjL8wJ8PGQvs3dC+KrxHjREisZ9vP/Qrk2UgnM= X-Received: by 2002:a05:600c:4750:b0:45f:28d2:bd38 with SMTP id 5b1f17b1804b1-46fa9af3095mr190660295e9.18.1760449106847; Tue, 14 Oct 2025 06:38:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9LT0uag2GyyPJHWzjA3hMST5/3+R0h1M2ApvuesI26xZfGYH8AE0LLD6G9jKNkQenK+/wXA== X-Received: by 2002:a05:600c:4750:b0:45f:28d2:bd38 with SMTP id 5b1f17b1804b1-46fa9af3095mr190659905e9.18.1760449106211; Tue, 14 Oct 2025 06:38:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Zhao Liu Subject: [PULL 26/28] rust: qemu-macros: add ToMigrationState derive macro Date: Tue, 14 Oct 2025 15:37:11 +0200 Message-ID: <20251014133713.1103695-26-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, T_SPF_TEMPERROR=0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449224974158500 Content-Type: text/plain; charset="utf-8" Add a macro that recursively builds the "migrated" version of a struct. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/Cargo.lock | 1 + rust/migration/Cargo.toml | 1 + rust/migration/meson.build | 2 +- rust/migration/src/lib.rs | 2 + rust/migration/src/migratable.rs | 12 +- rust/qemu-macros/src/lib.rs | 88 +++++++ rust/qemu-macros/src/migration_state.rs | 298 ++++++++++++++++++++++++ rust/qemu-macros/src/tests.rs | 113 ++++++++- 8 files changed, 512 insertions(+), 5 deletions(-) create mode 100644 rust/qemu-macros/src/migration_state.rs diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 5c2f8ea9240..0c1df625df1 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -200,6 +200,7 @@ dependencies =3D [ "bql", "common", "glib-sys", + "qemu_macros", "util", ] =20 diff --git a/rust/migration/Cargo.toml b/rust/migration/Cargo.toml index b995c4c8c88..415457496d6 100644 --- a/rust/migration/Cargo.toml +++ b/rust/migration/Cargo.toml @@ -15,6 +15,7 @@ rust-version.workspace =3D true [dependencies] bql =3D { path =3D "../bql" } common =3D { path =3D "../common" } +qemu_macros =3D { path =3D "../qemu-macros" } util =3D { path =3D "../util" } glib-sys.workspace =3D true =20 diff --git a/rust/migration/meson.build b/rust/migration/meson.build index 0d25455baa9..444494700ad 100644 --- a/rust/migration/meson.build +++ b/rust/migration/meson.build @@ -39,7 +39,7 @@ _migration_rs =3D static_library( override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', link_with: [_util_rs, _bql_rs], - dependencies: [common_rs, glib_sys_rs], + dependencies: [common_rs, glib_sys_rs, qemu_macros], ) =20 migration_rs =3D declare_dependency(link_with: [_migration_rs], diff --git a/rust/migration/src/lib.rs b/rust/migration/src/lib.rs index efe9896b619..c9bdf0d4133 100644 --- a/rust/migration/src/lib.rs +++ b/rust/migration/src/lib.rs @@ -2,6 +2,8 @@ =20 pub mod bindings; =20 +pub use qemu_macros::ToMigrationState; + pub mod migratable; pub use migratable::*; =20 diff --git a/rust/migration/src/migratable.rs b/rust/migration/src/migratab= le.rs index 46e533c16d1..ded6fe8f4a6 100644 --- a/rust/migration/src/migratable.rs +++ b/rust/migration/src/migratable.rs @@ -79,6 +79,10 @@ /// # dev2.restore_migrated_state_mut(*mig, 1).unwrap(); /// # assert_eq!(dev2, dev); /// ``` +/// +/// More commonly, the trait is derived through the +/// [`derive(ToMigrationState)`](qemu_macros::ToMigrationState) procedural +/// macro. pub trait ToMigrationState { /// The type used to represent the migrated state. type Migrated: Default + VMState; @@ -309,13 +313,17 @@ fn restore_migrated_state( /// It manages the lifecycle of migration state and provides automatic /// conversion between runtime and migration representations. /// -/// ```ignore +/// ``` /// # use std::sync::Mutex; -/// # use migration::Migratable; +/// # use migration::{Migratable, ToMigrationState, VMState, VMStateField}; /// +/// #[derive(ToMigrationState)] /// pub struct DeviceRegs { /// status: u32, /// } +/// # unsafe impl VMState for DeviceRegsMigration { +/// # const BASE: VMStateField =3D ::common::Zeroable::ZERO; +/// # } /// /// pub struct SomeDevice { /// // ... diff --git a/rust/qemu-macros/src/lib.rs b/rust/qemu-macros/src/lib.rs index 3bf315c4c0a..50239f228be 100644 --- a/rust/qemu-macros/src/lib.rs +++ b/rust/qemu-macros/src/lib.rs @@ -13,9 +13,13 @@ Attribute, Data, DeriveInput, Error, Field, Fields, FieldsUnnamed, Ide= nt, Meta, Path, Token, Variant, }; + mod bits; use bits::BitsConstInternal; =20 +mod migration_state; +use migration_state::MigrationStateDerive; + #[cfg(test)] mod tests; =20 @@ -412,3 +416,87 @@ pub fn bits_const_internal(ts: TokenStream) -> TokenSt= ream { } .into() } + +/// Derive macro for generating migration state structures and trait +/// implementations. +/// +/// This macro generates a migration state struct and implements the +/// `ToMigrationState` trait for the annotated struct, enabling state +/// serialization and restoration. Note that defining a `VMStateDescripti= on` +/// for the migration state struct is left to the user. +/// +/// # Container attributes +/// +/// The following attributes can be applied to the struct: +/// +/// - `#[migration_state(rename =3D CustomName)]` - Customizes the name of= the +/// generated migration struct. By default, the generated struct is named +/// `{OriginalName}Migration`. +/// +/// # Field attributes +/// +/// The following attributes can be applied to individual fields: +/// +/// - `#[migration_state(omit)]` - Excludes the field from the migration s= tate +/// entirely. +/// +/// - `#[migration_state(into(Type))]` - Converts the field using `.into()` +/// during both serialization and restoration. +/// +/// - `#[migration_state(try_into(Type))]` - Converts the field using +/// `.try_into()` during both serialization and restoration. Returns +/// `InvalidError` on conversion failure. +/// +/// - `#[migration_state(clone)]` - Clones the field value. +/// +/// Fields without any attributes use `ToMigrationState` recursively; note= that +/// this is a simple copy for types that implement `Copy`. +/// +/// # Attribute compatibility +/// +/// - `omit` cannot be used with any other attributes +/// - only one of `into(Type)`, `try_into(Type)` can be used, but they can= be +/// coupled with `clone`. +/// +/// # Examples +/// +/// Basic usage: +/// ```ignore +/// #[derive(ToMigrationState)] +/// struct MyStruct { +/// field1: u32, +/// field2: Timer, +/// } +/// ``` +/// +/// With attributes: +/// ```ignore +/// #[derive(ToMigrationState)] +/// #[migration_state(rename =3D CustomMigration)] +/// struct MyStruct { +/// #[migration_state(omit)] +/// runtime_field: u32, +/// +/// #[migration_state(clone)] +/// shared_data: String, +/// +/// #[migration_state(into(Cow<'static, str>), clone)] +/// converted_field: String, +/// +/// #[migration_state(try_into(i8))] +/// fallible_field: u32, +/// +/// // Default: use ToMigrationState trait recursively +/// nested_field: NestedStruct, +/// +/// // Primitive types have a default implementation of ToMigrationSta= te +/// simple_field: u32, +/// } +/// ``` +#[proc_macro_derive(ToMigrationState, attributes(migration_state))] +pub fn derive_to_migration_state(input: TokenStream) -> TokenStream { + let input =3D parse_macro_input!(input as DeriveInput); + MigrationStateDerive::expand(input) + .unwrap_or_else(syn::Error::into_compile_error) + .into() +} diff --git a/rust/qemu-macros/src/migration_state.rs b/rust/qemu-macros/src= /migration_state.rs new file mode 100644 index 00000000000..5edf0efe687 --- /dev/null +++ b/rust/qemu-macros/src/migration_state.rs @@ -0,0 +1,298 @@ +use std::borrow::Cow; + +use proc_macro2::TokenStream; +use quote::{format_ident, quote, ToTokens}; +use syn::{spanned::Spanned, DeriveInput, Error, Field, Ident, Result, Type= }; + +use crate::get_fields; + +#[derive(Debug, Default)] +enum ConversionMode { + #[default] + None, + Omit, + Into(Type), + TryInto(Type), + ToMigrationState, +} + +impl ConversionMode { + fn target_type(&self, original_type: &Type) -> TokenStream { + match self { + ConversionMode::Into(ty) | ConversionMode::TryInto(ty) =3D> ty= .to_token_stream(), + ConversionMode::ToMigrationState =3D> { + quote! { <#original_type as ToMigrationState>::Migrated } + } + _ =3D> original_type.to_token_stream(), + } + } +} + +#[derive(Debug, Default)] +struct ContainerAttrs { + rename: Option, +} + +impl ContainerAttrs { + fn parse_from(&mut self, attrs: &[syn::Attribute]) -> Result<()> { + use attrs::{set, with, Attrs}; + Attrs::new() + .once("rename", with::eq(set::parse(&mut self.rename))) + .parse_attrs("migration_state", attrs)?; + Ok(()) + } + + fn parse(attrs: &[syn::Attribute]) -> Result { + let mut container_attrs =3D Self::default(); + container_attrs.parse_from(attrs)?; + Ok(container_attrs) + } +} + +#[derive(Debug, Default)] +struct FieldAttrs { + conversion: ConversionMode, + clone: bool, +} + +impl FieldAttrs { + fn parse_from(&mut self, attrs: &[syn::Attribute]) -> Result<()> { + let mut omit_flag =3D false; + let mut into_type: Option =3D None; + let mut try_into_type: Option =3D None; + + use attrs::{set, with, Attrs}; + Attrs::new() + .once("omit", set::flag(&mut omit_flag)) + .once("into", with::paren(set::parse(&mut into_type))) + .once("try_into", with::paren(set::parse(&mut try_into_type))) + .once("clone", set::flag(&mut self.clone)) + .parse_attrs("migration_state", attrs)?; + + self.conversion =3D match (omit_flag, into_type, try_into_type, se= lf.clone) { + // Valid combinations of attributes first... + (true, None, None, false) =3D> ConversionMode::Omit, + (false, Some(ty), None, _) =3D> ConversionMode::Into(ty), + (false, None, Some(ty), _) =3D> ConversionMode::TryInto(ty), + (false, None, None, true) =3D> ConversionMode::None, // clone = without conversion + (false, None, None, false) =3D> ConversionMode::ToMigrationSta= te, // default behavior + + // ... then the error cases + (true, _, _, _) =3D> { + return Err(Error::new( + attrs[0].span(), + "ToMigrationState: omit cannot be used with other attr= ibutes", + )); + } + (_, Some(_), Some(_), _) =3D> { + return Err(Error::new( + attrs[0].span(), + "ToMigrationState: into and try_into attributes cannot= be used together", + )); + } + }; + + Ok(()) + } + + fn parse(attrs: &[syn::Attribute]) -> Result { + let mut field_attrs =3D Self::default(); + field_attrs.parse_from(attrs)?; + Ok(field_attrs) + } +} + +#[derive(Debug)] +struct MigrationStateField { + name: Ident, + original_type: Type, + attrs: FieldAttrs, +} + +impl MigrationStateField { + fn maybe_clone(&self, mut value: TokenStream) -> TokenStream { + if self.attrs.clone { + value =3D quote! { #value.clone() }; + } + value + } + + fn generate_migration_state_field(&self) -> TokenStream { + let name =3D &self.name; + let field_type =3D self.attrs.conversion.target_type(&self.origina= l_type); + + quote! { + pub #name: #field_type, + } + } + + fn generate_snapshot_field(&self) -> TokenStream { + let name =3D &self.name; + let value =3D self.maybe_clone(quote! { self.#name }); + + match &self.attrs.conversion { + ConversionMode::Omit =3D> { + unreachable!("Omitted fields are filtered out during proce= ssing") + } + ConversionMode::None =3D> quote! { + target.#name =3D #value; + }, + ConversionMode::Into(_) =3D> quote! { + target.#name =3D #value.into(); + }, + ConversionMode::TryInto(_) =3D> quote! { + target.#name =3D #value.try_into().map_err(|_| migration::= InvalidError)?; + }, + ConversionMode::ToMigrationState =3D> quote! { + self.#name.snapshot_migration_state(&mut target.#name)?; + }, + } + } + + fn generate_restore_field(&self) -> TokenStream { + let name =3D &self.name; + + match &self.attrs.conversion { + ConversionMode::Omit =3D> { + unreachable!("Omitted fields are filtered out during proce= ssing") + } + ConversionMode::None =3D> quote! { + self.#name =3D #name; + }, + ConversionMode::Into(_) =3D> quote! { + self.#name =3D #name.into(); + }, + ConversionMode::TryInto(_) =3D> quote! { + self.#name =3D #name.try_into().map_err(|_| migration::Inv= alidError)?; + }, + ConversionMode::ToMigrationState =3D> quote! { + self.#name.restore_migrated_state_mut(#name, _version_id)?; + }, + } + } +} + +#[derive(Debug)] +pub struct MigrationStateDerive { + input: DeriveInput, + fields: Vec, + container_attrs: ContainerAttrs, +} + +impl MigrationStateDerive { + fn parse(input: DeriveInput) -> Result { + let container_attrs =3D ContainerAttrs::parse(&input.attrs)?; + let fields =3D get_fields(&input, "ToMigrationState")?; + let fields =3D Self::process_fields(fields)?; + + Ok(Self { + input, + fields, + container_attrs, + }) + } + + fn process_fields( + fields: &syn::punctuated::Punctuated, + ) -> Result> { + let processed =3D fields + .iter() + .map(|field| { + let attrs =3D FieldAttrs::parse(&field.attrs)?; + Ok((field, attrs)) + }) + .collect::>>()? + .into_iter() + .filter(|(_, attrs)| !matches!(attrs.conversion, ConversionMod= e::Omit)) + .map(|(field, attrs)| MigrationStateField { + name: field.ident.as_ref().unwrap().clone(), + original_type: field.ty.clone(), + attrs, + }) + .collect(); + + Ok(processed) + } + + fn migration_state_name(&self) -> Cow<'_, Ident> { + match &self.container_attrs.rename { + Some(rename) =3D> Cow::Borrowed(rename), + None =3D> Cow::Owned(format_ident!("{}Migration", &self.input.= ident)), + } + } + + fn generate_migration_state_struct(&self) -> TokenStream { + let name =3D self.migration_state_name(); + let fields =3D self + .fields + .iter() + .map(MigrationStateField::generate_migration_state_field); + + quote! { + #[derive(Default)] + pub struct #name { + #(#fields)* + } + } + } + + fn generate_snapshot_migration_state(&self) -> TokenStream { + let fields =3D self + .fields + .iter() + .map(MigrationStateField::generate_snapshot_field); + + quote! { + fn snapshot_migration_state(&self, target: &mut Self::Migrated= ) -> Result<(), migration::InvalidError> { + #(#fields)* + Ok(()) + } + } + } + + fn generate_restore_migrated_state(&self) -> TokenStream { + let names: Vec<_> =3D self.fields.iter().map(|f| &f.name).collect(= ); + let fields =3D self + .fields + .iter() + .map(MigrationStateField::generate_restore_field); + + // version_id could be used or not depending on conversion attribu= tes + quote! { + #[allow(clippy::used_underscore_binding)] + fn restore_migrated_state_mut(&mut self, source: Self::Migrate= d, _version_id: u8) -> Result<(), migration::InvalidError> { + let Self::Migrated { #(#names),* } =3D source; + #(#fields)* + Ok(()) + } + } + } + + fn generate(&self) -> TokenStream { + let struct_name =3D &self.input.ident; + let generics =3D &self.input.generics; + + let (impl_generics, ty_generics, where_clause) =3D generics.split_= for_impl(); + let name =3D self.migration_state_name(); + let migration_state_struct =3D self.generate_migration_state_struc= t(); + let snapshot_impl =3D self.generate_snapshot_migration_state(); + let restore_impl =3D self.generate_restore_migrated_state(); + + quote! { + #migration_state_struct + + impl #impl_generics ToMigrationState for #struct_name #ty_gene= rics #where_clause { + type Migrated =3D #name; + + #snapshot_impl + + #restore_impl + } + } + } + + pub fn expand(input: DeriveInput) -> Result { + let tokens =3D Self::parse(input)?.generate(); + Ok(tokens) + } +} diff --git a/rust/qemu-macros/src/tests.rs b/rust/qemu-macros/src/tests.rs index ac998d20e30..65691412ff5 100644 --- a/rust/qemu-macros/src/tests.rs +++ b/rust/qemu-macros/src/tests.rs @@ -7,7 +7,7 @@ use super::*; =20 macro_rules! derive_compile_fail { - ($derive_fn:ident, $input:expr, $($error_msg:expr),+ $(,)?) =3D> {{ + ($derive_fn:path, $input:expr, $($error_msg:expr),+ $(,)?) =3D> {{ let input: proc_macro2::TokenStream =3D $input; let error_msg =3D &[$( quote! { ::core::compile_error! { $error_ms= g } } ),*]; let derive_fn: fn(input: syn::DeriveInput) -> Result =3D @@ -24,7 +24,7 @@ macro_rules! derive_compile_fail { } =20 macro_rules! derive_compile { - ($derive_fn:ident, $input:expr, $($expected:tt)*) =3D> {{ + ($derive_fn:path, $input:expr, $($expected:tt)*) =3D> {{ let input: proc_macro2::TokenStream =3D $input; let expected: proc_macro2::TokenStream =3D $($expected)*; let derive_fn: fn(input: syn::DeriveInput) -> Result =3D @@ -345,3 +345,112 @@ fn try_from(value: u8) -> Result { } ); } + +#[test] +fn test_derive_to_migration_state() { + derive_compile_fail!( + MigrationStateDerive::expand, + quote! { + struct MyStruct { + #[migration_state(omit, clone)] + bad: u32, + } + }, + "ToMigrationState: omit cannot be used with other attributes" + ); + derive_compile_fail!( + MigrationStateDerive::expand, + quote! { + struct MyStruct { + #[migration_state(into)] + bad: u32, + } + }, + "unexpected end of input, expected parentheses" + ); + derive_compile_fail!( + MigrationStateDerive::expand, + quote! { + struct MyStruct { + #[migration_state(into(String), try_into(String))] + bad: &'static str, + } + }, + "ToMigrationState: into and try_into attributes cannot be used tog= ether" + ); + derive_compile!( + MigrationStateDerive::expand, + quote! { + #[migration_state(rename =3D CustomMigration)] + struct MyStruct { + #[migration_state(omit)] + runtime_field: u32, + + #[migration_state(clone)] + shared_data: String, + + #[migration_state(into(Cow<'static, str>), clone)] + converted_field: String, + + #[migration_state(try_into(i8))] + fallible_field: u32, + + nested_field: NestedStruct, + simple_field: u32, + } + }, + quote! { + #[derive(Default)] + pub struct CustomMigration { + pub shared_data: String, + pub converted_field: Cow<'static, str>, + pub fallible_field: i8, + pub nested_field: ::Migr= ated, + pub simple_field: ::Migrated, + } + impl ToMigrationState for MyStruct { + type Migrated =3D CustomMigration; + fn snapshot_migration_state( + &self, + target: &mut Self::Migrated + ) -> Result<(), migration::InvalidError> { + target.shared_data =3D self.shared_data.clone(); + target.converted_field =3D self.converted_field.clone(= ).into(); + target.fallible_field =3D self + .fallible_field + .try_into() + .map_err(|_| migration::InvalidError)?; + self.nested_field + .snapshot_migration_state(&mut target.nested_field= )?; + self.simple_field + .snapshot_migration_state(&mut target.simple_field= )?; + Ok(()) + } + #[allow(clippy::used_underscore_binding)] + fn restore_migrated_state_mut( + &mut self, + source: Self::Migrated, + _version_id: u8 + ) -> Result<(), migration::InvalidError> { + let Self::Migrated { + shared_data, + converted_field, + fallible_field, + nested_field, + simple_field + } =3D source; + self.shared_data =3D shared_data; + self.converted_field =3D converted_field.into(); + self.fallible_field =3D fallible_field + .try_into() + .map_err(|_| migration::InvalidError)?; + self.nested_field + .restore_migrated_state_mut(nested_field, _version= _id)?; + self.simple_field + .restore_migrated_state_mut(simple_field, _version= _id)?; + Ok(()) + } + } + } + ); +} --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449141; cv=none; d=zohomail.com; s=zohoarc; b=eChIdoZgygSI0u0V7Be8XXhsgOtZJH3+KcStO1IKVCvOvkY+lm09d9mPpyODT/nkcLIRgT4ZQ50T5FMgGBBdwWxpsqwnwwSZwNTsD9wiPy1BiLGXd1ZWKDcXDolNw7Wc5+E5zskv+MK3N7M7bqZMwLtmYAQ/pjnnMUCctNdk59U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449141; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=npqTcVShS0e/GZMLlgnWk6EwsCoh0Dh4KtuIlmkDB7E=; b=XC7vVzhXJVxtFJ6vXIAKpHBtjAJMIixZrMJv3i2BFfjR4fXi0Y2sNe4UxDZKGGDYGrew8rGD4c7xJbuGMG7XozwmL9HLVnyoNB6IxRk2TKZEY05jJjB/ZjTPZQlmkXRtYKLOw6LtAI3TINRLvzet8VQZOjK3U3m6W7Z5k4399MM= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449141229802.1192269096738; Tue, 14 Oct 2025 06:39:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEj-0006Ay-S4; Tue, 14 Oct 2025 09:38:49 -0400 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 1v8fEe-00069D-GR for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fEZ-0001B0-Pa for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:39 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-440-eOKegtuVM5-ZgLUPRDCbVw-1; Tue, 14 Oct 2025 09:38:33 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4256fae4b46so3787991f8f.0 for ; Tue, 14 Oct 2025 06:38:32 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5e8b31sm23828846f8f.54.2025.10.14.06.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:38:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449114; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=npqTcVShS0e/GZMLlgnWk6EwsCoh0Dh4KtuIlmkDB7E=; b=SffshJl3pPkC5QjbC5aOD4HYljzX5GGbEk9o/4BxuLGz3RDoZA+hUtBUNcu5KMLvwojbKw 19YtJLeLbTQ5w7r25++QBwQq9BVeL5zAe/Mns9JkduNHoZlcO4oDXUZE9jl0j5baB2zwI5 P4L0ak3RcoB2NL5KTHm/gpGAObvtkyc= X-MC-Unique: eOKegtuVM5-ZgLUPRDCbVw-1 X-Mimecast-MFC-AGG-ID: eOKegtuVM5-ZgLUPRDCbVw_1760449112 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449111; x=1761053911; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=npqTcVShS0e/GZMLlgnWk6EwsCoh0Dh4KtuIlmkDB7E=; b=OE0H/Rs7ALSEYMMzdIKxBUy6POdWGrD3ola706s7PPko1O5ebKifKuQcNGQtM5K0Xz YSbJSLN4FBJGdj+wb89zYIgdcENeqdAvYgzg7tobZribR9SrELJmPa8XgIZaKxlkPPW+ StmgMii2g4US4drwdk+pcZPPJ9cK98SvOlg1FJwvemjBHq06YYC8+ZAp4K6buBIgfSGi cpIuvsqx050yT9AE0CYHLtqSreypcb17bAvkhT2xgII8INHF2zXJLxOKa2H+v9XSpFvH PS2XjYQbIqZv+fVSJTvLAr6ixx8jnrMqELYGQbnvqeEFMTiszOZ7axxKGbbpFhQgexS5 E91A== X-Gm-Message-State: AOJu0YzOOIdBLwJklE0Cxum3DCh+dlaPoJ6gih711eUjrcJsLdezV6vj 00OWWxxN3M6Z7BBAxjIFXaNjLRtTUq9EqIh3uydtKWCeYUptmTQ3Z0Eu/Xt2lHKfW1y137OHNln YyUY5yVsFlZvIwwHDizhicJZuxrkCRka3SsaxhYrbdmBR98XdSfrocKPrZsMkPSgOcE5NigOp/i Dx1LMvL0ZI9jLItmfDDppKPDJRMbkAJnIp/ug2VwoD X-Gm-Gg: ASbGncuVqqveIQ22gstM8PJI8a83rjrO/+7JAhX8KZ5BJ0a5OHeZX3EIeFLvTuRa//k ahtj6OiSFl0ME0pC9C6wZVTg/4oxG8rIg4d4IV8fZSGffW1ilOjO+9bhjF3hmCqbkt0paaINjR6 O8gOa3gNw0J1YghnKpAV2ca9CZtP8Ie2blrzuc1BZbEDaM4RMLZsSEs5IHW0SVDMxF69NRtNyx/ W7X7GXYkt58YErPKe4GAo50QBSES3LrhiOVck1O9AY1dFNjdI2tU4wxc7KH8+XjebdDYYgu7hCp VS/XPUYJW1tKKwM83JweHdP1xM/hcMcly1Nj2Admu1swJRZDWO1XKEUMLvH4dzq+JW66trVerV0 tC0ewNVoTFXNfapgQFxKTh4JypuAfEAvMJiRdugu3Zuw= X-Received: by 2002:a05:6000:2681:b0:3fe:1d64:1871 with SMTP id ffacd0b85a97d-4266e8de136mr15802528f8f.43.1760449110631; Tue, 14 Oct 2025 06:38:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpn9TdcctsX5R2l6ZapaOFPFL00LPWCqLizUp9Qn7u93U+Blj2vpvXuCyvqYAeXdVUEkDs6w== X-Received: by 2002:a05:6000:2681:b0:3fe:1d64:1871 with SMTP id ffacd0b85a97d-4266e8de136mr15802509f8f.43.1760449110183; Tue, 14 Oct 2025 06:38:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Zhao Liu Subject: [PULL 27/28] timer: constify some functions Date: Tue, 14 Oct 2025 15:37:12 +0200 Message-ID: <20251014133713.1103695-27-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449143190154100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- include/qemu/timer.h | 6 +++--- util/qemu-timer.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/qemu/timer.h b/include/qemu/timer.h index abd2204f3be..aec730ac257 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -699,7 +699,7 @@ void timer_mod_anticipate(QEMUTimer *ts, int64_t expire= _time); * * Returns: true if the timer is pending */ -bool timer_pending(QEMUTimer *ts); +bool timer_pending(const QEMUTimer *ts); =20 /** * timer_expired: @@ -710,7 +710,7 @@ bool timer_pending(QEMUTimer *ts); * * Returns: true if the timer has expired */ -bool timer_expired(QEMUTimer *timer_head, int64_t current_time); +bool timer_expired(const QEMUTimer *timer_head, int64_t current_time); =20 /** * timer_expire_time_ns: @@ -720,7 +720,7 @@ bool timer_expired(QEMUTimer *timer_head, int64_t curre= nt_time); * * Returns: the expiry time in nanoseconds */ -uint64_t timer_expire_time_ns(QEMUTimer *ts); +uint64_t timer_expire_time_ns(const QEMUTimer *ts); =20 /** * timer_get: diff --git a/util/qemu-timer.c b/util/qemu-timer.c index 1fb48be281a..56f11b6a641 100644 --- a/util/qemu-timer.c +++ b/util/qemu-timer.c @@ -89,7 +89,7 @@ static inline QEMUClock *qemu_clock_ptr(QEMUClockType typ= e) return &qemu_clocks[type]; } =20 -static bool timer_expired_ns(QEMUTimer *timer_head, int64_t current_time) +static bool timer_expired_ns(const QEMUTimer *timer_head, int64_t current_= time) { return timer_head && (timer_head->expire_time <=3D current_time); } @@ -475,12 +475,12 @@ void timer_mod_anticipate(QEMUTimer *ts, int64_t expi= re_time) timer_mod_anticipate_ns(ts, expire_time * ts->scale); } =20 -bool timer_pending(QEMUTimer *ts) +bool timer_pending(const QEMUTimer *ts) { return ts->expire_time >=3D 0; } =20 -bool timer_expired(QEMUTimer *timer_head, int64_t current_time) +bool timer_expired(const QEMUTimer *timer_head, int64_t current_time) { return timer_expired_ns(timer_head, current_time * timer_head->scale); } @@ -649,7 +649,7 @@ void init_clocks(QEMUTimerListNotifyCB *notify_cb) #endif } =20 -uint64_t timer_expire_time_ns(QEMUTimer *ts) +uint64_t timer_expire_time_ns(const QEMUTimer *ts) { return timer_pending(ts) ? ts->expire_time : -1; } --=20 2.51.0 From nobody Fri Nov 14 18:21:52 2025 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760449199; cv=none; d=zohomail.com; s=zohoarc; b=lZpvUvBw89LYAUYajPcCCsyqh+AyFBhYF+6n9e0o0IbSfPsNX9+FVOXkDu5mm4jMKQRscE9+fs9q1VilNXkNEIpOn5iV2BZMzMPoGKdB5hZc8d1czNHXPO35wUf//hucdIKlD5zPhYBrbyCvyl7VEqFPbWcRAfxCZnTwYL9tYsQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760449199; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Uh/pxSQ/Sd1WhNbQxNStDv+XeBlFCMlLdX4UKvDjl8Q=; b=l6KB9SK63Cv+ZnkeLvmdSPusnVq/36d9IrKFnUsk/Df7XFnyyCcQPaTg4s4orYgR63SDNomGGwFt+53BEeDufs+6Mub6vzVAQK44L0Qn7sTnQsLAHs9KXk9Rs+ffkDqlPST9EU1uEF7awih9tbFlEg4tavrWWksF8gIkQyJ/67A= ARC-Authentication-Results: i=1; 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760449199469666.3740481658809; Tue, 14 Oct 2025 06:39:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8fEw-0006Ui-EX; Tue, 14 Oct 2025 09:38:58 -0400 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 1v8fEn-0006JU-CY for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8fEc-0001Bt-T5 for qemu-devel@nongnu.org; Tue, 14 Oct 2025 09:38:48 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-675-kvZuiuB0OEqCLwaWK8519g-1; Tue, 14 Oct 2025 09:38:35 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-46e36686ca1so49926475e9.2 for ; Tue, 14 Oct 2025 06:38:35 -0700 (PDT) Received: from [192.168.10.48] ([151.61.22.175]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fab36ed3bsm163774515e9.0.2025.10.14.06.38.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 06:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760449117; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Uh/pxSQ/Sd1WhNbQxNStDv+XeBlFCMlLdX4UKvDjl8Q=; b=dZj4RFqsmj8ykWu3Q3bhWUHa+Z1+o2iozaMFqOqF5s1qkw9HlmKUDVRAS3bukCYskXuIZx yH50sWwJTlpvnCk64S1heaZzQnvRI1MFMSpCyZiOvOGJT1Puc+80oQ4rwICTRil19H48lo BaNayTyPNfE4DhsVkI7PKXWzMAIxjAI= X-MC-Unique: kvZuiuB0OEqCLwaWK8519g-1 X-Mimecast-MFC-AGG-ID: kvZuiuB0OEqCLwaWK8519g_1760449115 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760449114; x=1761053914; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uh/pxSQ/Sd1WhNbQxNStDv+XeBlFCMlLdX4UKvDjl8Q=; b=NU8sEqxdrBCvEVqpRlXiUfG5b051vUcRwArLmzEWLSaQJhDwNqW0q3rdFVvbhwiSsl h/fE0HlIb/PiSO53sPE/OloI8kRoqXchVSuhRSJjVJSLVnKN1fDjKNBXl92OZheT9tT7 QbtgacCFzJi7o85hntwHs58a8xBqcKmzphbHeifo/m7TnCAf7FGDTOiOkLTo4gWbA48R v1dP1d2bmrKWraL8oG8IfCbzFTkNiQ8hQIPdjoR0Xl13R/SmR6CbL9oi1pjKh+GAgx6S m3agGG1x09Ve27tIyvBse//3FlP9sJzDQIz4pNQoueecsNo+zuQV7/VLdjqNp5PFGZuV EZiA== X-Gm-Message-State: AOJu0YwAeDYuNC7IrE+ULHCeR5h7632h6xG3Yl0tC4nqF/9ag25Hkrwn 0dLx6XjItFfl5p2S1RKO2u4Tjnv/68VizI1fT5nZfMLt/X6T37kHKpBsfhsPdnDsSpp2xFJ6EYk +OJoe911FEE7wbdkb1RFnhLEvCQBQR98cKb6BWo+O5jlQb7OU3gJw71ouHbfEKYmWXLCWuFX/QU ULmNherPjYZMxmpP1fGqIRBy/YTpC5u3ht+hzQEbvj X-Gm-Gg: ASbGncsrEwaQ5YLsF7B3I4MyHwKtDqtNMZSDNLF2qGS8pnvSA43Nrf5rEPx/Tyk2SO0 e0L3jWaV9UXcE88Cwcq9P6Q7wWH0khJF3Kd9jWnCQiVTUfjli6yxBqVLGugimbheTTeISYudlcb 8O6Q14eW78YCVqdkuqyGjGrDoZ6mNy1c965y0IhfODFpCl2ZrkC0VInsxrCk6FiT8yfLhF6Y3Md izxTbd6hlxl/m6+J/PCOPZQ7G8PrzRBofIDXwdDTkvYdDAL95poUlBSN2xTXlTTh8tss+5pbMHx 7OKLB+CNzAOJbd/njZSZUYArL5xIheM65SSuu1MNh/u4iJhSNjiY3Qs28ims9TGPFihJbfHNzzE BmQWAnbkvpfl8nToicrtHwQ6BqAHKA0I7NQDy1zed4Gs= X-Received: by 2002:a05:600c:c091:b0:46e:59bd:f7d3 with SMTP id 5b1f17b1804b1-46fae33dffamr98424775e9.20.1760449114183; Tue, 14 Oct 2025 06:38:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE21Pc7pirquGQfHgv3GbUAv+Qiye+ZBS8YQ2zNUOpUiNxmh7qAInM154RCSTudFmqOfSUp+w== X-Received: by 2002:a05:600c:c091:b0:46e:59bd:f7d3 with SMTP id 5b1f17b1804b1-46fae33dffamr98424655e9.20.1760449113763; Tue, 14 Oct 2025 06:38:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Zhao Liu Subject: [PULL 28/28] rust: migration: implement ToMigrationState as part of impl_vmstate_bitsized Date: Tue, 14 Oct 2025 15:37:13 +0200 Message-ID: <20251014133713.1103695-28-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251014133540.1103268-1-pbonzini@redhat.com> References: <20251014133540.1103268-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760449204576158500 Content-Type: text/plain; charset="utf-8" This is most likely desirable, and is the easiest way to migrate a bit-sized value without peeking at the innards of the bilge crate. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/migration/src/vmstate.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index 445fe7fbc08..42e5df8d818 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -296,6 +296,25 @@ unsafe impl $crate::vmstate::VMState for $type { as ::bilge::prelude::Number>::Un= derlyingType as $crate::vmstate::VMState>::VAR= RAY_FLAG; } + + impl $crate::migratable::ToMigrationState for $type { + type Migrated =3D <<$type as ::bilge::prelude::Bitsized>::Arbi= traryInt + as ::bilge::prelude::Number>::Un= derlyingType; + + fn snapshot_migration_state(&self, target: &mut Self::Migrated= ) -> Result<(), $crate::InvalidError> { + *target =3D Self::Migrated::from(*self); + Ok(()) + } + + fn restore_migrated_state_mut( + &mut self, + source: Self::Migrated, + version_id: u8, + ) -> Result<(), $crate::InvalidError> { + *self =3D Self::from(source); + Ok(()) + } + } }; } =20 --=20 2.51.0