From nobody Sat May 30 18:35:09 2026 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1778680653; cv=pass; d=zohomail.com; s=zohoarc; b=Z8/FpEt3Iodr09M/xvC6wbReixFkOt0Np8KLVuaDem0tRq3heWW4u92ur4kVw0Q0AxSg350mYTHooGe4hbjLw90c7BPvsdHUvlLYVcDyVYIxCz1XAHthXXUBkka1gzahBaetqHwUZJNUalkwpUUXpRX6fDUzS6uAt8SmE86lbyE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778680653; 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=SrPy7v2QPk+IGDXrf7SVDQGELYOPzQqg+/vhVFdGyrA=; b=DbBoUcU2nWG3RRjWVihDQ1jw+4YXkfiLp25+E3r2Tg6aHQq/ryNhBvXT636eiOnwvMBVfExhJIlnvV9FmcxqkyZPYYsh1YDGSol4gQd3JQampFQM097FdYnEEhuw/QUmS4rcbq/rHbdnGgaBJ8ZiO4zCs3J9wac5cPvUTvWkUpc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778680653332832.1278097996483; Wed, 13 May 2026 06:57:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wNA50-0004qt-Go; Wed, 13 May 2026 09:56:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wNA4z-0004ql-J3 for qemu-devel@nongnu.org; Wed, 13 May 2026 09:56:53 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wNA4x-0007Gj-FT for qemu-devel@nongnu.org; Wed, 13 May 2026 09:56:53 -0400 Received: from pps.filterd (m0127840.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64DAvdR72908691; Wed, 13 May 2026 06:56:48 -0700 Received: from cy3pr05cu001.outbound.protection.outlook.com (mail-westcentralusazon11023133.outbound.protection.outlook.com [40.93.201.133]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 4e3nvc5s4u-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 13 May 2026 06:56:47 -0700 (PDT) Received: from CH2PR02MB6197.namprd02.prod.outlook.com (2603:10b6:610:4::25) by LV3PR02MB10644.namprd02.prod.outlook.com (2603:10b6:408:28a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.25.17; Wed, 13 May 2026 13:56:45 +0000 Received: from CH2PR02MB6197.namprd02.prod.outlook.com ([fe80::90e9:29cb:631d:9ab]) by CH2PR02MB6197.namprd02.prod.outlook.com ([fe80::90e9:29cb:631d:9ab%4]) with mapi id 15.21.0025.012; Wed, 13 May 2026 13:56:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=SrPy7v2QPk+IGDXrf7SVDQGELYOPzQqg+/vhVFdGy rA=; b=YKTEUHfcucFFnDXzmdw4RjcB6KPKQJ/lmFiNgJ1En4pnORBblKQcNS1sC z3Kod30DmFyRE7r2YRWqqMnWACDX2PkoehkC2dVJFNXgHGzAcD38QLxRJGFfAI8R 78bkpLKhExLmlON0c068Qche6eoxrBB159h9yPdzjNTXrdMYhYoc0o5lJL6+5LyA 3QaLF7bsuphiui+czigOE/CJVaV/BKkW2Wnb7LsFUHSR/CGcJCle6u7xHJW4QLBk Jq914Nh1ZMNlE9j6fnuO5FRrVsCzBEPePjJErmwp/BYJY04pPP4IyIciaWKB6hZv FOH+nRT1d3Ro/lkfsN1csIk9XZICw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bfIOhZeZA6jaTcn8vEoXguO1ortHKhWKeTEmrpWTQunmhMfckvG1quRXwZYMa5sGbcBU0KHDhluJZiKPk4060vYtGUErRGERItwopMW1ZY9PTzT6Fl4ASlNQzm2nbdcgs3eULjp6WFLnLDlkRoP3n3PG4lhwjxe3SRLr7R44AJVr88wm0cduLIfXvkZBkdb5Ic3O+gnrL9ZsIXQboyze70l2AjrIdnCaqWlJQrhJtCyHTMHSdcpsdLcr/4979wJzuKO19zGfCd9w+jChCBdYHR3yEghMsMTgnivT2ch0/RLOLiUCVODw2MQIhae7meg7x2xksO1v3ajX3/9RRDn/+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SrPy7v2QPk+IGDXrf7SVDQGELYOPzQqg+/vhVFdGyrA=; b=ojuwo8+kr3/gjBkYz5KrUOiJuSYiUMr46iS2CNH1FgwBw4ALQY1zP6Wxn1oc7ndICuDz+QCLOJr+wBzimyqhPM7pZAMppDGlOqICmbOK+0riWna0YeQnPBY1tX+YXFua6fTuURWpoFIt3tY+aIPLw807xWhehWyhdo/5a0MNd2FKSD2ryFjQdKIg063EQDeKkqhuZIfsstztXTvLZnZsecF6Zmneha6z6PBqbWi/+TuaBYDSJiatWgKa2ugsH+j3WLivv7f+x793ANp5rxIAOMZF94vLhuQibMbmTN5mq6a3ydQYsK0qN5LWctBSSjK9fTGNTr45KkGWHI5GK998eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SrPy7v2QPk+IGDXrf7SVDQGELYOPzQqg+/vhVFdGyrA=; b=VKf3JzdcPS60PS7oq6kkBqSIv1J3+a712vFNplUuF+JYE3VGQce3MPUySc22t2S5EIYHee4yxC27FJlbFf3RvT4JQSkoaFsz33x5ZPUQntdDsc14/ntUNT492+xXUQ+lSkzuoK6zcWwdNobKehvH0IZqXUOxugOo9yNFPZwoqcpWuLuLnagB478XOEC1IsM+s1WkfYWBauLQJ8PLigEV4c6GQopgjGxLdY9w7+HP0OeBmI+qMoPnYWxhoXHHVBP+w0qoYRAim6pTzhrgM8gXBflYO8HHYfMkZIcgcGo6TJgtNmg483lzxt6Gy/JwHO1lb5gfIQ45eg/TrAsitCFHig== From: Florian Schmidt To: Paolo Bonzini , Zhao Liu , Marcelo Tosatti Cc: qemu-devel@nongnu.org, Florian Schmidt Subject: [RFC PATCH v2 1/2] Add HvExtCallQueryCapabilities Date: Wed, 13 May 2026 13:56:15 +0000 Message-ID: <20260513135616.3519354-2-flosch@nutanix.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513135616.3519354-1-flosch@nutanix.com> References: <20260513135616.3519354-1-flosch@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: PH7P220CA0022.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:326::23) To CH2PR02MB6197.namprd02.prod.outlook.com (2603:10b6:610:4::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6197:EE_|LV3PR02MB10644:EE_ X-MS-Office365-Filtering-Correlation-Id: f6eae396-90c0-4568-d1a0-08deb0f77848 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|376014|52116014|38350700014|22082099003|18002099003|56012099003; X-Microsoft-Antispam-Message-Info: UrMvHVHGQhnmg+S/0OX9sMMX2giIXbI0YnUGScuOQyjARyXOgxGk7nsiCbfOWldzru69UvPVLT3p0804C9ct5mPEnTwWd7O8ZZqyY5o/C0RhGHbw7sdUj/Ow4z4Rk8mX76GVGZVEeV/s3QhfZzYx+O4rYn3YPeRR46fKt4hNYmTK35XMwElx659+L7cbVSJGH/ZqOKl3FUNBqgrWhvyH+tbCU/Wy93cheaeFHaUlkNUaIQoEF1UjZH+5Hmc+KtPcPwIepDiPXz4roJmvpBk+OVGcmStDrbzv5IBq6s1B8KrNcQE5pfv1nUujD23C/BZPRbGCwtjVpK71tuxUjiCOwqypEbvcRL+CfjIUbJm+f02J2N5eEXZvnOhDxrcZEzt1ym3BAxPabQ+8Bi2lDBlitstFELWpxAyAQoIdZlx45wdsMXmw1TPHAOTXfz9ED9P6am3NXHROGFj3wIdxUQJJU40lZMgXb6rjWLORwI9fr4+GtuYEBFEe9HGThAnDPO128fVtsP//Lzg+kpbP65QuBfWJ9Eb54HTa8NlUVS6/Ihc8sRWR9vzRxtPajlomXevgy0Fp8M6VMxbCKYAqZryV/i4ENeuYlwQScFxDiYkKZFBeX+d2Nbi5GTNXm/AZismm2ITKQbB68bh/OBmvZ2O7ZBUEzW71YDD2zf6Be+AtRhibtuag1rq12cjO38TQuRuUYYQlrnNAHTQLqpa3jpyHvRKxRUbuIDRmJVf0zxAz8minWI9TS3SK4h10fva6Z+qP X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6197.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(52116014)(38350700014)(22082099003)(18002099003)(56012099003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?mLofvZDTor1Prcj3n7nFxqWOEeXtJmNT8hvKJjuBYi6waDuyZWeJM2c/TWbu?= =?us-ascii?Q?mXRZk/OeOmO7lHoKE6Nqk9sScokYKjtG2JSX+hKBvRkJrwpjMFXsLRl9aBs1?= =?us-ascii?Q?hLcQ4Run3aM8RQeADUVaWuxkAc1UIRghyDNlP/VDd8guTOQBN1yFzYAp0b9T?= =?us-ascii?Q?IGLRpI0sXp0i7fD7UpIxopxDnH/kBJ10vZLjpRqzgdFO+m1Vj1wtzZlorzbR?= =?us-ascii?Q?1szLpyHZ51KoZe/oBsmQ9Cmk/V26WbaSN4roNyx41qWk5Z5d6HBfmeeJD0M6?= =?us-ascii?Q?ftXUq2MZiMK9aDopXR1MZ/MUgbVWxpiwxSZafUyPlJNMAuC1Ne5pF1xVqtSy?= =?us-ascii?Q?yOIWLJlhCFJG6h8j4knz2FuNydy4/960fBynkAWVo/tdgqiz8gNAxwsDHcii?= =?us-ascii?Q?lOI/N/KUfHcjlbiDK142ay66R3tpYgc74/RjWhNrYC3iJI39iimGH8Tp+boA?= =?us-ascii?Q?UVQT/alZVUURcpOvO9jOnUJYeyZEz5wuV41Z5nUVMP5YnUuSDDilOS2491Ce?= =?us-ascii?Q?P2EpAnL34P+SXi/CkFliWBEbXFVa7Fv8HgHsC2eTD/lQW6yjfPkzaz8NakLZ?= =?us-ascii?Q?fu0xDgDb4Y611FVCcLMqgxzCrGW2lEfrx+dfCiae+VZwnbasWtEgkpL1UO3B?= =?us-ascii?Q?OjvcHpeQUu+foDvUi8Vq1PrYpuhC25l6rjw7P/0RdUC7ZQNU6w9jRw2dZ/UQ?= =?us-ascii?Q?MIo51T5i9d68LW5pB1lTnvqCBR8mrN/XOE6oqH2N9BOaqyH9t52rJ1fTCdV3?= =?us-ascii?Q?4GSdjduO2G4xRYYL9X9niKVFDA9lUvF6faR41TFnmy5a46i6DmsR2nfyd75c?= =?us-ascii?Q?OVkEqOctq7MZQSkFLBtKVc/q6fzP+27VNNqsJy1e25TdAB4xuwgWoRalvT4O?= =?us-ascii?Q?qYjLFyU7SvnbIJBehiscjKeRP9AeEyqDJrhOMqiNQoK1p5GAXEIUfwQKytew?= =?us-ascii?Q?0RXavMq1LBMm7+9IvKeE1eh3GFCkjdnWja5yFGEPfQ2mvve2xQmc3XdheCxi?= =?us-ascii?Q?8zqlOAz1uSiiXDrYsAXNzJvnHHLOMKaxk5a4y6oYW1+II5cT7suQ8nGFROax?= =?us-ascii?Q?BMcNx39JSnwAb5GUqzCXzpur4Zg6/LSAcTQNsr2t6CbSYE4HXIGN2zzq7rn2?= =?us-ascii?Q?hAgWdyCqvHaoHEEXU7Tg3V9hwFihyPAZwMqlRTO2au/ioYfqenSHYskaCOH/?= =?us-ascii?Q?2qCGlU0EQBXQD/B0fO6zxxNgPLg1uGl5nsayd1nJMjxmLci34VeV1MavKaBR?= =?us-ascii?Q?evKi/X2lDjBd0umDyknO3Glxcww23Fh07VbyZRRTzbO0vZpcaCYvxRPLS968?= =?us-ascii?Q?D20x2vkoic54VVkA0tHF1v/UkechmuBNqHkkPhPaA06TIEOXxwxmfKCNowDg?= =?us-ascii?Q?ZCzfSwVPkS/AF0cWdYZQRFUcSsRmn90rrtgH39uJlGxjPT2KLCTJmAoQw7EF?= =?us-ascii?Q?5hmitKLCeRn7kQUZ7P3Jg3uSZb7fmz0WIrX877mclXl2/O1zjejkWOvfJK7j?= =?us-ascii?Q?Xqyt2iFqzVIjl0y9TycpnxrDEcSbi4H+/AnYpnXK5psOpBJq1p7OAVOAq8JL?= =?us-ascii?Q?ITnLxmPuA3puMgZvTMzIAG5IqD0Eg4w0L2+hXZi1S1KbbNODLAoAwssQk6x3?= =?us-ascii?Q?C/eyTXYHQrHegqsePgIl9oDybV2LIf8+FIG0FIiCCa/PlRoRuDqwDZTWTDwX?= =?us-ascii?Q?d4UB9bwEQ83Cf9VC7YLlvZLVNsib2IC2fk65+2qCOY5tU0JGFatSV5ZUBx8M?= =?us-ascii?Q?l7JRejBfYy8Vj9FAuvbaV6tbeTqo2wI=3D?= X-Exchange-RoutingPolicyChecked: a/5zE7mxV7X1QKjJ+1/zX3zpyLOXO1iKFvGzKghOxp3lHGGdj/cIWD2ycK2PhWt2enjoutjU6dI3tQmGGJ7BzhxNWI8jNY7vcc4i8vCTklNB9zvFHomArk+9iYTnLZty+ssBz1U4+Gr1NGDn1csT00Rda+aslDIBuuG2tSVNWmoHabRsK8v8gWrzT1K13uwEwU6P8H1u6olO864g8e0SQlR29ARMW5gxt+kxuE3Wd2kKX4nNJq3lIfOQH6mGgj6+UI6Lu5zSYjS+LdzxouMJpALx6kswZ3I2Az2+1oh7kHci/oNEw+4FC+nW7fpZubRWgUy2om0j6SjAMvoLsl0tFQ== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6eae396-90c0-4568-d1a0-08deb0f77848 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6197.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2026 13:56:45.6095 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qIXelfAU34+QjvHNuA6xTxUX5gznzQvIQ0v6WT37wbZWuYT53Xh14cJIJCSBAYwaH4G615wFw1zSTY7x+JohTRvIDa+/3Ma4D/hlUJtD3jE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR02MB10644 X-Proofpoint-ORIG-GUID: XO9u8Lpn42U6zAKYHfmHIzsgxroRgf12 X-Authority-Analysis: v=2.4 cv=StWgLvO0 c=1 sm=1 tr=0 ts=6a048320 cx=c_pps a=vRE8MZZT2q/xz/g36YwB4Q==:117 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=z/mQ4Ysz8XfWz/Q5cLBRGdckG28=:19 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=0kUYKlekyDsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VofLwUrZ8Iiv6rRUPXIb:22 a=_-M8LpHI31CeLmyZm6wg:22 a=64Cc0HZtAAAA:8 a=LRr5n-MZAe6TyMRmVYYA:9 X-Proofpoint-GUID: XO9u8Lpn42U6zAKYHfmHIzsgxroRgf12 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEzMDE0MyBTYWx0ZWRfX/L/L109Vbuwv J+NuvVlEaWBM9Vxxkoc8w1sLzvgkdWsJSmpCP2VrZFN8IvvuEODfkyVKi7LzHRmDsLbAkwVA+yv Xfz+wRNamlLzf0Fe8ZBfiE1uYoAG2U3ohG8oKN8HaQBrviVe0vPPuMNDnLGbM4a6DxUCQp5/NhO gh4d0jlrci3Dv4onnEFyq6+WeLYFpQVyxSpvUh38hYnY9rMzFRYcP7IT9qAxTXSTq0boAuwhAak YXii0Q4aaX82yxNIQ12K4z+aRLi1bD+Cd90WdH6ApFKzBBQk1KZ4FHQ42+pqDD4NvgEAAyDZ2m8 7sibcdCRfiqHKM4s1bXowYxy+j96nW2dc9obnnl/VcFfG9oMReG/mTfdGcxMVonjzPmESNL+f+Q HSPrhKHVl9gONGaeqLP+W2MMaPlp+0jqq2xr19XSC+jeaY1YeAYJUVScDxTkmgNdJBFvkTokMHt wn6Ned63gZheu3QFRxg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-13_01,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Reason: safe 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=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.151.68; envelope-from=flosch@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @nutanix.com) X-ZM-MESSAGEID: 1778680654980158500 Content-Type: text/plain; charset="utf-8" On CPUID leaf 0x40000003, EBX bit 20 signals that we support the HvExtCallQueryCapabilities hypercall. This returns a bit field which signals which further extended hypercalls are supported (as a way to conserve CPUID leaf bits). We'll track such capabilities in kvm_hyperv_properties like all the others, but they will have a ".reg" entry of 0, since they aren't returned via CPUID and so don't have a corresponding register. For now, we don't support any extended hypercalls, but we'll add HvExtCallGetBootZeroedMemory in a followup patch. Signed-off-by: Florian Schmidt --- docs/system/i386/hyperv.rst | 7 +++++++ hw/hyperv/hyperv.c | 28 ++++++++++++++++++++++++++++ include/hw/hyperv/hyperv-proto.h | 1 + include/hw/hyperv/hyperv.h | 5 +++++ target/i386/cpu.c | 2 ++ target/i386/cpu.h | 1 + target/i386/kvm/hyperv-proto.h | 1 + target/i386/kvm/hyperv.c | 6 ++++++ target/i386/kvm/kvm.c | 12 ++++++++++++ target/i386/kvm/kvm_i386.h | 2 ++ 10 files changed, 65 insertions(+) diff --git a/docs/system/i386/hyperv.rst b/docs/system/i386/hyperv.rst index 1c1de77feb..c5ca25067e 100644 --- a/docs/system/i386/hyperv.rst +++ b/docs/system/i386/hyperv.rst @@ -256,6 +256,13 @@ Existing enlightenments =20 Recommended: ``hv-evmcs`` (Intel) =20 +``hv-ext-query-caps`` + Certain "extended hypercalls" are not signaled to the guest directly via + CPUID bits, but use a separate hypercall that returns a bitfield to sign= al + support for them. This enables this hypercall. On its own, it does not + provide any useful new functionality, but it's it's required to be enabl= ed + to use any extended hypercalls. + Supplementary features ---------------------- =20 diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c index a854a4927a..1764203d3c 100644 --- a/hw/hyperv/hyperv.c +++ b/hw/hyperv/hyperv.c @@ -703,6 +703,34 @@ int hyperv_set_event_flag_handler(uint32_t conn_id, Ev= entNotifier *notifier) return set_event_flag_handler(conn_id, notifier); } =20 +uint16_t hyperv_ext_hcall_query_caps(uint64_t sup, uint64_t outgpa, bool f= ast) +{ + uint16_t ret; + uint64_t *supported =3D NULL; + hwaddr len; + + if (fast) { + ret =3D HV_STATUS_INVALID_HYPERCALL_CODE; + goto cleanup; + } + + len =3D sizeof(*supported); + supported =3D cpu_physical_memory_map(outgpa, &len, 1); + if (!supported || len < sizeof(*supported)) { + ret =3D HV_STATUS_INSUFFICIENT_MEMORY; + goto cleanup; + } + + *supported =3D sup; + ret =3D HV_STATUS_SUCCESS; + +cleanup: + if (supported) { + cpu_physical_memory_unmap(supported, sizeof(*supported), 1, len); + } + return ret; +} + uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast) { EventFlagHandler *handler; diff --git a/include/hw/hyperv/hyperv-proto.h b/include/hw/hyperv/hyperv-pr= oto.h index fffc5ce342..f1d1d2eb26 100644 --- a/include/hw/hyperv/hyperv-proto.h +++ b/include/hw/hyperv/hyperv-proto.h @@ -35,6 +35,7 @@ #define HV_POST_DEBUG_DATA 0x0069 #define HV_RETRIEVE_DEBUG_DATA 0x006a #define HV_RESET_DEBUG_SESSION 0x006b +#define HV_EXT_CALL_QUERY_CAPABILITIES 0x8001 #define HV_HYPERCALL_FAST (1u << 16) =20 /* diff --git a/include/hw/hyperv/hyperv.h b/include/hw/hyperv/hyperv.h index 23091301d0..e29d60f565 100644 --- a/include/hw/hyperv/hyperv.h +++ b/include/hw/hyperv/hyperv.h @@ -97,6 +97,11 @@ uint16_t hyperv_hcall_retreive_dbg_data(uint64_t ingpa, = uint64_t outgpa, */ uint16_t hyperv_hcall_post_dbg_data(uint64_t ingpa, uint64_t outgpa, bool = fast); =20 +/* + * Process HVCALL_EXT_QUERY_CAPABILITIES hypercall. + */ +uint16_t hyperv_ext_hcall_query_caps(uint64_t sup, uint64_t outgpa, bool f= ast); + uint32_t hyperv_syndbg_send(uint64_t ingpa, uint32_t count); uint32_t hyperv_syndbg_recv(uint64_t ingpa, uint32_t count); void hyperv_syndbg_set_pending_page(uint64_t ingpa); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 97c66c2226..4d77de52b4 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -10760,6 +10760,8 @@ static const Property x86_cpu_properties[] =3D { HYPERV_FEAT_TLBFLUSH_EXT, 0), DEFINE_PROP_BIT64("hv-tlbflush-direct", X86CPU, hyperv_features, HYPERV_FEAT_TLBFLUSH_DIRECT, 0), + DEFINE_PROP_BIT64("hv-ext-query-caps", X86CPU, hyperv_features, + HYPERV_FEAT_EXT_CALLS, 0), DEFINE_PROP_ON_OFF_AUTO("hv-no-nonarch-coresharing", X86CPU, hyperv_no_nonarch_cs, ON_OFF_AUTO_OFF), #ifdef CONFIG_SYNDBG diff --git a/target/i386/cpu.h b/target/i386/cpu.h index a836efd45e..eb870fa015 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1480,6 +1480,7 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *c= pu, FeatureWord w); #define HYPERV_FEAT_XMM_INPUT 18 #define HYPERV_FEAT_TLBFLUSH_EXT 19 #define HYPERV_FEAT_TLBFLUSH_DIRECT 20 +#define HYPERV_FEAT_EXT_CALLS 21 =20 #ifndef HYPERV_SPINLOCK_NEVER_NOTIFY #define HYPERV_SPINLOCK_NEVER_NOTIFY 0xFFFFFFFF diff --git a/target/i386/kvm/hyperv-proto.h b/target/i386/kvm/hyperv-proto.h index a9f056f2f3..4eb2955ac5 100644 --- a/target/i386/kvm/hyperv-proto.h +++ b/target/i386/kvm/hyperv-proto.h @@ -46,6 +46,7 @@ */ #define HV_POST_MESSAGES (1u << 4) #define HV_SIGNAL_EVENTS (1u << 5) +#define HV_ENABLE_EXT_HYPERCALLS (1u << 20) =20 /* * HV_CPUID_FEATURES.EDX bits diff --git a/target/i386/kvm/hyperv.c b/target/i386/kvm/hyperv.c index 420c76b5ff..807acaf6b1 100644 --- a/target/i386/kvm/hyperv.c +++ b/target/i386/kvm/hyperv.c @@ -17,6 +17,7 @@ #include "hyperv.h" #include "hw/hyperv/hyperv.h" #include "hyperv-proto.h" +#include "kvm_i386.h" =20 int hyperv_x86_synic_add(X86CPU *cpu) { @@ -117,6 +118,11 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_= exit *exit) exit->u.hcall.result =3D hyperv_hcall_reset_dbg_session(out_param); break; + case HV_EXT_CALL_QUERY_CAPABILITIES: + exit->u.hcall.result =3D + hyperv_ext_hcall_query_caps(hv_build_ext_call_caps(CPU(cpu= )), + out_param, fast); + break; default: exit->u.hcall.result =3D HV_STATUS_INVALID_HYPERCALL_CODE; } diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 9e352882c8..586656258d 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1136,6 +1136,13 @@ static struct { }, .dependencies =3D BIT(HYPERV_FEAT_VAPIC) }, + [HYPERV_FEAT_EXT_CALLS] =3D { + .desc =3D "query availability of extended hypercalls (hv-ext-query= -caps)", + .flags =3D { + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EBX, + .bits =3D HV_ENABLE_EXT_HYPERCALLS} + } + }, }; =20 static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max, @@ -1433,6 +1440,11 @@ static uint32_t hv_build_cpuid_leaf(CPUState *cs, ui= nt32_t func, int reg) return r; } =20 +uint64_t hv_build_ext_call_caps(CPUState *cs) +{ + return hv_build_cpuid_leaf(cs, HV_EXT_CALL_QUERY_CAPABILITIES, 0); +} + /* * Expand Hyper-V CPU features. In partucular, check that all the requested * features are supported by the host and the sanity of the configuration diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 2b653442f4..8c71ad01af 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -72,6 +72,8 @@ struct kvm_cpuid_entry2 *cpuid_find_entry(struct kvm_cpui= d2 *cpuid, uint32_t cpuid_entry_get_reg(struct kvm_cpuid_entry2 *entry, int reg); uint32_t kvm_x86_build_cpuid(CPUX86State *env, struct kvm_cpuid_entry2 *en= tries, uint32_t cpuid_i); + +uint64_t hv_build_ext_call_caps(CPUState *cs); #endif /* CONFIG_KVM */ =20 void kvm_smm_cpu_address_space_init(X86CPU *cpu); --=20 2.47.3 From nobody Sat May 30 18:35:09 2026 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1778680630; cv=pass; d=zohomail.com; s=zohoarc; b=FFQ2dzHBgcDbFMFXytMqyePWFfnaGD37BvZMGKhdl8I7pv9r0nuSnO3Dmmx91UB5Pf4kRsqBqid5vvfGCB9WxgriHRJ6TmnNekgLDpjmGKeQqtF3JrNRFBe+t2gQzTP6SBvkmXJU+H0SvliKGptJmL29nenx+DxhuPJjzRgcp/w= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778680630; 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=T2ciN/f7SbUh1blrfIHdCUBVDM5FzNV/kwAJxSJjz1o=; b=fqVEVrFWflDVWVMXJBUgjfKPMH3+CCr7U7yTT7HloP3ntKL9dsj2i2iHwdrNlH+qWHzh9T6XAD/5gijpwlEJRg2BIVJFsWmsQURDT0Jt/h25p3YcBaOmOwNKqG3zYhxBlckr8HsXv+nGD7kCPlSqqAgjttK4a9H/ISzzVN0U1EU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778680630901898.1126486196041; Wed, 13 May 2026 06:57:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wNA57-0004rV-Jb; Wed, 13 May 2026 09:57:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wNA53-0004rE-TH for qemu-devel@nongnu.org; Wed, 13 May 2026 09:56:57 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wNA51-0007Lb-32 for qemu-devel@nongnu.org; Wed, 13 May 2026 09:56:57 -0400 Received: from pps.filterd (m0127837.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64DAl33n4000222; Wed, 13 May 2026 06:56:53 -0700 Received: from cy3pr05cu001.outbound.protection.outlook.com (mail-westcentralusazon11023082.outbound.protection.outlook.com [40.93.201.82]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 4e3nvpwt49-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 13 May 2026 06:56:52 -0700 (PDT) Received: from CH2PR02MB6197.namprd02.prod.outlook.com (2603:10b6:610:4::25) by LV3PR02MB10644.namprd02.prod.outlook.com (2603:10b6:408:28a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.25.17; Wed, 13 May 2026 13:56:51 +0000 Received: from CH2PR02MB6197.namprd02.prod.outlook.com ([fe80::90e9:29cb:631d:9ab]) by CH2PR02MB6197.namprd02.prod.outlook.com ([fe80::90e9:29cb:631d:9ab%4]) with mapi id 15.21.0025.012; Wed, 13 May 2026 13:56:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=T2ciN/f7SbUh1blrfIHdCUBVDM5FzNV/kwAJxSJjz 1o=; b=Cq4GDbKxj+f0Zr2S+uVTsnX+P6K1hbuOeblyckpZoKUwKjtn5O3VmPM94 2waofiQxOGTwtg2H2Q9x62niBc7KvymOE6H4JjSHcRaKAdlyCyg4pKxVuBijlQ0g jOOE8VTzr84MFyOo+4KHbI5BogAOZdmmArixQzVVx4hc7UGW2X76LpPToOxExCfo 2XnP4Iamk72OdkYs5clGwscssNg7bWdmvJRMIjDmYlWTb5KrkNsKVdQ1DAnl04KS uuj9hylrxr444tORtHYGYpdOVWO+M8AUSZvQ5GcMpM3Lh2IvskyedCSycmAYn3ca dyXk6ySoh5MUtQRTGqATw8Xu7nTIg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sfcQMggIexV2TdNjFD+YOPqeiPZ6vRJIQzAoiHp1UNhxsZkCWnAhY5N3XMRFyjisPdUL34uYSW+jAhd1+mRROZ0iCGZ6Y7mdFoC0Lojl9qso7wMhDIqvFzjFvzIGwhAbzJBgJy2wrELJqRlJ27IAzQ3K9m+2IzzKprHP0yMBjdAqJ9oPnRWZhROOfL1F2eGfdMpH01w82o5c+5tjvMSztHcUCc3kPI/A+pr9wW22mbxK75XPFSVKQPsdbg7mnA3P7alrvlM5EMqhziJze2s3SheGxxTjXepGyipVLI/lpoB7sRBsHJEStRTWIAzKSBPPMwScNnohWdvgWfsqoLpaHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=T2ciN/f7SbUh1blrfIHdCUBVDM5FzNV/kwAJxSJjz1o=; b=YK+dN4UgKrEmOXzr0NOGCqHv5PN2UdXJtWODdRClFnsOZ7Acuz8U8JxDWhFzYj21hSqugseSgmDPP49tas7uweVCgkU+PkN2HNKVJO02d3Hme01ZZZYTJArq/sorfen/lon+zrmIrT7TSIIw0EAoW4nc3yt3JgAFIUO91/cM9R11uhFK7OTc+Hv/A6mkzpEgOd8HDvRQaPfcsxX4RwIxRXXote46aRWWh2f/GosNmdeVR50oxlyosiLMs6QxF66gMiW1cFeovTveKTa8YbbCyo9x2usl7gUw8xkCjUsUc8wl2o2qtCY9lzks+8wto655kgq8uQIPllp5a+cGuGO3qQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T2ciN/f7SbUh1blrfIHdCUBVDM5FzNV/kwAJxSJjz1o=; b=Tms0VzPXj4wXuR46CItE85gsU/p7dYYi+Ga0q1C2KCeder91vCqPSrYiiiUqEKQ5vgexDmLJLi7KRAbVbwZon7gvildcB7XHsagF7/leNT5TNbJN6StN/psuJP+r7A3p1dgAHfxh27orUZ6Z4l3i+Gt3JxqG+k0J0QgZEuXEIGIDBtHxE4tw2WQ0ZYJ92bacJe/IEQOAh7DAqzmQTkMVUoz4nJ6zoGzkwTriF2eX11YzZhTK9a72jzaH/J0mt2hfzDamQy8RU4gkYQbPbTn/lxoUQAkxNjmsCoLqpeQnjhlecCX5rHqj+SyzdHLKqG7yfQcxlaKXGBZdo3h1LjvDxg== From: Florian Schmidt To: Paolo Bonzini , Zhao Liu , Marcelo Tosatti Cc: qemu-devel@nongnu.org, Florian Schmidt Subject: [RFC PATCH v2 2/2] Add HvExtCallGetBootZeroedMemory Date: Wed, 13 May 2026 13:56:16 +0000 Message-ID: <20260513135616.3519354-3-flosch@nutanix.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513135616.3519354-1-flosch@nutanix.com> References: <20260513135616.3519354-1-flosch@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: PH7P220CA0022.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:326::23) To CH2PR02MB6197.namprd02.prod.outlook.com (2603:10b6:610:4::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6197:EE_|LV3PR02MB10644:EE_ X-MS-Office365-Filtering-Correlation-Id: 7cf3c52e-b1df-4bd9-454b-08deb0f77b71 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|376014|52116014|38350700014|3023799003|22082099003|18002099003|56012099003; X-Microsoft-Antispam-Message-Info: lVy621K3r0IWbRtL/Yx0S7trFCETc+UCmyDbtJRZw2pEqdVULTz8gCh6//3uaIax8yo9dy/Jkl+bQ3bIxFwJQLb6ZYLXO5jKsV2EyQUw19t0X6G7CNbXcCmEKEXHo8v/wdJ/9M2oq/suvWHd9NsDoQE7RxaGLAMHmYui8s7BQ4+UPbiYA23+I89RMYhQdg1XvjMb98uPOyFtb0wtZgBQ5oPNl4k/dVqt5q9wABZquTglLpNXvw4HmjETFBHRUwCkBjDcEmmwrDCR0I4q/GaH9rL1aNvEqPWLvNQ2JI5SpXBZDcOwlwjJJEBE5X4BLbTfRMOPxvO/IYcj//4nJ+nL1DLuxHRLusJUVjP3x8JiIIz/6j1KKRci0YQG9sjhCAzVH2R2Fs5+bJNOaxyfKL+xZZA8bBB3dmHEEeMYJKhsPil+xviY2zaQJBXz8dovyQXzI7je+RnVCmMVJ9Zo5TyUwd462sIAvKdPl5YUSbca8FDTscpROl74CNbHXkU+6EEfQnQv/rwKkQ8UllR+4aQOkk+d84uVbYtnfv6UXaXVSp6OXMHOKnwlwFxDt8h8AnjsTvvP6uLBURFNyiwegobk9aHpoSwU5XabakjmlF78p7b7AYGOnYKFa6al7C7KuzvngwxxhT9RIb/NjGSEBu8AwsIgM70k6w1teXbgl7LLrIXElVaE2RtpW7enHhJZvb5GVgoKG4YgJIJz5UwImvqhE9tQPS3yBL686sroF1SbPWIke2Im5KZSen2xU5O7K+Oa X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6197.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(52116014)(38350700014)(3023799003)(22082099003)(18002099003)(56012099003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4A0kMk+e7dcTWtgWFpwPmTyqfp36GB64290QrJQsts3FvkBsf5QLOqu3Sfp7?= =?us-ascii?Q?jT+CW0Ei5FvOBo02ey7WA3lqkldTqyllLoAiB6KlgV8MO0Aq96vfw0UeHQuy?= =?us-ascii?Q?JkeQua8syqIoGdnlI9Tsrh2VYdzdvxYVLwRvzu12ggXVO1Zql/JJmPIaXp2r?= =?us-ascii?Q?UkbLS7ZYS/jkAUnnvjiBYfj8CuRarWIdT5l4l5vNVFZVlORAfvcn1ZSDSu2r?= =?us-ascii?Q?E2cw/TQdl85LFl42H+6CmzFWdl+wIHqMiKjEXbj767qXMR6vRoteXOm92ul3?= =?us-ascii?Q?ZDXgBAEHOtLgl94XAHQtCqNhokPfgynbGnBgN3S9lH5k8kYWtV9T2PRPDyjv?= =?us-ascii?Q?oDgj8SIGbUfqALraDMjxmPdrf/uLdQOn8po7U32U/ts/AhhLC3LDu8KMNS81?= =?us-ascii?Q?lNV8AoujuNdrx2GPXjZFfgEoJSDAbNxE6M3GmrUU6aVLDYfVLzWaQvZzrENX?= =?us-ascii?Q?eT6oOWDui0e5UZhcMChC9CQIYKiJ/pe6gafDoXATD9SyV7uCkfanFngiL5Qq?= =?us-ascii?Q?2M28fU3YH0qcwMZr+QpKswk1wDrmw6tmdaJW4nrjGZiy3+oCUmR8SgNXCOl6?= =?us-ascii?Q?Wkk9RUgGVlO5KbbqFnDnA/EyVUG+q+PCg0xOIv1gmjbTYeRy3jAFrj2Qusgo?= =?us-ascii?Q?J/UixSuE11w/ZWC1Lwv8MUYHgu+3/+VmAf3z1y4SDCIGab7yN35DLfQeLcoY?= =?us-ascii?Q?6ZYxZLeiFXkhdvccw3DFkiguYolNs38bGtJr8DvvBwWmtpOKFvoZbGLJwP0D?= =?us-ascii?Q?Va2LlXBzRUasZ8xgKk/kjBWZlOk4DvdaSUtmdQhLBAxnPmHSvntid4Mh5BdC?= =?us-ascii?Q?TefbgbYfMJSvaFIZzCGCUbfBTAunUFISOP43mWybmBbwWz1DDAg+uNsRiWmD?= =?us-ascii?Q?RcpS4n6wsYmmaUpA3PvZwGOWiKzyUqWTQVNgmUibYhtuhUE6U14Zsel3Dyl5?= =?us-ascii?Q?mi2iHi39gZO69635Prfcw6ahD6fv27ZaKGUXeelMPwEve5sAG3W01kTLIKPW?= =?us-ascii?Q?mMy9XAh0iB/7w2lyr73vKK8iEYq4E40phZpm5zEAZWcUHJTwHYWo4Q6cvilY?= =?us-ascii?Q?4R1TokypgdnN3EC//1KKAcIq9ybvaGpDurLYPf+JMA1SSO9qay936JfAFi7e?= =?us-ascii?Q?yXlfTPMCFthwiQEbjqe8fI+MRtq+Nw7+UpXpXFydQuo8Aw+BNECJdTYtzOE7?= =?us-ascii?Q?93Kdas2sfbxIguCJQJJMEFN33Z+8k7Oylx07MTd5n3ZSnObLJrelsRkoMZ0w?= =?us-ascii?Q?smUToXNQXiRkqpyPjoDYj1yH7ydtuwwUvUqq6ufwM9nn3+holbk0FO56MAEQ?= =?us-ascii?Q?3+ElbPrPMm0EWUcyrQqpDjP/YHcr1WgOCfnkQqN8DSF0Vig5p1SopD5Y7AKY?= =?us-ascii?Q?YbeZGwf5m9bq2YruQsmcwGftu9QA32wqZQ/5ynxh7dtYp/3PjFlvBTsP/uVS?= =?us-ascii?Q?yZGq6/lC90gnIuvVhUaibes6p2G/oX47u1r/BWnLTd3yD9IUXy35NtDhj1rt?= =?us-ascii?Q?iPt6w5CMlAmv9hIFF+I6n+d13OWn/8MVxqtU4lHzGPGpk1BZ24Sce7C6a9Gw?= =?us-ascii?Q?uVKpVArFXXIFfpU9bxp6IFOMH9oLkvhyVDGHg2/pRWwZgRY7OO88EyNrwf3G?= =?us-ascii?Q?t49I8OAJ3EtitdYGJ/ODPwQWQKhnBaXQRn/VsZcbP4jVS9FTlzAeMiqyEiHt?= =?us-ascii?Q?ZPpOTRK1TqvJ0U99JrrEvvqcI2w0YE0RgnNUZLXth9AD4ss0XSduA+QrK8zt?= =?us-ascii?Q?d68IRP8qpvnAej2XkG8hy0X8UnZYhyM=3D?= X-Exchange-RoutingPolicyChecked: HktCVBlYcFlWF2LCbCoIifn5oPrvzQtdAtTN0wmONW/rSfq2ocqBo2jHmBhX8LIRh6wW5jogwseWnnqlBOG5k9erKEcKG9UDhn1FgHAPdNsj0Q6owq3qSO+c91vjx14Zf9wOxJ6EWwJpF+Ihs8ZZYXMUbMHxTHy+wZBK11sFeW5+IHwZJL2rsEEZw3jEga1xU1qsdVuY8Fz7EOqae/jMh2YDvkqjdStKvJ+v45V5oERPmtGgjz8JWQ8zV+AnO6rdsADJl58hb/FSCVQl0mOGHjwCUjPp6f113ABHzRtsJGVAz2Sn1yfZ77QoZfu5WzI9nZf4tdMwx9YdF5AaFFi48A== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7cf3c52e-b1df-4bd9-454b-08deb0f77b71 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6197.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2026 13:56:50.8917 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PRHWJHz709UjFBQPY9JXJTSxqfDCEMObmHlHesyGCw1U2DdV4fEMLqTJrTQWeyRp5pMd4vCElg7+Ds9Cam7H7AkVvyysUw1C3S6MEEaISvY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR02MB10644 X-Proofpoint-ORIG-GUID: QDbciS6NpFYTEyOhsHxeM5QjrTvNRZ_K X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEzMDE0MyBTYWx0ZWRfX4oslzKMJcZfQ 4ziTKXnuzzw+dlS1QHNkz8jhmBJIYQ8hyfwlSuMtUyTfOwSE0pO4EJkGBQuGhl7JdRWH4irxRZB 4v1zrUIeQtaTkvoHvafiVF3yMnLq9BBZZjOa2Wih23qpRnHg78wla+VaG1RcgRy5jRm7jo+iJRr wG7jnLbzJ0nQpE0MeH9RS1qMd53qZsnECr9GvPY/fF6esneg7u0f1aniO7G1b+EtAWjLWZSS4PP bkUTwuqgaQDUOl3r7RUw0NlsSSBRccPzXWMJmUOVe1MlGh1SJv42/c3wezpQSeV9BbdRndBJj+q Od3VZjcaKcVhbAHKeXXPWdTvn9+fNCYRoebAnThoix88Kyfo6qpT4UsPriNpKWURUOVsjjiaaYb U17/mfhddcRbABK6O9LoXEEopFdzahRh2rlxMIVfq2S2l7F29vEpmDLZofShvpVq8Up9fShdNfs JXO+Cwz+xczLIdp3LCg== X-Authority-Analysis: v=2.4 cv=TuXWQjXh c=1 sm=1 tr=0 ts=6a048324 cx=c_pps a=ulKS55DWmiSHHqtbYmVMKg==:117 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=z/mQ4Ysz8XfWz/Q5cLBRGdckG28=:19 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=0kUYKlekyDsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VofLwUrZ8Iiv6rRUPXIb:22 a=Ap8k9tRZuQ82DLYWQqG7:22 a=64Cc0HZtAAAA:8 a=y-RcV8gkgojH_-w_mxkA:9 X-Proofpoint-GUID: QDbciS6NpFYTEyOhsHxeM5QjrTvNRZ_K X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-13_01,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Reason: safe 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=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.151.68; envelope-from=flosch@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @nutanix.com) X-ZM-MESSAGEID: 1778680633249158500 Content-Type: text/plain; charset="utf-8" This call allows a guest to ask the hypervisor which of its (guest physical) memory ranges were already zeroed out by the hypervisor, which means there's no need for the guest to zero them out again at boot. To do so, we have to track what memory is not zero any more. The conservative estimate for this is to consider all memory that we ever touched to not be zero any more. To track this, we introduce a new bitmap, independent of the existing dirty tracking maps. This is for several reasons: * Dirty memory tracking bitmaps are always allocated. This is wasteful when we only want this bitmap for one specific use case. * Dirty memory tracking is tightly aligned with target page sizes. We want to track at a much coarser granularity, which reduces the bitmap size, and will also make our hypercall reply have fewer fragmented areas, without losing too much of the benefit. Note that there are limitations of what we track: we only track initial memory. Memory hotplugged later will not be tracked, and so never reported as pre-zeroed. We also don't track non-zero memory over migrations. Both of these are fine with respect to the use case: Windows only enquires about zeroed memory relatively early during boot, where both of these operations are uncommon. For those cases, we simply report "memory is not pre-zeroed". Finally, we currently don't track memory that the VM itself touched. For this, we will need KVM support, and likely a new ioctl that helps us track memory mapped by the guest. Signed-off-by: Florian Schmidt --- docs/system/i386/hyperv.rst | 7 ++ hw/hyperv/hyperv.c | 121 +++++++++++++++++++++++++++++++ include/hw/hyperv/hyperv-proto.h | 11 +++ include/hw/hyperv/hyperv.h | 7 ++ include/system/physmem.h | 8 ++ system/memory.c | 7 +- system/physmem.c | 52 +++++++++++++ target/i386/cpu.c | 2 + target/i386/cpu.h | 1 + target/i386/kvm/hyperv-proto.h | 5 ++ target/i386/kvm/hyperv.c | 8 ++ target/i386/kvm/kvm.c | 17 +++++ 12 files changed, 244 insertions(+), 2 deletions(-) diff --git a/docs/system/i386/hyperv.rst b/docs/system/i386/hyperv.rst index c5ca25067e..71ee456921 100644 --- a/docs/system/i386/hyperv.rst +++ b/docs/system/i386/hyperv.rst @@ -263,6 +263,13 @@ Existing enlightenments provide any useful new functionality, but it's it's required to be enabl= ed to use any extended hypercalls. =20 +``hv-boot-zeroed-mem`` + Enables the HvExtGetBootZeroedMemory hypercall. This allows a Windows gu= est to + inquire which memory has already been zeroed out by the host and thus do= esn't + need to be zeroed out at boot again. + + Requires: ``hv-ext-query-caps`` + Supplementary features ---------------------- =20 diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c index 1764203d3c..c99b247bc8 100644 --- a/hw/hyperv/hyperv.c +++ b/hw/hyperv/hyperv.c @@ -13,6 +13,8 @@ #include "qapi/error.h" #include "system/address-spaces.h" #include "system/memory.h" +#include "system/physmem.h" +#include "system/runstate.h" #include "exec/target_page.h" #include "exec/cpu-common.h" #include "linux/kvm.h" @@ -23,10 +25,13 @@ #include "qemu/queue.h" #include "qemu/rcu.h" #include "qemu/rcu_queue.h" +#include "hw/core/boards.h" #include "hw/hyperv/hyperv.h" #include "qom/object.h" #include "target/i386/kvm/hyperv-proto.h" =20 +#define HV_BOOT_ZEROED_PAGE_SHIFT 9 + struct SynICState { DeviceState parent_obj; =20 @@ -731,6 +736,98 @@ cleanup: return ret; } =20 +struct boot_zero_opaque { + struct hyperv_get_boot_zeroed_memory_output *zr; + const unsigned long *zero_blocks; + unsigned long num; + unsigned int order; + unsigned int count; +}; + +static bool bootzero_mem_cb(Int128 istart, Int128 ilen, const MemoryRegion= *mr, + hwaddr offset_in_region, void *opaque) +{ + struct boot_zero_opaque *p =3D opaque; + ram_addr_t r_start, r_pfn_start, r_pfn_end; + hwaddr ram_gpa_pfn_offset; + unsigned long b_start, b_end; + unsigned long begin, end, idx; + uint64_t pfn_start, pfn_end; + + if (!memory_region_is_ram(mr) + || memory_region_is_rom(mr) + || memory_region_is_ram_device(mr) + || (int128_get64(ilen) =3D=3D 0)) { + return false; + } + + r_start =3D memory_region_get_ram_addr(mr) + offset_in_region; + r_pfn_start =3D r_start >> TARGET_PAGE_BITS; + r_pfn_end =3D (r_start + int128_get64(ilen) - 1) >> TARGET_PAGE_BITS; + ram_gpa_pfn_offset =3D (int128_get64(istart) - r_start) >> TARGET_PAGE= _BITS; + b_start =3D r_pfn_start >> p->order; + b_end =3D MIN((r_pfn_end >> p->order) + 1, p->num); + + idx =3D b_start; + while (idx < b_end && p->count < ARRAY_SIZE(p->zr->ranges)) { + begin =3D find_next_zero_bit(p->zero_blocks, b_end, idx); + if (begin =3D=3D b_end) { + break; + } + end =3D find_next_bit(p->zero_blocks, b_end, begin); + + pfn_start =3D MAX(begin << p->order, r_pfn_start); + pfn_end =3D MIN((end << p->order) - 1, r_pfn_end); + + p->zr->ranges[p->count].start_pfn =3D pfn_start + ram_gpa_pfn_offs= et; + p->zr->ranges[p->count].page_count =3D pfn_end - pfn_start + 1; + p->count++; + idx =3D end; + } + + return p->count =3D=3D ARRAY_SIZE(p->zr->ranges); +} + +uint16_t hyperv_ext_hcall_get_boot_zeroed_memory(uint64_t outgpa, bool fas= t) +{ + uint16_t ret; + hwaddr len; + struct boot_zero_opaque priv =3D { 0 }; + hwaddr write_len =3D 0; + + if (fast) { + ret =3D HV_STATUS_INVALID_HYPERCALL_CODE; + goto cleanup; + } + + len =3D sizeof(*priv.zr); + priv.zr =3D cpu_physical_memory_map(outgpa, &len, 1); + if (!priv.zr || len < sizeof(*priv.zr)) { + ret =3D HV_STATUS_INSUFFICIENT_MEMORY; + goto cleanup; + } + + priv.zero_blocks =3D physical_memory_get_mapped_ranges(&priv.num, &pri= v.order); + priv.num *=3D BITS_PER_LONG; + + priv.zr->range_count =3D 0; + if (priv.zero_blocks) { + RCU_READ_LOCK_GUARD(); + flatview_for_each_range(address_space_to_flatview(&address_space_m= emory), + bootzero_mem_cb, &priv); + priv.zr->range_count =3D priv.count; + } + write_len =3D sizeof(priv.zr->range_count) + + priv.count * sizeof(priv.zr->ranges[0]); + ret =3D HV_STATUS_SUCCESS; + +cleanup: + if (priv.zr) { + cpu_physical_memory_unmap(priv.zr, len, 1, write_len); + } + return ret; +} + uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast) { EventFlagHandler *handler; @@ -1014,6 +1111,30 @@ uint64_t hyperv_syndbg_query_options(void) return msg.u.query_options.options; } =20 +void hyperv_boot_zeroed_setup(void) +{ + static bool initialized; + + if (initialized) { + return; + } + + initialized =3D true; + + if (runstate_check(RUN_STATE_INMIGRATE)) { + /* + * We do not track zeroed memory across migrations. + * The hypercall is only issues early during boot, so we don't lose + * much by not dealing with the complication of moving the zeroed + * state of guest memory to the migrated instance. + */ + return; + } + + physical_memory_init_mapped_tracker(current_machine->ram_size >> TARGE= T_PAGE_BITS, + HV_BOOT_ZEROED_PAGE_SHIFT); +} + static bool vmbus_recommended_features_enabled; =20 bool hyperv_are_vmbus_recommended_features_enabled(void) diff --git a/include/hw/hyperv/hyperv-proto.h b/include/hw/hyperv/hyperv-pr= oto.h index f1d1d2eb26..5bf5684d11 100644 --- a/include/hw/hyperv/hyperv-proto.h +++ b/include/hw/hyperv/hyperv-proto.h @@ -36,6 +36,7 @@ #define HV_RETRIEVE_DEBUG_DATA 0x006a #define HV_RESET_DEBUG_SESSION 0x006b #define HV_EXT_CALL_QUERY_CAPABILITIES 0x8001 +#define HV_EXT_CALL_GET_BOOT_ZEROED_MEMORY 0x8002 #define HV_HYPERCALL_FAST (1u << 16) =20 /* @@ -192,4 +193,14 @@ struct hyperv_retrieve_debug_data_output { uint32_t retrieved_count; uint32_t remaining_count; } __attribute__ ((__packed__)); + +struct hyperv_get_boot_zeroed_memory_range { + uint64_t start_pfn; + uint64_t page_count; +} __attribute__ ((__packed__)); + +struct hyperv_get_boot_zeroed_memory_output { + uint64_t range_count; + struct hyperv_get_boot_zeroed_memory_range ranges[255]; +} __attribute__ ((__packed__)); #endif diff --git a/include/hw/hyperv/hyperv.h b/include/hw/hyperv/hyperv.h index e29d60f565..8e7fec8e4a 100644 --- a/include/hw/hyperv/hyperv.h +++ b/include/hw/hyperv/hyperv.h @@ -102,11 +102,18 @@ uint16_t hyperv_hcall_post_dbg_data(uint64_t ingpa, u= int64_t outgpa, bool fast); */ uint16_t hyperv_ext_hcall_query_caps(uint64_t sup, uint64_t outgpa, bool f= ast); =20 +/* + * Process HVCALL_EXT_GET_BOOT_ZEROED_MEMORY hypercall. + */ +uint16_t hyperv_ext_hcall_get_boot_zeroed_memory(uint64_t outgpa, bool fas= t); + uint32_t hyperv_syndbg_send(uint64_t ingpa, uint32_t count); uint32_t hyperv_syndbg_recv(uint64_t ingpa, uint32_t count); void hyperv_syndbg_set_pending_page(uint64_t ingpa); uint64_t hyperv_syndbg_query_options(void); =20 +void hyperv_boot_zeroed_setup(void); + typedef enum HvSynthDbgMsgType { HV_SYNDBG_MSG_CONNECTION_INFO, HV_SYNDBG_MSG_SEND, diff --git a/include/system/physmem.h b/include/system/physmem.h index da91b77bd9..7f5063b0af 100644 --- a/include/system/physmem.h +++ b/include/system/physmem.h @@ -53,4 +53,12 @@ bool physical_memory_snapshot_get_dirty(DirtyBitmapSnaps= hot *snap, ram_addr_t length); int ram_block_rebind(Error **errp); =20 +void physical_memory_init_mapped_tracker(unsigned long num_pages, + unsigned int order); + +void physical_memory_set_mapped_range(ram_addr_t addr, ram_addr_t length); + +const unsigned long *physical_memory_get_mapped_ranges(unsigned long *len, + unsigned int *order= ); + #endif diff --git a/system/memory.c b/system/memory.c index 739ba11da6..21d14489b9 100644 --- a/system/memory.c +++ b/system/memory.c @@ -2188,9 +2188,12 @@ void memory_region_set_log(MemoryRegion *mr, bool lo= g, unsigned client) void memory_region_set_dirty(MemoryRegion *mr, hwaddr addr, hwaddr size) { + ram_addr_t ramaddr; + assert(mr->ram_block); - physical_memory_set_dirty_range(memory_region_get_ram_addr(mr) + addr, - size, + ramaddr =3D memory_region_get_ram_addr(mr); + physical_memory_set_mapped_range(ramaddr + addr, size); + physical_memory_set_dirty_range(ramaddr + addr, size, memory_region_get_dirty_log_mask(m= r)); } =20 diff --git a/system/physmem.c b/system/physmem.c index c58d940e80..0728367035 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -180,6 +180,56 @@ struct DirtyBitmapSnapshot { unsigned long dirty[]; }; =20 +/** + * TODO: Or as part of RAMBlock, but we don't intend to extend once set up= at + * init time. + * @mapped_blocks: pointer to the the bitmap itself, maybe NULL if no trac= king. + * @mapped_blocks_num: the length of the bitmap, in sizeof(*mapped_blocks) + * @mapped_blocks_order: the order, in pages, i.e., 0 =3D 1 bit per page. + */ +static unsigned long *mapped_blocks; +static unsigned long mapped_blocks_num; +static unsigned int mapped_blocks_order; + +void physical_memory_init_mapped_tracker(unsigned long num_pages, + unsigned int order) +{ + mapped_blocks_order =3D order; + mapped_blocks_num =3D DIV_ROUND_UP(DIV_ROUND_UP(num_pages, 1ULL << ord= er), + BITS_PER_LONG); + mapped_blocks =3D g_malloc0(sizeof(*mapped_blocks) * mapped_blocks_num= ); +} + +void physical_memory_set_mapped_range(ram_addr_t addr, ram_addr_t length) +{ + unsigned long first_bit, last_bit; + unsigned long max_bits =3D mapped_blocks_num * BITS_PER_LONG; + + if (mapped_blocks =3D=3D NULL || length =3D=3D 0) { + return; + } + + /* + * Since we don't track hotplugged memory, we may get requests to + * (partially or fully) set a region we don't track. + */ + first_bit =3D addr >> (TARGET_PAGE_BITS + mapped_blocks_order); + if (first_bit >=3D max_bits) { + return; + } + last_bit =3D MIN((addr + length - 1) >> (TARGET_PAGE_BITS + mapped_blo= cks_order), + max_bits - 1); + bitmap_set_atomic(mapped_blocks, first_bit, last_bit - first_bit + 1); +} + +const unsigned long *physical_memory_get_mapped_ranges(unsigned long *len, + unsigned int *orde= r) +{ + *len =3D mapped_blocks_num; + *order =3D mapped_blocks_order; + return mapped_blocks; +} + static void phys_map_node_reserve(PhysPageMap *map, unsigned nodes) { static unsigned alloc_hint =3D 16; @@ -3131,6 +3181,8 @@ static void invalidate_and_set_dirty(MemoryRegion *mr= , hwaddr addr, assert(ramaddr !=3D RAM_ADDR_INVALID); addr +=3D ramaddr; =20 + physical_memory_set_mapped_range(addr, length); + /* No early return if dirty_log_mask is or becomes 0, because * physical_memory_set_dirty_range will still call * xen_modified_memory. diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4d77de52b4..0a47dc376d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -10762,6 +10762,8 @@ static const Property x86_cpu_properties[] =3D { HYPERV_FEAT_TLBFLUSH_DIRECT, 0), DEFINE_PROP_BIT64("hv-ext-query-caps", X86CPU, hyperv_features, HYPERV_FEAT_EXT_CALLS, 0), + DEFINE_PROP_BIT64("hv-boot-zeroed-mem", X86CPU, hyperv_features, + HYPERV_FEAT_BOOT_ZEROED_MEMORY, 0), DEFINE_PROP_ON_OFF_AUTO("hv-no-nonarch-coresharing", X86CPU, hyperv_no_nonarch_cs, ON_OFF_AUTO_OFF), #ifdef CONFIG_SYNDBG diff --git a/target/i386/cpu.h b/target/i386/cpu.h index eb870fa015..9e64c78eaf 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1481,6 +1481,7 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *c= pu, FeatureWord w); #define HYPERV_FEAT_TLBFLUSH_EXT 19 #define HYPERV_FEAT_TLBFLUSH_DIRECT 20 #define HYPERV_FEAT_EXT_CALLS 21 +#define HYPERV_FEAT_BOOT_ZEROED_MEMORY 22 =20 #ifndef HYPERV_SPINLOCK_NEVER_NOTIFY #define HYPERV_SPINLOCK_NEVER_NOTIFY 0xFFFFFFFF diff --git a/target/i386/kvm/hyperv-proto.h b/target/i386/kvm/hyperv-proto.h index 4eb2955ac5..ec38b717e4 100644 --- a/target/i386/kvm/hyperv-proto.h +++ b/target/i386/kvm/hyperv-proto.h @@ -94,6 +94,11 @@ #define HV_NESTED_DIRECT_FLUSH (1u << 17) #define HV_NESTED_MSR_BITMAP (1u << 19) =20 +/* + * HV_EXT_CALL_QUERY_CAPABILITIES bits + */ +#define HV_EXT_CAP_GET_BOOT_ZEROED_MEMORY (1u << 0) + /* * Basic virtualized MSRs */ diff --git a/target/i386/kvm/hyperv.c b/target/i386/kvm/hyperv.c index 807acaf6b1..dc226b4419 100644 --- a/target/i386/kvm/hyperv.c +++ b/target/i386/kvm/hyperv.c @@ -123,6 +123,14 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_= exit *exit) hyperv_ext_hcall_query_caps(hv_build_ext_call_caps(CPU(cpu= )), out_param, fast); break; + case HV_EXT_CALL_GET_BOOT_ZEROED_MEMORY: + if (!hyperv_feat_enabled(cpu, HYPERV_FEAT_BOOT_ZEROED_MEMORY))= { + exit->u.hcall.result =3D HV_STATUS_INVALID_HYPERCALL_CODE; + } else { + exit->u.hcall.result =3D + hyperv_ext_hcall_get_boot_zeroed_memory(out_param, fas= t); + } + break; default: exit->u.hcall.result =3D HV_STATUS_INVALID_HYPERCALL_CODE; } diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 586656258d..70ac56624f 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1143,6 +1143,14 @@ static struct { .bits =3D HV_ENABLE_EXT_HYPERCALLS} } }, + [HYPERV_FEAT_BOOT_ZEROED_MEMORY] =3D { + .desc =3D "enlighten guest about pre-zeroed memory (hv-boot-zeroed= -mem)", + .flags =3D { + {.func =3D HV_EXT_CALL_QUERY_CAPABILITIES, .reg =3D 0, + .bits =3D HV_EXT_CAP_GET_BOOT_ZEROED_MEMORY} + }, + .dependencies =3D BIT(HYPERV_FEAT_EXT_CALLS) + }, }; =20 static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max, @@ -1378,6 +1386,11 @@ static bool hyperv_feature_supported(CPUState *cs, i= nt feature) continue; } =20 + if (func =3D=3D HV_EXT_CALL_QUERY_CAPABILITIES) { + /* These do not correspond to host CPUID feature bits. */ + return true; + } + if ((hv_cpuid_get_host(cs, func, reg) & bits) !=3D bits) { return false; } @@ -1819,6 +1832,10 @@ static int hyperv_init_vcpu(X86CPU *cpu) hyperv_x86_set_vmbus_recommended_features_enabled(); } =20 + if (hyperv_feat_enabled(cpu, HYPERV_FEAT_BOOT_ZEROED_MEMORY)) { + hyperv_boot_zeroed_setup(); + } + return 0; } =20 --=20 2.47.3