From nobody Fri Nov 14 22:21:13 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=1759996324; cv=none; d=zohomail.com; s=zohoarc; b=KxdgKb8R51/sXTHIL978evoBWpH3aQAyQK7/xoot7ipu8JoUU0S9F2vR1uCNxEiV+pEGgdLw93ZL+XH3rMre/PTpsW86lCwz1pI0nV8O/kJsLRvogWPNA3vguDaM8/spTEivSNTdP4W99FyTYU1h9HeO8WuSLaj0pioUR6TYfEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996324; 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=9cRZKuLYf1PeX3kptJkawumw9y9xmtGwH/7o1mOtoO4=; b=PsoS2/1zzj3/CPWUR56nL/xGf/Y8Sh2P4ObcxaKJE9YO05sYacI108ULHq+FrvH++5rZZ5mEjn0KNEIt/Al3adjXBnhGRHJrFXGEuf8QufQcLh+EXebBUTV6A/SkQjnWXBQft0hDZnoW3az7DGRGt+ikNskvXPSxSxvxgvEUZl8= 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 1759996324828864.2579985447383; Thu, 9 Oct 2025 00:52:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQA-00089z-WE; Thu, 09 Oct 2025 03:50: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 1v6lQ8-00089a-G2 for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:40 -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 1v6lQ4-0004JG-Co for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:39 -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-433-qUKCnBPrMCiCfb967RRbMg-1; Thu, 09 Oct 2025 03:50:31 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3ece0fd841cso684956f8f.0 for ; Thu, 09 Oct 2025 00:50:30 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46faf09a0e8sm33914095e9.0.2025.10.09.00.50.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996232; 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=9cRZKuLYf1PeX3kptJkawumw9y9xmtGwH/7o1mOtoO4=; b=SOclfsWJtNiKMp/YymH/n2MelCpcyxKycOapDyj9ug3/bXpauso4HDy2DhuAUsxZT3jWfe Quq9UD2n7psdYXSQYQriRWBdMrPS8N89KhXpZuABxXeTBvJzI/4h7e9MDEoshEGyuohfbN wOYPRTsDklrvlVdamGRqYw3GxMeR75E= X-MC-Unique: qUKCnBPrMCiCfb967RRbMg-1 X-Mimecast-MFC-AGG-ID: qUKCnBPrMCiCfb967RRbMg_1759996230 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996229; x=1760601029; 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=9cRZKuLYf1PeX3kptJkawumw9y9xmtGwH/7o1mOtoO4=; b=fx+uuPTFHw6rv8g582ybYz1oi3TuNHbqIcz35HMA7dIHyriBQGH0GGUaaxEB0FswD+ XDK/l6XuaAza5+hfMU/7H6w1IcR5Hgs/NmXQM3Nhm7b3Dya+El5klKbFAl6AVhDUdyu7 EatnKksiQqpXn/ycsNmjLURIWxkfPyVWfVBjokUVLzeg5UYG2w5ro0tr2sfqgReNH0tI F7W/XnOzThjIqgWI3EWNKppFzAz8fyU6imghi45ss2/+YBn3zLZVuadcrIbq7jpvshl9 m9nuN34C476PYCZBFM2di9cv3tACJor9SYBwjO/welvBkLVCqore0kwov8FYKMlEpvFH K29w== X-Gm-Message-State: AOJu0YyjP3SZRtQsCqo0gl8yPlgdbRnWzILuBMVDt7TH44uGRaXv1pBQ 5BkGvVxNR8S7+VG5snX6CAo5qCg6EsgkvQIY3l63tkBMmpUc6y5bcEAJFEoVkfgS/NCG31OBYSO 4iKuAf4DemOkpRff4bleGpxlAheaXC693rAGTw/NgK4UVHO3haJxoa6Muhe2JOS+As2ARWBKaQ6 aKWE30eLXKEt14CWbfnyTZE3MDb1fM4H/yJa+ojVSNq7c= X-Gm-Gg: ASbGncvYS+lo33lYE9tUblrDipwvxidCat+y33xaYpLKNFwf7fIiB+xVB1/sHIjvbTL 9tZWKHZKYJOZeEcGgTyV+PslC1DcTWClTJs3AuK/wAs0Zv7FRtBG+o27v4Hia/t3W8nGgf+QY8+ 8rYztyx6WMAJ4ApaIJd+l9wINf/vysWtUmYmKzahJ/aEkGdjdfTM+wvqupUw/Q+p9a2A+s9NUJC 3kjOyMQs8Fyov6m/Bfmf1tPBrkTwRTGGDH1wndN+PREcZ2V7OmP1LCIdhwzUeh+ks3E+in38OH2 y3duK30Umt/+vTdMDdQFE7OgAdTAG9lJrNXUs19IaC0oz5rjE/1NODibxTRCqXUDxmJ82ycil/O J0ldxkqLynPZX+ps/OzrKMhDq++uPebvVBugaxAaXn7VIuGKE X-Received: by 2002:a05:6000:2c0e:b0:3df:c5e3:55fe with SMTP id ffacd0b85a97d-4266e7dff05mr4046067f8f.29.1759996228950; Thu, 09 Oct 2025 00:50:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkyTYv6M1S+Be8mcKj6gGA7rEyjy70kpY0Kd4YeHH4v29SLgbSy/ofY0SsqMsMwBIheu2ZWg== X-Received: by 2002:a05:6000:2c0e:b0:3df:c5e3:55fe with SMTP id ffacd0b85a97d-4266e7dff05mr4046047f8f.29.1759996228534; Thu, 09 Oct 2025 00:50:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 01/35] subprojects: Remove version number from .gitignore Date: Thu, 9 Oct 2025 09:49:51 +0200 Message-ID: <20251009075026.505715-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996328253154100 Get rid of all the version numbers, and use wildcard matches instead, because peopl will repeatedly forgot to change these versions. Suggested-by: Manos Pitsidianakis Suggested-by: Daniel P. Berrang=C3=A9 Suggested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini --- subprojects/.gitignore | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/subprojects/.gitignore b/subprojects/.gitignore index 58a29f01204..0b5d9634094 100644 --- a/subprojects/.gitignore +++ b/subprojects/.gitignore @@ -6,21 +6,21 @@ /keycodemapdb /libvfio-user /slirp -/anyhow-1.0.98 -/arbitrary-int-1.2.7 -/attrs-0.2.9 -/bilge-0.2.0 -/bilge-impl-0.2.0 -/either-1.12.0 -/foreign-0.3.1 -/itertools-0.11.0 -/libc-0.2.162 -/proc-macro-error-1.0.4 -/proc-macro-error-attr-1.0.4 -/proc-macro2-1.0.95 -/quote-1.0.36 -/syn-2.0.66 -/unicode-ident-1.0.12 +/anyhow-* +/arbitrary-int-* +/attrs-* +/bilge-* +/bilge-impl-* +/either-* +/foreign-* +/itertools-* +/libc-* +/proc-macro-error-* +/proc-macro-error-attr-* +/proc-macro* +/quote-* +/syn-* +/unicode-ident-* =20 # Workaround for Meson v1.9.0 https://github.com/mesonbuild/meson/issues/1= 4948 /.wraplock --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996327; cv=none; d=zohomail.com; s=zohoarc; b=kA3yx0T8PIFJ1WAnCAhX/ZMR5uBEScwi965wJ3CwvD84bCSNTHe4IOBWqSMvrERz3rheQqihoMxxt74vXXZ3ywM+/lFGnPZ4RhfAhWnBEghywvcwDFXhOI9OrfgfGV8R0kW0V0796HMKUJ7/8D6PY8HRlO4WfRwI/zTSIx4e6GM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996327; 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=q+W9mI2TEY8Vy131c26AX2u4Sj+/YtxNA/TPL0BdJ4c=; b=mojQ9i1OgM0dnh01CJMMPB1xqjwfYyVXPSPMg++aCLwYwTNMOhprs03mMzhgttF6ubWuVN5oNDs4pDWo/fELL41oXv7/a1JYDVMVUna4CkR/OdjUUZ2PR1cjOQ4g7+sKISiOyaBYSYfWklS1Zx27RScx6O/NLww85Gmd/TyZgGE= 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 1759996327154466.7312382632706; Thu, 9 Oct 2025 00:52:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQI-0008BT-KS; Thu, 09 Oct 2025 03:50:50 -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 1v6lQF-0008Ai-2C for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:47 -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 1v6lQ6-0004JQ-00 for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:45 -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-150-IhnBmfLiMNqiBCmGbQ4hUQ-1; Thu, 09 Oct 2025 03:50:33 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3efe4fcc9ccso558339f8f.3 for ; Thu, 09 Oct 2025 00:50:33 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6b8bsm33338305f8f.4.2025.10.09.00.50.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996235; 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=q+W9mI2TEY8Vy131c26AX2u4Sj+/YtxNA/TPL0BdJ4c=; b=WRut60cqKRqNGoQXrQ3wE8i6QEsUrsxgJOlPtjmoNh8W0Q+O/J+3BNp1yKMjrwofDTvSvp m8q6fBogtPEGEWOUHzwBU/IiGF4EVMtQJPOrgLPa+idahrF46CHUc2wDzr3xegIozeBfZK KgwMvpnEXyc/eQ1s6kzkdv9OOecm7Tw= X-MC-Unique: IhnBmfLiMNqiBCmGbQ4hUQ-1 X-Mimecast-MFC-AGG-ID: IhnBmfLiMNqiBCmGbQ4hUQ_1759996232 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996232; x=1760601032; 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=q+W9mI2TEY8Vy131c26AX2u4Sj+/YtxNA/TPL0BdJ4c=; b=t+9RSqQIKwzk8p++qMO3nllWhKlsZvV455sxxN1K6+xhyt68gKXShTDHZxcHlpawtn HE30WtEM7XkgQMkivBvVNsSGCO+PLU6MvSywtzuDZsdXN+qY31iL2s5/p9PMUQaAMF5w /c66S30nTAB9KInM5o8xb/LNyM4YqzMY32SqxUS86+6hakygFpOiRHJvKDKCL40xqJin w9ebHdSraMt1uC25Rh6KL21d7Cd+pyNMcuhmenaBiW2gFW/jdWztWDNDVJK2xb6yVyoA jpYTj7TAflLxoNzuLmxJB6tNOMUmz2rKayRLTOAJ33LCgj7XwDoQGncO6XVyr31iw8Tv ORsQ== X-Gm-Message-State: AOJu0Yx7uc4Okws+DOoVa28Z+vn7w2EHhAHGTTAUcR1PqN1wIe6rAlG4 3jVJqaE+ZH16RpQ7zzwSk1jquvaN5cmsuskAg+rZvq/bS0PQrTiZi0ROmcjdJIolMyL1VA7pm/q /rICNfnOg2fVkqdvENg5SXigWFfnagUaKu+m4iyQ46BDA1jXiHGmplXOH0zYxOhUT0tNZ6cdAel idP9aIhZ28O6h94mSd1xY8LTfXFZUoUb/RNbphZ0QKbTY= X-Gm-Gg: ASbGncs2RAaDXWdvu//GyeBjX0n6iOtl+KevtTAzC8aCRao8UzeKX9Xv6MFk5bIlOmt kdzt/COycdEy9hws5Tt/gbm0ADwonZiWhDjFBjn4oqG07mPQYnDcepdAvn4oajeoEtDgUM9gwXy 5/X3iJYUqJFG/kzxibX86xJUPxhnwU2w9sqORgEPFlB3d3XieHaFL+/seXo3mTj+/vrdhCjda4O v5TAqu4wGDGxECzkIffv0qACU08U0rd+XvMq4wSqjhuRMkZYWCqmueBvTqnZ561R8r0cWVecR81 XCgJKrFYiYD4JivQ6W9LZ950e2ckxVBjaOpP3hdV7VSGmPQyNPt4zrhh7NzNENYmray9yjMUgQW 5EPGeuv9IjsZOyRp8ISzUd4cUfHhGHvB2WzWqlFLz+gWBySIp X-Received: by 2002:a05:6000:4382:b0:424:21d8:de30 with SMTP id ffacd0b85a97d-4266e8e90eamr4189856f8f.62.1759996231586; Thu, 09 Oct 2025 00:50:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEBZhGy+5RcSO2LUdm0r+NLgSOcg/heS2pbzeCZ8Z8lMwtln/pj/fi2F0jU5nUXwExE6UvtPw== X-Received: by 2002:a05:6000:4382:b0:424:21d8:de30 with SMTP id ffacd0b85a97d-4266e8e90eamr4189832f8f.62.1759996231083; Thu, 09 Oct 2025 00:50:31 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 02/35] subprojects: add glib-sys-rs Date: Thu, 9 Oct 2025 09:49:52 +0200 Message-ID: <20251009075026.505715-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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, 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: 1759996329765154100 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- rust/meson.build | 2 ++ scripts/archive-source.sh | 1 + subprojects/.gitignore | 1 + subprojects/glib-sys-0.21-rs.wrap | 7 ++++ .../packagefiles/glib-sys-0.21-rs/meson.build | 33 +++++++++++++++++++ 5 files changed, 44 insertions(+) create mode 100644 subprojects/glib-sys-0.21-rs.wrap create mode 100644 subprojects/packagefiles/glib-sys-0.21-rs/meson.build diff --git a/rust/meson.build b/rust/meson.build index 695d5a62de9..6ba075c8c71 100644 --- a/rust/meson.build +++ b/rust/meson.build @@ -2,12 +2,14 @@ subproject('anyhow-1-rs', required: true) subproject('bilge-0.2-rs', required: true) subproject('bilge-impl-0.2-rs', required: true) subproject('foreign-0.3-rs', required: true) +subproject('glib-sys-0.21-rs', required: true) subproject('libc-0.2-rs', required: true) =20 anyhow_rs =3D dependency('anyhow-1-rs') bilge_rs =3D dependency('bilge-0.2-rs') bilge_impl_rs =3D dependency('bilge-impl-0.2-rs') foreign_rs =3D dependency('foreign-0.3-rs') +glib_sys_rs =3D dependency('glib-sys-0.21-rs') libc_rs =3D dependency('libc-0.2-rs') =20 subproject('proc-macro2-1-rs', required: true) diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh index a725dd923dc..8f97b19a088 100755 --- a/scripts/archive-source.sh +++ b/scripts/archive-source.sh @@ -36,6 +36,7 @@ subprojects=3D( bilge-impl-0.2-rs either-1-rs foreign-0.3-rs + glib-sys-0.21-rs itertools-0.11-rs keycodemapdb libc-0.2-rs diff --git a/subprojects/.gitignore b/subprojects/.gitignore index 0b5d9634094..c00c8478372 100644 --- a/subprojects/.gitignore +++ b/subprojects/.gitignore @@ -13,6 +13,7 @@ /bilge-impl-* /either-* /foreign-* +/glib-sys-* /itertools-* /libc-* /proc-macro-error-* diff --git a/subprojects/glib-sys-0.21-rs.wrap b/subprojects/glib-sys-0.21-= rs.wrap new file mode 100644 index 00000000000..313ced731ac --- /dev/null +++ b/subprojects/glib-sys-0.21-rs.wrap @@ -0,0 +1,7 @@ +[wrap-file] +directory =3D glib-sys-0.21.2 +source_url =3D https://crates.io/api/v1/crates/glib-sys/0.21.2/download +source_filename =3D glib-sys-0.21.2.tar.gz +source_hash =3D d09d3d0fddf7239521674e57b0465dfbd844632fec54f059f7f56112e3= f927e1 +#method =3D cargo +patch_directory =3D glib-sys-0.21-rs diff --git a/subprojects/packagefiles/glib-sys-0.21-rs/meson.build b/subpro= jects/packagefiles/glib-sys-0.21-rs/meson.build new file mode 100644 index 00000000000..8c5483311ed --- /dev/null +++ b/subprojects/packagefiles/glib-sys-0.21-rs/meson.build @@ -0,0 +1,33 @@ +project('glib-sys-0.21-rs', 'rust', + meson_version: '>=3D1.5.0', + version: '0.21.2', + license: 'MIT', + default_options: []) + +subproject('libc-0.2-rs', required: true) +libc_rs =3D dependency('libc-0.2-rs') + +_glib_sys_rs =3D static_library( + 'glib_sys', + files('src/lib.rs'), + gnu_symbol_visibility: 'hidden', + override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], + rust_abi: 'rust', + rust_args: [ + '--cap-lints', 'allow', + '--cfg', 'feature=3D"v2_66"', + '--cfg', 'feature=3D"v2_64"', + '--cfg', 'feature=3D"v2_62"', + '--cfg', 'feature=3D"v2_60"', + '--cfg', 'feature=3D"v2_58"', + ], + # should also link with glib; don't bother doing it here since all + # QEMU targets have it + dependencies: [libc_rs], +) + +glib_sys_dep =3D declare_dependency( + link_with: _glib_sys_rs, +) + +meson.override_dependency('glib-sys-0.21-rs', glib_sys_dep) --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996695; cv=none; d=zohomail.com; s=zohoarc; b=AkzqNMxVD19NNFXb0FBhRUuaJ4iwZ31XB9PlMH45G6lQl0kwoBrGoL1VNu1UFDScxPnzJy9wAodPSMmR56Ky98hqbbFwTkLwnHIG2sYIBG/SYFetk2v17ZGqka8otsia4I+EpzqhB9Rin76aqp8yQcyCn4TEkDX606IU7cVKGHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996694; 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=gPWy9bRouIhDhdR+H4atS/CyKCnP4sSU4Jekx5brY74=; b=Q3qneSivPY7npIu+8hh7FKg0tTW+VSmIvhkRMdxEjPMXwu/ZSGMgeiUgUIZCuG5H1UecuoijzHqSmzYm2hFkTj/CfKt0LU1kAOquk/fC9/4/EBe7bJC+1zDgzssbNzb/LReA7xPRh/mny/OKb5r5VoaOO4N/iIxD55B8t0iG20c= 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 1759996694990132.20915199250305; Thu, 9 Oct 2025 00:58:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQP-0008DA-Jn; Thu, 09 Oct 2025 03:50: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 1v6lQN-0008Bq-4B for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:55 -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 1v6lQG-0004K3-4s for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:54 -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-96-I3NftokhOXuXmbQ7RC6hXw-1; Thu, 09 Oct 2025 03:50:36 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e377d8c80so2540885e9.3 for ; Thu, 09 Oct 2025 00:50:36 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f01absm33145877f8f.44.2025.10.09.00.50.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996238; 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=gPWy9bRouIhDhdR+H4atS/CyKCnP4sSU4Jekx5brY74=; b=Dwl0lSyqQYEojCwC+Ks+KQa22jMHIBdHqyRBqR87wnZ+NNOtvEexJsyIEef7G049E1YoC9 ipi5PtR/yU5Obi+yXVxC80nEaAQtKzQDvzf2njSk2a5cKSEosWO+oT8/B+Q+8BJQS19EcD kC5i9hAaezQgVlvzKSEQTNFuD2AKFGI= X-MC-Unique: I3NftokhOXuXmbQ7RC6hXw-1 X-Mimecast-MFC-AGG-ID: I3NftokhOXuXmbQ7RC6hXw_1759996235 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996234; x=1760601034; 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=gPWy9bRouIhDhdR+H4atS/CyKCnP4sSU4Jekx5brY74=; b=PQfRVjmqF6dHcdmEKL82xHy29kVKi5JX3xnobwBVqaHjFivk+lhj5ZUfdcjDqryzmE i8PUzHMZUCcRhP32+1BlWUpw6xpFw0cRDDkR6mGYMGrOHowDSUrLB2Ypw2pOg0JHw6PL G6UJNKrRwG5qS1SJJwXbjp0iaOo2anz4sBZcb/FLtGpI3ovYQp8k2CgNuO+rWKWJ8fRE 7g28GT6YqQ9aIdvhxiEUntXO+QabGkd93LKTiqtx+DuoFCG5H90Im5Lm3HREAmLj2DMX TrWQ5ldq4r6W0tvFrUUCgwA9DmXl7Vl34fG4jhLZieDZhSgfmOuGlHePXMwlxdKizJvl UNQw== X-Gm-Message-State: AOJu0YydHUvE7llG2lfC0q8w043ZCnCTjytV3FxKJWInxUhg7aBWKzMB cLRWYYNGmQr8/SNUF1v4U2S/OLwUjZ77MxYMNByTxm21IUlBqpP9QvN+b9M1PsoBjpZbAmkFZ9I 7FiTJ4HHRlwK64KTOmLXEVn5S0r+23fuVTDMZcQST7MTSWgWyuuWC2bbGZfJkLR9DxdKFiO+0lA B58136W3irJlZANev8aaMfpEYWCG/2GkmcJ017Kn2kz4s= X-Gm-Gg: ASbGncuCTHKsRJnNv5Zp6DWSwjcohavWnYSHYxj3zxANte62tJWby+29K9B8G5P+KKr yVwbw+U3/Qo+DNQ93o8FDo5qcgmdf5d7pTTbuuvNa3iRHm98bppp+hMOjh5ujgPmzFi8g+SrxqX JakI2YuCHxKRZXiIU4W9O4URkXocdredAXSKU6BG4ACsP0rbzDLp5b5wBWyu2rUuq33N3g9v/6s XCyTfHSHuzPRTKGg/ftDycc1UjQfE9vwFxzk2LiQc3m01Hy40w4o1GujygMfG66Mrd7evD/FZRH cFrSoX1Tw123Ozu0TX8kG5bAy+JV/Xci3BeiMHDk3mK4DnB6ZjqpHNVU0pokns1fNesX1z02BjV 3frOwD8X1M5CvYKZ3RxWR2U+pMnOi9B5jDUDljVvQ51x2MBpS X-Received: by 2002:a05:600c:529a:b0:46e:4912:d02a with SMTP id 5b1f17b1804b1-46fa9aef4cbmr41433755e9.23.1759996233888; Thu, 09 Oct 2025 00:50:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFo51EeFREj2ziGMhNzdELyPB/pTtwXzQ807Q0o7m8VNO4pyoCJbb+X9/d962WbDmEOLjJYRg== X-Received: by 2002:a05:600c:529a:b0:46e:4912:d02a with SMTP id 5b1f17b1804b1-46fa9aef4cbmr41433535e9.23.1759996233265; Thu, 09 Oct 2025 00:50:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 03/35] rust: use glib-sys Date: Thu, 9 Oct 2025 09:49:53 +0200 Message-ID: <20251009075026.505715-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996696008154100 From: Marc-Andr=C3=A9 Lureau Don't generate FFI for glib, rely on glib-sys crate. Signed-off-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- meson.build | 1 + include/hw/core/cpu.h | 2 +- rust/Cargo.lock | 180 +++++++++++++++++++++++++++++ rust/Cargo.toml | 1 + rust/bql/Cargo.toml | 1 + rust/bql/meson.build | 1 + rust/bql/src/bindings.rs | 4 + rust/chardev/Cargo.toml | 1 + rust/chardev/meson.build | 2 +- rust/chardev/src/bindings.rs | 4 + rust/hw/char/pl011/Cargo.toml | 1 + rust/hw/char/pl011/meson.build | 1 + rust/hw/char/pl011/src/bindings.rs | 5 + rust/hw/core/Cargo.toml | 1 + rust/hw/core/meson.build | 2 +- rust/hw/core/src/bindings.rs | 3 + rust/migration/Cargo.toml | 1 + rust/migration/meson.build | 2 +- rust/migration/src/bindings.rs | 1 + rust/qom/Cargo.toml | 1 + rust/qom/meson.build | 2 +- rust/qom/src/bindings.rs | 2 + rust/system/Cargo.toml | 1 + rust/system/meson.build | 2 +- rust/system/src/bindings.rs | 4 + rust/util/Cargo.toml | 1 + rust/util/meson.build | 2 +- rust/util/src/bindings.rs | 2 + 28 files changed, 224 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 55c8202a4d8..62766c0f19c 100644 --- a/meson.build +++ b/meson.build @@ -4239,6 +4239,7 @@ if have_rust '--no-prepend-enum-name', '--allowlist-file', meson.project_source_root() + '/include/.*', '--allowlist-file', meson.project_build_root() + '/.*', + '--blocklist-file', glib_pc.get_variable('includedir') + '/glib-2.0/.*= ', ] if not rustfmt.found() if bindgen.version().version_compare('<0.65.0') diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index c9f40c25392..4196293ba1c 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -169,7 +169,7 @@ struct CPUClass { vaddr (*gdb_adjust_breakpoint)(CPUState *cpu, vaddr addr); =20 const char *gdb_core_xml_file; - const gchar * (*gdb_arch_name)(CPUState *cpu); + const char * (*gdb_arch_name)(CPUState *cpu); const char * (*gdb_get_core_xml_file)(CPUState *cpu); =20 void (*disas_set_info)(CPUState *cpu, disassemble_info *info); diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 444ef516a70..11085133490 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -58,15 +58,27 @@ dependencies =3D [ name =3D "bql" version =3D "0.1.0" dependencies =3D [ + "glib-sys", "migration", ] =20 +[[package]] +name =3D "cfg-expr" +version =3D "0.20.3" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "1a2c5f3bf25ec225351aa1c8e230d04d880d3bd89dea133537dafad4ae29= 1e5c" +dependencies =3D [ + "smallvec", + "target-lexicon", +] + [[package]] name =3D "chardev" version =3D "0.1.0" dependencies =3D [ "bql", "common", + "glib-sys", "migration", "qom", "util", @@ -86,6 +98,12 @@ version =3D "1.12.0" source =3D "registry+https://github.com/rust-lang/crates.io-index" checksum =3D "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385= b58b" =20 +[[package]] +name =3D "equivalent" +version =3D "1.0.2" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe= 5c0f" + [[package]] name =3D "foreign" version =3D "0.3.1" @@ -95,6 +113,28 @@ dependencies =3D [ "libc", ] =20 +[[package]] +name =3D "glib-sys" +version =3D "0.21.2" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "d09d3d0fddf7239521674e57b0465dfbd844632fec54f059f7f56112e3f9= 27e1" +dependencies =3D [ + "libc", + "system-deps", +] + +[[package]] +name =3D "hashbrown" +version =3D "0.16.0" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482= 748d" + +[[package]] +name =3D "heck" +version =3D "0.5.0" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe= 55ea" + [[package]] name =3D "hpet" version =3D "0.1.0" @@ -115,6 +155,7 @@ dependencies =3D [ "bql", "chardev", "common", + "glib-sys", "migration", "qemu_macros", "qom", @@ -122,6 +163,16 @@ dependencies =3D [ "util", ] =20 +[[package]] +name =3D "indexmap" +version =3D "2.11.4" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b= 88e5" +dependencies =3D [ + "equivalent", + "hashbrown", +] + [[package]] name =3D "itertools" version =3D "0.11.0" @@ -137,14 +188,27 @@ version =3D "0.2.162" source =3D "registry+https://github.com/rust-lang/crates.io-index" checksum =3D "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef0150= 6398" =20 +[[package]] +name =3D "memchr" +version =3D "2.7.6" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4c= c273" + [[package]] name =3D "migration" version =3D "0.1.0" dependencies =3D [ "common", + "glib-sys", "util", ] =20 +[[package]] +name =3D "pkg-config" +version =3D "0.3.32" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b= 904c" + [[package]] name =3D "pl011" version =3D "0.1.0" @@ -155,6 +219,7 @@ dependencies =3D [ "bql", "chardev", "common", + "glib-sys", "hwcore", "migration", "qom", @@ -211,6 +276,7 @@ version =3D "0.1.0" dependencies =3D [ "bql", "common", + "glib-sys", "migration", "qemu_macros", "util", @@ -225,6 +291,50 @@ dependencies =3D [ "proc-macro2", ] =20 +[[package]] +name =3D "serde" +version =3D "1.0.226" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "0dca6411025b24b60bfa7ec1fe1f8e710ac09782dca409ee8237ba74b512= 95fd" +dependencies =3D [ + "serde_core", +] + +[[package]] +name =3D "serde_core" +version =3D "1.0.226" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "ba2ba63999edb9dac981fb34b3e5c0d111a69b0924e253ed29d83f7c99e9= 66a4" +dependencies =3D [ + "serde_derive", +] + +[[package]] +name =3D "serde_derive" +version =3D "1.0.226" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "8db53ae22f34573731bafa1db20f04027b2d25e02d8205921b569171699c= db33" +dependencies =3D [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name =3D "serde_spanned" +version =3D "0.6.9" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee= 75a3" +dependencies =3D [ + "serde", +] + +[[package]] +name =3D "smallvec" +version =3D "1.15.1" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6f= bd03" + [[package]] name =3D "syn" version =3D "2.0.104" @@ -241,10 +351,30 @@ name =3D "system" version =3D "0.1.0" dependencies =3D [ "common", + "glib-sys", "qom", "util", ] =20 +[[package]] +name =3D "system-deps" +version =3D "7.0.5" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "e4be53aa0cba896d2dc615bd42bbc130acdcffa239e0a2d965ea5b3b2a86= ffdb" +dependencies =3D [ + "cfg-expr", + "heck", + "pkg-config", + "toml", + "version-compare", +] + +[[package]] +name =3D "target-lexicon" +version =3D "0.13.2" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5= a69a" + [[package]] name =3D "tests" version =3D "0.1.0" @@ -259,6 +389,40 @@ dependencies =3D [ "util", ] =20 +[[package]] +name =3D "toml" +version =3D "0.8.23" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ce= d362" +dependencies =3D [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name =3D "toml_datetime" +version =3D "0.6.11" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8= f11c" +dependencies =3D [ + "serde", +] + +[[package]] +name =3D "toml_edit" +version =3D "0.22.27" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f= 819a" +dependencies =3D [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name =3D "trace" version =3D "0.1.0" @@ -279,11 +443,27 @@ dependencies =3D [ "anyhow", "common", "foreign", + "glib-sys", "libc", ] =20 +[[package]] +name =3D "version-compare" +version =3D "0.2.0" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411= c98b" + [[package]] name =3D "version_check" version =3D "0.9.4" source =3D "registry+https://github.com/rust-lang/crates.io-index" checksum =3D "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e= 483f" + +[[package]] +name =3D "winnow" +version =3D "0.7.13" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc90393= 39cf" +dependencies =3D [ + "memchr", +] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index f372d7dbf70..783e626802c 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -29,6 +29,7 @@ authors =3D ["The QEMU Project Developers "] anyhow =3D "~1.0" foreign =3D "~0.3.1" libc =3D "0.2.162" +glib-sys =3D { version =3D "0.21.2", features =3D ["v2_66"] } =20 [workspace.lints.rust] unexpected_cfgs =3D { level =3D "deny", check-cfg =3D ['cfg(MESON)'] } diff --git a/rust/bql/Cargo.toml b/rust/bql/Cargo.toml index 1041bd4ea93..d5177e5f8e2 100644 --- a/rust/bql/Cargo.toml +++ b/rust/bql/Cargo.toml @@ -14,6 +14,7 @@ rust-version.workspace =3D true =20 [dependencies] migration =3D { path =3D "../migration" } +glib-sys.workspace =3D true =20 [features] default =3D ["debug_cell"] diff --git a/rust/bql/meson.build b/rust/bql/meson.build index bc51c7f160b..22d7c9b8776 100644 --- a/rust/bql/meson.build +++ b/rust/bql/meson.build @@ -38,6 +38,7 @@ _bql_rs =3D static_library( rust_abi: 'rust', rust_args: _bql_cfg, link_with: [_migration_rs], + dependencies: [glib_sys_rs], ) =20 bql_rs =3D declare_dependency(link_with: [_bql_rs], diff --git a/rust/bql/src/bindings.rs b/rust/bql/src/bindings.rs index 9ffff12cded..8c70f3a87ce 100644 --- a/rust/bql/src/bindings.rs +++ b/rust/bql/src/bindings.rs @@ -18,6 +18,10 @@ clippy::too_many_arguments )] =20 +use glib_sys::{ + guint, GArray, GHashTable, GHashTableIter, GList, GPollFD, GPtrArray, = GQueue, GSList, GSource, +}; + #[cfg(MESON)] include!("bindings.inc.rs"); =20 diff --git a/rust/chardev/Cargo.toml b/rust/chardev/Cargo.toml index 3e77972546e..f105189dccb 100644 --- a/rust/chardev/Cargo.toml +++ b/rust/chardev/Cargo.toml @@ -13,6 +13,7 @@ repository.workspace =3D true rust-version.workspace =3D true =20 [dependencies] +glib-sys =3D { workspace =3D true } common =3D { path =3D "../common" } bql =3D { path =3D "../bql" } migration =3D { path =3D "../migration" } diff --git a/rust/chardev/meson.build b/rust/chardev/meson.build index e7ce02b3bc2..d365d8dd0f4 100644 --- a/rust/chardev/meson.build +++ b/rust/chardev/meson.build @@ -36,7 +36,7 @@ _chardev_rs =3D static_library( override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', link_with: [_bql_rs, _migration_rs, _qom_rs, _util_rs], - dependencies: [common_rs, qemu_macros], + dependencies: [glib_sys_rs, common_rs, qemu_macros], ) =20 chardev_rs =3D declare_dependency(link_with: [_chardev_rs], dependencies: = [chardev, qemuutil]) diff --git a/rust/chardev/src/bindings.rs b/rust/chardev/src/bindings.rs index 2d98026d627..c95dc89c56d 100644 --- a/rust/chardev/src/bindings.rs +++ b/rust/chardev/src/bindings.rs @@ -19,6 +19,10 @@ )] =20 use common::Zeroable; +use glib_sys::{ + gboolean, guint, GArray, GHashTable, GHashTableIter, GIOCondition, GLi= st, GMainContext, + GPollFD, GPtrArray, GQueue, GSList, GSource, GSourceFunc, +}; =20 #[cfg(MESON)] include!("bindings.inc.rs"); diff --git a/rust/hw/char/pl011/Cargo.toml b/rust/hw/char/pl011/Cargo.toml index dc41d0e499e..5b319455ee3 100644 --- a/rust/hw/char/pl011/Cargo.toml +++ b/rust/hw/char/pl011/Cargo.toml @@ -13,6 +13,7 @@ repository.workspace =3D true rust-version.workspace =3D true =20 [dependencies] +glib-sys.workspace =3D true bilge =3D { version =3D "0.2.0" } bilge-impl =3D { version =3D "0.2.0" } bits =3D { path =3D "../../../bits" } diff --git a/rust/hw/char/pl011/meson.build b/rust/hw/char/pl011/meson.build index 07b3da17e83..33b91f21911 100644 --- a/rust/hw/char/pl011/meson.build +++ b/rust/hw/char/pl011/meson.build @@ -33,6 +33,7 @@ _libpl011_rs =3D static_library( bilge_impl_rs, bits_rs, common_rs, + glib_sys_rs, util_rs, migration_rs, bql_rs, diff --git a/rust/hw/char/pl011/src/bindings.rs b/rust/hw/char/pl011/src/bi= ndings.rs index bd5ea840cb2..52a76d0de5c 100644 --- a/rust/hw/char/pl011/src/bindings.rs +++ b/rust/hw/char/pl011/src/bindings.rs @@ -20,6 +20,11 @@ =20 //! `bindgen`-generated declarations. =20 +use glib_sys::{ + gboolean, guint, GArray, GByteArray, GHashTable, GHashTableIter, GIOCo= ndition, GList, + GMainContext, GPollFD, GPtrArray, GQueue, GSList, GSource, GSourceFunc= , GString, +}; + #[cfg(MESON)] include!("bindings.inc.rs"); =20 diff --git a/rust/hw/core/Cargo.toml b/rust/hw/core/Cargo.toml index 9a9aa517082..ecfb5647184 100644 --- a/rust/hw/core/Cargo.toml +++ b/rust/hw/core/Cargo.toml @@ -13,6 +13,7 @@ repository.workspace =3D true rust-version.workspace =3D true =20 [dependencies] +glib-sys.workspace =3D true qemu_macros =3D { path =3D "../../qemu-macros" } common =3D { path =3D "../../common" } bql =3D { path =3D "../../bql" } diff --git a/rust/hw/core/meson.build b/rust/hw/core/meson.build index e1ae95ed61e..1560dd20c6b 100644 --- a/rust/hw/core/meson.build +++ b/rust/hw/core/meson.build @@ -59,7 +59,7 @@ _hwcore_rs =3D static_library( override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', link_with: [_bql_rs, _chardev_rs, _migration_rs, _qom_rs, _system_rs, _u= til_rs], - dependencies: [qemu_macros, common_rs], + dependencies: [glib_sys_rs, qemu_macros, common_rs], ) =20 hwcore_rs =3D declare_dependency(link_with: [_hwcore_rs], diff --git a/rust/hw/core/src/bindings.rs b/rust/hw/core/src/bindings.rs index 919c02b56ae..65b9aae7536 100644 --- a/rust/hw/core/src/bindings.rs +++ b/rust/hw/core/src/bindings.rs @@ -20,6 +20,9 @@ =20 use chardev::bindings::Chardev; use common::Zeroable; +use glib_sys::{ + GArray, GByteArray, GHashTable, GHashTableIter, GList, GPtrArray, GQue= ue, GSList, GString, +}; use migration::bindings::VMStateDescription; use qom::bindings::ObjectClass; use system::bindings::MemoryRegion; diff --git a/rust/migration/Cargo.toml b/rust/migration/Cargo.toml index 708bfaaa682..94504f3625c 100644 --- a/rust/migration/Cargo.toml +++ b/rust/migration/Cargo.toml @@ -15,6 +15,7 @@ rust-version.workspace =3D true [dependencies] common =3D { path =3D "../common" } util =3D { path =3D "../util" } +glib-sys.workspace =3D true =20 [lints] workspace =3D true diff --git a/rust/migration/meson.build b/rust/migration/meson.build index ddf5c2f51d5..18be65c92cf 100644 --- a/rust/migration/meson.build +++ b/rust/migration/meson.build @@ -38,7 +38,7 @@ _migration_rs =3D static_library( override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', link_with: [_util_rs], - dependencies: [common_rs], + dependencies: [common_rs, glib_sys_rs], ) =20 migration_rs =3D declare_dependency(link_with: [_migration_rs], diff --git a/rust/migration/src/bindings.rs b/rust/migration/src/bindings.rs index 8ce13a9000e..24503eb69bd 100644 --- a/rust/migration/src/bindings.rs +++ b/rust/migration/src/bindings.rs @@ -19,6 +19,7 @@ )] =20 use common::Zeroable; +use glib_sys::{GHashTable, GHashTableIter, GList, GPtrArray, GQueue, GSLis= t}; =20 #[cfg(MESON)] include!("bindings.inc.rs"); diff --git a/rust/qom/Cargo.toml b/rust/qom/Cargo.toml index 060ad2ec349..4be3c2541b6 100644 --- a/rust/qom/Cargo.toml +++ b/rust/qom/Cargo.toml @@ -18,6 +18,7 @@ bql =3D { path =3D "../bql" } migration =3D { path =3D "../migration" } qemu_macros =3D { path =3D "../qemu-macros" } util =3D { path =3D "../util" } +glib-sys.workspace =3D true =20 [lints] workspace =3D true diff --git a/rust/qom/meson.build b/rust/qom/meson.build index 71fdac696c3..e50f41858d6 100644 --- a/rust/qom/meson.build +++ b/rust/qom/meson.build @@ -29,7 +29,7 @@ _qom_rs =3D static_library( override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', link_with: [_bql_rs, _migration_rs], - dependencies: [common_rs, qemu_macros], + dependencies: [common_rs, glib_sys_rs, qemu_macros], ) =20 qom_rs =3D declare_dependency(link_with: [_qom_rs], dependencies: [qemu_ma= cros, qom]) diff --git a/rust/qom/src/bindings.rs b/rust/qom/src/bindings.rs index 9ffff12cded..91de42f2426 100644 --- a/rust/qom/src/bindings.rs +++ b/rust/qom/src/bindings.rs @@ -18,6 +18,8 @@ clippy::too_many_arguments )] =20 +use glib_sys::{GHashTable, GHashTableIter, GList, GPtrArray, GQueue, GSLis= t}; + #[cfg(MESON)] include!("bindings.inc.rs"); =20 diff --git a/rust/system/Cargo.toml b/rust/system/Cargo.toml index 7fd369b9e32..186ea00bfff 100644 --- a/rust/system/Cargo.toml +++ b/rust/system/Cargo.toml @@ -16,6 +16,7 @@ rust-version.workspace =3D true common =3D { path =3D "../common" } qom =3D { path =3D "../qom" } util =3D { path =3D "../util" } +glib-sys.workspace =3D true =20 [lints] workspace =3D true diff --git a/rust/system/meson.build b/rust/system/meson.build index 0859f397453..73d61991146 100644 --- a/rust/system/meson.build +++ b/rust/system/meson.build @@ -36,7 +36,7 @@ _system_rs =3D static_library( override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', link_with: [_bql_rs, _migration_rs, _qom_rs, _util_rs], - dependencies: [common_rs, qemu_macros], + dependencies: [glib_sys_rs, common_rs, qemu_macros], ) =20 system_rs =3D declare_dependency(link_with: [_system_rs], diff --git a/rust/system/src/bindings.rs b/rust/system/src/bindings.rs index 43edd98807a..6cbb588de3d 100644 --- a/rust/system/src/bindings.rs +++ b/rust/system/src/bindings.rs @@ -19,6 +19,10 @@ )] =20 use common::Zeroable; +use glib_sys::{ + guint, GArray, GByteArray, GHashTable, GHashTableIter, GList, GPollFD,= GPtrArray, GQueue, + GSList, GString, +}; =20 #[cfg(MESON)] include!("bindings.inc.rs"); diff --git a/rust/util/Cargo.toml b/rust/util/Cargo.toml index 1f6767ed9d1..85f91436545 100644 --- a/rust/util/Cargo.toml +++ b/rust/util/Cargo.toml @@ -15,6 +15,7 @@ rust-version.workspace =3D true [dependencies] anyhow =3D { workspace =3D true } foreign =3D { workspace =3D true } +glib-sys =3D { workspace =3D true } libc =3D { workspace =3D true } common =3D { path =3D "../common" } =20 diff --git a/rust/util/meson.build b/rust/util/meson.build index 094b43355aa..b0b75e93ff6 100644 --- a/rust/util/meson.build +++ b/rust/util/meson.build @@ -40,7 +40,7 @@ _util_rs =3D static_library( ), override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', - dependencies: [anyhow_rs, libc_rs, foreign_rs, common_rs, qom, qemuutil], + dependencies: [anyhow_rs, libc_rs, foreign_rs, glib_sys_rs, common_rs, q= om, qemuutil], ) =20 util_rs =3D declare_dependency(link_with: [_util_rs], dependencies: [qemuu= til, qom]) diff --git a/rust/util/src/bindings.rs b/rust/util/src/bindings.rs index 9ffff12cded..c277a295add 100644 --- a/rust/util/src/bindings.rs +++ b/rust/util/src/bindings.rs @@ -18,6 +18,8 @@ clippy::too_many_arguments )] =20 +use glib_sys::{guint, GList, GPollFD, GQueue, GSList, GString}; + #[cfg(MESON)] include!("bindings.inc.rs"); =20 --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996324; cv=none; d=zohomail.com; s=zohoarc; b=LA5dmZ0cwA59sKcBE8gQxMfAkFslsjrkSgaD+SfsCQVGhu6+8tUlrU1+efdZicXeZVP3qBdZyHnfd03Girjzl8293u6aHi1koAFn1p8DT2Cw8R+XjrBew6pLlp6cOYz/2pUC/wW2dJ/Oo9lBGRhPyfvZNRwHioci6Pwo5agFMa0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996324; 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=Q7iCef+6xuKmyGyRbd91CCrgKoZW7PCNqJldcVjWmVI=; b=dBivXj1kbq4Hwqu8rOOgnrbKBcV41PTy2MeBXxp5De391yQF6GSEj3eFvR6zW7Zx/5SZqObd2VFn8acdtFe0Es3CXXUh0jGVtpWuhCeDxRw/49xST4r/vqJHvxmgguCqxR+diEykBknvBvzXInI94nLmI52eZrOnuQwOD1ZWhqg= 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 175999632486196.0786222992449; Thu, 9 Oct 2025 00:52:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQG-0008B1-08; Thu, 09 Oct 2025 03:50:48 -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 1v6lQF-0008Aj-3J for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:47 -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 1v6lQ9-0004KM-11 for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:45 -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-284-mixsM9F0P_Kg6pa_LtgDuQ-1; Thu, 09 Oct 2025 03:50:37 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3efe4fcc9ccso558433f8f.3 for ; Thu, 09 Oct 2025 00:50:37 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fb1e0f019sm13829315e9.10.2025.10.09.00.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996239; 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=Q7iCef+6xuKmyGyRbd91CCrgKoZW7PCNqJldcVjWmVI=; b=cYKXyulHFBlbzG3W9E9sww6WurgynsXh+aeeONrR1SgN5AYMoBCCHwNo6k4xyWaOR+PXA0 RP/h1nNAy6JwkNva7csybOokBSHbeClu2HT/ncggq+TmrEOk6SICjLRx5C1GeQg3QK7/3e XrUwa8n+IoO//OOBRZADdulusYV1J1o= X-MC-Unique: mixsM9F0P_Kg6pa_LtgDuQ-1 X-Mimecast-MFC-AGG-ID: mixsM9F0P_Kg6pa_LtgDuQ_1759996237 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996235; x=1760601035; 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=Q7iCef+6xuKmyGyRbd91CCrgKoZW7PCNqJldcVjWmVI=; b=q2iz4Z4/jKii4LEjEpDZkbVBgN8PNoLSLL0XNOWVN7lUYt2QHr0xt4FaSngo9eWwdV njwHeprOEsLOsd/8hrakIp0xEUkqx12ieoI2maFYl++7TAup8n4KhnqC5Axc9BYH8UNJ NPit1Ma07fCPrga8Tn64rQCjQcBVqfbHqIwQGNta+BlcoDoO+qZzk7YYGWUttNbTpq6E jG4AcgxThGHZzyESw3aFZOvVcEQNbsWJr7gCZCNrwcPn1jdG/B7E5DrVf76jPiM7eoI3 qRk8da9H2xTkq5rNPVY81mDLL4Fx72RwERc7Bzasmfq3+V332dE2pFZBsTaLGolOxFQW TGRw== X-Gm-Message-State: AOJu0YxiSGcU78nr/mKFHXLa+FZxHl1E6ySe6IXQZ1d8SHGhbo8zrxF9 0OY8cZ62EJr0urKH/7Y9g+HPi5Bk4ge8Ohep11mC2rFlQQ5l1xUWrRB7CJUcxyD4qyWJtvrP1Yd StUU9bcJYaFwVtvVkII9aqH4w2+3pIsEgfTw/t9tXZb0xd0C0Wmr49Hii+0RMzgbyFT5XIrsK25 lCv0PkcEKD7XfccRFHrnRZQeEU5yyWTseE7tytNVDZEqQ= X-Gm-Gg: ASbGncsntvxUtk1xnbm06xVDcI2skwF+hmqsmw9VmR0fCmvrbZZK2paDqeK1yxABgtW 7g5NmQXuSEkrVYpiNi669bZqhTUbWA+rQ32UHfwVsZqECqHGRn8exBSN38CHGxt0d/wHdwfcQr4 kmLGwsba4D8LrR48TuckYkynittwH81PRK+82rVGTyeAdpvqqV90254XXwuz1GD+2HsjE9Ya+EO 6NUoIaj+kauwpcQbf3zcI1dB8tuhDb57geIaplBR1NacRWpYGW1fkCUAZ7czJxcvvMX2vYT2djT vNwEkqEG4yZMrWrT+HjLbC76hu9LgXkhd/NOUWoeqI6nRAfxfaOVpcwxgEbomTZGUr9leclk7c9 exNEyqZSQmHua6oSudN7hossYSWiORLM8bC8rwqmcCevZrV6p X-Received: by 2002:a05:600c:154a:b0:46e:5cb5:20df with SMTP id 5b1f17b1804b1-46fa9aa6985mr62371495e9.16.1759996235232; Thu, 09 Oct 2025 00:50:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHic47KYD6Lyd7imfahdStKHrOl4RrBSc2ujZXUCYrnTqHN+svz2j61oAH7RXpjSmkDqNLmA== X-Received: by 2002:a05:600c:154a:b0:46e:5cb5:20df with SMTP id 5b1f17b1804b1-46fa9aa6985mr62371125e9.16.1759996234701; Thu, 09 Oct 2025 00:50:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 04/35] build-sys: default to host vendor for rust target triple Date: Thu, 9 Oct 2025 09:49:54 +0200 Message-ID: <20251009075026.505715-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996328298154100 From: Marc-Andr=C3=A9 Lureau This fixes docker-test@alpine, which uses "alpine" vendor. Signed-off-by: Marc-Andr=C3=A9 Lureau Link: https://lore.kernel.org/r/20251007134558.251670-1-marcandre.lureau@re= dhat.com Signed-off-by: Paolo Bonzini --- configure | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 78445cbb4b3..a467f3a2e05 100755 --- a/configure +++ b/configure @@ -1216,8 +1216,9 @@ fi if test "$rust" !=3D disabled && test -z "$rust_target_triple"; then # arch and os generally matches between meson and rust rust_arch=3D$host_arch + # default to host vendor + rust_vendor=3D$(echo "$rust_host_triple" | cut -d'-' -f2) rust_os=3D$host_os - rust_machine=3Dunknown rust_osvariant=3D =20 # tweak rust_os if needed; also, machine and variant depend on the OS @@ -1225,7 +1226,7 @@ if test "$rust" !=3D disabled && test -z "$rust_targe= t_triple"; then case "$host_os" in darwin) # e.g. aarch64-apple-darwin - rust_machine=3Dapple + rust_vendor=3Dapple ;; =20 linux) @@ -1273,13 +1274,13 @@ EOF ;; =20 sunos) - rust_machine=3Dpc + rust_vendor=3Dpc rust_os=3Dsolaris ;; =20 windows) # e.g. aarch64-pc-windows-gnullvm, x86_64-pc-windows-gnu (MSVC not sup= ported) - rust_machine=3Dpc + rust_vendor=3Dpc if test "$host_arch" =3D aarch64; then rust_osvariant=3Dgnullvm else @@ -1310,7 +1311,7 @@ EOF sparc64) if test "$rust_os" =3D solaris; then rust_arch=3Dsparcv9 - rust_machine=3Dsun + rust_vendor=3Dsun fi ;; =20 @@ -1324,7 +1325,7 @@ EOF # e.g. aarch64-linux-android rust_target_triple=3D$rust_arch-$rust_os-$rust_osvariant else - rust_target_triple=3D$rust_arch-$rust_machine-$rust_os${rust_osvariant= :+-$rust_osvariant} + rust_target_triple=3D$rust_arch-$rust_vendor-$rust_os${rust_osvariant:= +-$rust_osvariant} fi fi =20 --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996356; cv=none; d=zohomail.com; s=zohoarc; b=W0yBHktjNTenxAtg7aozxLrYa++IfWTRrTWt/U3lb9Q0dAmO6mk0Te19vnzIjJcUUVyUfZRCmL3de2C7+sbx/dyrQfSOH9vPCBd2qs9+yRcA6vWYA4hRTmaOhaISBXM2Dh423FZgs1nqkBPxVWctwfadCQKSh3ges5vaHmfFFLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996356; 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=8o0W7CirxOV3+oFb65slTdKr/gut3Tw1MOGBhnjU1JQ=; b=nj/jNSzYhnHLSVhLldki5LDgWfl/dNtmE1BCXV4ymUEBeRudgS1N9yz2mZqzHu/yqxHtU5PQ/qV6CmgHrIr4GueEVLkqviie8B1GOrRJQ5QLtJ/9F5FaliW1KXuJq5po9l1IYiXZX5ez07opxX1frO1sRrNqwscSimi/iEcveSY= 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 1759996356773718.2448624012624; Thu, 9 Oct 2025 00:52:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQU-0008EZ-Q5; Thu, 09 Oct 2025 03:51: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 1v6lQS-0008EL-Ha for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:00 -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 1v6lQE-0004LB-Tc for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:00 -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-176-hZxwfpmcPImg8eYuGuLUXw-1; Thu, 09 Oct 2025 03:50:40 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3f384f10762so512103f8f.3 for ; Thu, 09 Oct 2025 00:50:40 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fa9bf81a3sm73199805e9.4.2025.10.09.00.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996241; 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=8o0W7CirxOV3+oFb65slTdKr/gut3Tw1MOGBhnjU1JQ=; b=E1C1IJU0ZNLegUGeMZK933rBSMjk/Z3bawLB45fX/hKk9imj4eFtsNIohHb5+I6yIFuexN ZsIiwIMNJX9nG3KA0VCrY3tsfONA3N9Tk4INzBbSyQRRTJk6F0/6pL6wiTDZsKI5gbRH7w OR+JX9/vAkHrATcNnshF6VkvUzKe+0o= X-MC-Unique: hZxwfpmcPImg8eYuGuLUXw-1 X-Mimecast-MFC-AGG-ID: hZxwfpmcPImg8eYuGuLUXw_1759996239 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996238; x=1760601038; 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=8o0W7CirxOV3+oFb65slTdKr/gut3Tw1MOGBhnjU1JQ=; b=LQ0JH4WDyXEHpJ4eIhPJd5ySHnCpg/vVVJnMyYZ2o8BMJenoxXLIf3Zx2j0UTJ/zA+ ZzEBZy64RKy5j9MrBCMVxJ+KS/hx/lJdIizhEzVJVFpSxCb8+TlwnUk7J6vmSlwaStqE S+oMS2ByZOQiXBH8dx6+SfDmXXumZ9Or2YamTx25JLr+72mNlOyX3qffS3+1WZX9OyFO AFcRaMq6EuLp+yNxVabEMYEkxMJ95w+BbgEmPn00escPNaZa21UN4iKv2rZxNi96mMbG 08Y0S5W/OMvkF+CDDl+C0RP/wTNOFTIxRiMBXyAlmPRg9NixT+POYFz0bE/hiDo/3q7B qukw== X-Gm-Message-State: AOJu0YyzH5z9Mgzwui9HmhXFTSF3k/UQkfJOq3XA8xoKZOfwPAD475sD YkH5PQYS9ozS2rKS3ZR3DgR7U3Xdblxy8Pi8m9+gdq+YIn+d+e/oENY595nYQY4t1GP+Fq/ih5v sjnij72HXStxSqt3IxxXqUCE4LtIXuuAjxSSQ9YkAM/w1/77ZEwU7zrp3nmnvRwAiSrelAi3kY3 Ip/S+6i9jWat2zpX3ah7Scqu8L149m05Lh9OjQLaLGroQ= X-Gm-Gg: ASbGnct0z/w+kocDBPTAnxku4tNUPffqnrkI4d0a8iboiYFnT5CXwXBNna8MoMr8VIC bpzWiXJg8WsRMiWgvIvoJEl+PUxXdfqlgt8PKMOjn1oQFd+4WVSphM0MHUhizfwSGz8P2EAQSCI EC6OD7MEAv8lIQzMZjFlj2L3jMPRBSLMWlTxBYkZRQO8p0fgwvMT+nyUZGeNe56yCQJoCXtBRPA 3M0eKF4wkpa87DOwSR6A628SlJyZspLsbLGRYP+aAygyBvAcfRMXOG8qWmJvLKBDR7lL9eN39Xq eU3YqrDR69Ta9dyVU/di8jkcn3Uu9ZxyOdzuWB6mDGzut6veYPLTUDoNwpEawd3ZlFCIH0u39Eb TY9FFp9O3KSJLU7qFExD1wfeS2aL5sHCKkGbD5zDm+dsP/rrS X-Received: by 2002:a05:600c:4f08:b0:45b:9afe:ad48 with SMTP id 5b1f17b1804b1-46fa9a98ecfmr52774395e9.16.1759996237841; Thu, 09 Oct 2025 00:50:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtkUjIRFugK6gTmJCjoVK477SWfAiaLlNvGvuxxivoj+tBOFqJX/W4mbl1F7M9YDrLEAbm3A== X-Received: by 2002:a05:600c:4f08:b0:45b:9afe:ad48 with SMTP id 5b1f17b1804b1-46fa9a98ecfmr52774075e9.16.1759996237308; Thu, 09 Oct 2025 00:50:37 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Hector Cao Subject: [PULL 05/35] target/i386: add compatibility property for arch_capabilities Date: Thu, 9 Oct 2025 09:49:55 +0200 Message-ID: <20251009075026.505715-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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, 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: 1759996358086154100 Content-Type: text/plain; charset="utf-8" Prior to v10.1, if requested by user, arch-capabilities is always on despite the fact that CPUID advertises it to be off/unvailable. This causes a migration issue for VMs that are run on a machine without arch-capabilities and expect this feature to be present on the destination host with QEMU 10.1. Add a compatibility property to restore the legacy behavior for all machines with version prior to 10.1. To preserve the functionality (added by 10.1) of turning off ARCH_CAPABILITIES where Windows does not like it, use directly the guest CPU vendor: x86_cpu_get_supported_feature_word is not KVM-specific and therefore should not necessarily use the host CPUID. Co-authored-by: Hector Cao Signed-off-by: Hector Cao Fixes: d3a24134e37 ("target/i386: do not expose ARCH_CAPABILITIES on AMD CP= U", 2025-07-17) Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 6 ++++++ hw/i386/pc.c | 1 + target/i386/cpu.c | 17 +++++++++++++++++ target/i386/kvm/kvm.c | 6 +----- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index e0be7a74068..414ca968e84 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2314,6 +2314,12 @@ struct ArchCPU { /* Forcefully disable KVM PV features not exposed in guest CPUIDs */ bool kvm_pv_enforce_cpuid; =20 + /* + * Expose arch-capabilities unconditionally even on AMD models, for ba= ckwards + * compatibility with QEMU <10.1. + */ + bool arch_cap_always_on; + /* Number of physical address bits supported */ uint32_t phys_bits; =20 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index bc048a6d137..d7f48150fdd 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -87,6 +87,7 @@ const size_t pc_compat_10_1_len =3D G_N_ELEMENTS(pc_compa= t_10_1); GlobalProperty pc_compat_10_0[] =3D { { TYPE_X86_CPU, "x-consistent-cache", "false" }, { TYPE_X86_CPU, "x-vendor-cpuid-only-v2", "false" }, + { TYPE_X86_CPU, "x-arch-cap-always-on", "true" }, }; const size_t pc_compat_10_0_len =3D G_N_ELEMENTS(pc_compat_10_0); =20 diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6d85149e6e1..fe369bb1284 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7539,6 +7539,20 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *= cpu, FeatureWord w) #endif break; =20 + case FEAT_7_0_EDX: + /* + * Windows does not like ARCH_CAPABILITIES on AMD machines at all. + * Do not show the fake ARCH_CAPABILITIES MSR that KVM sets up, + * except if needed for migration. + * + * When arch_cap_always_on is removed, this tweak can move to + * kvm_arch_get_supported_cpuid. + */ + if (cpu && IS_AMD_CPU(&cpu->env) && !cpu->arch_cap_always_on) { + unavail =3D CPUID_7_0_EDX_ARCH_CAPABILITIES; + } + break; + default: break; } @@ -10004,6 +10018,9 @@ static const Property x86_cpu_properties[] =3D { true), DEFINE_PROP_BOOL("x-l1-cache-per-thread", X86CPU, l1_cache_per_core, t= rue), DEFINE_PROP_BOOL("x-force-cpuid-0x1f", X86CPU, force_cpuid_0x1f, false= ), + + DEFINE_PROP_BOOL("x-arch-cap-always-on", X86CPU, + arch_cap_always_on, false), }; =20 #ifndef CONFIG_USER_ONLY diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 6a3a1c1ed8e..db40caa3412 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -503,12 +503,8 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uin= t32_t function, * Linux v4.17-v4.20 incorrectly return ARCH_CAPABILITIES on SVM h= osts. * We can detect the bug by checking if MSR_IA32_ARCH_CAPABILITIES= is * returned by KVM_GET_MSR_INDEX_LIST. - * - * But also, because Windows does not like ARCH_CAPABILITIES on AMD - * mcahines at all, do not show the fake ARCH_CAPABILITIES MSR that - * KVM sets up. */ - if (!has_msr_arch_capabs || !(edx & CPUID_7_0_EDX_ARCH_CAPABILITIE= S)) { + if (!has_msr_arch_capabs) { ret &=3D ~CPUID_7_0_EDX_ARCH_CAPABILITIES; } } else if (function =3D=3D 7 && index =3D=3D 1 && reg =3D=3D R_EAX) { --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996367; cv=none; d=zohomail.com; s=zohoarc; b=e2T98zpNwU6di6Vbi46mQCYZ6TjNjuycM686moZENzZnX8ujBPIV5uLWbdggU9nBh5fYhXMOhHGVWAmgtqMfXNH3FpwnpAlHkEii5OPQ5qYN2JpLBIsr5wikQ5jn1Fa026g6HiEpecpk3uEmAUvZ/aiYGaUAFo4WCkTVubTE2mQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996367; 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=a375QZbeNwmaWpIoRvdNLtIS+2HVCnHIvRjrNsLKivI=; b=nGAeEzdgcBmSWeJQs84MObtP1siZoot/9Z9PdVQDM1qikCGScrRW+NFygU8TtNMWqG+DmT5EcmJPuLBxTMl1ignJ5N+mo/ClmhcpoqHU6/dDECpAtAt8c6ARKj9IgsuD9oLFVXFHKfhP1/9eU3pBPtcsA03Q4mTy3AV+vxuXKnU= 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 1759996367650667.903692625545; Thu, 9 Oct 2025 00:52:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQN-0008CF-QI; Thu, 09 Oct 2025 03:50:55 -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 1v6lQL-0008Bi-Nj for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:53 -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 1v6lQE-0004LL-T8 for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:53 -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-209-DjIZF7ygPeKAVaxdAKIfjg-1; Thu, 09 Oct 2025 03:50:42 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e473e577eso4024165e9.0 for ; Thu, 09 Oct 2025 00:50:41 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6b8bsm33338863f8f.4.2025.10.09.00.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996243; 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=a375QZbeNwmaWpIoRvdNLtIS+2HVCnHIvRjrNsLKivI=; b=hiGqxAciF+Kt1lKz7GTdtdCrcg7ZItAsPRKjR12Qa7swFxQgcdauHkzIZM4F+ATzTgzuRG t7nCPUVV1Fzx5+ZOnV2noQk8Rz8S0y5skZHCh1ZGuup0/xf83kTJKzhHekL1h/4Vbo7Xpw Q+LlMV4N1UIUeJnu9wX20OF2D8rGDQ4= X-MC-Unique: DjIZF7ygPeKAVaxdAKIfjg-1 X-Mimecast-MFC-AGG-ID: DjIZF7ygPeKAVaxdAKIfjg_1759996241 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996239; x=1760601039; 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=a375QZbeNwmaWpIoRvdNLtIS+2HVCnHIvRjrNsLKivI=; b=KrJ/xT/tpF4/qvtGQttJ+klFNTteya8KG8kCHb4Rp1iJ1PNEbmpi6wOZ4a89q27p7j TTKxvtmXEgmKB5mMyVfi5rhzYRv4EJxwoabva2/LH7ngFD4Nea2FDpwZxcDBzNeiRLti ECvuVhgofaIxcOZPyZHrrWLWYOwJDY93M2lCQT7WxX3Dp24stj7Aj11QxOWKDoKNHlwM K0917+XwTi2SYbjZfYWb3KbL7ypIcMzY0nkcOY8z4n9rM6/yuMNvGOAsuXVmUfzlslwR mPRCoH+W53QxxsuQ8fOnVD8wkzmo0sDtkfwEZHwSRcBZNTrINVcmGPaWQJen7mD/vS3Y 3MZA== X-Gm-Message-State: AOJu0YxwwzuyFtavnDNIqKJ7CvsVo7pbfWmFkWXz/GFpmlvauxA+nHoG ZFZUbYYkX9CsuvrJY+FkdUqJ45ks2GgYs2jlZc44A9FG5rsejmpaUmFpac1MoEdE9VJdsn8EpqM 5wnWyYERqVw2DR8gPSOQgrw2Pht+VPHxUd9DaItRnUz+FCSP6k0j0Et5+SWV24oITnbH8alel1Q LVixFRfZhALLrWGsDPFBlIOcDONaE9rPDGm+Y7VhaHqqM= X-Gm-Gg: ASbGnctA7brE8Ws4U7O9I8/pBgb/6j89B2EHP6kuMltFgJZfDtslceRU2LptaQW1otU GmzzP5x9pCuA/BK7hIY1oHK8BVEhjlSbaGN8qYWsBRYEz0ZZGe/5WQSba+btO6/Gc6fZdS/93Wh GiKz/gud1JgLgvmlpRFE3Tvxq9usF1zqbxd0kvtvNu0W3J/7Ld8Y6LaGYcqetbWDNtl08bsG0LP +7/+LA+2vJl9VvMO2BbR4r7hYqL1VSp8hpyTRS+1IqrGE++/mJuPQMK2mpzbOvpzQJK8wElpHhw ets28yWqmWzNkyFcWZ3YXgq4ykXMGrsXnjV7Rr/184ZgjCuIZxTOUHgV2E5WYUup4rQKUqVGZr2 blOX0NE8QenBykXg6IQURAAt0Ttw9ul+CIv6AVFa3fOWoYxjC X-Received: by 2002:a05:600c:a02:b0:46e:4499:ba30 with SMTP id 5b1f17b1804b1-46fa9b052f2mr50291655e9.30.1759996239120; Thu, 09 Oct 2025 00:50:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdy4xTp1dnf31EJIaH/MkeDuj3Q7LBkfE4v7fFCGEEjyhGfOtCVYCWiI305qefRNp4xGYuKA== X-Received: by 2002:a05:600c:a02:b0:46e:4499:ba30 with SMTP id 5b1f17b1804b1-46fa9b052f2mr50291415e9.30.1759996238513; Thu, 09 Oct 2025 00:50:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Hector Cao Subject: [PULL 06/35] target/i386: add compatibility property for pdcm feature Date: Thu, 9 Oct 2025 09:49:56 +0200 Message-ID: <20251009075026.505715-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996374880116600 Content-Type: text/plain; charset="utf-8" From: Hector Cao The pdcm feature is supposed to be disabled when PMU is not available. Up until v10.1, pdcm feature is enabled even when PMU is off. This behavior has been fixed but this change breaks the migration of VMs that are run with QEMU < 10.0 and expect the pdcm feature to be enabled on the destination host. This commit restores the legacy behavior for machines with version prior to 10.1 to allow the migration from older QEMU to QEMU 10.1. Signed-off-by: Hector Cao Link: https://lore.kernel.org/r/20250910115733.21149-3-hector.cao@canonical= .com Fixes: e68ec298090 ("i386/cpu: Move adjustment of CPUID_EXT_PDCM before fea= ture_dependencies[] check", 2025-06-20) [Move property from migration object to CPU. - Paolo] Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 6 ++++++ hw/i386/pc.c | 1 + target/i386/cpu.c | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 414ca968e84..42168f1d6d8 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2320,6 +2320,12 @@ struct ArchCPU { */ bool arch_cap_always_on; =20 + /* + * Backwards compatibility with QEMU <10.1. The PDCM feature is now di= sabled when + * PMU is not available, but prior to 10.1 it was enabled even if PMU = is off. + */ + bool pdcm_on_even_without_pmu; + /* Number of physical address bits supported */ uint32_t phys_bits; =20 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index d7f48150fdd..4668918746e 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -88,6 +88,7 @@ GlobalProperty pc_compat_10_0[] =3D { { TYPE_X86_CPU, "x-consistent-cache", "false" }, { TYPE_X86_CPU, "x-vendor-cpuid-only-v2", "false" }, { TYPE_X86_CPU, "x-arch-cap-always-on", "true" }, + { TYPE_X86_CPU, "x-pdcm-on-even-without-pmu", "true" }, }; const size_t pc_compat_10_0_len =3D G_N_ELEMENTS(pc_compat_10_0); =20 diff --git a/target/i386/cpu.c b/target/i386/cpu.c index fe369bb1284..ab18de894e4 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7908,6 +7908,11 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, /* Fixup overflow: max value for bits 23-16 is 255. */ *ebx |=3D MIN(num, 255) << 16; } + if (cpu->pdcm_on_even_without_pmu) { + if (!cpu->enable_pmu) { + *ecx &=3D ~CPUID_EXT_PDCM; + } + } break; case 2: { /* cache info: needed for Pentium Pro compatibility */ const CPUCaches *caches; @@ -8958,9 +8963,11 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **er= rp) } } =20 - /* PDCM is fixed1 bit for TDX */ - if (!cpu->enable_pmu && !is_tdx_vm()) { - env->features[FEAT_1_ECX] &=3D ~CPUID_EXT_PDCM; + if (!cpu->pdcm_on_even_without_pmu) { + /* PDCM is fixed1 bit for TDX */ + if (!cpu->enable_pmu && !is_tdx_vm()) { + env->features[FEAT_1_ECX] &=3D ~CPUID_EXT_PDCM; + } } =20 for (i =3D 0; i < ARRAY_SIZE(feature_dependencies); i++) { @@ -10021,6 +10028,8 @@ static const Property x86_cpu_properties[] =3D { =20 DEFINE_PROP_BOOL("x-arch-cap-always-on", X86CPU, arch_cap_always_on, false), + DEFINE_PROP_BOOL("x-pdcm-on-even-without-pmu", X86CPU, + pdcm_on_even_without_pmu, false), }; =20 #ifndef CONFIG_USER_ONLY --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996506; cv=none; d=zohomail.com; s=zohoarc; b=aooX8VS5rEB9NvMwv8EGvLMGcBKCQF0fdp/kGtedUKq6lYmy3NQ/0TLzYo8fJzY8FgQLuuonAnvGwwFsoS7sS6ZoI1jNZp2arvLG00GL+FN2XuqC3C6aItrgHDrZNthP00mNm0HGlyf5UNixVocMSwWSS3xJXS94qC0tG8suW3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996506; 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=kyOnyEib+YgYPdGc4tRSKxU4ZzTsbMTZCc0XJuyrE4g=; b=LkosEKqD8d0tQxmx8V2hrUUQm2TsZFVhU8xbD5XYa945Mcev/oiBBUI8/dCerIld0/CqbW3LVsh6MGooz5eU2kHJyQKFlRyzHN6R+uw58tabET4Un3+AgGjZjCgjKd25vCwWb8htlHk4XkwFfsCaMB5kYVdCD9samCyD/2mYh7M= 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 1759996506874217.73626759043736; Thu, 9 Oct 2025 00:55:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQR-0008Dr-FZ; Thu, 09 Oct 2025 03:50: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 1v6lQP-0008DR-S3 for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:57 -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 1v6lQF-0004Lx-0m for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:57 -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-217-6qZ9DgQXOHS1YUApFfmWsA-1; Thu, 09 Oct 2025 03:50:44 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e41c32209so3394615e9.0 for ; Thu, 09 Oct 2025 00:50:44 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8abe9bsm33586711f8f.22.2025.10.09.00.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996245; 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=kyOnyEib+YgYPdGc4tRSKxU4ZzTsbMTZCc0XJuyrE4g=; b=bgd73962BkZh7Wn6sF/4iXWLoaBuR3VUCjvK5csFW6r4IHklojBOn+lAO+Gs6AL+UDjs7Z mtXWGj5ti0rCDvxwL/dxEufXld2V2ohM2a4nEyuQv2+S7N6QZxonvJD2Ft3PSY6aBcQcY8 hl+IQU/CfwiuZQ23sKnasLfw1V4Ae5E= X-MC-Unique: 6qZ9DgQXOHS1YUApFfmWsA-1 X-Mimecast-MFC-AGG-ID: 6qZ9DgQXOHS1YUApFfmWsA_1759996243 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996242; x=1760601042; 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=kyOnyEib+YgYPdGc4tRSKxU4ZzTsbMTZCc0XJuyrE4g=; b=E3y8v3th6x+xOFP87vl2l/bbgqAU9d0Yx+vB7u3MT7jb4BxvPpwij5MvHLPYwfVgx9 6dIXPNmrSdhvZgdHAZAv1T99prdh3gmtAIb9226sxiuglbidgCP4vxLlFgn33GvHc2mm 7MRVIXbKV5eV+OeViAcUgX6svzVwHVVXihL255Z67/+SkAHRThlL/2QQBG1CvHWZHh2w YnlBJoEi60h4E97jaLK4O8fEUskV6Wb5jS4U7XTRODoFXBQyl9xS73rCfHpS3LI8KZk4 asSTaOYEhuhiPSNKqxtNJsjZB+f8osqatwUNC1TH0q9R5RMCay3h+M/HC6gcochL8p+o 75rw== X-Gm-Message-State: AOJu0YyuJ8sza7P6KIP/iA9ihfejTCVDy5uEmbjR5xgjmWZjiHdkt7a9 xDIrhtQA1CBfuNUy8ap/AYIqqSICQiGZ/lJ8WXNNt14a2okqTHl3xuQf/UBAokARMmWQGJMLnow kZsLhJ1kqIiwr4DTQKUkcwCBoHKzdopdTR+tZ6/NczK8UkkZKVm2cmsKnI8+7mYp15WNkSkz46s qNSU/qDI5uoW0JSOaYP1VYRl5VLVktnfoAvlO3aFenqS8= X-Gm-Gg: ASbGnctVdZ2YUmInjZWnXvdXLsIuUsYBNL53yk7rtwrWu/PB3FUzTUKAUXh2P5wS6Ir 1yGll0e62x3M8vluKEkLp5w6+MfJrWO7P14kvwtRj4qWxEF8m87VRjXO4MP1TAqwzUVvvXlK4Cy VCDAMgKWz27TQwzgtW9jqvL1/EfUQIdukLkoBGv7I1sebFN7U7JctsTiO9ZZ5AiNXf8a/MxEqvc sX3zu94XilnTE9Bro3Yj4CBwq1bnu6RWmNEfAU7LMNFJ2pz+8gv6ZTr7qFCcbqDpistflwvL2Me jDnwp9dU/hnA6Hj0Bwj7RY2PR0LYwEj9P2cc9jXrnzXvEGUBdLQmM7G6Ek1jP3RUUbE2N5gUt0j lEgRdTkKyG8NuIWXX37wPwnLGntrZWH+X6CEWcVqF+kVC2l9x X-Received: by 2002:a05:600c:468c:b0:46e:3287:57d6 with SMTP id 5b1f17b1804b1-46fa9b0e7f0mr42688905e9.27.1759996242464; Thu, 09 Oct 2025 00:50:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHaINTuXxeJWDodHMV5vHaG60InsNvuqmxKdkCA4dSOyf5hicp9f966vtQ7dgOW1n1WXNA0Rg== X-Received: by 2002:a05:600c:468c:b0:46e:3287:57d6 with SMTP id 5b1f17b1804b1-46fa9b0e7f0mr42688655e9.27.1759996241973; Thu, 09 Oct 2025 00:50:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 07/35] accel: Add Meson and config support for MSHV accelerator Date: Thu, 9 Oct 2025 09:49:57 +0200 Message-ID: <20251009075026.505715-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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, 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: 1759996523701116600 From: Magnus Kulke Introduce a Meson feature option and default-config entry to allow building QEMU with MSHV (Microsoft Hypervisor) acceleration support. This is the first step toward implementing an MSHV backend in QEMU. Signed-off-by: Magnus Kulke Reviewed-by: Daniel P. Berrang=C3=A9 Link: https://lore.kernel.org/r/20250916164847.77883-2-magnuskulke@linux.mi= crosoft.com [Add error for unavailable accelerator. - Paolo] Signed-off-by: Paolo Bonzini --- meson.build | 13 +++++++++++++ accel/Kconfig | 3 +++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 4 files changed, 21 insertions(+) diff --git a/meson.build b/meson.build index 62766c0f19c..167021ed621 100644 --- a/meson.build +++ b/meson.build @@ -334,6 +334,7 @@ elif cpu =3D=3D 'x86_64' 'CONFIG_HVF': ['x86_64-softmmu'], 'CONFIG_NVMM': ['i386-softmmu', 'x86_64-softmmu'], 'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'], + 'CONFIG_MSHV': ['x86_64-softmmu'], } endif =20 @@ -883,6 +884,14 @@ accelerators =3D [] if get_option('kvm').allowed() and host_os =3D=3D 'linux' accelerators +=3D 'CONFIG_KVM' endif + +if get_option('mshv').allowed() and host_os =3D=3D 'linux' + if get_option('mshv').enabled() and host_machine.cpu() !=3D 'x86_64' + error('mshv accelerator requires x64_64 host') + endif + accelerators +=3D 'CONFIG_MSHV' +endif + if get_option('whpx').allowed() and host_os =3D=3D 'windows' if get_option('whpx').enabled() and host_machine.cpu() !=3D 'x86_64' error('WHPX requires 64-bit host') @@ -952,6 +961,9 @@ endif if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled() error('WHPX not available on this platform') endif +if 'CONFIG_MSHV' not in accelerators and get_option('mshv').enabled() + error('mshv not available on this platform') +endif =20 xen =3D not_found if get_option('xen').enabled() or (get_option('xen').auto() and have_syste= m) @@ -4827,6 +4839,7 @@ if have_system summary_info +=3D {'HVF support': config_all_accel.has_key('CONFIG= _HVF')} summary_info +=3D {'WHPX support': config_all_accel.has_key('CONFIG= _WHPX')} summary_info +=3D {'NVMM support': config_all_accel.has_key('CONFIG= _NVMM')} + summary_info +=3D {'MSHV support': config_all_accel.has_key('CONFIG= _MSHV')} summary_info +=3D {'Xen support': xen.found()} if xen.found() summary_info +=3D {'xen ctrl version': xen.version()} diff --git a/accel/Kconfig b/accel/Kconfig index 4263cab7227..a60f1149238 100644 --- a/accel/Kconfig +++ b/accel/Kconfig @@ -13,6 +13,9 @@ config TCG config KVM bool =20 +config MSHV + bool + config XEN bool select FSDEV_9P if VIRTFS diff --git a/meson_options.txt b/meson_options.txt index fff1521e580..1be7d61efdd 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -71,6 +71,8 @@ option('malloc', type : 'combo', choices : ['system', 'tc= malloc', 'jemalloc'], =20 option('kvm', type: 'feature', value: 'auto', description: 'KVM acceleration support') +option('mshv', type: 'feature', value: 'auto', + description: 'MSHV acceleration support') option('whpx', type: 'feature', value: 'auto', description: 'WHPX acceleration support') option('hvf', type: 'feature', value: 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 0ebe6bc52a6..d3d8f48bbbe 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -154,6 +154,7 @@ meson_options_help() { printf "%s\n" ' membarrier membarrier system call (for Linux 4.14+= or Windows' printf "%s\n" ' modules modules support (non Windows)' printf "%s\n" ' mpath Multipath persistent reservation passth= rough' + printf "%s\n" ' mshv MSHV acceleration support' printf "%s\n" ' multiprocess Out of process device emulation support' printf "%s\n" ' netmap netmap network backend support' printf "%s\n" ' nettle nettle cryptography support' @@ -408,6 +409,8 @@ _meson_option_parse() { --disable-modules) printf "%s" -Dmodules=3Ddisabled ;; --enable-mpath) printf "%s" -Dmpath=3Denabled ;; --disable-mpath) printf "%s" -Dmpath=3Ddisabled ;; + --enable-mshv) printf "%s" -Dmshv=3Denabled ;; + --disable-mshv) printf "%s" -Dmshv=3Ddisabled ;; --enable-multiprocess) printf "%s" -Dmultiprocess=3Denabled ;; --disable-multiprocess) printf "%s" -Dmultiprocess=3Ddisabled ;; --enable-netmap) printf "%s" -Dnetmap=3Denabled ;; --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996734; cv=none; d=zohomail.com; s=zohoarc; b=mS2fY5xAlcY2yImFLYNZqPs6pNBhULjlVnVk3ueiOavwOShTwF2Y66DMa2nJRc8XPCAe+FFFHip2lKbeQuHhVvj+8IbIXUynSKrTF49ySMulGC9qPVSzSjLFhGlQXWvoKEmL5g7hLXyHgbheaBsRNJp8tmfCXsa+1aGhFNh2QOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996734; 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=+8HYpUdO2P7nAh/MHMViByHQJ/N9zXJCXtwAC6CreTc=; b=FOLzx69dg76M9IqB8GK/vqot30eqm72DdvgoWgnxv1bA8rJbJ3IBm1WpJzp7t7VJf8yzCr0d/UzJQuOg8u1v7qhwBKQzk5wDZfx9KKF0WcnNMyd3GZ7QWoBhjh0t4NdhtLEnkKa++jq2GJIxc7eh3+KjV+ZemYjTPI/9JkZbe+o= 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 1759996734879990.6066383624826; Thu, 9 Oct 2025 00:58:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQP-0008DF-Jy; Thu, 09 Oct 2025 03:50:57 -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 1v6lQN-0008Br-46 for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:55 -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 1v6lQH-0004Mp-Cs for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:54 -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-408-brftt72HOnW11E6qbFwZlw-1; Thu, 09 Oct 2025 03:50:47 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3f93db57449so436874f8f.2 for ; Thu, 09 Oct 2025 00:50:46 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8ab960sm33305506f8f.13.2025.10.09.00.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996248; 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=+8HYpUdO2P7nAh/MHMViByHQJ/N9zXJCXtwAC6CreTc=; b=Zc17l/c1JIlz+OdbgRcQyYgpVIrgPtHbu0xSQfNnW83yDiPK5htVl2JYr8/+DGXVAW9oKC ssScmEw9A9wsjwYOIZ57qdL8PNgqAFtBzPPWLCZhe5MEt4mvCpb3Woz24vBonMZgne5p3l 5a1S2Jj8HFlunWO7sthG8V1gnqOoEhM= X-MC-Unique: brftt72HOnW11E6qbFwZlw-1 X-Mimecast-MFC-AGG-ID: brftt72HOnW11E6qbFwZlw_1759996246 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996245; x=1760601045; 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=+8HYpUdO2P7nAh/MHMViByHQJ/N9zXJCXtwAC6CreTc=; b=hMwp8ATFH4FQe2Gh5Gl5zqf1t54UsxXNBdfy3/mOvDmZkzvq9AhWo/6B3XHsowATW4 Z8Ghgt5zxNhgMVmrW05bdzkrtCNVutXnktjZGmhzmhoEP2tqO/aGhXmELL9wOZXvpyuI hIjWA8O/bSnZ+zKxFe8W4EFOTz7GFpWL4R9G8Zz5eOjfytZ7YgXfrMUSij8PQ7ZS0V7y DwGsyQQ38rMVAM3cDGysiHndxKgL+HHAEd++/wiKppbdzI1jd9u/AHJH9dozrrE1B218 zBhzzJksQoZr3etMad9qnht6UXh+vLSbSPJl+fwh6mhEobrOtQBB/IVgD4cXnFKwaRt9 4DVg== X-Gm-Message-State: AOJu0YykTHQG4+DkUi7BYSnMkAqoHSRGYBQIQuk2ByxF3es4qSZpU1zu Oy7/GDpuBGJVfHnlFULagt3YUYlA80KmNWu1RyT/j8RUJPoj5WbgSgctzWcFiVYtzyMvyoKNfJD Jll3Wp3edf6UIm0QJMUxVclBZ5UWDM9xang7eF/23I8fF1uKo2I6LtPtY+ICEIPrx3NV8tIjbVX 7TsHnDiKdWuzI396n00nceu6J6wyX4rtzkSdEg2gHOf6U= X-Gm-Gg: ASbGncv9D6q+eY0HO/zT6MTgWMEqRp+NBh7hErhWQrJXWOxNNkOS5zyQmP06/Uymr1f HWJDczOZ/Rzxqz/KzNhs8N7Nqecw9jclfyVVkm68KKQQ+bnIn6RYJxjcASP1IhZZwpJnDZJ61Lb hJ0sPZpUYQ2icaeF7IBCUshY4dhf/QJXAZBmsZQrHoy+3Lwv9ewC8dnbZIayxZI0BFixyOFcp4y k08V42gWo5FG4yBE+4l+52MdM4p+l47/vLrpyXUM7d63wS/QExCVFr8EjcZKWj6L+K52Z1lWhc4 vmtMG7c1T7FlP6tMsjkYLCwjH146eRbKxENF0r9AyUx4oxXY5zad35GGhgpvzkg61GvEIsz1eBO 9K8NeCXk6f0PMIiPT4JYlCdtgmTrI+LNgyCPA4uPGVn4yLXoN X-Received: by 2002:a05:6000:26ca:b0:400:1bbb:d279 with SMTP id ffacd0b85a97d-4266e7d44f1mr4180462f8f.39.1759996244648; Thu, 09 Oct 2025 00:50:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAKpfSXghO/EWp8z5+s6JW65nAgBB9/RMLk5Xkr+m0p+hGQr11MJJ74krAwxsR/EmUt77D8A== X-Received: by 2002:a05:6000:26ca:b0:400:1bbb:d279 with SMTP id ffacd0b85a97d-4266e7d44f1mr4180441f8f.39.1759996244193; Thu, 09 Oct 2025 00:50:44 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 08/35] target/i386/emulate: Allow instruction decoding from stream Date: Thu, 9 Oct 2025 09:49:58 +0200 Message-ID: <20251009075026.505715-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996740440116600 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Introduce a new helper function to decode x86 instructions from a raw instruction byte stream. MSHV delivers an instruction stream in a buffer of the vm_exit message. It can be used to speed up MMIO emulation, since instructions do not have to be fetched and translated. Added "fetch_instruction()" op to x86_emul_ops() to improve traceability. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-3-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- target/i386/emulate/x86_decode.h | 9 +++++++++ target/i386/emulate/x86_emu.h | 2 ++ target/i386/emulate/x86_decode.c | 27 +++++++++++++++++++++++---- target/i386/emulate/x86_emu.c | 3 ++- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/target/i386/emulate/x86_decode.h b/target/i386/emulate/x86_dec= ode.h index 927645af1a3..1cadf3694f0 100644 --- a/target/i386/emulate/x86_decode.h +++ b/target/i386/emulate/x86_decode.h @@ -272,6 +272,11 @@ typedef struct x86_decode_op { }; } x86_decode_op; =20 +typedef struct x86_insn_stream { + const uint8_t *bytes; + size_t len; +} x86_insn_stream; + typedef struct x86_decode { int len; uint8_t opcode[4]; @@ -298,11 +303,15 @@ typedef struct x86_decode { struct x86_modrm modrm; struct x86_decode_op op[4]; bool is_fpu; + + x86_insn_stream *stream; } x86_decode; =20 uint64_t sign(uint64_t val, int size); =20 uint32_t decode_instruction(CPUX86State *env, struct x86_decode *decode); +uint32_t decode_instruction_stream(CPUX86State *env, struct x86_decode *de= code, + struct x86_insn_stream *stream); =20 void *get_reg_ref(CPUX86State *env, int reg, int rex_present, int is_extended, int size); diff --git a/target/i386/emulate/x86_emu.h b/target/i386/emulate/x86_emu.h index a1a961284b2..05686b162f6 100644 --- a/target/i386/emulate/x86_emu.h +++ b/target/i386/emulate/x86_emu.h @@ -24,6 +24,8 @@ #include "cpu.h" =20 struct x86_emul_ops { + void (*fetch_instruction)(CPUState *cpu, void *data, target_ulong addr, + int bytes); void (*read_mem)(CPUState *cpu, void *data, target_ulong addr, int byt= es); void (*write_mem)(CPUState *cpu, void *data, target_ulong addr, int by= tes); void (*read_segment_descriptor)(CPUState *cpu, struct x86_segment_desc= riptor *desc, diff --git a/target/i386/emulate/x86_decode.c b/target/i386/emulate/x86_dec= ode.c index 2eca39802e3..97bd6f1a3be 100644 --- a/target/i386/emulate/x86_decode.c +++ b/target/i386/emulate/x86_decode.c @@ -71,10 +71,16 @@ static inline uint64_t decode_bytes(CPUX86State *env, s= truct x86_decode *decode, VM_PANIC_EX("%s invalid size %d\n", __func__, size); break; } - target_ulong va =3D linear_rip(env_cpu(env), env->eip) + decode->len; - emul_ops->read_mem(env_cpu(env), &val, va, size); + + /* copy the bytes from the instruction stream, if available */ + if (decode->stream && decode->len + size <=3D decode->stream->len) { + memcpy(&val, decode->stream->bytes + decode->len, size); + } else { + target_ulong va =3D linear_rip(env_cpu(env), env->eip) + decode->l= en; + emul_ops->fetch_instruction(env_cpu(env), &val, va, size); + } decode->len +=3D size; - =20 + return val; } =20 @@ -2076,9 +2082,10 @@ static void decode_opcodes(CPUX86State *env, struct = x86_decode *decode) } } =20 -uint32_t decode_instruction(CPUX86State *env, struct x86_decode *decode) +static uint32_t decode_opcode(CPUX86State *env, struct x86_decode *decode) { memset(decode, 0, sizeof(*decode)); + decode_prefix(env, decode); set_addressing_size(env, decode); set_operand_size(env, decode); @@ -2088,6 +2095,18 @@ uint32_t decode_instruction(CPUX86State *env, struct= x86_decode *decode) return decode->len; } =20 +uint32_t decode_instruction(CPUX86State *env, struct x86_decode *decode) +{ + return decode_opcode(env, decode); +} + +uint32_t decode_instruction_stream(CPUX86State *env, struct x86_decode *de= code, + struct x86_insn_stream *stream) +{ + decode->stream =3D stream; + return decode_opcode(env, decode); +} + void init_decoder(void) { int i; diff --git a/target/i386/emulate/x86_emu.c b/target/i386/emulate/x86_emu.c index db7a7f7437d..4409f7bc134 100644 --- a/target/i386/emulate/x86_emu.c +++ b/target/i386/emulate/x86_emu.c @@ -1246,7 +1246,8 @@ static void init_cmd_handler(void) bool exec_instruction(CPUX86State *env, struct x86_decode *ins) { if (!_cmd_handler[ins->cmd].handler) { - printf("Unimplemented handler (" TARGET_FMT_lx ") for %d (%x %x) \= n", env->eip, + printf("Unimplemented handler (" TARGET_FMT_lx ") for %d (%x %x)\n= ", + env->eip, ins->cmd, ins->opcode[0], ins->opcode_len > 1 ? ins->opcode[1] : 0); env->eip +=3D ins->len; --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996752; cv=none; d=zohomail.com; s=zohoarc; b=Mz2KRcEFKv8lNoFoQvG63sSxfPJmnhPmeIfnkevJtSR/NM/6FfeKEtfmp30G6cEcy+bteLmi9HtL1mtr10F9llDiu00UTrQaIX3iiFLA6I709CbrTKDq2XGS6dFQ/THk37fIobja04d3PIrlxPD0PWeioY+vT5GT2DfAHeXCsiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996752; 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=S8mgIyUucNwmMx4EjvXo3O9E8ww8tXMy2EwnkJclxwU=; b=QXYBrOd1dJuiBrVCVb2Q1stTm4w7OvbG3jPxm8C0LGuUX7J+ox8UsPdPUNJBfLmo4vmRsN0cOePzsE3XxOXaWkZyYLfPZgNQz3UXE2Ydn1P9oehy/25xuMFd/5+Jvxw560cURxXoyKArELKme08pLtCLluKNUHzn+ugujbzNBPA= 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 1759996752407260.39992800215555; Thu, 9 Oct 2025 00:59:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQT-0008ET-GZ; Thu, 09 Oct 2025 03:51: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 1v6lQP-0008DS-SC for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:57 -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 1v6lQK-0004NX-MY for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:50:57 -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-602-WA19fIHLMkOuZSw3BK4OvA-1; Thu, 09 Oct 2025 03:50:49 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e473e577eso4024805e9.0 for ; Thu, 09 Oct 2025 00:50:49 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fab633badsm31871615e9.3.2025.10.09.00.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996251; 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=S8mgIyUucNwmMx4EjvXo3O9E8ww8tXMy2EwnkJclxwU=; b=gX7cVVKJj7FRy38Iv2M1GsTCuUIyTl+/TgKLXat7RdmgjoiYsrR63kGPCXv8ymYo3aKEC7 PS1oQO8eJmFEWkopAUONMJ0QPJ0srdmrlqBEWD8wxHXXn/4SYbxKIly2o0jE1ZomdKw7BF HG70rndWJpJhEtAVrghd3U65QP5SYZo= X-MC-Unique: WA19fIHLMkOuZSw3BK4OvA-1 X-Mimecast-MFC-AGG-ID: WA19fIHLMkOuZSw3BK4OvA_1759996248 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996247; x=1760601047; 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=S8mgIyUucNwmMx4EjvXo3O9E8ww8tXMy2EwnkJclxwU=; b=DeFpjovlk8zjTukqroLjO31HLoX5CuGkWvWR21Dq6dL5qg0BwPGc00OUpuG/1ozCTu xKuxy3crMtGRaxbyDHC5tV3CkZXTdTgmYNTr8zpH80nswF1zEUYTJo2JbpD9bppzCgm4 HXg+hIYJ3xVxpsjNPwkpkYRt8/xqNCKZ6TPi39UCxGflXR4bg5IC69EckbPzrT15ZhCs 94Pn3vlHJOjHOwTvq9MLjCQ1McH50mcTExSxEb5otqG2qfZ66L6DDBjitRg6/KT2fTV+ /rzC7MJl9/MSGCi8T8aAxibDrEs/eQUSD6bXfZATVTeRSc/xw9cGAZB3zKeVFNfQ6zsW w2Cg== X-Gm-Message-State: AOJu0YzV9/iTX+9/SvM/EMouvcxWzXcXPVJ3YQgYEss1+fbpCPjIGkE+ WTVdoi5ybZ9gXTqDQnoYM33M9aIaiK6CIFfjhxq8d8v46WbcmbvrZcRG343xM4BHh/NHdIsrDNY fckdjS2xgu0nB7IAc+qvtYfhyMkuXZ2kT7mW5sexfiGgdGGd7vLQG/Mx5hDmWTzoG5Z8olhB+0Z V/hTsqivrM8BhSTS50xggQNkhWYLGlff//pyq0PbcS/Y8= X-Gm-Gg: ASbGncuIhSCwbAXWFSbRG2IBXYqubi8uiSqABh4C2Wi3OXGPUD+t/84LDAM3CXtVh8+ DZ9mJUwXeRL+SUmfpcWJCNxyEwmlWJYXOW6bmbOg6dMB+4EuaAS/8Do8OX6JG8eK/iI7mlo13u6 aKuPtWqf2LVqhgRHvULRaGpWwfghOSvo0sCDmB4eQfqDkwUbv3zCR5GL4TBpYW5DS3H7T/MwPnz yVISqesfy1iAt+7gOCTl5RIi1y67pZvgO7IugVBBqQLRZlOswzO3tyc1jaJQJU8b1HRpA4ObluK Xj8fEuEQp1MExG/m+NG7bxWRktNaHwcYjHC63CX8Xa6iST6S+/Yz42BePBtDpJdmBGy/0EHQOZ0 jOisEMBKhoMujSS4uBdPCLTF5HuwC7ias4oFeYe4URH7tbdyJ X-Received: by 2002:a05:600c:1d11:b0:46e:49dd:525e with SMTP id 5b1f17b1804b1-46fa9af197fmr50894485e9.21.1759996247224; Thu, 09 Oct 2025 00:50:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQlBCMFHkvbH7JBE18tmExDJZ0+DtIzNGiZqizye75DB0kOwCBv3O9fb4bUVp1ji/Ipf9jgA== X-Received: by 2002:a05:600c:1d11:b0:46e:49dd:525e with SMTP id 5b1f17b1804b1-46fa9af197fmr50894195e9.21.1759996246733; Thu, 09 Oct 2025 00:50:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 09/35] target/i386/mshv: Add x86 decoder/emu implementation Date: Thu, 9 Oct 2025 09:49:59 +0200 Message-ID: <20251009075026.505715-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996760888116600 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke The MSHV accelerator requires a x86 decoder/emulator in userland to emulate MMIO instructions. This change contains the implementations for the generalized i386 instruction decoder/emulator. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-4-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- include/system/mshv.h | 25 +++ target/i386/cpu.h | 2 +- target/i386/mshv/x86.c | 297 ++++++++++++++++++++++++++++++++ target/i386/emulate/meson.build | 7 +- target/i386/meson.build | 2 + target/i386/mshv/meson.build | 7 + 6 files changed, 337 insertions(+), 3 deletions(-) create mode 100644 include/system/mshv.h create mode 100644 target/i386/mshv/x86.c create mode 100644 target/i386/mshv/meson.build diff --git a/include/system/mshv.h b/include/system/mshv.h new file mode 100644 index 00000000000..342f1ef6a98 --- /dev/null +++ b/include/system/mshv.h @@ -0,0 +1,25 @@ +/* + * QEMU MSHV support + * + * Copyright Microsoft, Corp. 2025 + * + * Authors: Ziqiao Zhou + * Magnus Kulke + * Jinank Jain + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + */ + +#ifndef QEMU_MSHV_H +#define QEMU_MSHV_H + +#ifdef COMPILING_PER_TARGET +#ifdef CONFIG_MSHV +#define CONFIG_MSHV_IS_POSSIBLE +#endif +#else +#define CONFIG_MSHV_IS_POSSIBLE +#endif + +#endif diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 42168f1d6d8..3aec8fd41c8 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2126,7 +2126,7 @@ typedef struct CPUArchState { QEMUTimer *xen_periodic_timer; QemuMutex xen_timers_lock; #endif -#if defined(CONFIG_HVF) +#if defined(CONFIG_HVF) || defined(CONFIG_MSHV) void *emu_mmio_buf; #endif =20 diff --git a/target/i386/mshv/x86.c b/target/i386/mshv/x86.c new file mode 100644 index 00000000000..d574b3bc52f --- /dev/null +++ b/target/i386/mshv/x86.c @@ -0,0 +1,297 @@ +/* + * QEMU MSHV support + * + * Copyright Microsoft, Corp. 2025 + * + * Authors: Magnus Kulke + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" + +#include "cpu.h" +#include "emulate/x86_decode.h" +#include "emulate/x86_emu.h" +#include "qemu/typedefs.h" +#include "qemu/error-report.h" +#include "system/mshv.h" + +/* RW or Exec segment */ +static const uint8_t RWRX_SEGMENT_TYPE =3D 0x2; +static const uint8_t CODE_SEGMENT_TYPE =3D 0x8; +static const uint8_t EXPAND_DOWN_SEGMENT_TYPE =3D 0x4; + +typedef enum CpuMode { + REAL_MODE, + PROTECTED_MODE, + LONG_MODE, +} CpuMode; + +static CpuMode cpu_mode(CPUState *cpu) +{ + enum CpuMode m =3D REAL_MODE; + + if (x86_is_protected(cpu)) { + m =3D PROTECTED_MODE; + + if (x86_is_long_mode(cpu)) { + m =3D LONG_MODE; + } + } + + return m; +} + +static bool segment_type_ro(const SegmentCache *seg) +{ + uint32_t type_ =3D (seg->flags >> DESC_TYPE_SHIFT) & 15; + return (type_ & (~RWRX_SEGMENT_TYPE)) =3D=3D 0; +} + +static bool segment_type_code(const SegmentCache *seg) +{ + uint32_t type_ =3D (seg->flags >> DESC_TYPE_SHIFT) & 15; + return (type_ & CODE_SEGMENT_TYPE) !=3D 0; +} + +static bool segment_expands_down(const SegmentCache *seg) +{ + uint32_t type_ =3D (seg->flags >> DESC_TYPE_SHIFT) & 15; + + if (segment_type_code(seg)) { + return false; + } + + return (type_ & EXPAND_DOWN_SEGMENT_TYPE) !=3D 0; +} + +static uint32_t segment_limit(const SegmentCache *seg) +{ + uint32_t limit =3D seg->limit; + uint32_t granularity =3D (seg->flags & DESC_G_MASK) !=3D 0; + + if (granularity !=3D 0) { + limit =3D (limit << 12) | 0xFFF; + } + + return limit; +} + +static uint8_t segment_db(const SegmentCache *seg) +{ + return (seg->flags >> DESC_B_SHIFT) & 1; +} + +static uint32_t segment_max_limit(const SegmentCache *seg) +{ + if (segment_db(seg) !=3D 0) { + return 0xFFFFFFFF; + } + return 0xFFFF; +} + +static int linearize(CPUState *cpu, + target_ulong logical_addr, target_ulong *linear_addr, + X86Seg seg_idx) +{ + enum CpuMode mode; + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + SegmentCache *seg =3D &env->segs[seg_idx]; + target_ulong base =3D seg->base; + target_ulong logical_addr_32b; + uint32_t limit; + /* TODO: the emulator will not pass us "write" indicator yet */ + bool write =3D false; + + mode =3D cpu_mode(cpu); + + switch (mode) { + case LONG_MODE: + if (__builtin_add_overflow(logical_addr, base, linear_addr)) { + error_report("Address overflow"); + return -1; + } + break; + case PROTECTED_MODE: + case REAL_MODE: + if (segment_type_ro(seg) && write) { + error_report("Cannot write to read-only segment"); + return -1; + } + + logical_addr_32b =3D logical_addr & 0xFFFFFFFF; + limit =3D segment_limit(seg); + + if (segment_expands_down(seg)) { + if (logical_addr_32b >=3D limit) { + error_report("Address exceeds limit (expands down)"); + return -1; + } + + limit =3D segment_max_limit(seg); + } + + if (logical_addr_32b > limit) { + error_report("Address exceeds limit %u", limit); + return -1; + } + *linear_addr =3D logical_addr_32b + base; + break; + default: + error_report("Unknown cpu mode: %d", mode); + return -1; + } + + return 0; +} + +bool x86_read_segment_descriptor(CPUState *cpu, + struct x86_segment_descriptor *desc, + x86_segment_selector sel) +{ + target_ulong base; + uint32_t limit; + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + target_ulong gva; + + memset(desc, 0, sizeof(*desc)); + + /* valid gdt descriptors start from index 1 */ + if (!sel.index && GDT_SEL =3D=3D sel.ti) { + return false; + } + + if (GDT_SEL =3D=3D sel.ti) { + base =3D env->gdt.base; + limit =3D env->gdt.limit; + } else { + base =3D env->ldt.base; + limit =3D env->ldt.limit; + } + + if (sel.index * 8 >=3D limit) { + return false; + } + + gva =3D base + sel.index * 8; + emul_ops->read_mem(cpu, desc, gva, sizeof(*desc)); + + return true; +} + +bool x86_read_call_gate(CPUState *cpu, struct x86_call_gate *idt_desc, + int gate) +{ + target_ulong base; + uint32_t limit; + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + target_ulong gva; + + base =3D env->idt.base; + limit =3D env->idt.limit; + + memset(idt_desc, 0, sizeof(*idt_desc)); + if (gate * 8 >=3D limit) { + perror("call gate exceeds idt limit"); + return false; + } + + gva =3D base + gate * 8; + emul_ops->read_mem(cpu, idt_desc, gva, sizeof(*idt_desc)); + + return true; +} + +bool x86_is_protected(CPUState *cpu) +{ + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + uint64_t cr0 =3D env->cr[0]; + + return cr0 & CR0_PE_MASK; +} + +bool x86_is_real(CPUState *cpu) +{ + return !x86_is_protected(cpu); +} + +bool x86_is_v8086(CPUState *cpu) +{ + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + return x86_is_protected(cpu) && (env->eflags & VM_MASK); +} + +bool x86_is_long_mode(CPUState *cpu) +{ + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + uint64_t efer =3D env->efer; + uint64_t lme_lma =3D (MSR_EFER_LME | MSR_EFER_LMA); + + return ((efer & lme_lma) =3D=3D lme_lma); +} + +bool x86_is_long64_mode(CPUState *cpu) +{ + error_report("unimplemented: is_long64_mode()"); + abort(); +} + +bool x86_is_paging_mode(CPUState *cpu) +{ + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + uint64_t cr0 =3D env->cr[0]; + + return cr0 & CR0_PG_MASK; +} + +bool x86_is_pae_enabled(CPUState *cpu) +{ + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + uint64_t cr4 =3D env->cr[4]; + + return cr4 & CR4_PAE_MASK; +} + +target_ulong linear_addr(CPUState *cpu, target_ulong addr, X86Seg seg) +{ + int ret; + target_ulong linear_addr; + + ret =3D linearize(cpu, addr, &linear_addr, seg); + if (ret < 0) { + error_report("failed to linearize address"); + abort(); + } + + return linear_addr; +} + +target_ulong linear_addr_size(CPUState *cpu, target_ulong addr, int size, + X86Seg seg) +{ + switch (size) { + case 2: + addr =3D (uint16_t)addr; + break; + case 4: + addr =3D (uint32_t)addr; + break; + default: + break; + } + return linear_addr(cpu, addr, seg); +} + +target_ulong linear_rip(CPUState *cpu, target_ulong rip) +{ + return linear_addr(cpu, rip, R_CS); +} diff --git a/target/i386/emulate/meson.build b/target/i386/emulate/meson.bu= ild index 4edd4f462fc..b6dafb6a5be 100644 --- a/target/i386/emulate/meson.build +++ b/target/i386/emulate/meson.build @@ -1,5 +1,8 @@ -i386_system_ss.add(when: [hvf, 'CONFIG_HVF'], if_true: files( +emulator_files =3D files( 'x86_decode.c', 'x86_emu.c', 'x86_flags.c', -)) +) + +i386_system_ss.add(when: [hvf, 'CONFIG_HVF'], if_true: emulator_files) +i386_system_ss.add(when: 'CONFIG_MSHV', if_true: emulator_files) diff --git a/target/i386/meson.build b/target/i386/meson.build index 092af34e2d8..89ba4912aae 100644 --- a/target/i386/meson.build +++ b/target/i386/meson.build @@ -13,6 +13,7 @@ i386_ss.add(when: 'CONFIG_KVM', if_true: files('host-cpu.= c')) i386_ss.add(when: 'CONFIG_HVF', if_true: files('host-cpu.c')) i386_ss.add(when: 'CONFIG_WHPX', if_true: files('host-cpu.c')) i386_ss.add(when: 'CONFIG_NVMM', if_true: files('host-cpu.c')) +i386_ss.add(when: 'CONFIG_MSHV', if_true: files('host-cpu.c')) =20 i386_system_ss =3D ss.source_set() i386_system_ss.add(files( @@ -34,6 +35,7 @@ subdir('nvmm') subdir('hvf') subdir('tcg') subdir('emulate') +subdir('mshv') =20 target_arch +=3D {'i386': i386_ss} target_system_arch +=3D {'i386': i386_system_ss} diff --git a/target/i386/mshv/meson.build b/target/i386/mshv/meson.build new file mode 100644 index 00000000000..8ddaa7c11dc --- /dev/null +++ b/target/i386/mshv/meson.build @@ -0,0 +1,7 @@ +i386_mshv_ss =3D ss.source_set() + +i386_mshv_ss.add(files( + 'x86.c', +)) + +i386_system_ss.add_all(when: 'CONFIG_MSHV', if_true: i386_mshv_ss) --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996654; cv=none; d=zohomail.com; s=zohoarc; b=CQ9i1zQoMeNOuJunsSQC05cF4E1tETpiNS8iF2lmR2LMMWk22/NgAg5HZhD9waXGOoxTT8CAoGvHQ4WL2zitmoWoQ3l3LUIylvjyI3ySHNPOz3QWggdmbCV9TESXOFOnT+7kH9wQZcspT6MTFUdTTJQ7VCh8I39ISV5Kszwt+0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996654; 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=seTBrfyi/DDrrV1xDxXkPnrvQGhZFDqQgQXZovjNWnw=; b=GTBQkpeKEWNyTa4fZoBSwWq00HV0SSzD3+IHUwCV5a+v2CovBnCzkxCWnd8GU6+mQqYnp9cDWh72pzhSmHUZ/OPYmFZRUCkwPZRVS/OxmSQZpuqZB9uc+82YAKo/YjSgVMcyxu00Bm+oosxzm5YDi1iDMnB+ApqqlOvwp/HaF8g= 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 1759996654116881.0698073120345; Thu, 9 Oct 2025 00:57:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQX-0008Fe-Ev; Thu, 09 Oct 2025 03:51:05 -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 1v6lQU-0008EY-Jy for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:02 -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 1v6lQN-0004Ne-VU for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:02 -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-41-5oMivMaVPWW5vwxcLkHn7g-1; Thu, 09 Oct 2025 03:50:50 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e509374dcso2580565e9.1 for ; Thu, 09 Oct 2025 00:50:50 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46faf1841aasm32560575e9.18.2025.10.09.00.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996253; 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=seTBrfyi/DDrrV1xDxXkPnrvQGhZFDqQgQXZovjNWnw=; b=L418JWdDS0ags75tEyD5BeyJhh/MUPkSzKvd7vhYMlBnv3Eqa/Ftx6wTCEnzdl9WVbxrV6 qCbLqr9RPC9L8AFjBC4tVmaee7EmWrabTlr1pyKKxU/t2z2IFEW9GbbW7+1bzPMHgvIQg9 fxTxW/A0pIv0WZnqefZpqfbS+ES7CdU= X-MC-Unique: 5oMivMaVPWW5vwxcLkHn7g-1 X-Mimecast-MFC-AGG-ID: 5oMivMaVPWW5vwxcLkHn7g_1759996250 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996248; x=1760601048; 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=seTBrfyi/DDrrV1xDxXkPnrvQGhZFDqQgQXZovjNWnw=; b=N6LlWmsus5wACBjoseqNWIq6wA2MMfAqNtMRC4AwlQjX1R20ffJZTa1ygHi8BBrcKB AmpiLKmMck33069CNiyZsoMrvEOVVub98LSXLi1DxHHirBAKfT+6rcF6vwWj9lQgNGR+ ZPuluUtGaM6oTSrhxD/j29fjSQLIJArYeFK0a+x+V9qVfjF8erswcbYl7vd8wG6nOckk Kyzda+6b+wILPX9FgPCwJb2Crm7wKSjSouHK/sEnkXJI26+u1SzAQAd5XLxCKphxGlJk MNyJpUNIZCoaMEofUMfkrk5mgm22C9gkQSGbfKLOw2YSt8NZtQY5EHfez7+zcRUI5008 TaKw== X-Gm-Message-State: AOJu0YyB6KSQCFh73p1fob+x4XdkFdR7A7+UTdL9lMPVW6aXtOAwJSR7 2Th3U57eicDHTA9VbFQfBtxHqWSPRPVg3pDuGiXHrfyenRYSgGNlfMmZ+sh154PzOJtgkwoUREx 7ou+JKYPqVzXAbOUL0wwSLFgVFeDpKddLqZ+P/YnmgVBnske4H//7GdvQ9CAJvrVM/GfYu2AiNa qwqV9p9duOPmGvxLP2RIck2h7M/sdjh3hgeZ+crEy0ljU= X-Gm-Gg: ASbGnctEwmZTEw5SHwVJnOZwyakbBpx6ZW6Fkyr8dQY4rPfhMDD3z5GzprCtMIZXyD4 4t+lbULXHuzaL2PDDl0MDyVb+wnk05UW0u1Ezqrga9SCmqcDmSvpygrVgAohn6QknYKOhMrJ7XE XxTe2/fJHSxnze763nmFUl6+DPdxpHunWojcr4vUmUDziassWpzib4o+HXrW07oxDSTxKxLlyZn r/zVHZeWgoSpBBKOD2XAitmCCvntngGMaztE4q04lJjmn756A7xiJX2Mh2JqLvmbHEw7X57KLxL UuD0Xrx21/gJgbNgy6WByzaXhDGRAFSlcMK7VN1V160eGIlYXIOH6/KYga0PZma4yUGz9dkKpbo 9Qw4KbS653YLfab/nthwNTnR3sCjR4EDn1T4s/QrCrU6UKw+7 X-Received: by 2002:a05:600c:1552:b0:46e:1c16:7f42 with SMTP id 5b1f17b1804b1-46fa9a9659emr45222895e9.11.1759996248516; Thu, 09 Oct 2025 00:50:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpt0Y0q+ESrB92FDWEWe3O9JkTFk75ZBs16q1GgrZFWrexycyadlJNT+UZPENgafvWZLjlGQ== X-Received: by 2002:a05:600c:1552:b0:46e:1c16:7f42 with SMTP id 5b1f17b1804b1-46fa9a9659emr45222685e9.11.1759996247932; Thu, 09 Oct 2025 00:50:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 10/35] hw/intc: Generalize APIC helper names from kvm_* to accel_* Date: Thu, 9 Oct 2025 09:50:00 +0200 Message-ID: <20251009075026.505715-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996660674116600 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Rename APIC helper functions to use an accel_* prefix instead of kvm_* to support use by accelerators other than KVM. This is a preparatory step for integrating MSHV support with common APIC logic. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-5-magnuskulke@linux.mi= crosoft.com [Remove dead definition of mshv_msi_via_irqfd_enabled. - Paolo] Signed-off-by: Paolo Bonzini --- include/system/accel-irq.h | 37 +++++++++++++ include/system/mshv.h | 17 ++++++ accel/accel-irq.c | 106 +++++++++++++++++++++++++++++++++++++ hw/intc/ioapic.c | 20 ++++--- hw/virtio/virtio-pci.c | 21 ++++---- accel/meson.build | 2 +- 6 files changed, 185 insertions(+), 18 deletions(-) create mode 100644 include/system/accel-irq.h create mode 100644 accel/accel-irq.c diff --git a/include/system/accel-irq.h b/include/system/accel-irq.h new file mode 100644 index 00000000000..671fb7dfdbb --- /dev/null +++ b/include/system/accel-irq.h @@ -0,0 +1,37 @@ +/* + * Accelerated irqchip abstraction + * + * Copyright Microsoft, Corp. 2025 + * + * Authors: Ziqiao Zhou + * Magnus Kulke + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef SYSTEM_ACCEL_IRQ_H +#define SYSTEM_ACCEL_IRQ_H +#include "hw/pci/msi.h" +#include "qemu/osdep.h" +#include "system/kvm.h" +#include "system/mshv.h" + +static inline bool accel_msi_via_irqfd_enabled(void) +{ + return mshv_msi_via_irqfd_enabled() || kvm_msi_via_irqfd_enabled(); +} + +static inline bool accel_irqchip_is_split(void) +{ + return mshv_msi_via_irqfd_enabled() || kvm_irqchip_is_split(); +} + +int accel_irqchip_add_msi_route(KVMRouteChange *c, int vector, PCIDevice *= dev); +int accel_irqchip_update_msi_route(int vector, MSIMessage msg, PCIDevice *= dev); +void accel_irqchip_commit_route_changes(KVMRouteChange *c); +void accel_irqchip_commit_routes(void); +void accel_irqchip_release_virq(int virq); +int accel_irqchip_add_irqfd_notifier_gsi(EventNotifier *n, EventNotifier *= rn, + int virq); +int accel_irqchip_remove_irqfd_notifier_gsi(EventNotifier *n, int virq); +#endif diff --git a/include/system/mshv.h b/include/system/mshv.h index 342f1ef6a98..2a504ed81f2 100644 --- a/include/system/mshv.h +++ b/include/system/mshv.h @@ -22,4 +22,21 @@ #define CONFIG_MSHV_IS_POSSIBLE #endif =20 +#ifdef CONFIG_MSHV_IS_POSSIBLE +extern bool mshv_allowed; +#define mshv_enabled() (mshv_allowed) +#else /* CONFIG_MSHV_IS_POSSIBLE */ +#define mshv_enabled() false +#endif +#define mshv_msi_via_irqfd_enabled() false + +/* interrupt */ +int mshv_irqchip_add_msi_route(int vector, PCIDevice *dev); +int mshv_irqchip_update_msi_route(int virq, MSIMessage msg, PCIDevice *dev= ); +void mshv_irqchip_commit_routes(void); +void mshv_irqchip_release_virq(int virq); +int mshv_irqchip_add_irqfd_notifier_gsi(const EventNotifier *n, + const EventNotifier *rn, int virq); +int mshv_irqchip_remove_irqfd_notifier_gsi(const EventNotifier *n, int vir= q); + #endif diff --git a/accel/accel-irq.c b/accel/accel-irq.c new file mode 100644 index 00000000000..7f864e35c4e --- /dev/null +++ b/accel/accel-irq.c @@ -0,0 +1,106 @@ +/* + * Accelerated irqchip abstraction + * + * Copyright Microsoft, Corp. 2025 + * + * Authors: Ziqiao Zhou + * Magnus Kulke + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/pci/msi.h" + +#include "system/kvm.h" +#include "system/mshv.h" +#include "system/accel-irq.h" + +int accel_irqchip_add_msi_route(KVMRouteChange *c, int vector, PCIDevice *= dev) +{ +#ifdef CONFIG_MSHV_IS_POSSIBLE + if (mshv_msi_via_irqfd_enabled()) { + return mshv_irqchip_add_msi_route(vector, dev); + } +#endif + if (kvm_enabled()) { + return kvm_irqchip_add_msi_route(c, vector, dev); + } + return -ENOSYS; +} + +int accel_irqchip_update_msi_route(int vector, MSIMessage msg, PCIDevice *= dev) +{ +#ifdef CONFIG_MSHV_IS_POSSIBLE + if (mshv_msi_via_irqfd_enabled()) { + return mshv_irqchip_update_msi_route(vector, msg, dev); + } +#endif + if (kvm_enabled()) { + return kvm_irqchip_update_msi_route(kvm_state, vector, msg, dev); + } + return -ENOSYS; +} + +void accel_irqchip_commit_route_changes(KVMRouteChange *c) +{ +#ifdef CONFIG_MSHV_IS_POSSIBLE + if (mshv_msi_via_irqfd_enabled()) { + mshv_irqchip_commit_routes(); + } +#endif + if (kvm_enabled()) { + kvm_irqchip_commit_route_changes(c); + } +} + +void accel_irqchip_commit_routes(void) +{ +#ifdef CONFIG_MSHV_IS_POSSIBLE + if (mshv_msi_via_irqfd_enabled()) { + mshv_irqchip_commit_routes(); + } +#endif + if (kvm_enabled()) { + kvm_irqchip_commit_routes(kvm_state); + } +} + +void accel_irqchip_release_virq(int virq) +{ +#ifdef CONFIG_MSHV_IS_POSSIBLE + if (mshv_msi_via_irqfd_enabled()) { + mshv_irqchip_release_virq(virq); + } +#endif + if (kvm_enabled()) { + kvm_irqchip_release_virq(kvm_state, virq); + } +} + +int accel_irqchip_add_irqfd_notifier_gsi(EventNotifier *n, EventNotifier *= rn, + int virq) +{ +#ifdef CONFIG_MSHV_IS_POSSIBLE + if (mshv_msi_via_irqfd_enabled()) { + return mshv_irqchip_add_irqfd_notifier_gsi(n, rn, virq); + } +#endif + if (kvm_enabled()) { + return kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, rn, virq); + } + return -ENOSYS; +} + +int accel_irqchip_remove_irqfd_notifier_gsi(EventNotifier *n, int virq) +{ +#ifdef CONFIG_MSHV_IS_POSSIBLE + if (mshv_msi_via_irqfd_enabled()) { + return mshv_irqchip_remove_irqfd_notifier_gsi(n, virq); + } +#endif + if (kvm_enabled()) { + return kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, n, virq); + } + return -ENOSYS; +} diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index 133bef852d1..e431d003117 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -30,12 +30,18 @@ #include "hw/intc/ioapic_internal.h" #include "hw/pci/msi.h" #include "hw/qdev-properties.h" +#include "system/accel-irq.h" #include "system/kvm.h" #include "system/system.h" #include "hw/i386/apic-msidef.h" #include "hw/i386/x86-iommu.h" #include "trace.h" =20 + +#if defined(CONFIG_KVM) || defined(CONFIG_MSHV) +#define ACCEL_GSI_IRQFD_POSSIBLE +#endif + #define APIC_DELIVERY_MODE_SHIFT 8 #define APIC_POLARITY_SHIFT 14 #define APIC_TRIG_MODE_SHIFT 15 @@ -191,10 +197,10 @@ static void ioapic_set_irq(void *opaque, int vector, = int level) =20 static void ioapic_update_kvm_routes(IOAPICCommonState *s) { -#ifdef CONFIG_KVM +#ifdef ACCEL_GSI_IRQFD_POSSIBLE int i; =20 - if (kvm_irqchip_is_split()) { + if (accel_irqchip_is_split()) { for (i =3D 0; i < IOAPIC_NUM_PINS; i++) { MSIMessage msg; struct ioapic_entry_info info; @@ -202,15 +208,15 @@ static void ioapic_update_kvm_routes(IOAPICCommonStat= e *s) if (!info.masked) { msg.address =3D info.addr; msg.data =3D info.data; - kvm_irqchip_update_msi_route(kvm_state, i, msg, NULL); + accel_irqchip_update_msi_route(i, msg, NULL); } } - kvm_irqchip_commit_routes(kvm_state); + accel_irqchip_commit_routes(); } #endif } =20 -#ifdef CONFIG_KVM +#ifdef ACCEL_KERNEL_GSI_IRQFD_POSSIBLE static void ioapic_iec_notifier(void *private, bool global, uint32_t index, uint32_t mask) { @@ -428,11 +434,11 @@ static const MemoryRegionOps ioapic_io_ops =3D { =20 static void ioapic_machine_done_notify(Notifier *notifier, void *data) { -#ifdef CONFIG_KVM +#ifdef ACCEL_KERNEL_GSI_IRQFD_POSSIBLE IOAPICCommonState *s =3D container_of(notifier, IOAPICCommonState, machine_done); =20 - if (kvm_irqchip_is_split()) { + if (accel_irqchip_is_split()) { X86IOMMUState *iommu =3D x86_iommu_get_default(); if (iommu) { /* Register this IOAPIC with IOMMU IEC notifier, so that diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 767216d7959..0cdc16217ff 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -34,6 +34,7 @@ #include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "hw/loader.h" +#include "system/accel-irq.h" #include "system/kvm.h" #include "hw/virtio/virtio-pci.h" #include "qemu/range.h" @@ -825,11 +826,11 @@ static int kvm_virtio_pci_vq_vector_use(VirtIOPCIProx= y *proxy, =20 if (irqfd->users =3D=3D 0) { KVMRouteChange c =3D kvm_irqchip_begin_route_changes(kvm_state); - ret =3D kvm_irqchip_add_msi_route(&c, vector, &proxy->pci_dev); + ret =3D accel_irqchip_add_msi_route(&c, vector, &proxy->pci_dev); if (ret < 0) { return ret; } - kvm_irqchip_commit_route_changes(&c); + accel_irqchip_commit_route_changes(&c); irqfd->virq =3D ret; } irqfd->users++; @@ -841,7 +842,7 @@ static void kvm_virtio_pci_vq_vector_release(VirtIOPCIP= roxy *proxy, { VirtIOIRQFD *irqfd =3D &proxy->vector_irqfd[vector]; if (--irqfd->users =3D=3D 0) { - kvm_irqchip_release_virq(kvm_state, irqfd->virq); + accel_irqchip_release_virq(irqfd->virq); } } =20 @@ -850,7 +851,7 @@ static int kvm_virtio_pci_irqfd_use(VirtIOPCIProxy *pro= xy, unsigned int vector) { VirtIOIRQFD *irqfd =3D &proxy->vector_irqfd[vector]; - return kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, NULL, irqfd->v= irq); + return accel_irqchip_add_irqfd_notifier_gsi(n, NULL, irqfd->virq); } =20 static void kvm_virtio_pci_irqfd_release(VirtIOPCIProxy *proxy, @@ -860,7 +861,7 @@ static void kvm_virtio_pci_irqfd_release(VirtIOPCIProxy= *proxy, VirtIOIRQFD *irqfd =3D &proxy->vector_irqfd[vector]; int ret; =20 - ret =3D kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, n, irqfd->vir= q); + ret =3D accel_irqchip_remove_irqfd_notifier_gsi(n, irqfd->virq); assert(ret =3D=3D 0); } static int virtio_pci_get_notifier(VirtIOPCIProxy *proxy, int queue_no, @@ -995,12 +996,12 @@ static int virtio_pci_one_vector_unmask(VirtIOPCIProx= y *proxy, if (proxy->vector_irqfd) { irqfd =3D &proxy->vector_irqfd[vector]; if (irqfd->msg.data !=3D msg.data || irqfd->msg.address !=3D msg.a= ddress) { - ret =3D kvm_irqchip_update_msi_route(kvm_state, irqfd->virq, m= sg, - &proxy->pci_dev); + ret =3D accel_irqchip_update_msi_route(irqfd->virq, msg, + &proxy->pci_dev); if (ret < 0) { return ret; } - kvm_irqchip_commit_routes(kvm_state); + accel_irqchip_commit_routes(); } } =20 @@ -1229,7 +1230,7 @@ static int virtio_pci_set_guest_notifiers(DeviceState= *d, int nvqs, bool assign) VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); int r, n; bool with_irqfd =3D msix_enabled(&proxy->pci_dev) && - kvm_msi_via_irqfd_enabled(); + accel_msi_via_irqfd_enabled() ; =20 nvqs =3D MIN(nvqs, VIRTIO_QUEUE_MAX); =20 @@ -1433,7 +1434,7 @@ static void virtio_pci_set_vector(VirtIODevice *vdev, uint16_t new_vector) { bool kvm_irqfd =3D (vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) && - msix_enabled(&proxy->pci_dev) && kvm_msi_via_irqfd_enabled(); + msix_enabled(&proxy->pci_dev) && accel_msi_via_irqfd_enabled(); =20 if (new_vector =3D=3D old_vector) { return; diff --git a/accel/meson.build b/accel/meson.build index 25b0f100b51..6349efe682f 100644 --- a/accel/meson.build +++ b/accel/meson.build @@ -1,6 +1,6 @@ common_ss.add(files('accel-common.c')) specific_ss.add(files('accel-target.c')) -system_ss.add(files('accel-system.c', 'accel-blocker.c', 'accel-qmp.c')) +system_ss.add(files('accel-system.c', 'accel-blocker.c', 'accel-qmp.c', 'a= ccel-irq.c')) user_ss.add(files('accel-user.c')) =20 subdir('tcg') --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996677; cv=none; d=zohomail.com; s=zohoarc; b=iNhTpyhX0JXJd8Id/ymm0j16seAS9eGdb2KodDYOf9w5Fmecv5qHQtfLPnTscGJNS76W6L0qCiFriqkLKYOaCZXoiHKTEhUhj8kbb5Aj6KhK8yazVxxtBaVT5AtBmOgrlf6V0vdb4ydZMgTQjIpnwDhZoXf9ogma0VjiNWu24wE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996677; 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=0FJtIre7C/peQN1OQkcNqVV4ose8NiShy9MI1A8YMh8=; b=XxEwwvdBLHXa4QsdHrognzb4zZT8+ukx+9jGgqgaIDisoSRdkFvjjVJi+ltzdBmOFbaqvySrImWwcAwx9/WMADlXLcQccyv0Bfjm6KWkNeU7LA9Bya5CeHD/O+/6sKA5CtOfGa88OPSD2pbFEItK1mZ2HL5ABxQ97AOhmRqni8w= 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 1759996677055902.5721519310736; Thu, 9 Oct 2025 00:57:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQa-0008GE-5t; Thu, 09 Oct 2025 03:51:08 -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 1v6lQY-0008Ff-7i for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:06 -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 1v6lQQ-0004O8-7e for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:05 -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-237-y3XkrcYUOYifd3KhNS6xqw-1; Thu, 09 Oct 2025 03:50:54 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-426c4d733c4so412549f8f.3 for ; Thu, 09 Oct 2025 00:50:53 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fab3d92c0sm30787365e9.3.2025.10.09.00.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996256; 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=0FJtIre7C/peQN1OQkcNqVV4ose8NiShy9MI1A8YMh8=; b=G16pF0iz1cIh3GH+B+18aFNlWalW8Tsnj7uYXoaENjee79w5W3USApBAYCPIH0gFFZ3ELu fbuC/AArzrVjys7vu4bGvmFyt6UkmnSS24/PFHj2QWgHwYFdISLdoLNsSufjRHgW8aptyr vK2gPf25ZCCDQqwnkRhbrUMPCrarUJY= X-MC-Unique: y3XkrcYUOYifd3KhNS6xqw-1 X-Mimecast-MFC-AGG-ID: y3XkrcYUOYifd3KhNS6xqw_1759996253 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996252; x=1760601052; 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=0FJtIre7C/peQN1OQkcNqVV4ose8NiShy9MI1A8YMh8=; b=q8h2IaS0HdPHlgB2U6WN6szwg5HlRslgHVKjc57Hafx74XGaRSP84E2xeEUZIGkh7C eGqEo8H8Jyjyo1d+n48k7rwpUJMmrpJW7Gy/PB8/Z0wIcid2Zb77xshvAGRoikWNAnGb 95+Kugeam/mKUWEWioTFn88Cv0Argc6A5Bwr8t3qRuVEo7+lcEsk+/KcVDuZrVOaDN4C zinKznkk0Zj6s46Xj4ODBDWsS93nvYp6fxVxyED3W83zk2xd9kaW5Z4X/bBOoogl/qSP fFjjMlsLgB3zrbrPe2S9Ym6XzHXT8vaMXyryXv9vA6NLUpoxQZQ+R7B3rHyDLfqrWncP Tz6g== X-Gm-Message-State: AOJu0YxEZalZyYcmitbUZjgnxQJEv//3nlyaGdRiyd/OW8Ly6sCeVW2n HrNUdfkS+qvwglbYHg+dcX8SZO2SZpheWPVk5Cq0yBUqGyoa27JWYCJYbKij15I2Hp3KEkEds8/ BAJSOQUij2O/uJhU7+r3J/7lMlkSEBeDt4MISW7mc37w2pfoj7LnHFDaaOdy4fsnbr08t9qkKhU dhhKmXb9llPsIFr/+vOAozJyBCeX3AWtitlIMBdRG42Ek= X-Gm-Gg: ASbGncvtsmc813pW0swSd7R/HR9fYfGuj9XtwLRNe0LQ3baQFhyyzeiQ010QFaZz0aW lZmcCfByoPDfa5BWIXuICgqP/y60UwRsF2h7ArWD0ZAQbcbAwaSW7IxQMGDGyGomgizKv4lB2ql BJk8j0ssxA3VMJPZF4slSlug1dasEwb6n658y7SuDCaQEQ4CZQBGO0DnO9jKihuHD8qSW7qXxM1 MkzZ1vliUtW5E6AvTOKbFoquNkHBiN6GOflryMiVqS6xkcIULC/69I8Bl3Z89loVhwPrbbebK36 VumJRd8LY6VwnEOwP4a3Df9bGSlR/+YybpI0cl7FEg9LUkk9OpjQh+7pseEcmkzbZCE68tSZ8Ml fIrhDBJfSU9MGlNX2HpMGeUl2Eex6qdtt/fom5qQkoa5MBBmL X-Received: by 2002:a05:6000:40c7:b0:3e7:68b2:c556 with SMTP id ffacd0b85a97d-4266726c44fmr3870447f8f.26.1759996252046; Thu, 09 Oct 2025 00:50:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEas6C3kT7bIo6eLkr05PjcBCgQ+YbCtMRQ0VBl1KiJHjsHhco/4fhyRzHYkcPkfCHPNvXg8g== X-Received: by 2002:a05:6000:40c7:b0:3e7:68b2:c556 with SMTP id ffacd0b85a97d-4266726c44fmr3870416f8f.26.1759996251343; Thu, 09 Oct 2025 00:50:51 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 11/35] include/hw/hyperv: Add MSHV ABI header definitions Date: Thu, 9 Oct 2025 09:50:01 +0200 Message-ID: <20251009075026.505715-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996679663154100 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Introduce headers for the Microsoft Hypervisor (MSHV) userspace ABI, including IOCTLs and structures used to interface with the hypervisor. These definitions are based on the upstream Linux MSHV interface and will be used by the MSHV accelerator backend in later patches. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-6-magnuskulke@linux.mi= crosoft.com [Do not use __uN types. - Paolo] Signed-off-by: Paolo Bonzini --- include/hw/hyperv/hvgdk.h | 20 + include/hw/hyperv/hvgdk_mini.h | 817 ++++++++++++++++++++++++++++++++ include/hw/hyperv/hvhdk.h | 249 ++++++++++ include/hw/hyperv/hvhdk_mini.h | 102 ++++ scripts/update-linux-headers.sh | 2 +- 5 files changed, 1189 insertions(+), 1 deletion(-) create mode 100644 include/hw/hyperv/hvgdk.h create mode 100644 include/hw/hyperv/hvgdk_mini.h create mode 100644 include/hw/hyperv/hvhdk.h create mode 100644 include/hw/hyperv/hvhdk_mini.h diff --git a/include/hw/hyperv/hvgdk.h b/include/hw/hyperv/hvgdk.h new file mode 100644 index 00000000000..71161f477c4 --- /dev/null +++ b/include/hw/hyperv/hvgdk.h @@ -0,0 +1,20 @@ +/* + * Type definitions for the mshv guest interface. + * + * Copyright Microsoft, Corp. 2025 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_HYPERV_HVGDK_H +#define HW_HYPERV_HVGDK_H + +#define HVGDK_H_VERSION (25125) + +enum hv_unimplemented_msr_action { + HV_UNIMPLEMENTED_MSR_ACTION_FAULT =3D 0, + HV_UNIMPLEMENTED_MSR_ACTION_IGNORE_WRITE_READ_ZERO =3D 1, + HV_UNIMPLEMENTED_MSR_ACTION_COUNT =3D 2, +}; + +#endif /* HW_HYPERV_HVGDK_H */ diff --git a/include/hw/hyperv/hvgdk_mini.h b/include/hw/hyperv/hvgdk_mini.h new file mode 100644 index 00000000000..d89315f5452 --- /dev/null +++ b/include/hw/hyperv/hvgdk_mini.h @@ -0,0 +1,817 @@ +/* + * Userspace interfaces for /dev/mshv* devices and derived fds + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_HYPERV_HVGDK_MINI_H +#define HW_HYPERV_HVGDK_MINI_H + +#define MSHV_IOCTL 0xB8 + +typedef enum hv_register_name { + /* Pending Interruption Register */ + HV_REGISTER_PENDING_INTERRUPTION =3D 0x00010002, + + /* X64 User-Mode Registers */ + HV_X64_REGISTER_RAX =3D 0x00020000, + HV_X64_REGISTER_RCX =3D 0x00020001, + HV_X64_REGISTER_RDX =3D 0x00020002, + HV_X64_REGISTER_RBX =3D 0x00020003, + HV_X64_REGISTER_RSP =3D 0x00020004, + HV_X64_REGISTER_RBP =3D 0x00020005, + HV_X64_REGISTER_RSI =3D 0x00020006, + HV_X64_REGISTER_RDI =3D 0x00020007, + HV_X64_REGISTER_R8 =3D 0x00020008, + HV_X64_REGISTER_R9 =3D 0x00020009, + HV_X64_REGISTER_R10 =3D 0x0002000A, + HV_X64_REGISTER_R11 =3D 0x0002000B, + HV_X64_REGISTER_R12 =3D 0x0002000C, + HV_X64_REGISTER_R13 =3D 0x0002000D, + HV_X64_REGISTER_R14 =3D 0x0002000E, + HV_X64_REGISTER_R15 =3D 0x0002000F, + HV_X64_REGISTER_RIP =3D 0x00020010, + HV_X64_REGISTER_RFLAGS =3D 0x00020011, + + /* X64 Floating Point and Vector Registers */ + HV_X64_REGISTER_XMM0 =3D 0x00030000, + HV_X64_REGISTER_XMM1 =3D 0x00030001, + HV_X64_REGISTER_XMM2 =3D 0x00030002, + HV_X64_REGISTER_XMM3 =3D 0x00030003, + HV_X64_REGISTER_XMM4 =3D 0x00030004, + HV_X64_REGISTER_XMM5 =3D 0x00030005, + HV_X64_REGISTER_XMM6 =3D 0x00030006, + HV_X64_REGISTER_XMM7 =3D 0x00030007, + HV_X64_REGISTER_XMM8 =3D 0x00030008, + HV_X64_REGISTER_XMM9 =3D 0x00030009, + HV_X64_REGISTER_XMM10 =3D 0x0003000A, + HV_X64_REGISTER_XMM11 =3D 0x0003000B, + HV_X64_REGISTER_XMM12 =3D 0x0003000C, + HV_X64_REGISTER_XMM13 =3D 0x0003000D, + HV_X64_REGISTER_XMM14 =3D 0x0003000E, + HV_X64_REGISTER_XMM15 =3D 0x0003000F, + HV_X64_REGISTER_FP_MMX0 =3D 0x00030010, + HV_X64_REGISTER_FP_MMX1 =3D 0x00030011, + HV_X64_REGISTER_FP_MMX2 =3D 0x00030012, + HV_X64_REGISTER_FP_MMX3 =3D 0x00030013, + HV_X64_REGISTER_FP_MMX4 =3D 0x00030014, + HV_X64_REGISTER_FP_MMX5 =3D 0x00030015, + HV_X64_REGISTER_FP_MMX6 =3D 0x00030016, + HV_X64_REGISTER_FP_MMX7 =3D 0x00030017, + HV_X64_REGISTER_FP_CONTROL_STATUS =3D 0x00030018, + HV_X64_REGISTER_XMM_CONTROL_STATUS =3D 0x00030019, + + /* X64 Control Registers */ + HV_X64_REGISTER_CR0 =3D 0x00040000, + HV_X64_REGISTER_CR2 =3D 0x00040001, + HV_X64_REGISTER_CR3 =3D 0x00040002, + HV_X64_REGISTER_CR4 =3D 0x00040003, + HV_X64_REGISTER_CR8 =3D 0x00040004, + HV_X64_REGISTER_XFEM =3D 0x00040005, + + /* X64 Segment Registers */ + HV_X64_REGISTER_ES =3D 0x00060000, + HV_X64_REGISTER_CS =3D 0x00060001, + HV_X64_REGISTER_SS =3D 0x00060002, + HV_X64_REGISTER_DS =3D 0x00060003, + HV_X64_REGISTER_FS =3D 0x00060004, + HV_X64_REGISTER_GS =3D 0x00060005, + HV_X64_REGISTER_LDTR =3D 0x00060006, + HV_X64_REGISTER_TR =3D 0x00060007, + + /* X64 Table Registers */ + HV_X64_REGISTER_IDTR =3D 0x00070000, + HV_X64_REGISTER_GDTR =3D 0x00070001, + + /* X64 Virtualized MSRs */ + HV_X64_REGISTER_TSC =3D 0x00080000, + HV_X64_REGISTER_EFER =3D 0x00080001, + HV_X64_REGISTER_KERNEL_GS_BASE =3D 0x00080002, + HV_X64_REGISTER_APIC_BASE =3D 0x00080003, + HV_X64_REGISTER_PAT =3D 0x00080004, + HV_X64_REGISTER_SYSENTER_CS =3D 0x00080005, + HV_X64_REGISTER_SYSENTER_EIP =3D 0x00080006, + HV_X64_REGISTER_SYSENTER_ESP =3D 0x00080007, + HV_X64_REGISTER_STAR =3D 0x00080008, + HV_X64_REGISTER_LSTAR =3D 0x00080009, + HV_X64_REGISTER_CSTAR =3D 0x0008000A, + HV_X64_REGISTER_SFMASK =3D 0x0008000B, + HV_X64_REGISTER_INITIAL_APIC_ID =3D 0x0008000C, + + /* X64 Cache control MSRs */ + HV_X64_REGISTER_MSR_MTRR_CAP =3D 0x0008000D, + HV_X64_REGISTER_MSR_MTRR_DEF_TYPE =3D 0x0008000E, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASE0 =3D 0x00080010, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASE1 =3D 0x00080011, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASE2 =3D 0x00080012, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASE3 =3D 0x00080013, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASE4 =3D 0x00080014, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASE5 =3D 0x00080015, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASE6 =3D 0x00080016, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASE7 =3D 0x00080017, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASE8 =3D 0x00080018, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASE9 =3D 0x00080019, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASEA =3D 0x0008001A, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASEB =3D 0x0008001B, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASEC =3D 0x0008001C, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASED =3D 0x0008001D, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASEE =3D 0x0008001E, + HV_X64_REGISTER_MSR_MTRR_PHYS_BASEF =3D 0x0008001F, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASK0 =3D 0x00080040, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASK1 =3D 0x00080041, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASK2 =3D 0x00080042, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASK3 =3D 0x00080043, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASK4 =3D 0x00080044, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASK5 =3D 0x00080045, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASK6 =3D 0x00080046, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASK7 =3D 0x00080047, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASK8 =3D 0x00080048, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASK9 =3D 0x00080049, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASKA =3D 0x0008004A, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASKB =3D 0x0008004B, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASKC =3D 0x0008004C, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASKD =3D 0x0008004D, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASKE =3D 0x0008004E, + HV_X64_REGISTER_MSR_MTRR_PHYS_MASKF =3D 0x0008004F, + HV_X64_REGISTER_MSR_MTRR_FIX64K00000 =3D 0x00080070, + HV_X64_REGISTER_MSR_MTRR_FIX16K80000 =3D 0x00080071, + HV_X64_REGISTER_MSR_MTRR_FIX16KA0000 =3D 0x00080072, + HV_X64_REGISTER_MSR_MTRR_FIX4KC0000 =3D 0x00080073, + HV_X64_REGISTER_MSR_MTRR_FIX4KC8000 =3D 0x00080074, + HV_X64_REGISTER_MSR_MTRR_FIX4KD0000 =3D 0x00080075, + HV_X64_REGISTER_MSR_MTRR_FIX4KD8000 =3D 0x00080076, + HV_X64_REGISTER_MSR_MTRR_FIX4KE0000 =3D 0x00080077, + HV_X64_REGISTER_MSR_MTRR_FIX4KE8000 =3D 0x00080078, + HV_X64_REGISTER_MSR_MTRR_FIX4KF0000 =3D 0x00080079, + HV_X64_REGISTER_MSR_MTRR_FIX4KF8000 =3D 0x0008007A, + + HV_X64_REGISTER_TSC_AUX =3D 0x0008007B, + HV_X64_REGISTER_BNDCFGS =3D 0x0008007C, + HV_X64_REGISTER_DEBUG_CTL =3D 0x0008007D, + + /* Available */ + + HV_X64_REGISTER_SPEC_CTRL =3D 0x00080084, + HV_X64_REGISTER_TSC_ADJUST =3D 0x00080096, + + /* Other MSRs */ + HV_X64_REGISTER_MSR_IA32_MISC_ENABLE =3D 0x000800A0, + + /* Misc */ + HV_REGISTER_GUEST_OS_ID =3D 0x00090002, + HV_REGISTER_REFERENCE_TSC =3D 0x00090017, + + /* Hypervisor-defined Registers (Synic) */ + HV_REGISTER_SINT0 =3D 0x000A0000, + HV_REGISTER_SINT1 =3D 0x000A0001, + HV_REGISTER_SINT2 =3D 0x000A0002, + HV_REGISTER_SINT3 =3D 0x000A0003, + HV_REGISTER_SINT4 =3D 0x000A0004, + HV_REGISTER_SINT5 =3D 0x000A0005, + HV_REGISTER_SINT6 =3D 0x000A0006, + HV_REGISTER_SINT7 =3D 0x000A0007, + HV_REGISTER_SINT8 =3D 0x000A0008, + HV_REGISTER_SINT9 =3D 0x000A0009, + HV_REGISTER_SINT10 =3D 0x000A000A, + HV_REGISTER_SINT11 =3D 0x000A000B, + HV_REGISTER_SINT12 =3D 0x000A000C, + HV_REGISTER_SINT13 =3D 0x000A000D, + HV_REGISTER_SINT14 =3D 0x000A000E, + HV_REGISTER_SINT15 =3D 0x000A000F, + HV_REGISTER_SCONTROL =3D 0x000A0010, + HV_REGISTER_SVERSION =3D 0x000A0011, + HV_REGISTER_SIEFP =3D 0x000A0012, + HV_REGISTER_SIMP =3D 0x000A0013, + HV_REGISTER_EOM =3D 0x000A0014, + HV_REGISTER_SIRBP =3D 0x000A0015, +} hv_register_name; + +enum hv_intercept_type { + HV_INTERCEPT_TYPE_X64_IO_PORT =3D 0X00000000, + HV_INTERCEPT_TYPE_X64_MSR =3D 0X00000001, + HV_INTERCEPT_TYPE_X64_CPUID =3D 0X00000002, + HV_INTERCEPT_TYPE_EXCEPTION =3D 0X00000003, + + /* Used to be HV_INTERCEPT_TYPE_REGISTER */ + HV_INTERCEPT_TYPE_RESERVED0 =3D 0X00000004, + HV_INTERCEPT_TYPE_MMIO =3D 0X00000005, + HV_INTERCEPT_TYPE_X64_GLOBAL_CPUID =3D 0X00000006, + HV_INTERCEPT_TYPE_X64_APIC_SMI =3D 0X00000007, + HV_INTERCEPT_TYPE_HYPERCALL =3D 0X00000008, + + HV_INTERCEPT_TYPE_X64_APIC_INIT_SIPI =3D 0X00000009, + HV_INTERCEPT_MC_UPDATE_PATCH_LEVEL_MSR_READ =3D 0X0000000A, + + HV_INTERCEPT_TYPE_X64_APIC_WRITE =3D 0X0000000B, + HV_INTERCEPT_TYPE_X64_MSR_INDEX =3D 0X0000000C, + HV_INTERCEPT_TYPE_MAX, + HV_INTERCEPT_TYPE_INVALID =3D 0XFFFFFFFF, +}; + +struct hv_u128 { + uint64_t low_part; + uint64_t high_part; +}; + +union hv_x64_xmm_control_status_register { + struct hv_u128 as_uint128; + struct { + union { + /* long mode */ + uint64_t last_fp_rdp; + /* 32 bit mode */ + struct { + uint32_t last_fp_dp; + uint16_t last_fp_ds; + uint16_t padding; + }; + }; + uint32_t xmm_status_control; + uint32_t xmm_status_control_mask; + }; +}; + +union hv_x64_fp_register { + struct hv_u128 as_uint128; + struct { + uint64_t mantissa; + uint64_t biased_exponent:15; + uint64_t sign:1; + uint64_t reserved:48; + }; +}; + +union hv_x64_pending_exception_event { + uint64_t as_uint64[2]; + struct { + uint32_t event_pending:1; + uint32_t event_type:3; + uint32_t reserved0:4; + uint32_t deliver_error_code:1; + uint32_t reserved1:7; + uint32_t vector:16; + uint32_t error_code; + uint64_t exception_parameter; + }; +}; + +union hv_x64_pending_virtualization_fault_event { + uint64_t as_uint64[2]; + struct { + uint32_t event_pending:1; + uint32_t event_type:3; + uint32_t reserved0:4; + uint32_t reserved1:8; + uint32_t parameter0:16; + uint32_t code; + uint64_t parameter1; + }; +}; + +union hv_x64_pending_interruption_register { + uint64_t as_uint64; + struct { + uint32_t interruption_pending:1; + uint32_t interruption_type:3; + uint32_t deliver_error_code:1; + uint32_t instruction_length:4; + uint32_t nested_event:1; + uint32_t reserved:6; + uint32_t interruption_vector:16; + uint32_t error_code; + }; +}; + +union hv_x64_register_sev_control { + uint64_t as_uint64; + struct { + uint64_t enable_encrypted_state:1; + uint64_t reserved_z:11; + uint64_t vmsa_gpa_page_number:52; + }; +}; + +union hv_x64_msr_npiep_config_contents { + uint64_t as_uint64; + struct { + /* + * These bits enable instruction execution prevention for + * specific instructions. + */ + uint64_t prevents_gdt:1; + uint64_t prevents_idt:1; + uint64_t prevents_ldt:1; + uint64_t prevents_tr:1; + + /* The reserved bits must always be 0. */ + uint64_t reserved:60; + }; +}; + +typedef struct hv_x64_segment_register { + uint64_t base; + uint32_t limit; + uint16_t selector; + union { + struct { + uint16_t segment_type:4; + uint16_t non_system_segment:1; + uint16_t descriptor_privilege_level:2; + uint16_t present:1; + uint16_t reserved:4; + uint16_t available:1; + uint16_t _long:1; + uint16_t _default:1; + uint16_t granularity:1; + }; + uint16_t attributes; + }; +} hv_x64_segment_register; + +typedef struct hv_x64_table_register { + uint16_t pad[3]; + uint16_t limit; + uint64_t base; +} hv_x64_table_register; + +union hv_x64_fp_control_status_register { + struct hv_u128 as_uint128; + struct { + uint16_t fp_control; + uint16_t fp_status; + uint8_t fp_tag; + uint8_t reserved; + uint16_t last_fp_op; + union { + /* long mode */ + uint64_t last_fp_rip; + /* 32 bit mode */ + struct { + uint32_t last_fp_eip; + uint16_t last_fp_cs; + uint16_t padding; + }; + }; + }; +}; + +/* General Hypervisor Register Content Definitions */ + +union hv_explicit_suspend_register { + uint64_t as_uint64; + struct { + uint64_t suspended:1; + uint64_t reserved:63; + }; +}; + +union hv_internal_activity_register { + uint64_t as_uint64; + + struct { + uint64_t startup_suspend:1; + uint64_t halt_suspend:1; + uint64_t idle_suspend:1; + uint64_t rsvd_z:61; + }; +}; + +union hv_x64_interrupt_state_register { + uint64_t as_uint64; + struct { + uint64_t interrupt_shadow:1; + uint64_t nmi_masked:1; + uint64_t reserved:62; + }; +}; + +union hv_intercept_suspend_register { + uint64_t as_uint64; + struct { + uint64_t suspended:1; + uint64_t reserved:63; + }; +}; + +typedef union hv_register_value { + struct hv_u128 reg128; + uint64_t reg64; + uint32_t reg32; + uint16_t reg16; + uint8_t reg8; + union hv_x64_fp_register fp; + union hv_x64_fp_control_status_register fp_control_status; + union hv_x64_xmm_control_status_register xmm_control_status; + struct hv_x64_segment_register segment; + struct hv_x64_table_register table; + union hv_explicit_suspend_register explicit_suspend; + union hv_intercept_suspend_register intercept_suspend; + union hv_internal_activity_register internal_activity; + union hv_x64_interrupt_state_register interrupt_state; + union hv_x64_pending_interruption_register pending_interruption; + union hv_x64_msr_npiep_config_contents npiep_config; + union hv_x64_pending_exception_event pending_exception_event; + union hv_x64_pending_virtualization_fault_event + pending_virtualization_fault_event; + union hv_x64_register_sev_control sev_control; +} hv_register_value; + +typedef struct hv_register_assoc { + uint32_t name; /* enum hv_register_name */ + uint32_t reserved1; + uint64_t reserved2; + union hv_register_value value; +} hv_register_assoc; + +union hv_input_vtl { + uint8_t as_uint8; + struct { + uint8_t target_vtl:4; + uint8_t use_target_vtl:1; + uint8_t reserved_z:3; + }; +}; + +typedef struct hv_input_get_vp_registers { + uint64_t partition_id; + uint32_t vp_index; + union hv_input_vtl input_vtl; + uint8_t rsvd_z8; + uint16_t rsvd_z16; + uint32_t names[]; +} hv_input_get_vp_registers; + +typedef struct hv_input_set_vp_registers { + uint64_t partition_id; + uint32_t vp_index; + union hv_input_vtl input_vtl; + uint8_t rsvd_z8; + uint16_t rsvd_z16; + struct hv_register_assoc elements[]; +} hv_input_set_vp_registers; + +#define MSHV_VP_MAX_REGISTERS 128 + +struct mshv_vp_registers { + int count; /* at most MSHV_VP_MAX_REGISTERS */ + struct hv_register_assoc *regs; +}; + +union hv_interrupt_control { + uint64_t as_uint64; + struct { + uint32_t interrupt_type; /* enum hv_interrupt type */ + uint32_t level_triggered:1; + uint32_t logical_dest_mode:1; + uint32_t rsvd:30; + }; +}; + +struct hv_input_assert_virtual_interrupt { + uint64_t partition_id; + union hv_interrupt_control control; + uint64_t dest_addr; /* cpu's apic id */ + uint32_t vector; + uint8_t target_vtl; + uint8_t rsvd_z0; + uint16_t rsvd_z1; +}; + +/* /dev/mshv */ +#define MSHV_CREATE_PARTITION _IOW(MSHV_IOCTL, 0x00, struct mshv_create_= partition) +#define MSHV_CREATE_VP _IOW(MSHV_IOCTL, 0x01, struct mshv_create_= vp) + +/* Partition fds created with MSHV_CREATE_PARTITION */ +#define MSHV_INITIALIZE_PARTITION _IO(MSHV_IOCTL, 0x00) +#define MSHV_SET_GUEST_MEMORY _IOW(MSHV_IOCTL, 0x02, struct mshv_use= r_mem_region) +#define MSHV_IRQFD _IOW(MSHV_IOCTL, 0x03, struct mshv_use= r_irqfd) +#define MSHV_IOEVENTFD _IOW(MSHV_IOCTL, 0x04, struct mshv_use= r_ioeventfd) +#define MSHV_SET_MSI_ROUTING _IOW(MSHV_IOCTL, 0x05, struct mshv_use= r_irq_table) + +/* + ******************************** + * VP APIs for child partitions * + ******************************** + */ + +struct hv_local_interrupt_controller_state { + /* HV_X64_INTERRUPT_CONTROLLER_STATE */ + uint32_t apic_id; + uint32_t apic_version; + uint32_t apic_ldr; + uint32_t apic_dfr; + uint32_t apic_spurious; + uint32_t apic_isr[8]; + uint32_t apic_tmr[8]; + uint32_t apic_irr[8]; + uint32_t apic_esr; + uint32_t apic_icr_high; + uint32_t apic_icr_low; + uint32_t apic_lvt_timer; + uint32_t apic_lvt_thermal; + uint32_t apic_lvt_perfmon; + uint32_t apic_lvt_lint0; + uint32_t apic_lvt_lint1; + uint32_t apic_lvt_error; + uint32_t apic_lvt_cmci; + uint32_t apic_error_status; + uint32_t apic_initial_count; + uint32_t apic_counter_value; + uint32_t apic_divide_configuration; + uint32_t apic_remote_read; +}; + +/* Generic hypercall */ +#define MSHV_ROOT_HVCALL _IOWR(MSHV_IOCTL, 0x07, struct mshv_root_h= vcall) + +/* From hvgdk_mini.h */ + +#define HV_X64_MSR_GUEST_OS_ID 0x40000000 +#define HV_X64_MSR_SINT0 0x40000090 +#define HV_X64_MSR_SINT1 0x40000091 +#define HV_X64_MSR_SINT2 0x40000092 +#define HV_X64_MSR_SINT3 0x40000093 +#define HV_X64_MSR_SINT4 0x40000094 +#define HV_X64_MSR_SINT5 0x40000095 +#define HV_X64_MSR_SINT6 0x40000096 +#define HV_X64_MSR_SINT7 0x40000097 +#define HV_X64_MSR_SINT8 0x40000098 +#define HV_X64_MSR_SINT9 0x40000099 +#define HV_X64_MSR_SINT10 0x4000009A +#define HV_X64_MSR_SINT11 0x4000009B +#define HV_X64_MSR_SINT12 0x4000009C +#define HV_X64_MSR_SINT13 0x4000009D +#define HV_X64_MSR_SINT14 0x4000009E +#define HV_X64_MSR_SINT15 0x4000009F +#define HV_X64_MSR_SCONTROL 0x40000080 +#define HV_X64_MSR_SIEFP 0x40000082 +#define HV_X64_MSR_SIMP 0x40000083 +#define HV_X64_MSR_REFERENCE_TSC 0x40000021 +#define HV_X64_MSR_EOM 0x40000084 + +/* Define port identifier type. */ +union hv_port_id { + uint32_t asuint32_t; + struct { + uint32_t id:24; + uint32_t reserved:8; + }; +}; + +#define HV_MESSAGE_SIZE (256) +#define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240) +#define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30) + +/* Define hypervisor message types. */ +enum hv_message_type { + HVMSG_NONE =3D 0x00000000, + + /* Memory access messages. */ + HVMSG_UNMAPPED_GPA =3D 0x80000000, + HVMSG_GPA_INTERCEPT =3D 0x80000001, + HVMSG_UNACCEPTED_GPA =3D 0x80000003, + HVMSG_GPA_ATTRIBUTE_INTERCEPT =3D 0x80000004, + + /* Timer notification messages. */ + HVMSG_TIMER_EXPIRED =3D 0x80000010, + + /* Error messages. */ + HVMSG_INVALID_VP_REGISTER_VALUE =3D 0x80000020, + HVMSG_UNRECOVERABLE_EXCEPTION =3D 0x80000021, + HVMSG_UNSUPPORTED_FEATURE =3D 0x80000022, + + /* + * Opaque intercept message. The original intercept message is only + * accessible from the mapped intercept message page. + */ + HVMSG_OPAQUE_INTERCEPT =3D 0x8000003F, + + /* Trace buffer complete messages. */ + HVMSG_EVENTLOG_BUFFERCOMPLETE =3D 0x80000040, + + /* Hypercall intercept */ + HVMSG_HYPERCALL_INTERCEPT =3D 0x80000050, + + /* SynIC intercepts */ + HVMSG_SYNIC_EVENT_INTERCEPT =3D 0x80000060, + HVMSG_SYNIC_SINT_INTERCEPT =3D 0x80000061, + HVMSG_SYNIC_SINT_DELIVERABLE =3D 0x80000062, + + /* Async call completion intercept */ + HVMSG_ASYNC_CALL_COMPLETION =3D 0x80000070, + + /* Root scheduler messages */ + HVMSG_SCHEDULER_VP_SIGNAL_BITSE =3D 0x80000100, + HVMSG_SCHEDULER_VP_SIGNAL_PAIR =3D 0x80000101, + + /* Platform-specific processor intercept messages. */ + HVMSG_X64_IO_PORT_INTERCEPT =3D 0x80010000, + HVMSG_X64_MSR_INTERCEPT =3D 0x80010001, + HVMSG_X64_CPUID_INTERCEPT =3D 0x80010002, + HVMSG_X64_EXCEPTION_INTERCEPT =3D 0x80010003, + HVMSG_X64_APIC_EOI =3D 0x80010004, + HVMSG_X64_LEGACY_FP_ERROR =3D 0x80010005, + HVMSG_X64_IOMMU_PRQ =3D 0x80010006, + HVMSG_X64_HALT =3D 0x80010007, + HVMSG_X64_INTERRUPTION_DELIVERABLE =3D 0x80010008, + HVMSG_X64_SIPI_INTERCEPT =3D 0x80010009, + HVMSG_X64_SEV_VMGEXIT_INTERCEPT =3D 0x80010013, +}; + +union hv_x64_vp_execution_state { + uint16_t as_uint16; + struct { + uint16_t cpl:2; + uint16_t cr0_pe:1; + uint16_t cr0_am:1; + uint16_t efer_lma:1; + uint16_t debug_active:1; + uint16_t interruption_pending:1; + uint16_t vtl:4; + uint16_t enclave_mode:1; + uint16_t interrupt_shadow:1; + uint16_t virtualization_fault_active:1; + uint16_t reserved:2; + }; +}; + +/* From openvmm::hvdef */ +enum hv_x64_intercept_access_type { + HV_X64_INTERCEPT_ACCESS_TYPE_READ =3D 0, + HV_X64_INTERCEPT_ACCESS_TYPE_WRITE =3D 1, + HV_X64_INTERCEPT_ACCESS_TYPE_EXECUTE =3D 2, +}; + +struct hv_x64_intercept_message_header { + uint32_t vp_index; + uint8_t instruction_length:4; + uint8_t cr8:4; /* Only set for exo partitions */ + uint8_t intercept_access_type; + union hv_x64_vp_execution_state execution_state; + struct hv_x64_segment_register cs_segment; + uint64_t rip; + uint64_t rflags; +}; + +union hv_x64_io_port_access_info { + uint8_t as_uint8; + struct { + uint8_t access_size:3; + uint8_t string_op:1; + uint8_t rep_prefix:1; + uint8_t reserved:3; + }; +}; + +typedef struct hv_x64_io_port_intercept_message { + struct hv_x64_intercept_message_header header; + uint16_t port_number; + union hv_x64_io_port_access_info access_info; + uint8_t instruction_byte_count; + uint32_t reserved; + uint64_t rax; + uint8_t instruction_bytes[16]; + struct hv_x64_segment_register ds_segment; + struct hv_x64_segment_register es_segment; + uint64_t rcx; + uint64_t rsi; + uint64_t rdi; +} hv_x64_io_port_intercept_message; + +union hv_x64_memory_access_info { + uint8_t as_uint8; + struct { + uint8_t gva_valid:1; + uint8_t gva_gpa_valid:1; + uint8_t hypercall_output_pending:1; + uint8_t tlb_locked_no_overlay:1; + uint8_t reserved:4; + }; +}; + +struct hv_x64_memory_intercept_message { + struct hv_x64_intercept_message_header header; + uint32_t cache_type; /* enum hv_cache_type */ + uint8_t instruction_byte_count; + union hv_x64_memory_access_info memory_access_info; + uint8_t tpr_priority; + uint8_t reserved1; + uint64_t guest_virtual_address; + uint64_t guest_physical_address; + uint8_t instruction_bytes[16]; +}; + +union hv_message_flags { + uint8_t asu8; + struct { + uint8_t msg_pending:1; + uint8_t reserved:7; + }; +}; + +struct hv_message_header { + uint32_t message_type; + uint8_t payload_size; + union hv_message_flags message_flags; + uint8_t reserved[2]; + union { + uint64_t sender; + union hv_port_id port; + }; +}; + +struct hv_message { + struct hv_message_header header; + union { + uint64_t payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT]; + } u; +}; + +/* From github.com/rust-vmm/mshv-bindings/src/x86_64/regs.rs */ + +struct hv_cpuid_entry { + uint32_t function; + uint32_t index; + uint32_t flags; + uint32_t eax; + uint32_t ebx; + uint32_t ecx; + uint32_t edx; + uint32_t padding[3]; +}; + +struct hv_cpuid { + uint32_t nent; + uint32_t padding; + struct hv_cpuid_entry entries[0]; +}; + +#define IA32_MSR_TSC 0x00000010 +#define IA32_MSR_EFER 0xC0000080 +#define IA32_MSR_KERNEL_GS_BASE 0xC0000102 +#define IA32_MSR_APIC_BASE 0x0000001B +#define IA32_MSR_PAT 0x0277 +#define IA32_MSR_SYSENTER_CS 0x00000174 +#define IA32_MSR_SYSENTER_ESP 0x00000175 +#define IA32_MSR_SYSENTER_EIP 0x00000176 +#define IA32_MSR_STAR 0xC0000081 +#define IA32_MSR_LSTAR 0xC0000082 +#define IA32_MSR_CSTAR 0xC0000083 +#define IA32_MSR_SFMASK 0xC0000084 + +#define IA32_MSR_MTRR_CAP 0x00FE +#define IA32_MSR_MTRR_DEF_TYPE 0x02FF +#define IA32_MSR_MTRR_PHYSBASE0 0x0200 +#define IA32_MSR_MTRR_PHYSMASK0 0x0201 +#define IA32_MSR_MTRR_PHYSBASE1 0x0202 +#define IA32_MSR_MTRR_PHYSMASK1 0x0203 +#define IA32_MSR_MTRR_PHYSBASE2 0x0204 +#define IA32_MSR_MTRR_PHYSMASK2 0x0205 +#define IA32_MSR_MTRR_PHYSBASE3 0x0206 +#define IA32_MSR_MTRR_PHYSMASK3 0x0207 +#define IA32_MSR_MTRR_PHYSBASE4 0x0208 +#define IA32_MSR_MTRR_PHYSMASK4 0x0209 +#define IA32_MSR_MTRR_PHYSBASE5 0x020A +#define IA32_MSR_MTRR_PHYSMASK5 0x020B +#define IA32_MSR_MTRR_PHYSBASE6 0x020C +#define IA32_MSR_MTRR_PHYSMASK6 0x020D +#define IA32_MSR_MTRR_PHYSBASE7 0x020E +#define IA32_MSR_MTRR_PHYSMASK7 0x020F + +#define IA32_MSR_MTRR_FIX64K_00000 0x0250 +#define IA32_MSR_MTRR_FIX16K_80000 0x0258 +#define IA32_MSR_MTRR_FIX16K_A0000 0x0259 +#define IA32_MSR_MTRR_FIX4K_C0000 0x0268 +#define IA32_MSR_MTRR_FIX4K_C8000 0x0269 +#define IA32_MSR_MTRR_FIX4K_D0000 0x026A +#define IA32_MSR_MTRR_FIX4K_D8000 0x026B +#define IA32_MSR_MTRR_FIX4K_E0000 0x026C +#define IA32_MSR_MTRR_FIX4K_E8000 0x026D +#define IA32_MSR_MTRR_FIX4K_F0000 0x026E +#define IA32_MSR_MTRR_FIX4K_F8000 0x026F + +#define IA32_MSR_TSC_AUX 0xC0000103 +#define IA32_MSR_BNDCFGS 0x00000d90 +#define IA32_MSR_DEBUG_CTL 0x1D9 +#define IA32_MSR_SPEC_CTRL 0x00000048 +#define IA32_MSR_TSC_ADJUST 0x0000003b + +#define IA32_MSR_MISC_ENABLE 0x000001a0 + +#define HV_TRANSLATE_GVA_VALIDATE_READ (0x0001) +#define HV_TRANSLATE_GVA_VALIDATE_WRITE (0x0002) +#define HV_TRANSLATE_GVA_VALIDATE_EXECUTE (0x0004) + +#define HV_HYP_PAGE_SHIFT 12 +#define HV_HYP_PAGE_SIZE BIT(HV_HYP_PAGE_SHIFT) +#define HV_HYP_PAGE_MASK (~(HV_HYP_PAGE_SIZE - 1)) + +#define HVCALL_GET_PARTITION_PROPERTY 0x0044 +#define HVCALL_SET_PARTITION_PROPERTY 0x0045 +#define HVCALL_GET_VP_REGISTERS 0x0050 +#define HVCALL_SET_VP_REGISTERS 0x0051 +#define HVCALL_TRANSLATE_VIRTUAL_ADDRESS 0x0052 +#define HVCALL_REGISTER_INTERCEPT_RESULT 0x0091 +#define HVCALL_ASSERT_VIRTUAL_INTERRUPT 0x0094 + +#endif /* HW_HYPERV_HVGDK_MINI_H */ diff --git a/include/hw/hyperv/hvhdk.h b/include/hw/hyperv/hvhdk.h new file mode 100644 index 00000000000..866c8211bfe --- /dev/null +++ b/include/hw/hyperv/hvhdk.h @@ -0,0 +1,249 @@ +/* + * Type definitions for the mshv host. + * + * Copyright Microsoft, Corp. 2025 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_HYPERV_HVHDK_H +#define HW_HYPERV_HVHDK_H + +#define HV_PARTITION_SYNTHETIC_PROCESSOR_FEATURES_BANKS 1 + +struct hv_input_set_partition_property { + uint64_t partition_id; + uint32_t property_code; /* enum hv_partition_property_code */ + uint32_t padding; + uint64_t property_value; +}; + +union hv_partition_synthetic_processor_features { + uint64_t as_uint64[HV_PARTITION_SYNTHETIC_PROCESSOR_FEATURES_BANKS]; + + struct { + /* + * Report a hypervisor is present. CPUID leaves + * 0x40000000 and 0x40000001 are supported. + */ + uint64_t hypervisor_present:1; + + /* + * Features associated with HV#1: + */ + + /* Report support for Hv1 (CPUID leaves 0x40000000 - 0x40000006). = */ + uint64_t hv1:1; + + /* + * Access to HV_X64_MSR_VP_RUNTIME. + * Corresponds to access_vp_run_time_reg privilege. + */ + uint64_t access_vp_run_time_reg:1; + + /* + * Access to HV_X64_MSR_TIME_REF_COUNT. + * Corresponds to access_partition_reference_counter privilege. + */ + uint64_t access_partition_reference_counter:1; + + /* + * Access to SINT-related registers (HV_X64_MSR_SCONTROL through + * HV_X64_MSR_EOM and HV_X64_MSR_SINT0 through HV_X64_MSR_SINT15). + * Corresponds to access_synic_regs privilege. + */ + uint64_t access_synic_regs:1; + + /* + * Access to synthetic timers and associated MSRs + * (HV_X64_MSR_STIMER0_CONFIG through HV_X64_MSR_STIMER3_COUNT). + * Corresponds to access_synthetic_timer_regs privilege. + */ + uint64_t access_synthetic_timer_regs:1; + + /* + * Access to APIC MSRs (HV_X64_MSR_EOI, HV_X64_MSR_ICR and + * HV_X64_MSR_TPR) as well as the VP assist page. + * Corresponds to access_intr_ctrl_regs privilege. + */ + uint64_t access_intr_ctrl_regs:1; + + /* + * Access to registers associated with hypercalls + * (HV_X64_MSR_GUEST_OS_ID and HV_X64_MSR_HYPERCALL). + * Corresponds to access_hypercall_msrs privilege. + */ + uint64_t access_hypercall_regs:1; + + /* VP index can be queried. corresponds to access_vp_index privile= ge. */ + uint64_t access_vp_index:1; + + /* + * Access to the reference TSC. Corresponds to + * access_partition_reference_tsc privilege. + */ + uint64_t access_partition_reference_tsc:1; + + /* + * Partition has access to the guest idle reg. Corresponds to + * access_guest_idle_reg privilege. + */ + uint64_t access_guest_idle_reg:1; + + /* + * Partition has access to frequency regs. corresponds to + * access_frequency_regs privilege. + */ + uint64_t access_frequency_regs:1; + + uint64_t reserved_z12:1; /* Reserved for access_reenlightenment_co= ntrols */ + uint64_t reserved_z13:1; /* Reserved for access_root_scheduler_reg= */ + uint64_t reserved_z14:1; /* Reserved for access_tsc_invariant_cont= rols */ + + /* + * Extended GVA ranges for HvCallFlushVirtualAddressList hypercall. + * Corresponds to privilege. + */ + uint64_t enable_extended_gva_ranges_for_flush_virtual_address_list= :1; + + uint64_t reserved_z16:1; /* Reserved for access_vsm. */ + uint64_t reserved_z17:1; /* Reserved for access_vp_registers. */ + + /* Use fast hypercall output. Corresponds to privilege. */ + uint64_t fast_hypercall_output:1; + + uint64_t reserved_z19:1; /* Reserved for enable_extended_hypercall= s. */ + + /* + * HvStartVirtualProcessor can be used to start virtual processors. + * Corresponds to privilege. + */ + uint64_t start_virtual_processor:1; + + uint64_t reserved_z21:1; /* Reserved for Isolation. */ + + /* Synthetic timers in direct mode. */ + uint64_t direct_synthetic_timers:1; + + uint64_t reserved_z23:1; /* Reserved for synthetic time unhalted t= imer */ + + /* Use extended processor masks. */ + uint64_t extended_processor_masks:1; + + /* + * HvCallFlushVirtualAddressSpace / HvCallFlushVirtualAddressList = are + * supported. + */ + uint64_t tb_flush_hypercalls:1; + + /* HvCallSendSyntheticClusterIpi is supported. */ + uint64_t synthetic_cluster_ipi:1; + + /* HvCallNotifyLongSpinWait is supported. */ + uint64_t notify_long_spin_wait:1; + + /* HvCallQueryNumaDistance is supported. */ + uint64_t query_numa_distance:1; + + /* HvCallSignalEvent is supported. Corresponds to privilege. */ + uint64_t signal_events:1; + + /* HvCallRetargetDeviceInterrupt is supported. */ + uint64_t retarget_device_interrupt:1; + + /* HvCallRestorePartitionTime is supported. */ + uint64_t restore_time:1; + + /* EnlightenedVmcs nested enlightenment is supported. */ + uint64_t enlightened_vmcs:1; + + uint64_t reserved:30; + }; +}; + +enum hv_translate_gva_result_code { + HV_TRANSLATE_GVA_SUCCESS =3D 0, + + /* Translation failures. */ + HV_TRANSLATE_GVA_PAGE_NOT_PRESENT =3D 1, + HV_TRANSLATE_GVA_PRIVILEGE_VIOLATION =3D 2, + HV_TRANSLATE_GVA_INVALIDE_PAGE_TABLE_FLAGS =3D 3, + + /* GPA access failures. */ + HV_TRANSLATE_GVA_GPA_UNMAPPED =3D 4, + HV_TRANSLATE_GVA_GPA_NO_READ_ACCESS =3D 5, + HV_TRANSLATE_GVA_GPA_NO_WRITE_ACCESS =3D 6, + HV_TRANSLATE_GVA_GPA_ILLEGAL_OVERLAY_ACCESS =3D 7, + + /* + * Intercept for memory access by either + * - a higher VTL + * - a nested hypervisor (due to a violation of the nested page table) + */ + HV_TRANSLATE_GVA_INTERCEPT =3D 8, + + HV_TRANSLATE_GVA_GPA_UNACCEPTED =3D 9, +}; + +union hv_translate_gva_result { + uint64_t as_uint64; + struct { + uint32_t result_code; /* enum hv_translate_hva_result_code */ + uint32_t cache_type:8; + uint32_t overlay_page:1; + uint32_t reserved:23; + }; +}; + +typedef struct hv_input_translate_virtual_address { + uint64_t partition_id; + uint32_t vp_index; + uint32_t padding; + uint64_t control_flags; + uint64_t gva_page; +} hv_input_translate_virtual_address; + +typedef struct hv_output_translate_virtual_address { + union hv_translate_gva_result translation_result; + uint64_t gpa_page; +} hv_output_translate_virtual_address; + +typedef struct hv_register_x64_cpuid_result_parameters { + struct { + uint32_t eax; + uint32_t ecx; + uint8_t subleaf_specific; + uint8_t always_override; + uint16_t padding; + } input; + struct { + uint32_t eax; + uint32_t eax_mask; + uint32_t ebx; + uint32_t ebx_mask; + uint32_t ecx; + uint32_t ecx_mask; + uint32_t edx; + uint32_t edx_mask; + } result; +} hv_register_x64_cpuid_result_parameters; + +typedef struct hv_register_x64_msr_result_parameters { + uint32_t msr_index; + uint32_t access_type; + uint32_t action; /* enum hv_unimplemented_msr_action */ +} hv_register_x64_msr_result_parameters; + +union hv_register_intercept_result_parameters { + struct hv_register_x64_cpuid_result_parameters cpuid; + struct hv_register_x64_msr_result_parameters msr; +}; + +typedef struct hv_input_register_intercept_result { + uint64_t partition_id; + uint32_t vp_index; + uint32_t intercept_type; /* enum hv_intercept_type */ + union hv_register_intercept_result_parameters parameters; +} hv_input_register_intercept_result; + +#endif /* HW_HYPERV_HVHDK_H */ diff --git a/include/hw/hyperv/hvhdk_mini.h b/include/hw/hyperv/hvhdk_mini.h new file mode 100644 index 00000000000..9c2f3cf5aee --- /dev/null +++ b/include/hw/hyperv/hvhdk_mini.h @@ -0,0 +1,102 @@ +/* + * Type definitions for the mshv host interface. + * + * Copyright Microsoft, Corp. 2025 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_HYPERV_HVHDK_MINI_H +#define HW_HYPERV_HVHDK_MINI_H + +#define HVHVK_MINI_VERSION (25294) + +/* Each generic set contains 64 elements */ +#define HV_GENERIC_SET_SHIFT (6) +#define HV_GENERIC_SET_MASK (63) + +enum hv_generic_set_format { + HV_GENERIC_SET_SPARSE_4K, + HV_GENERIC_SET_ALL, +}; + +enum hv_partition_property_code { + /* Privilege properties */ + HV_PARTITION_PROPERTY_PRIVILEGE_FLAGS =3D 0x00010000, + HV_PARTITION_PROPERTY_SYNTHETIC_PROC_FEATURES =3D 0x00010001, + + /* Scheduling properties */ + HV_PARTITION_PROPERTY_SUSPEND =3D 0x00020000, + HV_PARTITION_PROPERTY_CPU_RESERVE =3D 0x00020001, + HV_PARTITION_PROPERTY_CPU_CAP =3D 0x00020002, + HV_PARTITION_PROPERTY_CPU_WEIGHT =3D 0x00020003, + HV_PARTITION_PROPERTY_CPU_GROUP_ID =3D 0x00020004, + + /* Time properties */ + HV_PARTITION_PROPERTY_TIME_FREEZE =3D 0x00030003, + HV_PARTITION_PROPERTY_REFERENCE_TIME =3D 0x00030005, + + /* Debugging properties */ + HV_PARTITION_PROPERTY_DEBUG_CHANNEL_ID =3D 0x00040000, + + /* Resource properties */ + HV_PARTITION_PROPERTY_VIRTUAL_TLB_PAGE_COUNT =3D 0x000= 50000, + HV_PARTITION_PROPERTY_VSM_CONFIG =3D 0x000= 50001, + HV_PARTITION_PROPERTY_ZERO_MEMORY_ON_RESET =3D 0x000= 50002, + HV_PARTITION_PROPERTY_PROCESSORS_PER_SOCKET =3D 0x000= 50003, + HV_PARTITION_PROPERTY_NESTED_TLB_SIZE =3D 0x000= 50004, + HV_PARTITION_PROPERTY_GPA_PAGE_ACCESS_TRACKING =3D 0x000= 50005, + HV_PARTITION_PROPERTY_VSM_PERMISSIONS_DIRTY_SINCE_LAST_QUERY =3D 0x000= 50006, + HV_PARTITION_PROPERTY_SGX_LAUNCH_CONTROL_CONFIG =3D 0x000= 50007, + HV_PARTITION_PROPERTY_DEFAULT_SGX_LAUNCH_CONTROL0 =3D 0x000= 50008, + HV_PARTITION_PROPERTY_DEFAULT_SGX_LAUNCH_CONTROL1 =3D 0x000= 50009, + HV_PARTITION_PROPERTY_DEFAULT_SGX_LAUNCH_CONTROL2 =3D 0x000= 5000a, + HV_PARTITION_PROPERTY_DEFAULT_SGX_LAUNCH_CONTROL3 =3D 0x000= 5000b, + HV_PARTITION_PROPERTY_ISOLATION_STATE =3D 0x000= 5000c, + HV_PARTITION_PROPERTY_ISOLATION_CONTROL =3D 0x000= 5000d, + HV_PARTITION_PROPERTY_ALLOCATION_ID =3D 0x000= 5000e, + HV_PARTITION_PROPERTY_MONITORING_ID =3D 0x000= 5000f, + HV_PARTITION_PROPERTY_IMPLEMENTED_PHYSICAL_ADDRESS_BITS =3D 0x000= 50010, + HV_PARTITION_PROPERTY_NON_ARCHITECTURAL_CORE_SHARING =3D 0x000= 50011, + HV_PARTITION_PROPERTY_HYPERCALL_DOORBELL_PAGE =3D 0x000= 50012, + HV_PARTITION_PROPERTY_ISOLATION_POLICY =3D 0x000= 50014, + HV_PARTITION_PROPERTY_UNIMPLEMENTED_MSR_ACTION =3D 0x000= 50017, + HV_PARTITION_PROPERTY_SEV_VMGEXIT_OFFLOADS =3D 0x000= 50022, + + /* Compatibility properties */ + HV_PARTITION_PROPERTY_PROCESSOR_VENDOR =3D 0x00060000, + HV_PARTITION_PROPERTY_PROCESSOR_FEATURES_DEPRECATED =3D 0x00060001, + HV_PARTITION_PROPERTY_PROCESSOR_XSAVE_FEATURES =3D 0x00060002, + HV_PARTITION_PROPERTY_PROCESSOR_CL_FLUSH_SIZE =3D 0x00060003, + HV_PARTITION_PROPERTY_ENLIGHTENMENT_MODIFICATIONS =3D 0x00060004, + HV_PARTITION_PROPERTY_COMPATIBILITY_VERSION =3D 0x00060005, + HV_PARTITION_PROPERTY_PHYSICAL_ADDRESS_WIDTH =3D 0x00060006, + HV_PARTITION_PROPERTY_XSAVE_STATES =3D 0x00060007, + HV_PARTITION_PROPERTY_MAX_XSAVE_DATA_SIZE =3D 0x00060008, + HV_PARTITION_PROPERTY_PROCESSOR_CLOCK_FREQUENCY =3D 0x00060009, + HV_PARTITION_PROPERTY_PROCESSOR_FEATURES0 =3D 0x0006000a, + HV_PARTITION_PROPERTY_PROCESSOR_FEATURES1 =3D 0x0006000b, + + /* Guest software properties */ + HV_PARTITION_PROPERTY_GUEST_OS_ID =3D 0x00070000, + + /* Nested virtualization properties */ + HV_PARTITION_PROPERTY_PROCESSOR_VIRTUALIZATION_FEATURES =3D 0x00080000, +}; + +/* HV Map GPA (Guest Physical Address) Flags */ +#define HV_MAP_GPA_PERMISSIONS_NONE 0x0 +#define HV_MAP_GPA_READABLE 0x1 +#define HV_MAP_GPA_WRITABLE 0x2 +#define HV_MAP_GPA_KERNEL_EXECUTABLE 0x4 +#define HV_MAP_GPA_USER_EXECUTABLE 0x8 +#define HV_MAP_GPA_EXECUTABLE 0xC +#define HV_MAP_GPA_PERMISSIONS_MASK 0xF +#define HV_MAP_GPA_ADJUSTABLE 0x8000 +#define HV_MAP_GPA_NO_ACCESS 0x10000 +#define HV_MAP_GPA_NOT_CACHED 0x200000 +#define HV_MAP_GPA_LARGE_PAGE 0x80000000 + +#define HV_PFN_RNG_PAGEBITS 24 /* HV_SPA_PAGE_RANGE_ADDITIONAL_PAGES_BITS= */ + +#endif /* HW_HYPERV_HVHDK_MINI_H */ diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers= .sh index 717c379f9e0..828a7809f75 100755 --- a/scripts/update-linux-headers.sh +++ b/scripts/update-linux-headers.sh @@ -195,7 +195,7 @@ rm -rf "$output/linux-headers/linux" mkdir -p "$output/linux-headers/linux" for header in const.h stddef.h kvm.h vfio.h vfio_ccw.h vfio_zdev.h vhost.h= \ psci.h psp-sev.h userfaultfd.h memfd.h mman.h nvme_ioctl.h \ - vduse.h iommufd.h bits.h; do + vduse.h iommufd.h bits.h mshv.h; do cp "$hdrdir/include/linux/$header" "$output/linux-headers/linux" done =20 --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996626; cv=none; d=zohomail.com; s=zohoarc; b=hcspKBaAj4kG8BCxHvN6ABeAUiy/Sy0J2FICfD369HTI797t0/6jr0z7xrvTn3Qys4iFPvtkkQYf+58rnj9B8/k5mS7cPvBJOZA5S7ddTW5FnHdeSQ+zFpI+9Uiz67WTZhwI3M0kVPBGyLNTH5F/ok8pvChsFb75Xq6ytREoYII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996626; 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=r5srvTzHoV3LP4XwQljxaZzDaB46yBog0GuxfhmPF98=; b=NHjlQjwydBZboabgojW7NIxOckGQdnCgZ/BTmO9XNWd5HvjQ2oTS3j8Vb8V/vrSDr6ZZ+9kQdYZrq0Bf99qkOjoZShJxCjBmAKPd/meA57xVuSAA89WAyxXxr6SBeZNZAJlYvpWB0l9X7ggx2J9g7qHY8cH/bGqiBW7AYul7IA4= 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 1759996626691886.1071248448185; Thu, 9 Oct 2025 00:57:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQX-0008FW-AF; Thu, 09 Oct 2025 03:51:05 -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 1v6lQU-0008EX-BY for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:02 -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 1v6lQQ-0004OD-9g for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:02 -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-368-hChXgI1gM1aoge9l08_5SA-1; Thu, 09 Oct 2025 03:50:55 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3ee130237e1so352097f8f.0 for ; Thu, 09 Oct 2025 00:50:55 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46faf4210d2sm32501735e9.1.2025.10.09.00.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996257; 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=r5srvTzHoV3LP4XwQljxaZzDaB46yBog0GuxfhmPF98=; b=GGFmk4IjbRKVnVcFeLwDah82iJQmCARfRvmkKNqsnmEc0WHnmCEEuDnq6g9asbud97uBbN t7R1CycAE2I1LSf7nbmnNmWGo/a+h2xgjlZ3fuiQUxgAesAY954fY1E6zil8O70fW2pXGe s0+HOave2y0ssLuuSvLHswOA65+nuPE= X-MC-Unique: hChXgI1gM1aoge9l08_5SA-1 X-Mimecast-MFC-AGG-ID: hChXgI1gM1aoge9l08_5SA_1759996255 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996253; x=1760601053; 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=r5srvTzHoV3LP4XwQljxaZzDaB46yBog0GuxfhmPF98=; b=EvNPlFbBvN1xlVUTAqnjOnM7KR/f/GlfqshPHZHbbnzcviwACP8Nx1iKLkf/OGXsrC 44EAbDZqLbx04qzLoJqYJPvLgheT3786tFq8TO4CQQhPXMoKISFFLzsAKN/reWLDbPaL JI4X8ugwbO0542vtxjgXwb5BB2XIrx8/771EOg5ItHqk4qARZPXa+lKLedjU5s6wPjE/ +QXhdLxgmUut2tRX4/bWy9WUUoIzJvWOxKw0PkkGpiT7Z9I6nAr3kKZjQ3MXuu4ylnaI VUZHv3kW2+eJvdllEHxGu5tNJ8Oep/mxymrV128gmYeXxy8bnZt+Slueio6FuPQBg8ZW y1Ig== X-Gm-Message-State: AOJu0YwAANqmFQuqkgBg1cmXAXrvKVEpe9lYkXgaW3xkxBpsJu9XDW7K nu96b3dCfq8tP+AXkzhieqQLl12JSU+hQVZYxG9AOlxsjhVFFv6neU8MdKGyjHPYJVm+Hiua+f1 Q5gN1cNh623FGZ6/iqwjkmZBVc9N7TssPrhHr5lli55mNbdv/Ruc7dWhrl8VxQ9LEmoNv60VmEs 8kzQoKoIWvmKTkBnug+91bf7IgTGS36DggTLLQyoHZs38= X-Gm-Gg: ASbGnctV0GR7VbLQoFHJWYEQjhFcwIVyg2medXKHST7+o9wKChsCVkO3QdhH/e8s3EX poX14Gztqvds6NIk8LBhzaB26MPTUQcDwlJSNXiPPo6jZMMZnpyGKqy0zg+rv9zxDVu2TS2RuOY 66Efpetpg+gGwPCnqWgWxc3osxUN3YHuaGBYMiLvcz7jiz+HIgUmQT6qFvJdE5r/Q6RHfnOGBns z8lEGq8XAIdmphsAS5ytT04+I2JrM/ht5Eb98MpsnMsZvTWoV/S0x4u4+aoOfxOlijD5eHRa5lT QwhkaPQn+I9X3/DWf+3EgRR/f8Qw3cXLDcZm7YgTOMqj1yyMT3cqWlpROO++F5p9qkx9iOjP+tw Xj6D1D+OLH6DK7dMtRbtABvcTA/QMa1Ku/ibtKXctv9F9+NNC X-Received: by 2002:a05:600c:1395:b0:46e:1cc6:25f7 with SMTP id 5b1f17b1804b1-46fa9aa045dmr45789285e9.9.1759996253140; Thu, 09 Oct 2025 00:50:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtVD3SDTnmLgVGNT8Lu+uqjK0VTjdy8KfKK7pq2dUrVJYFHmtoeiWNhoN/NQ1+LCRtUR1n+g== X-Received: by 2002:a05:600c:1395:b0:46e:1cc6:25f7 with SMTP id 5b1f17b1804b1-46fa9aa045dmr45789055e9.9.1759996252623; Thu, 09 Oct 2025 00:50:52 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 12/35] linux-headers/linux: Add mshv.h headers Date: Thu, 9 Oct 2025 09:50:02 +0200 Message-ID: <20251009075026.505715-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996631127116600 From: Magnus Kulke This file has been added to the tree by running `update-linux-header.sh` on linux v6.16. Signed-off-by: Magnus Kulke Reviewed-by: Daniel P. Berrang=C3=A9 Link: https://lore.kernel.org/r/20250916164847.77883-7-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- linux-headers/linux/mshv.h | 291 +++++++++++++++++++++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100644 linux-headers/linux/mshv.h diff --git a/linux-headers/linux/mshv.h b/linux-headers/linux/mshv.h new file mode 100644 index 00000000000..5bc83db6a32 --- /dev/null +++ b/linux-headers/linux/mshv.h @@ -0,0 +1,291 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Userspace interfaces for /dev/mshv* devices and derived fds + * + * This file is divided into sections containing data structures and IOCTL= s for + * a particular set of related devices or derived file descriptors. + * + * The IOCTL definitions are at the end of each section. They are grouped = by + * device/fd, so that new IOCTLs can easily be added with a monotonically + * increasing number. + */ +#ifndef _LINUX_MSHV_H +#define _LINUX_MSHV_H + +#include + +#define MSHV_IOCTL 0xB8 + +/* + ******************************************* + * Entry point to main VMM APIs: /dev/mshv * + ******************************************* + */ + +enum { + MSHV_PT_BIT_LAPIC, + MSHV_PT_BIT_X2APIC, + MSHV_PT_BIT_GPA_SUPER_PAGES, + MSHV_PT_BIT_COUNT, +}; + +#define MSHV_PT_FLAGS_MASK ((1 << MSHV_PT_BIT_COUNT) - 1) + +enum { + MSHV_PT_ISOLATION_NONE, + MSHV_PT_ISOLATION_COUNT, +}; + +/** + * struct mshv_create_partition - arguments for MSHV_CREATE_PARTITION + * @pt_flags: Bitmask of 1 << MSHV_PT_BIT_* + * @pt_isolation: MSHV_PT_ISOLATION_* + * + * Returns a file descriptor to act as a handle to a guest partition. + * At this point the partition is not yet initialized in the hypervisor. + * Some operations must be done with the partition in this state, e.g. set= ting + * so-called "early" partition properties. The partition can then be + * initialized with MSHV_INITIALIZE_PARTITION. + */ +struct mshv_create_partition { + __u64 pt_flags; + __u64 pt_isolation; +}; + +/* /dev/mshv */ +#define MSHV_CREATE_PARTITION _IOW(MSHV_IOCTL, 0x00, struct mshv_create_pa= rtition) + +/* + ************************ + * Child partition APIs * + ************************ + */ + +struct mshv_create_vp { + __u32 vp_index; +}; + +enum { + MSHV_SET_MEM_BIT_WRITABLE, + MSHV_SET_MEM_BIT_EXECUTABLE, + MSHV_SET_MEM_BIT_UNMAP, + MSHV_SET_MEM_BIT_COUNT +}; + +#define MSHV_SET_MEM_FLAGS_MASK ((1 << MSHV_SET_MEM_BIT_COUNT) - 1) + +/* The hypervisor's "native" page size */ +#define MSHV_HV_PAGE_SIZE 0x1000 + +/** + * struct mshv_user_mem_region - arguments for MSHV_SET_GUEST_MEMORY + * @size: Size of the memory region (bytes). Must be aligned to + * MSHV_HV_PAGE_SIZE + * @guest_pfn: Base guest page number to map + * @userspace_addr: Base address of userspace memory. Must be aligned to + * MSHV_HV_PAGE_SIZE + * @flags: Bitmask of 1 << MSHV_SET_MEM_BIT_*. If (1 << MSHV_SET_MEM_BIT_U= NMAP) + * is set, ignore other bits. + * @rsvd: MBZ + * + * Map or unmap a region of userspace memory to Guest Physical Addresses (= GPA). + * Mappings can't overlap in GPA space or userspace. + * To unmap, these fields must match an existing mapping. + */ +struct mshv_user_mem_region { + __u64 size; + __u64 guest_pfn; + __u64 userspace_addr; + __u8 flags; + __u8 rsvd[7]; +}; + +enum { + MSHV_IRQFD_BIT_DEASSIGN, + MSHV_IRQFD_BIT_RESAMPLE, + MSHV_IRQFD_BIT_COUNT, +}; + +#define MSHV_IRQFD_FLAGS_MASK ((1 << MSHV_IRQFD_BIT_COUNT) - 1) + +struct mshv_user_irqfd { + __s32 fd; + __s32 resamplefd; + __u32 gsi; + __u32 flags; +}; + +enum { + MSHV_IOEVENTFD_BIT_DATAMATCH, + MSHV_IOEVENTFD_BIT_PIO, + MSHV_IOEVENTFD_BIT_DEASSIGN, + MSHV_IOEVENTFD_BIT_COUNT, +}; + +#define MSHV_IOEVENTFD_FLAGS_MASK ((1 << MSHV_IOEVENTFD_BIT_COUNT) - 1) + +struct mshv_user_ioeventfd { + __u64 datamatch; + __u64 addr; /* legal pio/mmio address */ + __u32 len; /* 1, 2, 4, or 8 bytes */ + __s32 fd; + __u32 flags; + __u8 rsvd[4]; +}; + +struct mshv_user_irq_entry { + __u32 gsi; + __u32 address_lo; + __u32 address_hi; + __u32 data; +}; + +struct mshv_user_irq_table { + __u32 nr; + __u32 rsvd; /* MBZ */ + struct mshv_user_irq_entry entries[]; +}; + +enum { + MSHV_GPAP_ACCESS_TYPE_ACCESSED, + MSHV_GPAP_ACCESS_TYPE_DIRTY, + MSHV_GPAP_ACCESS_TYPE_COUNT /* Count of enum members */ +}; + +enum { + MSHV_GPAP_ACCESS_OP_NOOP, + MSHV_GPAP_ACCESS_OP_CLEAR, + MSHV_GPAP_ACCESS_OP_SET, + MSHV_GPAP_ACCESS_OP_COUNT /* Count of enum members */ +}; + +/** + * struct mshv_gpap_access_bitmap - arguments for MSHV_GET_GPAP_ACCESS_BIT= MAP + * @access_type: MSHV_GPAP_ACCESS_TYPE_* - The type of access to record in= the + * bitmap + * @access_op: MSHV_GPAP_ACCESS_OP_* - Allows an optional clear or set of = all + * the access states in the range, after retrieving the current + * states. + * @rsvd: MBZ + * @page_count: Number of pages + * @gpap_base: Base gpa page number + * @bitmap_ptr: Output buffer for bitmap, at least (page_count + 7) / 8 by= tes + * + * Retrieve a bitmap of either ACCESSED or DIRTY bits for a given range of= guest + * memory, and optionally clear or set the bits. + */ +struct mshv_gpap_access_bitmap { + __u8 access_type; + __u8 access_op; + __u8 rsvd[6]; + __u64 page_count; + __u64 gpap_base; + __u64 bitmap_ptr; +}; + +/** + * struct mshv_root_hvcall - arguments for MSHV_ROOT_HVCALL + * @code: Hypercall code (HVCALL_*) + * @reps: in: Rep count ('repcount') + * out: Reps completed ('repcomp'). MBZ unless rep hvcall + * @in_sz: Size of input incl rep data. <=3D MSHV_HV_PAGE_SIZE + * @out_sz: Size of output buffer. <=3D MSHV_HV_PAGE_SIZE. MBZ if out_ptr = is 0 + * @status: in: MBZ + * out: HV_STATUS_* from hypercall + * @rsvd: MBZ + * @in_ptr: Input data buffer (struct hv_input_*). If used with partition = or + * vp fd, partition id field is populated by kernel. + * @out_ptr: Output data buffer (optional) + */ +struct mshv_root_hvcall { + __u16 code; + __u16 reps; + __u16 in_sz; + __u16 out_sz; + __u16 status; + __u8 rsvd[6]; + __u64 in_ptr; + __u64 out_ptr; +}; + +/* Partition fds created with MSHV_CREATE_PARTITION */ +#define MSHV_INITIALIZE_PARTITION _IO(MSHV_IOCTL, 0x00) +#define MSHV_CREATE_VP _IOW(MSHV_IOCTL, 0x01, struct mshv_create_vp) +#define MSHV_SET_GUEST_MEMORY _IOW(MSHV_IOCTL, 0x02, struct mshv_user_mem= _region) +#define MSHV_IRQFD _IOW(MSHV_IOCTL, 0x03, struct mshv_user_irqfd) +#define MSHV_IOEVENTFD _IOW(MSHV_IOCTL, 0x04, struct mshv_user_ioeventfd) +#define MSHV_SET_MSI_ROUTING _IOW(MSHV_IOCTL, 0x05, struct mshv_user_irq_= table) +#define MSHV_GET_GPAP_ACCESS_BITMAP _IOWR(MSHV_IOCTL, 0x06, struct mshv_gp= ap_access_bitmap) +/* Generic hypercall */ +#define MSHV_ROOT_HVCALL _IOWR(MSHV_IOCTL, 0x07, struct mshv_root_hvcall) + +/* + ******************************** + * VP APIs for child partitions * + ******************************** + */ + +#define MSHV_RUN_VP_BUF_SZ 256 + +/* + * VP state pages may be mapped to userspace via mmap(). + * To specify which state page, use MSHV_VP_MMAP_OFFSET_ values multiplied= by + * the system page size. + * e.g. + * long page_size =3D sysconf(_SC_PAGE_SIZE); + * void *reg_page =3D mmap(NULL, MSHV_HV_PAGE_SIZE, PROT_READ|PROT_WRITE, + * MAP_SHARED, vp_fd, + * MSHV_VP_MMAP_OFFSET_REGISTERS * page_size); + */ +enum { + MSHV_VP_MMAP_OFFSET_REGISTERS, + MSHV_VP_MMAP_OFFSET_INTERCEPT_MESSAGE, + MSHV_VP_MMAP_OFFSET_GHCB, + MSHV_VP_MMAP_OFFSET_COUNT +}; + +/** + * struct mshv_run_vp - argument for MSHV_RUN_VP + * @msg_buf: On success, the intercept message is copied here. It can be + * interpreted using the relevant hypervisor definitions. + */ +struct mshv_run_vp { + __u8 msg_buf[MSHV_RUN_VP_BUF_SZ]; +}; + +enum { + MSHV_VP_STATE_LAPIC, /* Local interrupt controller state (either arch) */ + MSHV_VP_STATE_XSAVE, /* XSAVE data in compacted form (x86_64) */ + MSHV_VP_STATE_SIMP, + MSHV_VP_STATE_SIEFP, + MSHV_VP_STATE_SYNTHETIC_TIMERS, + MSHV_VP_STATE_COUNT, +}; + +/** + * struct mshv_get_set_vp_state - arguments for MSHV_[GET,SET]_VP_STATE + * @type: MSHV_VP_STATE_* + * @rsvd: MBZ + * @buf_sz: in: 4k page-aligned size of buffer + * out: Actual size of data (on EINVAL, check this to see if buff= er + * was too small) + * @buf_ptr: 4k page-aligned data buffer + */ +struct mshv_get_set_vp_state { + __u8 type; + __u8 rsvd[3]; + __u32 buf_sz; + __u64 buf_ptr; +}; + +/* VP fds created with MSHV_CREATE_VP */ +#define MSHV_RUN_VP _IOR(MSHV_IOCTL, 0x00, struct mshv_run_vp) +#define MSHV_GET_VP_STATE _IOWR(MSHV_IOCTL, 0x01, struct mshv_get_set_vp_= state) +#define MSHV_SET_VP_STATE _IOWR(MSHV_IOCTL, 0x02, struct mshv_get_set_vp_= state) +/* + * Generic hypercall + * Defined above in partition IOCTLs, avoid redefining it here + * #define MSHV_ROOT_HVCALL _IOWR(MSHV_IOCTL, 0x07, struct mshv_root_hvc= all) + */ + +#endif --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996360; cv=none; d=zohomail.com; s=zohoarc; b=JHRg/EUsWjgZuoWjscvPC+/2WPSWTpPW6noy+++9+KOpwXZz18+Er8VJSQ6c8ysu6RvQn+dKYncmsw4XLm7lgR2I0L/JymXv7U9rGurE4rS4Zdsj+1ILb6fL62IkuBLePuG+yREgNbRa6HRFfxg2RAaVAQdVdndMunFsePYtJUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996360; 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=BW2WJxOS4xr7mxNzCkKr1ZJuFLGZN8Iw793SnaBQLK8=; b=MLzwjfjv/xUcplCskc4X03Hfbu8vOYH6KezvJsC+Kn3R0uC/ihcJDdG38v0I1Q7mFozldGBZGWvf1y5U1MkL42zrpGydNhNZHl9qZgg2YjZZmh30BCvBMuz35cSpYuohmO64Ivig94S75Sr8yrMbfpLcdW3t682h/XmUKGmS42Q= 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 1759996360179765.1453442377897; Thu, 9 Oct 2025 00:52:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQZ-0008Fw-G8; Thu, 09 Oct 2025 03:51:07 -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 1v6lQY-0008Fg-7h for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51: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 1v6lQT-0004Og-UG for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:05 -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-668-rWOkIMncO8S-bk2RMLGxpQ-1; Thu, 09 Oct 2025 03:50:58 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46fb328a60eso569085e9.1 for ; Thu, 09 Oct 2025 00:50:58 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fab5250ddsm30255615e9.6.2025.10.09.00.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996260; 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=BW2WJxOS4xr7mxNzCkKr1ZJuFLGZN8Iw793SnaBQLK8=; b=H98usYd4pFZU+8QKqStPAARX+6JfyqU1hPCsvFgJVWKjVN0evq4IzAkQ7eKnqbYxKhcNMO ExVnjexQfljbNFfaZi0w9sJXgEqcK8yhlj5afQmg+bcI6PqAap2ajKg6ZITZvRRMqa6dnO dUkFpsnLCIZ+xd7drvgRJXgyf2ccXO8= X-MC-Unique: rWOkIMncO8S-bk2RMLGxpQ-1 X-Mimecast-MFC-AGG-ID: rWOkIMncO8S-bk2RMLGxpQ_1759996258 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996256; x=1760601056; 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=BW2WJxOS4xr7mxNzCkKr1ZJuFLGZN8Iw793SnaBQLK8=; b=IA30PoYimcFXhGdVouYKYMbVTsoad6XAQS1M/JMpXnmcYT2wYm1XuyuUbWxgKkXhj3 3f6gSBbV3Bi3v+gvmKxc1mi39ZVh2O1H1UabeGck21YeTuY+mUgW2iQwG8PkkgPGPJ4k OepX2dExqCzGZHyM3XdfJ4n1SSHZPyghspW/6hsBFU8Z/miYMU8hHmw6ko68WkjWrSTM Pxu3NbHfEyEa80izSpz0ckTxu+/NCGwtgmp/Zd0SRCPpENVa0phL3KNc/mAkQsq/E9/L UxEKmgYEhEtO5RP6r2SZnhmuhgJJHK7khODkOYvvZBU91fGwWv/jUA7LvLG9D0CNyTIv O4EQ== X-Gm-Message-State: AOJu0YzuwhLZulqRdCP690a3PErD3wR0F3T0QB09z+TFcIKksjqFIOWW GRdtzTVe9EnpH2SOnqMG+FlabUPFZoyQK3X1oiqUoo5NwTaW3yGmhvzrgy/HmJRrR+T/UWYd5Ll YTfpHE+SbJMGxQasjWu4MWK3RNZMelX2jeCyHSzWCMZj+DzgBX52aQvCZ2GzAWxWuCdTKr8unhA 0V2+punCgtHTMNSWlGH0RTX3fFbCptoVF1MFfz7ey3XKU= X-Gm-Gg: ASbGncsvzucIQYN8LXiLaN133r/5KGJ3hw9G7+IbrwiZ9lFqJ34EtWjpX7k9geOYp/I NTxqTMidIE8wNJi3v3N1hkqNfjAzQwPHjfmBf+Q9CW5QaBI9dyP8MNEzCjHLnX2rGuPBbvnpb3X duBqEp1Ayiy1P5kV3q3sG7e/ZHRSkopLXP0txTgAY5fEZNeLCqTvtT7j57LoI3QoCd6HPYRjLrz Qwujf3lNOK71/hTzRC+v/fRiNusa+rCkL4Dg4W64JiFg2DxgJpYaiMDPWcjka2APoTfo2wG81LD Bqn8+kGbiJ9cutVc5mAyhrNNSwhZYLs7LSJ9l3sJvrhs5QZdbwWr/YTYXa4mzpsrOAmIXEph7Oa MKhSXB6LOoBeEvTUaGi2QdLq2iksZabEGsiIWkfFfz9j67Eer X-Received: by 2002:a05:600d:41f3:b0:45b:7be1:be1f with SMTP id 5b1f17b1804b1-46fa9b092ddmr39467895e9.32.1759996256413; Thu, 09 Oct 2025 00:50:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0tg9xZoBoCQCZPtnXLx5EbmCPRivrDCwXTqh5lDdlWM3Ls/jihUcrTrjIwONfXuhEua7iww== X-Received: by 2002:a05:600d:41f3:b0:45b:7be1:be1f with SMTP id 5b1f17b1804b1-46fa9b092ddmr39467665e9.32.1759996255877; Thu, 09 Oct 2025 00:50:55 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 13/35] accel/mshv: Add accelerator skeleton Date: Thu, 9 Oct 2025 09:50:03 +0200 Message-ID: <20251009075026.505715-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996369624116600 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Introduce the initial scaffold for the MSHV (Microsoft Hypervisor) accelerator backend. This includes the basic directory structure and stub implementations needed to integrate with QEMU's accelerator framework. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-8-magnuskulke@linux.mi= crosoft.com [Move include of linux/mshv.h in the per-target section; create include/system/mshv_int.h. - Paolo] Signed-off-by: Paolo Bonzini --- include/system/mshv.h | 12 ++++ include/system/mshv_int.h | 41 +++++++++++ accel/mshv/mshv-all.c | 144 ++++++++++++++++++++++++++++++++++++++ accel/meson.build | 1 + accel/mshv/meson.build | 6 ++ 5 files changed, 204 insertions(+) create mode 100644 include/system/mshv_int.h create mode 100644 accel/mshv/mshv-all.c create mode 100644 accel/mshv/meson.build diff --git a/include/system/mshv.h b/include/system/mshv.h index 2a504ed81f2..434ea9682e1 100644 --- a/include/system/mshv.h +++ b/include/system/mshv.h @@ -14,8 +14,17 @@ #ifndef QEMU_MSHV_H #define QEMU_MSHV_H =20 +#include "qemu/osdep.h" +#include "qemu/accel.h" +#include "hw/hyperv/hyperv-proto.h" +#include "hw/hyperv/hvhdk.h" +#include "qapi/qapi-types-common.h" +#include "system/memory.h" +#include "accel/accel-ops.h" + #ifdef COMPILING_PER_TARGET #ifdef CONFIG_MSHV +#include #define CONFIG_MSHV_IS_POSSIBLE #endif #else @@ -30,6 +39,9 @@ extern bool mshv_allowed; #endif #define mshv_msi_via_irqfd_enabled() false =20 +typedef struct MshvState MshvState; +extern MshvState *mshv_state; + /* interrupt */ int mshv_irqchip_add_msi_route(int vector, PCIDevice *dev); int mshv_irqchip_update_msi_route(int virq, MSIMessage msg, PCIDevice *dev= ); diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h new file mode 100644 index 00000000000..132491b599d --- /dev/null +++ b/include/system/mshv_int.h @@ -0,0 +1,41 @@ +/* + * QEMU MSHV support + * + * Copyright Microsoft, Corp. 2025 + * + * Authors: Ziqiao Zhou + * Magnus Kulke + * Jinank Jain + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + */ + +#ifndef QEMU_MSHV_INT_H +#define QEMU_MSHV_INT_H + +struct AccelCPUState { + int cpufd; + bool dirty; +}; + +typedef struct MshvMemoryListener { + MemoryListener listener; + int as_id; +} MshvMemoryListener; + +typedef struct MshvAddressSpace { + MshvMemoryListener *ml; + AddressSpace *as; +} MshvAddressSpace; + +struct MshvState { + AccelState parent_obj; + int vm; + MshvMemoryListener memory_listener; + /* number of listeners */ + int nr_as; + MshvAddressSpace *as; +}; + +#endif diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c new file mode 100644 index 00000000000..ae12f0f58b9 --- /dev/null +++ b/accel/mshv/mshv-all.c @@ -0,0 +1,144 @@ +/* + * QEMU MSHV support + * + * Copyright Microsoft, Corp. 2025 + * + * Authors: + * Ziqiao Zhou + * Magnus Kulke + * Jinank Jain + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/event_notifier.h" +#include "qemu/module.h" +#include "qemu/main-loop.h" +#include "hw/boards.h" + +#include "hw/hyperv/hvhdk.h" +#include "hw/hyperv/hvhdk_mini.h" +#include "hw/hyperv/hvgdk.h" +#include "linux/mshv.h" + +#include "qemu/accel.h" +#include "qemu/guest-random.h" +#include "accel/accel-ops.h" +#include "accel/accel-cpu-ops.h" +#include "system/cpus.h" +#include "system/runstate.h" +#include "system/accel-blocker.h" +#include "system/address-spaces.h" +#include "system/mshv.h" +#include "system/mshv_int.h" +#include "system/reset.h" +#include "trace.h" +#include +#include +#include + +#define TYPE_MSHV_ACCEL ACCEL_CLASS_NAME("mshv") + +DECLARE_INSTANCE_CHECKER(MshvState, MSHV_STATE, TYPE_MSHV_ACCEL) + +bool mshv_allowed; + +MshvState *mshv_state; + +static int mshv_init(AccelState *as, MachineState *ms) +{ + error_report("unimplemented"); + abort(); +} + +static void mshv_start_vcpu_thread(CPUState *cpu) +{ + error_report("unimplemented"); + abort(); +} + +static void mshv_cpu_synchronize_post_init(CPUState *cpu) +{ + error_report("unimplemented"); + abort(); +} + +static void mshv_cpu_synchronize_post_reset(CPUState *cpu) +{ + error_report("unimplemented"); + abort(); +} + +static void mshv_cpu_synchronize_pre_loadvm(CPUState *cpu) +{ + error_report("unimplemented"); + abort(); +} + +static void mshv_cpu_synchronize(CPUState *cpu) +{ + error_report("unimplemented"); + abort(); +} + +static bool mshv_cpus_are_resettable(void) +{ + error_report("unimplemented"); + abort(); +} + +static void mshv_accel_class_init(ObjectClass *oc, const void *data) +{ + AccelClass *ac =3D ACCEL_CLASS(oc); + + ac->name =3D "MSHV"; + ac->init_machine =3D mshv_init; + ac->allowed =3D &mshv_allowed; +} + +static void mshv_accel_instance_init(Object *obj) +{ + MshvState *s =3D MSHV_STATE(obj); + + s->vm =3D 0; +} + +static const TypeInfo mshv_accel_type =3D { + .name =3D TYPE_MSHV_ACCEL, + .parent =3D TYPE_ACCEL, + .instance_init =3D mshv_accel_instance_init, + .class_init =3D mshv_accel_class_init, + .instance_size =3D sizeof(MshvState), +}; + +static void mshv_accel_ops_class_init(ObjectClass *oc, const void *data) +{ + AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); + + ops->create_vcpu_thread =3D mshv_start_vcpu_thread; + ops->synchronize_post_init =3D mshv_cpu_synchronize_post_init; + ops->synchronize_post_reset =3D mshv_cpu_synchronize_post_reset; + ops->synchronize_state =3D mshv_cpu_synchronize; + ops->synchronize_pre_loadvm =3D mshv_cpu_synchronize_pre_loadvm; + ops->cpus_are_resettable =3D mshv_cpus_are_resettable; + ops->handle_interrupt =3D generic_handle_interrupt; +} + +static const TypeInfo mshv_accel_ops_type =3D { + .name =3D ACCEL_OPS_NAME("mshv"), + .parent =3D TYPE_ACCEL_OPS, + .class_init =3D mshv_accel_ops_class_init, + .abstract =3D true, +}; + +static void mshv_type_init(void) +{ + type_register_static(&mshv_accel_type); + type_register_static(&mshv_accel_ops_type); +} + +type_init(mshv_type_init); diff --git a/accel/meson.build b/accel/meson.build index 6349efe682f..983dfd0bd55 100644 --- a/accel/meson.build +++ b/accel/meson.build @@ -10,6 +10,7 @@ if have_system subdir('kvm') subdir('xen') subdir('stubs') + subdir('mshv') endif =20 # qtest diff --git a/accel/mshv/meson.build b/accel/mshv/meson.build new file mode 100644 index 00000000000..4c03ac79219 --- /dev/null +++ b/accel/mshv/meson.build @@ -0,0 +1,6 @@ +mshv_ss =3D ss.source_set() +mshv_ss.add(if_true: files( + 'mshv-all.c' +)) + +specific_ss.add_all(when: 'CONFIG_MSHV', if_true: mshv_ss) --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996478; cv=none; d=zohomail.com; s=zohoarc; b=ct/z+DioUIEkSIRBDfkEorgkJkbs4rPojYBK/ncjoGM+P46fDrXZhhtdircrdGxBZCM3/BzUB1Ba78HGJ/uF4bhvuoEOCVduSjVNKWuBnoU23a7lXti+ywuhf4/SUUmCu0eBtnsIdhGWajl/5jt6QaSdwrkPw76/mKeJignjuIo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996478; 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=kRttI8LqJE5R4/hPKUJbIz7mchb821txk/PsshPhKrE=; b=YS8pT4FM9HgEL8Q5m9etVioCqi9aKhXt2JMCafnShZbwojNt3UA437qn9vE24b3Tz4XRMtEFyiIrD9eponn4jyEG8jHbTrm61TG2JtgZ7/kZmKzi3GKiL4z/TAGlOnfQTno87znyg30FZtcANB4rYXV5Kf9isf3mzjk8B36Aavs= 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 1759996478729784.0408912662086; Thu, 9 Oct 2025 00:54:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQe-0008Gq-3n; Thu, 09 Oct 2025 03:51:12 -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 1v6lQd-0008GX-4F for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:11 -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 1v6lQW-0004P1-Vu for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:10 -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-622-s4BmvBT6NimWYR7-U_7w7w-1; Thu, 09 Oct 2025 03:51:01 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3ecdfe971abso787889f8f.2 for ; Thu, 09 Oct 2025 00:51:01 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fa9d62890sm69282035e9.14.2025.10.09.00.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996263; 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=kRttI8LqJE5R4/hPKUJbIz7mchb821txk/PsshPhKrE=; b=FFZAubCbD5Zk9Yg3wntR4XVT+8VDtg0FrlngLSmZcEZxELJc5kGF9O6Ko6ZeccKu71nwgA TL38m5FKbllBX6YJvF0nIpmI3V0YByUJpuWIzspo8k5CqiQ6Q/FHR/273T+8YxhW0KOahF ne2s+0IP4o24DgOAMobG21xk9DQmElc= X-MC-Unique: s4BmvBT6NimWYR7-U_7w7w-1 X-Mimecast-MFC-AGG-ID: s4BmvBT6NimWYR7-U_7w7w_1759996260 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996259; x=1760601059; 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=kRttI8LqJE5R4/hPKUJbIz7mchb821txk/PsshPhKrE=; b=I0dALN4NVSpnMWpwqHZFiabH0NTSY8VmvCKMOG/Lwg77/dyKFZV0938ajHsEvh1q9z QZzqXDfx7vFnAG4+bgNNr6uGALUuv9JrSDM/Oo7USpydYamU1mQ3KqtbdM8sYM9U3Jmb gF65nZbucn84FDpP1P4W7Uw8sQPjcUFpQ1kw11VlG/8vCKL55s0cqdpYd2TbqR+7K4Fu VVkuzZvW8FWMSifQt8gCCnTAbmZmizztfEvW8KlTXVcS7VVZ3uR0W+6F1JJQ1uLmp0ry pwMmUIWyzAwXQqX7/NXORzcdm/ZBQaqTosA4KYL1ez5/Vpz7XQWjuO4F4QKsYg2+Pooh qJFw== X-Gm-Message-State: AOJu0YwnnD7y6ltd9HaYwVLGDTRk4ZEds0ogx5bnQxg2H1dnxwTalThc 5zZ+wYVtAdku0+rO+kL5+wLRwdoPKyBwYWQ/UcvYLAKmgrERfv5PmxXFhxb7x7/TGJs6YrlIV+7 zOX+8EpMBJccSla0lgmHm3V/tuRCS3jb4EXGUBASUT4aeyE5f2Hv1iuyTn0A/7QlRiWNVgSZStc XpRGVCcDQeif7m10AB7HoVbwqmpUmT2K9GJcG+7xXfH30= X-Gm-Gg: ASbGncuaiUsBeGe9GsjQguEnHUnJ25cfVkOPgYYGLc/qEKhyRO+dt6U/CL5LIogeyyB doLpW4o2wCgUx2whDU/hrV/c2JyVnDGwVlMu2xobx9bQWbDLY7ys4NfhQ6VaaSjCMaqwhuaRuv2 GdXj647h9n1uDtQ0Ujn/mhMx7CkXV/tBaolrA5OzzIlwwrB4o0iSXMnCYJvqYMC5XMVyxKZTR05 957f5dbMGipmF07nZ+yQsoxm839VCfA3cO1ntCf0HRzMJjYUFg79xOTdBkwWLTw/N1cUu8MbgKn yc6DYWbugKlXmyR/Ve0H4cKC49DCJnrfIOgDE8BlKBpsJgGa2/Y0PHGyzhFC3F9d+9g5w3VCKRs PsqhV0uW+K2BcgsTuozdhtBo2ARyAtWWDb3q9aLRndBc3Efys X-Received: by 2002:a05:600c:198f:b0:46e:3b1a:20d7 with SMTP id 5b1f17b1804b1-46fa9af8595mr49298145e9.19.1759996259232; Thu, 09 Oct 2025 00:50:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFlJJXmpR5YD6BvCj/ybtiU85WhsDEKc+ocnEN6V2cY2/HsI0wq17W9qQfES5qw3K5nu9v24g== X-Received: by 2002:a05:600c:198f:b0:46e:3b1a:20d7 with SMTP id 5b1f17b1804b1-46fa9af8595mr49297955e9.19.1759996258791; Thu, 09 Oct 2025 00:50:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 14/35] accel/mshv: Register memory region listeners Date: Thu, 9 Oct 2025 09:50:04 +0200 Message-ID: <20251009075026.505715-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996479503154100 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Add memory listener hooks for the MSHV accelerator to track guest memory regions. This enables the backend to respond to region additions, removals and will be used to manage guest memory mappings inside the hypervisor. Actually registering physical memory in the hypervisor is still stubbed out. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-9-magnuskulke@linux.mi= crosoft.com [mshv.h/mshv_int.h split. - Paolo] Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 4 +++ accel/mshv/mem.c | 25 +++++++++++++++ accel/mshv/mshv-all.c | 67 +++++++++++++++++++++++++++++++++++++-- accel/mshv/meson.build | 1 + 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 accel/mshv/mem.c diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 132491b599d..cfa177ff72f 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -38,4 +38,8 @@ struct MshvState { MshvAddressSpace *as; }; =20 +/* memory */ +void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryRegionSection *secti= on, + bool add); + #endif diff --git a/accel/mshv/mem.c b/accel/mshv/mem.c new file mode 100644 index 00000000000..9889918c31f --- /dev/null +++ b/accel/mshv/mem.c @@ -0,0 +1,25 @@ +/* + * QEMU MSHV support + * + * Copyright Microsoft, Corp. 2025 + * + * Authors: + * Magnus Kulke + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + */ + +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "system/address-spaces.h" +#include "system/mshv.h" +#include "system/mshv_int.h" + +void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryRegionSection *secti= on, + bool add) +{ + error_report("unimplemented"); + abort(); +} + diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index ae12f0f58b9..a684a366775 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -49,10 +49,73 @@ bool mshv_allowed; =20 MshvState *mshv_state; =20 +static void mem_region_add(MemoryListener *listener, + MemoryRegionSection *section) +{ + MshvMemoryListener *mml; + mml =3D container_of(listener, MshvMemoryListener, listener); + memory_region_ref(section->mr); + mshv_set_phys_mem(mml, section, true); +} + +static void mem_region_del(MemoryListener *listener, + MemoryRegionSection *section) +{ + MshvMemoryListener *mml; + mml =3D container_of(listener, MshvMemoryListener, listener); + mshv_set_phys_mem(mml, section, false); + memory_region_unref(section->mr); +} + +static MemoryListener mshv_memory_listener =3D { + .name =3D "mshv", + .priority =3D MEMORY_LISTENER_PRIORITY_ACCEL, + .region_add =3D mem_region_add, + .region_del =3D mem_region_del, +}; + +static MemoryListener mshv_io_listener =3D { + .name =3D "mshv", .priority =3D MEMORY_LISTENER_PRIORITY_DEV_BACKEND, + /* MSHV does not support PIO eventfd */ +}; + +static void register_mshv_memory_listener(MshvState *s, MshvMemoryListener= *mml, + AddressSpace *as, int as_id, + const char *name) +{ + int i; + + mml->listener =3D mshv_memory_listener; + mml->listener.name =3D name; + memory_listener_register(&mml->listener, as); + for (i =3D 0; i < s->nr_as; ++i) { + if (!s->as[i].as) { + s->as[i].as =3D as; + s->as[i].ml =3D mml; + break; + } + } +} + static int mshv_init(AccelState *as, MachineState *ms) { - error_report("unimplemented"); - abort(); + MshvState *s; + s =3D MSHV_STATE(as); + + accel_blocker_init(); + + s->vm =3D 0; + + s->nr_as =3D 1; + s->as =3D g_new0(MshvAddressSpace, s->nr_as); + + mshv_state =3D s; + + register_mshv_memory_listener(s, &s->memory_listener, &address_space_m= emory, + 0, "mshv-memory"); + memory_listener_register(&mshv_io_listener, &address_space_io); + + return 0; } =20 static void mshv_start_vcpu_thread(CPUState *cpu) diff --git a/accel/mshv/meson.build b/accel/mshv/meson.build index 4c03ac79219..8a6beb3fb1e 100644 --- a/accel/mshv/meson.build +++ b/accel/mshv/meson.build @@ -1,5 +1,6 @@ mshv_ss =3D ss.source_set() mshv_ss.add(if_true: files( + 'mem.c', 'mshv-all.c' )) =20 --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996383; cv=none; d=zohomail.com; s=zohoarc; b=eoER4T16Mn+1oX1Mn4dl86aLVE53/TN0FCBcbUFyk1/CM2gxnskphoLl4Ku+aspe/AAIKfe0ZSmGZ0mgQlTGPEVAjTTVnHt2gM5rssRIwBvTEqatvOh+qAeA11iW2VhOitKbBYJP2nM3foB6jmQJmG0dXC6Vl42INGVSmx/FF5A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996383; 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=/FsnFQ2/HC3jX91Jhs1DvKXLghyh1DJdCBxJnEQWP9w=; b=hfSZ8oVjC/M+NeklZkWsTJ1fQ1fAEhHFZSM7GWVyRP4EMg5OXgANzzNuxWS/FOlCjn+trrNcOLEI6OlgdE329E4cTlNb9FZYIwYhBd5lFXcgH27CL6qkIyVKbRQUcVj0Lm0g2aJWzaHRiC+JvaXjVv4pYkA05/uf/P65qowWgr8= 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 1759996383856327.39082863452177; Thu, 9 Oct 2025 00:53:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQg-0008I0-Tj; Thu, 09 Oct 2025 03:51:14 -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 1v6lQd-0008Ge-DU for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:11 -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 1v6lQY-0004PJ-Sh for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:11 -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-505-CTqUHinUPoCWT2qYUYZMXQ-1; Thu, 09 Oct 2025 03:51:04 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46e3a049abaso4020085e9.0 for ; Thu, 09 Oct 2025 00:51:03 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fab648795sm32268175e9.4.2025.10.09.00.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:50:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996265; 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=/FsnFQ2/HC3jX91Jhs1DvKXLghyh1DJdCBxJnEQWP9w=; b=XcrQfnGOGce3FtZYAgAqOpsgiAvaXdVUKm+W0Ghhif2bSYnaNBUUmCHKXphgXyAX0FahGg GfShB9OX8jeidsi0P9qnT0bICIRr77P8DshKvppuar07l8No0De3w9Igel6lGDy7ChnEqr KupOqdH5YUeE6AW5Evv6SnB1GbBan0c= X-MC-Unique: CTqUHinUPoCWT2qYUYZMXQ-1 X-Mimecast-MFC-AGG-ID: CTqUHinUPoCWT2qYUYZMXQ_1759996263 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996262; x=1760601062; 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=/FsnFQ2/HC3jX91Jhs1DvKXLghyh1DJdCBxJnEQWP9w=; b=n5qv2QjUsAJNkIT2cDI2yh07CquV9uFS3XnBoujWDIVEDRPNWRAPM/6c9d7pTaCWNp cH6xfXjUVI37wfDqjk9amvtaPQBFB+/ePdhEacm5d//Ls4AiWd0DP7t1gIvSWW5sRKYe 7jRE0fnT/Eu+yDfA+ifYwgO2C8dWrNaREt3sSUkmV3vSZr9snVYjeOfX294Iw3J0BGyH 0RAvhQAJ0sgjS8Y4JyufB40hLR5EnPczkThufJTAPmwx70/KgZSbo2+yUIAdvskxbJ6N 6k7b7uQnhSwd5ZU1UCoj/pReW/eRG2VpNSAl2R1kOlO0/YoIeEnYs7TfZXaoxvakO+w/ zRqQ== X-Gm-Message-State: AOJu0YyhEvXIeQTD3nihZJ6Sc8b5Nn4Gl1/WvKP5GATu3MRyPRzteH1q xErLLIli5ABuJ17upa3Ai65egil63jQE+9yDu8+J/m70FjfIgdSy0cdGeTSRDjjH/W3kBrJn2OT n+XE+EKgqlaDKZQj1RfDDejQc54ZJd692bZITkmy+h8at9bk7uK9SEWC6b+D+rnSEFRo+4dlbA7 DhqynuByKvrFxPPFp9UDBGY4beU7w3a2igxQ7nBDOW9qk= X-Gm-Gg: ASbGncu+RVgFW5z0X7vjmMSkyHCLwYQfm0aXvXbgmg1hBVmVM7H2w7NvvyuzQEMRHL9 s2AaVU2RJeG4ZCs6uywA1YV7QvsoogETKZdcUtrmEUHB3TgnUjW+44ZbQ+DWPf79zTGyJf7r7sD 2SbyjbSVgMLT1AeTwUtlHAwxLcXSY0tBDR4bWYfI3IoAhaYHDFQg88AxcQdRxGZVeGzFPyI6lUY gS3R9TNUj7uYLPs6e1wIWfoWrDYLD9RvVGRtMtbsR8Bn5NeSyEULuJ9UvDVGJAhk+h5T3Nkiowi eAJ1Ycat3D2tts5mf+MDjf8ugLe7jOAGf499ABqpIqoCkfDs8YD0vOz4cf9SKT3DuWPzAaSe5Dr tCckXoNjTXdKR9V7k0jr36rELVYbqnKfpSJHXvIGi4di/q3Hp X-Received: by 2002:a05:600c:6487:b0:46e:4783:1a7a with SMTP id 5b1f17b1804b1-46fa9a8f37emr41701915e9.3.1759996261687; Thu, 09 Oct 2025 00:51:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgdg+9ERiVH283RtVsoURmp1rEjXD2T0RD6mpl06VwQEXl1m7n+B9JOai5dCHF2/U5crW5HA== X-Received: by 2002:a05:600c:6487:b0:46e:4783:1a7a with SMTP id 5b1f17b1804b1-46fa9a8f37emr41701575e9.3.1759996260924; Thu, 09 Oct 2025 00:51:00 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 15/35] accel/mshv: Initialize VM partition Date: Thu, 9 Oct 2025 09:50:05 +0200 Message-ID: <20251009075026.505715-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996389101116600 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Create the MSHV virtual machine by opening a partition and issuing the necessary ioctl to initialize it. This sets up the basic VM structure and initial configuration used by MSHV to manage guest state. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-10-magnuskulke@linux.m= icrosoft.com [Add stubs; fix format strings for trace-events; make mshv_hvcall available only in per-target files; mshv.h/mshv_int.h split. - Paolo] Signed-off-by: Paolo Bonzini --- meson.build | 1 + accel/mshv/trace.h | 14 ++ include/system/mshv.h | 11 +- include/system/mshv_int.h | 25 +++ accel/mshv/irq.c | 399 +++++++++++++++++++++++++++++++++++ accel/mshv/mem.c | 129 ++++++++++- accel/mshv/mshv-all.c | 326 ++++++++++++++++++++++++++++ accel/stubs/mshv-stub.c | 44 ++++ hw/intc/apic.c | 8 + target/i386/mshv/mshv-cpu.c | 72 +++++++ accel/mshv/meson.build | 1 + accel/mshv/trace-events | 26 +++ accel/stubs/meson.build | 1 + target/i386/mshv/meson.build | 1 + 14 files changed, 1054 insertions(+), 4 deletions(-) create mode 100644 accel/mshv/trace.h create mode 100644 accel/mshv/irq.c create mode 100644 accel/stubs/mshv-stub.c create mode 100644 target/i386/mshv/mshv-cpu.c create mode 100644 accel/mshv/trace-events diff --git a/meson.build b/meson.build index 167021ed621..afaefa01722 100644 --- a/meson.build +++ b/meson.build @@ -3668,6 +3668,7 @@ if have_system trace_events_subdirs +=3D [ 'accel/hvf', 'accel/kvm', + 'accel/mshv', 'audio', 'backends', 'backends/tpm', diff --git a/accel/mshv/trace.h b/accel/mshv/trace.h new file mode 100644 index 00000000000..0dca48f9179 --- /dev/null +++ b/accel/mshv/trace.h @@ -0,0 +1,14 @@ +/* + * QEMU MSHV support + * + * Copyright Microsoft, Corp. 2025 + * + * Authors: + * Ziqiao Zhou + * Magnus Kulke + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + */ + +#include "trace/trace-accel_mshv.h" diff --git a/include/system/mshv.h b/include/system/mshv.h index 434ea9682e1..1011e81df47 100644 --- a/include/system/mshv.h +++ b/include/system/mshv.h @@ -31,18 +31,27 @@ #define CONFIG_MSHV_IS_POSSIBLE #endif =20 +#define MSHV_MAX_MSI_ROUTES 4096 + +#define MSHV_PAGE_SHIFT 12 + #ifdef CONFIG_MSHV_IS_POSSIBLE extern bool mshv_allowed; #define mshv_enabled() (mshv_allowed) +#define mshv_msi_via_irqfd_enabled() mshv_enabled() #else /* CONFIG_MSHV_IS_POSSIBLE */ #define mshv_enabled() false -#endif #define mshv_msi_via_irqfd_enabled() false +#endif =20 typedef struct MshvState MshvState; extern MshvState *mshv_state; =20 /* interrupt */ +int mshv_request_interrupt(MshvState *mshv_state, uint32_t interrupt_type,= uint32_t vector, + uint32_t vp_index, bool logical_destination_mod= e, + bool level_triggered); + int mshv_irqchip_add_msi_route(int vector, PCIDevice *dev); int mshv_irqchip_update_msi_route(int virq, MSIMessage msg, PCIDevice *dev= ); void mshv_irqchip_commit_routes(void); diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index cfa177ff72f..b36124a0ea7 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -36,10 +36,35 @@ struct MshvState { /* number of listeners */ int nr_as; MshvAddressSpace *as; + int fd; }; =20 +typedef struct MshvMsiControl { + bool updated; + GHashTable *gsi_routes; +} MshvMsiControl; + +void mshv_arch_amend_proc_features( + union hv_partition_synthetic_processor_features *features); +int mshv_arch_post_init_vm(int vm_fd); + +#if defined COMPILING_PER_TARGET && defined CONFIG_MSHV_IS_POSSIBLE +int mshv_hvcall(int fd, const struct mshv_root_hvcall *args); +#endif + /* memory */ +typedef struct MshvMemoryRegion { + uint64_t guest_phys_addr; + uint64_t memory_size; + uint64_t userspace_addr; + bool readonly; +} MshvMemoryRegion; + void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryRegionSection *secti= on, bool add); =20 +/* interrupt */ +void mshv_init_msicontrol(void); +int mshv_reserve_ioapic_msi_routes(int vm_fd); + #endif diff --git a/accel/mshv/irq.c b/accel/mshv/irq.c new file mode 100644 index 00000000000..adf8f337d9c --- /dev/null +++ b/accel/mshv/irq.c @@ -0,0 +1,399 @@ +/* + * QEMU MSHV support + * + * Copyright Microsoft, Corp. 2025 + * + * Authors: Ziqiao Zhou + * Magnus Kulke + * Stanislav Kinsburskii + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "linux/mshv.h" +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "hw/hyperv/hvhdk_mini.h" +#include "hw/hyperv/hvgdk_mini.h" +#include "hw/intc/ioapic.h" +#include "hw/pci/msi.h" +#include "system/mshv.h" +#include "system/mshv_int.h" +#include "trace.h" +#include +#include + +#define MSHV_IRQFD_RESAMPLE_FLAG (1 << MSHV_IRQFD_BIT_RESAMPLE) +#define MSHV_IRQFD_BIT_DEASSIGN_FLAG (1 << MSHV_IRQFD_BIT_DEASSIGN) + +static MshvMsiControl *msi_control; +static QemuMutex msi_control_mutex; + +void mshv_init_msicontrol(void) +{ + qemu_mutex_init(&msi_control_mutex); + msi_control =3D g_new0(MshvMsiControl, 1); + msi_control->gsi_routes =3D g_hash_table_new(g_direct_hash, g_direct_e= qual); + msi_control->updated =3D false; +} + +static int set_msi_routing(uint32_t gsi, uint64_t addr, uint32_t data) +{ + struct mshv_user_irq_entry *entry; + uint32_t high_addr =3D addr >> 32; + uint32_t low_addr =3D addr & 0xFFFFFFFF; + GHashTable *gsi_routes; + + trace_mshv_set_msi_routing(gsi, addr, data); + + if (gsi >=3D MSHV_MAX_MSI_ROUTES) { + error_report("gsi >=3D MSHV_MAX_MSI_ROUTES"); + return -1; + } + + assert(msi_control); + + WITH_QEMU_LOCK_GUARD(&msi_control_mutex) { + gsi_routes =3D msi_control->gsi_routes; + entry =3D g_hash_table_lookup(gsi_routes, GINT_TO_POINTER(gsi)); + + if (entry + && entry->address_hi =3D=3D high_addr + && entry->address_lo =3D=3D low_addr + && entry->data =3D=3D data) + { + /* nothing to update */ + return 0; + } + + /* free old entry */ + g_free(entry); + + /* create new entry */ + entry =3D g_new0(struct mshv_user_irq_entry, 1); + entry->gsi =3D gsi; + entry->address_hi =3D high_addr; + entry->address_lo =3D low_addr; + entry->data =3D data; + + g_hash_table_insert(gsi_routes, GINT_TO_POINTER(gsi), entry); + msi_control->updated =3D true; + } + + return 0; +} + +static int add_msi_routing(uint64_t addr, uint32_t data) +{ + struct mshv_user_irq_entry *route_entry; + uint32_t high_addr =3D addr >> 32; + uint32_t low_addr =3D addr & 0xFFFFFFFF; + int gsi; + GHashTable *gsi_routes; + + trace_mshv_add_msi_routing(addr, data); + + assert(msi_control); + + WITH_QEMU_LOCK_GUARD(&msi_control_mutex) { + /* find an empty slot */ + gsi =3D 0; + gsi_routes =3D msi_control->gsi_routes; + while (gsi < MSHV_MAX_MSI_ROUTES) { + route_entry =3D g_hash_table_lookup(gsi_routes, GINT_TO_POINTE= R(gsi)); + if (!route_entry) { + break; + } + gsi++; + } + if (gsi >=3D MSHV_MAX_MSI_ROUTES) { + error_report("No empty gsi slot available"); + return -1; + } + + /* create new entry */ + route_entry =3D g_new0(struct mshv_user_irq_entry, 1); + route_entry->gsi =3D gsi; + route_entry->address_hi =3D high_addr; + route_entry->address_lo =3D low_addr; + route_entry->data =3D data; + + g_hash_table_insert(gsi_routes, GINT_TO_POINTER(gsi), route_entry); + msi_control->updated =3D true; + } + + return gsi; +} + +static int commit_msi_routing_table(int vm_fd) +{ + guint len; + int i, ret; + size_t table_size; + struct mshv_user_irq_table *table; + GHashTableIter iter; + gpointer key, value; + + assert(msi_control); + + WITH_QEMU_LOCK_GUARD(&msi_control_mutex) { + if (!msi_control->updated) { + /* nothing to update */ + return 0; + } + + /* Calculate the size of the table */ + len =3D g_hash_table_size(msi_control->gsi_routes); + table_size =3D sizeof(struct mshv_user_irq_table) + + len * sizeof(struct mshv_user_irq_entry); + table =3D g_malloc0(table_size); + + g_hash_table_iter_init(&iter, msi_control->gsi_routes); + i =3D 0; + while (g_hash_table_iter_next(&iter, &key, &value)) { + struct mshv_user_irq_entry *entry =3D value; + table->entries[i] =3D *entry; + i++; + } + table->nr =3D i; + + trace_mshv_commit_msi_routing_table(vm_fd, len); + + ret =3D ioctl(vm_fd, MSHV_SET_MSI_ROUTING, table); + g_free(table); + if (ret < 0) { + error_report("Failed to commit msi routing table"); + return -1; + } + msi_control->updated =3D false; + } + return 0; +} + +static int remove_msi_routing(uint32_t gsi) +{ + struct mshv_user_irq_entry *route_entry; + GHashTable *gsi_routes; + + trace_mshv_remove_msi_routing(gsi); + + if (gsi >=3D MSHV_MAX_MSI_ROUTES) { + error_report("Invalid GSI: %u", gsi); + return -1; + } + + assert(msi_control); + + WITH_QEMU_LOCK_GUARD(&msi_control_mutex) { + gsi_routes =3D msi_control->gsi_routes; + route_entry =3D g_hash_table_lookup(gsi_routes, GINT_TO_POINTER(gs= i)); + if (route_entry) { + g_hash_table_remove(gsi_routes, GINT_TO_POINTER(gsi)); + g_free(route_entry); + msi_control->updated =3D true; + } + } + + return 0; +} + +/* Pass an eventfd which is to be used for injecting interrupts from userl= and */ +static int irqfd(int vm_fd, int fd, int resample_fd, uint32_t gsi, + uint32_t flags) +{ + int ret; + struct mshv_user_irqfd arg =3D { + .fd =3D fd, + .resamplefd =3D resample_fd, + .gsi =3D gsi, + .flags =3D flags, + }; + + ret =3D ioctl(vm_fd, MSHV_IRQFD, &arg); + if (ret < 0) { + error_report("Failed to set irqfd: gsi=3D%u, fd=3D%d", gsi, fd); + return -1; + } + return ret; +} + +static int register_irqfd(int vm_fd, int event_fd, uint32_t gsi) +{ + int ret; + + trace_mshv_register_irqfd(vm_fd, event_fd, gsi); + + ret =3D irqfd(vm_fd, event_fd, 0, gsi, 0); + if (ret < 0) { + error_report("Failed to register irqfd: gsi=3D%u", gsi); + return -1; + } + return 0; +} + +static int register_irqfd_with_resample(int vm_fd, int event_fd, + int resample_fd, uint32_t gsi) +{ + int ret; + uint32_t flags =3D MSHV_IRQFD_RESAMPLE_FLAG; + + ret =3D irqfd(vm_fd, event_fd, resample_fd, gsi, flags); + if (ret < 0) { + error_report("Failed to register irqfd with resample: gsi=3D%u", g= si); + return -errno; + } + return 0; +} + +static int unregister_irqfd(int vm_fd, int event_fd, uint32_t gsi) +{ + int ret; + uint32_t flags =3D MSHV_IRQFD_BIT_DEASSIGN_FLAG; + + ret =3D irqfd(vm_fd, event_fd, 0, gsi, flags); + if (ret < 0) { + error_report("Failed to unregister irqfd: gsi=3D%u", gsi); + return -errno; + } + return 0; +} + +static int irqchip_update_irqfd_notifier_gsi(const EventNotifier *event, + const EventNotifier *resample, + int virq, bool add) +{ + int fd =3D event_notifier_get_fd(event); + int rfd =3D resample ? event_notifier_get_fd(resample) : -1; + int vm_fd =3D mshv_state->vm; + + trace_mshv_irqchip_update_irqfd_notifier_gsi(fd, rfd, virq, add); + + if (!add) { + return unregister_irqfd(vm_fd, fd, virq); + } + + if (rfd > 0) { + return register_irqfd_with_resample(vm_fd, fd, rfd, virq); + } + + return register_irqfd(vm_fd, fd, virq); +} + + +int mshv_irqchip_add_msi_route(int vector, PCIDevice *dev) +{ + MSIMessage msg =3D { 0, 0 }; + int virq =3D 0; + + if (pci_available && dev) { + msg =3D pci_get_msi_message(dev, vector); + virq =3D add_msi_routing(msg.address, le32_to_cpu(msg.data)); + } + + return virq; +} + +void mshv_irqchip_release_virq(int virq) +{ + remove_msi_routing(virq); +} + +int mshv_irqchip_update_msi_route(int virq, MSIMessage msg, PCIDevice *dev) +{ + int ret; + + ret =3D set_msi_routing(virq, msg.address, le32_to_cpu(msg.data)); + if (ret < 0) { + error_report("Failed to set msi routing"); + return -1; + } + + return 0; +} + +int mshv_request_interrupt(MshvState *mshv_state, uint32_t interrupt_type,= uint32_t vector, + uint32_t vp_index, bool logical_dest_mode, + bool level_triggered) +{ + int ret; + int vm_fd =3D mshv_state->vm; + + if (vector =3D=3D 0) { + warn_report("Ignoring request for interrupt vector 0"); + return 0; + } + + union hv_interrupt_control control =3D { + .interrupt_type =3D interrupt_type, + .level_triggered =3D level_triggered, + .logical_dest_mode =3D logical_dest_mode, + .rsvd =3D 0, + }; + + struct hv_input_assert_virtual_interrupt arg =3D {0}; + arg.control =3D control; + arg.dest_addr =3D (uint64_t)vp_index; + arg.vector =3D vector; + + struct mshv_root_hvcall args =3D {0}; + args.code =3D HVCALL_ASSERT_VIRTUAL_INTERRUPT; + args.in_sz =3D sizeof(arg); + args.in_ptr =3D (uint64_t)&arg; + + ret =3D mshv_hvcall(vm_fd, &args); + if (ret < 0) { + error_report("Failed to request interrupt"); + return -errno; + } + return 0; +} + +void mshv_irqchip_commit_routes(void) +{ + int ret; + int vm_fd =3D mshv_state->vm; + + ret =3D commit_msi_routing_table(vm_fd); + if (ret < 0) { + error_report("Failed to commit msi routing table"); + abort(); + } +} + +int mshv_irqchip_add_irqfd_notifier_gsi(const EventNotifier *event, + const EventNotifier *resample, + int virq) +{ + return irqchip_update_irqfd_notifier_gsi(event, resample, virq, true); +} + +int mshv_irqchip_remove_irqfd_notifier_gsi(const EventNotifier *event, + int virq) +{ + return irqchip_update_irqfd_notifier_gsi(event, NULL, virq, false); +} + +int mshv_reserve_ioapic_msi_routes(int vm_fd) +{ + int ret, gsi; + + /* + * Reserve GSI 0-23 for IOAPIC pins, to avoid conflicts of legacy + * peripherals with MSI-X devices + */ + for (gsi =3D 0; gsi < IOAPIC_NUM_PINS; gsi++) { + ret =3D add_msi_routing(0, 0); + if (ret < 0) { + error_report("Failed to reserve GSI %d", gsi); + return -1; + } + } + + ret =3D commit_msi_routing_table(vm_fd); + if (ret < 0) { + error_report("Failed to commit reserved IOAPIC MSI routes"); + return -1; + } + + return 0; +} diff --git a/accel/mshv/mem.c b/accel/mshv/mem.c index 9889918c31f..a0a40eb3333 100644 --- a/accel/mshv/mem.c +++ b/accel/mshv/mem.c @@ -12,14 +12,137 @@ =20 #include "qemu/osdep.h" #include "qemu/error-report.h" +#include "linux/mshv.h" #include "system/address-spaces.h" #include "system/mshv.h" #include "system/mshv_int.h" +#include "exec/memattrs.h" +#include +#include "trace.h" + +static int set_guest_memory(int vm_fd, + const struct mshv_user_mem_region *region) +{ + int ret; + + ret =3D ioctl(vm_fd, MSHV_SET_GUEST_MEMORY, region); + if (ret < 0) { + error_report("failed to set guest memory"); + return -errno; + } + + return 0; +} + +static int map_or_unmap(int vm_fd, const MshvMemoryRegion *mr, bool map) +{ + struct mshv_user_mem_region region =3D {0}; + + region.guest_pfn =3D mr->guest_phys_addr >> MSHV_PAGE_SHIFT; + region.size =3D mr->memory_size; + region.userspace_addr =3D mr->userspace_addr; + + if (!map) { + region.flags |=3D (1 << MSHV_SET_MEM_BIT_UNMAP); + trace_mshv_unmap_memory(mr->userspace_addr, mr->guest_phys_addr, + mr->memory_size); + return set_guest_memory(vm_fd, ®ion); + } + + region.flags =3D BIT(MSHV_SET_MEM_BIT_EXECUTABLE); + if (!mr->readonly) { + region.flags |=3D BIT(MSHV_SET_MEM_BIT_WRITABLE); + } + + trace_mshv_map_memory(mr->userspace_addr, mr->guest_phys_addr, + mr->memory_size); + return set_guest_memory(vm_fd, ®ion); +} + +static int set_memory(const MshvMemoryRegion *mshv_mr, bool add) +{ + int ret =3D 0; + + if (!mshv_mr) { + error_report("Invalid mshv_mr"); + return -1; + } + + trace_mshv_set_memory(add, mshv_mr->guest_phys_addr, + mshv_mr->memory_size, + mshv_mr->userspace_addr, mshv_mr->readonly, + ret); + return map_or_unmap(mshv_state->vm, mshv_mr, add); +} + +/* + * Calculate and align the start address and the size of the section. + * Return the size. If the size is 0, the aligned section is empty. + */ +static hwaddr align_section(MemoryRegionSection *section, hwaddr *start) +{ + hwaddr size =3D int128_get64(section->size); + hwaddr delta, aligned; + + /* + * works in page size chunks, but the function may be called + * with sub-page size and unaligned start address. Pad the start + * address to next and truncate size to previous page boundary. + */ + aligned =3D ROUND_UP(section->offset_within_address_space, + qemu_real_host_page_size()); + delta =3D aligned - section->offset_within_address_space; + *start =3D aligned; + if (delta > size) { + return 0; + } + + return (size - delta) & qemu_real_host_page_mask(); +} =20 void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryRegionSection *secti= on, bool add) { - error_report("unimplemented"); - abort(); -} + int ret =3D 0; + MemoryRegion *area =3D section->mr; + bool writable =3D !area->readonly && !area->rom_device; + hwaddr start_addr, mr_offset, size; + void *ram; + MshvMemoryRegion mshv_mr =3D {0}; =20 + size =3D align_section(section, &start_addr); + trace_mshv_set_phys_mem(add, section->mr->name, start_addr); + + /* + * If the memory device is a writable non-ram area, we do not + * want to map it into the guest memory. If it is not a ROM device, + * we want to remove mshv memory mapping, so accesses will trap. + */ + if (!memory_region_is_ram(area)) { + if (writable) { + return; + } else if (!area->romd_mode) { + add =3D false; + } + } + + if (!size) { + return; + } + + mr_offset =3D section->offset_within_region + start_addr - + section->offset_within_address_space; + + ram =3D memory_region_get_ram_ptr(area) + mr_offset; + + mshv_mr.guest_phys_addr =3D start_addr; + mshv_mr.memory_size =3D size; + mshv_mr.readonly =3D !writable; + mshv_mr.userspace_addr =3D (uint64_t)ram; + + ret =3D set_memory(&mshv_mr, add); + if (ret < 0) { + error_report("Failed to set memory region"); + abort(); + } +} diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index a684a366775..653195c57c9 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -7,6 +7,7 @@ * Ziqiao Zhou * Magnus Kulke * Jinank Jain + * Wei Liu * * SPDX-License-Identifier: GPL-2.0-or-later * @@ -23,6 +24,7 @@ #include "hw/hyperv/hvhdk.h" #include "hw/hyperv/hvhdk_mini.h" #include "hw/hyperv/hvgdk.h" +#include "hw/hyperv/hvgdk_mini.h" #include "linux/mshv.h" =20 #include "qemu/accel.h" @@ -49,6 +51,175 @@ bool mshv_allowed; =20 MshvState *mshv_state; =20 +static int init_mshv(int *mshv_fd) +{ + int fd =3D open("/dev/mshv", O_RDWR | O_CLOEXEC); + if (fd < 0) { + error_report("Failed to open /dev/mshv: %s", strerror(errno)); + return -1; + } + *mshv_fd =3D fd; + return 0; +} + +/* freeze 1 to pause, 0 to resume */ +static int set_time_freeze(int vm_fd, int freeze) +{ + int ret; + struct hv_input_set_partition_property in =3D {0}; + in.property_code =3D HV_PARTITION_PROPERTY_TIME_FREEZE; + in.property_value =3D freeze; + + struct mshv_root_hvcall args =3D {0}; + args.code =3D HVCALL_SET_PARTITION_PROPERTY; + args.in_sz =3D sizeof(in); + args.in_ptr =3D (uint64_t)∈ + + ret =3D mshv_hvcall(vm_fd, &args); + if (ret < 0) { + error_report("Failed to set time freeze"); + return -1; + } + + return 0; +} + +static int pause_vm(int vm_fd) +{ + int ret; + + ret =3D set_time_freeze(vm_fd, 1); + if (ret < 0) { + error_report("Failed to pause partition: %s", strerror(errno)); + return -1; + } + + return 0; +} + +static int resume_vm(int vm_fd) +{ + int ret; + + ret =3D set_time_freeze(vm_fd, 0); + if (ret < 0) { + error_report("Failed to resume partition: %s", strerror(errno)); + return -1; + } + + return 0; +} + +static int create_partition(int mshv_fd, int *vm_fd) +{ + int ret; + struct mshv_create_partition args =3D {0}; + + /* Initialize pt_flags with the desired features */ + uint64_t pt_flags =3D (1ULL << MSHV_PT_BIT_LAPIC) | + (1ULL << MSHV_PT_BIT_X2APIC) | + (1ULL << MSHV_PT_BIT_GPA_SUPER_PAGES); + + /* Set default isolation type */ + uint64_t pt_isolation =3D MSHV_PT_ISOLATION_NONE; + + args.pt_flags =3D pt_flags; + args.pt_isolation =3D pt_isolation; + + ret =3D ioctl(mshv_fd, MSHV_CREATE_PARTITION, &args); + if (ret < 0) { + error_report("Failed to create partition: %s", strerror(errno)); + return -1; + } + + *vm_fd =3D ret; + return 0; +} + +static int set_synthetic_proc_features(int vm_fd) +{ + int ret; + struct hv_input_set_partition_property in =3D {0}; + union hv_partition_synthetic_processor_features features =3D {0}; + + /* Access the bitfield and set the desired features */ + features.hypervisor_present =3D 1; + features.hv1 =3D 1; + features.access_partition_reference_counter =3D 1; + features.access_synic_regs =3D 1; + features.access_synthetic_timer_regs =3D 1; + features.access_partition_reference_tsc =3D 1; + features.access_frequency_regs =3D 1; + features.access_intr_ctrl_regs =3D 1; + features.access_vp_index =3D 1; + features.access_hypercall_regs =3D 1; + features.tb_flush_hypercalls =3D 1; + features.synthetic_cluster_ipi =3D 1; + features.direct_synthetic_timers =3D 1; + + mshv_arch_amend_proc_features(&features); + + in.property_code =3D HV_PARTITION_PROPERTY_SYNTHETIC_PROC_FEATURES; + in.property_value =3D features.as_uint64[0]; + + struct mshv_root_hvcall args =3D {0}; + args.code =3D HVCALL_SET_PARTITION_PROPERTY; + args.in_sz =3D sizeof(in); + args.in_ptr =3D (uint64_t)∈ + + trace_mshv_hvcall_args("synthetic_proc_features", args.code, args.in_s= z); + + ret =3D mshv_hvcall(vm_fd, &args); + if (ret < 0) { + error_report("Failed to set synthethic proc features"); + return -errno; + } + return 0; +} + +static int initialize_vm(int vm_fd) +{ + int ret =3D ioctl(vm_fd, MSHV_INITIALIZE_PARTITION); + if (ret < 0) { + error_report("Failed to initialize partition: %s", strerror(errno)= ); + return -1; + } + return 0; +} + +static int create_vm(int mshv_fd, int *vm_fd) +{ + int ret =3D create_partition(mshv_fd, vm_fd); + if (ret < 0) { + return -1; + } + + ret =3D set_synthetic_proc_features(*vm_fd); + if (ret < 0) { + return -1; + } + + ret =3D initialize_vm(*vm_fd); + if (ret < 0) { + return -1; + } + + ret =3D mshv_reserve_ioapic_msi_routes(*vm_fd); + if (ret < 0) { + return -1; + } + + ret =3D mshv_arch_post_init_vm(*vm_fd); + if (ret < 0) { + return -1; + } + + /* Always create a frozen partition */ + pause_vm(*vm_fd); + + return 0; +} + static void mem_region_add(MemoryListener *listener, MemoryRegionSection *section) { @@ -67,11 +238,124 @@ static void mem_region_del(MemoryListener *listener, memory_region_unref(section->mr); } =20 +typedef enum { + DATAMATCH_NONE, + DATAMATCH_U32, + DATAMATCH_U64, +} DatamatchTag; + +typedef struct { + DatamatchTag tag; + union { + uint32_t u32; + uint64_t u64; + } value; +} Datamatch; + +/* flags: determine whether to de/assign */ +static int ioeventfd(int vm_fd, int event_fd, uint64_t addr, Datamatch dm, + uint32_t flags) +{ + struct mshv_user_ioeventfd args =3D {0}; + args.fd =3D event_fd; + args.addr =3D addr; + args.flags =3D flags; + + if (dm.tag =3D=3D DATAMATCH_NONE) { + args.datamatch =3D 0; + } else { + flags |=3D BIT(MSHV_IOEVENTFD_BIT_DATAMATCH); + args.flags =3D flags; + if (dm.tag =3D=3D DATAMATCH_U64) { + args.len =3D sizeof(uint64_t); + args.datamatch =3D dm.value.u64; + } else { + args.len =3D sizeof(uint32_t); + args.datamatch =3D dm.value.u32; + } + } + + return ioctl(vm_fd, MSHV_IOEVENTFD, &args); +} + +static int unregister_ioevent(int vm_fd, int event_fd, uint64_t mmio_addr) +{ + uint32_t flags =3D 0; + Datamatch dm =3D {0}; + + flags |=3D BIT(MSHV_IOEVENTFD_BIT_DEASSIGN); + dm.tag =3D DATAMATCH_NONE; + + return ioeventfd(vm_fd, event_fd, mmio_addr, dm, flags); +} + +static int register_ioevent(int vm_fd, int event_fd, uint64_t mmio_addr, + uint64_t val, bool is_64bit, bool is_datamatch) +{ + uint32_t flags =3D 0; + Datamatch dm =3D {0}; + + if (!is_datamatch) { + dm.tag =3D DATAMATCH_NONE; + } else if (is_64bit) { + dm.tag =3D DATAMATCH_U64; + dm.value.u64 =3D val; + } else { + dm.tag =3D DATAMATCH_U32; + dm.value.u32 =3D val; + } + + return ioeventfd(vm_fd, event_fd, mmio_addr, dm, flags); +} + +static void mem_ioeventfd_add(MemoryListener *listener, + MemoryRegionSection *section, + bool match_data, uint64_t data, + EventNotifier *e) +{ + int fd =3D event_notifier_get_fd(e); + int ret; + bool is_64 =3D int128_get64(section->size) =3D=3D 8; + uint64_t addr =3D section->offset_within_address_space; + + trace_mshv_mem_ioeventfd_add(addr, int128_get64(section->size), data); + + ret =3D register_ioevent(mshv_state->vm, fd, addr, data, is_64, match_= data); + + if (ret < 0) { + error_report("Failed to register ioeventfd: %s (%d)", strerror(-re= t), + -ret); + abort(); + } +} + +static void mem_ioeventfd_del(MemoryListener *listener, + MemoryRegionSection *section, + bool match_data, uint64_t data, + EventNotifier *e) +{ + int fd =3D event_notifier_get_fd(e); + int ret; + uint64_t addr =3D section->offset_within_address_space; + + trace_mshv_mem_ioeventfd_del(section->offset_within_address_space, + int128_get64(section->size), data); + + ret =3D unregister_ioevent(mshv_state->vm, fd, addr); + if (ret < 0) { + error_report("Failed to unregister ioeventfd: %s (%d)", strerror(-= ret), + -ret); + abort(); + } +} + static MemoryListener mshv_memory_listener =3D { .name =3D "mshv", .priority =3D MEMORY_LISTENER_PRIORITY_ACCEL, .region_add =3D mem_region_add, .region_del =3D mem_region_del, + .eventfd_add =3D mem_ioeventfd_add, + .eventfd_del =3D mem_ioeventfd_del, }; =20 static MemoryListener mshv_io_listener =3D { @@ -97,15 +381,57 @@ static void register_mshv_memory_listener(MshvState *s= , MshvMemoryListener *mml, } } =20 +int mshv_hvcall(int fd, const struct mshv_root_hvcall *args) +{ + int ret =3D 0; + + ret =3D ioctl(fd, MSHV_ROOT_HVCALL, args); + if (ret < 0) { + error_report("Failed to perform hvcall: %s", strerror(errno)); + return -1; + } + return ret; +} + + static int mshv_init(AccelState *as, MachineState *ms) { MshvState *s; + int mshv_fd, vm_fd, ret; + + if (mshv_state) { + warn_report("MSHV accelerator already initialized"); + return 0; + } + s =3D MSHV_STATE(as); =20 accel_blocker_init(); =20 s->vm =3D 0; =20 + ret =3D init_mshv(&mshv_fd); + if (ret < 0) { + return -1; + } + + mshv_init_msicontrol(); + + ret =3D create_vm(mshv_fd, &vm_fd); + if (ret < 0) { + close(mshv_fd); + return -1; + } + + ret =3D resume_vm(vm_fd); + if (ret < 0) { + close(mshv_fd); + close(vm_fd); + return -1; + } + + s->vm =3D vm_fd; + s->fd =3D mshv_fd; s->nr_as =3D 1; s->as =3D g_new0(MshvAddressSpace, s->nr_as); =20 diff --git a/accel/stubs/mshv-stub.c b/accel/stubs/mshv-stub.c new file mode 100644 index 00000000000..e499b199d9d --- /dev/null +++ b/accel/stubs/mshv-stub.c @@ -0,0 +1,44 @@ +/* + * QEMU MSHV stub + * + * Copyright Red Hat, Inc. 2025 + * + * Author: Paolo Bonzini + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/pci/msi.h" +#include "system/mshv.h" + +bool mshv_allowed; + +int mshv_irqchip_add_msi_route(int vector, PCIDevice *dev) +{ + return -ENOSYS; +} + +void mshv_irqchip_release_virq(int virq) +{ +} + +int mshv_irqchip_update_msi_route(int virq, MSIMessage msg, PCIDevice *dev) +{ + return -ENOSYS; +} + +void mshv_irqchip_commit_routes(void) +{ +} + +int mshv_irqchip_add_irqfd_notifier_gsi(const EventNotifier *n, + const EventNotifier *rn, int virq) +{ + return -ENOSYS; +} + +int mshv_irqchip_remove_irqfd_notifier_gsi(const EventNotifier *n, int vir= q) +{ + return -ENOSYS; +} diff --git a/hw/intc/apic.c b/hw/intc/apic.c index bcb103560c7..6d7859640c2 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -27,6 +27,7 @@ #include "hw/pci/msi.h" #include "qemu/host-utils.h" #include "system/kvm.h" +#include "system/mshv.h" #include "trace.h" #include "hw/i386/apic-msidef.h" #include "qapi/error.h" @@ -932,6 +933,13 @@ static void apic_send_msi(MSIMessage *msi) uint8_t trigger_mode =3D (data >> MSI_DATA_TRIGGER_SHIFT) & 0x1; uint8_t delivery =3D (data >> MSI_DATA_DELIVERY_MODE_SHIFT) & 0x7; /* XXX: Ignore redirection hint. */ +#ifdef CONFIG_MSHV + if (mshv_enabled()) { + mshv_request_interrupt(mshv_state, delivery, vector, dest, + dest_mode, trigger_mode); + return; + } +#endif apic_deliver_irq(dest, dest_mode, delivery, vector, trigger_mode); } =20 diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c new file mode 100644 index 00000000000..de0c26bc6c6 --- /dev/null +++ b/target/i386/mshv/mshv-cpu.c @@ -0,0 +1,72 @@ +/* + * QEMU MSHV support + * + * Copyright Microsoft, Corp. 2025 + * + * Authors: Ziqiao Zhou + * Magnus Kulke + * Jinank Jain + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qemu/typedefs.h" + +#include "system/mshv.h" +#include "system/mshv_int.h" +#include "system/address-spaces.h" +#include "linux/mshv.h" +#include "hw/hyperv/hvgdk.h" +#include "hw/hyperv/hvgdk_mini.h" +#include "hw/hyperv/hvhdk_mini.h" + +#include "trace-accel_mshv.h" +#include "trace.h" + +void mshv_arch_amend_proc_features( + union hv_partition_synthetic_processor_features *features) +{ + features->access_guest_idle_reg =3D 1; +} + +/* + * Default Microsoft Hypervisor behavior for unimplemented MSR is to send a + * fault to the guest if it tries to access it. It is possible to override + * this behavior with a more suitable option i.e., ignore writes from the = guest + * and return zero in attempt to read unimplemented. + */ +static int set_unimplemented_msr_action(int vm_fd) +{ + struct hv_input_set_partition_property in =3D {0}; + struct mshv_root_hvcall args =3D {0}; + + in.property_code =3D HV_PARTITION_PROPERTY_UNIMPLEMENTED_MSR_ACTION; + in.property_value =3D HV_UNIMPLEMENTED_MSR_ACTION_IGNORE_WRITE_READ_ZE= RO; + + args.code =3D HVCALL_SET_PARTITION_PROPERTY; + args.in_sz =3D sizeof(in); + args.in_ptr =3D (uint64_t)∈ + + trace_mshv_hvcall_args("unimplemented_msr_action", args.code, args.in_= sz); + + int ret =3D mshv_hvcall(vm_fd, &args); + if (ret < 0) { + error_report("Failed to set unimplemented MSR action"); + return -1; + } + return 0; +} + +int mshv_arch_post_init_vm(int vm_fd) +{ + int ret; + + ret =3D set_unimplemented_msr_action(vm_fd); + if (ret < 0) { + error_report("Failed to set unimplemented MSR action"); + } + + return ret; +} diff --git a/accel/mshv/meson.build b/accel/mshv/meson.build index 8a6beb3fb1e..f88fc8678c3 100644 --- a/accel/mshv/meson.build +++ b/accel/mshv/meson.build @@ -1,5 +1,6 @@ mshv_ss =3D ss.source_set() mshv_ss.add(if_true: files( + 'irq.c', 'mem.c', 'mshv-all.c' )) diff --git a/accel/mshv/trace-events b/accel/mshv/trace-events new file mode 100644 index 00000000000..6130c4abf8a --- /dev/null +++ b/accel/mshv/trace-events @@ -0,0 +1,26 @@ +# Authors: Ziqiao Zhou +# Magnus Kulke +# +# SPDX-License-Identifier: GPL-2.0-or-later + +mshv_set_memory(bool add, uint64_t gpa, uint64_t size, uint64_t user_addr,= bool readonly, int ret) "add=3D%d gpa=3D0x%" PRIx64 " size=3D0x%" PRIx64 "= user=3D0x%" PRIx64 " readonly=3D%d result=3D%d" +mshv_mem_ioeventfd_add(uint64_t addr, uint32_t size, uint32_t data) "addr= =3D0x%" PRIx64 " size=3D%d data=3D0x%x" +mshv_mem_ioeventfd_del(uint64_t addr, uint32_t size, uint32_t data) "addr= =3D0x%" PRIx64 " size=3D%d data=3D0x%x" + +mshv_hvcall_args(const char* hvcall, uint16_t code, uint16_t in_sz) "built= args for '%s' code: %d in_sz: %d" + +mshv_handle_interrupt(uint32_t cpu, int mask) "cpu_index=3D%d mask=3D0x%x" +mshv_set_msi_routing(uint32_t gsi, uint64_t addr, uint32_t data) "gsi=3D%d= addr=3D0x%" PRIx64 " data=3D0x%x" +mshv_remove_msi_routing(uint32_t gsi) "gsi=3D%d" +mshv_add_msi_routing(uint64_t addr, uint32_t data) "addr=3D0x%" PRIx64 " d= ata=3D0x%x" +mshv_commit_msi_routing_table(int vm_fd, int len) "vm_fd=3D%d table_size= =3D%d" +mshv_register_irqfd(int vm_fd, int event_fd, uint32_t gsi) "vm_fd=3D%d eve= nt_fd=3D%d gsi=3D%d" +mshv_irqchip_update_irqfd_notifier_gsi(int event_fd, int resample_fd, int = virq, bool add) "event_fd=3D%d resample_fd=3D%d virq=3D%d add=3D%d" + +mshv_insn_fetch(uint64_t addr, size_t size) "gpa=3D0x%" PRIx64 " size=3D%z= u" +mshv_mem_write(uint64_t addr, size_t size) "\tgpa=3D0x%" PRIx64 " size=3D%= zu" +mshv_mem_read(uint64_t addr, size_t size) "\tgpa=3D0x%" PRIx64 " size=3D%z= u" +mshv_map_memory(uint64_t userspace_addr, uint64_t gpa, uint64_t size) "\tu= _a=3D0x%" PRIx64 " gpa=3D0x%010" PRIx64 " size=3D0x%08" PRIx64 +mshv_unmap_memory(uint64_t userspace_addr, uint64_t gpa, uint64_t size) "\= tu_a=3D0x%" PRIx64 " gpa=3D0x%010" PRIx64 " size=3D0x%08" PRIx64 +mshv_set_phys_mem(bool add, const char *name, uint64_t gpa) "\tadd=3D%d na= me=3D%s gpa=3D0x%010" PRIx64 +mshv_handle_mmio(uint64_t gva, uint64_t gpa, uint64_t size, uint8_t access= _type) "\tgva=3D0x%" PRIx64 " gpa=3D0x%010" PRIx64 " size=3D0x%" PRIx64 " a= ccess_type=3D%d" diff --git a/accel/stubs/meson.build b/accel/stubs/meson.build index 9dfc4f9ddaf..48eccd1b861 100644 --- a/accel/stubs/meson.build +++ b/accel/stubs/meson.build @@ -5,5 +5,6 @@ system_stubs_ss.add(when: 'CONFIG_TCG', if_false: files('tc= g-stub.c')) system_stubs_ss.add(when: 'CONFIG_HVF', if_false: files('hvf-stub.c')) system_stubs_ss.add(when: 'CONFIG_NVMM', if_false: files('nvmm-stub.c')) system_stubs_ss.add(when: 'CONFIG_WHPX', if_false: files('whpx-stub.c')) +system_stubs_ss.add(when: 'CONFIG_MSHV', if_false: files('mshv-stub.c')) =20 specific_ss.add_all(when: ['CONFIG_SYSTEM_ONLY'], if_true: system_stubs_ss) diff --git a/target/i386/mshv/meson.build b/target/i386/mshv/meson.build index 8ddaa7c11dc..647e5dafb77 100644 --- a/target/i386/mshv/meson.build +++ b/target/i386/mshv/meson.build @@ -1,6 +1,7 @@ i386_mshv_ss =3D ss.source_set() =20 i386_mshv_ss.add(files( + 'mshv-cpu.c', 'x86.c', )) =20 --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996416; cv=none; d=zohomail.com; s=zohoarc; b=LtN3BxTYU6N3Oni8I0qQkHTY87pwU+U1tHFkSJCRh9zKrMncNU4nvnw6PTBRZTvzDwAMcXXhv307zzaG5D2I4tkfgZiQLZBheY7kAwi8KLmU1lOcTzmEe3hpY4ZxBg1L1gpQ8qm/NRQMnb1VKMLzjQ6azwp2BNBUAui3aB8XphQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996416; 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=9jql7MUxN6DyQAt65oei9CU9WqI9qc1PVKDanIBuSZI=; b=BdyFMV2bdLKiFlR4y3E9ASh/GIRSoQHNFeaHia9Oq5HfR7AnT4UJLYa8SBqlZC7dLtv2EsV2QEbAR5RvlX3iQqbtw0Z+2YpaJGGeYM+eTQzg9HXFya1iBykMFfu3nWpl5KTVC2p0euaX5dvrtojziO7fkjWydRBB/luNlZ+dB3k= 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 1759996416446778.5495676082232; Thu, 9 Oct 2025 00:53:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQm-0008Oj-4x; Thu, 09 Oct 2025 03:51:20 -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 1v6lQj-0008KH-Um for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:18 -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 1v6lQa-0004Pj-85 for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:17 -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-182-1Uxvgyj1NyyEBApO9SPepQ-1; Thu, 09 Oct 2025 03:51:05 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e7a2c3773so7856585e9.0 for ; Thu, 09 Oct 2025 00:51:05 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6b8bsm33340575f8f.4.2025.10.09.00.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996267; 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=9jql7MUxN6DyQAt65oei9CU9WqI9qc1PVKDanIBuSZI=; b=WhIoQO2m3OBenNCvbGV4B8uLTFLnxR2L40mKtOMu5CqIoawKOwO8ebIu1nD9xnEY8dZ1AS J1d7IMnqiTxHZh+hIzjWl9jJgw8pAuqsJS0+U5wOg/tXSqGtFb6w+RbeBi/1RhDiT4ZMEv zXay2YBF/ISN7R7ZvtMWz+AwZzc0y2I= X-MC-Unique: 1Uxvgyj1NyyEBApO9SPepQ-1 X-Mimecast-MFC-AGG-ID: 1Uxvgyj1NyyEBApO9SPepQ_1759996265 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996263; x=1760601063; 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=9jql7MUxN6DyQAt65oei9CU9WqI9qc1PVKDanIBuSZI=; b=ObteTb/HQOeOS7J4WCy0F2HpHmllxn4ZLR0ggPuKFM79m1PWu9WN/dZVpZjp8+SNty Ej+7YkNNDZ/XdrSiWGH4A4nE+gqG0mW/l1GWkhPblfHL9a/+55xTBwhhXVsDhwv3gB8n 2d+tWXwVBrj0sB/ERuYoda9ILpM3SQrMva7BnvzKO3KGxVyTDzHg3df7W5rrwDe52sak lCTNUEVtoPZ7tfPe/8JAB6bJt5WhpR9BBh/p/5CY9hITkvjUoRDf3FMbyyOQyq8f1n4O aCJ8y4KToRU4+PqDlcAPMILp4ajm7WDtQMP9yqaLM/sKonqrnoPL9cTOmY13WG1X7e/O aEow== X-Gm-Message-State: AOJu0Yx1ZaRE6Cl56F1OJ/d22sFEpIFRVkF4IfoYt+8fIhiphjrBb6Fq 9sDvU9RzJGGrd16BjxYCJcISfQmOD3TRaRxbQoQoVpBfX/FeGjocwumfxdVtwx0pYyXWhBJWNTj e+TxbYOfZ6xM1oXG9KM2UKMdSEpFx3DGNM8zIiYqpXsWJeFHlx253JgAmWnFUHhIW0vHKIdRXT1 wpyQOhDFtSSVHzRt3DMYjoiLT3IBM9pEd9NENKgXGD3wY= X-Gm-Gg: ASbGnctqeN1dG8LdSO3fdFrQ59rY6ZOS/kYXHjCYtoMGoZIbcvbFQmem4ejrLLJrnQA utgcQysTyAB1+D2fTrsvBJKNQqiscBJ975RfwjQ7MI/PshHGS4Hr44V3kesSxgnHx0qRHwcmfdf 7nJY0phVGMN1kHL9NrQ644cd3gFR3XkzuxRP8Qp872FiY0/gnRehqMawouO11TZTnWT0qEQNPzw 6ksIp+iPFGMKbTMPF7zFwNmrm+hR4fXgmAiXOsjl850gaP176SHJ37dm3kR5LDkMTi57bedL0kp EC0vOYdMmMAjLz1qNuWAYzGErpmow3OxZRkwq3nSX37Uolg7IEpm1vHlqTada4bXYOd+RX3Nnu3 JRafnvCjpptu9uV7g5af4AKyrVq4tq3oUcdKNdBSzJrS/thc0 X-Received: by 2002:a05:6000:2386:b0:425:6fb5:2ad4 with SMTP id ffacd0b85a97d-425829e78f4mr6787994f8f.15.1759996263044; Thu, 09 Oct 2025 00:51:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/09Lu9aEGppm7HeredNwct2rqsEPCktxM0aQDFNI66hpR08C76DkfP/ogl+xXjG0GTWyUXg== X-Received: by 2002:a05:6000:2386:b0:425:6fb5:2ad4 with SMTP id ffacd0b85a97d-425829e78f4mr6787968f8f.15.1759996262435; Thu, 09 Oct 2025 00:51:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 16/35] accel/mshv: Add vCPU creation and execution loop Date: Thu, 9 Oct 2025 09:50:06 +0200 Message-ID: <20251009075026.505715-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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, T_SPF_HELO_TEMPERROR=0.01, 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: 1759996419669116600 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Create MSHV vCPUs using MSHV_CREATE_VP and initialize their state. Register the MSHV CPU execution loop loop with the QEMU accelerator framework to enable guest code execution. The target/i386 functionality is still mostly stubbed out and will be populated in a later commit in this series. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-11-magnuskulke@linux.m= icrosoft.com [Fix g_free/g_clear_pointer confusion; rename qemu_wait_io_event; mshv.h/mshv_int.h split. - Paolo] Signed-off-by: Paolo Bonzini --- include/system/mshv.h | 2 +- include/system/mshv_int.h | 20 ++++ accel/mshv/mshv-all.c | 186 +++++++++++++++++++++++++++++++++--- target/i386/mshv/mshv-cpu.c | 63 ++++++++++++ accel/mshv/trace-events | 2 + 5 files changed, 260 insertions(+), 13 deletions(-) diff --git a/include/system/mshv.h b/include/system/mshv.h index 1011e81df47..bbc42f4dc3a 100644 --- a/include/system/mshv.h +++ b/include/system/mshv.h @@ -41,7 +41,7 @@ extern bool mshv_allowed; #define mshv_msi_via_irqfd_enabled() mshv_enabled() #else /* CONFIG_MSHV_IS_POSSIBLE */ #define mshv_enabled() false -#define mshv_msi_via_irqfd_enabled() false +#define mshv_msi_via_irqfd_enabled() mshv_enabled() #endif =20 typedef struct MshvState MshvState; diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index b36124a0ea7..fb80f69772b 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -14,6 +14,8 @@ #ifndef QEMU_MSHV_INT_H #define QEMU_MSHV_INT_H =20 +typedef struct hyperv_message hv_message; + struct AccelCPUState { int cpufd; bool dirty; @@ -44,6 +46,24 @@ typedef struct MshvMsiControl { GHashTable *gsi_routes; } MshvMsiControl; =20 +#define mshv_vcpufd(cpu) (cpu->accel->cpufd) + +/* cpu */ +typedef enum MshvVmExit { + MshvVmExitIgnore =3D 0, + MshvVmExitShutdown =3D 1, + MshvVmExitSpecial =3D 2, +} MshvVmExit; + +void mshv_init_mmio_emu(void); +int mshv_create_vcpu(int vm_fd, uint8_t vp_index, int *cpu_fd); +void mshv_remove_vcpu(int vm_fd, int cpu_fd); +int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *e= xit); +int mshv_load_regs(CPUState *cpu); +int mshv_store_regs(CPUState *cpu); +int mshv_arch_put_registers(const CPUState *cpu); +void mshv_arch_init_vcpu(CPUState *cpu); +void mshv_arch_destroy_vcpu(CPUState *cpu); void mshv_arch_amend_proc_features( union hv_partition_synthetic_processor_features *features); int mshv_arch_post_init_vm(int vm_fd); diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index 653195c57c9..e02421d79d4 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -393,6 +393,24 @@ int mshv_hvcall(int fd, const struct mshv_root_hvcall = *args) return ret; } =20 +static int mshv_init_vcpu(CPUState *cpu) +{ + int vm_fd =3D mshv_state->vm; + uint8_t vp_index =3D cpu->cpu_index; + int ret; + + mshv_arch_init_vcpu(cpu); + cpu->accel =3D g_new0(AccelCPUState, 1); + + ret =3D mshv_create_vcpu(vm_fd, vp_index, &cpu->accel->cpufd); + if (ret < 0) { + return -1; + } + + cpu->accel->dirty =3D true; + + return 0; +} =20 static int mshv_init(AccelState *as, MachineState *ms) { @@ -415,6 +433,8 @@ static int mshv_init(AccelState *as, MachineState *ms) return -1; } =20 + mshv_init_mmio_emu(); + mshv_init_msicontrol(); =20 ret =3D create_vm(mshv_fd, &vm_fd); @@ -444,40 +464,182 @@ static int mshv_init(AccelState *as, MachineState *m= s) return 0; } =20 +static int mshv_destroy_vcpu(CPUState *cpu) +{ + int cpu_fd =3D mshv_vcpufd(cpu); + int vm_fd =3D mshv_state->vm; + + mshv_remove_vcpu(vm_fd, cpu_fd); + mshv_vcpufd(cpu) =3D 0; + + mshv_arch_destroy_vcpu(cpu); + g_clear_pointer(&cpu->accel, g_free); + return 0; +} + +static int mshv_cpu_exec(CPUState *cpu) +{ + hv_message mshv_msg; + enum MshvVmExit exit_reason; + int ret =3D 0; + + bql_unlock(); + cpu_exec_start(cpu); + + do { + if (cpu->accel->dirty) { + ret =3D mshv_arch_put_registers(cpu); + if (ret) { + error_report("Failed to put registers after init: %s", + strerror(-ret)); + ret =3D -1; + break; + } + cpu->accel->dirty =3D false; + } + + ret =3D mshv_run_vcpu(mshv_state->vm, cpu, &mshv_msg, &exit_reason= ); + if (ret < 0) { + error_report("Failed to run on vcpu %d", cpu->cpu_index); + abort(); + } + + switch (exit_reason) { + case MshvVmExitIgnore: + break; + default: + ret =3D EXCP_INTERRUPT; + break; + } + } while (ret =3D=3D 0); + + cpu_exec_end(cpu); + bql_lock(); + + if (ret < 0) { + cpu_dump_state(cpu, stderr, CPU_DUMP_CODE); + vm_stop(RUN_STATE_INTERNAL_ERROR); + } + + return ret; +} + +static void *mshv_vcpu_thread(void *arg) +{ + CPUState *cpu =3D arg; + int ret; + + rcu_register_thread(); + + bql_lock(); + qemu_thread_get_self(cpu->thread); + cpu->thread_id =3D qemu_get_thread_id(); + current_cpu =3D cpu; + ret =3D mshv_init_vcpu(cpu); + if (ret < 0) { + error_report("Failed to init vcpu %d", cpu->cpu_index); + goto cleanup; + } + + /* signal CPU creation */ + cpu_thread_signal_created(cpu); + qemu_guest_random_seed_thread_part2(cpu->random_seed); + + do { + qemu_process_cpu_events(cpu); + if (cpu_can_run(cpu)) { + mshv_cpu_exec(cpu); + } + } while (!cpu->unplug || cpu_can_run(cpu)); + + mshv_destroy_vcpu(cpu); +cleanup: + cpu_thread_signal_destroyed(cpu); + bql_unlock(); + rcu_unregister_thread(); + return NULL; +} + static void mshv_start_vcpu_thread(CPUState *cpu) { - error_report("unimplemented"); - abort(); + char thread_name[VCPU_THREAD_NAME_SIZE]; + + cpu->thread =3D g_malloc0(sizeof(QemuThread)); + cpu->halt_cond =3D g_malloc0(sizeof(QemuCond)); + + qemu_cond_init(cpu->halt_cond); + + trace_mshv_start_vcpu_thread(thread_name, cpu->cpu_index); + qemu_thread_create(cpu->thread, thread_name, mshv_vcpu_thread, cpu, + QEMU_THREAD_JOINABLE); +} + +static void do_mshv_cpu_synchronize_post_init(CPUState *cpu, + run_on_cpu_data arg) +{ + int ret =3D mshv_arch_put_registers(cpu); + if (ret < 0) { + error_report("Failed to put registers after init: %s", strerror(-r= et)); + abort(); + } + + cpu->accel->dirty =3D false; } =20 static void mshv_cpu_synchronize_post_init(CPUState *cpu) { - error_report("unimplemented"); - abort(); + run_on_cpu(cpu, do_mshv_cpu_synchronize_post_init, RUN_ON_CPU_NULL); } =20 static void mshv_cpu_synchronize_post_reset(CPUState *cpu) { - error_report("unimplemented"); - abort(); + int ret =3D mshv_arch_put_registers(cpu); + if (ret) { + error_report("Failed to put registers after reset: %s", + strerror(-ret)); + cpu_dump_state(cpu, stderr, CPU_DUMP_CODE); + vm_stop(RUN_STATE_INTERNAL_ERROR); + } + cpu->accel->dirty =3D false; +} + +static void do_mshv_cpu_synchronize_pre_loadvm(CPUState *cpu, + run_on_cpu_data arg) +{ + cpu->accel->dirty =3D true; } =20 static void mshv_cpu_synchronize_pre_loadvm(CPUState *cpu) { - error_report("unimplemented"); - abort(); + run_on_cpu(cpu, do_mshv_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL); +} + +static void do_mshv_cpu_synchronize(CPUState *cpu, run_on_cpu_data arg) +{ + if (!cpu->accel->dirty) { + int ret =3D mshv_load_regs(cpu); + if (ret < 0) { + error_report("Failed to load registers for vcpu %d", + cpu->cpu_index); + + cpu_dump_state(cpu, stderr, CPU_DUMP_CODE); + vm_stop(RUN_STATE_INTERNAL_ERROR); + } + + cpu->accel->dirty =3D true; + } } =20 static void mshv_cpu_synchronize(CPUState *cpu) { - error_report("unimplemented"); - abort(); + if (!cpu->accel->dirty) { + run_on_cpu(cpu, do_mshv_cpu_synchronize, RUN_ON_CPU_NULL); + } } =20 static bool mshv_cpus_are_resettable(void) { - error_report("unimplemented"); - abort(); + return false; } =20 static void mshv_accel_class_init(ObjectClass *oc, const void *data) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index de0c26bc6c6..02d71ebc14a 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -22,15 +22,78 @@ #include "hw/hyperv/hvgdk_mini.h" #include "hw/hyperv/hvhdk_mini.h" =20 +#include "cpu.h" +#include "emulate/x86_decode.h" +#include "emulate/x86_emu.h" +#include "emulate/x86_flags.h" + #include "trace-accel_mshv.h" #include "trace.h" =20 +int mshv_store_regs(CPUState *cpu) +{ + error_report("unimplemented"); + abort(); +} + +int mshv_load_regs(CPUState *cpu) +{ + error_report("unimplemented"); + abort(); +} + +int mshv_arch_put_registers(const CPUState *cpu) +{ + error_report("unimplemented"); + abort(); +} + void mshv_arch_amend_proc_features( union hv_partition_synthetic_processor_features *features) { features->access_guest_idle_reg =3D 1; } =20 +int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *e= xit) +{ + error_report("unimplemented"); + abort(); +} + +void mshv_remove_vcpu(int vm_fd, int cpu_fd) +{ + error_report("unimplemented"); + abort(); +} + +int mshv_create_vcpu(int vm_fd, uint8_t vp_index, int *cpu_fd) +{ + error_report("unimplemented"); + abort(); +} + +void mshv_init_mmio_emu(void) +{ + error_report("unimplemented"); + abort(); +} + +void mshv_arch_init_vcpu(CPUState *cpu) +{ + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + + env->emu_mmio_buf =3D g_new(char, 4096); +} + +void mshv_arch_destroy_vcpu(CPUState *cpu) +{ + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + + g_clear_pointer(&env->emu_mmio_buf, g_free); +} + /* * Default Microsoft Hypervisor behavior for unimplemented MSR is to send a * fault to the guest if it tries to access it. It is possible to override diff --git a/accel/mshv/trace-events b/accel/mshv/trace-events index 6130c4abf8a..a4dffeb24a3 100644 --- a/accel/mshv/trace-events +++ b/accel/mshv/trace-events @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: GPL-2.0-or-later =20 +mshv_start_vcpu_thread(const char* thread, uint32_t cpu) "thread=3D%s cpu_= index=3D%d" + mshv_set_memory(bool add, uint64_t gpa, uint64_t size, uint64_t user_addr,= bool readonly, int ret) "add=3D%d gpa=3D0x%" PRIx64 " size=3D0x%" PRIx64 "= user=3D0x%" PRIx64 " readonly=3D%d result=3D%d" mshv_mem_ioeventfd_add(uint64_t addr, uint32_t size, uint32_t data) "addr= =3D0x%" PRIx64 " size=3D%d data=3D0x%x" mshv_mem_ioeventfd_del(uint64_t addr, uint32_t size, uint32_t data) "addr= =3D0x%" PRIx64 " size=3D%d data=3D0x%x" --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996329; cv=none; d=zohomail.com; s=zohoarc; b=Zl4S58qi7cVY60qacw2iHO+JMjkDqaaVLP2eI7R2ymFhU9CgcK7WVXPUCoT5pi3EWzCmRwmomlpAXdPbryDJSaE3IcmPNyIp68FCRTEiDbCwV4cafcFg0w3NvotbpiPZClxrwv7JnUx0mbIy1HjXIdx2S1qhCmZZwn+4DWYY1+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996329; 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=b35OUmPIlkjRw+EK5NvtUyTuytJCRQht6eOVyHoxw6k=; b=Z6kiE9JnAA/axj0OrV5nrDGAs2fH69nuk2PuXBF8Z4o/G4NqJ6A5QADgS+seVixxxSvskKvXEfiBlqc4gX/eqvmi6FIU+z0vgGgLzaQJAa1f1XwOXut8Y0JfAPfceQ2Q8qSsu36k+1+flP9n472+IB3waE+IcujQzMzXZBFzimU= 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 1759996329804524.7888856683538; Thu, 9 Oct 2025 00:52:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQi-0008JB-P9; Thu, 09 Oct 2025 03:51:17 -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 1v6lQh-0008I6-HF for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:15 -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 1v6lQc-0004Pw-Hq for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:13 -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-615--WtnrEZrOOeAWN1SdpzbTg-1; Thu, 09 Oct 2025 03:51:07 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e36686ca1so6611835e9.2 for ; Thu, 09 Oct 2025 00:51:07 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f02a8sm33790239f8f.39.2025.10.09.00.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996269; 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=b35OUmPIlkjRw+EK5NvtUyTuytJCRQht6eOVyHoxw6k=; b=bO4U6/Z1E0TBjKKQfMW9LE1k1zPjeo0Iu+xXc6rujXAL5uptG0885Xm0CKKYPyJGAuQme0 cSAs7JSwBCYqZfBJJdpO16JrHeYUCO/jDU9gKbo3yRPvWLBwqphMm9vYAVcM/nj9jvyw8a 8V1TinsUd76FMFVK4q8XViwAkebgt2Y= X-MC-Unique: -WtnrEZrOOeAWN1SdpzbTg-1 X-Mimecast-MFC-AGG-ID: -WtnrEZrOOeAWN1SdpzbTg_1759996266 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996265; x=1760601065; 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=b35OUmPIlkjRw+EK5NvtUyTuytJCRQht6eOVyHoxw6k=; b=XJEH1iZjy+pAq1db30rQDFoRwuqKHa5sVAbytezK9wAeh8H1tQAdUusX0NKw+OY1+U ZazUFTIDfvpAmczi/Bl5czD6M6yO5B9FS+UlijdCKuYHh+BDRCfL5W4hksAsqrDT4+6p tXCJvdTeYJ4QQDUXFkXMY2DOtkP12RHCn5M2c9gvqM9d6TrUgHX2Pqus4co30gkYKvgz 5ELgH/TKMLb6zGCIlR/mcXdw3G9+Q7Oy8b7hthRlUp2A6VPw701MvjVSGW0XBfurxPnW 9wZJYzU6yFhacn3gNVizluk1locF5FGtZ+xsAi1Wq1pJVAXRIMsUAa+mkMtE9Sfb0gkZ 8Nsw== X-Gm-Message-State: AOJu0YwGrv6h86Zbg1WQDXR5D1lnIhul+IuuWCLwvTF97n2qd6+88j2n btDJHh7SjzvvQfPV2sA6SAwfr+2D27OhZWzc7AhmuhcZ+jaF1DB4gBjFpIZi1euWjp6NQxYB+U9 o+Ygr8eUJ8mSj6rnH8ASY+9tPF8sms70Iy1wTdvO/U9EDxJI0YriWWw+aqvg/Y6wTeWQB/umhMp q53uq43fPS1pafJ3B5kVom+RAZqILts7i2wAMkLSfexrA= X-Gm-Gg: ASbGncv2Fayvqedj/0HM/E4cuBAhi8p+CsvHsRoQurnx5Qp/4clFwKjipFIjrFsgBvd 6AO2ivxRfAWM6U/yOira4tYUnwTvBSZazZws9SUCPuOhs1H+Bbe6IbeyWQNVH9CeBcop7h28aKb 3fbTzJVdXYNWa6BL1cbhAe6SunLqyaQqIHrfryOWSBj+/A2zMbtWYsUCRJGld/leed+fbV5JoK4 wkMispMGZCuqUB2fDILTDq254v9atttHWDEfdkhurCEop/JiCfluJ/OggEGaDEJSbPFWeV2NYjR nIxMgxGvOZWSHB4ITGdC6IhzcSJiBMVDCSk/uvB1pg42BJvDSVEOlLYrnQnkmMxa8X41AUQ46dd CJTPA466r/c1B+9X5uYiUYWodXjd0VhfusDqSYT8acIDqG/Ew X-Received: by 2002:a05:600c:5492:b0:46e:477a:16cc with SMTP id 5b1f17b1804b1-46fa9af84ecmr50381985e9.24.1759996264644; Thu, 09 Oct 2025 00:51:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAvcuJXjN4OaFnvU0BDpMBtHHOzemqxtXXbrzSy/pAfs0RHqZFHrlS13MzzsnxgNxVybLHlA== X-Received: by 2002:a05:600c:5492:b0:46e:477a:16cc with SMTP id 5b1f17b1804b1-46fa9af84ecmr50381745e9.24.1759996264196; Thu, 09 Oct 2025 00:51:04 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 17/35] accel/mshv: Add vCPU signal handling Date: Thu, 9 Oct 2025 09:50:07 +0200 Message-ID: <20251009075026.505715-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996343343116601 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Implement signal handling for MSHV vCPUs to support asynchronous interrupts from the main thread. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-12-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- accel/mshv/mshv-all.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index e02421d79d4..fa1f8f35bdb 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -524,6 +524,35 @@ static int mshv_cpu_exec(CPUState *cpu) return ret; } =20 +/* + * The signal handler is triggered when QEMU's main thread receives a SIG_= IPI + * (SIGUSR1). This signal causes the current CPU thread to be kicked, forc= ing a + * VM exit on the CPU. The VM exit generates an exit reason that breaks th= e loop + * (see mshv_cpu_exec). If the exit is due to a Ctrl+A+x command, the syst= em + * will shut down. For other cases, the system will continue running. + */ +static void sa_ipi_handler(int sig) +{ + /* TODO: call IOCTL to set_immediate_exit, once implemented. */ + + qemu_cpu_kick_self(); +} + +static void init_signal(CPUState *cpu) +{ + /* init cpu signals */ + struct sigaction sigact; + sigset_t set; + + memset(&sigact, 0, sizeof(sigact)); + sigact.sa_handler =3D sa_ipi_handler; + sigaction(SIG_IPI, &sigact, NULL); + + pthread_sigmask(SIG_BLOCK, NULL, &set); + sigdelset(&set, SIG_IPI); + pthread_sigmask(SIG_SETMASK, &set, NULL); +} + static void *mshv_vcpu_thread(void *arg) { CPUState *cpu =3D arg; @@ -540,6 +569,7 @@ static void *mshv_vcpu_thread(void *arg) error_report("Failed to init vcpu %d", cpu->cpu_index); goto cleanup; } + init_signal(cpu); =20 /* signal CPU creation */ cpu_thread_signal_created(cpu); --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996326; cv=none; d=zohomail.com; s=zohoarc; b=NWcEt6jUsvQcMaKSduxAmOWjZxObhDuzfs6IV7SEKuuCEEsa7nbFhp87YA+F/Rq/PmBza+joQGOyFoX/JXTy/QDDQnb1pJMVLbNRQbO6iLdSOMv+LuYswRVLE3SG7inoQAdCoAtdhP/YcCcWI0Dr+W4tnHSCipdr4w4gKLPzZ90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996326; 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=rUFiULUVUzPH0BKks65FyI6vNwb5lhVHtOUe9XrvOsw=; b=HIWk4oZhh9ZXlOq3MMWucXPek/0k8TIhC0+pcVUqqN4jlOBm0pUMJytXUU7/vQsJISGtBhp/K671IA5TcrdboqiexwxWAP1YOBj5j9joxgzD62NCUtEO4ZmVCDZR+1itDCla6UeLF0rUoeXErQ4C8seRkMprnNjmD4g1O1bXBzs= 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 1759996326400384.95557716763767; Thu, 9 Oct 2025 00:52:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQk-0008KL-AY; Thu, 09 Oct 2025 03:51:18 -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 1v6lQi-0008Im-5G for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:16 -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 1v6lQe-0004QG-Rj for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:15 -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-277-lqbaUwSDOP2jKGhIorblWw-1; Thu, 09 Oct 2025 03:51:09 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46b303f6c9cso4328605e9.2 for ; Thu, 09 Oct 2025 00:51:09 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fab633cdasm30515265e9.9.2025.10.09.00.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996271; 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=rUFiULUVUzPH0BKks65FyI6vNwb5lhVHtOUe9XrvOsw=; b=MxkeYlvPktbiKY0jlexyzuhvMmUKk69WUOMcnQtlIN9b05eot3X+RUwWHfYz6UpZm+4QS/ e4zcyYXi5vIOZPBsZHuV27ZGSOtYJDbckB5gf1j/pqDLAK+RcHlJg7SZgQNopGbUjUGx0l tXbKoFPICwyIIuNP1czrUzf9LUKWYY4= X-MC-Unique: lqbaUwSDOP2jKGhIorblWw-1 X-Mimecast-MFC-AGG-ID: lqbaUwSDOP2jKGhIorblWw_1759996268 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996268; x=1760601068; 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=rUFiULUVUzPH0BKks65FyI6vNwb5lhVHtOUe9XrvOsw=; b=ppEF7SaBzvtPJp5UmRnnnHtTrIXtTpcsBC1EWzTidfBiCUywYIRcwqqpxNDJDsqegw pyIyjry4B+AHBg7wRI/ed2HVQP9EBmGZa4Jcgbs409zgj+RoSzwCYxe9KTtgvIrxM5tA +xXfhDoyOrgTBdfh1GxSWFs/p/xnNTamaS+YtO5z3mapgBuV8Vjy8hwViE6H8xCQc7QE ov3P67NqqcYKSlhBuj1oreKtxNnuODBvHLzNWOR2Kw+Rq/V53PXK7uXH4tnzKvrdI5bH B9Kd7O03lUHAIgYQ6hBsyxtjyImaB3vWnUR6ISa9E6r8j4iKoxC6SNH1GBnJoAorOepn 0F5Q== X-Gm-Message-State: AOJu0YxbngIuQLYGd3fi5eQ0seLE1/8IjQSKu5snxCs+Jv/WEUuQ2d8u tYTIn2JHJ8hHyC2tQTuDmMXsXp5sj4FQD4kbwjpTwS1rWOAtExu5J+YiSIQLHq5N605uJNQ/k7v WvSyVqRkN5w7OQzWmi5/mYChKZ4Kgu0xh2Z4bSH/gzLBoUdxBKLZG7Z/Qff7gFKiyMu4Hkm32lH iEzH1DUgwF5o4mGouxqWPC2ryfOlB+6gWar+MRtfzH2xU= X-Gm-Gg: ASbGncuKC68bXyy/ExRp6B/P2QoJQU7fxFXD4oNDyC4shKrwLF22Zy0sixell8O1dh9 3SdLhz+iIxzWVKdX9n+po76Q1WGlyR0gPPV3fgFOksplZc1RPmOEWN10zmJ1x4nPkNOaGWUAYia VUP/qnUB1NMlT71ZbTztjaiQ8RDaEOF7Lng/gsP8V28Ha8bk18YJVZbxGlxHx0AkEPQBKP9Bq9C q8UDfiQUZv4of3cooWhFObb0e0gob0cxs2Mloe/v2EloU+OmfLvP38AP4eXXB2vdxKXU816F9ZN JHIjt2r4X3RjRzv77aSA0j3y1LoH0vYMXsU97GLbdNxqHXxRl69QYGocZPz6l43Ya3iAv6JvKmm 3LQVLWxPGB6CG/FAWnX7FDyeh5kD0QjWOfe3lUmhEDusfc9bw X-Received: by 2002:a05:600c:3b2a:b0:461:8bdb:e8 with SMTP id 5b1f17b1804b1-46fa9b06c50mr50772595e9.30.1759996267940; Thu, 09 Oct 2025 00:51:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcmxZ0RQ3ZSpR7X2jz0a7Uc3cD7JtYWf8Nr2Y04yPz0GR7R04c0TGJprT5HfxkzfiNxk1kBg== X-Received: by 2002:a05:600c:3b2a:b0:461:8bdb:e8 with SMTP id 5b1f17b1804b1-46fa9b06c50mr50772305e9.30.1759996267492; Thu, 09 Oct 2025 00:51:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 18/35] target/i386/mshv: Add CPU create and remove logic Date: Thu, 9 Oct 2025 09:50:08 +0200 Message-ID: <20251009075026.505715-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996328254154100 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Implement MSHV-specific hooks for vCPU creation and teardown in the i386 target. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-13-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- target/i386/mshv/mshv-cpu.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 02d71ebc14a..5069ab7a22f 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -30,6 +30,8 @@ #include "trace-accel_mshv.h" #include "trace.h" =20 +#include + int mshv_store_regs(CPUState *cpu) { error_report("unimplemented"); @@ -62,20 +64,29 @@ int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message = *msg, MshvVmExit *exit) =20 void mshv_remove_vcpu(int vm_fd, int cpu_fd) { - error_report("unimplemented"); - abort(); + close(cpu_fd); } =20 + int mshv_create_vcpu(int vm_fd, uint8_t vp_index, int *cpu_fd) { - error_report("unimplemented"); - abort(); + int ret; + struct mshv_create_vp vp_arg =3D { + .vp_index =3D vp_index, + }; + ret =3D ioctl(vm_fd, MSHV_CREATE_VP, &vp_arg); + if (ret < 0) { + error_report("failed to create mshv vcpu: %s", strerror(errno)); + return -1; + } + + *cpu_fd =3D ret; + + return 0; } =20 void mshv_init_mmio_emu(void) { - error_report("unimplemented"); - abort(); } =20 void mshv_arch_init_vcpu(CPUState *cpu) --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996431; cv=none; d=zohomail.com; s=zohoarc; b=F9oDc9cLckD0orbQjoA1tzV4u72oKRmGztWxdxf/V8t3Z9GjlRfCIGiLRfXC1LmrZMcS6MHrBAQVA9M8dy3rEOCzNK6kA9XnFS1EjsJ53qbTX/FBVf5f9ABxALnlsGPdcGMSn+SJX4Dra6mawK1guo10nIMAfxqptJPVQ3tZt8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996431; 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=011a463v1dGyOKFiUiQNsEioHBlxgPsH4SJpYihX+aE=; b=MwEdOsn2HgOe5SG1D8/g7ug/fyRenpQc0mC9OeykvnczX3BtaVSbvHyJM2ICQGPaDr6cXolKn9LRF+aGS7tzgciZLaiIFvvwL+bQFlA7ThTjV7wGCxluJKggTvrqTJuBI4oJvu4uPJguo4gJ8k2ZRSCzk4A79jv+P/bxzO7wZ04= 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 1759996431017814.4100503628503; Thu, 9 Oct 2025 00:53:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lR4-0008WU-M5; Thu, 09 Oct 2025 03:51:38 -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 1v6lR1-0008VT-7w for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:35 -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 1v6lQt-0004R4-VE for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51: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-623-kuK76CgJMcGP2fzHODBE0g-1; Thu, 09 Oct 2025 03:51:15 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3ee13e43dd9so433447f8f.1 for ; Thu, 09 Oct 2025 00:51:14 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fa9c07992sm82926675e9.5.2025.10.09.00.51.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996281; 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=011a463v1dGyOKFiUiQNsEioHBlxgPsH4SJpYihX+aE=; b=FP272V5wBGyYUaMTHUA569UQJ4D8Zhr6Y3Wu1ri1IqnsM6qkT3KugQT2yySlUONhOU7fTt G+KmdYzDyAlMIS7oPt0AIlJwf8cfc2udxs7px2Qx+zdSYQyzOs51ok/YozO5a0kCBjILt3 A/c442PhwLeW8kfh16D7uww7KQ2L86E= X-MC-Unique: kuK76CgJMcGP2fzHODBE0g-1 X-Mimecast-MFC-AGG-ID: kuK76CgJMcGP2fzHODBE0g_1759996271 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996270; x=1760601070; 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=011a463v1dGyOKFiUiQNsEioHBlxgPsH4SJpYihX+aE=; b=C58sz5brJQ7ya8jhYqyLthzLyEWTm6NMoPzPxTPcD7/MJRMMTNQklBZwFphQaonMR2 LUHn314DRvqtc5f08jEZsT0WSuX/bhgneYDYHXpi3o4bEJ+rg47LgDsbMkTe6RYMB06j hOCltwlsIDJNhKfN1DSN8svKIvXvtZ7aKF6f5V/d57PF4HreXJp9pjL1B/nSp0J8eoCt mVxhBreIn8Dre7S8hcmJmwhrPWk7a48cXMQZXqGVxA6brcU9afFiJs0FMjmeqKCrmL9W 6pA13HZxMSQOb+OqcwRHhsGaot6hpnjx7By5uRCpEQwOZ59/uQ2tjR/venNO2X7iW3iR u23A== X-Gm-Message-State: AOJu0YxTZryvl18ntE+iBR9jqE+sAFc8vIGpOutJVfXkjOmqjZFk2EWM zg6C4GWTyk2YKG0m7LE+8d0KPFjNLcdMj3MNkF/jNzV17D2BdgMIKYLsDb7pGDbXom/Tu52+2sc R94baGDOpdvEntORiw8iJyCemcXHDqaiQxqvJge8klSNvilZqMYWgwxHZvG2wj+phpsKohNyCQc H+LpCgxRKQ3lqsTXG6WUqq87zbb64B3tAr7HGt3TuoYy0= X-Gm-Gg: ASbGncvYsC3m5pLFJC7FkYlJSw53p6invLzYi0lsYYxzOP92kMaW+jJ1vXAlz4nqvge wXBNuYx5ucLn7ygPJ/6MW9mc7TCVX0YwYbV5kMm/jz7z5LLhxnyCmWWDO1iEdB8Zc8cd95SF8v3 EYWeju+5GawU4ry8f9pVPM10zU8RJqqPllpE4roIlCTPh101WBs8y7svMoZy+Vx63RYPFjDEya3 SF/ABEz3Eo/NEZJEcc927wYWj2cDS7R6m14LnAw3QcKI4jD5xgkOo6Z/Bw/NxiGKQ2cKgmizrIP N5oFD5yCyJDECM2Wkc7RFTgKwJXSY/eTJ/7Vl8LS2E2reYR+uuj9J1J488w4KXXEwAABq4nv4QN dK3f09ZuY7KH3tC3H8mUhYz0LZY9c7/LPvCNf5TouIktf+z5k X-Received: by 2002:a05:6000:2289:b0:3ec:dd2f:eeb8 with SMTP id ffacd0b85a97d-4266e8e6e5bmr3986789f8f.62.1759996269836; Thu, 09 Oct 2025 00:51:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiVOo4Adpp90D8E3NCR16dXXLIfwzrHxaEqIGYPIOhHQ3slyw776nG3DTi9lHnbCxfH2RSVQ== X-Received: by 2002:a05:6000:2289:b0:3ec:dd2f:eeb8 with SMTP id ffacd0b85a97d-4266e8e6e5bmr3986764f8f.62.1759996269330; Thu, 09 Oct 2025 00:51:09 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 19/35] target/i386/mshv: Implement mshv_store_regs() Date: Thu, 9 Oct 2025 09:50:09 +0200 Message-ID: <20251009075026.505715-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996433066154100 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Add support for writing general-purpose registers to MSHV vCPUs during initialization or migration using the MSHV register interface. A generic set_register call is introduced to abstract the HV call over the various register types. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-14-magnuskulke@linux.m= icrosoft.com [mshv.h/mshv_int.h split. - Paolo] Signed-off-by: Paolo Bonzini --- include/system/mshv.h | 1 + include/system/mshv_int.h | 2 + target/i386/mshv/mshv-cpu.c | 116 +++++++++++++++++++++++++++++++++++- 3 files changed, 117 insertions(+), 2 deletions(-) diff --git a/include/system/mshv.h b/include/system/mshv.h index bbc42f4dc3a..8b1fc20c80d 100644 --- a/include/system/mshv.h +++ b/include/system/mshv.h @@ -18,6 +18,7 @@ #include "qemu/accel.h" #include "hw/hyperv/hyperv-proto.h" #include "hw/hyperv/hvhdk.h" +#include "hw/hyperv/hvgdk_mini.h" #include "qapi/qapi-types-common.h" #include "system/memory.h" #include "accel/accel-ops.h" diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index fb80f69772b..731841af929 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -61,6 +61,8 @@ void mshv_remove_vcpu(int vm_fd, int cpu_fd); int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *e= xit); int mshv_load_regs(CPUState *cpu); int mshv_store_regs(CPUState *cpu); +int mshv_set_generic_regs(const CPUState *cpu, const hv_register_assoc *as= socs, + size_t n_regs); int mshv_arch_put_registers(const CPUState *cpu); void mshv_arch_init_vcpu(CPUState *cpu); void mshv_arch_destroy_vcpu(CPUState *cpu); diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 5069ab7a22f..9ead03ca2d8 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -32,12 +32,124 @@ =20 #include =20 +static enum hv_register_name STANDARD_REGISTER_NAMES[18] =3D { + HV_X64_REGISTER_RAX, + HV_X64_REGISTER_RBX, + HV_X64_REGISTER_RCX, + HV_X64_REGISTER_RDX, + HV_X64_REGISTER_RSI, + HV_X64_REGISTER_RDI, + HV_X64_REGISTER_RSP, + HV_X64_REGISTER_RBP, + HV_X64_REGISTER_R8, + HV_X64_REGISTER_R9, + HV_X64_REGISTER_R10, + HV_X64_REGISTER_R11, + HV_X64_REGISTER_R12, + HV_X64_REGISTER_R13, + HV_X64_REGISTER_R14, + HV_X64_REGISTER_R15, + HV_X64_REGISTER_RIP, + HV_X64_REGISTER_RFLAGS, +}; + +int mshv_set_generic_regs(const CPUState *cpu, const hv_register_assoc *as= socs, + size_t n_regs) +{ + int cpu_fd =3D mshv_vcpufd(cpu); + int vp_index =3D cpu->cpu_index; + size_t in_sz, assocs_sz; + hv_input_set_vp_registers *in; + struct mshv_root_hvcall args =3D {0}; + int ret; + + /* find out the size of the struct w/ a flexible array at the tail */ + assocs_sz =3D n_regs * sizeof(hv_register_assoc); + in_sz =3D sizeof(hv_input_set_vp_registers) + assocs_sz; + + /* fill the input struct */ + in =3D g_malloc0(in_sz); + in->vp_index =3D vp_index; + memcpy(in->elements, assocs, assocs_sz); + + /* create the hvcall envelope */ + args.code =3D HVCALL_SET_VP_REGISTERS; + args.in_sz =3D in_sz; + args.in_ptr =3D (uint64_t) in; + args.reps =3D (uint16_t) n_regs; + + /* perform the call */ + ret =3D mshv_hvcall(cpu_fd, &args); + g_free(in); + if (ret < 0) { + error_report("Failed to set registers"); + return -1; + } + + /* assert we set all registers */ + if (args.reps !=3D n_regs) { + error_report("Failed to set registers: expected %zu elements" + ", got %u", n_regs, args.reps); + return -1; + } + + return 0; +} + +static int set_standard_regs(const CPUState *cpu) +{ + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + hv_register_assoc assocs[ARRAY_SIZE(STANDARD_REGISTER_NAMES)]; + int ret; + size_t n_regs =3D ARRAY_SIZE(STANDARD_REGISTER_NAMES); + + /* set names */ + for (size_t i =3D 0; i < ARRAY_SIZE(STANDARD_REGISTER_NAMES); i++) { + assocs[i].name =3D STANDARD_REGISTER_NAMES[i]; + } + assocs[0].value.reg64 =3D env->regs[R_EAX]; + assocs[1].value.reg64 =3D env->regs[R_EBX]; + assocs[2].value.reg64 =3D env->regs[R_ECX]; + assocs[3].value.reg64 =3D env->regs[R_EDX]; + assocs[4].value.reg64 =3D env->regs[R_ESI]; + assocs[5].value.reg64 =3D env->regs[R_EDI]; + assocs[6].value.reg64 =3D env->regs[R_ESP]; + assocs[7].value.reg64 =3D env->regs[R_EBP]; + assocs[8].value.reg64 =3D env->regs[R_R8]; + assocs[9].value.reg64 =3D env->regs[R_R9]; + assocs[10].value.reg64 =3D env->regs[R_R10]; + assocs[11].value.reg64 =3D env->regs[R_R11]; + assocs[12].value.reg64 =3D env->regs[R_R12]; + assocs[13].value.reg64 =3D env->regs[R_R13]; + assocs[14].value.reg64 =3D env->regs[R_R14]; + assocs[15].value.reg64 =3D env->regs[R_R15]; + assocs[16].value.reg64 =3D env->eip; + lflags_to_rflags(env); + assocs[17].value.reg64 =3D env->eflags; + + ret =3D mshv_set_generic_regs(cpu, assocs, n_regs); + if (ret < 0) { + error_report("failed to set standard registers"); + return -errno; + } + return 0; +} + int mshv_store_regs(CPUState *cpu) { - error_report("unimplemented"); - abort(); + int ret; + + ret =3D set_standard_regs(cpu); + if (ret < 0) { + error_report("Failed to store standard registers"); + return -1; + } + + return 0; } =20 + int mshv_load_regs(CPUState *cpu) { error_report("unimplemented"); --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996348; cv=none; d=zohomail.com; s=zohoarc; b=g+NS+8kIcVbFMSwsN5pvUcjsJUoyu6qb2EXSBSFL94/UNdIe0M7wX0XdBcmkmHLzu7E2uuoeIdK4Bgun3tAIZKmsb7FnXyP9Ts3/sDgQXbOwGH6+IMhQypbPJTnlxxNUV5uad9PDbxgo9tJrDnVosn0TUhYmSi4VTHOeeBI6l6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996348; 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=hORXZXs3nBLx9w7TUsCj+3ttCe8oEF72vZas/IkNe60=; b=AiPNSL+j9RAAHz+ksKM6zWFguaCedj8nfEI/axE1QQMHNVovn6EUQspGL+bqJ60wEgIndDC51cY6kaXPEDSCtoBHxj/If0u9HBaTYQnYpgnemLfI2cpbbwMQ3hILuU0LI/yduOARkdmGkHnI3cKh3LySz0qLjjtyaVh4wHoIFXw= 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 1759996348678389.081281464997; Thu, 9 Oct 2025 00:52:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lR8-00006j-T6; Thu, 09 Oct 2025 03:51:42 -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 1v6lR1-0008Vm-MD for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:35 -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 1v6lQm-0004QX-M4 for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:35 -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-29-jstkfHBUPOWVJv4eAUGAQg-1; Thu, 09 Oct 2025 03:51:13 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e3a049abaso4021155e9.0 for ; Thu, 09 Oct 2025 00:51:13 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46faf1841aasm32576065e9.18.2025.10.09.00.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996275; 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=hORXZXs3nBLx9w7TUsCj+3ttCe8oEF72vZas/IkNe60=; b=FBLzwXV3Txn4xf9vqQ7m/u9nCC2xgNNqzARwiP2qbFAAkbV1QDJJV7jPXs/sYRcEKXSDFw nCcJzG7dVS3pLxLpk3K5VGcFSXvD/MA/iIS/A0TSgsNsIjPwvO9BKLun4L5501PzZ/lQd9 GGe/H3BFjlw3uQcq3hTKhhkcsbwr17k= X-MC-Unique: jstkfHBUPOWVJv4eAUGAQg-1 X-Mimecast-MFC-AGG-ID: jstkfHBUPOWVJv4eAUGAQg_1759996272 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996271; x=1760601071; 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=hORXZXs3nBLx9w7TUsCj+3ttCe8oEF72vZas/IkNe60=; b=QeUDqXViwJtcsf1+1LiAmQO4Y0XYX9rOO2QFPOPg8ga6WIovL6SvP/23Qqu4FxQEtj /Yvz1iYkOOfUFJjE1OdkozJMcxs4unTXUoT7pPhxdYWWELiyTemS18QPaIefyrMY8fmo eXxdi5eoqf3/dsIluwcgYJELt8pCM4kcXKtV1PLpzvtODGSICrGVmd5Kug6OxU1/ub1j LIpzezr5Ym5u/CKrzan1lN9Im0QzJXFKvJqokx8WjrSBotTRXUJShFYAW2mGVQ0aA4pM /cfhXQ5x6NaaaAQD4NSTG1Gy7CP00yMWjsj8rKyZVa9XhQI/1c+FzToJ/lgHTLknAaTi z6sw== X-Gm-Message-State: AOJu0Yw6u+xCBPDsSW+2+w5G00CMGyod+WIOh53Q06kBuIGmL59hbS5K nk9rQJcftdmUPGeWipq/QmbkpI24HvQvnJPJ19lcWhINOcmtMi5ziFvGJf7Vzs4NNbwV+IC+kcB TGflo0O5dueyHZZ/42740kw6Ql6RSXFHvHXQOXZYqjnNVmm2ceO67PD45l+nqQR+WCUqPkO84nu DEPnCeSedpK8bU6IehUREdBxjeCbCnv0EHv767kJIGpyI= X-Gm-Gg: ASbGncsnKb5EGJQxsSa3vwH9FFm/MwPyrB2tVc+hlDvaLrJh+YMoQTNMcYd32sEA9sl TB2dkPgp83KQcqjVZcm2oQKzgfmo+1lzFACORbPgA8aB3MX4WWrLxvBKQVzKqAx2vAi0fjxWOee +0+6dTWg7IYXgoZp0l3+8wdHIg523WNJqjvdCUwB6tiaGMe/8H/M/QLR59F45zm0XOeKS/1t30g T0e56BkQLSW1f0Veb0Iz2RpRueILYka3iwyW5TR2EjpdDFUsUfrOhC7ttM8QOVWuFYxY70hGHnI R4+nXR4SoOE9upDt+lDawDfoXFOU7SD1Q1ehQpdOSjASurOX356aKIDd7fFI7+Sm3V+0qGKeGX2 kLp+4TeYz+Lqmw4jAG8FeZxQrLHTx6oylXgX7Jy0r2rUs4WJT X-Received: by 2002:a05:600c:6388:b0:46e:1a07:7bd5 with SMTP id 5b1f17b1804b1-46fa9b0797cmr44423265e9.29.1759996270996; Thu, 09 Oct 2025 00:51:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFnB/z1c3Q3wgqAXdsU2+WjHB7mMZ9qP/aVL6lqbAqDwyhA/Y9egxDQCtC4gaExVjQunTrRfA== X-Received: by 2002:a05:600c:6388:b0:46e:1a07:7bd5 with SMTP id 5b1f17b1804b1-46fa9b0797cmr44423085e9.29.1759996270483; Thu, 09 Oct 2025 00:51:10 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 20/35] target/i386/mshv: Implement mshv_get_standard_regs() Date: Thu, 9 Oct 2025 09:50:10 +0200 Message-ID: <20251009075026.505715-21-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1759996350331154100 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Fetch standard register state from MSHV vCPUs to support debugging, migration, and other introspection features in QEMU. Fetch standard register state from a MHSV vCPU's. A generic get_regs() function and a mapper to map the different register representations are introduced. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-15-magnuskulke@linux.m= icrosoft.com [mshv.h/mshv_int.h split. - Paolo] Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 1 + target/i386/mshv/mshv-cpu.c | 116 +++++++++++++++++++++++++++++++++++- 2 files changed, 115 insertions(+), 2 deletions(-) diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 731841af929..b0a79296ad9 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -58,6 +58,7 @@ typedef enum MshvVmExit { void mshv_init_mmio_emu(void); int mshv_create_vcpu(int vm_fd, uint8_t vp_index, int *cpu_fd); void mshv_remove_vcpu(int vm_fd, int cpu_fd); +int mshv_get_standard_regs(CPUState *cpu); int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *e= xit); int mshv_load_regs(CPUState *cpu); int mshv_store_regs(CPUState *cpu); diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 9ead03ca2d8..4e3eee113bb 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -96,6 +96,66 @@ int mshv_set_generic_regs(const CPUState *cpu, const hv_= register_assoc *assocs, return 0; } =20 +static int get_generic_regs(CPUState *cpu, hv_register_assoc *assocs, + size_t n_regs) +{ + int cpu_fd =3D mshv_vcpufd(cpu); + int vp_index =3D cpu->cpu_index; + hv_input_get_vp_registers *in; + hv_register_value *values; + size_t in_sz, names_sz, values_sz; + int i, ret; + struct mshv_root_hvcall args =3D {0}; + + /* find out the size of the struct w/ a flexible array at the tail */ + names_sz =3D n_regs * sizeof(hv_register_name); + in_sz =3D sizeof(hv_input_get_vp_registers) + names_sz; + + /* fill the input struct */ + in =3D g_malloc0(in_sz); + in->vp_index =3D vp_index; + for (i =3D 0; i < n_regs; i++) { + in->names[i] =3D assocs[i].name; + } + + /* allocate value output buffer */ + values_sz =3D n_regs * sizeof(union hv_register_value); + values =3D g_malloc0(values_sz); + + /* create the hvcall envelope */ + args.code =3D HVCALL_GET_VP_REGISTERS; + args.in_sz =3D in_sz; + args.in_ptr =3D (uint64_t) in; + args.out_sz =3D values_sz; + args.out_ptr =3D (uint64_t) values; + args.reps =3D (uint16_t) n_regs; + + /* perform the call */ + ret =3D mshv_hvcall(cpu_fd, &args); + g_free(in); + if (ret < 0) { + g_free(values); + error_report("Failed to retrieve registers"); + return -1; + } + + /* assert we got all registers */ + if (args.reps !=3D n_regs) { + g_free(values); + error_report("Failed to retrieve registers: expected %zu elements" + ", got %u", n_regs, args.reps); + return -1; + } + + /* copy values into assoc */ + for (i =3D 0; i < n_regs; i++) { + assocs[i].value =3D values[i]; + } + g_free(values); + + return 0; +} + static int set_standard_regs(const CPUState *cpu) { X86CPU *x86cpu =3D X86_CPU(cpu); @@ -149,11 +209,63 @@ int mshv_store_regs(CPUState *cpu) return 0; } =20 +static void populate_standard_regs(const hv_register_assoc *assocs, + CPUX86State *env) +{ + env->regs[R_EAX] =3D assocs[0].value.reg64; + env->regs[R_EBX] =3D assocs[1].value.reg64; + env->regs[R_ECX] =3D assocs[2].value.reg64; + env->regs[R_EDX] =3D assocs[3].value.reg64; + env->regs[R_ESI] =3D assocs[4].value.reg64; + env->regs[R_EDI] =3D assocs[5].value.reg64; + env->regs[R_ESP] =3D assocs[6].value.reg64; + env->regs[R_EBP] =3D assocs[7].value.reg64; + env->regs[R_R8] =3D assocs[8].value.reg64; + env->regs[R_R9] =3D assocs[9].value.reg64; + env->regs[R_R10] =3D assocs[10].value.reg64; + env->regs[R_R11] =3D assocs[11].value.reg64; + env->regs[R_R12] =3D assocs[12].value.reg64; + env->regs[R_R13] =3D assocs[13].value.reg64; + env->regs[R_R14] =3D assocs[14].value.reg64; + env->regs[R_R15] =3D assocs[15].value.reg64; + + env->eip =3D assocs[16].value.reg64; + env->eflags =3D assocs[17].value.reg64; + rflags_to_lflags(env); +} + +int mshv_get_standard_regs(CPUState *cpu) +{ + struct hv_register_assoc assocs[ARRAY_SIZE(STANDARD_REGISTER_NAMES)]; + int ret; + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + size_t n_regs =3D ARRAY_SIZE(STANDARD_REGISTER_NAMES); + + for (size_t i =3D 0; i < n_regs; i++) { + assocs[i].name =3D STANDARD_REGISTER_NAMES[i]; + } + ret =3D get_generic_regs(cpu, assocs, n_regs); + if (ret < 0) { + error_report("failed to get standard registers"); + return -1; + } + + populate_standard_regs(assocs, env); + return 0; +} =20 int mshv_load_regs(CPUState *cpu) { - error_report("unimplemented"); - abort(); + int ret; + + ret =3D mshv_get_standard_regs(cpu); + if (ret < 0) { + error_report("Failed to load standard registers"); + return -1; + } + + return 0; } =20 int mshv_arch_put_registers(const CPUState *cpu) --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996550; cv=none; d=zohomail.com; s=zohoarc; b=MhlaowSRHEctPAzwb+ekX58Ul/Zw/EHuPBxZZeyWBMlQ0gMbAcWynOzGGfCtFYC2aaSxFRyvumF2kE34rC4K9GcfDUXQ9/VkHVqtJX74x2ieMJctFfrMsB13vLw94nw/i2HT7aRRxxzdOg2U0Ttvtpj475eL5uxVnflO/U44Umc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996550; 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=ybg7xeLuE7xqCSx05hiU1cBvGy3lci2b+snhEgiPC5w=; b=X+hK/YuxeLOuHvQeaDDz5jIhI1BxUwYPiKWi7/zMU1Ul86zked+lm3q4s+WCUIwV1GY9hPADuNnEVDUfX++HCiCJ9/7GfKUu2tpKALKO3VfuuuzzLeX/D0+SYtyRneAbLWYabnVBbsT0XRW8JaU1mFT8nThQU+0A3Vt8mi31CBw= 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 1759996550189890.4904169030713; Thu, 9 Oct 2025 00:55:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQt-0008T0-Uc; Thu, 09 Oct 2025 03:51:28 -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 1v6lQr-0008Sn-3w for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:25 -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 1v6lQl-0004Qr-6D for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:24 -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-609-a-H9N710Na-zYiBnhbFAGw-1; Thu, 09 Oct 2025 03:51:16 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e4c8fa2b1so2946735e9.0 for ; Thu, 09 Oct 2025 00:51:16 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6bb2sm32514984f8f.10.2025.10.09.00.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996277; 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=ybg7xeLuE7xqCSx05hiU1cBvGy3lci2b+snhEgiPC5w=; b=V9PhQoO6vEon4UXaCRWI3skbGPmwxBaQ4E6rMIGxo5wvi0yZesvDBjRGnSpU8AbH+E8VJq bITVcvpbFA5pEHtaBvmnNEI0QmMYm930mHbDZiz9gvStpJSFjJjl5p37N7hiecdz3yrlIX cNl8AHTCI2t7qQ+8d0gNlKfp4GSxZM0= X-MC-Unique: a-H9N710Na-zYiBnhbFAGw-1 X-Mimecast-MFC-AGG-ID: a-H9N710Na-zYiBnhbFAGw_1759996275 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996274; x=1760601074; 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=ybg7xeLuE7xqCSx05hiU1cBvGy3lci2b+snhEgiPC5w=; b=XFCrAcx4RD1Zc3SHDB2TyWSCS0Nl76MaSRR199J2TxaKw1AilMQKVITMML36Z6KzHH iK/RH3BBP9zj7UGLXn+ZL63lt0Y+XHnvMv3Kgki198bWLjup1nsGBhlRQZVb3MXm4wNX vv7BaZgKU8b89lW6i8HPl33Jp4qj41Mj8+fOe9sLf9p58XXeG0AAdnJww6Pu4mENbDbH rm5hiYP9uB+gD8ikRFgi9azxbnyc5wNfF0WmfBtIKKbGsLcHbOQ78oBTpeIN7lq/evXW p0175+Q1Y6vzSIDv8R1ccGMemoxJE8X5r47RuyiOfp+R87ukLW+VK/82fvRPnmjbODbe bYFQ== X-Gm-Message-State: AOJu0YwF/uY0P45E+33qIkN2BInmlOP80xfHSjZbGi+ZwKBuCCvoP84o 2DaDEMKfBhdotSoLXn68bb5YJ+BTcLr179EGVLwbk3kHggQBT+T/CMQle3wwBU4G9wicFsh6A49 X0n+dTkoe6JJvTQYI7tFelKhjnaYcvrDQae6WKzArTsJ/DntsWO26MyoNg4z4poK6eLXhCJAXyL o3wCnom2CxqCN3NzW6M7lMI9v6+8yk3wnsUXyJ2rsegm8= X-Gm-Gg: ASbGnct3RLqk8wCdodTnFcuHFKiBCGy7be+2xsj5h1rznh9vWOauFhk2xIv88qVsaid eQyouLP5g0IFKh330ReBwqT7ScJTueAnKbNo6cJy5AipjpAnQ1rcuXA24/8j3pTVrNtlUusAMNK lOBQ/xKG7SM4DuiaUfbM38bLWCYMunMryl1nk984ahNPo5/om2vb+UoAnupo9VNIiSmAKM7OhOD aAlTPqKT1EQZGuAGQ95ACK9LrLi+n99N4qT99yXYTG2bmTFhiFr1TtWEepQfENuFJM9eWzrR1Xm c1YJabHqlJy9PYvMYKzatGVyzdz4UbXFPva7LjIgrAj2IobTLR26nhl5npS36UcsFkELisehaW/ OC5wQekDHjKRna9/iYHNkhM/SLvjU3tb9X5NGY0L1sr7x6y+z X-Received: by 2002:a05:600c:529a:b0:46e:4912:d02a with SMTP id 5b1f17b1804b1-46fa9aef4cbmr41445395e9.23.1759996273980; Thu, 09 Oct 2025 00:51:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQWHFlSbyyhOh/uM+oPcIJ35RkNmWpcnYrefdqO+fMmCvOfGmhIcdQjJAR8RG22VqqLZ2lvw== X-Received: by 2002:a05:600c:529a:b0:46e:4912:d02a with SMTP id 5b1f17b1804b1-46fa9aef4cbmr41445225e9.23.1759996273518; Thu, 09 Oct 2025 00:51:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 21/35] target/i386/mshv: Implement mshv_get_special_regs() Date: Thu, 9 Oct 2025 09:50:11 +0200 Message-ID: <20251009075026.505715-22-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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, 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: 1759996552209154100 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Retrieve special registers (e.g. segment, control, and descriptor table registers) from MSHV vCPUs. Various helper functions to map register state representations between Qemu and MSHV are introduced. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-16-magnuskulke@linux.m= icrosoft.com [mshv.h/mshv_int.h split. - Paolo] Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 1 + target/i386/mshv/mshv-cpu.c | 104 ++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index b0a79296ad9..c6e6e8af307 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -59,6 +59,7 @@ void mshv_init_mmio_emu(void); int mshv_create_vcpu(int vm_fd, uint8_t vp_index, int *cpu_fd); void mshv_remove_vcpu(int vm_fd, int cpu_fd); int mshv_get_standard_regs(CPUState *cpu); +int mshv_get_special_regs(CPUState *cpu); int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *e= xit); int mshv_load_regs(CPUState *cpu); int mshv_store_regs(CPUState *cpu); diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 4e3eee113bb..bc75686f828 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -53,6 +53,26 @@ static enum hv_register_name STANDARD_REGISTER_NAMES[18]= =3D { HV_X64_REGISTER_RFLAGS, }; =20 +static enum hv_register_name SPECIAL_REGISTER_NAMES[17] =3D { + HV_X64_REGISTER_CS, + HV_X64_REGISTER_DS, + HV_X64_REGISTER_ES, + HV_X64_REGISTER_FS, + HV_X64_REGISTER_GS, + HV_X64_REGISTER_SS, + HV_X64_REGISTER_TR, + HV_X64_REGISTER_LDTR, + HV_X64_REGISTER_GDTR, + HV_X64_REGISTER_IDTR, + HV_X64_REGISTER_CR0, + HV_X64_REGISTER_CR2, + HV_X64_REGISTER_CR3, + HV_X64_REGISTER_CR4, + HV_X64_REGISTER_CR8, + HV_X64_REGISTER_EFER, + HV_X64_REGISTER_APIC_BASE, +}; + int mshv_set_generic_regs(const CPUState *cpu, const hv_register_assoc *as= socs, size_t n_regs) { @@ -255,6 +275,84 @@ int mshv_get_standard_regs(CPUState *cpu) return 0; } =20 +static inline void populate_segment_reg(const hv_x64_segment_register *hv_= seg, + SegmentCache *seg) +{ + memset(seg, 0, sizeof(SegmentCache)); + + seg->base =3D hv_seg->base; + seg->limit =3D hv_seg->limit; + seg->selector =3D hv_seg->selector; + + seg->flags =3D (hv_seg->segment_type << DESC_TYPE_SHIFT) + | (hv_seg->present * DESC_P_MASK) + | (hv_seg->descriptor_privilege_level << DESC_DPL_SHIFT) + | (hv_seg->_default << DESC_B_SHIFT) + | (hv_seg->non_system_segment * DESC_S_MASK) + | (hv_seg->_long << DESC_L_SHIFT) + | (hv_seg->granularity * DESC_G_MASK) + | (hv_seg->available * DESC_AVL_MASK); + +} + +static inline void populate_table_reg(const hv_x64_table_register *hv_seg, + SegmentCache *tbl) +{ + memset(tbl, 0, sizeof(SegmentCache)); + + tbl->base =3D hv_seg->base; + tbl->limit =3D hv_seg->limit; +} + +static void populate_special_regs(const hv_register_assoc *assocs, + X86CPU *x86cpu) +{ + CPUX86State *env =3D &x86cpu->env; + + populate_segment_reg(&assocs[0].value.segment, &env->segs[R_CS]); + populate_segment_reg(&assocs[1].value.segment, &env->segs[R_DS]); + populate_segment_reg(&assocs[2].value.segment, &env->segs[R_ES]); + populate_segment_reg(&assocs[3].value.segment, &env->segs[R_FS]); + populate_segment_reg(&assocs[4].value.segment, &env->segs[R_GS]); + populate_segment_reg(&assocs[5].value.segment, &env->segs[R_SS]); + + populate_segment_reg(&assocs[6].value.segment, &env->tr); + populate_segment_reg(&assocs[7].value.segment, &env->ldt); + + populate_table_reg(&assocs[8].value.table, &env->gdt); + populate_table_reg(&assocs[9].value.table, &env->idt); + + env->cr[0] =3D assocs[10].value.reg64; + env->cr[2] =3D assocs[11].value.reg64; + env->cr[3] =3D assocs[12].value.reg64; + env->cr[4] =3D assocs[13].value.reg64; + + cpu_set_apic_tpr(x86cpu->apic_state, assocs[14].value.reg64); + env->efer =3D assocs[15].value.reg64; + cpu_set_apic_base(x86cpu->apic_state, assocs[16].value.reg64); +} + + +int mshv_get_special_regs(CPUState *cpu) +{ + struct hv_register_assoc assocs[ARRAY_SIZE(SPECIAL_REGISTER_NAMES)]; + int ret; + X86CPU *x86cpu =3D X86_CPU(cpu); + size_t n_regs =3D ARRAY_SIZE(SPECIAL_REGISTER_NAMES); + + for (size_t i =3D 0; i < n_regs; i++) { + assocs[i].name =3D SPECIAL_REGISTER_NAMES[i]; + } + ret =3D get_generic_regs(cpu, assocs, n_regs); + if (ret < 0) { + error_report("failed to get special registers"); + return -errno; + } + + populate_special_regs(assocs, x86cpu); + return 0; +} + int mshv_load_regs(CPUState *cpu) { int ret; @@ -265,6 +363,12 @@ int mshv_load_regs(CPUState *cpu) return -1; } =20 + ret =3D mshv_get_special_regs(cpu); + if (ret < 0) { + error_report("Failed to load special registers"); + return -1; + } + return 0; } =20 --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996373; cv=none; d=zohomail.com; s=zohoarc; b=mUYVViZd+TF+m5WGYYV9gvxoGgmftkuHtJuLrl4nwj63QcRfEoCgn0wrV8yL4OBo0T2lf8aLhqhK7EU1ZqFljxMl9EMd6QLPSNgGu6ebW5HUFfD96H8BTup7pwz/YFCkvgDXaj7D1qSTr8Vxc8PWqxXkufG9QrqY4YUPCN1JNzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996373; 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=uIPVW/vreV6f3fNXGaXrbRU4fqOOeANYsAJB3x/TZdo=; b=N+UeG1eVqk7JELcvTc+I0SIg+GmIY1l7zUyoK7tC/zrnrIQRCNKKGLZ+gvIijgmeVf5lxJhiTHlJK1npwxldKFlGiEj8tNm/tc5DLkUlaI6+rbn9wILy1Lp+0Yl9sZfKVEb0fqxN/WPiaWN4lWOzcHFiWse77kVU84ubiCy76Uc= 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 1759996373062597.4696016792286; Thu, 9 Oct 2025 00:52:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQw-0008U9-3E; Thu, 09 Oct 2025 03:51:30 -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 1v6lQt-0008TH-8F for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51: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 1v6lQp-0004R3-6x for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:26 -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-527-bT0ikaWIPiKMvh-WO7KYtg-1; Thu, 09 Oct 2025 03:51:19 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46fa88b5760so2038875e9.3 for ; Thu, 09 Oct 2025 00:51:19 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fa9b622cdsm71342885e9.0.2025.10.09.00.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996280; 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=uIPVW/vreV6f3fNXGaXrbRU4fqOOeANYsAJB3x/TZdo=; b=OTPWbFrLZ9zfZtpEX2PHIaKHb7MEf5sNLBZXbMpM3wwf7zrw4CEzSnuo8ueR2ZFvR2wLtk uRMQx9BLZRLI/Zn0DEe/aXhhc0XWca1WKgLbyGiu2Y1dPmHURT9wtJmLjqrp4d/pHv0Y3L EXRMZpTVGWdmF8BrMGMJD2SBwo0JLjU= X-MC-Unique: bT0ikaWIPiKMvh-WO7KYtg-1 X-Mimecast-MFC-AGG-ID: bT0ikaWIPiKMvh-WO7KYtg_1759996278 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996277; x=1760601077; 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=uIPVW/vreV6f3fNXGaXrbRU4fqOOeANYsAJB3x/TZdo=; b=DT6IoH6VKtwIsIb6IlY1eEyK0MOUwKIURsV2bSUhSVOG0Wys+KK17moEz0IzHpR+dM 07H77qAZKHM4MlyOYKwn6bzJeVOghp76By97sspBi1aLoh7oTbjIPNuUT2tDUijH4LsK cnvOotyrhDZJmg4mhGQwAOu5Y3qo+8X8JNy2dOuvLmvmiag8XP/3lKISYZ6k+0gbbJJN ChBTIQAByHiHP0XOaSTYRdEU9lX7LXCVOAVXGKLiW5bEhANBwWMqsq+6qS+LMH+iBE/A RHU6XazulBAw508/y0crdlr4Nq7haRJeYw4jEjnzUhOT/2+fNn6oTO/BbPhILGpQrW7s AfEA== X-Gm-Message-State: AOJu0YyB+tpvYOkCuwdTeE4F9bHx58CuGgBdUW8/1u+nHJnEga1DAlcJ kXN6fEShcVDNsiOEP+jd4gWk4iEyOlZmqFN7frd3yGPviHzX1IdWyB7f9pmS/3J7KpgMaxdhZ0b AUii92DSM16R7jlkH1B/DHInPaTz+HOcOW5J1gVQbAWCb2hCi9IfbUhW/smuJFgN+zQYOzeGvg6 pJyOQn5z1XdxQsmDPfCkOBXCjzyazQJx5NuOfu11e+N7Y= X-Gm-Gg: ASbGncs4g7RDO16CvRXOBqg6wrAMaELbBSmVPitDCZT14lDcREhTQPm8ka/ZZfkSKdH giCFheZ3gyVub2MTfv5snjckWxaQUqCNPfrQnEhCbaeVqUTtVGmgX0ewRWJJ7kcbshE/39690P7 dAP7sQZJMxMro+gdavEXU8wPkyxG9Ner3YuKQUB1zE5zm3a2TSV964r0eqjN07w6z32r8256SeG zA1jOxokr9ZyMaT99WcmD1Bz201b0AzNa5STUHefimZlwc5okRxkHwMR0KdA8ZXM2Z7z8T/TAA0 MfN9Cd3mRd9ZDBYQhfs/5eF9Ja7kTZqxjysA52mzknFsKKes3yiV9aRblUtsGfzT2THOJ6D/I4M x4E9LDkCzJtk0pQgQ0IbBkwuBMG3LJF30Lj2DJaS2GQAkiXUI X-Received: by 2002:a05:600d:8110:b0:45f:2922:2aef with SMTP id 5b1f17b1804b1-46fa9b09233mr34363775e9.28.1759996276913; Thu, 09 Oct 2025 00:51:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHh5BzeOpzk9YPY5rNBi9iy/9ASzYHyFCbO4IG9chXAV+bzn0eFFWirCrk2ibM+n0Uczpk3uA== X-Received: by 2002:a05:600d:8110:b0:45f:2922:2aef with SMTP id 5b1f17b1804b1-46fa9b09233mr34363585e9.28.1759996276453; Thu, 09 Oct 2025 00:51:16 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 22/35] target/i386/mshv: Implement mshv_arch_put_registers() Date: Thu, 9 Oct 2025 09:50:12 +0200 Message-ID: <20251009075026.505715-23-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996374292154100 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Write CPU register state to MSHV vCPUs. Various mapping functions to prepare the payload for the HV call have been implemented. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-17-magnuskulke@linux.m= icrosoft.com [mshv.h/mshv_int.h split. - Paolo] Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 15 +++ target/i386/mshv/mshv-cpu.c | 237 ++++++++++++++++++++++++++++++++++++ 2 files changed, 252 insertions(+) diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index c6e6e8af307..0ea8d504fa5 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -49,6 +49,20 @@ typedef struct MshvMsiControl { #define mshv_vcpufd(cpu) (cpu->accel->cpufd) =20 /* cpu */ +typedef struct MshvFPU { + uint8_t fpr[8][16]; + uint16_t fcw; + uint16_t fsw; + uint8_t ftwx; + uint8_t pad1; + uint16_t last_opcode; + uint64_t last_ip; + uint64_t last_dp; + uint8_t xmm[16][16]; + uint32_t mxcsr; + uint32_t pad2; +} MshvFPU; + typedef enum MshvVmExit { MshvVmExitIgnore =3D 0, MshvVmExitShutdown =3D 1, @@ -58,6 +72,7 @@ typedef enum MshvVmExit { void mshv_init_mmio_emu(void); int mshv_create_vcpu(int vm_fd, uint8_t vp_index, int *cpu_fd); void mshv_remove_vcpu(int vm_fd, int cpu_fd); +int mshv_configure_vcpu(const CPUState *cpu, const MshvFPU *fpu, uint64_t = xcr0); int mshv_get_standard_regs(CPUState *cpu); int mshv_get_special_regs(CPUState *cpu); int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *e= xit); diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index bc75686f828..8b10c79e547 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -73,6 +73,35 @@ static enum hv_register_name SPECIAL_REGISTER_NAMES[17] = =3D { HV_X64_REGISTER_APIC_BASE, }; =20 +static enum hv_register_name FPU_REGISTER_NAMES[26] =3D { + HV_X64_REGISTER_XMM0, + HV_X64_REGISTER_XMM1, + HV_X64_REGISTER_XMM2, + HV_X64_REGISTER_XMM3, + HV_X64_REGISTER_XMM4, + HV_X64_REGISTER_XMM5, + HV_X64_REGISTER_XMM6, + HV_X64_REGISTER_XMM7, + HV_X64_REGISTER_XMM8, + HV_X64_REGISTER_XMM9, + HV_X64_REGISTER_XMM10, + HV_X64_REGISTER_XMM11, + HV_X64_REGISTER_XMM12, + HV_X64_REGISTER_XMM13, + HV_X64_REGISTER_XMM14, + HV_X64_REGISTER_XMM15, + HV_X64_REGISTER_FP_MMX0, + HV_X64_REGISTER_FP_MMX1, + HV_X64_REGISTER_FP_MMX2, + HV_X64_REGISTER_FP_MMX3, + HV_X64_REGISTER_FP_MMX4, + HV_X64_REGISTER_FP_MMX5, + HV_X64_REGISTER_FP_MMX6, + HV_X64_REGISTER_FP_MMX7, + HV_X64_REGISTER_FP_CONTROL_STATUS, + HV_X64_REGISTER_XMM_CONTROL_STATUS, +}; + int mshv_set_generic_regs(const CPUState *cpu, const hv_register_assoc *as= socs, size_t n_regs) { @@ -372,8 +401,216 @@ int mshv_load_regs(CPUState *cpu) return 0; } =20 +static inline void populate_hv_segment_reg(SegmentCache *seg, + hv_x64_segment_register *hv_reg) +{ + uint32_t flags =3D seg->flags; + + hv_reg->base =3D seg->base; + hv_reg->limit =3D seg->limit; + hv_reg->selector =3D seg->selector; + hv_reg->segment_type =3D (flags >> DESC_TYPE_SHIFT) & 0xF; + hv_reg->non_system_segment =3D (flags & DESC_S_MASK) !=3D 0; + hv_reg->descriptor_privilege_level =3D (flags >> DESC_DPL_SHIFT) & 0x3; + hv_reg->present =3D (flags & DESC_P_MASK) !=3D 0; + hv_reg->reserved =3D 0; + hv_reg->available =3D (flags & DESC_AVL_MASK) !=3D 0; + hv_reg->_long =3D (flags >> DESC_L_SHIFT) & 0x1; + hv_reg->_default =3D (flags >> DESC_B_SHIFT) & 0x1; + hv_reg->granularity =3D (flags & DESC_G_MASK) !=3D 0; +} + +static inline void populate_hv_table_reg(const struct SegmentCache *seg, + hv_x64_table_register *hv_reg) +{ + memset(hv_reg, 0, sizeof(*hv_reg)); + + hv_reg->base =3D seg->base; + hv_reg->limit =3D seg->limit; +} + +static int set_special_regs(const CPUState *cpu) +{ + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + struct hv_register_assoc assocs[ARRAY_SIZE(SPECIAL_REGISTER_NAMES)]; + size_t n_regs =3D ARRAY_SIZE(SPECIAL_REGISTER_NAMES); + int ret; + + /* set names */ + for (size_t i =3D 0; i < n_regs; i++) { + assocs[i].name =3D SPECIAL_REGISTER_NAMES[i]; + } + populate_hv_segment_reg(&env->segs[R_CS], &assocs[0].value.segment); + populate_hv_segment_reg(&env->segs[R_DS], &assocs[1].value.segment); + populate_hv_segment_reg(&env->segs[R_ES], &assocs[2].value.segment); + populate_hv_segment_reg(&env->segs[R_FS], &assocs[3].value.segment); + populate_hv_segment_reg(&env->segs[R_GS], &assocs[4].value.segment); + populate_hv_segment_reg(&env->segs[R_SS], &assocs[5].value.segment); + populate_hv_segment_reg(&env->tr, &assocs[6].value.segment); + populate_hv_segment_reg(&env->ldt, &assocs[7].value.segment); + + populate_hv_table_reg(&env->gdt, &assocs[8].value.table); + populate_hv_table_reg(&env->idt, &assocs[9].value.table); + + assocs[10].value.reg64 =3D env->cr[0]; + assocs[11].value.reg64 =3D env->cr[2]; + assocs[12].value.reg64 =3D env->cr[3]; + assocs[13].value.reg64 =3D env->cr[4]; + assocs[14].value.reg64 =3D cpu_get_apic_tpr(x86cpu->apic_state); + assocs[15].value.reg64 =3D env->efer; + assocs[16].value.reg64 =3D cpu_get_apic_base(x86cpu->apic_state); + + ret =3D mshv_set_generic_regs(cpu, assocs, n_regs); + if (ret < 0) { + error_report("failed to set special registers"); + return -1; + } + + return 0; +} + +static int set_fpu(const CPUState *cpu, const struct MshvFPU *regs) +{ + struct hv_register_assoc assocs[ARRAY_SIZE(FPU_REGISTER_NAMES)]; + union hv_register_value *value; + size_t fp_i; + union hv_x64_fp_control_status_register *ctrl_status; + union hv_x64_xmm_control_status_register *xmm_ctrl_status; + int ret; + size_t n_regs =3D ARRAY_SIZE(FPU_REGISTER_NAMES); + + /* first 16 registers are xmm0-xmm15 */ + for (size_t i =3D 0; i < 16; i++) { + assocs[i].name =3D FPU_REGISTER_NAMES[i]; + value =3D &assocs[i].value; + memcpy(&value->reg128, ®s->xmm[i], 16); + } + + /* next 8 registers are fp_mmx0-fp_mmx7 */ + for (size_t i =3D 16; i < 24; i++) { + assocs[i].name =3D FPU_REGISTER_NAMES[i]; + fp_i =3D (i - 16); + value =3D &assocs[i].value; + memcpy(&value->reg128, ®s->fpr[fp_i], 16); + } + + /* last two registers are fp_control_status and xmm_control_status */ + assocs[24].name =3D FPU_REGISTER_NAMES[24]; + value =3D &assocs[24].value; + ctrl_status =3D &value->fp_control_status; + ctrl_status->fp_control =3D regs->fcw; + ctrl_status->fp_status =3D regs->fsw; + ctrl_status->fp_tag =3D regs->ftwx; + ctrl_status->reserved =3D 0; + ctrl_status->last_fp_op =3D regs->last_opcode; + ctrl_status->last_fp_rip =3D regs->last_ip; + + assocs[25].name =3D FPU_REGISTER_NAMES[25]; + value =3D &assocs[25].value; + xmm_ctrl_status =3D &value->xmm_control_status; + xmm_ctrl_status->xmm_status_control =3D regs->mxcsr; + xmm_ctrl_status->xmm_status_control_mask =3D 0; + xmm_ctrl_status->last_fp_rdp =3D regs->last_dp; + + ret =3D mshv_set_generic_regs(cpu, assocs, n_regs); + if (ret < 0) { + error_report("failed to set fpu registers"); + return -1; + } + + return 0; +} + +static int set_xc_reg(const CPUState *cpu, uint64_t xcr0) +{ + int ret; + struct hv_register_assoc assoc =3D { + .name =3D HV_X64_REGISTER_XFEM, + .value.reg64 =3D xcr0, + }; + + ret =3D mshv_set_generic_regs(cpu, &assoc, 1); + if (ret < 0) { + error_report("failed to set xcr0"); + return -errno; + } + return 0; +} + +static int set_cpu_state(const CPUState *cpu, const MshvFPU *fpu_regs, + uint64_t xcr0) +{ + int ret; + + ret =3D set_standard_regs(cpu); + if (ret < 0) { + return ret; + } + ret =3D set_special_regs(cpu); + if (ret < 0) { + return ret; + } + ret =3D set_fpu(cpu, fpu_regs); + if (ret < 0) { + return ret; + } + ret =3D set_xc_reg(cpu, xcr0); + if (ret < 0) { + return ret; + } + return 0; +} + +/* + * TODO: populate topology info: + * + * X86CPU *x86cpu =3D X86_CPU(cpu); + * CPUX86State *env =3D &x86cpu->env; + * X86CPUTopoInfo *topo_info =3D &env->topo_info; + */ +int mshv_configure_vcpu(const CPUState *cpu, const struct MshvFPU *fpu, + uint64_t xcr0) +{ + int ret; + + ret =3D set_cpu_state(cpu, fpu, xcr0); + if (ret < 0) { + error_report("failed to set cpu state"); + return -1; + } + + return 0; +} + +static int put_regs(const CPUState *cpu) +{ + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + MshvFPU fpu =3D {0}; + int ret; + + memset(&fpu, 0, sizeof(fpu)); + + ret =3D mshv_configure_vcpu(cpu, &fpu, env->xcr0); + if (ret < 0) { + error_report("failed to configure vcpu"); + return ret; + } + + return 0; +} + int mshv_arch_put_registers(const CPUState *cpu) { + int ret; + + ret =3D put_regs(cpu); + if (ret < 0) { + error_report("Failed to put registers"); + return -1; + } + error_report("unimplemented"); abort(); } --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996557; cv=none; d=zohomail.com; s=zohoarc; b=iClDsohRh5YyNKa5LbidxHXtEwWsYLhIu+v+tZCKuGR1tvBO56U5AQ6RuswhW7cl6xm79VCBDbt7vjjpZYq5A+zrNp78LiA8F4hfm6bHmVGMZOX6mkc5L49ynf8ezlX7eKG5fz7KNXjUYSKBfGYTKmX1ddkE37ZfmKaacGiBFMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996557; 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=i4e5WisuIRnKwgKzQaGFn0q2ckBCBWWEQciLxXlj8bI=; b=IcenkTA4ClLz3bJ0gG0DpHlLignT8lbUHf4KJC1dv81m6QeNvlsMDdN79wCQU8LNnPMQSdCj5+h34Vn3VzukAnO5e5ux74Osonn6WHgtk6/uVMw1/DY0LpKL2l30ffdg7Nlrnl4bCuZOI63NLRTxb4ndyx51jMooQa69+G7zxus= 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 1759996557640933.8681750894651; Thu, 9 Oct 2025 00:55:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQu-0008Tb-VB; Thu, 09 Oct 2025 03:51:29 -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 1v6lQt-0008TK-Cf for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:27 -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 1v6lQp-0004RC-Pu for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:27 -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-396-ClWHQkEdMEG328XoGDkzBA-1; Thu, 09 Oct 2025 03:51:20 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3ece14b9231so517135f8f.0 for ; Thu, 09 Oct 2025 00:51:20 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8acc4csm32951297f8f.16.2025.10.09.00.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996282; 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=i4e5WisuIRnKwgKzQaGFn0q2ckBCBWWEQciLxXlj8bI=; b=fZlqNFIDNffSakYKU91KfA5Qr+CNHYq+MHnGy6aILAvJaH6S4Spmbq2ZMhjjfAJIkrsxsG ncgpKBRwaDAsnQ5C93mRlwMSRt7wgyWsi6JBRnCt5m1z0AGQDSndh4v8P+SW6Wk8U1LYVx JlaDGx+UoSyQuEnIG6mKeSnvcnsQlUE= X-MC-Unique: ClWHQkEdMEG328XoGDkzBA-1 X-Mimecast-MFC-AGG-ID: ClWHQkEdMEG328XoGDkzBA_1759996279 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996278; x=1760601078; 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=i4e5WisuIRnKwgKzQaGFn0q2ckBCBWWEQciLxXlj8bI=; b=MNUJ/Xf2i4y1SVaYArDLle1ZJb+fIZ8AMwnEikR/yyVICk3iNDDKHMurJeYcsolD9n HSTq6xJcP6Nl/mMsJddz3QL7EQBNosboRt9ugJ+wt9hTVal4RpYihIm2qHA6LpB2eIxS NXw8v30yZFapd0nG25B9j3XBZsZVFGmS9Wk995NKHNvuETHTSTpi6ml37V697J0UOU/k /oWFHlxFROkRVjCHFl33uG180RXQt8UFlw7VtDHmHAeuw5BPq/OoUKdTI49sFQ60Yz/Q fxO4ZaCQB6f/DuR+OEJyaaKSJlhfkEy1SF8OQlAI4I1EkTehJNL23keg6dUPQAfO/zLz ibBQ== X-Gm-Message-State: AOJu0YxXLc6QXZp3dPL8S3naBwsLLvYng1HXnQ5wwffAGllerfvy8DkW hPWfwa7lVBT0C2tIn7nvHpSPIMiE70R/T6iBfu9urdSZ1lj77BTA0rDShoikhuNuUwgYUv+kWWv bHwh9R2psFDT6A6G0x08IsXKnSg49t3AqMajiyfVOh8PVJCRs508e9CCNUZPEY40v7lVpUAsyuC uxtkIAuC1Km89f3kQtBOznAwgG1LicVFitGOIgPciLajE= X-Gm-Gg: ASbGnctYDLS6hJBhBVsFiCSirY9hpnjf3ALbSeOUURDfR0bzRn0D0eE247TaxAu77Wv 3wP/TEmEj6PeFUm2VVBqcx8s72ekTHX0rCPlSENBIGkiVOVR53Wy8FKqksIPYSkDCD20CSRYy4a LMojd0u+sFmzINa0nQHH+JFSOS9tQMR0tee00rn1kfuqpzqtFPAQTtL5yiw2WvjPi7M6/+rt6PM yxBw/eIUClEUUyjeigZqLcSt0qGYfVV2zrQGi06zyWjQ4R3nRoFVupzwx0RbKdu5kUslZLwHXEG MPrVN6DD7xx2Se5Z4ASjn+b+Kx3NQUPg3tPL8adpyve+tWaLuty2IiTH3QPzP+S6L5KBLwobFC1 NRxXAUlCdbwTd6VpzF2mFR7jZWSaClUUMURwS6HApxZQJZg6k X-Received: by 2002:a05:6000:60f:b0:411:f07a:680b with SMTP id ffacd0b85a97d-4266e8d8a7dmr4377795f8f.33.1759996278011; Thu, 09 Oct 2025 00:51:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE++XMu4ekhBRSyEQC3OxsD4S2QcrcWTzHbtqJp7O30pX0J0x7ufZdn7fF/oEbfwFBdfBYUcQ== X-Received: by 2002:a05:6000:60f:b0:411:f07a:680b with SMTP id ffacd0b85a97d-4266e8d8a7dmr4377770f8f.33.1759996277595; Thu, 09 Oct 2025 00:51:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 23/35] target/i386/mshv: Set local interrupt controller state Date: Thu, 9 Oct 2025 09:50:13 +0200 Message-ID: <20251009075026.505715-24-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996558282154100 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke To set the local interrupt controller state, perform hv calls retrieving partition state from the hypervisor. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-18-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- target/i386/mshv/mshv-cpu.c | 117 ++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 8b10c79e547..0fe3cbb48d8 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -12,6 +12,7 @@ =20 #include "qemu/osdep.h" #include "qemu/error-report.h" +#include "qemu/memalign.h" #include "qemu/typedefs.h" =20 #include "system/mshv.h" @@ -21,6 +22,7 @@ #include "hw/hyperv/hvgdk.h" #include "hw/hyperv/hvgdk_mini.h" #include "hw/hyperv/hvhdk_mini.h" +#include "hw/i386/apic_internal.h" =20 #include "cpu.h" #include "emulate/x86_decode.h" @@ -562,6 +564,114 @@ static int set_cpu_state(const CPUState *cpu, const M= shvFPU *fpu_regs, return 0; } =20 +static int get_vp_state(int cpu_fd, struct mshv_get_set_vp_state *state) +{ + int ret; + + ret =3D ioctl(cpu_fd, MSHV_GET_VP_STATE, state); + if (ret < 0) { + error_report("failed to get partition state: %s", strerror(errno)); + return -1; + } + + return 0; +} + +static int get_lapic(int cpu_fd, + struct hv_local_interrupt_controller_state *state) +{ + int ret; + size_t size =3D 4096; + /* buffer aligned to 4k, as *state requires that */ + void *buffer =3D qemu_memalign(size, size); + struct mshv_get_set_vp_state mshv_state =3D { 0 }; + + mshv_state.buf_ptr =3D (uint64_t) buffer; + mshv_state.buf_sz =3D size; + mshv_state.type =3D MSHV_VP_STATE_LAPIC; + + ret =3D get_vp_state(cpu_fd, &mshv_state); + if (ret =3D=3D 0) { + memcpy(state, buffer, sizeof(*state)); + } + qemu_vfree(buffer); + if (ret < 0) { + error_report("failed to get lapic"); + return -1; + } + + return 0; +} + +static uint32_t set_apic_delivery_mode(uint32_t reg, uint32_t mode) +{ + return ((reg) & ~0x700) | ((mode) << 8); +} + +static int set_vp_state(int cpu_fd, const struct mshv_get_set_vp_state *st= ate) +{ + int ret; + + ret =3D ioctl(cpu_fd, MSHV_SET_VP_STATE, state); + if (ret < 0) { + error_report("failed to set partition state: %s", strerror(errno)); + return -1; + } + + return 0; +} + +static int set_lapic(int cpu_fd, + const struct hv_local_interrupt_controller_state *sta= te) +{ + int ret; + size_t size =3D 4096; + /* buffer aligned to 4k, as *state requires that */ + void *buffer =3D qemu_memalign(size, size); + struct mshv_get_set_vp_state mshv_state =3D { 0 }; + + if (!state) { + error_report("lapic state is NULL"); + return -1; + } + memcpy(buffer, state, sizeof(*state)); + + mshv_state.buf_ptr =3D (uint64_t) buffer; + mshv_state.buf_sz =3D size; + mshv_state.type =3D MSHV_VP_STATE_LAPIC; + + ret =3D set_vp_state(cpu_fd, &mshv_state); + qemu_vfree(buffer); + if (ret < 0) { + error_report("failed to set lapic: %s", strerror(errno)); + return -1; + } + + return 0; +} + +static int set_lint(int cpu_fd) +{ + int ret; + uint32_t *lvt_lint0, *lvt_lint1; + + struct hv_local_interrupt_controller_state lapic_state =3D { 0 }; + ret =3D get_lapic(cpu_fd, &lapic_state); + if (ret < 0) { + return ret; + } + + lvt_lint0 =3D &lapic_state.apic_lvt_lint0; + *lvt_lint0 =3D set_apic_delivery_mode(*lvt_lint0, APIC_DM_EXTINT); + + lvt_lint1 =3D &lapic_state.apic_lvt_lint1; + *lvt_lint1 =3D set_apic_delivery_mode(*lvt_lint1, APIC_DM_NMI); + + /* TODO: should we skip setting lapic if the values are the same? */ + + return set_lapic(cpu_fd, &lapic_state); +} + /* * TODO: populate topology info: * @@ -573,6 +683,7 @@ int mshv_configure_vcpu(const CPUState *cpu, const stru= ct MshvFPU *fpu, uint64_t xcr0) { int ret; + int cpu_fd =3D mshv_vcpufd(cpu); =20 ret =3D set_cpu_state(cpu, fpu, xcr0); if (ret < 0) { @@ -580,6 +691,12 @@ int mshv_configure_vcpu(const CPUState *cpu, const str= uct MshvFPU *fpu, return -1; } =20 + ret =3D set_lint(cpu_fd); + if (ret < 0) { + error_report("failed to set lpic int"); + return -1; + } + return 0; } =20 --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996613; cv=none; d=zohomail.com; s=zohoarc; b=XVxeK1rxgxZxB7BJpeJZvbGkI8tRGlDKURYG/tsHsoU8r2PrRCoUTwXlmlu702mQZrT21SwxxgXcSG0wph/5KaoiDXk2iSVx48p/3hgQym8W9GhYWZOThAEaedJE9piZ10t83S1FT2D2sl/DSYpwQ+3rDHD1s14oEfpUWnuxaPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996613; 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=DIImP9rsbENMbkYn9y/syNVGQpkLhbp28x1tK4d0VmY=; b=I4pBQBWb+zu8domrh5esZceeTu5GG56b9qqav790gT9luH2M5aHpL6wOnob5h0M+vEpveOShzSvbHAXvX+PYS7CC8QaOQ4ks3s5ZRdNEueokOr441hSFNrRIJEJYc0TUD9dSgX1fv0IbGvARLrQEXuZQC9HxECagcVDDYNa72Ks= 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 175999661318071.22618510885695; Thu, 9 Oct 2025 00:56:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lQy-0008Ur-1p; Thu, 09 Oct 2025 03:51:32 -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 1v6lQw-0008UI-78 for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51: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 1v6lQt-0004Rg-II for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:29 -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-435-vK8Yy5FYPTazp-xo0hJbkA-1; Thu, 09 Oct 2025 03:51:23 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3ecdd80ea44so541454f8f.1 for ; Thu, 09 Oct 2025 00:51:23 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8e97f0sm33092084f8f.27.2025.10.09.00.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996285; 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=DIImP9rsbENMbkYn9y/syNVGQpkLhbp28x1tK4d0VmY=; b=P0Q9Dnmm77KqoDjPaldpiEarrTTMsUCjp2OZzW1i4NzBsx2A8t/Nr/xM6TTRBmeq8Qrl3P caXCjtWDriDa+b73KY0/qcu0L4ekD4tgElzD+dfuZsHr0FhzKP3OU44C4S1Eh9h6p8b+uO yRjXrwQYpyWoeWGelLUmM9NEKV859NI= X-MC-Unique: vK8Yy5FYPTazp-xo0hJbkA-1 X-Mimecast-MFC-AGG-ID: vK8Yy5FYPTazp-xo0hJbkA_1759996283 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996282; x=1760601082; 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=DIImP9rsbENMbkYn9y/syNVGQpkLhbp28x1tK4d0VmY=; b=m/qqMmIEyDWM1smrzOi/rDNE0mHzFQj1NjSPCI//qICgv7AKJeoA4QE8c6XVqNnEsi 7ezP8ic+X0sTHTeI/6p4U7IRiY0cw+/7Q3wZtLu+tS/o3nXiQwhAFpEEb+NA+D+kJF6T DLt2947trCyvQvydWzjCOyp2Kn8OVTk+A+necKn2uwfCmE+8wwWOVJhY+LybDaBDhOk/ MDXEdJuBBKnvN78ilA3WJS24/CG4F2K8CWXGTlkut2bJIGdxm1ZDhh68oY1Zqqr3gnRI SIeimWQGDUYqww58v9aONnqSXmoXSyn8s4jygpYzSPhsYDovUFHVpz1LzmXjjHxvFtvQ GzGQ== X-Gm-Message-State: AOJu0YyA8LVaK7Ec+aQOxvH+k7fjpibonaTchdAVUKa6+8pUUzLH/Nc1 faS2MNbL5iByzYNu/q5Oa1r2431UfsCP3bLRB6pNYOuk+wBrNHZeeTZdiCx11LmgW7PigLwQzIN o2D/M+yfly4BhulQHHDzY40Sl8OzqVdTKAGZipXWeSxEsMubqGuMfaj8tI2N3/LoT5YxaLSUBbc NyQn1Xy3C/r0m8zryXD2AoVTFw2CKK5ubLCoIh8YP8teQ= X-Gm-Gg: ASbGnctvKhM9MzYKrUNAyhY1t1PqMXolE+Ge3877k2rK5lCC7tzncZMgLcfhB1nDNNY 427fm8ea63ojgssRL3iz6RC9XmkEBic04ekqawF1OldX2B09k8vjfDQglYVeSunp3wl1tahTAKR s+A57GyBzWyrj4RMGQPpDi0OSqRiZpKB6VG2H6S4PiFeRqH0bf6Ty84MDeFX9IBJtommsQxHTwa R9ety0GOqaURP1aODubVNMl9eBy9PR0g+vwCCUHXu099qtya9ZkK8inP0/eNO0DLgyTC6nsqDbe 6xKurLbyjmok3eAOwmAxBuLHgNs3BYZb2TkOI15krnS0muHWNpl4hxlJtdCukIxypbZ6nEhnr7c A+J9lpq3C9lkBJe+CTbfMu0jXcFjrgA2zI48V6DWeQSUM0UmV X-Received: by 2002:a05:6000:2c02:b0:401:ae97:a1ab with SMTP id ffacd0b85a97d-42666aa67f9mr4850193f8f.10.1759996281608; Thu, 09 Oct 2025 00:51:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfaByyQlmT9MlDK+1uimYC2uGepwrZY9j/pASb17HgNVNKv8iEdASvF82gsUC3f/BUcoNO7A== X-Received: by 2002:a05:6000:2c02:b0:401:ae97:a1ab with SMTP id ffacd0b85a97d-42666aa67f9mr4850166f8f.10.1759996281129; Thu, 09 Oct 2025 00:51:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 24/35] target/i386/mshv: Register CPUID entries with MSHV Date: Thu, 9 Oct 2025 09:50:14 +0200 Message-ID: <20251009075026.505715-25-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996622113116600 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Convert the guest CPU's CPUID model into MSHV's format and register it with the hypervisor. This ensures that the guest observes the correct CPU feature set during CPUID instructions. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-19-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- target/i386/mshv/mshv-cpu.c | 206 ++++++++++++++++++++++++++++++++++++ 1 file changed, 206 insertions(+) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 0fe3cbb48d8..2b7a81274b3 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -403,6 +403,206 @@ int mshv_load_regs(CPUState *cpu) return 0; } =20 +static void add_cpuid_entry(GList *cpuid_entries, + uint32_t function, uint32_t index, + uint32_t eax, uint32_t ebx, + uint32_t ecx, uint32_t edx) +{ + struct hv_cpuid_entry *entry; + + entry =3D g_malloc0(sizeof(struct hv_cpuid_entry)); + entry->function =3D function; + entry->index =3D index; + entry->eax =3D eax; + entry->ebx =3D ebx; + entry->ecx =3D ecx; + entry->edx =3D edx; + + cpuid_entries =3D g_list_append(cpuid_entries, entry); +} + +static void collect_cpuid_entries(const CPUState *cpu, GList *cpuid_entrie= s) +{ + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + uint32_t eax, ebx, ecx, edx; + uint32_t leaf, subleaf; + size_t max_leaf =3D 0x1F; + size_t max_subleaf =3D 0x20; + + uint32_t leaves_with_subleaves[] =3D {0x4, 0x7, 0xD, 0xF, 0x10}; + int n_subleaf_leaves =3D ARRAY_SIZE(leaves_with_subleaves); + + /* Regular leaves without subleaves */ + for (leaf =3D 0; leaf <=3D max_leaf; leaf++) { + bool has_subleaves =3D false; + for (int i =3D 0; i < n_subleaf_leaves; i++) { + if (leaf =3D=3D leaves_with_subleaves[i]) { + has_subleaves =3D true; + break; + } + } + + if (!has_subleaves) { + cpu_x86_cpuid(env, leaf, 0, &eax, &ebx, &ecx, &edx); + if (eax =3D=3D 0 && ebx =3D=3D 0 && ecx =3D=3D 0 && edx =3D=3D= 0) { + /* all zeroes indicates no more leaves */ + continue; + } + + add_cpuid_entry(cpuid_entries, leaf, 0, eax, ebx, ecx, edx); + continue; + } + + subleaf =3D 0; + while (subleaf < max_subleaf) { + cpu_x86_cpuid(env, leaf, subleaf, &eax, &ebx, &ecx, &edx); + + if (eax =3D=3D 0 && ebx =3D=3D 0 && ecx =3D=3D 0 && edx =3D=3D= 0) { + /* all zeroes indicates no more leaves */ + break; + } + add_cpuid_entry(cpuid_entries, leaf, 0, eax, ebx, ecx, edx); + subleaf++; + } + } +} + +static int register_intercept_result_cpuid_entry(const CPUState *cpu, + uint8_t subleaf_specific, + uint8_t always_override, + struct hv_cpuid_entry *en= try) +{ + int ret; + int vp_index =3D cpu->cpu_index; + int cpu_fd =3D mshv_vcpufd(cpu); + + struct hv_register_x64_cpuid_result_parameters cpuid_params =3D { + .input.eax =3D entry->function, + .input.ecx =3D entry->index, + .input.subleaf_specific =3D subleaf_specific, + .input.always_override =3D always_override, + .input.padding =3D 0, + /* + * With regard to masks - these are to specify bits to be overwrit= ten + * The current CpuidEntry structure wouldn't allow to carry the ma= sks + * in addition to the actual register values. For this reason, the + * masks are set to the exact values of the corresponding register= bits + * to be registered for an overwrite. To view resulting values the + * hypervisor would return, HvCallGetVpCpuidValues hypercall can be + * used. + */ + .result.eax =3D entry->eax, + .result.eax_mask =3D entry->eax, + .result.ebx =3D entry->ebx, + .result.ebx_mask =3D entry->ebx, + .result.ecx =3D entry->ecx, + .result.ecx_mask =3D entry->ecx, + .result.edx =3D entry->edx, + .result.edx_mask =3D entry->edx, + }; + union hv_register_intercept_result_parameters parameters =3D { + .cpuid =3D cpuid_params, + }; + + hv_input_register_intercept_result in =3D {0}; + in.vp_index =3D vp_index; + in.intercept_type =3D HV_INTERCEPT_TYPE_X64_CPUID; + in.parameters =3D parameters; + + struct mshv_root_hvcall args =3D {0}; + args.code =3D HVCALL_REGISTER_INTERCEPT_RESULT; + args.in_sz =3D sizeof(in); + args.in_ptr =3D (uint64_t)∈ + + ret =3D mshv_hvcall(cpu_fd, &args); + if (ret < 0) { + error_report("failed to register intercept result for cpuid"); + return -1; + } + + return 0; +} + +static int register_intercept_result_cpuid(const CPUState *cpu, + struct hv_cpuid *cpuid) +{ + int ret =3D 0, entry_ret; + struct hv_cpuid_entry *entry; + uint8_t subleaf_specific, always_override; + + for (size_t i =3D 0; i < cpuid->nent; i++) { + entry =3D &cpuid->entries[i]; + + /* set defaults */ + subleaf_specific =3D 0; + always_override =3D 1; + + /* Intel */ + /* 0xb - Extended Topology Enumeration Leaf */ + /* 0x1f - V2 Extended Topology Enumeration Leaf */ + /* AMD */ + /* 0x8000_001e - Processor Topology Information */ + /* 0x8000_0026 - Extended CPU Topology */ + if (entry->function =3D=3D 0xb + || entry->function =3D=3D 0x1f + || entry->function =3D=3D 0x8000001e + || entry->function =3D=3D 0x80000026) { + subleaf_specific =3D 1; + always_override =3D 1; + } else if (entry->function =3D=3D 0x00000001 + || entry->function =3D=3D 0x80000000 + || entry->function =3D=3D 0x80000001 + || entry->function =3D=3D 0x80000008) { + subleaf_specific =3D 0; + always_override =3D 1; + } + + entry_ret =3D register_intercept_result_cpuid_entry(cpu, subleaf_s= pecific, + always_override, + entry); + if ((entry_ret < 0) && (ret =3D=3D 0)) { + ret =3D entry_ret; + } + } + + return ret; +} + +static int set_cpuid2(const CPUState *cpu) +{ + int ret; + size_t n_entries, cpuid_size; + struct hv_cpuid *cpuid; + struct hv_cpuid_entry *entry; + GList *entries =3D NULL; + + collect_cpuid_entries(cpu, entries); + n_entries =3D g_list_length(entries); + + cpuid_size =3D sizeof(struct hv_cpuid) + + n_entries * sizeof(struct hv_cpuid_entry); + + cpuid =3D g_malloc0(cpuid_size); + cpuid->nent =3D n_entries; + cpuid->padding =3D 0; + + for (size_t i =3D 0; i < n_entries; i++) { + entry =3D g_list_nth_data(entries, i); + cpuid->entries[i] =3D *entry; + g_free(entry); + } + g_list_free(entries); + + ret =3D register_intercept_result_cpuid(cpu, cpuid); + g_free(cpuid); + if (ret < 0) { + return ret; + } + + return 0; +} + static inline void populate_hv_segment_reg(SegmentCache *seg, hv_x64_segment_register *hv_reg) { @@ -685,6 +885,12 @@ int mshv_configure_vcpu(const CPUState *cpu, const str= uct MshvFPU *fpu, int ret; int cpu_fd =3D mshv_vcpufd(cpu); =20 + ret =3D set_cpuid2(cpu); + if (ret < 0) { + error_report("failed to set cpuid"); + return -1; + } + ret =3D set_cpu_state(cpu, fpu, xcr0); if (ret < 0) { error_report("failed to set cpu state"); --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996326; cv=none; d=zohomail.com; s=zohoarc; b=TpSC8GSztVXYJF7T76V/fFYeV4brSn9Xq8PrauPuBwnxo2pj1INgCg6b9WXplCsFQoqnmO55YOFgRPfAL0gg/vXH3exe0RaYGP3Vi34FGovrfNFtiyC4/Zq/QC7Ye7nyxujrMXzZvTprf0n4WYNkKVyXe6w3lbJ1bqpaMXQbo6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996326; 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=5ygv6RTzMSuQ3OP4FqjilFtENFefWJsZh6TTWfD7xr4=; b=eDcmz0+PCRxSl43iayW2d1B36QNy+U8+3Qwnv3NVvIJl8c5fOh0UwwgRoD5tqgrpF6wZ/8zfSpygwqx6fdHpdrb0EDHETyP/hrBrHMUduPcSbCj8UoZsiZy2N1Qat4kGNb5MflNxSfRPAHqHg7NvSoGCYtcH9BJGKyCdhNNrVTM= 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 1759996326155686.5701606688106; Thu, 9 Oct 2025 00:52:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lR1-0008Vk-PE; Thu, 09 Oct 2025 03:51: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 1v6lR0-0008VG-0e for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51: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 1v6lQv-0004S7-O2 for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:33 -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-31-88hqiSnNPbeQUyDDa-NWJw-1; Thu, 09 Oct 2025 03:51:26 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-46e38bd6680so4834995e9.1 for ; Thu, 09 Oct 2025 00:51:26 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46faf105ad7sm33911095e9.4.2025.10.09.00.51.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996287; 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=5ygv6RTzMSuQ3OP4FqjilFtENFefWJsZh6TTWfD7xr4=; b=TMXMx2fkd8yJOlB6c2KUh/jT4IJIaBk5Md/K6m0OPAeBz3WXo+Gh8gphRkkhJetavrGFNW tYIs0srZJue9Qth5vbSOfoqY8p+baTVCV3kwRqA5Ag0ePFCJQ0Ll6qAyCM8z5tr3AF4FT2 GWlG7JE28d/Mt/SB6TXIs0VcYBHJY3Q= X-MC-Unique: 88hqiSnNPbeQUyDDa-NWJw-1 X-Mimecast-MFC-AGG-ID: 88hqiSnNPbeQUyDDa-NWJw_1759996285 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996284; x=1760601084; 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=5ygv6RTzMSuQ3OP4FqjilFtENFefWJsZh6TTWfD7xr4=; b=FKRbMu0d43j60JXEQViLl2xFPKhEq30JV88CWKsBrT9vblS+cqtemaFNdzKgqTdo/p i9jt+JqHtORz/yOWmS+GSn2euo2Ixa8SlOWfeyZzhmC0+0osKABWDEfDlFjzSLA7g/HT jxj52CwsYZfW5SvTNS5C3is2uxVYo46EjqtInZbILognkdx5z5+H/FeF0C5CWRL6BQ30 V0T0qrkA1SVkIOnB2A5D67BC7nAuPtcQNurJRuB6OM2BphhqjQ2lQIBVbN3PEl01aoEK +mF7dH2gvfvJMqnc5Q5An87HQrdfFEFRdJW+tUypGhskMR0RWmzp1pk5VjTgMPf1HKro PpcA== X-Gm-Message-State: AOJu0YwAR19qrWgJiSxvTCSTz2leQIw2tPkgqY1i/E74mBb0RbUtjwM7 iPhHAGf8MaqBJL0KBsP6lPV9tGdsXWvAn3Zq0spTflcT/jbeunyFMunHeMA1QnW3u9/cBb4NUXM lCFC6I15XQNzzZuL2mdpLscxR4teR5rx8sQVjDIa2/3XqmT2ZFCUoYwxfh+Uv6y+OnC0Eo/ERiL W8YM7zkGd/d47hDvacmjpIffIxalcGMcprkQPXTlQAXNs= X-Gm-Gg: ASbGncsqhfcBuIIFugEa12NlQA2nwxaUsPI8WRLZwdXsAwKC6Od8Wq6bHhWxy9NfRUb TJgZP0wixecUWtrKoij3qFBdgawGjqZKbKtPm4TfTky39gT2Z8X0jamT71v5uCHd4322GYL6yoh loDywT7ozcBdDqw/r5vgdJt395VXee5pbNMVh2wxZWOJGYJV32MTeQqJCwejDVBMJ/nxl+xMxL/ rvz944TosfRqgc3FaOKp3f8gjynemCDLz7Jtma3R5vBjtvRYAhLDfljbnP2+iIVznGE+akNkUnC ehSklD6zyaQT3GGPSCVaBkUazNSFO81QB/MkT2QpcQAw/iMfO0lKrH0dZliLAY+x69o6gEgDcmn poWFQzRmvd0B/Z2fi66Smryn5oTtxBnwIFUCp23W8gk6DOwVY X-Received: by 2002:a05:600c:3b08:b0:456:1b6f:c888 with SMTP id 5b1f17b1804b1-46fa9af364bmr36956015e9.23.1759996284053; Thu, 09 Oct 2025 00:51:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFByRBzrb00IRdWGsfwRCK6gIh+xhAjYmgtooCQ9lsVsG0U6TAXLMs5SyjaiPSYxXSGREsGBw== X-Received: by 2002:a05:600c:3b08:b0:456:1b6f:c888 with SMTP id 5b1f17b1804b1-46fa9af364bmr36955805e9.23.1759996283439; Thu, 09 Oct 2025 00:51:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 25/35] target/i386/mshv: Register MSRs with MSHV Date: Thu, 9 Oct 2025 09:50:15 +0200 Message-ID: <20251009075026.505715-26-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996329755154100 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Build and register the guest vCPU's model-specific registers using the MSHV interface. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-20-magnuskulke@linux.m= icrosoft.com [mshv.h/mshv_int.h split. - Paolo] Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 17 ++ target/i386/cpu.h | 2 + accel/mshv/msr.c | 375 ++++++++++++++++++++++++++++++++++++ target/i386/mshv/mshv-cpu.c | 33 ++++ accel/mshv/meson.build | 1 + 5 files changed, 428 insertions(+) create mode 100644 accel/mshv/msr.c diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 0ea8d504fa5..66494383134 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -14,6 +14,8 @@ #ifndef QEMU_MSHV_INT_H #define QEMU_MSHV_INT_H =20 +#define MSHV_MSR_ENTRIES_COUNT 64 + typedef struct hyperv_message hv_message; =20 struct AccelCPUState { @@ -102,6 +104,21 @@ typedef struct MshvMemoryRegion { void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryRegionSection *secti= on, bool add); =20 +/* msr */ +typedef struct MshvMsrEntry { + uint32_t index; + uint32_t reserved; + uint64_t data; +} MshvMsrEntry; + +typedef struct MshvMsrEntries { + MshvMsrEntry entries[MSHV_MSR_ENTRIES_COUNT]; + uint32_t nmsrs; +} MshvMsrEntries; + +int mshv_configure_msr(const CPUState *cpu, const MshvMsrEntry *msrs, + size_t n_msrs); + /* interrupt */ void mshv_init_msicontrol(void); int mshv_reserve_ioapic_msi_routes(int vm_fd); diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 3aec8fd41c8..8b7c173838e 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -435,9 +435,11 @@ typedef enum X86Seg { #define MSR_SMI_COUNT 0x34 #define MSR_CORE_THREAD_COUNT 0x35 #define MSR_MTRRcap 0xfe +#define MSR_MTRR_MEM_TYPE_WB 0x06 #define MSR_MTRRcap_VCNT 8 #define MSR_MTRRcap_FIXRANGE_SUPPORT (1 << 8) #define MSR_MTRRcap_WC_SUPPORTED (1 << 10) +#define MSR_MTRR_ENABLE (1 << 11) =20 #define MSR_IA32_SYSENTER_CS 0x174 #define MSR_IA32_SYSENTER_ESP 0x175 diff --git a/accel/mshv/msr.c b/accel/mshv/msr.c new file mode 100644 index 00000000000..e6e5baef507 --- /dev/null +++ b/accel/mshv/msr.c @@ -0,0 +1,375 @@ +/* + * QEMU MSHV support + * + * Copyright Microsoft, Corp. 2025 + * + * Authors: Magnus Kulke + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "system/mshv.h" +#include "system/mshv_int.h" +#include "hw/hyperv/hvgdk_mini.h" +#include "linux/mshv.h" +#include "qemu/error-report.h" + +static uint32_t supported_msrs[64] =3D { + IA32_MSR_TSC, + IA32_MSR_EFER, + IA32_MSR_KERNEL_GS_BASE, + IA32_MSR_APIC_BASE, + IA32_MSR_PAT, + IA32_MSR_SYSENTER_CS, + IA32_MSR_SYSENTER_ESP, + IA32_MSR_SYSENTER_EIP, + IA32_MSR_STAR, + IA32_MSR_LSTAR, + IA32_MSR_CSTAR, + IA32_MSR_SFMASK, + IA32_MSR_MTRR_DEF_TYPE, + IA32_MSR_MTRR_PHYSBASE0, + IA32_MSR_MTRR_PHYSMASK0, + IA32_MSR_MTRR_PHYSBASE1, + IA32_MSR_MTRR_PHYSMASK1, + IA32_MSR_MTRR_PHYSBASE2, + IA32_MSR_MTRR_PHYSMASK2, + IA32_MSR_MTRR_PHYSBASE3, + IA32_MSR_MTRR_PHYSMASK3, + IA32_MSR_MTRR_PHYSBASE4, + IA32_MSR_MTRR_PHYSMASK4, + IA32_MSR_MTRR_PHYSBASE5, + IA32_MSR_MTRR_PHYSMASK5, + IA32_MSR_MTRR_PHYSBASE6, + IA32_MSR_MTRR_PHYSMASK6, + IA32_MSR_MTRR_PHYSBASE7, + IA32_MSR_MTRR_PHYSMASK7, + IA32_MSR_MTRR_FIX64K_00000, + IA32_MSR_MTRR_FIX16K_80000, + IA32_MSR_MTRR_FIX16K_A0000, + IA32_MSR_MTRR_FIX4K_C0000, + IA32_MSR_MTRR_FIX4K_C8000, + IA32_MSR_MTRR_FIX4K_D0000, + IA32_MSR_MTRR_FIX4K_D8000, + IA32_MSR_MTRR_FIX4K_E0000, + IA32_MSR_MTRR_FIX4K_E8000, + IA32_MSR_MTRR_FIX4K_F0000, + IA32_MSR_MTRR_FIX4K_F8000, + IA32_MSR_TSC_AUX, + IA32_MSR_DEBUG_CTL, + HV_X64_MSR_GUEST_OS_ID, + HV_X64_MSR_SINT0, + HV_X64_MSR_SINT1, + HV_X64_MSR_SINT2, + HV_X64_MSR_SINT3, + HV_X64_MSR_SINT4, + HV_X64_MSR_SINT5, + HV_X64_MSR_SINT6, + HV_X64_MSR_SINT7, + HV_X64_MSR_SINT8, + HV_X64_MSR_SINT9, + HV_X64_MSR_SINT10, + HV_X64_MSR_SINT11, + HV_X64_MSR_SINT12, + HV_X64_MSR_SINT13, + HV_X64_MSR_SINT14, + HV_X64_MSR_SINT15, + HV_X64_MSR_SCONTROL, + HV_X64_MSR_SIEFP, + HV_X64_MSR_SIMP, + HV_X64_MSR_REFERENCE_TSC, + HV_X64_MSR_EOM, +}; +static const size_t msr_count =3D ARRAY_SIZE(supported_msrs); + +static int compare_msr_index(const void *a, const void *b) +{ + return *(uint32_t *)a - *(uint32_t *)b; +} + +__attribute__((constructor)) +static void init_sorted_msr_map(void) +{ + qsort(supported_msrs, msr_count, sizeof(uint32_t), compare_msr_index); +} + +static int mshv_is_supported_msr(uint32_t msr) +{ + return bsearch(&msr, supported_msrs, msr_count, sizeof(uint32_t), + compare_msr_index) !=3D NULL; +} + +static int mshv_msr_to_hv_reg_name(uint32_t msr, uint32_t *hv_reg) +{ + switch (msr) { + case IA32_MSR_TSC: + *hv_reg =3D HV_X64_REGISTER_TSC; + return 0; + case IA32_MSR_EFER: + *hv_reg =3D HV_X64_REGISTER_EFER; + return 0; + case IA32_MSR_KERNEL_GS_BASE: + *hv_reg =3D HV_X64_REGISTER_KERNEL_GS_BASE; + return 0; + case IA32_MSR_APIC_BASE: + *hv_reg =3D HV_X64_REGISTER_APIC_BASE; + return 0; + case IA32_MSR_PAT: + *hv_reg =3D HV_X64_REGISTER_PAT; + return 0; + case IA32_MSR_SYSENTER_CS: + *hv_reg =3D HV_X64_REGISTER_SYSENTER_CS; + return 0; + case IA32_MSR_SYSENTER_ESP: + *hv_reg =3D HV_X64_REGISTER_SYSENTER_ESP; + return 0; + case IA32_MSR_SYSENTER_EIP: + *hv_reg =3D HV_X64_REGISTER_SYSENTER_EIP; + return 0; + case IA32_MSR_STAR: + *hv_reg =3D HV_X64_REGISTER_STAR; + return 0; + case IA32_MSR_LSTAR: + *hv_reg =3D HV_X64_REGISTER_LSTAR; + return 0; + case IA32_MSR_CSTAR: + *hv_reg =3D HV_X64_REGISTER_CSTAR; + return 0; + case IA32_MSR_SFMASK: + *hv_reg =3D HV_X64_REGISTER_SFMASK; + return 0; + case IA32_MSR_MTRR_CAP: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_CAP; + return 0; + case IA32_MSR_MTRR_DEF_TYPE: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_DEF_TYPE; + return 0; + case IA32_MSR_MTRR_PHYSBASE0: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE0; + return 0; + case IA32_MSR_MTRR_PHYSMASK0: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK0; + return 0; + case IA32_MSR_MTRR_PHYSBASE1: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE1; + return 0; + case IA32_MSR_MTRR_PHYSMASK1: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK1; + return 0; + case IA32_MSR_MTRR_PHYSBASE2: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE2; + return 0; + case IA32_MSR_MTRR_PHYSMASK2: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK2; + return 0; + case IA32_MSR_MTRR_PHYSBASE3: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE3; + return 0; + case IA32_MSR_MTRR_PHYSMASK3: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK3; + return 0; + case IA32_MSR_MTRR_PHYSBASE4: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE4; + return 0; + case IA32_MSR_MTRR_PHYSMASK4: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK4; + return 0; + case IA32_MSR_MTRR_PHYSBASE5: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE5; + return 0; + case IA32_MSR_MTRR_PHYSMASK5: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK5; + return 0; + case IA32_MSR_MTRR_PHYSBASE6: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE6; + return 0; + case IA32_MSR_MTRR_PHYSMASK6: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK6; + return 0; + case IA32_MSR_MTRR_PHYSBASE7: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE7; + return 0; + case IA32_MSR_MTRR_PHYSMASK7: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK7; + return 0; + case IA32_MSR_MTRR_FIX64K_00000: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX64K00000; + return 0; + case IA32_MSR_MTRR_FIX16K_80000: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX16K80000; + return 0; + case IA32_MSR_MTRR_FIX16K_A0000: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX16KA0000; + return 0; + case IA32_MSR_MTRR_FIX4K_C0000: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KC0000; + return 0; + case IA32_MSR_MTRR_FIX4K_C8000: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KC8000; + return 0; + case IA32_MSR_MTRR_FIX4K_D0000: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KD0000; + return 0; + case IA32_MSR_MTRR_FIX4K_D8000: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KD8000; + return 0; + case IA32_MSR_MTRR_FIX4K_E0000: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KE0000; + return 0; + case IA32_MSR_MTRR_FIX4K_E8000: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KE8000; + return 0; + case IA32_MSR_MTRR_FIX4K_F0000: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KF0000; + return 0; + case IA32_MSR_MTRR_FIX4K_F8000: + *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KF8000; + return 0; + case IA32_MSR_TSC_AUX: + *hv_reg =3D HV_X64_REGISTER_TSC_AUX; + return 0; + case IA32_MSR_BNDCFGS: + *hv_reg =3D HV_X64_REGISTER_BNDCFGS; + return 0; + case IA32_MSR_DEBUG_CTL: + *hv_reg =3D HV_X64_REGISTER_DEBUG_CTL; + return 0; + case IA32_MSR_TSC_ADJUST: + *hv_reg =3D HV_X64_REGISTER_TSC_ADJUST; + return 0; + case IA32_MSR_SPEC_CTRL: + *hv_reg =3D HV_X64_REGISTER_SPEC_CTRL; + return 0; + case HV_X64_MSR_GUEST_OS_ID: + *hv_reg =3D HV_REGISTER_GUEST_OS_ID; + return 0; + case HV_X64_MSR_SINT0: + *hv_reg =3D HV_REGISTER_SINT0; + return 0; + case HV_X64_MSR_SINT1: + *hv_reg =3D HV_REGISTER_SINT1; + return 0; + case HV_X64_MSR_SINT2: + *hv_reg =3D HV_REGISTER_SINT2; + return 0; + case HV_X64_MSR_SINT3: + *hv_reg =3D HV_REGISTER_SINT3; + return 0; + case HV_X64_MSR_SINT4: + *hv_reg =3D HV_REGISTER_SINT4; + return 0; + case HV_X64_MSR_SINT5: + *hv_reg =3D HV_REGISTER_SINT5; + return 0; + case HV_X64_MSR_SINT6: + *hv_reg =3D HV_REGISTER_SINT6; + return 0; + case HV_X64_MSR_SINT7: + *hv_reg =3D HV_REGISTER_SINT7; + return 0; + case HV_X64_MSR_SINT8: + *hv_reg =3D HV_REGISTER_SINT8; + return 0; + case HV_X64_MSR_SINT9: + *hv_reg =3D HV_REGISTER_SINT9; + return 0; + case HV_X64_MSR_SINT10: + *hv_reg =3D HV_REGISTER_SINT10; + return 0; + case HV_X64_MSR_SINT11: + *hv_reg =3D HV_REGISTER_SINT11; + return 0; + case HV_X64_MSR_SINT12: + *hv_reg =3D HV_REGISTER_SINT12; + return 0; + case HV_X64_MSR_SINT13: + *hv_reg =3D HV_REGISTER_SINT13; + return 0; + case HV_X64_MSR_SINT14: + *hv_reg =3D HV_REGISTER_SINT14; + return 0; + case HV_X64_MSR_SINT15: + *hv_reg =3D HV_REGISTER_SINT15; + return 0; + case IA32_MSR_MISC_ENABLE: + *hv_reg =3D HV_X64_REGISTER_MSR_IA32_MISC_ENABLE; + return 0; + case HV_X64_MSR_SCONTROL: + *hv_reg =3D HV_REGISTER_SCONTROL; + return 0; + case HV_X64_MSR_SIEFP: + *hv_reg =3D HV_REGISTER_SIEFP; + return 0; + case HV_X64_MSR_SIMP: + *hv_reg =3D HV_REGISTER_SIMP; + return 0; + case HV_X64_MSR_REFERENCE_TSC: + *hv_reg =3D HV_REGISTER_REFERENCE_TSC; + return 0; + case HV_X64_MSR_EOM: + *hv_reg =3D HV_REGISTER_EOM; + return 0; + default: + error_report("failed to map MSR %u to HV register name", msr); + return -1; + } +} + +static int set_msrs(const CPUState *cpu, GList *msrs) +{ + size_t n_msrs; + GList *entries; + MshvMsrEntry *entry; + enum hv_register_name name; + struct hv_register_assoc *assoc; + int ret; + size_t i =3D 0; + + n_msrs =3D g_list_length(msrs); + hv_register_assoc *assocs =3D g_new0(hv_register_assoc, n_msrs); + + entries =3D msrs; + for (const GList *elem =3D entries; elem !=3D NULL; elem =3D elem->nex= t) { + entry =3D elem->data; + ret =3D mshv_msr_to_hv_reg_name(entry->index, &name); + if (ret < 0) { + g_free(assocs); + return ret; + } + assoc =3D &assocs[i]; + assoc->name =3D name; + /* the union has been initialized to 0 */ + assoc->value.reg64 =3D entry->data; + i++; + } + ret =3D mshv_set_generic_regs(cpu, assocs, n_msrs); + g_free(assocs); + if (ret < 0) { + error_report("failed to set msrs"); + return -1; + } + return 0; +} + + +int mshv_configure_msr(const CPUState *cpu, const MshvMsrEntry *msrs, + size_t n_msrs) +{ + GList *valid_msrs =3D NULL; + uint32_t msr_index; + int ret; + + for (size_t i =3D 0; i < n_msrs; i++) { + msr_index =3D msrs[i].index; + /* check whether index of msrs is in SUPPORTED_MSRS */ + if (mshv_is_supported_msr(msr_index)) { + valid_msrs =3D g_list_append(valid_msrs, (void *) &msrs[i]); + } + } + + ret =3D set_msrs(cpu, valid_msrs); + g_list_free(valid_msrs); + + return ret; +} diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 2b7a81274b3..1f43dfc58ac 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -872,6 +872,33 @@ static int set_lint(int cpu_fd) return set_lapic(cpu_fd, &lapic_state); } =20 +static int setup_msrs(const CPUState *cpu) +{ + int ret; + uint64_t default_type =3D MSR_MTRR_ENABLE | MSR_MTRR_MEM_TYPE_WB; + + /* boot msr entries */ + MshvMsrEntry msrs[9] =3D { + { .index =3D IA32_MSR_SYSENTER_CS, .data =3D 0x0, }, + { .index =3D IA32_MSR_SYSENTER_ESP, .data =3D 0x0, }, + { .index =3D IA32_MSR_SYSENTER_EIP, .data =3D 0x0, }, + { .index =3D IA32_MSR_STAR, .data =3D 0x0, }, + { .index =3D IA32_MSR_CSTAR, .data =3D 0x0, }, + { .index =3D IA32_MSR_LSTAR, .data =3D 0x0, }, + { .index =3D IA32_MSR_KERNEL_GS_BASE, .data =3D 0x0, }, + { .index =3D IA32_MSR_SFMASK, .data =3D 0x0, }, + { .index =3D IA32_MSR_MTRR_DEF_TYPE, .data =3D default_type, }, + }; + + ret =3D mshv_configure_msr(cpu, msrs, 9); + if (ret < 0) { + error_report("failed to setup msrs"); + return -1; + } + + return 0; +} + /* * TODO: populate topology info: * @@ -891,6 +918,12 @@ int mshv_configure_vcpu(const CPUState *cpu, const str= uct MshvFPU *fpu, return -1; } =20 + ret =3D setup_msrs(cpu); + if (ret < 0) { + error_report("failed to setup msrs"); + return -1; + } + ret =3D set_cpu_state(cpu, fpu, xcr0); if (ret < 0) { error_report("failed to set cpu state"); diff --git a/accel/mshv/meson.build b/accel/mshv/meson.build index f88fc8678c3..d3a2b325811 100644 --- a/accel/mshv/meson.build +++ b/accel/mshv/meson.build @@ -2,6 +2,7 @@ mshv_ss =3D ss.source_set() mshv_ss.add(if_true: files( 'irq.c', 'mem.c', + 'msr.c', 'mshv-all.c' )) =20 --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996514; cv=none; d=zohomail.com; s=zohoarc; b=mJr7ZDKgkDu5lZAG6nEKZXhDZVBlWlmL4h8ER77tUA/3nEa/xBlmOScdSly9yU9+9tqmX9LhKqh/e/6Fy5DlshtTp0zH+R/rmKL7CZKco4IKUOGoXiKcA3gMHwc5VId8H1lzGOzZXjKC5t9LWHeInhuJbnKLZnTUrbDp56f7HDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996514; 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=F7AoqxUKObbMsXJjOBehknEDHvdGEyjdVUlJubkLvsI=; b=DVItmiommHZYQIjC8/nyUApOw4Zgsl/muUZzqV3KNZIufgn2LrYFOy8j1Ci1hx68JW+wXets/eSYb5dhn0N762ll6GhTonHmeC/n4Mcxi1e4F/BWbRRcu+5gqeDZ0Bh6wSKSyqrGJs1f/bLM1tk8aO6H1arPBWbTJh5iJ8s5wmM= 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 1759996514961827.4247435861744; Thu, 9 Oct 2025 00:55:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lR5-000053-Or; Thu, 09 Oct 2025 03:51:40 -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 1v6lR1-0008Vj-GP for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:35 -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 1v6lQy-0004SY-JM for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:35 -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-271-TnboVIKqMKyV5Dz06kcjfw-1; Thu, 09 Oct 2025 03:51:28 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3ee1365964cso632245f8f.2 for ; Thu, 09 Oct 2025 00:51:28 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fab3d2c1asm30928305e9.1.2025.10.09.00.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996289; 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=F7AoqxUKObbMsXJjOBehknEDHvdGEyjdVUlJubkLvsI=; b=HvSzER380fi8qRycl3XU4ngNv0gMudOHzO/uL4gsoskSFaTyTf230tJDy8p5RCQ8S19p+o hpJL0HqrYVGo/u7t0fqq7UhEqgzX+V7vc2iF1qdxp2MCgI2KhKiVHetpk9BHXB/2Amj12+ jvoZy1pkKjQcTRmKYtqatrnBaijtD0o= X-MC-Unique: TnboVIKqMKyV5Dz06kcjfw-1 X-Mimecast-MFC-AGG-ID: TnboVIKqMKyV5Dz06kcjfw_1759996287 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996286; x=1760601086; 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=F7AoqxUKObbMsXJjOBehknEDHvdGEyjdVUlJubkLvsI=; b=QgkY0If3+UhCcbXDrI9Umeqt7Gj2SkPaaOkYqSulv96XHC5Yn4bj296jIeeLp4XXGT krLRj1L2t9IfIbSv8ODW8yu7f0jonSstkJTFlb1nWjWzoJa3/LMN+UYvYipxr3NUeBzk ABSia/pzr7Fw1mNwYcXtMWVERIgGBQpBYcY07AuDvdYBmpJvpF3GKle2HCL06J2Y8eif uFR322DSTupf1/Buk9qV4nraQ08QHpXfqnr6cELT20RL1noT1YJBObXALZR36smg+FWX Y3z0mEeZUCQJDVMTdjPgibwRTpGZ88kZTMGkbeDJl7FVY3RKPNgm8ewBHuWWEwcS+e4/ o4uw== X-Gm-Message-State: AOJu0YzLkI5BtgXCX+fcKBrPP3OLUmKKBcVNe/A9IWIRXEg3OLpWH3ef pYCDjOwJjegHDCWYtDPzD5UPL/Cfu5YadhWyKoW9ALt1q/c+1uJPb8PE3GPjSnzB0YKks9sJ+pU cKrEe5DUoGAW1nVkPs8tVPF9jgJjI1dugaL7auApNSYadYgAKvJGQ7Yu19lfLfdHpo1OiIwU2a9 5/5HZD55LjJ0I1sParSAeykXAcBLykNooivVbGmVspSMU= X-Gm-Gg: ASbGncuEc3S0fCtwHC+Z2/94WbKNDsmnhj1l9hQG1372kGk+ziB5FNHNSde2Nff26Kc g/D/uNDMfr48yxNc2zlqgEoGhx+0lKsw5hGEBIEpluZFB7GlYbuOe2mpp4c4r4qsQa1JrAWD7Ea kQIss3tDXM2syrlyE3dpV3ALDoqua0xse6LuLPyo1wYgzNkQQjhdwUtYwNAMb8i1fgmBGMJIkZH B5dpr+nBNdjkUqJR22x0YnWN18VvIr+bJw3whzWUPWc+qSU39qq9adWyXPr4mccpk0P9SCT5k4b dGevR0sDDsRe/AHr34xPZIdXfDtM8V1pmBGcWt4+9y6c5iFI7DQ299g4YottZOqpeVjiGCi1Weo 8yqkp2DXeZmhZ2s/weQnVd4CWkMQLbvAj1uVRl3wa+ZSmW127 X-Received: by 2002:a05:6000:186a:b0:425:72cd:835e with SMTP id ffacd0b85a97d-4266e7e140amr3544137f8f.37.1759996286387; Thu, 09 Oct 2025 00:51:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJm6sGFZUx8Q+UmW9VWNxeKb8Bi2e6s13YaR4A4Hyq5qiCyvwdC9X7WAl/u8ge5ov0KGoD3Q== X-Received: by 2002:a05:6000:186a:b0:425:72cd:835e with SMTP id ffacd0b85a97d-4266e7e140amr3544117f8f.37.1759996285842; Thu, 09 Oct 2025 00:51:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 26/35] target/i386/mshv: Integrate x86 instruction decoder/emulator Date: Thu, 9 Oct 2025 09:50:16 +0200 Message-ID: <20251009075026.505715-27-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996517911154100 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Connect the x86 instruction decoder and emulator to the MSHV backend to handle intercepted instructions. This enables software emulation of MMIO operations in MSHV guests. MSHV has a translate_gva hypercall that is used to accessing the physical guest memory. A guest might read from unmapped memory regions (e.g. OVMF will probe 0xfed40000 for a vTPM). In those cases 0xFF bytes is returned instead of aborting the execution. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-21-magnuskulke@linux.m= icrosoft.com [mshv.h/mshv_int.h split. - Paolo] Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 4 ++ accel/mshv/mem.c | 65 +++++++++++++++++ target/i386/mshv/mshv-cpu.c | 135 ++++++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+) diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 66494383134..b29d39911db 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -101,6 +101,10 @@ typedef struct MshvMemoryRegion { bool readonly; } MshvMemoryRegion; =20 +int mshv_guest_mem_read(uint64_t gpa, uint8_t *data, uintptr_t size, + bool is_secure_mode, bool instruction_fetch); +int mshv_guest_mem_write(uint64_t gpa, const uint8_t *data, uintptr_t size, + bool is_secure_mode); void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryRegionSection *secti= on, bool add); =20 diff --git a/accel/mshv/mem.c b/accel/mshv/mem.c index a0a40eb3333..e55c38d4db9 100644 --- a/accel/mshv/mem.c +++ b/accel/mshv/mem.c @@ -59,6 +59,71 @@ static int map_or_unmap(int vm_fd, const MshvMemoryRegio= n *mr, bool map) return set_guest_memory(vm_fd, ®ion); } =20 +static int handle_unmapped_mmio_region_read(uint64_t gpa, uint64_t size, + uint8_t *data) +{ + warn_report("read from unmapped mmio region gpa=3D0x%lx size=3D%lu", g= pa, size); + + if (size =3D=3D 0 || size > 8) { + error_report("invalid size %lu for reading from unmapped mmio regi= on", + size); + return -1; + } + + memset(data, 0xFF, size); + + return 0; +} + +int mshv_guest_mem_read(uint64_t gpa, uint8_t *data, uintptr_t size, + bool is_secure_mode, bool instruction_fetch) +{ + int ret; + MemTxAttrs memattr =3D { .secure =3D is_secure_mode }; + + if (instruction_fetch) { + trace_mshv_insn_fetch(gpa, size); + } else { + trace_mshv_mem_read(gpa, size); + } + + ret =3D address_space_rw(&address_space_memory, gpa, memattr, (void *)= data, + size, false); + if (ret =3D=3D MEMTX_OK) { + return 0; + } + + if (ret =3D=3D MEMTX_DECODE_ERROR) { + return handle_unmapped_mmio_region_read(gpa, size, data); + } + + error_report("failed to read guest memory at 0x%lx", gpa); + return -1; +} + +int mshv_guest_mem_write(uint64_t gpa, const uint8_t *data, uintptr_t size, + bool is_secure_mode) +{ + int ret; + MemTxAttrs memattr =3D { .secure =3D is_secure_mode }; + + trace_mshv_mem_write(gpa, size); + ret =3D address_space_rw(&address_space_memory, gpa, memattr, (void *)= data, + size, true); + if (ret =3D=3D MEMTX_OK) { + return 0; + } + + if (ret =3D=3D MEMTX_DECODE_ERROR) { + warn_report("write to unmapped mmio region gpa=3D0x%lx size=3D%lu"= , gpa, + size); + return 0; + } + + error_report("Failed to write guest memory"); + return -1; +} + static int set_memory(const MshvMemoryRegion *mshv_mr, bool add) { int ret =3D 0; diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 1f43dfc58ac..424ebdb1228 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -104,6 +104,47 @@ static enum hv_register_name FPU_REGISTER_NAMES[26] = =3D { HV_X64_REGISTER_XMM_CONTROL_STATUS, }; =20 +static int translate_gva(const CPUState *cpu, uint64_t gva, uint64_t *gpa, + uint64_t flags) +{ + int ret; + int cpu_fd =3D mshv_vcpufd(cpu); + int vp_index =3D cpu->cpu_index; + + hv_input_translate_virtual_address in =3D { 0 }; + hv_output_translate_virtual_address out =3D { 0 }; + struct mshv_root_hvcall args =3D {0}; + uint64_t gva_page =3D gva >> HV_HYP_PAGE_SHIFT; + + in.vp_index =3D vp_index; + in.control_flags =3D flags; + in.gva_page =3D gva_page; + + /* create the hvcall envelope */ + args.code =3D HVCALL_TRANSLATE_VIRTUAL_ADDRESS; + args.in_sz =3D sizeof(in); + args.in_ptr =3D (uint64_t) ∈ + args.out_sz =3D sizeof(out); + args.out_ptr =3D (uint64_t) &out; + + /* perform the call */ + ret =3D mshv_hvcall(cpu_fd, &args); + if (ret < 0) { + error_report("Failed to invoke gva->gpa translation"); + return -errno; + } + + if (out.translation_result.result_code !=3D HV_TRANSLATE_GVA_SUCCESS) { + error_report("Failed to translate gva (" TARGET_FMT_lx ") to gpa",= gva); + return -1; + } + + *gpa =3D ((out.gpa_page << HV_HYP_PAGE_SHIFT) + | (gva & ~(uint64_t)HV_HYP_PAGE_MASK)); + + return 0; +} + int mshv_set_generic_regs(const CPUState *cpu, const hv_register_assoc *as= socs, size_t n_regs) { @@ -1006,8 +1047,102 @@ int mshv_create_vcpu(int vm_fd, uint8_t vp_index, i= nt *cpu_fd) return 0; } =20 +static int guest_mem_read_with_gva(const CPUState *cpu, uint64_t gva, + uint8_t *data, uintptr_t size, + bool fetch_instruction) +{ + int ret; + uint64_t gpa, flags; + + flags =3D HV_TRANSLATE_GVA_VALIDATE_READ; + ret =3D translate_gva(cpu, gva, &gpa, flags); + if (ret < 0) { + error_report("failed to translate gva to gpa"); + return -1; + } + + ret =3D mshv_guest_mem_read(gpa, data, size, false, fetch_instruction); + if (ret < 0) { + error_report("failed to read from guest memory"); + return -1; + } + + return 0; +} + +static int guest_mem_write_with_gva(const CPUState *cpu, uint64_t gva, + const uint8_t *data, uintptr_t size) +{ + int ret; + uint64_t gpa, flags; + + flags =3D HV_TRANSLATE_GVA_VALIDATE_WRITE; + ret =3D translate_gva(cpu, gva, &gpa, flags); + if (ret < 0) { + error_report("failed to translate gva to gpa"); + return -1; + } + ret =3D mshv_guest_mem_write(gpa, data, size, false); + if (ret < 0) { + error_report("failed to write to guest memory"); + return -1; + } + return 0; +} + +static void write_mem(CPUState *cpu, void *data, target_ulong addr, int by= tes) +{ + if (guest_mem_write_with_gva(cpu, addr, data, bytes) < 0) { + error_report("failed to write memory"); + abort(); + } +} + +static void fetch_instruction(CPUState *cpu, void *data, + target_ulong addr, int bytes) +{ + if (guest_mem_read_with_gva(cpu, addr, data, bytes, true) < 0) { + error_report("failed to fetch instruction"); + abort(); + } +} + +static void read_mem(CPUState *cpu, void *data, target_ulong addr, int byt= es) +{ + if (guest_mem_read_with_gva(cpu, addr, data, bytes, false) < 0) { + error_report("failed to read memory"); + abort(); + } +} + +static void read_segment_descriptor(CPUState *cpu, + struct x86_segment_descriptor *desc, + enum X86Seg seg_idx) +{ + bool ret; + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + SegmentCache *seg =3D &env->segs[seg_idx]; + x86_segment_selector sel =3D { .sel =3D seg->selector & 0xFFFF }; + + ret =3D x86_read_segment_descriptor(cpu, desc, sel); + if (ret =3D=3D false) { + error_report("failed to read segment descriptor"); + abort(); + } +} + +static const struct x86_emul_ops mshv_x86_emul_ops =3D { + .fetch_instruction =3D fetch_instruction, + .read_mem =3D read_mem, + .write_mem =3D write_mem, + .read_segment_descriptor =3D read_segment_descriptor, +}; + void mshv_init_mmio_emu(void) { + init_decoder(); + init_emu(&mshv_x86_emul_ops); } =20 void mshv_arch_init_vcpu(CPUState *cpu) --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996453; cv=none; d=zohomail.com; s=zohoarc; b=MnB1FKqroRdZlnZUm3XkP482KsX9Aq5euLvXDXkfywUDs4W2LjZdMh3g7s4j0cZHLR65eIrJ3CSAvbfJ38pXSS6/MNgmqPHciUAww6mghDblY3dFtnqzmFZMuKSFdFj/Q0RR5nF+VUa4epghdgmCPfE7Y3UJzVTPPKuGgVh8EXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996453; 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=E6w7VzOtHR3BZVmb/GNxbKkCwO8qv7ohv9fFtyVvBzo=; b=NBOh+AEULC/Mc/3fFwZ2bMd25jlHy3eDQpORxOwR2VxLjB1tTsq1806UNJ5zS4qVR8B2o9JkvENnKJF4s26OWNFRU5wdrNRPrwXMfkPH8YjxFFg/DIzuni49w+TvuyxFOK0QLvS8CC2FV/8mfuc0mNqKfQ8136t8+z2n1HpTMUo= 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 1759996453934669.0849750141227; Thu, 9 Oct 2025 00:54:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lR5-000051-5x; Thu, 09 Oct 2025 03:51: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 1v6lR2-0008WE-9q for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:36 -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 1v6lQz-0004Sr-3O for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:36 -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-639-nhAa99paNgCdjevK9p0Icw-1; Thu, 09 Oct 2025 03:51:30 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e3ed6540fso4538915e9.0 for ; Thu, 09 Oct 2025 00:51:30 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46faf17b82bsm33438305e9.15.2025.10.09.00.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996291; 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=E6w7VzOtHR3BZVmb/GNxbKkCwO8qv7ohv9fFtyVvBzo=; b=fF3u0NcF/L+AMWLWLbCHLEvKxB6a7MlLsQQWQgDbs4ZFrXRNiBiwQhSjrdmQDJJ+6PpO8i I/3BKYjrokVymYYGylRYqy57vfdkO7KCrumVrF1zCuLQmWliaPoFLEaypDcVFLiiJFe559 LDfzw+mMag51G5z2v+p3qRy2xWNvIMU= X-MC-Unique: nhAa99paNgCdjevK9p0Icw-1 X-Mimecast-MFC-AGG-ID: nhAa99paNgCdjevK9p0Icw_1759996289 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996288; x=1760601088; 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=E6w7VzOtHR3BZVmb/GNxbKkCwO8qv7ohv9fFtyVvBzo=; b=bH2dCTFZrI6AzAxbjpeeKhUkKYohGbEnotJg+SLYSc9aql4gid6vo0yyLYKLi3dS1J PxCTsdHBFHRdsFRNQdkbK0spYQhUEk5GFGaDGsuO1OhfFI3BJ6nRncd+asqdqoOwpI1n IvKxyeek++BtadaAI50HSjKQMvZ5pgKA7LegEUsKA059eB/dv4GNf26IVhziG0BGefIy MZVl0R9yAvXs33QFcWRpLV7ET4LZSmRHZYGdWw0y/dzr4mInfSJn+2cwbJAgyetX126X YibyjrVlAb2N0129NvNKk0LS7wADB1sxaTF7c0KSp+jU77SnTwAW5Vq6n/9e3oo74QRz h1bw== X-Gm-Message-State: AOJu0Yzu544ACCRTLAs6ejSanNApmYeeGh9EHje6KzDXP+nnley7sb/G /nbysaAE8J8SY0vUmGysmHaLljG2hmEjwCQxfLUXG7VZz3gqxn8+d3Nh92nuOzb5d+UeFaW7Eaq A6fE/O7YK499Ita7uEyUKbT6sGWVA32qY1OU/khIDX/AvMelUy0sHeVKbR4cYbUIDmoZ4PLP7ql UERnAxmi1RlbH4vX2KR1JGz587PjFfG120nS9hI96s1C4= X-Gm-Gg: ASbGncvlfKxEk4Pa9MWGIF8Il+iMS+qqNENRy0/NrOlBUYyy8LnrPanIaV/2Rf7GG7X 5Bw062SRGa+fXcvk8nWg/b7WFUWoowNaXMDH0nG96y06FDZ7W9sWH9x+oDSca/qOB4+5HfBc/Tt KUKqDi4wP28ve55os63dYMLQiENoI9P5ACGiJR31uPaLaYvxIiwRyRA9NB4wR6duPMJH8sTg+9j T9YniX2J/iuaeIUK0AIZi33FAQj1ofZnjV0nQ1pRpMt5AsfnqdO5OWBu4Qm2wWjdvFcFWHiehXA tZ62pMjAQNy3iafx7KhdlzqNxghZHap/53lMegPJR/MizQz/iIYnBCms186NMlJ82uLXZHmOlGC Vt8e+TuLG8lUc4zVS8JZ4GKMYZytwG8dZw4N87WeQ1ln98oF+ X-Received: by 2002:a05:600c:6a07:b0:46e:74bb:6bd with SMTP id 5b1f17b1804b1-46fa2952c89mr55072155e9.4.1759996288557; Thu, 09 Oct 2025 00:51:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuKEhRlcHDyUNZBk8Ba7Kh4nkdjuEb3sxsQGHMtqJXZJgKXBD4e7miOQaZD/nsjWlgQvKPnA== X-Received: by 2002:a05:600c:6a07:b0:46e:74bb:6bd with SMTP id 5b1f17b1804b1-46fa2952c89mr55071985e9.4.1759996288058; Thu, 09 Oct 2025 00:51:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 27/35] target/i386/mshv: Write MSRs to the hypervisor Date: Thu, 9 Oct 2025 09:50:17 +0200 Message-ID: <20251009075026.505715-28-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996455256154100 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Push current model-specific register (MSR) values to MSHV's vCPUs as part of setting state to the hypervisor. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-22-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- target/i386/mshv/mshv-cpu.c | 68 +++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 424ebdb1228..33a3ce8b110 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -998,6 +998,65 @@ static int put_regs(const CPUState *cpu) return 0; } =20 +struct MsrPair { + uint32_t index; + uint64_t value; +}; + +static int put_msrs(const CPUState *cpu) +{ + int ret =3D 0; + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + MshvMsrEntries *msrs =3D g_malloc0(sizeof(MshvMsrEntries)); + + struct MsrPair pairs[] =3D { + { MSR_IA32_SYSENTER_CS, env->sysenter_cs }, + { MSR_IA32_SYSENTER_ESP, env->sysenter_esp }, + { MSR_IA32_SYSENTER_EIP, env->sysenter_eip }, + { MSR_EFER, env->efer }, + { MSR_PAT, env->pat }, + { MSR_STAR, env->star }, + { MSR_CSTAR, env->cstar }, + { MSR_LSTAR, env->lstar }, + { MSR_KERNELGSBASE, env->kernelgsbase }, + { MSR_FMASK, env->fmask }, + { MSR_MTRRdefType, env->mtrr_deftype }, + { MSR_VM_HSAVE_PA, env->vm_hsave }, + { MSR_SMI_COUNT, env->msr_smi_count }, + { MSR_IA32_PKRS, env->pkrs }, + { MSR_IA32_BNDCFGS, env->msr_bndcfgs }, + { MSR_IA32_XSS, env->xss }, + { MSR_IA32_UMWAIT_CONTROL, env->umwait }, + { MSR_IA32_TSX_CTRL, env->tsx_ctrl }, + { MSR_AMD64_TSC_RATIO, env->amd_tsc_scale_msr }, + { MSR_TSC_AUX, env->tsc_aux }, + { MSR_TSC_ADJUST, env->tsc_adjust }, + { MSR_IA32_SMBASE, env->smbase }, + { MSR_IA32_SPEC_CTRL, env->spec_ctrl }, + { MSR_VIRT_SSBD, env->virt_ssbd }, + }; + + if (ARRAY_SIZE(pairs) > MSHV_MSR_ENTRIES_COUNT) { + error_report("MSR entries exceed maximum size"); + g_free(msrs); + return -1; + } + + for (size_t i =3D 0; i < ARRAY_SIZE(pairs); i++) { + MshvMsrEntry *entry =3D &msrs->entries[i]; + entry->index =3D pairs[i].index; + entry->reserved =3D 0; + entry->data =3D pairs[i].value; + msrs->nmsrs++; + } + + ret =3D mshv_configure_msr(cpu, &msrs->entries[0], msrs->nmsrs); + g_free(msrs); + return ret; +} + + int mshv_arch_put_registers(const CPUState *cpu) { int ret; @@ -1008,8 +1067,13 @@ int mshv_arch_put_registers(const CPUState *cpu) return -1; } =20 - error_report("unimplemented"); - abort(); + ret =3D put_msrs(cpu); + if (ret < 0) { + error_report("Failed to put msrs"); + return -1; + } + + return 0; } =20 void mshv_arch_amend_proc_features( --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996593; cv=none; d=zohomail.com; s=zohoarc; b=fMb1jWt6j/o/Q5MxSIgr02EfWxjLXFHfAQxN97hKZEzaamp9roTfbCN4opskRcDCgCrF+6JP+51jvbluPhvsEcoGHMjdLHsBXsiu0QWOy8DBIniKpKxianPi9TDLWvYl40yub+3VTOW9wyQKF4pKa2rBh6vUvO8o/k+T6ziV808= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996593; 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=uB+V3u/aPrqwLddsF879FaTd8eb+vL09HILtMavahqo=; b=TKS9fdlBpMofaLnjHXQ7xre3PW8JquM6T+Pk3gyVQtWnfePrTl0VvRXwgGckqsrZvRwXepi3y92FOd9hyxrqr3BMYA+edTe82KzTEPfgbLQ+X128MFYvueRVIWpbP1VmA7ucLHOyzyjEP1O3BLVu/tPMMv2e/mmEpxwGjkDm+9E= 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 1759996593513691.4365463122871; Thu, 9 Oct 2025 00:56:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lRA-00009H-5h; Thu, 09 Oct 2025 03:51: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 1v6lR8-00007u-Bt for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:42 -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 1v6lR2-0004TN-Sl for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:42 -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-395-jjLBk_oXP5icr2sr-qk49w-1; Thu, 09 Oct 2025 03:51:33 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-41066f050a4so386717f8f.1 for ; Thu, 09 Oct 2025 00:51:33 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8e97fbsm33139531f8f.34.2025.10.09.00.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996295; 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=uB+V3u/aPrqwLddsF879FaTd8eb+vL09HILtMavahqo=; b=NQAZWp3aTGU3fh6sWZLkEWi2fOB1FeXdaST5AAxuNkzDHAAmm7W6LycyQ5Jrr0dR/myHzl 70qHKrYOKCs0e/PtUO+3ZzxhSTn2RlkQrZ5IDcRsYrkLVNbXXYextGcJtv2MV/EUsvIERO NTXfQzfJXnby3Yqwv9Bc9ZSboTQSX8I= X-MC-Unique: jjLBk_oXP5icr2sr-qk49w-1 X-Mimecast-MFC-AGG-ID: jjLBk_oXP5icr2sr-qk49w_1759996293 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996291; x=1760601091; 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=uB+V3u/aPrqwLddsF879FaTd8eb+vL09HILtMavahqo=; b=ESaabvqGJeunSGgX9IPpIkblYLpWAFbZekD3xsRlBolFs9iIOsMAfCck45kgh3liI1 GVmQoOU2yKqvrNrLmeg/bZxFDN7sFVPf+pfPW2ZfqEoNXKm8Pmiifu2kEdD4C0u+pIFf fph2qqdgQ5rZwBBXD6t/sxIdHXqF9ECC/DLGomKOmz5pzJbUMwX1Uepa8xT7wEnJxJhp /8Z2cWfqZ5W46ZprhUwyjhKCt9LY9sEObidlaycBqJf/DNgeIwotDm3H6/w8HuMSfxbx 3ZCbV4mGzQXqBBttSkYJHTonE7MFlQ8QhMMvCghfPcDE/QIo6cQy4JEwS5Ab8kAa+LlE xhKw== X-Gm-Message-State: AOJu0YyMBo0w+e3XTCjeDD9FUH9cbPRGCyGBDj9tuKeh5Qf0dVuKE537 y3YLubaNVE4sVqaYChcV+UsLfkjKwJu0pBL8xE6/smsNxDkmFEceYCqm3q1HFlcX6ixfAG9k9XR cOOV8JjM+Xvj38b0fDA128IpOoaCwoZpQ1K9LLDy3F1xjwxS2xjhXCNfMr0iQ/GmOKnM5r7Ebqa uKCDCBhxjthd9Hr/HZawLm8TYby9lACxPbATMydMM23do= X-Gm-Gg: ASbGncvY1edoI7h7uhUIg57fHcb3rq7BZtudhEDY95kuRaKdROB0Q4VUtw15JJfflSB DBGXiANsIvvBfeVd11iokQ7QMWao/Pd6RQ5Fdp28L8XAvS2aOLpt4N5nPge7yUCitHb/3DenCi+ F7McUv5BJ/nE8UDudtARmqSDqhje4OCcgdh3Vv9pGFW8nxZyaE0jJXqiNGREmqvNIY+09QZVJLK qeenMMfkG2Xbq2k1FW5jiqyaKqQ9lrg9qzLejJqnJtqn3MJo5vvvVe5e+vHVFl9rBpCq154vmON lAxF6PJP6oEblEogq9DYeq6S0nCAI4eznXl3x/9VcIAk0wAIi78fe8c0VWPdJAlGAww2xtmjZxd U4sHzx1OV9RapZioO7EFwklSra3cD4NaVKv7vJkvNo1QdC73X X-Received: by 2002:a05:6000:2c0d:b0:3e9:9282:cfdf with SMTP id ffacd0b85a97d-4266e8d777bmr4026400f8f.41.1759996291130; Thu, 09 Oct 2025 00:51:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGczbXWVL2aWvb6Pxa50DHzHGLyehHz6kU28lBmnHI94yWWpjBN10sij+q8Xgc7Qsj9T2AbjA== X-Received: by 2002:a05:6000:2c0d:b0:3e9:9282:cfdf with SMTP id ffacd0b85a97d-4266e8d777bmr4026374f8f.41.1759996290592; Thu, 09 Oct 2025 00:51:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 28/35] target/i386/mshv: Implement mshv_vcpu_run() Date: Thu, 9 Oct 2025 09:50:18 +0200 Message-ID: <20251009075026.505715-29-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996602514116600 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Add the main vCPU execution loop for MSHV using the MSHV_RUN_VP ioctl. The execution loop handles guest entry and VM exits. There are handlers for memory r/w, PIO and MMIO to which the exit events are dispatched. In case of MMIO the i386 instruction decoder/emulator is invoked to perform the operation in user space. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-23-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- target/i386/mshv/mshv-cpu.c | 444 +++++++++++++++++++++++++++++++++++- 1 file changed, 442 insertions(+), 2 deletions(-) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 33a3ce8b110..7edc032cea3 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -1082,10 +1082,450 @@ void mshv_arch_amend_proc_features( features->access_guest_idle_reg =3D 1; } =20 +static int set_memory_info(const struct hyperv_message *msg, + struct hv_x64_memory_intercept_message *info) +{ + if (msg->header.message_type !=3D HVMSG_GPA_INTERCEPT + && msg->header.message_type !=3D HVMSG_UNMAPPED_GPA + && msg->header.message_type !=3D HVMSG_UNACCEPTED_GPA) { + error_report("invalid message type"); + return -1; + } + memcpy(info, msg->payload, sizeof(*info)); + + return 0; +} + +static int emulate_instruction(CPUState *cpu, + const uint8_t *insn_bytes, size_t insn_len, + uint64_t gva, uint64_t gpa) +{ + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + struct x86_decode decode =3D { 0 }; + int ret; + x86_insn_stream stream =3D { .bytes =3D insn_bytes, .len =3D insn_len = }; + + ret =3D mshv_load_regs(cpu); + if (ret < 0) { + error_report("failed to load registers"); + return -1; + } + + decode_instruction_stream(env, &decode, &stream); + exec_instruction(env, &decode); + + ret =3D mshv_store_regs(cpu); + if (ret < 0) { + error_report("failed to store registers"); + return -1; + } + + return 0; +} + +static int handle_mmio(CPUState *cpu, const struct hyperv_message *msg, + MshvVmExit *exit_reason) +{ + struct hv_x64_memory_intercept_message info =3D { 0 }; + size_t insn_len; + uint8_t access_type; + uint8_t *instruction_bytes; + int ret; + + ret =3D set_memory_info(msg, &info); + if (ret < 0) { + error_report("failed to convert message to memory info"); + return -1; + } + insn_len =3D info.instruction_byte_count; + access_type =3D info.header.intercept_access_type; + + if (access_type =3D=3D HV_X64_INTERCEPT_ACCESS_TYPE_EXECUTE) { + error_report("invalid intercept access type: execute"); + return -1; + } + + if (insn_len > 16) { + error_report("invalid mmio instruction length: %zu", insn_len); + return -1; + } + + trace_mshv_handle_mmio(info.guest_virtual_address, + info.guest_physical_address, + info.instruction_byte_count, access_type); + + instruction_bytes =3D info.instruction_bytes; + + ret =3D emulate_instruction(cpu, instruction_bytes, insn_len, + info.guest_virtual_address, + info.guest_physical_address); + if (ret < 0) { + error_report("failed to emulate mmio"); + return -1; + } + + *exit_reason =3D MshvVmExitIgnore; + + return 0; +} + +static int set_ioport_info(const struct hyperv_message *msg, + hv_x64_io_port_intercept_message *info) +{ + if (msg->header.message_type !=3D HVMSG_X64_IO_PORT_INTERCEPT) { + error_report("Invalid message type"); + return -1; + } + memcpy(info, msg->payload, sizeof(*info)); + + return 0; +} + +static int set_x64_registers(const CPUState *cpu, const uint32_t *names, + const uint64_t *values) +{ + + hv_register_assoc assocs[2]; + int ret; + + for (size_t i =3D 0; i < ARRAY_SIZE(assocs); i++) { + assocs[i].name =3D names[i]; + assocs[i].value.reg64 =3D values[i]; + } + + ret =3D mshv_set_generic_regs(cpu, assocs, ARRAY_SIZE(assocs)); + if (ret < 0) { + error_report("failed to set x64 registers"); + return -1; + } + + return 0; +} + +static inline MemTxAttrs get_mem_attrs(bool is_secure_mode) +{ + MemTxAttrs memattr =3D {0}; + memattr.secure =3D is_secure_mode; + return memattr; +} + +static void pio_read(uint64_t port, uint8_t *data, uintptr_t size, + bool is_secure_mode) +{ + int ret =3D 0; + MemTxAttrs memattr =3D get_mem_attrs(is_secure_mode); + ret =3D address_space_rw(&address_space_io, port, memattr, (void *)dat= a, size, + false); + if (ret !=3D MEMTX_OK) { + error_report("Failed to read from port %lx: %d", port, ret); + abort(); + } +} + +static int pio_write(uint64_t port, const uint8_t *data, uintptr_t size, + bool is_secure_mode) +{ + int ret =3D 0; + MemTxAttrs memattr =3D get_mem_attrs(is_secure_mode); + ret =3D address_space_rw(&address_space_io, port, memattr, (void *)dat= a, size, + true); + return ret; +} + +static int handle_pio_non_str(const CPUState *cpu, + hv_x64_io_port_intercept_message *info) +{ + size_t len =3D info->access_info.access_size; + uint8_t access_type =3D info->header.intercept_access_type; + int ret; + uint32_t val, eax; + const uint32_t eax_mask =3D 0xffffffffu >> (32 - len * 8); + size_t insn_len; + uint64_t rip, rax; + uint32_t reg_names[2]; + uint64_t reg_values[2]; + uint16_t port =3D info->port_number; + + if (access_type =3D=3D HV_X64_INTERCEPT_ACCESS_TYPE_WRITE) { + union { + uint32_t u32; + uint8_t bytes[4]; + } conv; + + /* convert the first 4 bytes of rax to bytes */ + conv.u32 =3D (uint32_t)info->rax; + /* secure mode is set to false */ + ret =3D pio_write(port, conv.bytes, len, false); + if (ret < 0) { + error_report("Failed to write to io port"); + return -1; + } + } else { + uint8_t data[4] =3D { 0 }; + /* secure mode is set to false */ + pio_read(info->port_number, data, len, false); + + /* Preserve high bits in EAX, but clear out high bits in RAX */ + val =3D *(uint32_t *)data; + eax =3D (((uint32_t)info->rax) & ~eax_mask) | (val & eax_mask); + info->rax =3D (uint64_t)eax; + } + + insn_len =3D info->header.instruction_length; + + /* Advance RIP and update RAX */ + rip =3D info->header.rip + insn_len; + rax =3D info->rax; + + reg_names[0] =3D HV_X64_REGISTER_RIP; + reg_values[0] =3D rip; + reg_names[1] =3D HV_X64_REGISTER_RAX; + reg_values[1] =3D rax; + + ret =3D set_x64_registers(cpu, reg_names, reg_values); + if (ret < 0) { + error_report("Failed to set x64 registers"); + return -1; + } + + cpu->accel->dirty =3D false; + + return 0; +} + +static int fetch_guest_state(CPUState *cpu) +{ + int ret; + + ret =3D mshv_get_standard_regs(cpu); + if (ret < 0) { + error_report("Failed to get standard registers"); + return -1; + } + + ret =3D mshv_get_special_regs(cpu); + if (ret < 0) { + error_report("Failed to get special registers"); + return -1; + } + + return 0; +} + +static int read_memory(const CPUState *cpu, uint64_t initial_gva, + uint64_t initial_gpa, uint64_t gva, uint8_t *data, + size_t len) +{ + int ret; + uint64_t gpa, flags; + + if (gva =3D=3D initial_gva) { + gpa =3D initial_gpa; + } else { + flags =3D HV_TRANSLATE_GVA_VALIDATE_READ; + ret =3D translate_gva(cpu, gva, &gpa, flags); + if (ret < 0) { + return -1; + } + + ret =3D mshv_guest_mem_read(gpa, data, len, false, false); + if (ret < 0) { + error_report("failed to read guest mem"); + return -1; + } + } + + return 0; +} + +static int write_memory(const CPUState *cpu, uint64_t initial_gva, + uint64_t initial_gpa, uint64_t gva, const uint8_t = *data, + size_t len) +{ + int ret; + uint64_t gpa, flags; + + if (gva =3D=3D initial_gva) { + gpa =3D initial_gpa; + } else { + flags =3D HV_TRANSLATE_GVA_VALIDATE_WRITE; + ret =3D translate_gva(cpu, gva, &gpa, flags); + if (ret < 0) { + error_report("failed to translate gva to gpa"); + return -1; + } + } + ret =3D mshv_guest_mem_write(gpa, data, len, false); + if (ret !=3D MEMTX_OK) { + error_report("failed to write to mmio"); + return -1; + } + + return 0; +} + +static int handle_pio_str_write(CPUState *cpu, + hv_x64_io_port_intercept_message *info, + size_t repeat, uint16_t port, + bool direction_flag) +{ + int ret; + uint64_t src; + uint8_t data[4] =3D { 0 }; + size_t len =3D info->access_info.access_size; + + src =3D linear_addr(cpu, info->rsi, R_DS); + + for (size_t i =3D 0; i < repeat; i++) { + ret =3D read_memory(cpu, 0, 0, src, data, len); + if (ret < 0) { + error_report("Failed to read memory"); + return -1; + } + ret =3D pio_write(port, data, len, false); + if (ret < 0) { + error_report("Failed to write to io port"); + return -1; + } + src +=3D direction_flag ? -len : len; + info->rsi +=3D direction_flag ? -len : len; + } + + return 0; +} + +static int handle_pio_str_read(CPUState *cpu, + hv_x64_io_port_intercept_message *info, + size_t repeat, uint16_t port, + bool direction_flag) +{ + int ret; + uint64_t dst; + size_t len =3D info->access_info.access_size; + uint8_t data[4] =3D { 0 }; + + dst =3D linear_addr(cpu, info->rdi, R_ES); + + for (size_t i =3D 0; i < repeat; i++) { + pio_read(port, data, len, false); + + ret =3D write_memory(cpu, 0, 0, dst, data, len); + if (ret < 0) { + error_report("Failed to write memory"); + return -1; + } + dst +=3D direction_flag ? -len : len; + info->rdi +=3D direction_flag ? -len : len; + } + + return 0; +} + +static int handle_pio_str(CPUState *cpu, hv_x64_io_port_intercept_message = *info) +{ + uint8_t access_type =3D info->header.intercept_access_type; + uint16_t port =3D info->port_number; + bool repop =3D info->access_info.rep_prefix =3D=3D 1; + size_t repeat =3D repop ? info->rcx : 1; + size_t insn_len =3D info->header.instruction_length; + bool direction_flag; + uint32_t reg_names[3]; + uint64_t reg_values[3]; + int ret; + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + + ret =3D fetch_guest_state(cpu); + if (ret < 0) { + error_report("Failed to fetch guest state"); + return -1; + } + + direction_flag =3D (env->eflags & DESC_E_MASK) !=3D 0; + + if (access_type =3D=3D HV_X64_INTERCEPT_ACCESS_TYPE_WRITE) { + ret =3D handle_pio_str_write(cpu, info, repeat, port, direction_fl= ag); + if (ret < 0) { + error_report("Failed to handle pio str write"); + return -1; + } + reg_names[0] =3D HV_X64_REGISTER_RSI; + reg_values[0] =3D info->rsi; + } else { + ret =3D handle_pio_str_read(cpu, info, repeat, port, direction_fla= g); + reg_names[0] =3D HV_X64_REGISTER_RDI; + reg_values[0] =3D info->rdi; + } + + reg_names[1] =3D HV_X64_REGISTER_RIP; + reg_values[1] =3D info->header.rip + insn_len; + reg_names[2] =3D HV_X64_REGISTER_RAX; + reg_values[2] =3D info->rax; + + ret =3D set_x64_registers(cpu, reg_names, reg_values); + if (ret < 0) { + error_report("Failed to set x64 registers"); + return -1; + } + + cpu->accel->dirty =3D false; + + return 0; +} + +static int handle_pio(CPUState *cpu, const struct hyperv_message *msg) +{ + struct hv_x64_io_port_intercept_message info =3D { 0 }; + int ret; + + ret =3D set_ioport_info(msg, &info); + if (ret < 0) { + error_report("Failed to convert message to ioport info"); + return -1; + } + + if (info.access_info.string_op) { + return handle_pio_str(cpu, &info); + } + + return handle_pio_non_str(cpu, &info); +} + int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *e= xit) { - error_report("unimplemented"); - abort(); + int ret; + enum MshvVmExit exit_reason; + int cpu_fd =3D mshv_vcpufd(cpu); + + ret =3D ioctl(cpu_fd, MSHV_RUN_VP, msg); + if (ret < 0) { + return MshvVmExitShutdown; + } + + switch (msg->header.message_type) { + case HVMSG_UNRECOVERABLE_EXCEPTION: + return MshvVmExitShutdown; + case HVMSG_UNMAPPED_GPA: + case HVMSG_GPA_INTERCEPT: + ret =3D handle_mmio(cpu, msg, &exit_reason); + if (ret < 0) { + error_report("failed to handle mmio"); + return -1; + } + return exit_reason; + case HVMSG_X64_IO_PORT_INTERCEPT: + ret =3D handle_pio(cpu, msg); + if (ret < 0) { + return MshvVmExitSpecial; + } + return MshvVmExitIgnore; + default: + break; + } + + *exit =3D MshvVmExitIgnore; + return 0; } =20 void mshv_remove_vcpu(int vm_fd, int cpu_fd) --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996575; cv=none; d=zohomail.com; s=zohoarc; b=i+RsaXdAY+coA1Q2MWtwtIH19cNiPK4NNgT/xB3Etjv9puujbMSUYR6JNPIcnXajOLcQK8S2HYdm00QcXQWoEwdCqG82upN/evjv++DixDU6KFWs3bGs71B8HwkkilLAdcvN8TpxHVJQaWcOiNYYdrzyDlOillm291SFCIyvHR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996575; 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=u30x/55IvFNCQpDjqbfcuUoNhz5W2rD1TNjSa+BpMjw=; b=WJJTHvBlBDROSY6CQpZLA4sehl8f3UOWR4MaHth05cm3/+lx50g3V4JWyqTyKhcV34C2fEJTxtokbzfketB/cub+qKw6DCFZgcy9ZZ/sYDjhSuMQjbU3V5tdM2sEUXMp5HKdrnjKhdcJ1rQXRWHkOWX/k3JYoyu64y3Ddz3/hPc= 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 1759996575972942.9177859281228; Thu, 9 Oct 2025 00:56:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lRE-0000BM-1e; Thu, 09 Oct 2025 03:51:48 -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 1v6lRB-00009s-Uy for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51: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 1v6lR6-0004Tm-KG for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:45 -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-612-YSMro4xWMr-DyUo1fJvShg-1; Thu, 09 Oct 2025 03:51:35 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-42421b15185so548626f8f.1 for ; Thu, 09 Oct 2025 00:51:35 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8abf38sm32988750f8f.20.2025.10.09.00.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996298; 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=u30x/55IvFNCQpDjqbfcuUoNhz5W2rD1TNjSa+BpMjw=; b=bJ7EYfoZBf5ImaSHqN72/BjIETa2C+ts6LmAo3gA7xAbAIkHZU6UoblJV4W/oRFl+fKp05 MiTmbbNr3s5SuOxKcVIW/QaeCaFEJlabGStivTmYJqCbyUSuLwwycOyF9sZ2n0/fbvjdU4 Z6wOHkq5q+x2q97DJN2ZQWdJXiSvrJM= X-MC-Unique: YSMro4xWMr-DyUo1fJvShg-1 X-Mimecast-MFC-AGG-ID: YSMro4xWMr-DyUo1fJvShg_1759996294 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996293; x=1760601093; 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=u30x/55IvFNCQpDjqbfcuUoNhz5W2rD1TNjSa+BpMjw=; b=AhWVSBzfXp+6bv1EnUOrZyslxmiXQD7CgzvPfv+qku/RBpbnyVO3xq39AUgSE42Lvi 09JkHbO4MWhitEy+GqFxCAgThdsm2mNudXsJwtKCwlb11fTA70PLoH8zMgAYl1I0zWBD CYTWayGM87PZQ7A7cna0RQAdeQkr9UGI+ij0v6EthR/zuWIYwGxGKGjOivsLny0ECkHl VEW7cJGmeZrCzHwYn5+qVcU7vthpNlP4C8jYRP8FUJfKPWc//nH4MUVbn/pFKnD1jefn NsSmpAWv4siOXYipE3EFpGMnjBQUs3Hp9AAM/8gBvBn26obljr8Fn2KKA9lYzV+IBFoy YG8g== X-Gm-Message-State: AOJu0YxN2V1j92yvV4ZtbjH9IUF/qVk2ykhlKfp9nvX2mn4hiccjiS+W y+LDRdA8TqA3ZWYKOIILVRfQo2FGNJZJBusjZGnG5hRFz8rnnDmfjoGn1GUQbF06UPVqZsWOeMY HhZWXih+4AnVjV1YAMPn9ffzdPnB1J/BOcrZg+1hk7FL0EPM4PsKtqqR9JWEJS+yB2mjhPYS3UY 34YbktAqBHTWnXRn2VfSh0H4gQSQxBytndDamtRuoj2FI= X-Gm-Gg: ASbGnctvzkRG8cBUjGrdOqrLtPSolCFENe2JQmj30JrLEP8rwsg+XUecYvmkxK1Pht3 EqOTANCDpIB3pklPIPTthu7UGk6QhgbNTqPUEMy+SeUOB+JzfpMXalm/T7vpEjLWKTsSMbEMVlY QqWCoznxhqFOnllDYujupj55/O/tksdaXT03V7Bj6oDpN+YwwE9kh3CAVE6bEnJTEqT6SF2FCla Ia7jPtsAEcOKFuQ2D+Fprj5Oce7vwtSikEOBvOnXYt6f/a6VYJKtGT2VePpQa2J0nGWDiQGo8C+ qoQ6mnZpfXeGGqKTnY+ozl/M6/Xn/kk5fPdy5SZxZUwtoyDi1dFzeRymDHaNIY23NvnMhGan9Zn 6H/gziYj6p7Tnp6LG7Myji81/aNqr+fljpByfiSvJo1LyQg/+ X-Received: by 2002:a05:6000:2504:b0:3ec:a019:3936 with SMTP id ffacd0b85a97d-4266e8e4a51mr4231141f8f.55.1759996292902; Thu, 09 Oct 2025 00:51:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuQUODVdEuh/vC59SS8ky8by2+ngSnq9gyTmMWpaS3ZR6cm0/PASxwKYPsJAj0RG9Akr6pBg== X-Received: by 2002:a05:6000:2504:b0:3ec:a019:3936 with SMTP id ffacd0b85a97d-4266e8e4a51mr4231111f8f.55.1759996292133; Thu, 09 Oct 2025 00:51:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 29/35] accel/mshv: Handle overlapping mem mappings Date: Thu, 9 Oct 2025 09:50:19 +0200 Message-ID: <20251009075026.505715-30-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996584611116600 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke QEMU maps certain regions into the guest multiple times, as seen in the trace below. Currently the MSHV kernel driver will reject those mappings. To workaround this, a record is kept (a static global list of "slots", inspired by what the HVF accelerator has implemented). An overlapping region is not registered at the hypervisor, and marked as mapped=3Dfalse. If there is an UNMAPPED_GPA exit, we can look for a slot that is unmapped and would cover the GPA. In this case we map out the conflicting slot and map in the requested region. mshv_set_phys_mem add=3D1 name=3Dpc.bios mshv_map_memory =3D> u_a=3D7ffff4e00000 gpa=3D00fffc0000 size=3D000400= 00 mshv_set_phys_mem add=3D1 name=3Dioapic mshv_set_phys_mem add=3D1 name=3Dhpet mshv_set_phys_mem add=3D0 name=3Dpc.ram mshv_unmap_memory u_a=3D7fff67e00000 gpa=3D0000000000 size=3D80000000 mshv_set_phys_mem add=3D1 name=3Dpc.ram mshv_map_memory u_a=3D7fff67e00000 gpa=3D0000000000 size=3D000c0000 mshv_set_phys_mem add=3D1 name=3Dpc.rom mshv_map_memory u_a=3D7ffff4c00000 gpa=3D00000c0000 size=3D00020000 mshv_set_phys_mem add=3D1 name=3Dpc.bios mshv_remap_attempt =3D> u_a=3D7ffff4e20000 gpa=3D00000e0000 size=3D000200= 00 The mapping table is guarded by a mutex for concurrent modification and RCU mechanisms for concurrent reads. Writes occur rarely, but we'll have to verify whether an unmapped region exist for each UNMAPPED_GPA exit, which happens frequently. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-24-magnuskulke@linux.m= icrosoft.com [Fix format strings for trace-events; mshv.h/mshv_int.h split. - Paolo] Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 22 +- accel/mshv/mem.c | 406 +++++++++++++++++++++++++++++++++--- accel/mshv/mshv-all.c | 2 + target/i386/mshv/mshv-cpu.c | 43 ++++ accel/mshv/trace-events | 5 + 5 files changed, 448 insertions(+), 30 deletions(-) diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index b29d39911db..6350c69e9d3 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -16,6 +16,8 @@ =20 #define MSHV_MSR_ENTRIES_COUNT 64 =20 +#define MSHV_MAX_MEM_SLOTS 32 + typedef struct hyperv_message hv_message; =20 struct AccelCPUState { @@ -33,6 +35,12 @@ typedef struct MshvAddressSpace { AddressSpace *as; } MshvAddressSpace; =20 +typedef struct MshvMemorySlotManager { + size_t n_slots; + GList *slots; + QemuMutex mutex; +} MshvMemorySlotManager; + struct MshvState { AccelState parent_obj; int vm; @@ -41,6 +49,7 @@ struct MshvState { int nr_as; MshvAddressSpace *as; int fd; + MshvMemorySlotManager msm; }; =20 typedef struct MshvMsiControl { @@ -71,6 +80,12 @@ typedef enum MshvVmExit { MshvVmExitSpecial =3D 2, } MshvVmExit; =20 +typedef enum MshvRemapResult { + MshvRemapOk =3D 0, + MshvRemapNoMapping =3D 1, + MshvRemapNoOverlap =3D 2, +} MshvRemapResult; + void mshv_init_mmio_emu(void); int mshv_create_vcpu(int vm_fd, uint8_t vp_index, int *cpu_fd); void mshv_remove_vcpu(int vm_fd, int cpu_fd); @@ -94,19 +109,22 @@ int mshv_hvcall(int fd, const struct mshv_root_hvcall = *args); #endif =20 /* memory */ -typedef struct MshvMemoryRegion { +typedef struct MshvMemorySlot { uint64_t guest_phys_addr; uint64_t memory_size; uint64_t userspace_addr; bool readonly; -} MshvMemoryRegion; + bool mapped; +} MshvMemorySlot; =20 +MshvRemapResult mshv_remap_overlap_region(int vm_fd, uint64_t gpa); int mshv_guest_mem_read(uint64_t gpa, uint8_t *data, uintptr_t size, bool is_secure_mode, bool instruction_fetch); int mshv_guest_mem_write(uint64_t gpa, const uint8_t *data, uintptr_t size, bool is_secure_mode); void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryRegionSection *secti= on, bool add); +void mshv_init_memory_slot_manager(MshvState *mshv_state); =20 /* msr */ typedef struct MshvMsrEntry { diff --git a/accel/mshv/mem.c b/accel/mshv/mem.c index e55c38d4db9..0e2164af3ee 100644 --- a/accel/mshv/mem.c +++ b/accel/mshv/mem.c @@ -11,7 +11,9 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/lockable.h" #include "qemu/error-report.h" +#include "qemu/rcu.h" #include "linux/mshv.h" #include "system/address-spaces.h" #include "system/mshv.h" @@ -20,6 +22,137 @@ #include #include "trace.h" =20 +typedef struct SlotsRCUReclaim { + struct rcu_head rcu; + GList *old_head; + MshvMemorySlot *removed_slot; +} SlotsRCUReclaim; + +static void rcu_reclaim_slotlist(struct rcu_head *rcu) +{ + SlotsRCUReclaim *r =3D container_of(rcu, SlotsRCUReclaim, rcu); + g_list_free(r->old_head); + g_free(r->removed_slot); + g_free(r); +} + +static void publish_slots(GList *new_head, GList *old_head, + MshvMemorySlot *removed_slot) +{ + MshvMemorySlotManager *manager =3D &mshv_state->msm; + + assert(manager); + qatomic_store_release(&manager->slots, new_head); + + SlotsRCUReclaim *r =3D g_new(SlotsRCUReclaim, 1); + r->old_head =3D old_head; + r->removed_slot =3D removed_slot; + + call_rcu1(&r->rcu, rcu_reclaim_slotlist); +} + +/* Needs to be called with mshv_state->msm.mutex held */ +static int remove_slot(MshvMemorySlot *slot) +{ + GList *old_head, *new_head; + MshvMemorySlotManager *manager =3D &mshv_state->msm; + + assert(manager); + old_head =3D qatomic_load_acquire(&manager->slots); + + if (!g_list_find(old_head, slot)) { + error_report("slot requested for removal not found"); + return -1; + } + + new_head =3D g_list_copy(old_head); + new_head =3D g_list_remove(new_head, slot); + manager->n_slots--; + + publish_slots(new_head, old_head, slot); + + return 0; +} + +/* Needs to be called with mshv_state->msm.mutex held */ +static MshvMemorySlot *append_slot(uint64_t gpa, uint64_t userspace_addr, + uint64_t size, bool readonly) +{ + GList *old_head, *new_head; + MshvMemorySlot *slot; + MshvMemorySlotManager *manager =3D &mshv_state->msm; + + assert(manager); + + old_head =3D qatomic_load_acquire(&manager->slots); + + if (manager->n_slots >=3D MSHV_MAX_MEM_SLOTS) { + error_report("no free memory slots available"); + return NULL; + } + + slot =3D g_new0(MshvMemorySlot, 1); + slot->guest_phys_addr =3D gpa; + slot->userspace_addr =3D userspace_addr; + slot->memory_size =3D size; + slot->readonly =3D readonly; + + new_head =3D g_list_copy(old_head); + new_head =3D g_list_append(new_head, slot); + manager->n_slots++; + + publish_slots(new_head, old_head, NULL); + + return slot; +} + +static int slot_overlaps(const MshvMemorySlot *slot1, + const MshvMemorySlot *slot2) +{ + uint64_t start_1 =3D slot1->userspace_addr, + start_2 =3D slot2->userspace_addr; + size_t len_1 =3D slot1->memory_size, + len_2 =3D slot2->memory_size; + + if (slot1 =3D=3D slot2) { + return -1; + } + + return ranges_overlap(start_1, len_1, start_2, len_2) ? 0 : -1; +} + +static bool is_mapped(MshvMemorySlot *slot) +{ + /* Subsequent reads of mapped field see a fully-initialized slot */ + return qatomic_load_acquire(&slot->mapped); +} + +/* + * Find slot that is: + * - overlapping in userspace + * - currently mapped in the guest + * + * Needs to be called with mshv_state->msm.mutex or RCU read lock held. + */ +static MshvMemorySlot *find_overlap_mem_slot(GList *head, MshvMemorySlot *= slot) +{ + GList *found; + MshvMemorySlot *overlap_slot; + + found =3D g_list_find_custom(head, slot, (GCompareFunc) slot_overlaps); + + if (!found) { + return NULL; + } + + overlap_slot =3D found->data; + if (!overlap_slot || !is_mapped(overlap_slot)) { + return NULL; + } + + return overlap_slot; +} + static int set_guest_memory(int vm_fd, const struct mshv_user_mem_region *region) { @@ -27,38 +160,169 @@ static int set_guest_memory(int vm_fd, =20 ret =3D ioctl(vm_fd, MSHV_SET_GUEST_MEMORY, region); if (ret < 0) { - error_report("failed to set guest memory"); - return -errno; + error_report("failed to set guest memory: %s", strerror(errno)); + return -1; } =20 return 0; } =20 -static int map_or_unmap(int vm_fd, const MshvMemoryRegion *mr, bool map) +static int map_or_unmap(int vm_fd, const MshvMemorySlot *slot, bool map) { struct mshv_user_mem_region region =3D {0}; =20 - region.guest_pfn =3D mr->guest_phys_addr >> MSHV_PAGE_SHIFT; - region.size =3D mr->memory_size; - region.userspace_addr =3D mr->userspace_addr; + region.guest_pfn =3D slot->guest_phys_addr >> MSHV_PAGE_SHIFT; + region.size =3D slot->memory_size; + region.userspace_addr =3D slot->userspace_addr; =20 if (!map) { region.flags |=3D (1 << MSHV_SET_MEM_BIT_UNMAP); - trace_mshv_unmap_memory(mr->userspace_addr, mr->guest_phys_addr, - mr->memory_size); + trace_mshv_unmap_memory(slot->userspace_addr, slot->guest_phys_add= r, + slot->memory_size); return set_guest_memory(vm_fd, ®ion); } =20 region.flags =3D BIT(MSHV_SET_MEM_BIT_EXECUTABLE); - if (!mr->readonly) { + if (!slot->readonly) { region.flags |=3D BIT(MSHV_SET_MEM_BIT_WRITABLE); } =20 - trace_mshv_map_memory(mr->userspace_addr, mr->guest_phys_addr, - mr->memory_size); + trace_mshv_map_memory(slot->userspace_addr, slot->guest_phys_addr, + slot->memory_size); return set_guest_memory(vm_fd, ®ion); } =20 +static int slot_matches_region(const MshvMemorySlot *slot1, + const MshvMemorySlot *slot2) +{ + return (slot1->guest_phys_addr =3D=3D slot2->guest_phys_addr && + slot1->userspace_addr =3D=3D slot2->userspace_addr && + slot1->memory_size =3D=3D slot2->memory_size) ? 0 : -1; +} + +/* Needs to be called with mshv_state->msm.mutex held */ +static MshvMemorySlot *find_mem_slot_by_region(uint64_t gpa, uint64_t size, + uint64_t userspace_addr) +{ + MshvMemorySlot ref_slot =3D { + .guest_phys_addr =3D gpa, + .userspace_addr =3D userspace_addr, + .memory_size =3D size, + }; + GList *found; + MshvMemorySlotManager *manager =3D &mshv_state->msm; + + assert(manager); + found =3D g_list_find_custom(manager->slots, &ref_slot, + (GCompareFunc) slot_matches_region); + + return found ? found->data : NULL; +} + +static int slot_covers_gpa(const MshvMemorySlot *slot, uint64_t *gpa_p) +{ + uint64_t gpa_offset, gpa =3D *gpa_p; + + gpa_offset =3D gpa - slot->guest_phys_addr; + return (slot->guest_phys_addr <=3D gpa && gpa_offset < slot->memory_si= ze) + ? 0 : -1; +} + +/* Needs to be called with mshv_state->msm.mutex or RCU read lock held */ +static MshvMemorySlot *find_mem_slot_by_gpa(GList *head, uint64_t gpa) +{ + GList *found; + MshvMemorySlot *slot; + + trace_mshv_find_slot_by_gpa(gpa); + + found =3D g_list_find_custom(head, &gpa, (GCompareFunc) slot_covers_gp= a); + if (found) { + slot =3D found->data; + trace_mshv_found_slot(slot->userspace_addr, slot->guest_phys_addr, + slot->memory_size); + return slot; + } + + return NULL; +} + +/* Needs to be called with mshv_state->msm.mutex held */ +static void set_mapped(MshvMemorySlot *slot, bool mapped) +{ + /* prior writes to mapped field becomes visible before readers see slo= t */ + qatomic_store_release(&slot->mapped, mapped); +} + +MshvRemapResult mshv_remap_overlap_region(int vm_fd, uint64_t gpa) +{ + MshvMemorySlot *gpa_slot, *overlap_slot; + GList *head; + int ret; + MshvMemorySlotManager *manager =3D &mshv_state->msm; + + /* fast path, called often by unmapped_gpa vm exit */ + WITH_RCU_READ_LOCK_GUARD() { + assert(manager); + head =3D qatomic_load_acquire(&manager->slots); + /* return early if no slot is found */ + gpa_slot =3D find_mem_slot_by_gpa(head, gpa); + if (gpa_slot =3D=3D NULL) { + return MshvRemapNoMapping; + } + + /* return early if no overlapping slot is found */ + overlap_slot =3D find_overlap_mem_slot(head, gpa_slot); + if (overlap_slot =3D=3D NULL) { + return MshvRemapNoOverlap; + } + } + + /* + * We'll modify the mapping list, so we need to upgrade to mutex and + * recheck. + */ + assert(manager); + QEMU_LOCK_GUARD(&manager->mutex); + + /* return early if no slot is found */ + gpa_slot =3D find_mem_slot_by_gpa(manager->slots, gpa); + if (gpa_slot =3D=3D NULL) { + return MshvRemapNoMapping; + } + + /* return early if no overlapping slot is found */ + overlap_slot =3D find_overlap_mem_slot(manager->slots, gpa_slot); + if (overlap_slot =3D=3D NULL) { + return MshvRemapNoOverlap; + } + + /* unmap overlapping slot */ + ret =3D map_or_unmap(vm_fd, overlap_slot, false); + if (ret < 0) { + error_report("failed to unmap overlap region"); + abort(); + } + set_mapped(overlap_slot, false); + warn_report("mapped out userspace_addr=3D0x%016lx gpa=3D0x%010lx size= =3D0x%lx", + overlap_slot->userspace_addr, + overlap_slot->guest_phys_addr, + overlap_slot->memory_size); + + /* map region for gpa */ + ret =3D map_or_unmap(vm_fd, gpa_slot, true); + if (ret < 0) { + error_report("failed to map new region"); + abort(); + } + set_mapped(gpa_slot, true); + warn_report("mapped in userspace_addr=3D0x%016lx gpa=3D0x%010lx size= =3D0x%lx", + gpa_slot->userspace_addr, gpa_slot->guest_phys_addr, + gpa_slot->memory_size); + + return MshvRemapOk; +} + static int handle_unmapped_mmio_region_read(uint64_t gpa, uint64_t size, uint8_t *data) { @@ -124,20 +388,97 @@ int mshv_guest_mem_write(uint64_t gpa, const uint8_t = *data, uintptr_t size, return -1; } =20 -static int set_memory(const MshvMemoryRegion *mshv_mr, bool add) +static int tracked_unmap(int vm_fd, uint64_t gpa, uint64_t size, + uint64_t userspace_addr) { - int ret =3D 0; + int ret; + MshvMemorySlot *slot; + MshvMemorySlotManager *manager =3D &mshv_state->msm; =20 - if (!mshv_mr) { - error_report("Invalid mshv_mr"); + assert(manager); + + QEMU_LOCK_GUARD(&manager->mutex); + + slot =3D find_mem_slot_by_region(gpa, size, userspace_addr); + if (!slot) { + trace_mshv_skip_unset_mem(userspace_addr, gpa, size); + /* no work to do */ + return 0; + } + + if (!is_mapped(slot)) { + /* remove slot, no need to unmap */ + return remove_slot(slot); + } + + ret =3D map_or_unmap(vm_fd, slot, false); + if (ret < 0) { + error_report("failed to unmap memory region"); + return ret; + } + return remove_slot(slot); +} + +static int tracked_map(int vm_fd, uint64_t gpa, uint64_t size, bool readon= ly, + uint64_t userspace_addr) +{ + MshvMemorySlot *slot, *overlap_slot; + int ret; + MshvMemorySlotManager *manager =3D &mshv_state->msm; + + assert(manager); + + QEMU_LOCK_GUARD(&manager->mutex); + + slot =3D find_mem_slot_by_region(gpa, size, userspace_addr); + if (slot) { + error_report("memory region already mapped at gpa=3D0x%lx, " + "userspace_addr=3D0x%lx, size=3D0x%lx", + slot->guest_phys_addr, slot->userspace_addr, + slot->memory_size); return -1; } =20 - trace_mshv_set_memory(add, mshv_mr->guest_phys_addr, - mshv_mr->memory_size, - mshv_mr->userspace_addr, mshv_mr->readonly, - ret); - return map_or_unmap(mshv_state->vm, mshv_mr, add); + slot =3D append_slot(gpa, userspace_addr, size, readonly); + + overlap_slot =3D find_overlap_mem_slot(manager->slots, slot); + if (overlap_slot) { + trace_mshv_remap_attempt(slot->userspace_addr, + slot->guest_phys_addr, + slot->memory_size); + warn_report("attempt to map region [0x%lx-0x%lx], while " + "[0x%lx-0x%lx] is already mapped in the guest", + userspace_addr, userspace_addr + size - 1, + overlap_slot->userspace_addr, + overlap_slot->userspace_addr + + overlap_slot->memory_size - 1); + + /* do not register mem slot in hv, but record for later swap-in */ + set_mapped(slot, false); + + return 0; + } + + ret =3D map_or_unmap(vm_fd, slot, true); + if (ret < 0) { + error_report("failed to map memory region"); + return -1; + } + set_mapped(slot, true); + + return 0; +} + +static int set_memory(uint64_t gpa, uint64_t size, bool readonly, + uint64_t userspace_addr, bool add) +{ + int vm_fd =3D mshv_state->vm; + + if (add) { + return tracked_map(vm_fd, gpa, size, readonly, userspace_addr); + } + + return tracked_unmap(vm_fd, gpa, size, userspace_addr); } =20 /* @@ -173,7 +514,9 @@ void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryR= egionSection *section, bool writable =3D !area->readonly && !area->rom_device; hwaddr start_addr, mr_offset, size; void *ram; - MshvMemoryRegion mshv_mr =3D {0}; + + size =3D align_section(section, &start_addr); + trace_mshv_set_phys_mem(add, section->mr->name, start_addr); =20 size =3D align_section(section, &start_addr); trace_mshv_set_phys_mem(add, section->mr->name, start_addr); @@ -200,14 +543,21 @@ void mshv_set_phys_mem(MshvMemoryListener *mml, Memor= yRegionSection *section, =20 ram =3D memory_region_get_ram_ptr(area) + mr_offset; =20 - mshv_mr.guest_phys_addr =3D start_addr; - mshv_mr.memory_size =3D size; - mshv_mr.readonly =3D !writable; - mshv_mr.userspace_addr =3D (uint64_t)ram; - - ret =3D set_memory(&mshv_mr, add); + ret =3D set_memory(start_addr, size, !writable, (uint64_t)ram, add); if (ret < 0) { - error_report("Failed to set memory region"); + error_report("failed to set memory region"); abort(); } } + +void mshv_init_memory_slot_manager(MshvState *mshv_state) +{ + MshvMemorySlotManager *manager; + + assert(mshv_state); + manager =3D &mshv_state->msm; + + manager->n_slots =3D 0; + manager->slots =3D NULL; + qemu_mutex_init(&manager->mutex); +} diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index fa1f8f35bdb..5edfcbad9d2 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -437,6 +437,8 @@ static int mshv_init(AccelState *as, MachineState *ms) =20 mshv_init_msicontrol(); =20 + mshv_init_memory_slot_manager(s); + ret =3D create_vm(mshv_fd, &vm_fd); if (ret < 0) { close(mshv_fd); diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 7edc032cea3..de87142bffc 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -1170,6 +1170,43 @@ static int handle_mmio(CPUState *cpu, const struct h= yperv_message *msg, return 0; } =20 +static int handle_unmapped_mem(int vm_fd, CPUState *cpu, + const struct hyperv_message *msg, + MshvVmExit *exit_reason) +{ + struct hv_x64_memory_intercept_message info =3D { 0 }; + uint64_t gpa; + int ret; + enum MshvRemapResult remap_result; + + ret =3D set_memory_info(msg, &info); + if (ret < 0) { + error_report("failed to convert message to memory info"); + return -1; + } + + gpa =3D info.guest_physical_address; + + /* attempt to remap the region, in case of overlapping userspace mappi= ngs */ + remap_result =3D mshv_remap_overlap_region(vm_fd, gpa); + *exit_reason =3D MshvVmExitIgnore; + + switch (remap_result) { + case MshvRemapNoMapping: + /* if we didn't find a mapping, it is probably mmio */ + return handle_mmio(cpu, msg, exit_reason); + case MshvRemapOk: + break; + case MshvRemapNoOverlap: + /* This should not happen, but we are forgiving it */ + warn_report("found no overlap for unmapped region"); + *exit_reason =3D MshvVmExitSpecial; + break; + } + + return 0; +} + static int set_ioport_info(const struct hyperv_message *msg, hv_x64_io_port_intercept_message *info) { @@ -1507,6 +1544,12 @@ int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_messa= ge *msg, MshvVmExit *exit) case HVMSG_UNRECOVERABLE_EXCEPTION: return MshvVmExitShutdown; case HVMSG_UNMAPPED_GPA: + ret =3D handle_unmapped_mem(vm_fd, cpu, msg, &exit_reason); + if (ret < 0) { + error_report("failed to handle unmapped memory"); + return -1; + } + return exit_reason; case HVMSG_GPA_INTERCEPT: ret =3D handle_mmio(cpu, msg, &exit_reason); if (ret < 0) { diff --git a/accel/mshv/trace-events b/accel/mshv/trace-events index a4dffeb24a3..36f0d59b385 100644 --- a/accel/mshv/trace-events +++ b/accel/mshv/trace-events @@ -26,3 +26,8 @@ mshv_map_memory(uint64_t userspace_addr, uint64_t gpa, ui= nt64_t size) "\tu_a=3D0x% mshv_unmap_memory(uint64_t userspace_addr, uint64_t gpa, uint64_t size) "\= tu_a=3D0x%" PRIx64 " gpa=3D0x%010" PRIx64 " size=3D0x%08" PRIx64 mshv_set_phys_mem(bool add, const char *name, uint64_t gpa) "\tadd=3D%d na= me=3D%s gpa=3D0x%010" PRIx64 mshv_handle_mmio(uint64_t gva, uint64_t gpa, uint64_t size, uint8_t access= _type) "\tgva=3D0x%" PRIx64 " gpa=3D0x%010" PRIx64 " size=3D0x%" PRIx64 " a= ccess_type=3D%d" + +mshv_found_slot(uint64_t userspace_addr, uint64_t gpa, uint64_t size) "\tu= _a=3D0x%" PRIx64 " gpa=3D0x%010" PRIx64 " size=3D0x%08" PRIx64 +mshv_skip_unset_mem(uint64_t userspace_addr, uint64_t gpa, uint64_t size) = "\tu_a=3D0x%" PRIx64 " gpa=3D0x%010" PRIx64 " size=3D0x%08" PRIx64 +mshv_remap_attempt(uint64_t userspace_addr, uint64_t gpa, uint64_t size) "= \tu_a=3D0x%" PRIx64 " gpa=3D0x%010" PRIx64 " size=3D0x%08" PRIx64 +mshv_find_slot_by_gpa(uint64_t gpa) "\tgpa=3D0x%010" PRIx64 --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996659; cv=none; d=zohomail.com; s=zohoarc; b=KZsPYw7pM2vIpHVpdPKZ0dXuSwPbun0T8yFkGfNYUnTJM2DRYVkV8jYimnbhLgD5InbH30EVBwcP0yeZe94KOfjQEKeq4u+57jgWt3GSRrI/32P57qVfxVNXV4dG5isa9P83RtTDv6LYRd+wdHHe2PKpDUOmcWGerMHqoMr1uG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996659; 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=xo7/waLBB+eaxCnywl7D9abhJb3gDRPAUFE9UsF2G9Q=; b=mV9rBU9EaWc69isbuxJyEli3UTOPv+x8efCrUuyzSWjKVaWNCQ78ZNgPf9SoHbcaa3N6OZfKAPwBJzWUk4Xnvd8RnQ8rwoBjq5L8gDMR43K871cInsIXWbb0C7psF+bqIh62jRCah4cENePz3SB1lKvsuLqMbvRQowblmv73t7s= 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 1759996659678553.9110959948955; Thu, 9 Oct 2025 00:57:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lRI-0000CH-5v; Thu, 09 Oct 2025 03:51:52 -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 1v6lRE-0000Bf-Vy for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51: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 1v6lRA-0004Tr-11 for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:48 -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-74-bVDtTozJPNmtbPaX78Zy2A-1; Thu, 09 Oct 2025 03:51:38 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-40cfb98eddbso863007f8f.0 for ; Thu, 09 Oct 2025 00:51:38 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8ab8fdsm32956970f8f.15.2025.10.09.00.51.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996299; 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=xo7/waLBB+eaxCnywl7D9abhJb3gDRPAUFE9UsF2G9Q=; b=Ghb1MTYWP/lc5INl7RIECRYJ9iaGHP/YpvstUr0LtacvqutXJ5MYLqddRRLVu6d6YwLgd1 M7IYE0F4ydM1uIQOIy6jhtOWL99bu8tZFqs9MpTtIWdeMqvgxOWtJjm73U1+ECJn1n+KMs p4v12oB6xvW8qaVhmFiqgn0nG1ha2Vw= X-MC-Unique: bVDtTozJPNmtbPaX78Zy2A-1 X-Mimecast-MFC-AGG-ID: bVDtTozJPNmtbPaX78Zy2A_1759996297 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996296; x=1760601096; 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=xo7/waLBB+eaxCnywl7D9abhJb3gDRPAUFE9UsF2G9Q=; b=djQgAA6VRjcp6itimi9pNe0v9IGl3KzVqThAR3QEhsfA11HeYzYNXJqaa/fAH6SwA1 e9Smqch0DTK8U9pM/nMFhIdmytYfk8tyr9vb3IAHoAD5OKzA7yKo5DqxbwiKa0qRBIKj E/aaGlbgxZQEaE78jwBP9s6Qhk2pKMybheVQdO1MYtza4CRNbG3cxujHoZdYv41jD0CF UnaAln6b0qwwM5mkuPpVdaSnZ3UGHkdDCEvd8EcVVsQ5koZwRmf9cNDIqRst9xN3jNEc W8gXvxlteQwQfj7EOWoyinfgkDD6H8KhIpEESAYOXFOh0c9TeuBc427QhF0JXw/Qe3oE yCTw== X-Gm-Message-State: AOJu0YwMyRLNb92VKmUkavGutAc3Y7J+aml5ouKEO0R39kA6bpeI4uTR rCxPOMLtNT2mnGfU+qpVpVzO7RSseMeHaC8GoHyIoRUBPpYe/qWhGjOVEaxFd/qc48PD8Q/HuE8 kyKZ1ECmCQTa15051sXQ/MFtUrddZIq9nvv3ChIWtBRvZp7pxFzw2oi2gPNxaGzIMMObxmuPvcl 2152PB5kZizw01H+BE/gr+W0jV6FDkAn5PLM5ykMW6oG8= X-Gm-Gg: ASbGncsfSI/w1CKPHgzJ+I+U12WcDJ9i1Siuqs1Nj483PYNixX9Lpo1zM8Ugo5tb0/I GVoZMmdt4gOl6ZLQbG6Far0D4xDX7Zpl4Ujy1EpOH5jPwXBEcyhxa5cNQ0V6oyxiGEujnEUPJm6 wKRnNoO5SLTJTD6VN6VVbbys1n7Nu1gfu5XKoRTZxaBKFMFYTdQJBp01FR6PlzKj2c4MkWo2GZs z8E7B3Fk3cvq/TMyBLBE3RyZrpl0TuTqklUw+z2hBmhfGKtNa91KFS3KFq641XbZ58M9p+aQ7vZ KYBrNY8IeaWcnfM6lqX6xqcRpS/rUIzOeHe4+6s0oqRgZcI1T2LXV1kTnYAcXtNKEBXBvC43gtV 6PIZf2u8M32DNhkcOF+UAuOQkXYQ8jrDU3XJAl3Ayb5PRZigR X-Received: by 2002:a05:6000:26d1:b0:3fa:2df7:6a0a with SMTP id ffacd0b85a97d-425829ee53emr6538894f8f.22.1759996296212; Thu, 09 Oct 2025 00:51:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGiENv4ZyiIXYE25XeoB7eJmYLn2B3CGZ2+pPhF1CtN7Iw86LU2UWLT4WYd4Ql83CFW1tWQdQ== X-Received: by 2002:a05:6000:26d1:b0:3fa:2df7:6a0a with SMTP id ffacd0b85a97d-425829ee53emr6538878f8f.22.1759996295694; Thu, 09 Oct 2025 00:51:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Praveen K Paladugu , Magnus Kulke , "Dr. David Alan Gilbert" Subject: [PULL 30/35] qapi/accel: Allow to query mshv capabilities Date: Thu, 9 Oct 2025 09:50:20 +0200 Message-ID: <20251009075026.505715-31-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996671617116600 Content-Type: text/plain; charset="utf-8" From: Praveen K Paladugu Allow to query mshv capabilities via query-mshv QMP and info mshv HMP comma= nds. Signed-off-by: Magnus Kulke Acked-by: Dr. David Alan Gilbert Link: https://lore.kernel.org/r/20250916164847.77883-25-magnuskulke@linux.m= icrosoft.com [Fix "since" version. - Paolo] Signed-off-by: Paolo Bonzini --- qapi/accelerator.json | 29 +++++++++++++++++++++++++++++ include/monitor/hmp.h | 1 + include/system/hw_accel.h | 1 + hw/core/machine-hmp-cmds.c | 15 +++++++++++++++ hw/core/machine-qmp-cmds.c | 14 ++++++++++++++ hmp-commands-info.hx | 13 +++++++++++++ 6 files changed, 73 insertions(+) diff --git a/qapi/accelerator.json b/qapi/accelerator.json index fb28c8d920a..664e0272465 100644 --- a/qapi/accelerator.json +++ b/qapi/accelerator.json @@ -54,3 +54,32 @@ { 'command': 'x-accel-stats', 'returns': 'HumanReadableText', 'features': [ 'unstable' ] } + +## +# @MshvInfo: +# +# Information about support for MSHV acceleration +# +# @enabled: true if MSHV acceleration is active +# +# @present: true if MSHV acceleration is built into this executable +# +# Since: 10.2.0 +## +{ 'struct': 'MshvInfo', 'data': {'enabled': 'bool', 'present': 'bool'} } + +## +# @query-mshv: +# +# Return information about MSHV acceleration +# +# Returns: @MshvInfo +# +# Since: 10.0.92 +# +# .. qmp-example:: +# +# -> { "execute": "query-mshv" } +# <- { "return": { "enabled": true, "present": true } } +## +{ 'command': 'query-mshv', 'returns': 'MshvInfo' } diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index ae116d9804a..31bd812e5f4 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -24,6 +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_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/include/system/hw_accel.h b/include/system/hw_accel.h index fa9228d5d2d..55497edc293 100644 --- a/include/system/hw_accel.h +++ b/include/system/hw_accel.h @@ -14,6 +14,7 @@ #include "hw/core/cpu.h" #include "system/kvm.h" #include "system/hvf.h" +#include "system/mshv.h" #include "system/whpx.h" #include "system/nvmm.h" =20 diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c index 3a612e2232d..682ed9f49b8 100644 --- a/hw/core/machine-hmp-cmds.c +++ b/hw/core/machine-hmp-cmds.c @@ -163,6 +163,21 @@ void hmp_info_kvm(Monitor *mon, const QDict *qdict) qapi_free_KvmInfo(info); } =20 +void hmp_info_mshv(Monitor *mon, const QDict *qdict) +{ + MshvInfo *info; + + 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"); + } + + qapi_free_MshvInfo(info); +} + void hmp_info_uuid(Monitor *mon, const QDict *qdict) { UuidInfo *info; diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 6aca1a626e6..e24bf0d97bf 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -28,6 +28,20 @@ #include "system/runstate.h" #include "system/system.h" #include "hw/s390x/storage-keys.h" +#include + +/* + * QMP query for MSHV + */ +MshvInfo *qmp_query_mshv(Error **errp) +{ + MshvInfo *info =3D g_malloc0(sizeof(*info)); + + info->enabled =3D mshv_enabled(); + info->present =3D accel_find("mshv"); + + return info; +} =20 /* * fast means: we NEVER interrupt vCPU threads to retrieve diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 6142f60e7b1..eaaa880c1b3 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -307,6 +307,19 @@ SRST Show KVM information. ERST =20 + { + .name =3D "mshv", + .args_type =3D "", + .params =3D "", + .help =3D "show MSHV information", + .cmd =3D hmp_info_mshv, + }, + +SRST + ``info mshv`` + Show MSHV information. +ERST + { .name =3D "numa", .args_type =3D "", --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996692; cv=none; d=zohomail.com; s=zohoarc; b=jt7HLs+Nr9k04/mVbNEKeb2dxtg1Nqr8maOFM0AcFHVHDrVcxEgzcjLoXc+OeIEUU8tHMoY2hRQStcwEKsyFRk99KD951meU4Ipa4rAJjab7rBQvOXD2UocAUQkC2Bj1njWOfZC4yOBlmeEF+kzXaK4DjY1ylsI7Exrmk7sYHVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996692; 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=+wOqIA00+2P30PgO3MjOrt5nn3whgZt6cWLk1eUimlA=; b=RWlJOgS7bWJUSzPYHZRI2joAfOrmGwWHCr9jR/ErWntqjmXZTD2twwZ39G5DCWFK0wd29UvYy7N+xJzW9xzGDdTvHbZdbDMWQk9a0P1HYKfDW1qMC4AaalEwr5JgOpe4cI7SBWXcsdnV3Jv9S9YwGVYmePl4EKwBHG/9244cscI= 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 1759996692021458.18265686939003; Thu, 9 Oct 2025 00:58:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lRK-0000Cs-2n; Thu, 09 Oct 2025 03:51:54 -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 1v6lRG-0000Bu-Nq for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:50 -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 1v6lRB-0004UA-0o for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:49 -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-362-FWhQntWAPdS2eET1d75xTQ-1; Thu, 09 Oct 2025 03:51:40 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46e7a2c3773so7859625e9.0 for ; Thu, 09 Oct 2025 00:51:40 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46faf105ad7sm33921625e9.4.2025.10.09.00.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996302; 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=+wOqIA00+2P30PgO3MjOrt5nn3whgZt6cWLk1eUimlA=; b=BhHkXOYCiUnzsHDKREqy2IfdCKWUhwoVg7T/VsJ9W27IfkwifaaWw14JptIGtFQXxSul9s OgJXjrnx6i7acaBFkz9WvJqE71U7yngE8qbVo2eDx4f1Rz59puz4cZxkPMuhZ6a5e/ZqP9 w+n6NC9nuhdxUCv+xDv8yMbteE04/5s= X-MC-Unique: FWhQntWAPdS2eET1d75xTQ-1 X-Mimecast-MFC-AGG-ID: FWhQntWAPdS2eET1d75xTQ_1759996300 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996298; x=1760601098; 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=+wOqIA00+2P30PgO3MjOrt5nn3whgZt6cWLk1eUimlA=; b=Ti/RavlC/B/icaBKNtCTT/tXMGOvAEDH+ORq8dfCI8gv4t0ZzkRI1K29rVfIjd8PgJ mVC6nWnOtMTWQKzPvqkWm0YfYha1wi+4d/NeNdqVEcEZZ43Le8JVkV+vpZpb5bfbNwiP OBNPYviCzfSgSQzGLu0oUo6gV1C7YV3llcIlUB6BhMpg3aBkgH1mwANVac397av6/mNW nhnH4ygmznunW6dQ2vzzU0UfGiDCgbJ7NatNJPPPTSq4a24OWVujnosvAIm+BgN6nv6B OCO/+akM65VNQMpM2KJrwajSB9hOt5QnDBTFsio9NOFCLZv7LXu+jguISf0XgBHQFxSE 0X1w== X-Gm-Message-State: AOJu0YxE7oRD8biIEG7sY0ztY6x1ZBk+Rz7HIQNgCwEdyDg9liYxUVrU HuBIIlOY1J/0hZrTpWL6p0L2I0fM/Vt9P0z4a+nEFf/N9vcj1LpMnRGZleocn8vK32dww/yZ9DM VobcjyAY2AjA/AZx3GWiEF49IReuiVde8PTThpSHmXmHxcek5Y8wzkkdZiodpvErVSh93Vqdqkt wp6JbenOZ994TWcdkKn4QAVDhSRv6R2xyqq1E0DOHF5Qo= X-Gm-Gg: ASbGncs43A1r9QjEyI1/+d1nH52RJhfMsLt+eny4lTFJrbgsZH6SwWtrK+dSo+6cM+v V3k+jn3yPopjkbjqoHy8XQ/5UwZ/rGkSqQhaxauxcsSylFKBf4KJZOlmM6sSj/WvSrsft14Xdpz IV/mc0vFGafRukU6NBit9byHkkOxQ38p+Xf6S2E4q7aFoOmMN6JgVGUOLtEVvmc/1uOOv3LNQwr YTCsS+L1pRxa5fWc8iCUOJ1da4t+Ca+2j5qaqA4fk4giWKUpkwWUoDjVrqv+1+Ue0y+yjiQydiU DlogPCz1xngefEN7IsW2bROXFy5nxkCOkDKzdNYzJQ2D2F/pucuPK+OFeMtgYYCRKx+Y5XrFpof ItkNX2GeFjd/7z2wmSs/e8uNyjknW6hz9KVu2/tx6E5PSCoD+ X-Received: by 2002:a05:600c:8a8:b0:46d:38c4:1ac9 with SMTP id 5b1f17b1804b1-46fa2952c99mr43879895e9.2.1759996298376; Thu, 09 Oct 2025 00:51:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+yhF/3xtvAR9nF2QwTpmPEbmP/LRAts19mBJVnh2C3KgJojsjLH/l92YmUYziuTGFEa9+EA== X-Received: by 2002:a05:600c:8a8:b0:46d:38c4:1ac9 with SMTP id 5b1f17b1804b1-46fa2952c99mr43879725e9.2.1759996297841; Thu, 09 Oct 2025 00:51:37 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 31/35] target/i386/mshv: Use preallocated page for hvcall Date: Thu, 9 Oct 2025 09:50:21 +0200 Message-ID: <20251009075026.505715-32-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996693819154100 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke There are hvcalls that are invoked during MMIO exits, the payload is of dynamic size. To avoid heap allocations we can use preallocated pages as in/out buffer for those calls. A page is reserved per vCPU and used for set/get register hv calls. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-26-magnuskulke@linux.m= icrosoft.com [Use standard MAX_CONST macro; mshv.h/mshv_int.h split. - Paolo] Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 7 +++++++ accel/mshv/mshv-all.c | 2 +- target/i386/mshv/mshv-cpu.c | 38 +++++++++++++++++++++++++------------ 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 6350c69e9d3..490563c1ab2 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -20,9 +20,16 @@ =20 typedef struct hyperv_message hv_message; =20 +typedef struct MshvHvCallArgs { + void *base; + void *input_page; + void *output_page; +} MshvHvCallArgs; + struct AccelCPUState { int cpufd; bool dirty; + MshvHvCallArgs hvcall_args; }; =20 typedef struct MshvMemoryListener { diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index 5edfcbad9d2..45174f7c4eb 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -399,8 +399,8 @@ static int mshv_init_vcpu(CPUState *cpu) uint8_t vp_index =3D cpu->cpu_index; int ret; =20 - mshv_arch_init_vcpu(cpu); cpu->accel =3D g_new0(AccelCPUState, 1); + mshv_arch_init_vcpu(cpu); =20 ret =3D mshv_create_vcpu(vm_fd, vp_index, &cpu->accel->cpufd); if (ret < 0) { diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index de87142bffc..1f7b9cb37ec 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -34,6 +34,10 @@ =20 #include =20 +#define MAX_REGISTER_COUNT (MAX_CONST(ARRAY_SIZE(STANDARD_REGISTER_NAMES),= \ + MAX_CONST(ARRAY_SIZE(SPECIAL_REGISTER_NAMES), \ + ARRAY_SIZE(FPU_REGISTER_NAMES)))) + static enum hv_register_name STANDARD_REGISTER_NAMES[18] =3D { HV_X64_REGISTER_RAX, HV_X64_REGISTER_RBX, @@ -151,7 +155,7 @@ int mshv_set_generic_regs(const CPUState *cpu, const hv= _register_assoc *assocs, int cpu_fd =3D mshv_vcpufd(cpu); int vp_index =3D cpu->cpu_index; size_t in_sz, assocs_sz; - hv_input_set_vp_registers *in; + hv_input_set_vp_registers *in =3D cpu->accel->hvcall_args.input_page; struct mshv_root_hvcall args =3D {0}; int ret; =20 @@ -160,7 +164,7 @@ int mshv_set_generic_regs(const CPUState *cpu, const hv= _register_assoc *assocs, in_sz =3D sizeof(hv_input_set_vp_registers) + assocs_sz; =20 /* fill the input struct */ - in =3D g_malloc0(in_sz); + memset(in, 0, sizeof(hv_input_set_vp_registers)); in->vp_index =3D vp_index; memcpy(in->elements, assocs, assocs_sz); =20 @@ -172,7 +176,6 @@ int mshv_set_generic_regs(const CPUState *cpu, const hv= _register_assoc *assocs, =20 /* perform the call */ ret =3D mshv_hvcall(cpu_fd, &args); - g_free(in); if (ret < 0) { error_report("Failed to set registers"); return -1; @@ -193,8 +196,8 @@ static int get_generic_regs(CPUState *cpu, hv_register_= assoc *assocs, { int cpu_fd =3D mshv_vcpufd(cpu); int vp_index =3D cpu->cpu_index; - hv_input_get_vp_registers *in; - hv_register_value *values; + hv_input_get_vp_registers *in =3D cpu->accel->hvcall_args.input_page; + hv_register_value *values =3D cpu->accel->hvcall_args.output_page; size_t in_sz, names_sz, values_sz; int i, ret; struct mshv_root_hvcall args =3D {0}; @@ -204,15 +207,14 @@ static int get_generic_regs(CPUState *cpu, hv_registe= r_assoc *assocs, in_sz =3D sizeof(hv_input_get_vp_registers) + names_sz; =20 /* fill the input struct */ - in =3D g_malloc0(in_sz); + memset(in, 0, sizeof(hv_input_get_vp_registers)); in->vp_index =3D vp_index; for (i =3D 0; i < n_regs; i++) { in->names[i] =3D assocs[i].name; } =20 - /* allocate value output buffer */ + /* determine size of value output buffer */ values_sz =3D n_regs * sizeof(union hv_register_value); - values =3D g_malloc0(values_sz); =20 /* create the hvcall envelope */ args.code =3D HVCALL_GET_VP_REGISTERS; @@ -224,16 +226,13 @@ static int get_generic_regs(CPUState *cpu, hv_registe= r_assoc *assocs, =20 /* perform the call */ ret =3D mshv_hvcall(cpu_fd, &args); - g_free(in); if (ret < 0) { - g_free(values); error_report("Failed to retrieve registers"); return -1; } =20 /* assert we got all registers */ if (args.reps !=3D n_regs) { - g_free(values); error_report("Failed to retrieve registers: expected %zu elements" ", got %u", n_regs, args.reps); return -1; @@ -243,7 +242,6 @@ static int get_generic_regs(CPUState *cpu, hv_register_= assoc *assocs, for (i =3D 0; i < n_regs; i++) { assocs[i].value =3D values[i]; } - g_free(values); =20 return 0; } @@ -1696,6 +1694,19 @@ void mshv_arch_init_vcpu(CPUState *cpu) { X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; + AccelCPUState *state =3D cpu->accel; + size_t page =3D HV_HYP_PAGE_SIZE; + void *mem =3D qemu_memalign(page, 2 * page); + + /* sanity check, to make sure we don't overflow the page */ + QEMU_BUILD_BUG_ON((MAX_REGISTER_COUNT + * sizeof(hv_register_assoc) + + sizeof(hv_input_get_vp_registers) + > HV_HYP_PAGE_SIZE)); + + state->hvcall_args.base =3D mem; + state->hvcall_args.input_page =3D mem; + state->hvcall_args.output_page =3D (uint8_t *)mem + page; =20 env->emu_mmio_buf =3D g_new(char, 4096); } @@ -1704,7 +1715,10 @@ void mshv_arch_destroy_vcpu(CPUState *cpu) { X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; + AccelCPUState *state =3D cpu->accel; =20 + g_free(state->hvcall_args.base); + state->hvcall_args =3D (MshvHvCallArgs){0}; g_clear_pointer(&env->emu_mmio_buf, g_free); } =20 --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996494; cv=none; d=zohomail.com; s=zohoarc; b=dteepMdx1eIKsF2xvIT+jvPXSB1YkmXrY9V1e2lcks/dnIGZDAa9kLEuoAi5IA6EOK245P+Eu0Pc4OWHHZT2chkJq4ey3uyY5uWq5qfA3XqlK8hz+1jY6PZqdKX4hj/tOVk3QiPRlrK7uaWx3Hspcve4fo588yR/bxYWgxwY72Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996494; 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=enfkQAB8afdi5HCkMd+8fUqs4ubojxDRXj46eZbewuM=; b=dJNSsyMD7U1/n4PBtJoW3drPyR76l9tw2p8CB04mBj89GHL3FTDxBHoBiSbEY7M8iC589HHr3bLrlxqeF1+yJULwsSy3UGS6y2q6NoFOYlKs1HRa+ktACR+1I4OjRkS0FPn8f8+HzVcfJajcz3ElGF6WKn2WXahjAPLTARkD/E0= 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 175999649468029.942378835522504; Thu, 9 Oct 2025 00:54:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lRO-0000F1-Vy; Thu, 09 Oct 2025 03:51: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 1v6lRN-0000EX-5O for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:57 -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 1v6lRA-0004UF-ND for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:56 -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-331-WCy23cOUOTyf5dmPWK1_Pw-1; Thu, 09 Oct 2025 03:51:42 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e44b9779eso2992405e9.1 for ; Thu, 09 Oct 2025 00:51:41 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46faf112fdbsm34023845e9.8.2025.10.09.00.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996303; 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=enfkQAB8afdi5HCkMd+8fUqs4ubojxDRXj46eZbewuM=; b=P+eEIIPkvjoQhHeogfyysZgxCiZmxrlCLBg9xH6MrMP32X4XjOEbhqXagZFJXKiAIyQtam wQL+Qkgpwkg7d14pUh0hYtxcPQiPEhjRKQ6/RjRFoA9WONk94Qb95sNoBQsY7fY5dmetLI ySkGSmLSFVL2sE2TCRBTEDseDAdxT/c= X-MC-Unique: WCy23cOUOTyf5dmPWK1_Pw-1 X-Mimecast-MFC-AGG-ID: WCy23cOUOTyf5dmPWK1_Pw_1759996301 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996299; x=1760601099; 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=enfkQAB8afdi5HCkMd+8fUqs4ubojxDRXj46eZbewuM=; b=wwTO8RFqCYYRgB1N+GYXn86sre3xBK8YRdB+tWOukxdjkT7TmZGO2OOq7uvkfFS7cS JJY8ezglojEezeFMGUYhy3aFJhK3/2Fm9lg9Ds5dRvplckdyTjdUKaS2cbGduKGNEPR8 53adoivGekXqVlW/wzXU92gYp2pMIqeRLb7MkVDiBWmVM7ynDG6G/Jb0y6lle44pXOyd 3hiktENA1umcBy4cDq8hrBIMFt+F/o63dxuhLEz9mR8PznFiI+rCjjY6K8AVT82yFJ9S Y3xPQTDlSNr076I2PgSle0lWPYCQhTbQltuo0q0UuTx2kx4qwD+IMkN+vpQVSdJTneIh tQLg== X-Gm-Message-State: AOJu0YwouEq2wENQ+8oIbs7xrTRjq4qfyLWiiZMFnqTwMb0Iln66eTgz w4avKzXPMXRyggewHtvIlu/edLoZ0DUX1+/JO3PK4JEYeU4vZcUwtGCJl2JE1Bd4TX4vc9nTpYW CUji0608SN+Y+6OGUekpDzJbOte/RNpdd0k+LaU7LZEn2yxW4ceCUxphDwy2eH4ucG9HJlJPykB /do/lql/8QXiRm31loHSEx1vXWmR1KD2ICficWFXNwCUc= X-Gm-Gg: ASbGncuNleDgXnkXtO8wOTzwx3cb/pXs0N6rZ5xFLUpBv+ih81WMQ2kLjI3h5WwrXKI FQdoOGqQAVe5mHoNNLrWwMiPgxwqE0KtRkCz/nupbGxD54YnzVud37jbwPCT6c5lbtfKgtbashL fcPgYg2lUpVGROXlNC+1O5PYd8PBfjrL29B2OclQ+iVDq6z0zCjFt5PAYY6CEsqw50yIG8/+MtL aPlzRC3zAG+TpjRtqDyhKyK5L2WlZFud03YjIn3hH9m1R6nSEJI+ZGeZ8Z694O4nFMQezvcV9cO i59LSpUUEILmvyR9gp6UlFo485Pi0jgy4AC3bfs5LycsK/I/dpa9TvVYJA0tyeL/bDD1U9ZLBw6 PMAjRM9FGaz8HVyRvibltLjKu28mY1g4T4uY6/s8Q0Q0qgNCd X-Received: by 2002:a05:600c:350b:b0:46e:6603:2ab0 with SMTP id 5b1f17b1804b1-46fa9aeff11mr49207175e9.24.1759996299524; Thu, 09 Oct 2025 00:51:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5NFNS7fTmrtKuMLaFbOaFqaWRkR64tkdDlWsWyHf+EX4GYm+0O095HCTakqMF2G1+M7x9Sw== X-Received: by 2002:a05:600c:350b:b0:46e:6603:2ab0 with SMTP id 5b1f17b1804b1-46fa9aeff11mr49206885e9.24.1759996299039; Thu, 09 Oct 2025 00:51:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 32/35] docs: Add mshv to documentation Date: Thu, 9 Oct 2025 09:50:22 +0200 Message-ID: <20251009075026.505715-33-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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, 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: 1759996495750154100 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Added mshv to the list of accelerators in doc text. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-27-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- docs/about/build-platforms.rst | 2 +- docs/devel/codebase.rst | 2 +- docs/glossary.rst | 7 +++---- docs/system/introduction.rst | 3 +++ qemu-options.hx | 16 ++++++++-------- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/docs/about/build-platforms.rst b/docs/about/build-platforms.rst index 798cb4631df..fc2743658d4 100644 --- a/docs/about/build-platforms.rst +++ b/docs/about/build-platforms.rst @@ -53,7 +53,7 @@ Those hosts are officially supported, with various accele= rators: * - SPARC - tcg * - x86 - - hvf (64 bit only), kvm, nvmm, tcg, whpx (64 bit only), xen + - hvf (64 bit only), mshv (64 bit only), kvm, nvmm, tcg, whpx (64 bit= only), xen =20 Other host architectures are not supported. It is possible to build QEMU s= ystem emulation on an unsupported host architecture using the configure diff --git a/docs/devel/codebase.rst b/docs/devel/codebase.rst index 2a3143787a6..69d88271178 100644 --- a/docs/devel/codebase.rst +++ b/docs/devel/codebase.rst @@ -48,7 +48,7 @@ yet, so sometimes the source code is all you have. * `accel `_: Infrastructure and architecture agnostic code related to the various `accelerators ` supported by QEMU - (TCG, KVM, hvf, whpx, xen, nvmm). + (TCG, KVM, hvf, whpx, xen, nvmm, mshv). Contains interfaces for operations that will be implemented per `target `_. * `audio `_: diff --git a/docs/glossary.rst b/docs/glossary.rst index 4fa044bfb6e..2857731bc44 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -12,7 +12,7 @@ Accelerator =20 A specific API used to accelerate execution of guest instructions. It can = be hardware-based, through a virtualization API provided by the host OS (kvm,= hvf, -whpx, ...), or software-based (tcg). See this description of `supported +whpx, mshv, ...), or software-based (tcg). See this description of `suppor= ted accelerators`. =20 Board @@ -101,9 +101,8 @@ manage a virtual machine. QEMU is a virtualizer, that i= nteracts with various hypervisors. =20 In the context of QEMU, an hypervisor is an API, provided by the Host OS, -allowing to execute virtual machines. Linux implementation is KVM (and sup= ports -Xen as well). For MacOS, it's HVF. Windows defines WHPX. And NetBSD provid= es -NVMM. +allowing to execute virtual machines. Linux provides a choice of KVM, Xen +or MSHV; MacOS provides HVF; Windows provides WHPX; NetBSD provides NVMM. =20 .. _machine: =20 diff --git a/docs/system/introduction.rst b/docs/system/introduction.rst index 4cd46b5b8f9..9c57523b6c2 100644 --- a/docs/system/introduction.rst +++ b/docs/system/introduction.rst @@ -23,6 +23,9 @@ Tiny Code Generator (TCG) capable of emulating many CPUs. * - Xen - Linux (as dom0) - Arm, x86 + * - MSHV + - Linux (as dom0) + - x86 * - Hypervisor Framework (hvf) - MacOS - x86 (64 bit only), Arm (64 bit only) diff --git a/qemu-options.hx b/qemu-options.hx index 075f4be2e3e..56db4bf9e5e 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -28,7 +28,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ "-machine [type=3D]name[,prop[=3Dvalue][,...]]\n" " selects emulated machine ('-machine help' for list)\n" " property accel=3Daccel1[:accel2[:...]] selects accele= rator\n" - " supported accelerators are kvm, xen, hvf, nvmm, whpx = or tcg (default: tcg)\n" + " supported accelerators are kvm, xen, hvf, nvmm, whpx,= mshv or tcg (default: tcg)\n" " vmport=3Don|off|auto controls emulation of vmport (de= fault: auto)\n" " dump-guest-core=3Don|off include guest memory in a co= re dump (default=3Don)\n" " mem-merge=3Don|off controls memory merge support (def= ault: on)\n" @@ -66,10 +66,10 @@ SRST =20 ``accel=3Daccels1[:accels2[:...]]`` This is used to enable an accelerator. Depending on the target - architecture, kvm, xen, hvf, nvmm, whpx or tcg can be available. - By default, tcg is used. If there is more than one accelerator - specified, the next one is used if the previous one fails to - initialize. + architecture, kvm, xen, hvf, nvmm, whpx, mshv or tcg can be + available. By default, tcg is used. If there is more than one + accelerator specified, the next one is used if the previous one + fails to initialize. =20 ``vmport=3Don|off|auto`` Enables emulation of VMWare IO port, for vmmouse etc. auto says @@ -226,7 +226,7 @@ ERST =20 DEF("accel", HAS_ARG, QEMU_OPTION_accel, "-accel [accel=3D]accelerator[,prop[=3Dvalue][,...]]\n" - " select accelerator (kvm, xen, hvf, nvmm, whpx or tcg;= use 'help' for a list)\n" + " select accelerator (kvm, xen, hvf, nvmm, whpx, mshv o= r tcg; use 'help' for a list)\n" " igd-passthru=3Don|off (enable Xen integrated Intel gr= aphics passthrough, default=3Doff)\n" " kernel-irqchip=3Don|off|split controls accelerated ir= qchip support (default=3Don)\n" " kvm-shadow-mem=3Dsize of KVM shadow MMU in bytes\n" @@ -241,8 +241,8 @@ DEF("accel", HAS_ARG, QEMU_OPTION_accel, SRST ``-accel name[,prop=3Dvalue[,...]]`` This is used to enable an accelerator. Depending on the target - architecture, kvm, xen, hvf, nvmm, whpx or tcg can be available. By - default, tcg is used. If there is more than one accelerator + architecture, kvm, xen, hvf, nvmm, whpx, mshv or tcg can be available. + By default, tcg is used. If there is more than one accelerator specified, the next one is used if the previous one fails to initialize. =20 --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996614; cv=none; d=zohomail.com; s=zohoarc; b=BIiGusUm7EVVQ+Ou9J9NgcjiBcrwzw+EPTICoOYpRUCUKG1dRgC+pJiYtlN8de4Io2Yb31e9paKNV/0GIRSB8UbSuBHLVUeg0KXTK36VNBtspyk7Z72RqdOmhWFv5T6iyNAiMTIRYsEDqbOZN7WO18PzzjKiTxgSQb2L2DQ3IfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996614; 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=eHTeFILZi+U3w7nE87D0Nrp2o/VDEMaD0RN/V3cIXtw=; b=EmMRKprjsiZpZn8wTk9xWSnd/IGOTPSH7HWFfVqU0PP3h9dhHIr0/w1wYKH71+z8i6Z9vlj92Q2y0BwI75nNYtPxshp2zE2wdGVsep+JeesSuP2kB1XjJmUpQLRVWE5J4/4ZOoqMMwQRynVxN+JPx6oBSnuy1FYHo9AyQpk1lMQ= 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 1759996614669810.2055574509416; Thu, 9 Oct 2025 00:56:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lRK-0000Cw-8E; Thu, 09 Oct 2025 03:51:54 -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 1v6lRH-0000CD-Qk for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51: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 1v6lRE-0004Ue-Ko for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:51 -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-215-YDwSxAIsONChMSAAQLtP9g-1; Thu, 09 Oct 2025 03:51:45 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-401dbafbcfaso495383f8f.1 for ; Thu, 09 Oct 2025 00:51:45 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8e9703sm33775035f8f.30.2025.10.09.00.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996306; 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=eHTeFILZi+U3w7nE87D0Nrp2o/VDEMaD0RN/V3cIXtw=; b=Q+wNl2wzksEgvUSOMl4/juwUk9P1AHWp0pyRM2VTFg3Z6+SlQ82FXnHL5Fym/GwZxVPoTZ ZvKOchpVooy3sfWgKwZRgwApFh+XZ/PuqChmcNd6NLFm4G7OtpUdxaxXyOKlSqpWrV8w12 4o3TbbvFFvdqqchoq6aOTHUFQ2MXOI4= X-MC-Unique: YDwSxAIsONChMSAAQLtP9g-1 X-Mimecast-MFC-AGG-ID: YDwSxAIsONChMSAAQLtP9g_1759996304 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996303; x=1760601103; 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=eHTeFILZi+U3w7nE87D0Nrp2o/VDEMaD0RN/V3cIXtw=; b=twg219FtYuM/DLY6QtxW9hPFT62tVjp+n9Ii1zWZrSwiv30lD+9J/Itf9hrC/O/TdM waRF9grxWUEoRVx0wjWB2uN6z4FzjqaBaOmNXr1xMecilkvRIWpPocoCtp0wU3tvtrTN Hb2Pjas5XnzyKPNSODwJSaOMWRkuVvEioJ8ccXbULw0mVtbooY7kn40nQfYdbz49wR7W kpjeRy8ne1v8n6KHwFql/BtDIHTtwLvekSDmvb6+3LUd5YyfLuc8tm1vZVrt/zGN6k3E ayfwkGQW1ebtjCgxifI0HC3V5N3PpspUlLrAUy68Kc8to1IfaYTNKIqClK0591ptTX2J HIfg== X-Gm-Message-State: AOJu0Yx36oq+1fiaZvkI7dhuGO/9lQ8fQxVzZEMuPoVklI/xxbDMA0MF QgeGc9GGClhVBjD/Yp6g3j03rK6S87TIeS2lxSvXK5kO7vkxaWgZs5EA40Yf9FNhXAHBdf9atDV msVnqTvDublM9Ig6cJ6XpxOJ0ouZV0RQAG/bhSA3hFG5wgjU3cpN9aH+rjriJA9q+JQshnDB7gs /EEIvCLkYWjSH/O6W4/fpetQnKqXLa88V7bUBbj//KfYs= X-Gm-Gg: ASbGncuYHY0LIlIb0UlzGRzsM1ffagQPdLD2LfQ0V3g2LBY8jgq0xk/L22UiQeCe3rP lujXKgGeI0js3oTwWnvgCqfPSxCXLMdWSOwHgWDmBxPghG+VF3m2sHUJL258Hy2zPQ4eGTRKSeX QXfzm3f0f/f58uzURek7IaJSclaLpPSyUmFiINu5lrEhH0lJuUSktkGFVC1y99d4HBBSjz6t9FR y7ZlEseJxVe/Y8g/aBjUNPqwnhDctMiJmKE2MwcMkJC3sOKDVPqzbmScRk8VLXDIVoITCs2nXdD YdSjkgxf7rnhgCPXtbTU3PY8ZerKzsfyAyRaKqu3Y8ZDp0oZRMss/RglftgNvZVktGvoAHxhZct SLPa0fOIVaz8emN+ffgOitC3gptnatKMayG+EoQ/UYsODtZma X-Received: by 2002:a05:6000:2902:b0:3ec:3cac:7dfd with SMTP id ffacd0b85a97d-4266e7c4ac1mr4359749f8f.26.1759996303066; Thu, 09 Oct 2025 00:51:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEny1Kb6+tcK1YO0ttNmDO6HJ2eqRlaka6CAZq/CWAjKE8xk3fiLpBJ5F8K3zf/hCG/LazV/w== X-Received: by 2002:a05:6000:2902:b0:3ec:3cac:7dfd with SMTP id ffacd0b85a97d-4266e7c4ac1mr4359737f8f.26.1759996302557; Thu, 09 Oct 2025 00:51:42 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 33/35] MAINTAINERS: Add maintainers for mshv accelerator Date: Thu, 9 Oct 2025 09:50:23 +0200 Message-ID: <20251009075026.505715-34-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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: 1759996621865116600 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Adding Magnus Kulke and Wei Liu to the maintainers file for the respective folders/files. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20250916164847.77883-28-magnuskulke@linux.m= icrosoft.com [Rename "MAHV CPUs" to mention x86. - Paolo] Signed-off-by: Paolo Bonzini --- MAINTAINERS | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 406cef88f0c..645344c4faf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -551,6 +551,21 @@ F: target/i386/whpx/ F: accel/stubs/whpx-stub.c F: include/system/whpx.h =20 +MSHV +M: Magnus Kulke +R: Wei Liu +S: Supported +F: accel/mshv/ +F: include/system/mshv.h +F: include/hw/hyperv/hvgdk*.h +F: include/hw/hyperv/hvhdk*.h + +X86 MSHV CPUs +M: Magnus Kulke +R: Wei Liu +S: Supported +F: target/i386/mshv/ + X86 Instruction Emulator M: Cameron Esfahani M: Roman Bolshakov --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996745; cv=none; d=zohomail.com; s=zohoarc; b=XoKB1m9fFJ/swe684aTm251FdmLBid5nE8ODtaZzZF+O1wQi5yRPh/kKV93ydqhy/eRUuq0rwX3Y4jptsaP9ni9Pox8bpIoanvkSDmeIAzZx3GN+2o07u/UHUG5iBgOlJRWXyw/Yi9YRHHLifnxeJFRGTBgSibt4whvRnIHEqyo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996745; 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=hpLehWuVj/iTQMlAG5SBBBJrQjnUYuy4M749N9Qa2C8=; b=nHyCH6PRXMCRPz8eJC0fnQzSYEMYvooKYSe822SLGN/uZXRHBZBRK+9XDMfGqRllqs8vAMDBjed80vfENMtovO1mC2QTYisPWMm7LMXlBtkqr5YYS0kRFvpOC+Jj4Zad2Tn8FcooodYogZqz6WP6LzuS2AqJC6Hhdsd9Ve9pE6Q= 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 1759996745056862.1800089789365; Thu, 9 Oct 2025 00:59:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lRL-0000Dm-8X; Thu, 09 Oct 2025 03:51:55 -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 1v6lRJ-0000Ce-CB for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:53 -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 1v6lRG-0004Ut-PJ for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:53 -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-519-nwltMzyHNyS04xeH472pow-1; Thu, 09 Oct 2025 03:51:47 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-46e3d43bbc7so3140895e9.2 for ; Thu, 09 Oct 2025 00:51:46 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fb1e0f019sm13875935e9.10.2025.10.09.00.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996308; 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=hpLehWuVj/iTQMlAG5SBBBJrQjnUYuy4M749N9Qa2C8=; b=esskA8Ism16xjV8qpDXANW9uN0wLN3xmRZtixHpiInwv6QYFoSiFt3PcgDEUy1WLSP/DEw GvAfgcUDStkl1mjc4wkwO03dkBeXUF6/8jVaLp9FnK1A4CDk7n/vDuiBti3ZT1zk9zv34p nBgxP42y6MwGscpcb6kv6AccZC6SLAE= X-MC-Unique: nwltMzyHNyS04xeH472pow-1 X-Mimecast-MFC-AGG-ID: nwltMzyHNyS04xeH472pow_1759996306 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996305; x=1760601105; 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=hpLehWuVj/iTQMlAG5SBBBJrQjnUYuy4M749N9Qa2C8=; b=j6vn+UdfOm1B7o9WSw28TtJ7FT1dGQ3oOLSbXA93Wr1Cef1sTlMnwJmNH+z9+grEWt kbAnXr+rAj7tYdPn6gyd3Rnonzn4z45ctzKu7kuouNFJiav7LJK04A74ELFUI1aYUW1a ztBf4hyia7j3AdBuPyTkz+iNZRjfCBRUbiUAiN/gygGqfx3KIOb+/la/xkT8RW2Uvd4U eFUqB2pzLnTDEJ/VhFbsxDqG9IV6WNPBYLjRPbkndS0uXQT3eVyIZ9Z7/TBjK1UdRuWB Cox2DgEvb+LLLBpDpcdYB0oQZ0uUWoVNqVoozAbKXJt1D1D8SvQpXFLZ4OaMa1x5xzh1 M5MQ== X-Gm-Message-State: AOJu0Yz80/pTANhgQWq/vpVj5EzIsuZ/SK6KYEp53Phq0B3P5XGIZaUb 6Pl1CUAEn7rdCe39Eo9EvkT+rxLgJFqheh4KusXXkqbSTjHibf85LcZ2LRFLIRd6JrFkck/dN04 zMtDaBFaqlP0oBPvnudH6JsVrbIr2gksos6no8DRhHSnaM4uHBs3MpM5lGT2RN1MAI3Bnf5ORlS rrir3pMck3X/ioPXlmKHgm6YnT0cRNo+zFbYCz+fN/RmU= X-Gm-Gg: ASbGnctFWkd0FP70JE60gOE0z+LX1hutyfvsVqZowEwZfBQfA8aSEurVp9xTZT8v8g/ Vv5UUBvmPVviKb/24k6wGOFDAntreC5gyENgSvYixDBlW/t5yOYs1BXDtczKXB8I21rvDkX+1zV DQvc5NyxsDNTSMu0ukMiE9i5thF/n3pWXxb81agy5CxgGyISKFgMYjqyFIyehI4o0DS+CjNMY1L GwPSrpVYxdGQ9aD4eN7lNblYO02Aj+xhWSZAgjpLN8CUdacxyZCALI/4zpsBVp+S2KbmYHbqFMo YjNMRlYwJqzih4/7QiF1hUs7w+i5xzSL8U4bmzWdFm3BDbrIflm0GYM6VFZg3Ts6LwlpEVypmqW Oi06oyi59hJ/p5qXaXZgzchytYN7ZJaMkc354id1NMh3NKaTm X-Received: by 2002:a05:600c:19d2:b0:45d:84ca:8a7 with SMTP id 5b1f17b1804b1-46fa9a96712mr42492515e9.14.1759996305656; Thu, 09 Oct 2025 00:51:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyRaTWhC2L8anr87OdCOfpThLQPuwvxVjYJArYTqPkUqCXCt0RIp90HT1BjwVOd/Lo49yEVw== X-Received: by 2002:a05:600c:19d2:b0:45d:84ca:8a7 with SMTP id 5b1f17b1804b1-46fa9a96712mr42492325e9.14.1759996305188; Thu, 09 Oct 2025 00:51:45 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 34/35] tests/docker: make --enable-rust overridable with EXTRA_CONFIGURE_OPTS Date: Thu, 9 Oct 2025 09:50:24 +0200 Message-ID: <20251009075026.505715-35-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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, TVD_SPACE_RATIO=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: 1759996746321154100 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Link: https://lore.kernel.org/r/20251007153406.421032-1-marcandre.lureau@re= dhat.com Signed-off-by: Paolo Bonzini --- tests/docker/common.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/docker/common.rc b/tests/docker/common.rc index 752f4f3aed9..79d533ab2e5 100755 --- a/tests/docker/common.rc +++ b/tests/docker/common.rc @@ -53,8 +53,8 @@ configure_qemu() config_opts=3D"--enable-werror \ ${TARGET_LIST:+--target-list=3D${TARGET_LIST}} \ --prefix=3D$INSTALL_DIR \ - $QEMU_CONFIGURE_OPTS $EXTRA_CONFIGURE_OPTS \ $enable_rust \ + $QEMU_CONFIGURE_OPTS $EXTRA_CONFIGURE_OPTS \ $@" echo "Configure options:" echo $config_opts --=20 2.51.0 From nobody Fri Nov 14 22:21:13 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=1759996651; cv=none; d=zohomail.com; s=zohoarc; b=m3M+sRR6I7GHtDuStFaGCuuKQOpLzE6oBFUkHH8weBCRlTbo15ftXkDtFU5AWkxVLEPGCHfA1TUhO1LpGqJvwPE5CX2hLaXE0SnMEkOCb5c/EqtDhgsAiZHEVtO4ztMkLdwN7lsT9iA/M+vJANcpqnYHJ3keb8EeI26ymBNKJTE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759996651; 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=bcU076SoM74F/33kjQ/Q+W/mx4ZXb153IX1f2euibwI=; b=UYhXfb0EDlGIThheg33KBiN8ChJ5kkeJh/1o3O00Ko9ImPYbqqVpB1FmTsmkQyGxIzsc5kXe7TKF1kEMzf5r5ufeO6C5PKy89oZFwtnzx5OIYg8DpCncsx4A8kZW/JvR0Yr3CrjAqf16/arsn0uLBM2MDvLIeGtVk9n+GHuUALo= 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 1759996651057391.7830973060079; Thu, 9 Oct 2025 00:57:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v6lRQ-0000FH-9j; Thu, 09 Oct 2025 03:52:00 -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 1v6lRO-0000F2-Kl for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51: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 1v6lRI-0004VS-Br for qemu-devel@nongnu.org; Thu, 09 Oct 2025 03:51:58 -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-591-oxb1izrfNa-Nh7oOCaKwYg-1; Thu, 09 Oct 2025 03:51:49 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e3d9bf9e1so3607225e9.1 for ; Thu, 09 Oct 2025 00:51:49 -0700 (PDT) Received: from [192.168.10.48] ([151.95.36.217]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fab3703adsm30865855e9.0.2025.10.09.00.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 00:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759996310; 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=bcU076SoM74F/33kjQ/Q+W/mx4ZXb153IX1f2euibwI=; b=M1opwDJ0TB3VyCJ5gObKIxgNYGgYR1AmRKFcflZUX+dmEKYHks7cw9P1JHvb447bhDtlGA a76UkUYnhfZM6/VnzryKeIzrsvaR21va+XpLQpNEmAQi2mIX/c0JFs2Q3ahNQak5aXQOfS 8MgBETYcLu9kbPWZ1PAyyYU6DI7AWZQ= X-MC-Unique: oxb1izrfNa-Nh7oOCaKwYg-1 X-Mimecast-MFC-AGG-ID: oxb1izrfNa-Nh7oOCaKwYg_1759996308 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759996307; x=1760601107; 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=bcU076SoM74F/33kjQ/Q+W/mx4ZXb153IX1f2euibwI=; b=DQoumqOvbQpMFq95cwDVweEwtVIe+iZwKnEbCVN/jZLuZbIDPEE1qgvpzYWB/74MGa geJhqtBddtNbHjf1ZlOWEuaXRhTtKoyVQue3zIUB2vCGoTeW88f9PsJrsH6kqsbao4k8 GvdD82LEytZLjeXaXzAPpy1xu2o10G0gWxUfTIOnjlrEaWMhgRsoWKS5qzf6TzYvdDeg fv0G+b/ggtr8hfI8IE1Lh1wjc9r35KyLYgHH/hxQ2RaH48JRAy5d6TFs9wqSo1yPDSqy NIsJ+4T8Yp80Nl5ZmnzcM2kUEgBJeD3CYfqw1mVpPVlM+oX9v0J8s/mB1YmXJ0aDDe0+ Gvxg== X-Gm-Message-State: AOJu0YyeXmuS0jlZw9yCYOmZTgZFOGr/9kZ9rP4/y0ciSuW4CrIlpSnV +KCJoaEAmWvynBUrjpYX8/tB5O6kAZRZB4z0aoXxRAZtiUPzbUEaf5uQr9SFlA6v0OBJdU6SfB9 ZPNFM6XOdTodOlW3EWQ1sx3Na5OUrFmvvVADG+Vc0BSh+oiu2edNO7XLdQjNrOix5ATeAy6ghsI byaAv5SDrbqPMwqy5hZeHoFh6UKsW9ulOnN2LdQNlwoRQ= X-Gm-Gg: ASbGncvXk7m3F52wYvfZfdSISIA8bqfD4UyKRO6zzg6CC6HobTexHswGvYZejTrY3nz T8DjBXkDq9SXc0K2ZsDzYBM//zbUqY+ibOiiBTFu9KBky7LVn4u6gu4chf2Bou8Wx6g6fyefalT pUCIugq/avACcta9josXWvKk0UqyLiXmw/Gz3W10cKfFIRj5PJkxMt1/8AoCmtO7FA2PVTVZ/nx N74T0s21NdaDM//Akgn6bHqKb3hkolDdxstJ9VK6ybbh2LzpyDIW9CEu+aA5Ci0rJDtxtTOkMAR WsbWHA4Rc0Wn9aMeR2jL6RyD/Kzvo55eDPMFU8VVlksR/Tls0PncMFwOS9ehYx34RigB/4i4Dl+ UfqgQIF+VMTZQKV3IMU+CqGp++9XE7vOxRRFqQ2rxv0P03t/v X-Received: by 2002:a05:600c:a341:b0:46e:39da:1195 with SMTP id 5b1f17b1804b1-46fa9a8b3a9mr46844525e9.3.1759996307367; Thu, 09 Oct 2025 00:51:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXEG2+NoknKSyu0A7W0D3Dybmb6CnDsfaxxbjHCv2xdBMRFzAsRcXr6RT2mP4OXxd1ANJJ/Q== X-Received: by 2002:a05:600c:a341:b0:46e:39da:1195 with SMTP id 5b1f17b1804b1-46fa9a8b3a9mr46844285e9.3.1759996306916; Thu, 09 Oct 2025 00:51:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Manos Pitsidianakis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 35/35] rust: fix path to rust_root_crate.sh Date: Thu, 9 Oct 2025 09:50:25 +0200 Message-ID: <20251009075026.505715-36-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009075026.505715-1-pbonzini@redhat.com> References: <20251009075026.505715-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.442, 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_PASS=-0.001, T_SPF_HELO_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: 1759996653594154100 From: Stefan Hajnoczi Generated Rust root crate source files contain the wrong path to the rust_root_crate.sh script. Signed-off-by: Stefan Hajnoczi Reviewed-by: Manos Pitsidianakis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Link: https://lore.kernel.org/r/20251007194427.118871-1-stefanha@redhat.com Signed-off-by: Paolo Bonzini --- scripts/rust/rust_root_crate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/rust/rust_root_crate.sh b/scripts/rust/rust_root_crate= .sh index 975bddf7f1a..f05b8d02108 100755 --- a/scripts/rust/rust_root_crate.sh +++ b/scripts/rust/rust_root_crate.sh @@ -4,7 +4,7 @@ set -eu =20 cat <