From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759444; cv=none; d=zohomail.com; s=zohoarc; b=QhjdqFLtysr/WcTpbLKKD2O/pTHhzBN5Pvi2WZccmjYY/CAFGcRgG42B9E1qpfY+Oa2mjduiN/WaonLv84uCmN1YIYwSjSGTatcg45csFxMfHheHf8NAcr8NjOUWx4eQrjOCi/qYpIAVazuhtJr1mtkqhHabe6L43ITX9iho7Xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759444; 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=+fMggmtg/uZNHz3nywgemPAlDNuqwqAYkYrWDswgN9E=; b=FA/b5Ei1S6hyhezFQMV1bL0z7WG7wnoiKyqLTTdOuyOPzTVCXHG1ugY/AmkbEX76c0lkSBQLqc866NXWLuX8iU12aXX8FgRon1LdDD0My1ULmQVNu8X2A0sbYQcC3lFOLUY/qKkS60qJPMELihMYd7KkypOoupAby7j1zck+jpk= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176175944455027.472106620384352; Wed, 29 Oct 2025 10:37:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5F-0003Q1-GR; Wed, 29 Oct 2025 13:35:41 -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 1vEA5A-0003O4-SV for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:37 -0400 Received: from p-east2-cluster4-host7-snip4-7.eps.apple.com ([57.103.78.238] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA4v-0003F6-C4 for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:35 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 833D91821F5A; Wed, 29 Oct 2025 17:35:16 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id F30741846C36; Wed, 29 Oct 2025 16:55:17 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=+fMggmtg/uZNHz3nywgemPAlDNuqwqAYkYrWDswgN9E=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=gkIKHAcvQtvbT3+E7lQJOuWdIX0vY5froNjzCzSbJiQy5I8xsN9DMHC50HgAU8lmsIQH037sFumALdFfY2RHdqZEhwSm+bjlWohrSU8OMTmNtgnziKNqBRbk1CAZq9kL+AcwRKKJie1ppGYXjRpQxO+lu+squKBo/lDxW7g9MHEDZmv964JIUZVe20M4ny9Xl1VIP+PnKYIxS5OOanbbfI87IzFnJvS3pHJlkAjU4lGToKpRbxKSh2AfBLOOWQEZlRIaZZCVHfdeUXbpX4O+sj3xSFon+XMy0OgRQvf4Ly5jvtnQQOw8qoERDbH2IwDBOcTVzz52YaSo25+ZZgMlsQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Sebastian Ott , Pierrick Bouvier Subject: [PATCH v10 01/28] target/arm/kvm: add constants for new PSCI versions Date: Wed, 29 Oct 2025 17:54:43 +0100 Message-ID: <20251029165510.45824-2-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX08lYxwcpRPJF oYbuIQ+A1NfcjdRftrfqnnlroEJhdTr59vbcNNTuhgFmIlZ4OeKfp/Q/5yl0KbH12D9m1P4EENV 0ZnVe5AT4V5cnEmr5GbhvGGFsRtClk6+KlREhCUDTFSYO5hJv9KEnRa1Vw4Xrg088T93Gojh54h 2ZEsPv6noQHaqIVZCx560D+t7gMg9FWaU+GJw/Cblp7rk867YE2Kotldbzp4S3prDQ2zS5X8eEy 1f3gxGUscL5RhMpZN00tshfCb9BMQ9VmXFrJgxU6Vl4yKJKbFd1wSXVZ9T8/NcWdRUwD6d600= X-Proofpoint-GUID: XLLgT9CHI5YMLuY1mGSaYyLCP6T7ebh5 X-Proofpoint-ORIG-GUID: XLLgT9CHI5YMLuY1mGSaYyLCP6T7ebh5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxlogscore=787 adultscore=0 malwarescore=0 suspectscore=0 phishscore=0 mlxscore=0 clxscore=1030 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABWyX62p9XQNvmqfbj25ymUukuLqE1vE2C/X2TQTw3dUS1u76qkirvGW4FOtpmANglZSGTzxUZ1a9DhLpgtmkFm06ssfqDbDpjvQd9bPlTc0PwwDy4vsZKr9orknoaAoFGEwRIUjaeY7NNHoG+rXwji0tugwqvJL7YqXPNNLr6oovRYg+o9JEJ4q/imZMM7QWtNz/jkijNZjMHCu39MJ+XcOVOO/nY6N12NTQGPFsFaZKPQt5y+uemHFAzACndWBLCang0kzpjbJESUA0Nn/XXWqOsZKG2YdWNdrDig6k5GpDF9WsvCDb5I1sdv2Gn9z3o6ZiL3lX6a9stf2brPAHXD+LouJYN2EMBcCPogvlqbppbOWg9SuZRM4jENKMS8ULJmuUj+BiDSxEKmrREJVxKL+9peDrtDSRLS5AO4QaKIpYsc/BqsnHW09K19rDurWjIRFx6C38Zu5fEiGaRMOQr+2No5VLTYdS3dsI/En/7/bo2P1bMcyDWE3KPDbYVnyrg0NSgX7oS3Qi7hzkvSW1926XuPfef5c20do8x8WBLP5O5XOh/azsBj6jjdSpGw8pdoIri8s57zgHU6q7xZqoDpLF5e0uQ29/aSD65ppwsF1zdT7PALoYEtSfFjIeMlddZ/4qqtuKIQPoQiqwUfq6JQXYAF91XzoQ5PEGUy2Cqi42TA09zQIWOtXEp+gPjyDsrtL1uoor5TmtZZan/7pAVOvEtbA0ebNGafY690Fk0It55X7f60jvDxLZBOpPJvPhWbJrhn8xe31NV+sLUnTg6vsciIDCZ+7LRFpg= 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=57.103.78.238; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FORGED_SPF_HELO=1, 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=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759446535158501 Content-Type: text/plain; charset="utf-8" From: Sebastian Ott Add constants for PSCI version 1_2 and 1_3. Signed-off-by: Sebastian Ott Reviewed-by: Pierrick Bouvier --- target/arm/kvm-consts.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/arm/kvm-consts.h b/target/arm/kvm-consts.h index 54ae5da7ce..9fba3e886d 100644 --- a/target/arm/kvm-consts.h +++ b/target/arm/kvm-consts.h @@ -97,6 +97,8 @@ MISMATCH_CHECK(QEMU_PSCI_1_0_FN_PSCI_FEATURES, PSCI_1_0_F= N_PSCI_FEATURES); #define QEMU_PSCI_VERSION_0_2 0x00002 #define QEMU_PSCI_VERSION_1_0 0x10000 #define QEMU_PSCI_VERSION_1_1 0x10001 +#define QEMU_PSCI_VERSION_1_2 0x10002 +#define QEMU_PSCI_VERSION_1_3 0x10003 =20 MISMATCH_CHECK(QEMU_PSCI_0_2_RET_TOS_MIGRATION_NOT_REQUIRED, PSCI_0_2_TOS_= MP); /* We don't bother to check every possible version value */ --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759381; cv=none; d=zohomail.com; s=zohoarc; b=PaQZL7HD2f1USoeDXiDNfGciJ/WsOG+S5mo3ESFz93hE9V+z6Jpl0u0hmoSrEGszxdNBO+naigy0PKGPcCta7ygcv0pSl6CooNwOnJk9hzurRnqpkJZdWJxWOgDlZSjJPqqjJDbVjsUSH5SfSA7viL/UTAp8XWwQzMIiY9F7sTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759381; 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=aRq3YU5535mG5uSPAFBSlmsbBJkL1R5+IAqIsTf/zZw=; b=Gpj3/acd4uTFVS0R/q/gVCG2qkn1SUucGVy2xAEACTHrB/hRK5yDwSp4J04Mzos8BuweB2w4KywzQQpcQDGKSFPF8zHXQDidBsktP6peYB4pAiIcvmDgM32OE58MMIlnxP0mSFAw6SbT0LXA+iUoldaEF2ndWrSZpWy4qM1CR3M= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759380821293.89394924080136; Wed, 29 Oct 2025 10:36:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5I-0003Sg-Ux; Wed, 29 Oct 2025 13:35:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5A-0003O2-J9 for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:37 -0400 Received: from p-east2-cluster4-host1-snip4-10.eps.apple.com ([57.103.78.161] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA4x-0003FO-6u for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:35 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 79011180179B; Wed, 29 Oct 2025 17:35:17 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id AE9BE1859E4C; Wed, 29 Oct 2025 16:55:19 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=aRq3YU5535mG5uSPAFBSlmsbBJkL1R5+IAqIsTf/zZw=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=A2hSRdwyl/UgrlpqMy9e0ENjN/9vOSCMnpMjmPp9QUDlatQeknhegGxjcEtmD1hU6oVXAGvrNgZd2/PuoIfzJHEF2KaPoRL+pcPyZjkhfRmQr1VuklzAnW2Xof18cdpQ11bFmG0d80abjRCobqykOmoIW6sTpj8eaWpwD8rIG3uZQJf5oT9xy62jzqHM9zkybehvnedrV76YzjZYRwi6q1UgDmvViGVj/OZev4T/t111sULgwXB12H90Ql/iU/3rfFn2x+jhTclz9XtKp9XDVbgaDqKSQMk1h3HlS4YmQATowwGQ+nhoLBEiBJZN2wJWO+wtX1s3bdHABwVhY6RB3Q== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v10 02/28] accel/system: Introduce hwaccel_enabled() helper Date: Wed, 29 Oct 2025 17:54:44 +0100 Message-ID: <20251029165510.45824-3-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX9Zc91t2wIyIn kcLwL9xhkPz3omenZw39rx8nJm65DusyzOT9dRVwz0f8Ub2XQFiYEfCs/qXJIy1r3Rf2fzAPPRS 66I5a0t+CtrcUdnAn2v3jAF7CU9MUhpW5Kya6Cevw01PXdjk/bBLQMfXiD4ue1EF8DsVaHBjFdT lEKOv83CdRZRv2BrffO4J7XohM7Q06mgPsbhMQ6hPjpZ35B1NjAs8pFVd43l5uqnqHBI4OHzbMn k2WtofSsmHSUQsxlvLQq1xSnRuI0mjz1gvic2R+wJByQG9JMNpppkWoQl0dCsnaYwSEBpGQio= X-Proofpoint-GUID: Xl-M6ReIRqEvTt-9Kxm5akcbKx1o3hBc X-Proofpoint-ORIG-GUID: Xl-M6ReIRqEvTt-9Kxm5akcbKx1o3hBc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxlogscore=987 adultscore=0 malwarescore=0 suspectscore=0 phishscore=0 mlxscore=0 clxscore=1030 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABVOJBTEx9oKbU9OF+tEOYNDibdFl5ejT3VYlKfTY/azh0pHBMuBoy9zJ12r7uSqHVNt4ywWYW1hfYihnntuxw+4nm1Nng2TBEDXldGOH+Haj0BkgkArd16Lj3zJeKbzo2f+zKGK+OdN2DOtccHKPFo6Fgo0fzg+urJHN6qWWE6iodU5iSGowU3RVTnoLsMuuGIphj1Vc/xYeDiuXEg5ae8Qz8oR5QD6vCjgHsalPiO+uKuXov1iTXaA6/2TwbuB+Iz8WOR4VqIS+N3Kg/SMmE0mYnVztHiIjoJaYsexjo1bowT6PnBkEtfYD2NwA6NcCSBOzm3XbnK1rpgtdPh7feGFcEb5xN1Ko7GlZHm6CjeXeb7lTLzQY07nsjszM8pvyUdvFwsxzwbUZi+5KEYzCQ8vtbmT8eysdTOm6+4RgrgEv7h31XcRcfrVv1oUNH2oY3HgXZYmVsD32aNLVwXvgIMd97hIKpP9lvidMysM8iB6i9V5bEGp0iv4ktuihmRnklSY6XLddh3PNdKxG+btxxY5JpqQhovFNYeeM0I01jHODlcSFqHBzBT/nM9CG8mg4jhBuZTn4FkxhxO4eMKuJgsugYcXE9KiGAP/eMEzgqyhHRChlFhKrHTB97nJ2o3U5sQvWGeqyPDj8PZ2yJjP9nY12pb0xY9J8zg6qvWQrGNoy0GnkxOa6+wy96yibFlrk/FWNnKV5vB5wsRJJUu9oF8duwdxi52FQBxbvNB+DuntaCMuETxKixaPgt4keFSymdaJs= 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=57.103.78.161; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1761759386185154100 From: Philippe Mathieu-Daud=C3=A9 hwaccel_enabled() return whether any hardware accelerator is enabled. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- include/system/hw_accel.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/system/hw_accel.h b/include/system/hw_accel.h index 55497edc29..628a50e066 100644 --- a/include/system/hw_accel.h +++ b/include/system/hw_accel.h @@ -40,4 +40,17 @@ void cpu_synchronize_pre_loadvm(CPUState *cpu); void cpu_synchronize_post_reset(CPUState *cpu); void cpu_synchronize_post_init(CPUState *cpu); =20 +/** + * hwaccel_enabled: + * + * Returns: %true if a hardware accelerator is enabled, %false otherwise. + */ +static inline bool hwaccel_enabled(void) +{ + return hvf_enabled() + || kvm_enabled() + || nvmm_enabled() + || whpx_enabled(); +} + #endif /* QEMU_HW_ACCEL_H */ --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759428; cv=none; d=zohomail.com; s=zohoarc; b=TyTuSnkeCenhDhZi1PHXN2P/5ZOaQ3Pwys4W4OYenmEjGeJCyFI+7bljhOskR3FGLATYIQ5fcuVkTg9WzcemR5RZs5BoIPcueukBA1LwfEaoN9+xEqOk9W/c3IIBG9aDC7OaQSoa9ckckmxJZY1zTEUUyyRsXA4Km4QZK8u2v6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759428; 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=lE935EhSo6eiiRGBTf1TCzdO8HBh375WWDyS664DB/c=; b=ccJfdhjvMB0wxX4jZvQVlbU8dWbfEFo6/uO1TNfFERnoR1HVXmr9YqDbeZuYa3IiBeGVBsn8cIQkcxiDIAbgWlpqFLJ9goMgSDn2gH8oza6se+5apVvgoBSETJc2B4gy85kn1jh4jISJw7Z/vcByjFJnhUEaty+wOPJx4Dp8E30= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176175942823336.687214632655696; Wed, 29 Oct 2025 10:37:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5F-0003Pk-BT; Wed, 29 Oct 2025 13:35:41 -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 1vEA58-0003NO-5i for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:35 -0400 Received: from p-east2-cluster1-host9-snip4-6.eps.apple.com ([57.103.76.109] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA4x-0003Fc-6w for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:33 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id B7CB71819DFF; Wed, 29 Oct 2025 17:35:18 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 3AEAB1859E4B; Wed, 29 Oct 2025 16:55:21 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=lE935EhSo6eiiRGBTf1TCzdO8HBh375WWDyS664DB/c=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=UstOJnhK/+7HSOCeSb3QX26LdpoZlBq9oWD/6OBgmCNxCNFBCE0qECtkjAtNu8iY7lNRBEt+Fvb2TWyurncRemuHaWk9m3p4SoRUKPkafR3CPlo/ISAUu7tBNYbSoVg9mAJ6l+BXlFfbOV3VqY5tvSxr3QDsuwiTMbCJsszYwuRjW3LGMNPsNHBPSPVVaLUfgdFFAhDgllR8HaWK6nM/niVrbvxZ09y/GhXL3nokYnsfbibArPGA3dlX441rpe3XHA4mUnM9gZ4zzMhF3CU4jxq9JO8bFSt/oyp1lOR8UFggkotrJ09OiVStT//botiYW7xF/jjDBg86C8FWxnk1mw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 03/28] qtest: hw/arm: virt: skip ACPI test for ITS off Date: Wed, 29 Oct 2025 17:54:45 +0100 Message-ID: <20251029165510.45824-4-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: xTADgFWmv7xhy2aejrbm0uVmCKHXaiEc X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfXye64S+Kio2Pw dld5bpAium1xHbktoqFuhNpu+t7cQZU8PKM4GRCphgdFAmGXrdZtxFsypzcD7kZEH9j68A4F562 sqlQ3faR7xyqZ4QsTzdebPaDyAMyQiqh6G6QqHA9thluLkT91JZkm/q15ijPMbXcXFItwhmwStk hvWplKKmp+MFvu5p/bhtuloFE67B/8DHG+tQTkWDYxAZxsMITUPr7q3clXTdXGLpDzsJ6wG+krs 12e78bQscpgyLscqBRoOPY5COLKbmRbU13SDHRehzaJl0gT2yZobo58rUGKVQ2NDEvNNHrdL0= X-Proofpoint-ORIG-GUID: xTADgFWmv7xhy2aejrbm0uVmCKHXaiEc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 clxscore=1030 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=774 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABVZ9HcTW9oAxeUbUrQ1o27a5PgxkR3/USwiNQGPoeSpy3OcmGZO0w8LyEr8e6UGPiTfoUVYQSCFGK1PiAC1vZckjesYlmi7+0OKF80q/33DhKwVOjxqroe6Cmx2erts8H6kfdow8trUUVnLpPIdCrkkiW8x8cNDL66tjTj/0Fp9reQLt+cKPgMk7pJ82V3IWlJkecnPJ86+my9gsWGHm+HBaYr/Ria/Cme7dy/uUpoXSrTL2sOPSYkttVPVAybOA/6ljonqvAs/JJsdctsYukp2B3BaAY/2Ojto3l3KrRWS5W7ueBOtU7TVj0965Gvr6jyIFbH9b+88oj27HiODCf0qmAWK0mW8/Hpw0iO9A2lsKOuroz0LT+i3chA//dN9FAwprCezGoeBW7jz21KwZ1a6VZ2msHwa8QDj1DM7MNHQRZqCERYYd1/20Lr9NgMiquHRgVeRciuNsPaAK85lr8jQZrt0PqkQy/Kuy5hUVRHJnY56lpY32ZsP2a+w0NSotYgFjDfh5XPJY5Emz04xycqZZZuBjjqSvWX2Zf9qQ/zzPG637Gx57U5bwvO4HDcBZozwYH4wgmAYLxOUNptRhreZ9RR+LdDNbVk9tweJvenL3EaU1rf2jMeIcaSxZcPNlzAuIk2v+j9ePzoxJJ1y8r5F3hyWnZIKuRytH1/odemQrvHM7k5M8aLOSEgQclcaCedJTxbh+CR6Nn0RX4AGXTJjnSdX5tzMV40g4OUP7I66UJ+KwmbIyLcWTHdsxZU58kfi5GZrR3nT+Ylh8= 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=57.103.76.109; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.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_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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759430476158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni Reviewed-by: Pierrick Bouvier --- tests/qtest/bios-tables-test-allowed-diff.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..bfc4d60124 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,2 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/aarch64/virt/APIC.its_off", --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759390; cv=none; d=zohomail.com; s=zohoarc; b=YhuwCW5jm4NK87WKpMXvwhiXcYoHdYxylHB+GNazGnGyplzKdrFQVIRg+qnwejBbnwElQnA7zd7FKWGoxyVO08MF3rgg/1qFE7nbja/qD7rEAF4lPqx0aDuM6BXkFB7ldRiUU/UrAUEtBXq2z/HEj420TdSNi5jIptxHadNIazI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759390; 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=JHEgQXI56zcvBQsz6pNUn1flvTbXYsGowZgT2ZZujDg=; b=AUKkpJTCMTTMON9CpeIcPOGyJfBymM6QxxYK/Q7L8l+Ygt5lxLY5MGMNi5V9IDg9L64apuM9fHce6h4Azz0OQKyDqhZ4NN2QgvgqiYRWrdiRcF2yQWsz8qhO8S3VU8LfgGkY6L1EOHKWAifmZsYwKa9b0p1sEvo8ugPtOdxnz3M= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759390370570.1710842437607; Wed, 29 Oct 2025 10:36:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5O-0003VW-Od; Wed, 29 Oct 2025 13:35:51 -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 1vEA5F-0003Pg-AM for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:41 -0400 Received: from p-east2-cluster1-host4-snip4-10.eps.apple.com ([57.103.76.23] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA50-0003Ff-HR for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:39 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 5041A1800602; Wed, 29 Oct 2025 17:35:19 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id D38471859E5A; Wed, 29 Oct 2025 16:55:22 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=JHEgQXI56zcvBQsz6pNUn1flvTbXYsGowZgT2ZZujDg=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=AXLAmwbELPlKLSDAkK2EVSF7ZKHo+AFwCLvT/8Lm5RGN6zeB/hrqFCN4YqF/mxvlG0y62TaSslm8B1rM/HB8t1wIkm1ltafAHVS+UjLQ2tdMcEzWQsSYwpwi4i4Lwo8aOmCpOfddoHtZvHzj45aoCWs/HkpNGZbp6Mjl0LOz024DXxkTrh1aQ/UngG6RL90oGLNNzeQHVTgASVyiP6adg9pVpHy9wa6tYaWBgsOkpHpc8oM0+whmMCF4AfOdoHbugQ+CcNPM+5TIzsPfNVB/ChzlvjLyIOwOtgx2wI6T70OQapNUYZv9vR1rfRDCmNWgz5Asxa17IUIOa8A8M3grLA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 04/28] hw/arm: virt: add GICv2m for the case when ITS is not available Date: Wed, 29 Oct 2025 17:54:46 +0100 Message-ID: <20251029165510.45824-5-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: GpNlfF904dzmvLdrIuxrGVRhdaLS3Kkb X-Proofpoint-GUID: GpNlfF904dzmvLdrIuxrGVRhdaLS3Kkb X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX8D6Op2qk5AIW HUKQV7fZQnVsiOgEZ7JQHDRpEUPdRo03XKfAllcHKHqFqhXkZHIE6dDK4SWhKhetbGLD30JZvd5 MSqDP4cVtviMnZpb2iZXnMEXtv/UFu4yz3OM29mmnN98fHaTTN2l6muIkOtT6KMeJF5wlNS91nk cWKvNGGPD41qhurmGC/2InwpgASJgnsWdAQttgmrom5JkIgiAdEiZ/0/bJTtovAGs+x9PK+YKpj JcrDGtnbVMWvwKbwhMYiYrAEiut1XCEAnvLkV6fbrcitdQldI5jrqf0kF0KutL19JL0SJOAU0= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxscore=0 suspectscore=0 spamscore=0 clxscore=1030 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABEB7F0yRrIsY/oZiKFrA0cImsd7ywWhaq0a1dA7H3vQ/KSJh211OjiJER8WQ/maBDYcoYTozeeemufUevYK3aKqDvW0lUVIJGkn/UYkvUn3+j2q/rAKE3BDJ6dtnINlnKtCp+tbxRnPEQLv8aam4v//+slyqGkZIq+tzrKB7ekKKCNQlY9zXkWB18VvKqL22Tv/9Iag6Fx6qzyB0elrUC1yA/d8yQ+YwiRGqogmsClQ1wI5HEMQjcf8DoNX1DGQs1JPoK1has+77IJj3ZWjz1uDdPFpBPYgK1gZ0ihH93OXUspBhRHJPaZGX2wcMNaFpd2E3N4/whfxFG6rUIeEosyVHEnQq6giGuUfjNEbCfpFb0imCMKKBVv5DoiQOSNF7aH7iV0WqI9QX+ibYrr4fyA7B1gA7yF2Vrvu64TeZ+RAu7bdwjdVeSnh1Vq6c52VGwzy+YGR9clt0RRezbcYa7Fol41+t7crWChr7WQQtGvTw7hTRMDznFw7tVEk8JenCNz4eKc/MvE1p3gITVx9DCPnPxwVEBVaLsAO5zEb7a1IOuXSH6KZqNQwUJQ0v7N/Nniawp5bsQQaLu20fQJHGxxiKKMWWzpKmB9F3uZSQCrAATEKNw6X5ynGFhC6iePl5dw0mcw5vUFX0ESLG0d3kt4KTbBVPZOa05Chva4bn+oP0CS66ZN6/cztkPdL8WCQGQ574NxrgXqPov9QK2pdDlW6Bw/1EpenLpl7YCTnXqwsrxf08xx5ktE2wwXZZWJxOOdEY1DlWGAYKqVGr/KbTkIqHJ0JE= 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=57.103.76.23; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1761759396012158500 Content-Type: text/plain; charset="utf-8" On Hypervisor.framework for macOS and WHPX for Windows, the provided enviro= nment is a GICv3 without ITS. As such, support a GICv3 w/ GICv2m for that scenario. Signed-off-by: Mohamed Mediouni Reviewed-by: Pierrick Bouvier --- hw/arm/virt-acpi-build.c | 4 +++- hw/arm/virt.c | 8 ++++++++ include/hw/arm/virt.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 8bb6b60515..0a6ec74aa0 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -959,7 +959,9 @@ build_madt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) build_append_int_noprefix(table_data, memmap[VIRT_GIC_ITS].bas= e, 8); build_append_int_noprefix(table_data, 0, 4); /* Reserved */ } - } else { + } + + if (!(vms->gic_version !=3D VIRT_GIC_VERSION_2 && vms->its) && !vms->n= o_gicv3_with_gicv2m) { const uint16_t spi_base =3D vms->irqmap[VIRT_GIC_V2M] + ARM_SPI_BA= SE; =20 /* 5.2.12.16 GIC MSI Frame Structure */ diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 175023897a..61d7bab803 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -956,6 +956,8 @@ static void create_gic(VirtMachineState *vms, MemoryReg= ion *mem) =20 if (vms->gic_version !=3D VIRT_GIC_VERSION_2 && vms->its) { create_its(vms); + } else if (vms->gic_version !=3D VIRT_GIC_VERSION_2 && !vms->no_gicv3_= with_gicv2m) { + create_v2m(vms); } else if (vms->gic_version =3D=3D VIRT_GIC_VERSION_2) { create_v2m(vms); } @@ -2447,6 +2449,8 @@ static void machvirt_init(MachineState *machine) vms->ns_el2_virt_timer_irq =3D ns_el2_virt_timer_present() && !vmc->no_ns_el2_virt_timer_irq; =20 + vms->no_gicv3_with_gicv2m =3D vmc->no_gicv3_with_gicv2m; + fdt_add_timer_nodes(vms); fdt_add_cpu_nodes(vms); =20 @@ -3484,6 +3488,7 @@ static void virt_instance_init(Object *obj) vms->its =3D true; /* Allow ITS emulation if the machine version supports it */ vms->tcg_its =3D !vmc->no_tcg_its; + vms->no_gicv3_with_gicv2m =3D false; =20 /* Default disallows iommu instantiation */ vms->iommu =3D VIRT_IOMMU_NONE; @@ -3536,9 +3541,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(10, 2) =20 static void virt_machine_10_1_options(MachineClass *mc) { + VirtMachineClass *vmc =3D VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); + virt_machine_10_2_options(mc); mc->smbios_memory_device_size =3D 2047 * TiB; compat_props_add(mc->compat_props, hw_compat_10_1, hw_compat_10_1_len); + vmc->no_gicv3_with_gicv2m =3D true; } DEFINE_VIRT_MACHINE(10, 1) =20 diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 04a09af354..d31348dd61 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -132,6 +132,7 @@ struct VirtMachineClass { bool no_cpu_topology; bool no_tcg_lpa2; bool no_ns_el2_virt_timer_irq; + bool no_gicv3_with_gicv2m; bool no_nested_smmu; }; =20 @@ -180,6 +181,7 @@ struct VirtMachineState { char *oem_id; char *oem_table_id; bool ns_el2_virt_timer_irq; + bool no_gicv3_with_gicv2m; CXLState cxl_devices_state; bool legacy_smmuv3_present; }; --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759900; cv=none; d=zohomail.com; s=zohoarc; b=dJmtCugkqiJhag34Bip82SIQeHeyJRo/K+B7Y5cqhixB/Q7ShS4AaGpLeQv5Cydp+dMqYevwXxF/sxDqu8T7bxa2jE7Y1XBM6Q2dFEsdfT7U6smrfY9Cf5MES5xIn5/A7M8kU9G2vDI1FpeaaMjWBRBFQAyfhk13foXSWfNacaI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759900; 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=9vYko/DI2RK+OqhuWK0dyFWYB5OCgm45PuZW5dC4nJ8=; b=kRxe+fjyT5URzjnwvIml1T/J+h7zlFy/2MgAhS31Nf4BFHEenOZ3iLEkkLo57ygtqM7BVtwz7ysVt0gewUrAGEJ2Ko53O/lTDdCZ8+TtF/RSpxATHQtrGFvvJ7/T9XYT6rmRac24vbPyfqj6yJSljqRBL/NIMFh7ABw9CeSpvtY= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759900965118.17904796747587; Wed, 29 Oct 2025 10:45:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5U-0003ZH-G4; Wed, 29 Oct 2025 13:35:56 -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 1vEA5Q-0003Wu-3P for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:52 -0400 Received: from p-east2-cluster1-host10-snip4-10.eps.apple.com ([57.103.76.123] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5E-0003JY-Bc for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:51 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 323C71821F70; Wed, 29 Oct 2025 17:35:20 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id CAE8E180C460; Wed, 29 Oct 2025 16:55:24 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=9vYko/DI2RK+OqhuWK0dyFWYB5OCgm45PuZW5dC4nJ8=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=RXA040iNMR9mhe6xWo+BYg3EsWEgVsAscx3Np9uc90SMa/wXzxaQWnrNH8Ucusoi1D09pSQ5NAwrjr0nd90IB368L8/Jqt1bm4uQm7X66HvsHx114mV3oULhxFTG6lEOkBgv3Tsva8Z87px21AvBJiNf5ELnKUFUDRhV52ddms0zpNRPoX1nESmcCv4i+i0bSeawWkwtl9qaukl0eQvjCGLtRyLQM71n9hGvKoJD3Nu1zzcMNAymPhwMy8LrxPBZThMgqSMmpM0cP7pKKX6BBr6gfOtbvPVWrAu9SGe2U6bWDI6dw5YLWzBk3iqUL9A1lrZlZHA63M+mRGmr/qJEhw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v10 05/28] tests: data: update AArch64 ACPI tables Date: Wed, 29 Oct 2025 17:54:47 +0100 Message-ID: <20251029165510.45824-6-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: UcrQvaXpqse_96mAUSlS8lDmIMMyg1aB X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX+S8CLRJeU8fp E6vJTQBT/h3KLOxb6jQNETL2EzEnkg31t8uJT3Mut5+J+XIH/qsVsZlmMex5e6NTWZIZejhFalc FEv5LdNW/fGjrPDvNcpGfbtmkxloH7rOYVKMsIskhqttJ7mTOyslXlabMlwFwyejLGcjqwEh+3I IIIh0PCriaYJNQe7b8eDSVshH5OkncVvK1s+JLSm/nur84CRYoSvpFuLp1/mqCVVe7tEWuDbykv qwAMzARu1lSOzfx4mTqro+iBjcWEMrgSmYeWtQVvDwILE7BZBg91wwlNa2duS+UHuqrSTFKYI= X-Proofpoint-ORIG-GUID: UcrQvaXpqse_96mAUSlS8lDmIMMyg1aB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 bulkscore=0 adultscore=0 clxscore=1030 phishscore=0 mlxlogscore=723 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABhw7wmrWWSVFddaSHDKGI3UZK4G6cM3DURXcUk+XcP8h34Dvlw2oNkO1uW9qh4BwKHim7/0ORJjkVbgbPAwmcJBew9kFLxfFVfBxQPSSVjC8tL0zU09wj758OP5hhEzZGvJQ2s69h+kw2QyI19UxrVCNx1M0PmEplAbYocHHG5xQJ8JxNwT6lv+1vEFJJFU2OqAIYRmI7Vv3ECO6Wzdng+bnLxLqvKTOtz+wGlasFpguYxKVr08bfTSoaSUmAd5bPsHR9TOd4yTXU1IjJmpfq6yBw+xQ8YLH1LqP/2uXSOmkjFkSs6YqAgpSMrHkVKUdcpOoR+iIS8p8BiXP/xBxdVcYGS76w5faeMikNa19xcBC3a7YlYPFxiKa0vfBOPb2uYJFXBfAVUk7vPxbsu4n1wCGqq8+xb/ZF7xEdlE3Sugs7QWUcb4dp68EBezETX3tYI+jPyrlqGrWV9VDh42Y+9hN2Y+CaeFN+ufOeAMXr/fqZVanS5V8Ni9xZ3kCtNot0naHqMvrq7eDJ/lpqmxN+9TbBGI2SiwjrpSBRbbLbyqYIKOH0qp4I2CymCBjLLVzCFx/RpuaaxwWjziFpLFY62eLjzR8mdyk5PZpIqQzQimeqeOT7VHkyIkZjjQESdLrAOG71QFyGz75XVK6Kqz3mlkkigFZNPLf+AlmsvVnDHuwKZRAy/2fuvWpTLrZw/V5BA5sUG4/k+lX5mJK6T798sqek0uRPjlXIZv+zLZB3oEnW2vmZVl1kVrT/XbU= 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=57.103.76.123; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1761759903224154100 Content-Type: text/plain; charset="utf-8" After the previous commit introducing GICv3 + GICv2m configurations, update the AArch64 ACPI table for the its=3Doff case. Signed-off-by: Mohamed Mediouni --- tests/data/acpi/aarch64/virt/APIC.its_off | Bin 164 -> 188 bytes tests/qtest/bios-tables-test-allowed-diff.h | 1 - 2 files changed, 1 deletion(-) diff --git a/tests/data/acpi/aarch64/virt/APIC.its_off b/tests/data/acpi/aa= rch64/virt/APIC.its_off index 6130cb7d07103b326feb4dcd7034f85808bebadf..16a01a17c0af605daf64f3cd2de= 3572be9e60cab 100644 GIT binary patch delta 43 qcmZ3&xQCI;F~HM#4+8@Oi@`*$SrWVwKqeS4aeydBAa-B~U;qHCpaq8j delta 18 ZcmdnPxP+0*F~HM#2?GNI3&%vRSpY3v1aANU diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index bfc4d60124..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,2 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/aarch64/virt/APIC.its_off", --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759446; cv=none; d=zohomail.com; s=zohoarc; b=blggZD3jGvQfAxzl/i2+AxlWZZuxj4mo/E+O9hk5vjm+W9C7nPI57wcJM6ZnijNWIl4G64hajWM5B8nyti0035yYGuoigFOEnniGHApVInxlJemGnmd0fG5QMPFIdO1/ZzyIuVrWuAqC0nmHGAucOAB6RmGWksuFaX7Vb7e+t2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759446; 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=tZPXOL+uIWMOEt6HxsooL4DtZPhoOOqc0cyEH40+x1w=; b=Kw6VgIG/CXOBAbIwnlQQWB9HA3gH921xGTY5q3DZ4nkUnz7RwGYvyX4PY1eNdSJ8Oeq936295TjMD8xe6sCEyR+9rFRfZUh8bqkLBh2lgSh2RVfbZancxUdvSazrE2TL9WwaSwtoPqLPsc1OGj6dNnXY16WKw3ACFodEqQ/vFJk= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176175944591997.7551201828959; Wed, 29 Oct 2025 10:37:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5O-0003VS-MP; Wed, 29 Oct 2025 13:35: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 1vEA5K-0003UP-Qy for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:47 -0400 Received: from p-east2-cluster1-host7-snip4-10.eps.apple.com ([57.103.76.73] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5C-0003JZ-8I for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:46 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 36A9D1800316; Wed, 29 Oct 2025 17:35:21 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 904071859E44; Wed, 29 Oct 2025 16:55:26 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=tZPXOL+uIWMOEt6HxsooL4DtZPhoOOqc0cyEH40+x1w=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=Ad8dYuLjDBlQ5Z5K6hZq5Cnp8i8mnWqdjOQi+KFBw14jKpe5jr+Emg25OO0H98lc+q4x0yMMBYjxv5yhslA2Tjhc8PPaFEHm6V6CaScy2tEoWzrapkgnG7wIAWfLzF9hg+pD0Pazxrpf9XPjcAllwjS9C5v/RTyk3RdtZ8WS/BUJKqPw0pVwLvNi/VAN9MxFMY8UAq1ABoTaULF24A7iA+Yk39jgU94nc/76S/tsV8fyG4sF1LpccXz9LG4Ox1tePJW2Qt6+imzXqsmMvXmHkitbpRe5Am6t98OD7x963DRBXJ5AYVdfEkWDhHYmc7WRVFyZJcO4jr1XVx49QHYkgQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 06/28] whpx: Move around files before introducing AArch64 support Date: Wed, 29 Oct 2025 17:54:48 +0100 Message-ID: <20251029165510.45824-7-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX4HLaR5BZtoDe XkgZjfLOrYgNJUw8hDBcfIT5iQ3WDBPKJLbP27ffRUEmLJZVilUxlGzbXpnTkTnHzcQiDZWqXkt TEXpcH7T/vlmXF65zw4XSdlycoJyeLU+ChnATv2pmltqlD2+mK9ZN5lLV8Xia+B/Zvl2SdzmkCi /rff/d8WfSRQEdvw1TWyXuJ6YR/xAUGKo1941fRs07c2Mx+QHgiq7PNwPAFU4c+J0Khwvz53IH4 xgOmXpMvd+RF1pbqTeRHJ37JCnMlOwDhCOywYgi1qMdu8zGKsFtEE3UZhIQm9VdidVh2rBOo/Um fL9Da0xDb/6HRDa8GUI X-Proofpoint-GUID: ggOxSInIvkevspp9OhMgksOecCBTRiJz X-Proofpoint-ORIG-GUID: ggOxSInIvkevspp9OhMgksOecCBTRiJz X-Authority-Info: v=2.4 cv=WfoBqkhX c=1 sm=1 tr=0 ts=6902505a cx=c_apl:c_pps a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=IkcTkHD0fZMA:10 a=x6icFKpwvdMA:10 a=KKAkSRfTAAAA:8 a=yMhMjlubAAAA:8 a=5-iGLm-LtT_B5TT3xKgA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 mlxlogscore=999 bulkscore=0 adultscore=0 suspectscore=0 phishscore=0 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2509250000 definitions=main-2510290140 X-JNJ: AAAAAAABuEyOIja3iIA8lCGzPc9CDsLvSxoSYPT/sXBoqEKkFwgmjAefNWbWjsEl9hFsoU5DUIBbpOTmolLhCbCLwKOG64iwSTqNPZ3hdYQ9OnAkRcvrbuycdE5YHkCrQLWKVUm3Vc/Yu44nWAD0ysUu8iqgE/ok1VWERdqQZI+lH4LCP1dLu5vxKPPgM9pG4qK/qYCN0qxl6DruHS37MPpBVkc7P6fYgUiDtqVjWQhLgOkKPoCXbV+QXPsNvQE/tf4Q7apjUMUbwFcA1+Oa9HGjVM44DpVB1UDg+8X3apu9IIrBZO2ldZJ9n2JczE1eW7WYRMYkiNxWWzH3pdoj9M9jBXnQ7HDyaC+5Qx/y0cM8Rq5UvzDAdSd/pvz6izvzDvjWLBOvvegUuP+ZysKkd1nzRfHYR9iYhRz+i1h8qh5wmS7uwBqFid5ZwEQLReKSE+f2pU3G/vDOAu4kq8pBGu13yhe3nGiaOqCO3jCjXX3NSgpuCOIviZFOxJWO1s6Bis3CAhWiPee3ptUoFgvKvx4MUBDR03xYl3RZiIFhRaPO+wnQwEo2m+3JfBf9KsGSiKUI1FR/bwLGcLD0GM3XUzLzMdVcU3sS1vbdM1rAHILYLDjiWfD6CimRR3y8T9M35IbGqfOA9BLFoacDc48s4udYTyqd0Mrl6tqSMqopOBqNcK19aqr3ERIOtg2HOvM75FNeL7mRSOmRvPMMtskdiou8Ad1x89Inl6PKoaBdGzAnmutAEMvHLWz7khoScsU4jEnoHYw4+Xb2rxiG9IfLPVgQBg== 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=57.103.76.73; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1761759447216154100 Switch to a design where we can share whpx code between x86 and AArch64 whe= n it makes sense to do so. Signed-off-by: Mohamed Mediouni Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- MAINTAINERS | 2 ++ accel/meson.build | 1 + accel/whpx/meson.build | 6 ++++++ {target/i386 =3D> accel}/whpx/whpx-accel-ops.c | 4 ++-- {target/i386/whpx =3D> include/system}/whpx-accel-ops.h | 4 ++-- {target/i386/whpx =3D> include/system}/whpx-internal.h | 5 +++-- target/i386/whpx/meson.build | 1 - target/i386/whpx/whpx-all.c | 4 ++-- target/i386/whpx/whpx-apic.c | 2 +- 9 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 accel/whpx/meson.build rename {target/i386 =3D> accel}/whpx/whpx-accel-ops.c (97%) rename {target/i386/whpx =3D> include/system}/whpx-accel-ops.h (92%) rename {target/i386/whpx =3D> include/system}/whpx-internal.h (98%) diff --git a/MAINTAINERS b/MAINTAINERS index 64491c800c..4ea4c48a2a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -549,9 +549,11 @@ F: include/system/hvf_int.h WHPX CPUs M: Sunil Muthuswamy S: Supported +F: accel/whpx/ F: target/i386/whpx/ F: accel/stubs/whpx-stub.c F: include/system/whpx.h +F: include/system/whpx-accel-ops.h =20 MSHV M: Magnus Kulke diff --git a/accel/meson.build b/accel/meson.build index 983dfd0bd5..289b7420ff 100644 --- a/accel/meson.build +++ b/accel/meson.build @@ -6,6 +6,7 @@ user_ss.add(files('accel-user.c')) subdir('tcg') if have_system subdir('hvf') + subdir('whpx') subdir('qtest') subdir('kvm') subdir('xen') diff --git a/accel/whpx/meson.build b/accel/whpx/meson.build new file mode 100644 index 0000000000..7b3d6f1c1c --- /dev/null +++ b/accel/whpx/meson.build @@ -0,0 +1,6 @@ +whpx_ss =3D ss.source_set() +whpx_ss.add(files( + 'whpx-accel-ops.c', +)) + +specific_ss.add_all(when: 'CONFIG_WHPX', if_true: whpx_ss) diff --git a/target/i386/whpx/whpx-accel-ops.c b/accel/whpx/whpx-accel-ops.c similarity index 97% rename from target/i386/whpx/whpx-accel-ops.c rename to accel/whpx/whpx-accel-ops.c index f75886128d..c84a25c273 100644 --- a/target/i386/whpx/whpx-accel-ops.c +++ b/accel/whpx/whpx-accel-ops.c @@ -16,8 +16,8 @@ #include "qemu/guest-random.h" =20 #include "system/whpx.h" -#include "whpx-internal.h" -#include "whpx-accel-ops.h" +#include "system/whpx-internal.h" +#include "system/whpx-accel-ops.h" =20 static void *whpx_cpu_thread_fn(void *arg) { diff --git a/target/i386/whpx/whpx-accel-ops.h b/include/system/whpx-accel-= ops.h similarity index 92% rename from target/i386/whpx/whpx-accel-ops.h rename to include/system/whpx-accel-ops.h index 54cfc25a14..ed9d4c49f4 100644 --- a/target/i386/whpx/whpx-accel-ops.h +++ b/include/system/whpx-accel-ops.h @@ -7,8 +7,8 @@ * See the COPYING file in the top-level directory. */ =20 -#ifndef TARGET_I386_WHPX_ACCEL_OPS_H -#define TARGET_I386_WHPX_ACCEL_OPS_H +#ifndef SYSTEM_WHPX_ACCEL_OPS_H +#define SYSTEM_WHPX_ACCEL_OPS_H =20 #include "system/cpus.h" =20 diff --git a/target/i386/whpx/whpx-internal.h b/include/system/whpx-interna= l.h similarity index 98% rename from target/i386/whpx/whpx-internal.h rename to include/system/whpx-internal.h index 2dcad1f565..c59f9de091 100644 --- a/target/i386/whpx/whpx-internal.h +++ b/include/system/whpx-internal.h @@ -1,5 +1,6 @@ -#ifndef TARGET_I386_WHPX_INTERNAL_H -#define TARGET_I386_WHPX_INTERNAL_H +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef SYSTEM_WHPX_INTERNAL_H +#define SYSTEM_WHPX_INTERNAL_H =20 #include #include diff --git a/target/i386/whpx/meson.build b/target/i386/whpx/meson.build index 9c54aaad39..c3aaaff9fd 100644 --- a/target/i386/whpx/meson.build +++ b/target/i386/whpx/meson.build @@ -1,5 +1,4 @@ i386_system_ss.add(when: 'CONFIG_WHPX', if_true: files( 'whpx-all.c', 'whpx-apic.c', - 'whpx-accel-ops.c', )) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 6bf8d5f4bb..c0bd429d19 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -31,8 +31,8 @@ #include "accel/accel-cpu-target.h" #include =20 -#include "whpx-internal.h" -#include "whpx-accel-ops.h" +#include "system/whpx-internal.h" +#include "system/whpx-accel-ops.h" =20 #include #include diff --git a/target/i386/whpx/whpx-apic.c b/target/i386/whpx/whpx-apic.c index afcb25843b..b934fdcbe1 100644 --- a/target/i386/whpx/whpx-apic.c +++ b/target/i386/whpx/whpx-apic.c @@ -18,7 +18,7 @@ #include "hw/pci/msi.h" #include "system/hw_accel.h" #include "system/whpx.h" -#include "whpx-internal.h" +#include "system/whpx-internal.h" =20 struct whpx_lapic_state { struct { --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759548; cv=none; d=zohomail.com; s=zohoarc; b=jBizx4/CQbumk+yf79WYAXwSJZcfEKAaQ5Nhh2Y9oHqN1oZBuK+xtg+nVXmXFZVRWh/F7wtXK2B+r1MTZtktr0HCpR2Ilp8Amb8v2qZJybUSVzfPjOsMv8bAHBjeBasf/8ulBJHIRRmaD/lWMMHLNA/oxTuSCskeqoYpXn69myM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759548; 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=zCckHvMlb4VeRi3eksm9UNrSgcz2wC8+oslqosK0I4g=; b=A5W13VgswCiB1v7YUk/H+pzv9KomrfVznbZEu7pF+cwwCKSaaKnJD4J408COBVjohAHmFWccWsSnL8k8ITvhOuwYBwKKk+kuFrru6+GUXjNnE0zpJ9gIHebeBsQBdclk4v0gGq9Ddgsi/6rUFw8qhk/Yng1OSi8fQgFIghCO2iA= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176175954811249.32572853107672; Wed, 29 Oct 2025 10:39:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5W-0003a8-KW; Wed, 29 Oct 2025 13:35: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 1vEA5R-0003Y2-7w for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:53 -0400 Received: from p-east2-cluster1-host3-snip4-4.eps.apple.com ([57.103.76.7] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5D-0003Jz-K8 for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:52 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 427171824493; Wed, 29 Oct 2025 17:35:22 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 5D14D1859E5E; Wed, 29 Oct 2025 16:55:28 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=zCckHvMlb4VeRi3eksm9UNrSgcz2wC8+oslqosK0I4g=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=Iv+aSStoJqdLVfuvxs6FhPEKM76OPmnOIOcFdrQ7t6JH2B/vIUzWah3TMoei7TcCq2g5csd5HSkMIJJoRZ/+SanerkAoYyT4wOuKIHGEIhQNLLlIDlC96KJqiE+Wlwt6BZY8iVOC+QoEGVnEvdp6XsnKwfpAOG/OCCyEa0uIvBf2jR89O9aZWqIEkiKa9Rk1/QFyutZNmoNoDYURASbOKL4TI3OSFgOA8+a98/+/V6CUTpVzc+JWPnioR6ukUKDAPpc6kGCbdQbu/bP+mTlgfR0KrCs7to+vydadSvvA3NDRzZyUNApl4ZW+IO6NB801Hvb4vmXY2+oa+QX1FCwcSg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 07/28] whpx: reshuffle common code Date: Wed, 29 Oct 2025 17:54:49 +0100 Message-ID: <20251029165510.45824-8-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info: v=2.4 cv=LtyfC3dc c=1 sm=1 tr=0 ts=6902505b cx=c_apl:c_pps a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=x6icFKpwvdMA:10 a=KKAkSRfTAAAA:8 a=yMhMjlubAAAA:8 a=XtnWhMvHLvoGx0dyWtYA:9 a=cvBusfyB2V15izCimMoJ:22 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX8+NZR79sXONV zTnbfKWM8vOA6LKvDfKx/o7gYSuIqrnA04EaE32k2nOJvlf4QP4N/xIB9GoeL6MKIdYx4iTbS78 acZ9h4eMkyhJqvJe8TBCjG8LpX1DUfVU5oh/+jYNXvQZSBMEJio6n54pzg+VvtADMhdKDm96NZI 5D4T+2YT2EfCnMlfX4ZwB18B97KG9yXBFO55lFDiq7u+x9EeHu03B0CUx1UY5k3mM1s2JxakUZk NUodmFlGgMAeciIof9+ZwCQhnh8c5p2ctrodpu0BqxobU0FpFdU657tgm2ut3MVuFGF4bx6oLn6 JaW1ZKJhJ+e2pyj2ee5 X-Proofpoint-ORIG-GUID: A6oO7JNd0OtPIlxTx9uLGTRw_SZfz2y8 X-Proofpoint-GUID: A6oO7JNd0OtPIlxTx9uLGTRw_SZfz2y8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 phishscore=0 clxscore=1030 malwarescore=0 mlxscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2509250000 definitions=main-2510290140 X-JNJ: AAAAAAABtTK7JZz9OGCB2o8JuAhcxoR+944SxvzGQca0GYNV9ApediOqNnCayqoB4GJE6F/x/nF+Cn+D+vszPHxAq5jFRsrDQRnw8sygIjv3jjPpjV1Q7YzqhAkTvJJpBNvLNU7PFmzBwDS0HvML4k0be8VA1yxwW4LBsZnuCgplmn/dSHvtyZoltkPibgNJpP2uU2iBa+KaGoV6XNSXI4AnhWRgjJDvF5Kk2VKwzBomEr2daGp+torAoPXmsWrA31EWjieSDPI37Wxd+wyu7sIPAXXc6GLH3JVePAcKi8PCjy4Nf4b4IKNhYLMdvducu+yIdoM1XNcY/GUjtkZM0Ha/HCBZJdrgsfg6b8Y4CWh9nHYWplhlKPkbTRPbV09/bnSJO4L9FMu2A0fUJLBTqXmoF+7nTFLsET1R/U39dB6X4zOtAzcWOF+QY7UsHr8SylBi0CN8ezoBh6Zk0GcdjfHNCiYaCnX2XVcrutEAHb6jlWfuL1v4Kucn3z3hLeP07IpKuiRZ9snbZzkgT/HOaLpTmy27cfqRD6/EXP/p/PEZH/Zu2BvaWiaZ7I38alUS7L6Y5v+f57SO99dV0i8FY1Qs/bXpLr0JuUSgDfKQpABcJjNTCEbiWSUx7rDOLtS+PSyJrnvAQR9bee4VS9Yq4DbH7x1tr6WIGGu2voGqcHsYfALb9nYCtNUpDyXgF4ymdzPlEqF9cOtabd71vAqmxaY0RKWlhw2hZ7BYk2ukot6bMcMaZ2d+I/Xa 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=57.103.76.7; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.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_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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759550580154100 Content-Type: text/plain; charset="utf-8" Some code can be shared between x86_64 and arm64 WHPX. Do so as much as rea= sonable. Signed-off-by: Mohamed Mediouni Reviewed-by: Pierrick Bouvier --- MAINTAINERS | 2 + accel/whpx/meson.build | 1 + accel/whpx/whpx-common.c | 562 +++++++++++++++++++++++++++++++++++ include/system/whpx-all.h | 20 ++ include/system/whpx-common.h | 21 ++ target/i386/whpx/whpx-all.c | 551 +--------------------------------- 6 files changed, 616 insertions(+), 541 deletions(-) create mode 100644 accel/whpx/whpx-common.c create mode 100644 include/system/whpx-all.h create mode 100644 include/system/whpx-common.h diff --git a/MAINTAINERS b/MAINTAINERS index 4ea4c48a2a..c6b7f45459 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -554,6 +554,8 @@ F: target/i386/whpx/ F: accel/stubs/whpx-stub.c F: include/system/whpx.h F: include/system/whpx-accel-ops.h +F: include/system/whpx-common.h +F: include/system/whpx-internal.h =20 MSHV M: Magnus Kulke diff --git a/accel/whpx/meson.build b/accel/whpx/meson.build index 7b3d6f1c1c..fad28dddcb 100644 --- a/accel/whpx/meson.build +++ b/accel/whpx/meson.build @@ -1,6 +1,7 @@ whpx_ss =3D ss.source_set() whpx_ss.add(files( 'whpx-accel-ops.c', + 'whpx-common.c' )) =20 specific_ss.add_all(when: 'CONFIG_WHPX', if_true: whpx_ss) diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c new file mode 100644 index 0000000000..66c9238586 --- /dev/null +++ b/accel/whpx/whpx-common.c @@ -0,0 +1,562 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * QEMU Windows Hypervisor Platform accelerator (WHPX) + * + * Copyright Microsoft Corp. 2017 + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "system/address-spaces.h" +#include "system/ioport.h" +#include "gdbstub/helpers.h" +#include "qemu/accel.h" +#include "accel/accel-ops.h" +#include "system/whpx.h" +#include "system/cpus.h" +#include "system/runstate.h" +#include "qemu/main-loop.h" +#include "hw/boards.h" +#include "hw/intc/ioapic.h" +#include "qemu/error-report.h" +#include "qapi/error.h" +#include "qapi/qapi-types-common.h" +#include "qapi/qapi-visit-common.h" +#include "migration/blocker.h" +#include "accel/accel-cpu-target.h" +#include + +#include "system/whpx-internal.h" +#include "system/whpx-accel-ops.h" +#include "system/whpx-common.h" +#include "system/whpx-all.h" + +#include +#include + +bool whpx_allowed; +static bool whp_dispatch_initialized; +static HMODULE hWinHvPlatform; +static HMODULE hWinHvEmulation; + +struct whpx_state whpx_global; +struct WHPDispatch whp_dispatch; + +/* Tries to find a breakpoint at the specified address. */ +struct whpx_breakpoint *whpx_lookup_breakpoint_by_addr(uint64_t address) +{ + struct whpx_state *whpx =3D &whpx_global; + int i; + + if (whpx->breakpoints.breakpoints) { + for (i =3D 0; i < whpx->breakpoints.breakpoints->used; i++) { + if (address =3D=3D whpx->breakpoints.breakpoints->data[i].addr= ess) { + return &whpx->breakpoints.breakpoints->data[i]; + } + } + } + + return NULL; +} + +/* + * This function is called when the a VCPU is about to start and no other + * VCPUs have been started so far. Since the VCPU start order could be + * arbitrary, it doesn't have to be VCPU#0. + * + * It is used to commit the breakpoints into memory, and configure WHPX + * to intercept debug exceptions. + * + * Note that whpx_set_exception_exit_bitmap() cannot be called if one or + * more VCPUs are already running, so this is the best place to do it. + */ +int whpx_first_vcpu_starting(CPUState *cpu) +{ + struct whpx_state *whpx =3D &whpx_global; + + g_assert(bql_locked()); + + if (!QTAILQ_EMPTY(&cpu->breakpoints) || + (whpx->breakpoints.breakpoints && + whpx->breakpoints.breakpoints->used)) { + CPUBreakpoint *bp; + int i =3D 0; + bool update_pending =3D false; + + QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) { + if (i >=3D whpx->breakpoints.original_address_count || + bp->pc !=3D whpx->breakpoints.original_addresses[i]) { + update_pending =3D true; + } + + i++; + } + + if (i !=3D whpx->breakpoints.original_address_count) { + update_pending =3D true; + } + + if (update_pending) { + /* + * The CPU breakpoints have changed since the last call to + * whpx_translate_cpu_breakpoints(). WHPX breakpoints must + * now be recomputed. + */ + whpx_translate_cpu_breakpoints(&whpx->breakpoints, cpu, i); + } + /* Actually insert the breakpoints into the memory. */ + whpx_apply_breakpoints(whpx->breakpoints.breakpoints, cpu, true); + } + HRESULT hr; + uint64_t exception_mask; + if (whpx->step_pending || + (whpx->breakpoints.breakpoints && + whpx->breakpoints.breakpoints->used)) { + /* + * We are either attempting to single-step one or more CPUs, or + * have one or more breakpoints enabled. Both require intercepting + * the WHvX64ExceptionTypeBreakpointTrap exception. + */ + exception_mask =3D 1UL << WHvX64ExceptionTypeDebugTrapOrFault; + } else { + /* Let the guest handle all exceptions. */ + exception_mask =3D 0; + } + hr =3D whpx_set_exception_exit_bitmap(exception_mask); + if (!SUCCEEDED(hr)) { + error_report("WHPX: Failed to update exception exit mask," + "hr=3D%08lx.", hr); + return 1; + } + return 0; +} + +/* + * This function is called when the last VCPU has finished running. + * It is used to remove any previously set breakpoints from memory. + */ +int whpx_last_vcpu_stopping(CPUState *cpu) +{ + whpx_apply_breakpoints(whpx_global.breakpoints.breakpoints, cpu, false= ); + return 0; +} + +static void do_whpx_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data a= rg) +{ + if (!cpu->vcpu_dirty) { + whpx_get_registers(cpu); + cpu->vcpu_dirty =3D true; + } +} + +static void do_whpx_cpu_synchronize_post_reset(CPUState *cpu, + run_on_cpu_data arg) +{ + whpx_set_registers(cpu, WHPX_SET_RESET_STATE); + cpu->vcpu_dirty =3D false; +} + +static void do_whpx_cpu_synchronize_post_init(CPUState *cpu, + run_on_cpu_data arg) +{ + whpx_set_registers(cpu, WHPX_SET_FULL_STATE); + cpu->vcpu_dirty =3D false; +} + +static void do_whpx_cpu_synchronize_pre_loadvm(CPUState *cpu, + run_on_cpu_data arg) +{ + cpu->vcpu_dirty =3D true; +} + +/* + * CPU support. + */ + +void whpx_cpu_synchronize_state(CPUState *cpu) +{ + if (!cpu->vcpu_dirty) { + run_on_cpu(cpu, do_whpx_cpu_synchronize_state, RUN_ON_CPU_NULL); + } +} + +void whpx_cpu_synchronize_post_reset(CPUState *cpu) +{ + run_on_cpu(cpu, do_whpx_cpu_synchronize_post_reset, RUN_ON_CPU_NULL); +} + +void whpx_cpu_synchronize_post_init(CPUState *cpu) +{ + run_on_cpu(cpu, do_whpx_cpu_synchronize_post_init, RUN_ON_CPU_NULL); +} + +void whpx_cpu_synchronize_pre_loadvm(CPUState *cpu) +{ + run_on_cpu(cpu, do_whpx_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL); +} + +static void whpx_pre_resume_vm(AccelState *as, bool step_pending) +{ + whpx_global.step_pending =3D step_pending; +} + +/* + * Vcpu support. + */ + +int whpx_vcpu_exec(CPUState *cpu) +{ + int ret; + int fatal; + + for (;;) { + if (cpu->exception_index >=3D EXCP_INTERRUPT) { + ret =3D cpu->exception_index; + cpu->exception_index =3D -1; + break; + } + + fatal =3D whpx_vcpu_run(cpu); + + if (fatal) { + error_report("WHPX: Failed to exec a virtual processor"); + abort(); + } + } + + return ret; +} + +void whpx_destroy_vcpu(CPUState *cpu) +{ + struct whpx_state *whpx =3D &whpx_global; + + whp_dispatch.WHvDeleteVirtualProcessor(whpx->partition, cpu->cpu_index= ); + AccelCPUState *vcpu =3D cpu->accel; + whp_dispatch.WHvEmulatorDestroyEmulator(vcpu->emulator); + g_free(cpu->accel); +} + + +void whpx_vcpu_kick(CPUState *cpu) +{ + struct whpx_state *whpx =3D &whpx_global; + whp_dispatch.WHvCancelRunVirtualProcessor( + whpx->partition, cpu->cpu_index, 0); +} + +/* + * Memory support. + */ + +static void whpx_update_mapping(hwaddr start_pa, ram_addr_t size, + void *host_va, int add, int rom, + const char *name) +{ + struct whpx_state *whpx =3D &whpx_global; + HRESULT hr; + + /* + if (add) { + printf("WHPX: ADD PA:%p Size:%p, Host:%p, %s, '%s'\n", + (void*)start_pa, (void*)size, host_va, + (rom ? "ROM" : "RAM"), name); + } else { + printf("WHPX: DEL PA:%p Size:%p, Host:%p, '%s'\n", + (void*)start_pa, (void*)size, host_va, name); + } + */ + + if (add) { + hr =3D whp_dispatch.WHvMapGpaRange(whpx->partition, + host_va, + start_pa, + size, + (WHvMapGpaRangeFlagRead | + WHvMapGpaRangeFlagExecute | + (rom ? 0 : WHvMapGpaRangeFlagWri= te))); + } else { + hr =3D whp_dispatch.WHvUnmapGpaRange(whpx->partition, + start_pa, + size); + } + + if (FAILED(hr)) { + error_report("WHPX: Failed to %s GPA range '%s' PA:%p, Size:%p byt= es," + " Host:%p, hr=3D%08lx", + (add ? "MAP" : "UNMAP"), name, + (void *)(uintptr_t)start_pa, (void *)size, host_va, h= r); + } +} + +static void whpx_process_section(MemoryRegionSection *section, int add) +{ + MemoryRegion *mr =3D section->mr; + hwaddr start_pa =3D section->offset_within_address_space; + ram_addr_t size =3D int128_get64(section->size); + unsigned int delta; + uint64_t host_va; + + if (!memory_region_is_ram(mr)) { + return; + } + + delta =3D qemu_real_host_page_size() - (start_pa & ~qemu_real_host_pag= e_mask()); + delta &=3D ~qemu_real_host_page_mask(); + if (delta > size) { + return; + } + start_pa +=3D delta; + size -=3D delta; + size &=3D qemu_real_host_page_mask(); + if (!size || (start_pa & ~qemu_real_host_page_mask())) { + return; + } + + host_va =3D (uintptr_t)memory_region_get_ram_ptr(mr) + + section->offset_within_region + delta; + + whpx_update_mapping(start_pa, size, (void *)(uintptr_t)host_va, add, + memory_region_is_rom(mr), mr->name); +} + +static void whpx_region_add(MemoryListener *listener, + MemoryRegionSection *section) +{ + memory_region_ref(section->mr); + whpx_process_section(section, 1); +} + +static void whpx_region_del(MemoryListener *listener, + MemoryRegionSection *section) +{ + whpx_process_section(section, 0); + memory_region_unref(section->mr); +} + +static void whpx_transaction_begin(MemoryListener *listener) +{ +} + +static void whpx_transaction_commit(MemoryListener *listener) +{ +} + +static void whpx_log_sync(MemoryListener *listener, + MemoryRegionSection *section) +{ + MemoryRegion *mr =3D section->mr; + + if (!memory_region_is_ram(mr)) { + return; + } + + memory_region_set_dirty(mr, 0, int128_get64(section->size)); +} + +static MemoryListener whpx_memory_listener =3D { + .name =3D "whpx", + .begin =3D whpx_transaction_begin, + .commit =3D whpx_transaction_commit, + .region_add =3D whpx_region_add, + .region_del =3D whpx_region_del, + .log_sync =3D whpx_log_sync, + .priority =3D MEMORY_LISTENER_PRIORITY_ACCEL, +}; + +void whpx_memory_init(void) +{ + memory_listener_register(&whpx_memory_listener, &address_space_memory); +} + +/* + * Load the functions from the given library, using the given handle. If a + * handle is provided, it is used, otherwise the library is opened. The + * handle will be updated on return with the opened one. + */ +static bool load_whp_dispatch_fns(HMODULE *handle, + WHPFunctionList function_list) +{ + HMODULE hLib =3D *handle; + + #define WINHV_PLATFORM_DLL "WinHvPlatform.dll" + #define WINHV_EMULATION_DLL "WinHvEmulation.dll" + #define WHP_LOAD_FIELD_OPTIONAL(return_type, function_name, signature)= \ + whp_dispatch.function_name =3D \ + (function_name ## _t)GetProcAddress(hLib, #function_name); \ + + #define WHP_LOAD_FIELD(return_type, function_name, signature) \ + whp_dispatch.function_name =3D \ + (function_name ## _t)GetProcAddress(hLib, #function_name); \ + if (!whp_dispatch.function_name) { \ + error_report("Could not load function %s", #function_name); \ + goto error; \ + } \ + + #define WHP_LOAD_LIB(lib_name, handle_lib) \ + if (!handle_lib) { \ + handle_lib =3D LoadLibrary(lib_name); \ + if (!handle_lib) { \ + error_report("Could not load library %s.", lib_name); \ + goto error; \ + } \ + } \ + + switch (function_list) { + case WINHV_PLATFORM_FNS_DEFAULT: + WHP_LOAD_LIB(WINHV_PLATFORM_DLL, hLib) + LIST_WINHVPLATFORM_FUNCTIONS(WHP_LOAD_FIELD) + break; + case WINHV_EMULATION_FNS_DEFAULT: + WHP_LOAD_LIB(WINHV_EMULATION_DLL, hLib) + LIST_WINHVEMULATION_FUNCTIONS(WHP_LOAD_FIELD) + break; + case WINHV_PLATFORM_FNS_SUPPLEMENTAL: + WHP_LOAD_LIB(WINHV_PLATFORM_DLL, hLib) + LIST_WINHVPLATFORM_FUNCTIONS_SUPPLEMENTAL(WHP_LOAD_FIELD_OPTIONAL) + break; + } + + *handle =3D hLib; + return true; + +error: + if (hLib) { + FreeLibrary(hLib); + } + + return false; +} + +static void whpx_set_kernel_irqchip(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + struct whpx_state *whpx =3D &whpx_global; + OnOffSplit mode; + + if (!visit_type_OnOffSplit(v, name, &mode, errp)) { + return; + } + + switch (mode) { + case ON_OFF_SPLIT_ON: + whpx->kernel_irqchip_allowed =3D true; + whpx->kernel_irqchip_required =3D true; + break; + + case ON_OFF_SPLIT_OFF: + whpx->kernel_irqchip_allowed =3D false; + whpx->kernel_irqchip_required =3D false; + break; + + case ON_OFF_SPLIT_SPLIT: + error_setg(errp, "WHPX: split irqchip currently not supported"); + error_append_hint(errp, + "Try without kernel-irqchip or with kernel-irqchip=3Don|off"); + break; + + default: + /* + * The value was checked in visit_type_OnOffSplit() above. If + * we get here, then something is wrong in QEMU. + */ + abort(); + } +} + +static void whpx_cpu_accel_class_init(ObjectClass *oc, const void *data) +{ + AccelCPUClass *acc =3D ACCEL_CPU_CLASS(oc); + + acc->cpu_instance_init =3D whpx_cpu_instance_init; +} + +static const TypeInfo whpx_cpu_accel_type =3D { + .name =3D ACCEL_CPU_NAME("whpx"), + + .parent =3D TYPE_ACCEL_CPU, + .class_init =3D whpx_cpu_accel_class_init, + .abstract =3D true, +}; + +/* + * Partition support + */ + +bool whpx_apic_in_platform(void) +{ + return whpx_global.apic_in_platform; +} + +static void whpx_accel_class_init(ObjectClass *oc, const void *data) +{ + AccelClass *ac =3D ACCEL_CLASS(oc); + ac->name =3D "WHPX"; + ac->init_machine =3D whpx_accel_init; + ac->pre_resume_vm =3D whpx_pre_resume_vm; + ac->allowed =3D &whpx_allowed; + + object_class_property_add(oc, "kernel-irqchip", "on|off|split", + NULL, whpx_set_kernel_irqchip, + NULL, NULL); + object_class_property_set_description(oc, "kernel-irqchip", + "Configure WHPX in-kernel irqchip"); +} + +static void whpx_accel_instance_init(Object *obj) +{ + struct whpx_state *whpx =3D &whpx_global; + + memset(whpx, 0, sizeof(struct whpx_state)); + /* Turn on kernel-irqchip, by default */ + whpx->kernel_irqchip_allowed =3D true; +} + +static const TypeInfo whpx_accel_type =3D { + .name =3D ACCEL_CLASS_NAME("whpx"), + .parent =3D TYPE_ACCEL, + .instance_init =3D whpx_accel_instance_init, + .class_init =3D whpx_accel_class_init, +}; + +static void whpx_type_init(void) +{ + type_register_static(&whpx_accel_type); + type_register_static(&whpx_cpu_accel_type); +} + +bool init_whp_dispatch(void) +{ + if (whp_dispatch_initialized) { + return true; + } + + if (!load_whp_dispatch_fns(&hWinHvPlatform, WINHV_PLATFORM_FNS_DEFAULT= )) { + goto error; + } + + if (!load_whp_dispatch_fns(&hWinHvEmulation, WINHV_EMULATION_FNS_DEFAU= LT)) { + goto error; + } + + assert(load_whp_dispatch_fns(&hWinHvPlatform, + WINHV_PLATFORM_FNS_SUPPLEMENTAL)); + whp_dispatch_initialized =3D true; + + return true; +error: + if (hWinHvPlatform) { + FreeLibrary(hWinHvPlatform); + } + if (hWinHvEmulation) { + FreeLibrary(hWinHvEmulation); + } + return false; +} + +type_init(whpx_type_init); diff --git a/include/system/whpx-all.h b/include/system/whpx-all.h new file mode 100644 index 0000000000..f13cdf7f66 --- /dev/null +++ b/include/system/whpx-all.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef SYSTEM_WHPX_ALL_H +#define SYSTEM_WHPX_ALL_H + +/* Called by whpx-common */ +int whpx_vcpu_run(CPUState *cpu); +void whpx_get_registers(CPUState *cpu); +void whpx_set_registers(CPUState *cpu, int level); +int whpx_accel_init(AccelState *as, MachineState *ms); +void whpx_cpu_instance_init(CPUState *cs); +HRESULT whpx_set_exception_exit_bitmap(UINT64 exceptions); +void whpx_apply_breakpoints( +struct whpx_breakpoint_collection *breakpoints, + CPUState *cpu, + bool resuming); +void whpx_translate_cpu_breakpoints( + struct whpx_breakpoints *breakpoints, + CPUState *cpu, + int cpu_breakpoint_count); +#endif diff --git a/include/system/whpx-common.h b/include/system/whpx-common.h new file mode 100644 index 0000000000..e549c7539c --- /dev/null +++ b/include/system/whpx-common.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef SYSTEM_WHPX_COMMON_H +#define SYSTEM_WHPX_COMMON_H + +struct AccelCPUState { + WHV_EMULATOR_HANDLE emulator; + bool window_registered; + bool interruptable; + bool ready_for_pic_interrupt; + uint64_t tpr; + uint64_t apic_base; + bool interruption_pending; + /* Must be the last field as it may have a tail */ + WHV_RUN_VP_EXIT_CONTEXT exit_ctx; +}; + +int whpx_first_vcpu_starting(CPUState *cpu); +int whpx_last_vcpu_stopping(CPUState *cpu); +void whpx_memory_init(void); +struct whpx_breakpoint *whpx_lookup_breakpoint_by_addr(uint64_t address); +#endif diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index c0bd429d19..c63bb28b20 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -33,6 +33,8 @@ =20 #include "system/whpx-internal.h" #include "system/whpx-accel-ops.h" +#include "system/whpx-all.h" +#include "system/whpx-common.h" =20 #include #include @@ -232,28 +234,9 @@ typedef enum WhpxStepMode { WHPX_STEP_EXCLUSIVE, } WhpxStepMode; =20 -struct AccelCPUState { - WHV_EMULATOR_HANDLE emulator; - bool window_registered; - bool interruptable; - bool ready_for_pic_interrupt; - uint64_t tpr; - uint64_t apic_base; - bool interruption_pending; - - /* Must be the last field as it may have a tail */ - WHV_RUN_VP_EXIT_CONTEXT exit_ctx; -}; - -bool whpx_allowed; -static bool whp_dispatch_initialized; -static HMODULE hWinHvPlatform, hWinHvEmulation; static uint32_t max_vcpu_index; static WHV_PROCESSOR_XSAVE_FEATURES whpx_xsave_cap; =20 -struct whpx_state whpx_global; -struct WHPDispatch whp_dispatch; - static bool whpx_has_xsave(void) { return whpx_xsave_cap.XsaveSupport; @@ -379,7 +362,7 @@ static uint64_t whpx_cr8_to_apic_tpr(uint64_t cr8) return cr8 << 4; } =20 -static void whpx_set_registers(CPUState *cpu, int level) +void whpx_set_registers(CPUState *cpu, int level) { struct whpx_state *whpx =3D &whpx_global; AccelCPUState *vcpu =3D cpu->accel; @@ -594,7 +577,7 @@ static void whpx_get_xcrs(CPUState *cpu) cpu_env(cpu)->xcr0 =3D xcr0.Reg64; } =20 -static void whpx_get_registers(CPUState *cpu) +void whpx_get_registers(CPUState *cpu) { struct whpx_state *whpx =3D &whpx_global; AccelCPUState *vcpu =3D cpu->accel; @@ -934,7 +917,7 @@ static int whpx_handle_portio(CPUState *cpu, * The 'exceptions' argument accepts a bitmask, e.g: * (1 << WHvX64ExceptionTypeDebugTrapOrFault) | (...) */ -static HRESULT whpx_set_exception_exit_bitmap(UINT64 exceptions) +HRESULT whpx_set_exception_exit_bitmap(UINT64 exceptions) { struct whpx_state *whpx =3D &whpx_global; WHV_PARTITION_PROPERTY prop =3D { 0, }; @@ -1084,23 +1067,6 @@ static HRESULT whpx_vcpu_configure_single_stepping(C= PUState *cpu, return S_OK; } =20 -/* Tries to find a breakpoint at the specified address. */ -static struct whpx_breakpoint *whpx_lookup_breakpoint_by_addr(uint64_t add= ress) -{ - struct whpx_state *whpx =3D &whpx_global; - int i; - - if (whpx->breakpoints.breakpoints) { - for (i =3D 0; i < whpx->breakpoints.breakpoints->used; i++) { - if (address =3D=3D whpx->breakpoints.breakpoints->data[i].addr= ess) { - return &whpx->breakpoints.breakpoints->data[i]; - } - } - } - - return NULL; -} - /* * Linux uses int3 (0xCC) during startup (see int3_selftest()) and for * debugging user-mode applications. Since the WHPX API does not offer @@ -1136,7 +1102,7 @@ static const uint8_t whpx_breakpoint_instruction =3D = 0xF1; * memory, but doesn't actually do it. The memory accessing is done in * whpx_apply_breakpoints(). */ -static void whpx_translate_cpu_breakpoints( +void whpx_translate_cpu_breakpoints( struct whpx_breakpoints *breakpoints, CPUState *cpu, int cpu_breakpoint_count) @@ -1230,7 +1196,7 @@ static void whpx_translate_cpu_breakpoints( * Passing resuming=3Dtrue will try to set all previously unset breakpoin= ts. * Passing resuming=3Dfalse will remove all inserted ones. */ -static void whpx_apply_breakpoints( +void whpx_apply_breakpoints( struct whpx_breakpoint_collection *breakpoints, CPUState *cpu, bool resuming) @@ -1306,93 +1272,6 @@ static void whpx_apply_breakpoints( } } =20 -/* - * This function is called when the a VCPU is about to start and no other - * VCPUs have been started so far. Since the VCPU start order could be - * arbitrary, it doesn't have to be VCPU#0. - * - * It is used to commit the breakpoints into memory, and configure WHPX - * to intercept debug exceptions. - * - * Note that whpx_set_exception_exit_bitmap() cannot be called if one or - * more VCPUs are already running, so this is the best place to do it. - */ -static int whpx_first_vcpu_starting(CPUState *cpu) -{ - struct whpx_state *whpx =3D &whpx_global; - HRESULT hr; - - g_assert(bql_locked()); - - if (!QTAILQ_EMPTY(&cpu->breakpoints) || - (whpx->breakpoints.breakpoints && - whpx->breakpoints.breakpoints->used)) { - CPUBreakpoint *bp; - int i =3D 0; - bool update_pending =3D false; - - QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) { - if (i >=3D whpx->breakpoints.original_address_count || - bp->pc !=3D whpx->breakpoints.original_addresses[i]) { - update_pending =3D true; - } - - i++; - } - - if (i !=3D whpx->breakpoints.original_address_count) { - update_pending =3D true; - } - - if (update_pending) { - /* - * The CPU breakpoints have changed since the last call to - * whpx_translate_cpu_breakpoints(). WHPX breakpoints must - * now be recomputed. - */ - whpx_translate_cpu_breakpoints(&whpx->breakpoints, cpu, i); - } - - /* Actually insert the breakpoints into the memory. */ - whpx_apply_breakpoints(whpx->breakpoints.breakpoints, cpu, true); - } - - uint64_t exception_mask; - if (whpx->step_pending || - (whpx->breakpoints.breakpoints && - whpx->breakpoints.breakpoints->used)) { - /* - * We are either attempting to single-step one or more CPUs, or - * have one or more breakpoints enabled. Both require intercepting - * the WHvX64ExceptionTypeBreakpointTrap exception. - */ - - exception_mask =3D 1UL << WHvX64ExceptionTypeDebugTrapOrFault; - } else { - /* Let the guest handle all exceptions. */ - exception_mask =3D 0; - } - - hr =3D whpx_set_exception_exit_bitmap(exception_mask); - if (!SUCCEEDED(hr)) { - error_report("WHPX: Failed to update exception exit mask," - "hr=3D%08lx.", hr); - return 1; - } - - return 0; -} - -/* - * This function is called when the last VCPU has finished running. - * It is used to remove any previously set breakpoints from memory. - */ -static int whpx_last_vcpu_stopping(CPUState *cpu) -{ - whpx_apply_breakpoints(whpx_global.breakpoints.breakpoints, cpu, false= ); - return 0; -} - /* Returns the address of the next instruction that is about to be execute= d. */ static vaddr whpx_vcpu_get_pc(CPUState *cpu, bool exit_context_valid) { @@ -1634,7 +1513,7 @@ static void whpx_vcpu_process_async_events(CPUState *= cpu) } } =20 -static int whpx_vcpu_run(CPUState *cpu) +int whpx_vcpu_run(CPUState *cpu) { HRESULT hr; struct whpx_state *whpx =3D &whpx_global; @@ -2057,65 +1936,6 @@ static int whpx_vcpu_run(CPUState *cpu) return ret < 0; } =20 -static void do_whpx_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data a= rg) -{ - if (!cpu->vcpu_dirty) { - whpx_get_registers(cpu); - cpu->vcpu_dirty =3D true; - } -} - -static void do_whpx_cpu_synchronize_post_reset(CPUState *cpu, - run_on_cpu_data arg) -{ - whpx_set_registers(cpu, WHPX_SET_RESET_STATE); - cpu->vcpu_dirty =3D false; -} - -static void do_whpx_cpu_synchronize_post_init(CPUState *cpu, - run_on_cpu_data arg) -{ - whpx_set_registers(cpu, WHPX_SET_FULL_STATE); - cpu->vcpu_dirty =3D false; -} - -static void do_whpx_cpu_synchronize_pre_loadvm(CPUState *cpu, - run_on_cpu_data arg) -{ - cpu->vcpu_dirty =3D true; -} - -/* - * CPU support. - */ - -void whpx_cpu_synchronize_state(CPUState *cpu) -{ - if (!cpu->vcpu_dirty) { - run_on_cpu(cpu, do_whpx_cpu_synchronize_state, RUN_ON_CPU_NULL); - } -} - -void whpx_cpu_synchronize_post_reset(CPUState *cpu) -{ - run_on_cpu(cpu, do_whpx_cpu_synchronize_post_reset, RUN_ON_CPU_NULL); -} - -void whpx_cpu_synchronize_post_init(CPUState *cpu) -{ - run_on_cpu(cpu, do_whpx_cpu_synchronize_post_init, RUN_ON_CPU_NULL); -} - -void whpx_cpu_synchronize_pre_loadvm(CPUState *cpu) -{ - run_on_cpu(cpu, do_whpx_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL); -} - -static void whpx_pre_resume_vm(AccelState *as, bool step_pending) -{ - whpx_global.step_pending =3D step_pending; -} - /* * Vcpu support. */ @@ -2244,295 +2064,18 @@ error: return ret; } =20 -int whpx_vcpu_exec(CPUState *cpu) -{ - int ret; - int fatal; - - for (;;) { - if (cpu->exception_index >=3D EXCP_INTERRUPT) { - ret =3D cpu->exception_index; - cpu->exception_index =3D -1; - break; - } - - fatal =3D whpx_vcpu_run(cpu); - - if (fatal) { - error_report("WHPX: Failed to exec a virtual processor"); - abort(); - } - } - - return ret; -} - -void whpx_destroy_vcpu(CPUState *cpu) -{ - struct whpx_state *whpx =3D &whpx_global; - AccelCPUState *vcpu =3D cpu->accel; - - whp_dispatch.WHvDeleteVirtualProcessor(whpx->partition, cpu->cpu_index= ); - whp_dispatch.WHvEmulatorDestroyEmulator(vcpu->emulator); - g_free(cpu->accel); -} - -void whpx_vcpu_kick(CPUState *cpu) -{ - struct whpx_state *whpx =3D &whpx_global; - whp_dispatch.WHvCancelRunVirtualProcessor( - whpx->partition, cpu->cpu_index, 0); -} - -/* - * Memory support. - */ - -static void whpx_update_mapping(hwaddr start_pa, ram_addr_t size, - void *host_va, int add, int rom, - const char *name) -{ - struct whpx_state *whpx =3D &whpx_global; - HRESULT hr; - - /* - if (add) { - printf("WHPX: ADD PA:%p Size:%p, Host:%p, %s, '%s'\n", - (void*)start_pa, (void*)size, host_va, - (rom ? "ROM" : "RAM"), name); - } else { - printf("WHPX: DEL PA:%p Size:%p, Host:%p, '%s'\n", - (void*)start_pa, (void*)size, host_va, name); - } - */ - - if (add) { - hr =3D whp_dispatch.WHvMapGpaRange(whpx->partition, - host_va, - start_pa, - size, - (WHvMapGpaRangeFlagRead | - WHvMapGpaRangeFlagExecute | - (rom ? 0 : WHvMapGpaRangeFlagWri= te))); - } else { - hr =3D whp_dispatch.WHvUnmapGpaRange(whpx->partition, - start_pa, - size); - } - - if (FAILED(hr)) { - error_report("WHPX: Failed to %s GPA range '%s' PA:%p, Size:%p byt= es," - " Host:%p, hr=3D%08lx", - (add ? "MAP" : "UNMAP"), name, - (void *)(uintptr_t)start_pa, (void *)size, host_va, h= r); - } -} - -static void whpx_process_section(MemoryRegionSection *section, int add) -{ - MemoryRegion *mr =3D section->mr; - hwaddr start_pa =3D section->offset_within_address_space; - ram_addr_t size =3D int128_get64(section->size); - unsigned int delta; - uint64_t host_va; - - if (!memory_region_is_ram(mr)) { - return; - } - - delta =3D qemu_real_host_page_size() - (start_pa & ~qemu_real_host_pag= e_mask()); - delta &=3D ~qemu_real_host_page_mask(); - if (delta > size) { - return; - } - start_pa +=3D delta; - size -=3D delta; - size &=3D qemu_real_host_page_mask(); - if (!size || (start_pa & ~qemu_real_host_page_mask())) { - return; - } - - host_va =3D (uintptr_t)memory_region_get_ram_ptr(mr) - + section->offset_within_region + delta; - - whpx_update_mapping(start_pa, size, (void *)(uintptr_t)host_va, add, - memory_region_is_rom(mr), mr->name); -} - -static void whpx_region_add(MemoryListener *listener, - MemoryRegionSection *section) -{ - memory_region_ref(section->mr); - whpx_process_section(section, 1); -} - -static void whpx_region_del(MemoryListener *listener, - MemoryRegionSection *section) -{ - whpx_process_section(section, 0); - memory_region_unref(section->mr); -} - -static void whpx_transaction_begin(MemoryListener *listener) -{ -} - -static void whpx_transaction_commit(MemoryListener *listener) -{ -} - -static void whpx_log_sync(MemoryListener *listener, - MemoryRegionSection *section) -{ - MemoryRegion *mr =3D section->mr; - - if (!memory_region_is_ram(mr)) { - return; - } - - memory_region_set_dirty(mr, 0, int128_get64(section->size)); -} - -static MemoryListener whpx_memory_listener =3D { - .name =3D "whpx", - .begin =3D whpx_transaction_begin, - .commit =3D whpx_transaction_commit, - .region_add =3D whpx_region_add, - .region_del =3D whpx_region_del, - .log_sync =3D whpx_log_sync, - .priority =3D MEMORY_LISTENER_PRIORITY_ACCEL, -}; - -static void whpx_memory_init(void) -{ - memory_listener_register(&whpx_memory_listener, &address_space_memory); -} - -/* - * Load the functions from the given library, using the given handle. If a - * handle is provided, it is used, otherwise the library is opened. The - * handle will be updated on return with the opened one. - */ -static bool load_whp_dispatch_fns(HMODULE *handle, - WHPFunctionList function_list) -{ - HMODULE hLib =3D *handle; - - #define WINHV_PLATFORM_DLL "WinHvPlatform.dll" - #define WINHV_EMULATION_DLL "WinHvEmulation.dll" - #define WHP_LOAD_FIELD_OPTIONAL(return_type, function_name, signature)= \ - whp_dispatch.function_name =3D \ - (function_name ## _t)GetProcAddress(hLib, #function_name); \ - - #define WHP_LOAD_FIELD(return_type, function_name, signature) \ - whp_dispatch.function_name =3D \ - (function_name ## _t)GetProcAddress(hLib, #function_name); \ - if (!whp_dispatch.function_name) { \ - error_report("Could not load function %s", #function_name); \ - goto error; \ - } \ - - #define WHP_LOAD_LIB(lib_name, handle_lib) \ - if (!handle_lib) { \ - handle_lib =3D LoadLibrary(lib_name); \ - if (!handle_lib) { \ - error_report("Could not load library %s.", lib_name); \ - goto error; \ - } \ - } \ - - switch (function_list) { - case WINHV_PLATFORM_FNS_DEFAULT: - WHP_LOAD_LIB(WINHV_PLATFORM_DLL, hLib) - LIST_WINHVPLATFORM_FUNCTIONS(WHP_LOAD_FIELD) - break; - - case WINHV_EMULATION_FNS_DEFAULT: - WHP_LOAD_LIB(WINHV_EMULATION_DLL, hLib) - LIST_WINHVEMULATION_FUNCTIONS(WHP_LOAD_FIELD) - break; - - case WINHV_PLATFORM_FNS_SUPPLEMENTAL: - WHP_LOAD_LIB(WINHV_PLATFORM_DLL, hLib) - LIST_WINHVPLATFORM_FUNCTIONS_SUPPLEMENTAL(WHP_LOAD_FIELD_OPTIONAL) - break; - } - - *handle =3D hLib; - return true; - -error: - if (hLib) { - FreeLibrary(hLib); - } - - return false; -} - -static void whpx_set_kernel_irqchip(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) -{ - struct whpx_state *whpx =3D &whpx_global; - OnOffSplit mode; - - if (!visit_type_OnOffSplit(v, name, &mode, errp)) { - return; - } - - switch (mode) { - case ON_OFF_SPLIT_ON: - whpx->kernel_irqchip_allowed =3D true; - whpx->kernel_irqchip_required =3D true; - break; - - case ON_OFF_SPLIT_OFF: - whpx->kernel_irqchip_allowed =3D false; - whpx->kernel_irqchip_required =3D false; - break; - - case ON_OFF_SPLIT_SPLIT: - error_setg(errp, "WHPX: split irqchip currently not supported"); - error_append_hint(errp, - "Try without kernel-irqchip or with kernel-irqchip=3Don|off"); - break; - - default: - /* - * The value was checked in visit_type_OnOffSplit() above. If - * we get here, then something is wrong in QEMU. - */ - abort(); - } -} - -static void whpx_cpu_instance_init(CPUState *cs) +void whpx_cpu_instance_init(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); =20 host_cpu_instance_init(cpu); } =20 -static void whpx_cpu_accel_class_init(ObjectClass *oc, const void *data) -{ - AccelCPUClass *acc =3D ACCEL_CPU_CLASS(oc); - - acc->cpu_instance_init =3D whpx_cpu_instance_init; -} - -static const TypeInfo whpx_cpu_accel_type =3D { - .name =3D ACCEL_CPU_NAME("whpx"), - - .parent =3D TYPE_ACCEL_CPU, - .class_init =3D whpx_cpu_accel_class_init, - .abstract =3D true, -}; - /* * Partition support */ =20 -static int whpx_accel_init(AccelState *as, MachineState *ms) +int whpx_accel_init(AccelState *as, MachineState *ms) { struct whpx_state *whpx; int ret; @@ -2715,77 +2258,3 @@ error: =20 return ret; } - -bool whpx_apic_in_platform(void) { - return whpx_global.apic_in_platform; -} - -static void whpx_accel_class_init(ObjectClass *oc, const void *data) -{ - AccelClass *ac =3D ACCEL_CLASS(oc); - ac->name =3D "WHPX"; - ac->init_machine =3D whpx_accel_init; - ac->pre_resume_vm =3D whpx_pre_resume_vm; - ac->allowed =3D &whpx_allowed; - - object_class_property_add(oc, "kernel-irqchip", "on|off|split", - NULL, whpx_set_kernel_irqchip, - NULL, NULL); - object_class_property_set_description(oc, "kernel-irqchip", - "Configure WHPX in-kernel irqchip"); -} - -static void whpx_accel_instance_init(Object *obj) -{ - struct whpx_state *whpx =3D &whpx_global; - - memset(whpx, 0, sizeof(struct whpx_state)); - /* Turn on kernel-irqchip, by default */ - whpx->kernel_irqchip_allowed =3D true; -} - -static const TypeInfo whpx_accel_type =3D { - .name =3D ACCEL_CLASS_NAME("whpx"), - .parent =3D TYPE_ACCEL, - .instance_init =3D whpx_accel_instance_init, - .class_init =3D whpx_accel_class_init, -}; - -static void whpx_type_init(void) -{ - type_register_static(&whpx_accel_type); - type_register_static(&whpx_cpu_accel_type); -} - -bool init_whp_dispatch(void) -{ - if (whp_dispatch_initialized) { - return true; - } - - if (!load_whp_dispatch_fns(&hWinHvPlatform, WINHV_PLATFORM_FNS_DEFAULT= )) { - goto error; - } - - if (!load_whp_dispatch_fns(&hWinHvEmulation, WINHV_EMULATION_FNS_DEFAU= LT)) { - goto error; - } - - assert(load_whp_dispatch_fns(&hWinHvPlatform, - WINHV_PLATFORM_FNS_SUPPLEMENTAL)); - whp_dispatch_initialized =3D true; - - return true; -error: - if (hWinHvPlatform) { - FreeLibrary(hWinHvPlatform); - } - - if (hWinHvEmulation) { - FreeLibrary(hWinHvEmulation); - } - - return false; -} - -type_init(whpx_type_init); --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759620; cv=none; d=zohomail.com; s=zohoarc; b=eGwH5ysLfjKxVgDjhlwUpPEmoxYI1iOawsHjsKJXRbW9Ydb5JD/lHrJ/jFyWfSuxJxSuhCuHhEq/YWdCvIff5jh+RZ/rtq4uHDhQLMGsVN+ZjL4TuN71MQhM0ELVu9Yf+NUPXFLzCHoJaVpu9B8ocx8mcCY4+TgK4MqeGMRw6fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759620; 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=1HDLl+vsTco3N+tEGqvISSZb2bm2NYHKpsf2pCMBzc0=; b=fwaHQevTg1/Gsg1bk5HeIVb7Qq7BTy9VJuReyINiGvmBA+z0ELWdhHfCIzOyVzSAOxJBqIRTKPP16YnaezeduBvxASjYXgcapfCIirzu5qbge/o2fb5mgc+ydSwGNuVu4/BH4JWAZvSG3uwUKHmkQdc7inySiTeRS2L1b+IAHSs= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759620757447.5152746867899; Wed, 29 Oct 2025 10:40:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5R-0003YF-RO; Wed, 29 Oct 2025 13:35: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 1vEA5N-0003Ut-6I for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:49 -0400 Received: from p-east2-cluster1-host11-snip4-10.eps.apple.com ([57.103.76.53] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5D-0003K0-4n for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:48 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id D465C1824483; Wed, 29 Oct 2025 17:35:22 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 8E4521859E66; Wed, 29 Oct 2025 16:55:30 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=1HDLl+vsTco3N+tEGqvISSZb2bm2NYHKpsf2pCMBzc0=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=BwAsqKOSbip07u5CS/m/UfySTMI1w5sgi/boEIqlxAgCJZnqMcPYAeRm9+Fk9szVsHvl3ewxEkzwICWPHysoxHvBwMz8oRywdytz088XdX+UiudcEtJhU/fWkpJUwRLZoR+p6RTX1mdJdzyH+2j/j15yPIKmI9AGtaI5ijFUYCWMTcCI80xWF54f1siNcHN14s9duu/DcthNwBAAMdLYFZlEf5Ih+F0+QgtEzRBUJaALSmhKDoabQmC7NQgMoDwD9fEfR8KsQXyazyydcOJ7lcljAicEbQtg//Yov1xYXpCyBL5Nk1QxTgpqZAoOswb4/wzIvOr2+soOPUN8X0upFA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 08/28] whpx: ifdef out winhvemulation on non-x86_64 Date: Wed, 29 Oct 2025 17:54:50 +0100 Message-ID: <20251029165510.45824-9-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: NEJjKMJ3uqR4tUUv3UdyP86MizXMCZB5 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX3fl1uFD1Ytjq bt98jpt2ftshxAr9lpguSvWhQPSSc0PRh7eXQWShczoc9QVDMH94Gbs50N377PkShWfR30in7Hd K9L4Acxj3Hz3m3iDJjlZei7BaNBWLzdsXm0TEou5GD1a9VS5Ba6UHu/lE0j5H3P7QHqaolhhq60 pfwJZFku0dS7VTU9DbwYawvLsQ5JZNRPZJLsn3NtBQLjv1UKLT3EuH/asOKGcztLC41Io3VzfXN txTgKCLjtZaDiXRLiZvTuTNMo797rnK52ymFrf6GjXhp22COdFU5e6Ky/Vz5zSm7Ja//W8Ffs= X-Proofpoint-ORIG-GUID: NEJjKMJ3uqR4tUUv3UdyP86MizXMCZB5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=633 mlxscore=0 malwarescore=0 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 clxscore=1030 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAAByo7/N4vbmLcRbOgnRTmmKl9nApjKURLXZm1hkyggvasJuajH3PpfPkuio45T9OUo3gbWMEQb0FGNYhoWvPzkOLdqLfyjuZoyWtF/rm0mUqGFOsGtdIg3Ix/JEYRqc6yv+OSgKfa3mTwD6fEp6TTa7OY+8wmYRd0alx01yIs4S7Ch24wdq4JIZYMCZCIE7RUpsw4LzxPCU+070oYwiVPS3/JF0a5FRsti0eSjPWTHxkUDFu9NZipcnxjwemT/idtmPPluLXW0r/4a9IK4CSu78bB16C3YM6RRbDFMZ4m0ngu4h0Fziy7WVSZBNiIOX7CsLhV7oJ+L/DCOgL7WUScmglRM43r6lFMEhB/5XFrbcDxxyI+6tBUDNnfVUBQPbs75AcmqqDJ73AxO0TgxNIMxW6+Z1dCWvMKqR9itkS/qcVRd2XgEJ82Lfqs4NIzYBzG4nuyqNWmANCEmys4EhuTi4SeQ24shTI+XNZBMZOXu41+2y0oyua+0c3L1RFOiNBpiDwX2hd1kHRiTMQvzeAvndKJ8NHIfJy/bcEtYCnswoCeyKDSw3d9nSRR7z09vllyGDDhec/99vyuWGKFMXT5gsEn2FedmCM5aB4sWWmlFyEmNGGq0Q7YKU887wA7Qd5SEwVGjuqYqUczbAKObD/cViQn1RNVVCpJzRXJeB6SDwG8w3FcKw8feMRcuO5/sj7Ov0V8+Z4Prb1tY0qe2/DaymCHRpB7K1eBD2zRgWzo3OS8iwKMnNX4eYDT4LefbxoVESPDEP5MSHR5+SPlKPsHN 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=57.103.76.53; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1761759622340158500 Content-Type: text/plain; charset="utf-8" winhvemulation is x86_64 only. In the future, we might want to get rid of winhvemulation usage entirely. Signed-off-by: Mohamed Mediouni Reviewed-by: Pierrick Bouvier --- accel/whpx/whpx-common.c | 14 ++++++++++++-- include/system/whpx-common.h | 2 ++ include/system/whpx-internal.h | 7 ++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c index 66c9238586..95664a1df7 100644 --- a/accel/whpx/whpx-common.c +++ b/accel/whpx/whpx-common.c @@ -41,7 +41,9 @@ bool whpx_allowed; static bool whp_dispatch_initialized; static HMODULE hWinHvPlatform; +#ifdef __x86_64__ static HMODULE hWinHvEmulation; +#endif =20 struct whpx_state whpx_global; struct WHPDispatch whp_dispatch; @@ -236,8 +238,10 @@ void whpx_destroy_vcpu(CPUState *cpu) struct whpx_state *whpx =3D &whpx_global; =20 whp_dispatch.WHvDeleteVirtualProcessor(whpx->partition, cpu->cpu_index= ); +#ifdef __x86_64__ AccelCPUState *vcpu =3D cpu->accel; whp_dispatch.WHvEmulatorDestroyEmulator(vcpu->emulator); +#endif g_free(cpu->accel); } =20 @@ -412,8 +416,12 @@ static bool load_whp_dispatch_fns(HMODULE *handle, LIST_WINHVPLATFORM_FUNCTIONS(WHP_LOAD_FIELD) break; case WINHV_EMULATION_FNS_DEFAULT: +#ifdef __x86_64__ WHP_LOAD_LIB(WINHV_EMULATION_DLL, hLib) LIST_WINHVEMULATION_FUNCTIONS(WHP_LOAD_FIELD) +#else + g_assert_not_reached(); +#endif break; case WINHV_PLATFORM_FNS_SUPPLEMENTAL: WHP_LOAD_LIB(WINHV_PLATFORM_DLL, hLib) @@ -539,11 +547,11 @@ bool init_whp_dispatch(void) if (!load_whp_dispatch_fns(&hWinHvPlatform, WINHV_PLATFORM_FNS_DEFAULT= )) { goto error; } - +#ifdef __x86_64__ if (!load_whp_dispatch_fns(&hWinHvEmulation, WINHV_EMULATION_FNS_DEFAU= LT)) { goto error; } - +#endif assert(load_whp_dispatch_fns(&hWinHvPlatform, WINHV_PLATFORM_FNS_SUPPLEMENTAL)); whp_dispatch_initialized =3D true; @@ -553,9 +561,11 @@ error: if (hWinHvPlatform) { FreeLibrary(hWinHvPlatform); } +#ifdef __x86_64__ if (hWinHvEmulation) { FreeLibrary(hWinHvEmulation); } +#endif return false; } =20 diff --git a/include/system/whpx-common.h b/include/system/whpx-common.h index e549c7539c..7a7c607e0a 100644 --- a/include/system/whpx-common.h +++ b/include/system/whpx-common.h @@ -3,7 +3,9 @@ #define SYSTEM_WHPX_COMMON_H =20 struct AccelCPUState { +#ifdef __x86_64__ WHV_EMULATOR_HANDLE emulator; +#endif bool window_registered; bool interruptable; bool ready_for_pic_interrupt; diff --git a/include/system/whpx-internal.h b/include/system/whpx-internal.h index c59f9de091..4565436682 100644 --- a/include/system/whpx-internal.h +++ b/include/system/whpx-internal.h @@ -4,8 +4,9 @@ =20 #include #include +#ifdef __x86_64__ #include - +#endif #include "hw/i386/apic.h" =20 typedef enum WhpxBreakpointState { @@ -100,12 +101,16 @@ void whpx_apic_get(APICCommonState *s); =20 /* Define function typedef */ LIST_WINHVPLATFORM_FUNCTIONS(WHP_DEFINE_TYPE) +#ifdef __x86_64__ LIST_WINHVEMULATION_FUNCTIONS(WHP_DEFINE_TYPE) +#endif LIST_WINHVPLATFORM_FUNCTIONS_SUPPLEMENTAL(WHP_DEFINE_TYPE) =20 struct WHPDispatch { LIST_WINHVPLATFORM_FUNCTIONS(WHP_DECLARE_MEMBER) +#ifdef __x86_64__ LIST_WINHVEMULATION_FUNCTIONS(WHP_DECLARE_MEMBER) +#endif LIST_WINHVPLATFORM_FUNCTIONS_SUPPLEMENTAL(WHP_DECLARE_MEMBER) }; =20 --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759675; cv=none; d=zohomail.com; s=zohoarc; b=JOi0x/HFzkJVSDrV7Kq/ste2aKJ86td+L6QlRQx64dbuzazRdk1Al2dvZJURhGWWU92rq8bnOQ6Mb52aLvhFdA9Wp1xPs88Cw2qw4+3+TlC6m3o2MhZkV2JTiE4q2Ip+7O1kSC1YoIiGgJ2NG/CJvNlypxEut029ViAviHSmlt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759675; 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=zNv66cYWOjcoM4iD8mPZ0d3N5D4+2q07Wwy2NtrQNPs=; b=bX1lxos5DsuMPxeErjOi9Hsl6RS/HHcUs8eL3NZhq+8N9+PUo0kieq0u5SK6JKkPfz+4sumxUe/6RfaLmSjVtQImn9uM3+Ytr/+nUEpl3OYa+3t7l4pYz/NfHbYXhGiGeeurA+rcEXENS2LC0pgtHxQ+UdSYdEBOYAKVywAh/vw= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759675661794.3369415172835; Wed, 29 Oct 2025 10:41:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5X-0003bN-G7; Wed, 29 Oct 2025 13:35: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 1vEA5U-0003Z1-9l for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:56 -0400 Received: from p-east2-cluster1-host1-snip4-7.eps.apple.com ([57.103.76.30] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5E-0003KO-Ro for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:55 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 1E1A11800339; Wed, 29 Oct 2025 17:35:24 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 44496184693B; Wed, 29 Oct 2025 16:55:32 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=zNv66cYWOjcoM4iD8mPZ0d3N5D4+2q07Wwy2NtrQNPs=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=Sd627H1z6/EVY8ZIzWRmzrX2z6DKO848m3l8jvYquTghaXKRipBA0M790pnQfQxqETKQ1tn09awwkfRxp5lSDAAzrhN1CMpcDKV8Zld9SgXcODiFfmzeAR8zwiNf8xaFD/igdfPI3OqawlOYcb8seU12cqvhjL8bmc8W8fIF4NRAHddjG/PIcByPaQ3bcPo9HnhrBU69Mqw6X3ysLBHVLnsssf+NS70fbNnBX5fCBpfcYeo9acTgXPGjkpZbvqzeRS06VrB+/CuZjR73FVNrwgZUIzr3a4aM9VccFopNad/u3k6TEAuCMLDJtkiaPGfYN0qh67FZTIJaNvNew8KYKQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 09/28] whpx: common: add WHPX_INTERCEPT_DEBUG_TRAPS define Date: Wed, 29 Oct 2025 17:54:51 +0100 Message-ID: <20251029165510.45824-10-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX0AKDS7xy1BSL nwMzUk3HCkhA4GR6wIfZxVD/zqG9pJjZgHMSohYIKL2e2ZiLteLogwvL/wwuUsZJYrVxa3yCnZb EVH7VpNaPtgEQMfkh3/QVcdjixYuAE7H8NiSuVaJmQ0rs42MeIRXn95xLru2FYJzyUB/UtTkm/X eqx1wMybdQXbz5p3suSM4ENXbsUWVNEfkNwJz5yMoJAjRwZtOavjTQO2uqSjjjTLOHP8sQ8Fglq irP2ElC1B1SQYpU8vF/yybiIwmafSEAVK616TtkyIziNuswF4uXO/VeYIWTswsPvKSx+Uek68= X-Proofpoint-ORIG-GUID: SFysRDlZm7-icfbEARPK_IHz7sLy92qL X-Proofpoint-GUID: SFysRDlZm7-icfbEARPK_IHz7sLy92qL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 clxscore=1030 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 mlxlogscore=853 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAAB+jQ8o1t2AZTAebtGvkUN5Y5zRkdXn+9Kfe3swu+d39kKbEs/Vl0gI8ZUU70qJSa6zrWG/KEMiJPZ0ahK8YVMo8FuUeGHmdQHsK5QHMZjSbfnhv/Jm6pyZ4qNV9vcQRNdVFBLa68a98Zajy4KbFg8rsoTVnKdvcvWRYvBCZxRcuL3zzRY4t5vVK0NL9wbdy6aGxgAjK7eJhs1wnr28xChDez4cfeaB78kV93wjmppB+CrPKn7b8lEHvJPIBnp+MllWtZRHIcHGgixgnH0YM6pA90YSxBnApZ47rJkZdWrYRX+lx5UAqRZeAsfRSt3bfiqux4zmqLtLBJmi/936LyydQFgjFy9QEatwEh/5xqQkS9l9pPF177SW+mOepQqZuO+5Nvl5nL70oB+I5RHMvTArMJMnWe1zLBtp87+ISoq2FnnqvJ+UMhuUt5r1ZbFepF0HF53F+g0eoJDS9ykOZFZHtXEje2O4fa8m8p4zBvll5+BxAfMD8HJ9/gcD00cpH5RmiH4ClIhOouKyyF+Vved9nyGRUbCqWdfIrOxYYkx4MB+fxFaVol8lAXhw9WuleNcdrEaEsSoYTf3KjrNUjzhIpu2Wp5Rr+jLD7rmgB6JcaMJ4szP2SEtgwo+ZO66Ki+FHvlXSOSnPJhYmuF3O+S5SKOQcSvrupHY/MNTCeyS5yKBw0/wxCqtIa3LDO+grWffGKq+vD3Ui7kLqi7C4Kx+6Hk8Wt90v3JVsz1YotwE0EdZNq5kR2gwVTkgwpcurhsYBFetFqYm145OJf3KVyZOxOQiabNofBdE2UbfMS+R 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=57.103.76.30; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.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_MSPIKE_H2=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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759678066154101 Content-Type: text/plain; charset="utf-8" As of why: WHPX on arm64 doesn't have debug trap support as of today. Keep the exception bitmap interface for now - despite that being entirely u= navailable on arm64 too. Signed-off-by: Mohamed Mediouni Reviewed-by: Pierrick Bouvier --- accel/whpx/whpx-common.c | 2 +- include/system/whpx-common.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c index 95664a1df7..c0ff6cacb8 100644 --- a/accel/whpx/whpx-common.c +++ b/accel/whpx/whpx-common.c @@ -123,7 +123,7 @@ int whpx_first_vcpu_starting(CPUState *cpu) * have one or more breakpoints enabled. Both require intercepting * the WHvX64ExceptionTypeBreakpointTrap exception. */ - exception_mask =3D 1UL << WHvX64ExceptionTypeDebugTrapOrFault; + exception_mask =3D 1UL << WHPX_INTERCEPT_DEBUG_TRAPS; } else { /* Let the guest handle all exceptions. */ exception_mask =3D 0; diff --git a/include/system/whpx-common.h b/include/system/whpx-common.h index 7a7c607e0a..73b9f7c119 100644 --- a/include/system/whpx-common.h +++ b/include/system/whpx-common.h @@ -20,4 +20,7 @@ int whpx_first_vcpu_starting(CPUState *cpu); int whpx_last_vcpu_stopping(CPUState *cpu); void whpx_memory_init(void); struct whpx_breakpoint *whpx_lookup_breakpoint_by_addr(uint64_t address); + +/* On x64: same as WHvX64ExceptionTypeDebugTrapOrFault */ +#define WHPX_INTERCEPT_DEBUG_TRAPS 1 #endif --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759600; cv=none; d=zohomail.com; s=zohoarc; b=P+3glXLNMRITW7cLLKaHE4T6BjofvIuP2ugFa7Ug9jI20Ceas8PL7Ba+W21AP8PblwaQ1eu4AzVQd6IjDFYE1UF8wi8itEKpdeF8Ym0xYkb8YUdTriyz+lPMtbCYn/OIgTgkYH0186+j7ASHFc7kdK8oNKxQt1d3xNe7LSps9Z8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759600; 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=7XXwlHQPk/SKyuEJ63acz+SZiCgkqqjnl8cfroXHjPg=; b=PCDgxEVtXvCdAoAU0sQ+vR+cZgXINnoXmQYff2uxTPtehSxLe5MIfaUIZOyZTfcWjrou4noYwssiMx5735EtktGU+0PwgquOYAK88ADX651XXh2e1gXsGaEMMpZaXiDqqvOluaU/0ESLYZKgLFHTaiTmUcRtuOY3yCtPQ4McUM4= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759600879837.041252486395; Wed, 29 Oct 2025 10:40:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5V-0003a9-Di; Wed, 29 Oct 2025 13:35: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 1vEA5Q-0003X3-5L for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:52 -0400 Received: from p-east2-cluster1-host4-snip4-7.eps.apple.com ([57.103.76.20] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5D-0003KN-JO for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:51 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 91F111824481; Wed, 29 Oct 2025 17:35:24 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id DEC86185B011; Wed, 29 Oct 2025 16:55:33 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=7XXwlHQPk/SKyuEJ63acz+SZiCgkqqjnl8cfroXHjPg=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=JKJck4u2Sz3djwtc+HDA8mU9+X4svex+u/RdWLyKvJm6qsxqETxOw6hLDax+ybxeYuISLX7sWVkZGU4HDPfRFgndXooQQYCDhYz/3lGa5FJRjR8vYptDaZ05xfJRx7sWZumZ3PttQM/3PrM2CkkuQQ1kMqWQctA37/7iHzWhWsB08xLibiNsUk9v8YLuZQyKKfDxYUluA+vRi8F3XRZEuWzdd3ajKg+PELloLEj1g9cCG13OmkHcG/ILLdKpwHf9Aut8s4FX3+JVJxjFkMV2IgYf35WR5uABGSx8C45T0rYioigf5Na6bOR5ix/4GC1VCtbYzmB1hAJV9FfJQ800cQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 10/28] hw, target, accel: whpx: change apic_in_platform to kernel_irqchip Date: Wed, 29 Oct 2025 17:54:52 +0100 Message-ID: <20251029165510.45824-11-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: N3qpuN_2zxUP4gbvPd-3fij3TdJmOd3X X-Proofpoint-ORIG-GUID: N3qpuN_2zxUP4gbvPd-3fij3TdJmOd3X X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX1jKzzcqT4zRJ 28RcUAvz9bYdOuJAEF+/FRROoRcy3nB1pqO4WaHXQ3C3/nZAgYnGv9iNSTStBF0moLw3dIVxuga 7TREmzee5WeC4VCnrPPuluU2CYC/SEAvd/le+nDqB3U4RdxDGaLkTsbp/3GDgs65XYTsnH1i+YL U0ssqlxeJ9IIsizQozqo5kasv2w1+qjEbl5LKeUiygoj4mMPgg6Sq5RIw/YJeoCBygReNwebXSM xTFFD1G78LvhGFBlcWgN0Zdg6SJnbo0gBf7NODpPvLst7ZYlIpFV/HV7UuxM4cNnDeSIpZ2+M= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=833 malwarescore=0 suspectscore=0 adultscore=0 clxscore=1030 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABJMn7clLHS3bVCE3GP/7PfgGpkTh3WCR4SxJKxW9uEeKnOw2ZKLEDxJIVKsYx+iWgnSrhjRKVi+PvdqU7JP5pCA9GFy+SZVAePKl7oaKmX18MEWnbqOGJWUIcf6/GgBb1bDBeSqH8ZvcZlZyvNrFxw5bQW+GD+zd60SCrzqo9hcA8LgsGN5quGwBwGJLr7JlLht0T5s30bEiMkWjjK1ioKMcnnvZOkkkSwexHl+bDJUJjbBB6mLAbgeh/DxjDH0aFSjjdBU1X4XOeX9OiRiYf2Z2+b6fra1WlqXnzyicamerO05h/sjPDKLojuLFE94hI/9bmcfXT91leumbnwXKtV/ismY3M846m806jqEhHYnWQTUZs34qV01gGCKp/W6GtmUua8EULYSWH7apRrK9eGEtAyj36x6a55cm2VFPasMDBEp7jvCxEiV10JyUZBL7FcAMmrIKv5+Uu1xnsPXcmNF0voI9YBBc1Qn0HCgZqE/wJSnlHE4Wr4WJNhRBmk/4zZSDsDW+j07hBT4v7F47U9wwm0lK2tOLbFciXQxBjOYdZcTBVimkBMsUyTFw4DCbZdeSMrrNf2g5NwPuC5tQHgCcjh+OHsZ5fJu0GbAd/ikVChsmLcTiy1G+xNJYm7KwX9Cf6zyOBFVfGu3n8Y5YwLeeWV/93EosgwVerNR6Zz4Y2MsSFS89Pd1+RJTCufBvxSuIXbBxwjZY2n4XDynBXkYPLrXYXVoN0afUBwEJUf7wWuLtzZxKnbJ7vGTwhU8jWhfgbdUvhsfHfZZWkMLnkY1S4RV0e3V772Q== 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=57.103.76.20; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.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_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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759603064154100 Content-Type: text/plain; charset="utf-8" Change terminology to match the KVM one, as APIC is x86-specific. Signed-off-by: Mohamed Mediouni Reviewed-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- accel/whpx/whpx-accel-ops.c | 2 +- accel/whpx/whpx-common.c | 4 ++-- hw/i386/x86-cpu.c | 4 ++-- include/system/whpx-internal.h | 2 +- include/system/whpx.h | 4 ++-- target/i386/cpu-apic.c | 2 +- target/i386/whpx/whpx-all.c | 14 +++++++------- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/accel/whpx/whpx-accel-ops.c b/accel/whpx/whpx-accel-ops.c index c84a25c273..50fadea0fd 100644 --- a/accel/whpx/whpx-accel-ops.c +++ b/accel/whpx/whpx-accel-ops.c @@ -78,7 +78,7 @@ static void whpx_kick_vcpu_thread(CPUState *cpu) =20 static bool whpx_vcpu_thread_is_idle(CPUState *cpu) { - return !whpx_apic_in_platform(); + return !whpx_irqchip_in_kernel(); } =20 static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data) diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c index c0ff6cacb8..18d93225c1 100644 --- a/accel/whpx/whpx-common.c +++ b/accel/whpx/whpx-common.c @@ -496,9 +496,9 @@ static const TypeInfo whpx_cpu_accel_type =3D { * Partition support */ =20 -bool whpx_apic_in_platform(void) +bool whpx_irqchip_in_kernel(void) { - return whpx_global.apic_in_platform; + return whpx_global.kernel_irqchip; } =20 static void whpx_accel_class_init(ObjectClass *oc, const void *data) diff --git a/hw/i386/x86-cpu.c b/hw/i386/x86-cpu.c index 1a86a853d5..aee7fc76f5 100644 --- a/hw/i386/x86-cpu.c +++ b/hw/i386/x86-cpu.c @@ -45,7 +45,7 @@ static void pic_irq_request(void *opaque, int irq, int le= vel) =20 trace_x86_pic_interrupt(irq, level); if (cpu_is_apic_enabled(cpu->apic_state) && !kvm_irqchip_in_kernel() && - !whpx_apic_in_platform()) { + !whpx_irqchip_in_kernel()) { CPU_FOREACH(cs) { cpu =3D X86_CPU(cs); if (apic_accept_pic_intr(cpu->apic_state)) { @@ -71,7 +71,7 @@ int cpu_get_pic_interrupt(CPUX86State *env) X86CPU *cpu =3D env_archcpu(env); int intno; =20 - if (!kvm_irqchip_in_kernel() && !whpx_apic_in_platform()) { + if (!kvm_irqchip_in_kernel() && !whpx_irqchip_in_kernel()) { intno =3D apic_get_interrupt(cpu->apic_state); if (intno >=3D 0) { return intno; diff --git a/include/system/whpx-internal.h b/include/system/whpx-internal.h index 4565436682..81c0c1819f 100644 --- a/include/system/whpx-internal.h +++ b/include/system/whpx-internal.h @@ -44,7 +44,7 @@ struct whpx_state { =20 bool kernel_irqchip_allowed; bool kernel_irqchip_required; - bool apic_in_platform; + bool kernel_irqchip; }; =20 extern struct whpx_state whpx_global; diff --git a/include/system/whpx.h b/include/system/whpx.h index 00f6a3e523..98fe045ba1 100644 --- a/include/system/whpx.h +++ b/include/system/whpx.h @@ -26,10 +26,10 @@ #ifdef CONFIG_WHPX_IS_POSSIBLE extern bool whpx_allowed; #define whpx_enabled() (whpx_allowed) -bool whpx_apic_in_platform(void); +bool whpx_irqchip_in_kernel(void); #else /* !CONFIG_WHPX_IS_POSSIBLE */ #define whpx_enabled() 0 -#define whpx_apic_in_platform() (0) +#define whpx_irqchip_in_kernel() (0) #endif /* !CONFIG_WHPX_IS_POSSIBLE */ =20 #endif /* QEMU_WHPX_H */ diff --git a/target/i386/cpu-apic.c b/target/i386/cpu-apic.c index 564c1288e4..c0492035b8 100644 --- a/target/i386/cpu-apic.c +++ b/target/i386/cpu-apic.c @@ -32,7 +32,7 @@ APICCommonClass *apic_get_class(Error **errp) apic_type =3D "kvm-apic"; } else if (xen_enabled()) { apic_type =3D "xen-apic"; - } else if (whpx_apic_in_platform()) { + } else if (whpx_irqchip_in_kernel()) { apic_type =3D "whpx-apic"; } =20 diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index c63bb28b20..d778e358f6 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -607,7 +607,7 @@ void whpx_get_registers(CPUState *cpu) hr); } =20 - if (whpx_apic_in_platform()) { + if (whpx_irqchip_in_kernel()) { /* * Fetch the TPR value from the emulated APIC. It may get overwrit= ten * below with the value from CR8 returned by @@ -749,7 +749,7 @@ void whpx_get_registers(CPUState *cpu) =20 assert(idx =3D=3D RTL_NUMBER_OF(whpx_register_names)); =20 - if (whpx_apic_in_platform()) { + if (whpx_irqchip_in_kernel()) { whpx_apic_get(x86_cpu->apic_state); } =20 @@ -1379,7 +1379,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu) } =20 /* Get pending hard interruption or replay one that was overwritten */ - if (!whpx_apic_in_platform()) { + if (!whpx_irqchip_in_kernel()) { if (!vcpu->interruption_pending && vcpu->interruptable && (env->eflags & IF_MASK)) { assert(!new_int.InterruptionPending); @@ -1553,7 +1553,7 @@ int whpx_vcpu_run(CPUState *cpu) =20 if (exclusive_step_mode =3D=3D WHPX_STEP_NONE) { whpx_vcpu_process_async_events(cpu); - if (cpu->halted && !whpx_apic_in_platform()) { + if (cpu->halted && !whpx_irqchip_in_kernel()) { cpu->exception_index =3D EXCP_HLT; qatomic_set(&cpu->exit_request, false); return 0; @@ -1642,7 +1642,7 @@ int whpx_vcpu_run(CPUState *cpu) break; =20 case WHvRunVpExitReasonX64ApicEoi: - assert(whpx_apic_in_platform()); + assert(whpx_irqchip_in_kernel()); ioapic_eoi_broadcast(vcpu->exit_ctx.ApicEoi.InterruptVector); break; =20 @@ -2187,7 +2187,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) goto error; } } else { - whpx->apic_in_platform =3D true; + whpx->kernel_irqchip =3D true; } } =20 @@ -2196,7 +2196,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) prop.ExtendedVmExits.X64MsrExit =3D 1; prop.ExtendedVmExits.X64CpuidExit =3D 1; prop.ExtendedVmExits.ExceptionExit =3D 1; - if (whpx_apic_in_platform()) { + if (whpx_irqchip_in_kernel()) { prop.ExtendedVmExits.X64ApicInitSipiExitTrap =3D 1; } =20 --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759551; cv=none; d=zohomail.com; s=zohoarc; b=XWmaU1jPHyQxz/rjpifwAr5eX/XSYeV7xFkyZmHEkKEvWPB/kkor3OeWRlKpXqIf/6fJO2r/NfA0+L2QVLUTIiVJpJU3P+9KaJKuQhF9mJYJI31EZNH9qt4Pv94UBSlapaTNcYvkIY2E3DvuefJCHvDbwvnHpnw2hNVbaCzh/Dg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759551; 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=x0AeXVBnKwJPdtruMIBq71ElqhCOTD6zQN1Y4p0awp4=; b=JudiHu+M11TaFiBfaTslbOGvzMTGjUJIMEh5okUNX9Zhs+fE+t+cqjdoRD2t+flO+EHUpjZxD6LJd9pz7Z5yIarUYshwx1JaaANR5IgmKJDPKvfA91dqXOaTj9PpqByulw3/dT1b3mFbPNXex/kjyTyLyP9ll0gjKbOsZ88Q68I= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176175955118743.22176197393935; Wed, 29 Oct 2025 10:39:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5e-0003eb-Nq; Wed, 29 Oct 2025 13:36:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5Z-0003c1-Ey for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:01 -0400 Received: from p-east2-cluster1-host1-snip4-10.eps.apple.com ([57.103.76.33] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5G-0003MK-Tk for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:00 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 1566E1808538; Wed, 29 Oct 2025 17:35:25 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 977E7185FF48; Wed, 29 Oct 2025 16:55:35 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=x0AeXVBnKwJPdtruMIBq71ElqhCOTD6zQN1Y4p0awp4=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=AzqYm0oVk4S8AKcb/lGGzEtEtlDSFIe5PX/+OKC6weHdv433inEyIoapJjY3M6UBPgSnUFsmECyzDOfWiGAePf0+qNDjYY1nBBQGYsaD6R7WEnrPIuu1MMkjF+Q77NQWThEZabs7QGkv1Fd+DEyBkjEVLFD8IhQUJhroNn2ef0TFlsZOnKGIsa6HPQ8kbQFDVcqN0Px2dFVH6G67pXcTQwpOP4W5xykwtfsxhiYhHZcK6j/5bSAL4WWhBCXyO0WcKwF9aBTXpwIFWrAtqzx7Rz31ZZWVs1fOrJcGmUOfen+IiVkt7+F/pOlmyiPGeBcWjP51Y//JSwgK2rPgM0ZcOg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 11/28] whpx: interrupt controller support Date: Wed, 29 Oct 2025 17:54:53 +0100 Message-ID: <20251029165510.45824-12-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: EJIJVN9l9eQgkCHr-bjkGg1yL6t_eO8q X-Proofpoint-ORIG-GUID: EJIJVN9l9eQgkCHr-bjkGg1yL6t_eO8q X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX5yY2tRjRAJKq KBwrODrKiG6gajCIWlRGZBXiPa8MCBrWJ1O7lPjz7vOqXYYoWV9yRVFCzQphCRNI9WcNWTuBmxO 3RhcM3AYYqrUrDBbt8cNQXgxG16DhlX7Sf6rZe7ulec7x7n4FmtReMTkFd3r9F8vGR3r+8QDcck LMg7nsFxwAt2vHT1CWmceAK5W1B7isEmlGFwOwXwXOholMLP8GECiT7kTNtHtVVzjqn/ceNcY/Q eMaielKl0r0VEUwf5sxFtobYwiMy6PxRVUv0fiHXQ7Z4M9qRRDhi8new45E4Ntt3W2z20joa4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 adultscore=0 clxscore=1030 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABGeWSXNzdwzTOl+RuWOlURF96CXQGL+eWNObtGIg83dhL+En+pWQiZlC3YRgqbSnVtVjFwx7Y/NPRGXEVmbfOvbEYahIPesqj7/de2XedYwFSdIvOGZAJkAhXRa+aemQOq8NraqmvhOb/Kmz9HW4WBrn+u04oYsgRkcFno0BJqiWVB3pZLo3247/CpHsdaB7I3j9iVVWmuitx9Uw+z/cbjwJJF4XaW+x8NqrGwbNUN8gJYInxm9v3czjgr7RLrtosb01sPeYPsq5k37HQKC87a9UXV4ECTZtDCdLS7eFGJSsNnnlfpd1XTKmbEH79v6/Kq2C7CjyM5XARKhejc93VNT8w+8hKP+F+QrvKnof2YzCuZvF+/jxLhVu5Ll6qC2RLqK6aryZgDcRRud96vvFbtD2k0fkFt/2lV1UBssPDjjPvgczG5XawFIlm6TKhZWE6T+p/+DIsTDNUiBr/Py6qO6yJE/gYMKMMur6jrOrU214ULBEKR6PD83hpUdSqhU6Yi9YyhDT7ziKpYwS9pCgXaN3pbeaASZ1joyMUEiZwkdZRlPLkjHyk/nqieaog9BftufEls/DoHtRmdDDiTpSSb1DOl72agS15IKLAD60dzv4Ar9LB4j89oNEM0zTCWQAWCuOgkjdTBtf6OuXMXv+HRTkqSIs48B1oMt3AAQUv+jtjauWqPze6qKWV2fbyHE61Pije5m9Vm2kYPZCa5WrCWPyCY3MgLjtllKuo/YPSyuQz8V0WbTzl/mmtJ7pTMDhbKBYK26ssxFpldIaH 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=57.103.76.33; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759552431154100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni Reviewed-by: Pierrick Bouvier --- hw/arm/virt.c | 3 + hw/intc/arm_gicv3_common.c | 3 + hw/intc/arm_gicv3_whpx.c | 239 +++++++++++++++++++++++++++++ hw/intc/meson.build | 1 + include/hw/intc/arm_gicv3_common.h | 3 + 5 files changed, 249 insertions(+) create mode 100644 hw/intc/arm_gicv3_whpx.c diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 61d7bab803..9121eb37eb 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -47,6 +47,7 @@ #include "system/tcg.h" #include "system/kvm.h" #include "system/hvf.h" +#include "system/whpx.h" #include "system/qtest.h" #include "system/system.h" #include "hw/loader.h" @@ -2105,6 +2106,8 @@ static void finalize_gic_version(VirtMachineState *vm= s) /* KVM w/o kernel irqchip can only deal with GICv2 */ gics_supported |=3D VIRT_GIC_VERSION_2_MASK; accel_name =3D "KVM with kernel-irqchip=3Doff"; + } else if (whpx_enabled()) { + gics_supported |=3D VIRT_GIC_VERSION_3_MASK; } else if (tcg_enabled() || hvf_enabled() || qtest_enabled()) { gics_supported |=3D VIRT_GIC_VERSION_2_MASK; if (module_object_class_by_name("arm-gicv3")) { diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c index 2d0df6da86..1fd1e329e8 100644 --- a/hw/intc/arm_gicv3_common.c +++ b/hw/intc/arm_gicv3_common.c @@ -32,6 +32,7 @@ #include "gicv3_internal.h" #include "hw/arm/linux-boot-if.h" #include "system/kvm.h" +#include "system/whpx.h" =20 =20 static void gicv3_gicd_no_migration_shift_bug_post_load(GICv3State *cs) @@ -663,6 +664,8 @@ const char *gicv3_class_name(void) { if (kvm_irqchip_in_kernel()) { return "kvm-arm-gicv3"; + } else if (whpx_enabled()) { + return TYPE_WHPX_GICV3; } else { if (kvm_enabled()) { error_report("Userspace GICv3 is not supported with KVM"); diff --git a/hw/intc/arm_gicv3_whpx.c b/hw/intc/arm_gicv3_whpx.c new file mode 100644 index 0000000000..88a05e5901 --- /dev/null +++ b/hw/intc/arm_gicv3_whpx.c @@ -0,0 +1,239 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * ARM Generic Interrupt Controller using HVF platform support + * + * Copyright (c) 2025 Mohamed Mediouni + * Based on vGICv3 KVM code by Pavel Fedin + * + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/intc/arm_gicv3_common.h" +#include "qemu/error-report.h" +#include "qemu/module.h" +#include "system/runstate.h" +#include "system/whpx.h" +#include "system/whpx-internal.h" +#include "gicv3_internal.h" +#include "vgic_common.h" +#include "qom/object.h" +#include "target/arm/cpregs.h" + +#include "hw/arm/bsa.h" +#include +#include +#include + +struct WHPXARMGICv3Class { + ARMGICv3CommonClass parent_class; + DeviceRealize parent_realize; + ResettablePhases parent_phases; +}; + +typedef struct WHPXARMGICv3Class WHPXARMGICv3Class; + +/* This is reusing the GICv3State typedef from ARM_GICV3_ITS_COMMON */ +DECLARE_OBJ_CHECKERS(GICv3State, WHPXARMGICv3Class, + WHPX_GICV3, TYPE_WHPX_GICV3); + +/* TODO: Implement GIC state save-restore */ +static void whpx_gicv3_check(GICv3State *s) +{ +} + +static void whpx_gicv3_put(GICv3State *s) +{ + whpx_gicv3_check(s); +} + +static void whpx_gicv3_get(GICv3State *s) +{ +} + +static void whpx_gicv3_set_irq(void *opaque, int irq, int level) +{ + struct whpx_state *whpx =3D &whpx_global; + + GICv3State *s =3D (GICv3State *)opaque; + if (irq > s->num_irq) { + return; + } + WHV_INTERRUPT_TYPE interrupt_type =3D WHvArm64InterruptTypeFixed; + WHV_INTERRUPT_CONTROL interrupt_control =3D { + interrupt_type =3D WHvArm64InterruptTypeFixed, + .RequestedVector =3D GIC_INTERNAL + irq, .InterruptControl.Asserted = =3D level}; + + whp_dispatch.WHvRequestInterrupt(whpx->partition, &interrupt_control, + sizeof(interrupt_control)); +} + +static void whpx_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) +{ + GICv3State *s; + GICv3CPUState *c; + + c =3D (GICv3CPUState *)env->gicv3state; + s =3D c->gic; + + c->icc_pmr_el1 =3D 0; + /* + * Architecturally the reset value of the ICC_BPR registers + * is UNKNOWN. We set them all to 0 here; when the kernel + * uses these values to program the ICH_VMCR_EL2 fields that + * determine the guest-visible ICC_BPR register values, the + * hardware's "writing a value less than the minimum sets + * the field to the minimum value" behaviour will result in + * them effectively resetting to the correct minimum value + * for the host GIC. + */ + c->icc_bpr[GICV3_G0] =3D 0; + c->icc_bpr[GICV3_G1] =3D 0; + c->icc_bpr[GICV3_G1NS] =3D 0; + + c->icc_sre_el1 =3D 0x7; + memset(c->icc_apr, 0, sizeof(c->icc_apr)); + memset(c->icc_igrpen, 0, sizeof(c->icc_igrpen)); + + if (s->migration_blocker) { + return; + } + + c->icc_ctlr_el1[GICV3_S] =3D c->icc_ctlr_el1[GICV3_NS]; +} + +static void whpx_gicv3_reset_hold(Object *obj, ResetType type) +{ + GICv3State *s =3D ARM_GICV3_COMMON(obj); + WHPXARMGICv3Class *kgc =3D WHPX_GICV3_GET_CLASS(s); + + if (kgc->parent_phases.hold) { + kgc->parent_phases.hold(obj, type); + } + + whpx_gicv3_put(s); +} + + +/* + * CPU interface registers of GIC needs to be reset on CPU reset. + * For the calling arm_gicv3_icc_reset() on CPU reset, we register + * below ARMCPRegInfo. As we reset the whole cpu interface under single + * register reset, we define only one register of CPU interface instead + * of defining all the registers. + */ +static const ARMCPRegInfo gicv3_cpuif_reginfo[] =3D { + { .name =3D "ICC_CTLR_EL1", .state =3D ARM_CP_STATE_BOTH, + .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 12, .opc2 =3D 4, + /* + * If ARM_CP_NOP is used, resetfn is not called, + * So ARM_CP_NO_RAW is appropriate type. + */ + .type =3D ARM_CP_NO_RAW, + .access =3D PL1_RW, + .readfn =3D arm_cp_read_zero, + .writefn =3D arm_cp_write_ignore, + /* + * We hang the whole cpu interface reset routine off here + * rather than parcelling it out into one little function + * per register + */ + .resetfn =3D whpx_gicv3_icc_reset, + }, +}; + +static void whpx_set_reg(CPUState *cpu, WHV_REGISTER_NAME reg, WHV_REGISTE= R_VALUE val) +{ + struct whpx_state *whpx =3D &whpx_global; + HRESULT hr; + hr =3D whp_dispatch.WHvSetVirtualProcessorRegisters(whpx->partition, c= pu->cpu_index, + ®, 1, &val); + + if (FAILED(hr)) { + error_report("WHPX: Failed to set register %08x, hr=3D%08lx", reg,= hr); + } +} + +static void whpx_gicv3_realize(DeviceState *dev, Error **errp) +{ + GICv3State *s =3D WHPX_GICV3(dev); + WHPXARMGICv3Class *kgc =3D WHPX_GICV3_GET_CLASS(s); + Error *local_err =3D NULL; + int i; + + kgc->parent_realize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + if (s->revision !=3D 3) { + error_setg(errp, "unsupported GIC revision %d for platform GIC", + s->revision); + } + + if (s->security_extn) { + error_setg(errp, "the platform vGICv3 does not implement the " + "security extensions"); + return; + } + + if (s->nmi_support) { + error_setg(errp, "NMI is not supported with the platform GIC"); + return; + } + + if (s->nb_redist_regions > 1) { + error_setg(errp, "Multiple VGICv3 redistributor regions are not " + "supported by WHPX"); + error_append_hint(errp, "A maximum of %d VCPUs can be used", + s->redist_region_count[0]); + return; + } + + gicv3_init_irqs_and_mmio(s, whpx_gicv3_set_irq, NULL); + + for (i =3D 0; i < s->num_cpu; i++) { + CPUState *cpu_state =3D qemu_get_cpu(i); + ARMCPU *cpu =3D ARM_CPU(cpu_state); + WHV_REGISTER_VALUE val =3D {.Reg64 =3D 0x080A0000 + (GICV3_REDIST_= SIZE * i)}; + whpx_set_reg(cpu_state, WHvArm64RegisterGicrBaseGpa, val); + define_arm_cp_regs(cpu, gicv3_cpuif_reginfo); + } + + if (s->maint_irq) { + error_setg(errp, "Nested virtualisation not currently supported by= WHPX."); + return; + } +} + +static void whpx_gicv3_class_init(ObjectClass *klass, const void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + ARMGICv3CommonClass *agcc =3D ARM_GICV3_COMMON_CLASS(klass); + WHPXARMGICv3Class *kgc =3D WHPX_GICV3_CLASS(klass); + + agcc->pre_save =3D whpx_gicv3_get; + agcc->post_load =3D whpx_gicv3_put; + + device_class_set_parent_realize(dc, whpx_gicv3_realize, + &kgc->parent_realize); + resettable_class_set_parent_phases(rc, NULL, whpx_gicv3_reset_hold, NU= LL, + &kgc->parent_phases); +} + +static const TypeInfo whpx_arm_gicv3_info =3D { + .name =3D TYPE_WHPX_GICV3, + .parent =3D TYPE_ARM_GICV3_COMMON, + .instance_size =3D sizeof(GICv3State), + .class_init =3D whpx_gicv3_class_init, + .class_size =3D sizeof(WHPXARMGICv3Class), +}; + +static void whpx_gicv3_register_types(void) +{ + type_register_static(&whpx_arm_gicv3_info); +} + +type_init(whpx_gicv3_register_types) diff --git a/hw/intc/meson.build b/hw/intc/meson.build index faae20b93d..96742df090 100644 --- a/hw/intc/meson.build +++ b/hw/intc/meson.build @@ -41,6 +41,7 @@ specific_ss.add(when: 'CONFIG_APIC', if_true: files('apic= .c', 'apic_common.c')) arm_common_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif_= common.c')) arm_common_ss.add(when: 'CONFIG_ARM_GICV3', if_true: files('arm_gicv3_cpui= f.c')) specific_ss.add(when: 'CONFIG_ARM_GIC_KVM', if_true: files('arm_gic_kvm.c'= )) +specific_ss.add(when: ['CONFIG_WHPX', 'TARGET_AARCH64'], if_true: files('a= rm_gicv3_whpx.c')) specific_ss.add(when: ['CONFIG_ARM_GIC_KVM', 'TARGET_AARCH64'], if_true: f= iles('arm_gicv3_kvm.c', 'arm_gicv3_its_kvm.c')) arm_common_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_nvic.c')) specific_ss.add(when: 'CONFIG_GRLIB', if_true: files('grlib_irqmp.c')) diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3= _common.h index 61d51915e0..9fd8b9b858 100644 --- a/include/hw/intc/arm_gicv3_common.h +++ b/include/hw/intc/arm_gicv3_common.h @@ -313,6 +313,9 @@ typedef struct ARMGICv3CommonClass ARMGICv3CommonClass; DECLARE_OBJ_CHECKERS(GICv3State, ARMGICv3CommonClass, ARM_GICV3_COMMON, TYPE_ARM_GICV3_COMMON) =20 +/* Types for GICv3 kernel-irqchip */ +#define TYPE_WHPX_GICV3 "whpx-arm-gicv3" + struct ARMGICv3CommonClass { /*< private >*/ SysBusDeviceClass parent_class; --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759741; cv=none; d=zohomail.com; s=zohoarc; b=nJdGV4DbDBrbrrmf3HcifCUF4b2mp1PfB7MZsV/ly6fGF45GG4BrABsFyXJMMu3EYOvnX/FOoupuB0RRSk37zTq8HybcYfYO0RaRHi2CPJ8v2nKvkniiYbVroO+VtF7mMtcsdQ/EAXF6y7pSp0USC+Bkyn+LJou5wbpeYOqUbKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759741; 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=KS1drIzDSxivmOt789wl2SZJxZmlGZDJzXCWJBUlG48=; b=JFHfY2wXklHxkoiQQOxX6Bdy7JeCaLIlI2NFArgG1eIDKKg6mwzYoUrd1d3GjD+Oyo7UYwB+xf0PyQDT+pzcc8xCrlZxZji8xNs08eOE/6MvO5fBuu14zPgeLPdFUxFNY+ru/tSnmRBzLKHQsSpI76MSJ31w81UW9zoks/TCg+0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759741568309.2930244535273; Wed, 29 Oct 2025 10:42:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5b-0003ci-Sj; Wed, 29 Oct 2025 13:36:04 -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 1vEA5Y-0003bc-HD for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:01 -0400 Received: from p-east2-cluster1-host9-snip4-10.eps.apple.com ([57.103.76.113] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5H-0003Ln-84 for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:59 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id A63581808522; Wed, 29 Oct 2025 17:35:26 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 44DEB182B06A; Wed, 29 Oct 2025 16:55:38 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=KS1drIzDSxivmOt789wl2SZJxZmlGZDJzXCWJBUlG48=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=SPnGbnTySc25185d9QHytSLpel+q1vnb7tK9AyrzPbNOmhITipe3Y5X5QqfKg9dtY0aUteUrxZ3sF2Nat9JLWXOYDcEXaW9Czsms3938ZAf6exzkRjhdnfuPGLAoee9IQzwpBDzH9bGlgkN4j132zegNxvJ5cm37MQ7KLpSn7mIasxGpyOKIyM9uZQxeSojk5OpCqZUBD+mJgy6r6z9K5MI11yqjQTtrewVeJOzzWfTvguXP+fF65b3bFrYpMYX4L+3dHOoj0Ketf5AI9zoYVatH7GLILS+A3BtWbkrAdNkxI1IRMOiuGv3mmOO5n1IVIzw0ZEErRyklNp3ygZK1YA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 12/28] whpx: add arm64 support Date: Wed, 29 Oct 2025 17:54:54 +0100 Message-ID: <20251029165510.45824-13-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: xzAU7yMel3l3c8z2xhiH9Wy9iX75Lo7r X-Proofpoint-ORIG-GUID: xzAU7yMel3l3c8z2xhiH9Wy9iX75Lo7r X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfXzY/FAnKRZA7n GvPhYy2YuRoSSTOnz1vjbh4gkDMShECl83qcknxlCRlWl+w3ZYIrcSYnQhU4E5/v18yCOIGcJGe A+sJt2X0lYYL9wkybJ48BoumKhEbXzTAS9mgGygcS5Hsl2iWHgji3oOf0GFBoQXNdook/Pn5zbY Gp6Xftaca25Nrkf4N8S+fVqmaYBexJKrUatH19eS0vHHalI0R1ae6IRNO+wy3FhUtA89HGyT07H A19dQhiDlDB3E5p8iA8BhjEpoOT2qQZYNLjMd4nUji1vS5s1fcnf5bciTtz1umUy+SXZX94D8= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 mlxscore=0 malwarescore=0 clxscore=1030 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABKStMAnh5Duf3+UdOaxrFIL8qhRCdyezYqKHJk+Lm3FRwC8r9N/ISMPigNS2dIxNPAoWXLYPVAqyTp4JmPZVohHyKzKq4cb2EvBc48pn2F/4LH/Krt/YQwkEUt/+Xv5rZXPF8r0OjeXTFAlJCLgYavPy+KOiZJhGK0M7mb0CEf0I+MXUsStsSlZPel4Ds3+LQu/ZlEaP4bp4cux2IEzrpoFTbxGxqKIlVoqC7oBaJCtU/YllVpOePmNVIo8Effndxxza8HiiObHR2x175vrvQQuEQDjkqYB4CBsLtiyVMy6bQ2E2qYf1JqBJ631RoFhpdfRw0S7woLcyzgBTG0UR2D5HqYam6Oh8Jfs/t4NvjpdBUY463xdaJ7uikVCX9krQ7gosck9HXhd3i/c9QDwk8hAn2hpgspgF2I9uie5QWwx866B+hc97IwqoQWHPyOcUZomA970fYeorK7sy2OgWV7+86BhfuEeoPsPwVFiMImb/wyP1IKHR7qGmoelY4oQxWnNvI/oOwtGt4ZGkKaivzjTxq+tj/Lz1BUrwbD/dd1orF2ZuNKBsZht5pUP8fot5EsU69JZCa4yrs2+okecOvoaKKdNMH10th6I6vtr37EiEKaMrmPMTuhFLDmwjzes0I2u1OaJaLn7Zcgpulln0W0Jz+VRHlwFMNYFd/9Po3vtzm09Z8Nvap6Ngp/q8WMtrRuD+4NsPv/jBjw1Nqqg6G8NNCicgiiiMRCoDpx/UxPDVVRfYNZ5T0I/ei/KT6B7aah9g= 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=57.103.76.113; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1761759743298154100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni Reviewed-by: Pierrick Bouvier --- accel/whpx/whpx-common.c | 1 + target/arm/meson.build | 1 + target/arm/whpx/meson.build | 3 + target/arm/whpx/whpx-all.c | 845 ++++++++++++++++++++++++++++++++++++ 4 files changed, 850 insertions(+) create mode 100644 target/arm/whpx/meson.build create mode 100644 target/arm/whpx/whpx-all.c diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c index 18d93225c1..c69792e638 100644 --- a/accel/whpx/whpx-common.c +++ b/accel/whpx/whpx-common.c @@ -16,6 +16,7 @@ #include "gdbstub/helpers.h" #include "qemu/accel.h" #include "accel/accel-ops.h" +#include "system/memory.h" #include "system/whpx.h" #include "system/cpus.h" #include "system/runstate.h" diff --git a/target/arm/meson.build b/target/arm/meson.build index 3df7e03654..61277a627c 100644 --- a/target/arm/meson.build +++ b/target/arm/meson.build @@ -59,6 +59,7 @@ arm_common_system_ss.add(files( )) =20 subdir('hvf') +subdir('whpx') =20 if 'CONFIG_TCG' in config_all_accel subdir('tcg') diff --git a/target/arm/whpx/meson.build b/target/arm/whpx/meson.build new file mode 100644 index 0000000000..1de2ef0283 --- /dev/null +++ b/target/arm/whpx/meson.build @@ -0,0 +1,3 @@ +arm_system_ss.add(when: 'CONFIG_WHPX', if_true: files( + 'whpx-all.c', +)) diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c new file mode 100644 index 0000000000..8c34650765 --- /dev/null +++ b/target/arm/whpx/whpx-all.c @@ -0,0 +1,845 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * QEMU Windows Hypervisor Platform accelerator (WHPX) + * + * Copyright (c) 2025 Mohamed Mediouni + * + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "system/address-spaces.h" +#include "system/ioport.h" +#include "gdbstub/helpers.h" +#include "qemu/accel.h" +#include "accel/accel-ops.h" +#include "system/whpx.h" +#include "system/cpus.h" +#include "system/runstate.h" +#include "qemu/main-loop.h" +#include "hw/boards.h" +#include "qemu/error-report.h" +#include "qapi/error.h" +#include "qapi/qapi-types-common.h" +#include "qapi/qapi-visit-common.h" +#include "migration/blocker.h" +#include "accel/accel-cpu-target.h" +#include + +#include "syndrome.h" +#include "cpu.h" +#include "target/arm/cpregs.h" +#include "internals.h" + +#include "system/whpx-internal.h" +#include "system/whpx-accel-ops.h" +#include "system/whpx-all.h" +#include "system/whpx-common.h" +#include "hw/arm/bsa.h" +#include "arm-powerctl.h" + +#include +#include + +struct whpx_reg_match { + WHV_REGISTER_NAME reg; + uint64_t offset; +}; + +static const struct whpx_reg_match whpx_reg_match[] =3D { + { WHvArm64RegisterX0, offsetof(CPUARMState, xregs[0]) }, + { WHvArm64RegisterX1, offsetof(CPUARMState, xregs[1]) }, + { WHvArm64RegisterX2, offsetof(CPUARMState, xregs[2]) }, + { WHvArm64RegisterX3, offsetof(CPUARMState, xregs[3]) }, + { WHvArm64RegisterX4, offsetof(CPUARMState, xregs[4]) }, + { WHvArm64RegisterX5, offsetof(CPUARMState, xregs[5]) }, + { WHvArm64RegisterX6, offsetof(CPUARMState, xregs[6]) }, + { WHvArm64RegisterX7, offsetof(CPUARMState, xregs[7]) }, + { WHvArm64RegisterX8, offsetof(CPUARMState, xregs[8]) }, + { WHvArm64RegisterX9, offsetof(CPUARMState, xregs[9]) }, + { WHvArm64RegisterX10, offsetof(CPUARMState, xregs[10]) }, + { WHvArm64RegisterX11, offsetof(CPUARMState, xregs[11]) }, + { WHvArm64RegisterX12, offsetof(CPUARMState, xregs[12]) }, + { WHvArm64RegisterX13, offsetof(CPUARMState, xregs[13]) }, + { WHvArm64RegisterX14, offsetof(CPUARMState, xregs[14]) }, + { WHvArm64RegisterX15, offsetof(CPUARMState, xregs[15]) }, + { WHvArm64RegisterX16, offsetof(CPUARMState, xregs[16]) }, + { WHvArm64RegisterX17, offsetof(CPUARMState, xregs[17]) }, + { WHvArm64RegisterX18, offsetof(CPUARMState, xregs[18]) }, + { WHvArm64RegisterX19, offsetof(CPUARMState, xregs[19]) }, + { WHvArm64RegisterX20, offsetof(CPUARMState, xregs[20]) }, + { WHvArm64RegisterX21, offsetof(CPUARMState, xregs[21]) }, + { WHvArm64RegisterX22, offsetof(CPUARMState, xregs[22]) }, + { WHvArm64RegisterX23, offsetof(CPUARMState, xregs[23]) }, + { WHvArm64RegisterX24, offsetof(CPUARMState, xregs[24]) }, + { WHvArm64RegisterX25, offsetof(CPUARMState, xregs[25]) }, + { WHvArm64RegisterX26, offsetof(CPUARMState, xregs[26]) }, + { WHvArm64RegisterX27, offsetof(CPUARMState, xregs[27]) }, + { WHvArm64RegisterX28, offsetof(CPUARMState, xregs[28]) }, + { WHvArm64RegisterFp, offsetof(CPUARMState, xregs[29]) }, + { WHvArm64RegisterLr, offsetof(CPUARMState, xregs[30]) }, + { WHvArm64RegisterPc, offsetof(CPUARMState, pc) }, +}; + +static const struct whpx_reg_match whpx_fpreg_match[] =3D { + { WHvArm64RegisterQ0, offsetof(CPUARMState, vfp.zregs[0]) }, + { WHvArm64RegisterQ1, offsetof(CPUARMState, vfp.zregs[1]) }, + { WHvArm64RegisterQ2, offsetof(CPUARMState, vfp.zregs[2]) }, + { WHvArm64RegisterQ3, offsetof(CPUARMState, vfp.zregs[3]) }, + { WHvArm64RegisterQ4, offsetof(CPUARMState, vfp.zregs[4]) }, + { WHvArm64RegisterQ5, offsetof(CPUARMState, vfp.zregs[5]) }, + { WHvArm64RegisterQ6, offsetof(CPUARMState, vfp.zregs[6]) }, + { WHvArm64RegisterQ7, offsetof(CPUARMState, vfp.zregs[7]) }, + { WHvArm64RegisterQ8, offsetof(CPUARMState, vfp.zregs[8]) }, + { WHvArm64RegisterQ9, offsetof(CPUARMState, vfp.zregs[9]) }, + { WHvArm64RegisterQ10, offsetof(CPUARMState, vfp.zregs[10]) }, + { WHvArm64RegisterQ11, offsetof(CPUARMState, vfp.zregs[11]) }, + { WHvArm64RegisterQ12, offsetof(CPUARMState, vfp.zregs[12]) }, + { WHvArm64RegisterQ13, offsetof(CPUARMState, vfp.zregs[13]) }, + { WHvArm64RegisterQ14, offsetof(CPUARMState, vfp.zregs[14]) }, + { WHvArm64RegisterQ15, offsetof(CPUARMState, vfp.zregs[15]) }, + { WHvArm64RegisterQ16, offsetof(CPUARMState, vfp.zregs[16]) }, + { WHvArm64RegisterQ17, offsetof(CPUARMState, vfp.zregs[17]) }, + { WHvArm64RegisterQ18, offsetof(CPUARMState, vfp.zregs[18]) }, + { WHvArm64RegisterQ19, offsetof(CPUARMState, vfp.zregs[19]) }, + { WHvArm64RegisterQ20, offsetof(CPUARMState, vfp.zregs[20]) }, + { WHvArm64RegisterQ21, offsetof(CPUARMState, vfp.zregs[21]) }, + { WHvArm64RegisterQ22, offsetof(CPUARMState, vfp.zregs[22]) }, + { WHvArm64RegisterQ23, offsetof(CPUARMState, vfp.zregs[23]) }, + { WHvArm64RegisterQ24, offsetof(CPUARMState, vfp.zregs[24]) }, + { WHvArm64RegisterQ25, offsetof(CPUARMState, vfp.zregs[25]) }, + { WHvArm64RegisterQ26, offsetof(CPUARMState, vfp.zregs[26]) }, + { WHvArm64RegisterQ27, offsetof(CPUARMState, vfp.zregs[27]) }, + { WHvArm64RegisterQ28, offsetof(CPUARMState, vfp.zregs[28]) }, + { WHvArm64RegisterQ29, offsetof(CPUARMState, vfp.zregs[29]) }, + { WHvArm64RegisterQ30, offsetof(CPUARMState, vfp.zregs[30]) }, + { WHvArm64RegisterQ31, offsetof(CPUARMState, vfp.zregs[31]) }, +}; + +struct whpx_sreg_match { + WHV_REGISTER_NAME reg; + uint32_t key; + bool global; + uint32_t cp_idx; +}; + +static struct whpx_sreg_match whpx_sreg_match[] =3D { + { WHvArm64RegisterDbgbvr0El1, ENCODE_AA64_CP_REG(0, 0, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr0El1, ENCODE_AA64_CP_REG(0, 0, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr0El1, ENCODE_AA64_CP_REG(0, 0, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr0El1, ENCODE_AA64_CP_REG(0, 0, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr0El1, ENCODE_AA64_CP_REG(0, 1, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr0El1, ENCODE_AA64_CP_REG(0, 1, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr0El1, ENCODE_AA64_CP_REG(0, 1, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr0El1, ENCODE_AA64_CP_REG(0, 1, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr2El1, ENCODE_AA64_CP_REG(0, 2, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr2El1, ENCODE_AA64_CP_REG(0, 2, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr2El1, ENCODE_AA64_CP_REG(0, 2, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr2El1, ENCODE_AA64_CP_REG(0, 2, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr3El1, ENCODE_AA64_CP_REG(0, 3, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr3El1, ENCODE_AA64_CP_REG(0, 3, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr3El1, ENCODE_AA64_CP_REG(0, 3, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr3El1, ENCODE_AA64_CP_REG(0, 3, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr4El1, ENCODE_AA64_CP_REG(0, 4, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr4El1, ENCODE_AA64_CP_REG(0, 4, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr4El1, ENCODE_AA64_CP_REG(0, 4, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr4El1, ENCODE_AA64_CP_REG(0, 4, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr5El1, ENCODE_AA64_CP_REG(0, 5, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr5El1, ENCODE_AA64_CP_REG(0, 5, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr5El1, ENCODE_AA64_CP_REG(0, 5, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr5El1, ENCODE_AA64_CP_REG(0, 5, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr6El1, ENCODE_AA64_CP_REG(0, 6, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr6El1, ENCODE_AA64_CP_REG(0, 6, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr6El1, ENCODE_AA64_CP_REG(0, 6, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr6El1, ENCODE_AA64_CP_REG(0, 6, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr7El1, ENCODE_AA64_CP_REG(0, 7, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr7El1, ENCODE_AA64_CP_REG(0, 7, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr7El1, ENCODE_AA64_CP_REG(0, 7, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr7El1, ENCODE_AA64_CP_REG(0, 7, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr8El1, ENCODE_AA64_CP_REG(0, 8, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr8El1, ENCODE_AA64_CP_REG(0, 8, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr8El1, ENCODE_AA64_CP_REG(0, 8, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr8El1, ENCODE_AA64_CP_REG(0, 8, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr9El1, ENCODE_AA64_CP_REG(0, 9, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr9El1, ENCODE_AA64_CP_REG(0, 9, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr9El1, ENCODE_AA64_CP_REG(0, 9, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr9El1, ENCODE_AA64_CP_REG(0, 9, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr10El1, ENCODE_AA64_CP_REG(0, 10, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr10El1, ENCODE_AA64_CP_REG(0, 10, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr10El1, ENCODE_AA64_CP_REG(0, 10, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr10El1, ENCODE_AA64_CP_REG(0, 10, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr11El1, ENCODE_AA64_CP_REG(0, 11, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr11El1, ENCODE_AA64_CP_REG(0, 11, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr11El1, ENCODE_AA64_CP_REG(0, 11, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr11El1, ENCODE_AA64_CP_REG(0, 11, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr12El1, ENCODE_AA64_CP_REG(0, 12, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr12El1, ENCODE_AA64_CP_REG(0, 12, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr12El1, ENCODE_AA64_CP_REG(0, 12, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr12El1, ENCODE_AA64_CP_REG(0, 12, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr13El1, ENCODE_AA64_CP_REG(0, 13, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr13El1, ENCODE_AA64_CP_REG(0, 13, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr13El1, ENCODE_AA64_CP_REG(0, 13, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr13El1, ENCODE_AA64_CP_REG(0, 13, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr14El1, ENCODE_AA64_CP_REG(0, 14, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr14El1, ENCODE_AA64_CP_REG(0, 14, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr14El1, ENCODE_AA64_CP_REG(0, 14, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr14El1, ENCODE_AA64_CP_REG(0, 14, 2, 0, 7) }, + + { WHvArm64RegisterDbgbvr15El1, ENCODE_AA64_CP_REG(0, 15, 2, 0, 4) }, + { WHvArm64RegisterDbgbcr15El1, ENCODE_AA64_CP_REG(0, 15, 2, 0, 5) }, + { WHvArm64RegisterDbgwvr15El1, ENCODE_AA64_CP_REG(0, 15, 2, 0, 6) }, + { WHvArm64RegisterDbgwcr15El1, ENCODE_AA64_CP_REG(0, 15, 2, 0, 7) }, +#ifdef SYNC_NO_RAW_REGS + /* + * The registers below are manually synced on init because they are + * marked as NO_RAW. We still list them to make number space sync easi= er. + */ + { WHvArm64RegisterMidrEl1, ENCODE_AA64_CP_REG(0, 0, 3, 0, 0) }, + { WHvArm64RegisterMpidrEl1, ENCODE_AA64_CP_REG(0, 0, 3, 0, 5) }, + { WHvArm64RegisterIdPfr0El1, ENCODE_AA64_CP_REG(0, 4, 3, 0, 0) }, +#endif + { WHvArm64RegisterIdAa64Pfr1El1, ENCODE_AA64_CP_REG(0, 4, 3, 0, 1), tr= ue }, + { WHvArm64RegisterIdAa64Dfr0El1, ENCODE_AA64_CP_REG(0, 5, 3, 0, 0), tr= ue }, + { WHvArm64RegisterIdAa64Dfr1El1, ENCODE_AA64_CP_REG(0, 5, 3, 0, 1), tr= ue }, + { WHvArm64RegisterIdAa64Isar0El1, ENCODE_AA64_CP_REG(0, 6, 3, 0, 0), t= rue }, + { WHvArm64RegisterIdAa64Isar1El1, ENCODE_AA64_CP_REG(0, 6, 3, 0, 1), t= rue }, +#ifdef SYNC_NO_MMFR0 + /* We keep the hardware MMFR0 around. HW limits are there anyway */ + { WHvArm64RegisterIdAa64Mmfr0El1, ENCODE_AA64_CP_REG(0, 7, 3, 0, 0) }, +#endif + { WHvArm64RegisterIdAa64Mmfr1El1, ENCODE_AA64_CP_REG(0, 7, 3, 0, 1), t= rue }, + { WHvArm64RegisterIdAa64Mmfr2El1, ENCODE_AA64_CP_REG(0, 7, 3, 0, 2), t= rue }, + { WHvArm64RegisterIdAa64Mmfr3El1, ENCODE_AA64_CP_REG(0, 7, 3, 0, 3), t= rue }, + + { WHvArm64RegisterMdscrEl1, ENCODE_AA64_CP_REG(0, 2, 2, 0, 2) }, + { WHvArm64RegisterSctlrEl1, ENCODE_AA64_CP_REG(1, 0, 3, 0, 0) }, + { WHvArm64RegisterCpacrEl1, ENCODE_AA64_CP_REG(1, 0, 3, 0, 2) }, + { WHvArm64RegisterTtbr0El1, ENCODE_AA64_CP_REG(2, 0, 3, 0, 0) }, + { WHvArm64RegisterTtbr1El1, ENCODE_AA64_CP_REG(2, 0, 3, 0, 1) }, + { WHvArm64RegisterTcrEl1, ENCODE_AA64_CP_REG(2, 0, 3, 0, 2) }, + + { WHvArm64RegisterApiAKeyLoEl1, ENCODE_AA64_CP_REG(2, 1, 3, 0, 0) }, + { WHvArm64RegisterApiAKeyHiEl1, ENCODE_AA64_CP_REG(2, 1, 3, 0, 1) }, + { WHvArm64RegisterApiBKeyLoEl1, ENCODE_AA64_CP_REG(2, 1, 3, 0, 2) }, + { WHvArm64RegisterApiBKeyHiEl1, ENCODE_AA64_CP_REG(2, 1, 3, 0, 3) }, + { WHvArm64RegisterApdAKeyLoEl1, ENCODE_AA64_CP_REG(2, 2, 3, 0, 0) }, + { WHvArm64RegisterApdAKeyHiEl1, ENCODE_AA64_CP_REG(2, 2, 3, 0, 1) }, + { WHvArm64RegisterApdBKeyLoEl1, ENCODE_AA64_CP_REG(2, 2, 3, 0, 2) }, + { WHvArm64RegisterApdBKeyHiEl1, ENCODE_AA64_CP_REG(2, 2, 3, 0, 3) }, + { WHvArm64RegisterApgAKeyLoEl1, ENCODE_AA64_CP_REG(2, 3, 3, 0, 0) }, + { WHvArm64RegisterApgAKeyHiEl1, ENCODE_AA64_CP_REG(2, 3, 3, 0, 1) }, + + { WHvArm64RegisterSpsrEl1, ENCODE_AA64_CP_REG(4, 0, 3, 0, 0) }, + { WHvArm64RegisterElrEl1, ENCODE_AA64_CP_REG(4, 0, 3, 0, 1) }, + { WHvArm64RegisterSpEl1, ENCODE_AA64_CP_REG(4, 1, 3, 0, 0) }, + { WHvArm64RegisterEsrEl1, ENCODE_AA64_CP_REG(5, 2, 3, 0, 0) }, + { WHvArm64RegisterFarEl1, ENCODE_AA64_CP_REG(6, 0, 3, 0, 0) }, + { WHvArm64RegisterParEl1, ENCODE_AA64_CP_REG(7, 4, 3, 0, 0) }, + { WHvArm64RegisterMairEl1, ENCODE_AA64_CP_REG(10, 2, 3, 0, 0) }, + { WHvArm64RegisterVbarEl1, ENCODE_AA64_CP_REG(12, 0, 3, 0, 0) }, + { WHvArm64RegisterContextidrEl1, ENCODE_AA64_CP_REG(13, 0, 3, 0, 1) }, + { WHvArm64RegisterTpidrEl1, ENCODE_AA64_CP_REG(13, 0, 3, 0, 4) }, + { WHvArm64RegisterCntkctlEl1, ENCODE_AA64_CP_REG(14, 1, 3, 0, 0) }, + { WHvArm64RegisterCsselrEl1, ENCODE_AA64_CP_REG(0, 0, 3, 2, 0) }, + { WHvArm64RegisterTpidrEl0, ENCODE_AA64_CP_REG(13, 0, 3, 3, 2) }, + { WHvArm64RegisterTpidrroEl0, ENCODE_AA64_CP_REG(13, 0, 3, 3, 3) }, + { WHvArm64RegisterCntvCtlEl0, ENCODE_AA64_CP_REG(14, 3, 3, 3, 1) }, + { WHvArm64RegisterCntvCvalEl0, ENCODE_AA64_CP_REG(14, 3, 3, 3, 2) }, + { WHvArm64RegisterSpEl1, ENCODE_AA64_CP_REG(4, 1, 3, 4, 0) }, +}; + +static void flush_cpu_state(CPUState *cpu) +{ + if (cpu->vcpu_dirty) { + whpx_set_registers(cpu, WHPX_SET_RUNTIME_STATE); + cpu->vcpu_dirty =3D false; + } +} + +HRESULT whpx_set_exception_exit_bitmap(UINT64 exceptions) +{ + if (exceptions !=3D 0) { + return E_NOTIMPL; + } + return ERROR_SUCCESS; +} +void whpx_apply_breakpoints( +struct whpx_breakpoint_collection *breakpoints, + CPUState *cpu, + bool resuming) +{ + +} +void whpx_translate_cpu_breakpoints( + struct whpx_breakpoints *breakpoints, + CPUState *cpu, + int cpu_breakpoint_count) +{ + +} + +static void whpx_get_reg(CPUState *cpu, WHV_REGISTER_NAME reg, WHV_REGISTE= R_VALUE* val) +{ + struct whpx_state *whpx =3D &whpx_global; + HRESULT hr; + + flush_cpu_state(cpu); + + hr =3D whp_dispatch.WHvGetVirtualProcessorRegisters(whpx->partition, c= pu->cpu_index, + ®, 1, val); + + if (FAILED(hr)) { + error_report("WHPX: Failed to get register %08x, hr=3D%08lx", reg,= hr); + } +} + +static void whpx_set_reg(CPUState *cpu, WHV_REGISTER_NAME reg, WHV_REGISTE= R_VALUE val) +{ + struct whpx_state *whpx =3D &whpx_global; + HRESULT hr; + hr =3D whp_dispatch.WHvSetVirtualProcessorRegisters(whpx->partition, c= pu->cpu_index, + ®, 1, &val); + + if (FAILED(hr)) { + error_report("WHPX: Failed to set register %08x, hr=3D%08lx", reg,= hr); + } +} + +static void whpx_get_global_reg(WHV_REGISTER_NAME reg, WHV_REGISTER_VALUE = *val) +{ + struct whpx_state *whpx =3D &whpx_global; + HRESULT hr; + + hr =3D whp_dispatch.WHvGetVirtualProcessorRegisters(whpx->partition, W= HV_ANY_VP, + ®, 1, val); + + if (FAILED(hr)) { + error_report("WHPX: Failed to get register %08x, hr=3D%08lx", reg,= hr); + } +} + +static void whpx_set_global_reg(WHV_REGISTER_NAME reg, WHV_REGISTER_VALUE = val) +{ + struct whpx_state *whpx =3D &whpx_global; + HRESULT hr; + hr =3D whp_dispatch.WHvSetVirtualProcessorRegisters(whpx->partition, W= HV_ANY_VP, + ®, 1, &val); + + if (FAILED(hr)) { + error_report("WHPX: Failed to set register %08x, hr=3D%08lx", reg,= hr); + } +} + +static uint64_t whpx_get_gp_reg(CPUState *cpu, int rt) +{ + assert(rt <=3D 31); + if (rt =3D=3D 31) { + return 0; + } + WHV_REGISTER_NAME reg =3D WHvArm64RegisterX0 + rt; + WHV_REGISTER_VALUE val; + whpx_get_reg(cpu, reg, &val); + + return val.Reg64; +} + +static void whpx_set_gp_reg(CPUState *cpu, int rt, uint64_t val) +{ + assert(rt < 31); + WHV_REGISTER_NAME reg =3D WHvArm64RegisterX0 + rt; + WHV_REGISTER_VALUE reg_val =3D {.Reg64 =3D val}; + + whpx_set_reg(cpu, reg, reg_val); +} + +static int whpx_handle_mmio(CPUState *cpu, WHV_MEMORY_ACCESS_CONTEXT *ctx) +{ + uint64_t syndrome =3D ctx->Syndrome; + + bool isv =3D syndrome & ARM_EL_ISV; + bool iswrite =3D (syndrome >> 6) & 1; + bool sse =3D (syndrome >> 21) & 1; + uint32_t sas =3D (syndrome >> 22) & 3; + uint32_t len =3D 1 << sas; + uint32_t srt =3D (syndrome >> 16) & 0x1f; + uint32_t cm =3D (syndrome >> 8) & 0x1; + uint64_t val =3D 0; + + assert(!cm); + assert(isv); + + if (iswrite) { + val =3D whpx_get_gp_reg(cpu, srt); + address_space_write(&address_space_memory, + ctx->Gpa, + MEMTXATTRS_UNSPECIFIED, &val, len); + } else { + address_space_read(&address_space_memory, + ctx->Gpa, + MEMTXATTRS_UNSPECIFIED, &val, len); + if (sse) { + val =3D sextract64(val, 0, len * 8); + } + whpx_set_gp_reg(cpu, srt, val); + } + + return 0; +} + +static void whpx_psci_cpu_off(ARMCPU *arm_cpu) +{ + int32_t ret =3D arm_set_cpu_off(arm_cpu_mp_affinity(arm_cpu)); + assert(ret =3D=3D QEMU_ARM_POWERCTL_RET_SUCCESS); +} + +int whpx_vcpu_run(CPUState *cpu) +{ + HRESULT hr; + struct whpx_state *whpx =3D &whpx_global; + ARMCPU *arm_cpu =3D ARM_CPU(cpu); + AccelCPUState *vcpu =3D cpu->accel; + int ret; + + + g_assert(bql_locked()); + + if (whpx->running_cpus++ =3D=3D 0) { + ret =3D whpx_first_vcpu_starting(cpu); + if (ret !=3D 0) { + return ret; + } + } + + bql_unlock(); + + + cpu_exec_start(cpu); + do { + bool advance_pc =3D false; + if (cpu->vcpu_dirty) { + whpx_set_registers(cpu, WHPX_SET_RUNTIME_STATE); + cpu->vcpu_dirty =3D false; + } + + if (qatomic_read(&cpu->exit_request)) { + whpx_vcpu_kick(cpu); + } + + hr =3D whp_dispatch.WHvRunVirtualProcessor( + whpx->partition, cpu->cpu_index, + &vcpu->exit_ctx, sizeof(vcpu->exit_ctx)); + + if (FAILED(hr)) { + error_report("WHPX: Failed to exec a virtual processor," + " hr=3D%08lx", hr); + ret =3D -1; + break; + } + + switch (vcpu->exit_ctx.ExitReason) { + case WHvRunVpExitReasonGpaIntercept: + case WHvRunVpExitReasonUnmappedGpa: + advance_pc =3D true; + + if (vcpu->exit_ctx.MemoryAccess.Syndrome >> 8 & 0x1) { + error_report("WHPX: cached access to unmapped memory" + "Pc =3D 0x%llx Gva =3D 0x%llx Gpa =3D 0x%llx", + vcpu->exit_ctx.MemoryAccess.Header.Pc, + vcpu->exit_ctx.MemoryAccess.Gpa, + vcpu->exit_ctx.MemoryAccess.Gva); + break; + } + + ret =3D whpx_handle_mmio(cpu, &vcpu->exit_ctx.MemoryAccess); + break; + case WHvRunVpExitReasonCanceled: + cpu->exception_index =3D EXCP_INTERRUPT; + ret =3D 1; + break; + case WHvRunVpExitReasonArm64Reset: + switch (vcpu->exit_ctx.Arm64Reset.ResetType) { + case WHvArm64ResetTypePowerOff: + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN= ); + break; + case WHvArm64ResetTypeReboot: + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); + break; + default: + g_assert_not_reached(); + } + bql_lock(); + if (arm_cpu->power_state !=3D PSCI_OFF) { + whpx_psci_cpu_off(arm_cpu); + } + bql_unlock(); + break; + case WHvRunVpExitReasonNone: + case WHvRunVpExitReasonUnrecoverableException: + case WHvRunVpExitReasonInvalidVpRegisterValue: + case WHvRunVpExitReasonUnsupportedFeature: + default: + error_report("WHPX: Unexpected VP exit code 0x%08x", + vcpu->exit_ctx.ExitReason); + whpx_get_registers(cpu); + bql_lock(); + qemu_system_guest_panicked(cpu_get_crash_info(cpu)); + bql_unlock(); + break; + } + if (advance_pc) { + WHV_REGISTER_VALUE pc; + + flush_cpu_state(cpu); + pc.Reg64 =3D vcpu->exit_ctx.MemoryAccess.Header.Pc + 4; + whpx_set_reg(cpu, WHvArm64RegisterPc, pc); + } + } while (!ret); + + cpu_exec_end(cpu); + + bql_lock(); + current_cpu =3D cpu; + + if (--whpx->running_cpus =3D=3D 0) { + whpx_last_vcpu_stopping(cpu); + } + + qatomic_set(&cpu->exit_request, false); + + return ret < 0; +} + +static void clean_whv_register_value(WHV_REGISTER_VALUE *val) +{ + memset(val, 0, sizeof(WHV_REGISTER_VALUE)); +} + +void whpx_get_registers(CPUState *cpu) +{ + ARMCPU *arm_cpu =3D ARM_CPU(cpu); + CPUARMState *env =3D &arm_cpu->env; + WHV_REGISTER_VALUE val; + int i; + + for (i =3D 0; i < ARRAY_SIZE(whpx_reg_match); i++) { + whpx_get_reg(cpu, whpx_reg_match[i].reg, &val); + *(uint64_t *)((void *)env + whpx_reg_match[i].offset) =3D val.Reg6= 4; + } + + for (i =3D 0; i < ARRAY_SIZE(whpx_fpreg_match); i++) { + whpx_get_reg(cpu, whpx_reg_match[i].reg, &val); + memcpy((void *)env + whpx_fpreg_match[i].offset, &val, sizeof(val.= Reg128)); + } + + whpx_get_reg(cpu, WHvArm64RegisterPc, &val); + env->pc =3D val.Reg64; + + whpx_get_reg(cpu, WHvArm64RegisterFpcr, &val); + vfp_set_fpcr(env, val.Reg32); + + whpx_get_reg(cpu, WHvArm64RegisterFpsr, &val); + vfp_set_fpsr(env, val.Reg32); + + whpx_get_reg(cpu, WHvArm64RegisterPstate, &val); + pstate_write(env, val.Reg32); + + for (i =3D 0; i < ARRAY_SIZE(whpx_sreg_match); i++) { + if (whpx_sreg_match[i].global =3D=3D true) { + continue; + } + if (whpx_sreg_match[i].cp_idx =3D=3D -1) { + continue; + } + + whpx_get_reg(cpu, whpx_sreg_match[i].reg, &val); + + arm_cpu->cpreg_values[whpx_sreg_match[i].cp_idx] =3D val.Reg64; + } + + /* WHP disallows us from reading global regs as a vCPU */ + for (i =3D 0; i < ARRAY_SIZE(whpx_sreg_match); i++) { + if (whpx_sreg_match[i].global =3D=3D false) { + continue; + } + if (whpx_sreg_match[i].cp_idx =3D=3D -1) { + continue; + } + + whpx_get_global_reg(whpx_sreg_match[i].reg, &val); + + arm_cpu->cpreg_values[whpx_sreg_match[i].cp_idx] =3D val.Reg64; + } + assert(write_list_to_cpustate(arm_cpu)); + + aarch64_restore_sp(env, arm_current_el(env)); +} + +void whpx_set_registers(CPUState *cpu, int level) +{ + ARMCPU *arm_cpu =3D ARM_CPU(cpu); + CPUARMState *env =3D &arm_cpu->env; + WHV_REGISTER_VALUE val; + clean_whv_register_value(&val); + int i; + + assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu)); + + for (i =3D 0; i < ARRAY_SIZE(whpx_reg_match); i++) { + val.Reg64 =3D *(uint64_t *)((void *)env + whpx_reg_match[i].offset= ); + whpx_set_reg(cpu, whpx_reg_match[i].reg, val); + } + + for (i =3D 0; i < ARRAY_SIZE(whpx_fpreg_match); i++) { + memcpy(&val.Reg128, (void *)env + whpx_fpreg_match[i].offset, size= of(val.Reg128)); + whpx_set_reg(cpu, whpx_reg_match[i].reg, val); + } + + clean_whv_register_value(&val); + val.Reg64 =3D env->pc; + whpx_set_reg(cpu, WHvArm64RegisterPc, val); + + clean_whv_register_value(&val); + val.Reg32 =3D vfp_get_fpcr(env); + whpx_set_reg(cpu, WHvArm64RegisterFpcr, val); + val.Reg32 =3D vfp_get_fpsr(env); + whpx_set_reg(cpu, WHvArm64RegisterFpsr, val); + val.Reg32 =3D pstate_read(env); + whpx_set_reg(cpu, WHvArm64RegisterPstate, val); + + aarch64_save_sp(env, arm_current_el(env)); + + assert(write_cpustate_to_list(arm_cpu, false)); + for (i =3D 0; i < ARRAY_SIZE(whpx_sreg_match); i++) { + if (whpx_sreg_match[i].global =3D=3D true) { + continue; + } + + if (whpx_sreg_match[i].cp_idx =3D=3D -1) { + continue; + } + clean_whv_register_value(&val); + val.Reg64 =3D arm_cpu->cpreg_values[whpx_sreg_match[i].cp_idx]; + whpx_set_reg(cpu, whpx_sreg_match[i].reg, val); + } + + /* Currently set global regs every time. */ + for (i =3D 0; i < ARRAY_SIZE(whpx_sreg_match); i++) { + if (whpx_sreg_match[i].global =3D=3D false) { + continue; + } + + if (whpx_sreg_match[i].cp_idx =3D=3D -1) { + continue; + } + clean_whv_register_value(&val); + val.Reg64 =3D arm_cpu->cpreg_values[whpx_sreg_match[i].cp_idx]; + whpx_set_global_reg(whpx_sreg_match[i].reg, val); + } +} + +static uint32_t max_vcpu_index; + +static void whpx_cpu_update_state(void *opaque, bool running, RunState sta= te) +{ +} + +int whpx_init_vcpu(CPUState *cpu) +{ + HRESULT hr; + struct whpx_state *whpx =3D &whpx_global; + AccelCPUState *vcpu =3D NULL; + ARMCPU *arm_cpu =3D ARM_CPU(cpu); + CPUARMState *env =3D &arm_cpu->env; + int ret; + + uint32_t sregs_match_len =3D ARRAY_SIZE(whpx_sreg_match); + uint32_t sregs_cnt =3D 0; + WHV_REGISTER_VALUE val; + int i; + + vcpu =3D g_new0(AccelCPUState, 1); + + hr =3D whp_dispatch.WHvCreateVirtualProcessor( + whpx->partition, cpu->cpu_index, 0); + if (FAILED(hr)) { + error_report("WHPX: Failed to create a virtual processor," + " hr=3D%08lx", hr); + ret =3D -EINVAL; + goto error; + } + + /* Assumption that CNTFRQ_EL0 is the same between the VMM and the part= ition. */ + asm volatile("mrs %0, cntfrq_el0" : "=3Dr"(arm_cpu->gt_cntfrq_hz)); + + cpu->vcpu_dirty =3D true; + cpu->accel =3D vcpu; + max_vcpu_index =3D max(max_vcpu_index, cpu->cpu_index); + qemu_add_vm_change_state_handler(whpx_cpu_update_state, env); + + env->aarch64 =3D true; + + /* Allocate enough space for our sysreg sync */ + arm_cpu->cpreg_indexes =3D g_renew(uint64_t, arm_cpu->cpreg_indexes, + sregs_match_len); + arm_cpu->cpreg_values =3D g_renew(uint64_t, arm_cpu->cpreg_values, + sregs_match_len); + arm_cpu->cpreg_vmstate_indexes =3D g_renew(uint64_t, + arm_cpu->cpreg_vmstate_indexe= s, + sregs_match_len); + arm_cpu->cpreg_vmstate_values =3D g_renew(uint64_t, + arm_cpu->cpreg_vmstate_values, + sregs_match_len); + + memset(arm_cpu->cpreg_values, 0, sregs_match_len * sizeof(uint64_t)); + + /* Populate cp list for all known sysregs */ + for (i =3D 0; i < sregs_match_len; i++) { + const ARMCPRegInfo *ri; + uint32_t key =3D whpx_sreg_match[i].key; + + ri =3D get_arm_cp_reginfo(arm_cpu->cp_regs, key); + if (ri) { + assert(!(ri->type & ARM_CP_NO_RAW)); + whpx_sreg_match[i].cp_idx =3D sregs_cnt; + arm_cpu->cpreg_indexes[sregs_cnt++] =3D cpreg_to_kvm_id(key); + } else { + whpx_sreg_match[i].cp_idx =3D -1; + } + } + arm_cpu->cpreg_array_len =3D sregs_cnt; + arm_cpu->cpreg_vmstate_array_len =3D sregs_cnt; + + assert(write_cpustate_to_list(arm_cpu, false)); + + /* Set CP_NO_RAW system registers on init */ + val.Reg64 =3D arm_cpu->midr; + whpx_set_reg(cpu, WHvArm64RegisterMidrEl1, + val); + + clean_whv_register_value(&val); + + val.Reg64 =3D deposit64(arm_cpu->mp_affinity, 31, 1, 1 /* RES1 */); + whpx_set_reg(cpu, WHvArm64RegisterMpidrEl1, val); + + return 0; + +error: + g_free(vcpu); + + return ret; + +} + +void whpx_cpu_instance_init(CPUState *cs) +{ +} + +int whpx_accel_init(AccelState *as, MachineState *ms) +{ + struct whpx_state *whpx; + int ret; + HRESULT hr; + WHV_CAPABILITY whpx_cap; + UINT32 whpx_cap_size; + WHV_PARTITION_PROPERTY prop; + WHV_CAPABILITY_FEATURES features =3D {0}; + + whpx =3D &whpx_global; + /* on arm64 Windows Hypervisor Platform, vGICv3 always used */ + whpx->kernel_irqchip =3D true; + + if (!init_whp_dispatch()) { + ret =3D -ENOSYS; + goto error; + } + + whpx->mem_quota =3D ms->ram_size; + + hr =3D whp_dispatch.WHvGetCapability( + WHvCapabilityCodeHypervisorPresent, &whpx_cap, + sizeof(whpx_cap), &whpx_cap_size); + if (FAILED(hr) || !whpx_cap.HypervisorPresent) { + error_report("WHPX: No accelerator found, hr=3D%08lx", hr); + ret =3D -ENOSPC; + goto error; + } + + hr =3D whp_dispatch.WHvGetCapability( + WHvCapabilityCodeFeatures, &features, sizeof(features), NULL); + if (FAILED(hr)) { + error_report("WHPX: Failed to query capabilities, hr=3D%08lx", hr); + ret =3D -EINVAL; + goto error; + } + + if (!features.Arm64Support) { + error_report("WHPX: host OS exposing pre-release WHPX implementati= on. " + "Please update your operating system to at least build 26100.3= 915"); + ret =3D -EINVAL; + goto error; + } + + hr =3D whp_dispatch.WHvCreatePartition(&whpx->partition); + if (FAILED(hr)) { + error_report("WHPX: Failed to create partition, hr=3D%08lx", hr); + ret =3D -EINVAL; + goto error; + } + + memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY)); + prop.ProcessorCount =3D ms->smp.cpus; + hr =3D whp_dispatch.WHvSetPartitionProperty( + whpx->partition, + WHvPartitionPropertyCodeProcessorCount, + &prop, + sizeof(WHV_PARTITION_PROPERTY)); + + if (FAILED(hr)) { + error_report("WHPX: Failed to set partition processor count to %u," + " hr=3D%08lx", prop.ProcessorCount, hr); + ret =3D -EINVAL; + goto error; + } + + if (!whpx->kernel_irqchip_allowed) { + error_report("WHPX: on Arm, only kernel-irqchip=3Don is currently = supported"); + ret =3D -EINVAL; + goto error; + } + + memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY)); + + hr =3D whp_dispatch.WHvSetupPartition(whpx->partition); + if (FAILED(hr)) { + error_report("WHPX: Failed to setup partition, hr=3D%08lx", hr); + ret =3D -EINVAL; + goto error; + } + + whpx_memory_init(); + + return 0; + +error: + + if (NULL !=3D whpx->partition) { + whp_dispatch.WHvDeletePartition(whpx->partition); + whpx->partition =3D NULL; + } + + return ret; +} --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759437; cv=none; d=zohomail.com; s=zohoarc; b=OhooLVZ9w5Lz3zRB13sVqFXdC2lPsQ39VJZ8CF434BC/VBQLXUk9YPUM2ck4VUOnJ4s1kDcxFE7CxYTVcc2VkKIsCuf4zuJ1bMwlQEJZEPok1AhjT+EJ0LPooDkNuTEIqjbDXpBzNDBAFaFLHc1lqgu54Gelrf01BfnVRjTCZUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759437; 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=xJAo1UBdZ8OCZhRCAjdQFGpLMCFJEpy5JZqSAAb7aX8=; b=EnBtAyzNuuUpdM7AEetUrYr9aeOGjsKO+712QerocSdxc3fQQ5JAGQNYTAr2X+2+G96c6PpjCqkHUElnFTGHZRAep0zQ/SDLn1Twx9tysbmTw+hAwFe+Q2XAPYV+fteNmbCXsS4Yb8vjgBHCQLVovciUdTdTUZQHN4zvFiF6mQw= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759437780192.5319123419656; Wed, 29 Oct 2025 10:37:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5c-0003dI-Gd; Wed, 29 Oct 2025 13:36:04 -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 1vEA5W-0003ax-LT for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:58 -0400 Received: from p-east2-cluster1-host9-snip4-10.eps.apple.com ([57.103.76.113] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5G-0003Lo-78 for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:35:58 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id B6A9C1824491; Wed, 29 Oct 2025 17:35:27 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 5A47518076DB; Wed, 29 Oct 2025 16:55:40 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=xJAo1UBdZ8OCZhRCAjdQFGpLMCFJEpy5JZqSAAb7aX8=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=X4pJiibYhti+2D/uvrYZPeN82ScQbo0ZH2GNgDOt2N6fOrTUJCi1yqgZzZcjZvBAH1nofp/jlJXl1suSjXtSaSe8cMep19j/qpJbBoS14HVXypwkfKUatQ8e4DSgwa7yTlz7/OsaavquYygzmUb580Mh4KwQ3nacOFXnxvNKgbh1VDrlNDetOY39dIWo5DSdsi9q9NGBth7iDvoggTa0Nb09YwNS+JX0SZSJ/pydMIJheNsPeirurLdEnqY4JBxfURwAIYBO0MzQtnoYLKRHYYQcvj4WdJMQzHh6GjUsmEOce+wE+NQDjNsVMroLJyfFKR4IXWSS3WghrSf7vHpQiA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v10 13/28] whpx: change memory management logic Date: Wed, 29 Oct 2025 17:54:55 +0100 Message-ID: <20251029165510.45824-14-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: KLsQIPo04_gTGx1Y4AoWkeQG4ohI7u6D X-Proofpoint-GUID: KLsQIPo04_gTGx1Y4AoWkeQG4ohI7u6D X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfXzqlEouIAHAy4 qqyV7KRZdRCljmjeEk6aa4qkq5tWyyK6KMG3T35iMvwRTBJeQaQpn3L+LkNgdAR8Do0+0U1Fv3r ccxOEpZSph9Djz8CzabufvYqM3UCg15AjXLc0Cmb7g4cMU/Zb9Y1CffpL/WuuBgx0gh+ybA0om+ che6FMPEveyfqH9NL2UBUlam66XLZn5AWkcyQIxCDpHPSvkcxjmyeWNdDCBWd1z26wLzJS2cSe0 eE9Eg9ikxay3ruePdqQ2P6TOZzikI5RPi0UBBUQVzMmVBnt1aNk4J1Xrh7Fv8N4d3igmZI7Sg= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 adultscore=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 mlxlogscore=963 clxscore=1030 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABmYl7oBGtiQGRAMK1r6hwErmrBUsLvDEt5FXthu1IeVXZd3Oz+cAkj3dtdtXjmDkk+3pYfxQIfTiQMwAqUcmT2B4tFTgyl1f1TstOuXfh2q+KJRV0llpFT/5WcG86pjQbRL6/kMaa7EyV0E0E+zakaw3sfPgzp559fkcsS/FiE0tjSRFYwoBfJTt7CrKb2X0ztDMCRgzHLCUlFgXMZJoA54k9R1/V/bZv6SifxMVdGt4ATo1LluTS9MM4blvDIxVb6AnqbwAzxSlVcZjIRGJzzK2SYZd1TahTUgH2pL8xqlrTYYNOZs6UmfKHYYwwMPg/icEMtnmv/SiKQjRNil15oKEa8YiYKXaExzVkUU1UrbiGMsds2B3vLWQfvfCtfoKe/2qHlPGYvU++hVKFEPH/CtOBHFD8MW/1CF03fFTu+W7XEGC7eEFXGl852ZT2tCzYnXNWpGLSMPjtOQua6StihFTQIJ4O1oC5koNB/+QEt3a1Clj1zrAW/DDQ4H4wo60Lco4Vuh2vXnujsMPuAtkyyTCrvIWT84ASgReX7WQgBvPwZrHJ0XgzBNU4ciXk/bmtfNC+9z/Nxtyj6UgtK1fDWWs4AHCb6uaIEz1u5oeHcIOdYNyXdCbIj07P+WM8x2drp0X/jEekRoi0U49NpfCUe08fhoW5dHpeAb+ujzRJYRj5uk7pqU7x/LaOry+XIGvwT1f/00KFFSL35oBK0ZzpPtcqDj2EmKoCiV/ee4DXT+Ah1GzbDxTtDMkHxJwtWw== 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=57.103.76.113; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1761759440040158500 Content-Type: text/plain; charset="utf-8" This allows edk2 to work on Arm, although u-boot is still not functional. Signed-off-by: Mohamed Mediouni --- accel/whpx/whpx-common.c | 101 +++++++++++++++------------------------ 1 file changed, 38 insertions(+), 63 deletions(-) diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c index c69792e638..aefec4bc8f 100644 --- a/accel/whpx/whpx-common.c +++ b/accel/whpx/whpx-common.c @@ -258,89 +258,64 @@ void whpx_vcpu_kick(CPUState *cpu) * Memory support. */ =20 -static void whpx_update_mapping(hwaddr start_pa, ram_addr_t size, - void *host_va, int add, int rom, - const char *name) +static void whpx_set_phys_mem(MemoryRegionSection *section, bool add) { struct whpx_state *whpx =3D &whpx_global; - HRESULT hr; - - /* - if (add) { - printf("WHPX: ADD PA:%p Size:%p, Host:%p, %s, '%s'\n", - (void*)start_pa, (void*)size, host_va, - (rom ? "ROM" : "RAM"), name); - } else { - printf("WHPX: DEL PA:%p Size:%p, Host:%p, '%s'\n", - (void*)start_pa, (void*)size, host_va, name); - } - */ - - if (add) { - hr =3D whp_dispatch.WHvMapGpaRange(whpx->partition, - host_va, - start_pa, - size, - (WHvMapGpaRangeFlagRead | - WHvMapGpaRangeFlagExecute | - (rom ? 0 : WHvMapGpaRangeFlagWri= te))); - } else { - hr =3D whp_dispatch.WHvUnmapGpaRange(whpx->partition, - start_pa, - size); - } - - if (FAILED(hr)) { - error_report("WHPX: Failed to %s GPA range '%s' PA:%p, Size:%p byt= es," - " Host:%p, hr=3D%08lx", - (add ? "MAP" : "UNMAP"), name, - (void *)(uintptr_t)start_pa, (void *)size, host_va, h= r); + MemoryRegion *area =3D section->mr; + bool writable =3D !area->readonly && !area->rom_device; + WHV_MAP_GPA_RANGE_FLAGS flags; + uint64_t page_size =3D qemu_real_host_page_size(); + uint64_t gva =3D section->offset_within_address_space; + uint64_t size =3D int128_get64(section->size); + HRESULT res; + void *mem; + + if (!memory_region_is_ram(area)) { + if (writable) { + return; + } else if (!memory_region_is_romd(area)) { + add =3D false; + } } -} - -static void whpx_process_section(MemoryRegionSection *section, int add) -{ - MemoryRegion *mr =3D section->mr; - hwaddr start_pa =3D section->offset_within_address_space; - ram_addr_t size =3D int128_get64(section->size); - unsigned int delta; - uint64_t host_va; =20 - if (!memory_region_is_ram(mr)) { - return; + if (!QEMU_IS_ALIGNED(size, page_size) || + !QEMU_IS_ALIGNED(gva, page_size)) { + /* Not page aligned, so we can not map as RAM */ + add =3D false; } =20 - delta =3D qemu_real_host_page_size() - (start_pa & ~qemu_real_host_pag= e_mask()); - delta &=3D ~qemu_real_host_page_mask(); - if (delta > size) { - return; - } - start_pa +=3D delta; - size -=3D delta; - size &=3D qemu_real_host_page_mask(); - if (!size || (start_pa & ~qemu_real_host_page_mask())) { + if (!add) { + res =3D whp_dispatch.WHvUnmapGpaRange(whpx->partition, + gva, size); + if (!SUCCEEDED(res)) { + error_report("WHPX: failed to unmap GPA range"); + abort(); + } return; } =20 - host_va =3D (uintptr_t)memory_region_get_ram_ptr(mr) - + section->offset_within_region + delta; + flags =3D WHvMapGpaRangeFlagRead | WHvMapGpaRangeFlagExecute + | (writable ? WHvMapGpaRangeFlagWrite : 0); + mem =3D memory_region_get_ram_ptr(area) + section->offset_within_regio= n; =20 - whpx_update_mapping(start_pa, size, (void *)(uintptr_t)host_va, add, - memory_region_is_rom(mr), mr->name); + res =3D whp_dispatch.WHvMapGpaRange(whpx->partition, + mem, gva, size, flags); + if (!SUCCEEDED(res)) { + error_report("WHPX: failed to map GPA range"); + abort(); + } } =20 static void whpx_region_add(MemoryListener *listener, MemoryRegionSection *section) { - memory_region_ref(section->mr); - whpx_process_section(section, 1); + whpx_set_phys_mem(section, true); } =20 static void whpx_region_del(MemoryListener *listener, MemoryRegionSection *section) { - whpx_process_section(section, 0); - memory_region_unref(section->mr); + whpx_set_phys_mem(section, false); } =20 static void whpx_transaction_begin(MemoryListener *listener) --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759711; cv=none; d=zohomail.com; s=zohoarc; b=RrFits/br2BFD/D06lq2+CL7B+VUH3FMiFwdTx9UbREC5ow1W4EAdlnGtVP7pe8vp7oDy+jKu0FRIuHPHFHmsv8oMN3p5HRPDaDQYwcee/kHiFTTHJDUDWXLTkzcJjq04K3YWStGyGEdwl7+Q6FCM24aoTD9mtx7InK3TeMxI9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759711; 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=4aQelUdZ9m4SoQ1tmmqgdVsoa/ORFIMr7NbmJ7jciug=; b=Qch+Se1hHRcWH0f0w/nmOyXLITg1NinXUFN8yPzyUbB5+v1RZ9958WdTuRs7FxVfDOsNOY0ft90hSKHtBmI0gYLllMa9cNONIWldxMIwRDllEwPGVw0pJ6hnOlBuVJ2P9csL5n5llbw+HlHbsU3HvnP7hzwrakaOSMhIa0hic2o= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176175971193639.40746257301714; Wed, 29 Oct 2025 10:41:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA6C-00048Y-Kg; Wed, 29 Oct 2025 13:36: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 1vEA5l-0003k2-IL for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:15 -0400 Received: from p-east2-cluster1-host9-snip4-7.eps.apple.com ([57.103.76.110] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5N-0003Pn-Km for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:12 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 9538A182449F; Wed, 29 Oct 2025 17:35:28 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id EE7F6185FF7A; Wed, 29 Oct 2025 16:55:41 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=4aQelUdZ9m4SoQ1tmmqgdVsoa/ORFIMr7NbmJ7jciug=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=VnlrXa5pebXRkSMg9bcR5I1O9LkCMAxLL43A8tK9JHbLCZa+Xd5iTgez697eU42ZAZoB3AB0TId6HBGsfGZeAHC4YcuEexNyx+ipIkcGvIXxraEVEWuk5w0NZaQmHQYKBmegH+g1gGh+dWBp5cS7JIzpqq7Sknha5P0Ci/VZ1inQ3Y1HbXOVI6/voeUIJENjRMsIm5webD9MOmJVlBCtHRKgvxjxDO1Jcy9H6pSpx5Xqm+7KcQoJLeSWU1eBZUCaFync3AzU1B4qIc7yVUvtx5fkAlIAk0affDFJsk3IceYZSOvadPOLdwHurwJxsybCI7DsGRt2laSQQwCzmig7Bg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 14/28] target/arm: cpu: mark WHPX as supporting PSCI 1.3 Date: Wed, 29 Oct 2025 17:54:56 +0100 Message-ID: <20251029165510.45824-15-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: XVwXTaBgHgbtaUkLZl6OJbIZYnlkjLAl X-Proofpoint-GUID: XVwXTaBgHgbtaUkLZl6OJbIZYnlkjLAl X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX628+cXcFydB2 Ph0tNUABYNqG+oH31qafm6ixXDtW7Xc2bHRAYCNjW5KoEr2BgCuogjxoP3iF+VQc4aBDCZZamgH pSRn2AtddkozM6HO5VvNn7KM1IFn6wlcAS97JVwSSsSnKytvBgQRxIpBqIDwFmAsYv4Q80uhE1B mfl5QdYsYn5RWPE5jqk1q66HcvHa7b1PBn82eV5S7NUPcgsCzx6YsL7uwFfazYWL73wQvnbXMeW mEUsi6XPNHxzqFbCPiQJQ0RgJGTlQemILFaAAiroXkY58sr3YlGvo7TvKRMBavX+wFbXnNOVY= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 phishscore=0 spamscore=0 mlxscore=0 clxscore=1030 malwarescore=0 bulkscore=0 mlxlogscore=690 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAAB9ImGYfVemxyrS+w21SXu1jD1nU/XN21WB1Ow3Mhb9uAFUQHy0femL62Rzg9W2YiXlrbbVFR8xZUR8NYQl93gV9sPL2/3SZsRUnDJjN69qwFC4cZr3+G6GjnE0ru9b3iZwxhETL78QFMFCO6MZGyNPP0OQFbqylPU2VlZJugd/saNJAZR6HWhiPfYijy33LMkOnmQQCv5vR67KyllK5M0WR8iNHAno/yfqXPr9F0p6YQeBySGbXahLaTnZ+QBSZJzKxpOcunVB8b9MCLVHg6/qbfMLOkrYsOXboH9mCnlbx89qAyc5704s55JvlSim9xoDmZDCvmkvav13KaL75oc593/3oGTaVD8QWDTfvCRlqSn5ua1Uflex7cAkTj25QkA2WCZnztwU0Q7mA41zGpKwP1gsg8e3gLUpcWjmsUxVzX+EHL05iwQn/1F5KIlmiECHsMSb+8N6lsVVpz15goqtpQYszRYJtn0vI67qOZdQ6ksbJK6wAXQzJQ0imSdhxVGjQ3DaTbiHA/8WDXXgvQViQk8Hxz8QWI+GvMvZ4Us4XbDkod60lvZE3Z3ULWvhGy8qpsZaD4Vr4uQyscRTc7Z4WDDkiLC43BqcXnpZF/wEZJQ1BC84q69B2QHP0HHx8vYZOS+D7ccElXL7yFhN2ZBwUZzooks/bI1LosyHIrV3xs99QYB8Ramsw326u280BXB4pVfk6KY08k2aAMpnaPm3g5qEREWa0ImQZY7w5U1kNcS6NQfDls6vM+XJOJepELzx7BDHBuUCArls9w63x0uR25EstvsbtJF3KOqkZrWLg== 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=57.103.76.110; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1761759715244158500 Content-Type: text/plain; charset="utf-8" Hyper-V supports PSCI 1.3, and that implementation is exposed through WHPX. Signed-off-by: Mohamed Mediouni Reviewed-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- target/arm/cpu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index d2fc17eab6..854b46f40a 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -23,6 +23,7 @@ #include "qemu/timer.h" #include "qemu/log.h" #include "exec/page-vary.h" +#include "system/whpx.h" #include "target/arm/idau.h" #include "qemu/module.h" #include "qapi/error.h" @@ -1143,6 +1144,8 @@ static void arm_cpu_initfn(Object *obj) if (tcg_enabled() || hvf_enabled()) { /* TCG and HVF implement PSCI 1.1 */ cpu->psci_version =3D QEMU_PSCI_VERSION_1_1; + } else if (whpx_enabled()) { + cpu->psci_version =3D QEMU_PSCI_VERSION_1_3; } } =20 --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759438; cv=none; d=zohomail.com; s=zohoarc; b=U5yQdEmyrDiVBL5FM8uoiuh+QLRwK+a7i9s4D7l17iTIkP6yzfRHBwpzP5qSJu+gQGoSh0zOWvTgEaXs1NhbTiiW0sM9Zen2vwWcVhdZcNUOIPN9a2GcUQTV86/2TiAyN+rSMaS0mwq4OTCMQmUCO0kxq6X7OGN65Y10OT1A0sM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759438; 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=jXPIkvwftnVZHRg4Mjz/B4doNai4bCzAxKe4sYL/QI8=; b=Tu8p3j6s/GzEIz4GMYWjQkjJdt/ccM1PUwweYWygkvSgkecH0gJaSCr6uDHBt0MLKJr2DQNKHU06+Shk2fFWh5oZyZamvuxThdlI590aD9+OPHqP2bJWOshBY0gFh43r73eLGb4EDDMHmv+4iTH4t4/EphmcBP4z7tEsX5jgVMw= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759438944907.9920600685406; Wed, 29 Oct 2025 10:37:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA6A-00045j-UD; Wed, 29 Oct 2025 13:36: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 1vEA5s-0003pZ-2B for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:22 -0400 Received: from p-east2-cluster4-host2-snip4-1.eps.apple.com ([57.103.78.162] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5S-0003QK-8C for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:19 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id E48C5182449C; Wed, 29 Oct 2025 17:35:29 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 929AC1859E7F; Wed, 29 Oct 2025 16:55:43 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=jXPIkvwftnVZHRg4Mjz/B4doNai4bCzAxKe4sYL/QI8=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=VI5BEDOUZ0wpMa8WLJel5uRrxlFR4XCHGrfQ+4I2z2T5v0rqEra702BRSLbM7e6PHaPtv7Hq2+9Oer238Ud8/SLUhPEuBZEE0g88bFA2EXrb6NAvBBlx7beypI8aSgDWQr7/P4cg4drHWYb/7jIcBOGHDuakSMWs3ErwRHEQ1QK936NZHb/wgr5f5dsc6ik936otAUvTgKwamUtRttnaGy+vuoLQIEAkmqZ2YkTg+1YcbrAfjflGjHuldcEXGj+BVYE7s8Oifi03kffJaBlwy21xYt9fp7eRU0slQuenB2GLy6HQwnWkwXZ9CXz7QpNRa4B5NXy1n1Kls6qJ6y4QDg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v10 15/28] hw/arm: virt: cleanly fail on attempt to use the platform vGIC together with ITS Date: Wed, 29 Oct 2025 17:54:57 +0100 Message-ID: <20251029165510.45824-16-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: 5FJ96SY-4GqKLTxw1XGc8AYppsT211T7 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX25SvIoRy8gr5 tFhfGXuBm4QCuiQl8Nzur7HAnAT5uX/+fLuk2Elasja1g4Vkff8h6++pSM2q3Fulr1m/rOooPWu sKfI6MmSaa6Pu0ifMo28VIZtwvL+scfMyIRdE9LbAshtA6LYBEbP6YMPnqoUE3RcMsmlVGyEdB2 k0VtCBkn36Xvg9+8HiMKgITqwhQ5wlK0mK6qblAd7tocwwkLo+psuOZPx1tdH4oc7XaA74KxdtX ZxCZuL+ISS8J9pXPnrGoPX0JcAqYERNDMY2+YBL5C5zNJimovtVCn8qEFyGLQ5fOdqrpGMb9E= X-Proofpoint-GUID: 5FJ96SY-4GqKLTxw1XGc8AYppsT211T7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 suspectscore=0 bulkscore=0 spamscore=0 mlxlogscore=798 malwarescore=0 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABBkN3elvJAtNm4Vlco2NM6jhwqtq7ocWb/w/4rIe3doHUnH/i37fCWFkVdZ/jEAC4uh3gC1xDC9otGxRqUIgDAYi/eHbWe+fAcXzq0tAwU0MvlQuGDEdOZP8GyE7KB9nfKee7F8uIeg35hI5RAEIE5iqE1t1xAs1nOSsBqHDEoo5hjk7l6F+dfUAfh+MW4z6RMvRWGjYQo/4mCGcD1406NDF1Y+oTFUWeT6QRyBkOthTYbrILuoWQJPOZZZDuVSunVRosnbLPOXi4xPb45duwgwLu5nhjj+Mxg3Fh+n3N+n1T8HzqI9md3Flg9dq+T0L8nUG9wfguuaA7crWt/SDVc0+sMEHkxfmZpoNf4xB5+jgSzGM08ZRTw825sbZlzLDaADPOqrOzURfXcDhbkYX4FxwLD2gzi0JB36/4/7ODkMdNuvqaVYOmNACOobzD7unXthovLOaH9pJ/v1T/Wb+5QXH+RZl2Sou9FeC2ZyNKiMI9xJkAVKlQpuugErAXBPsrk0xab7H8rqyvmc4/wlwBSx3FxrA+Hc5g53+x3BH4ziVAH0CyQabQW2mwqwBmXKzAA3SKCRhMGplm+cop1enyprQeDAN8/4DqX2b8U9q+89QjRAy3puEhzInny6rCBTZnw/P/lhYMykdOXHhV33wSLk6vDvclKSWh9kXq56s8WbiFsPc0Y7K2fE8T+6fAZEDU7nw++vsNKQ0zJdZWyDTOOpXyWq+o98FHZaNUV3BmVN17zTnIxpsGkY6MIg== 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=57.103.78.162; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1761759440067158500 Content-Type: text/plain; charset="utf-8" Switch its to a tristate. Windows Hypervisor Platform's vGIC doesn't support ITS. Deal with this by reporting to the user and exiting. Regular configuration: GICv3 + ITS New default configuration with WHPX: GICv3 with GICv2m And its=3Doff explicitly for the newest machine version: GICv3 + GICv2m Signed-off-by: Mohamed Mediouni --- hw/arm/virt-acpi-build.c | 15 +++++++------ hw/arm/virt.c | 46 +++++++++++++++++++++++++++++++--------- include/hw/arm/virt.h | 4 +++- 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 0a6ec74aa0..8e730731ca 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -472,7 +472,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) nb_nodes =3D num_smmus + 1; /* RC and SMMUv3 */ rc_mapping_count =3D rc_smmu_idmaps_len; =20 - if (vms->its) { + if (virt_is_its_enabled(vms)) { /* * Knowing the ID ranges from the RC to the SMMU, it's possibl= e to * determine the ID ranges from RC that go directly to ITS. @@ -483,7 +483,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) rc_mapping_count +=3D rc_its_idmaps->len; } } else { - if (vms->its) { + if (virt_is_its_enabled(vms)) { nb_nodes =3D 2; /* RC and ITS */ rc_mapping_count =3D 1; /* Direct map to ITS */ } else { @@ -498,7 +498,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) build_append_int_noprefix(table_data, IORT_NODE_OFFSET, 4); build_append_int_noprefix(table_data, 0, 4); /* Reserved */ =20 - if (vms->its) { + if (virt_is_its_enabled(vms)) { /* Table 12 ITS Group Format */ build_append_int_noprefix(table_data, 0 /* ITS Group */, 1); /* Ty= pe */ node_size =3D 20 /* fixed header size */ + 4 /* 1 GIC ITS Identif= ier */; @@ -517,7 +517,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) int smmu_mapping_count, offset_to_id_array; int irq =3D sdev->irq; =20 - if (vms->its) { + if (virt_is_its_enabled(vms)) { smmu_mapping_count =3D 1; /* ITS Group node */ offset_to_id_array =3D SMMU_V3_ENTRY_SIZE; /* Just after the h= eader */ } else { @@ -610,7 +610,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) } } =20 - if (vms->its) { + if (virt_is_its_enabled(vms)) { /* * Map bypassed (don't go through the SMMU) RIDs (input) to * ITS Group node directly: RC -> ITS. @@ -945,7 +945,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) memmap[VIRT_HIGH_GIC_REDIST2].si= ze); } =20 - if (vms->its) { + if (virt_is_its_enabled(vms)) { /* * ACPI spec, Revision 6.0 Errata A * (original 6.0 definition has invalid Length) @@ -961,7 +961,8 @@ build_madt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) } } =20 - if (!(vms->gic_version !=3D VIRT_GIC_VERSION_2 && vms->its) && !vms->n= o_gicv3_with_gicv2m) { + if (!(vms->gic_version !=3D VIRT_GIC_VERSION_2 && virt_is_its_enabled(= vms)) + && !vms->no_gicv3_with_gicv2m) { const uint16_t spi_base =3D vms->irqmap[VIRT_GIC_V2M] + ARM_SPI_BA= SE; =20 /* 5.2.12.16 GIC MSI Frame Structure */ diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 9121eb37eb..dbf9a28b8d 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -735,7 +735,7 @@ static void create_its(VirtMachineState *vms) { DeviceState *dev; =20 - assert(vms->its); + assert(virt_is_its_enabled(vms)); if (!kvm_irqchip_in_kernel() && !vms->tcg_its) { /* * Do nothing if ITS is neither supported by the host nor emulated= by @@ -744,6 +744,15 @@ static void create_its(VirtMachineState *vms) return; } =20 + if (whpx_enabled() && vms->tcg_its) { + /* + * Signal to the user when ITS is neither supported by the host + * nor emulated by the machine. + */ + info_report("ITS not supported on WHPX."); + exit(1); + } + dev =3D qdev_new(its_class_name()); =20 object_property_set_link(OBJECT(dev), "parent-gicv3", OBJECT(vms->gic), @@ -955,7 +964,7 @@ static void create_gic(VirtMachineState *vms, MemoryReg= ion *mem) =20 fdt_add_gic_node(vms); =20 - if (vms->gic_version !=3D VIRT_GIC_VERSION_2 && vms->its) { + if (vms->gic_version !=3D VIRT_GIC_VERSION_2 && virt_is_its_enabled(vm= s)) { create_its(vms); } else if (vms->gic_version !=3D VIRT_GIC_VERSION_2 && !vms->no_gicv3_= with_gicv2m) { create_v2m(vms); @@ -2705,18 +2714,34 @@ static void virt_set_highmem_mmio_size(Object *obj,= Visitor *v, extended_memmap[VIRT_HIGH_PCIE_MMIO].size =3D size; } =20 -static bool virt_get_its(Object *obj, Error **errp) +bool virt_is_its_enabled(VirtMachineState *vms) +{ + if (vms->its =3D=3D ON_OFF_AUTO_OFF) { + return false; + } + if (vms->its =3D=3D ON_OFF_AUTO_AUTO) { + if (whpx_enabled()) { + return false; + } + } + return true; +} + +static void virt_get_its(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(obj); + OnOffAuto its =3D vms->its; =20 - return vms->its; + visit_type_OnOffAuto(v, name, &its, errp); } =20 -static void virt_set_its(Object *obj, bool value, Error **errp) +static void virt_set_its(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(obj); =20 - vms->its =3D value; + visit_type_OnOffAuto(v, name, &vms->its, errp); } =20 static bool virt_get_dtb_randomness(Object *obj, Error **errp) @@ -3426,8 +3451,9 @@ static void virt_machine_class_init(ObjectClass *oc, = const void *data) "guest CPU which implements the = ARM " "Memory Tagging Extension"); =20 - object_class_property_add_bool(oc, "its", virt_get_its, - virt_set_its); + object_class_property_add(oc, "its", "OnOffAuto", + virt_get_its, virt_set_its, + NULL, NULL); object_class_property_set_description(oc, "its", "Set on/off to enable/disable " "ITS instantiation"); @@ -3487,8 +3513,8 @@ static void virt_instance_init(Object *obj) vms->highmem_mmio =3D true; vms->highmem_redists =3D true; =20 - /* Default allows ITS instantiation */ - vms->its =3D true; + /* Default allows ITS instantiation if available */ + vms->its =3D ON_OFF_AUTO_AUTO; /* Allow ITS emulation if the machine version supports it */ vms->tcg_its =3D !vmc->no_tcg_its; vms->no_gicv3_with_gicv2m =3D false; diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index d31348dd61..997dd51678 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -149,7 +149,7 @@ struct VirtMachineState { bool highmem_ecam; bool highmem_mmio; bool highmem_redists; - bool its; + OnOffAuto its; bool tcg_its; bool virt; bool ras; @@ -218,4 +218,6 @@ static inline int virt_gicv3_redist_region_count(VirtMa= chineState *vms) vms->highmem_redists) ? 2 : 1; } =20 +bool virt_is_its_enabled(VirtMachineState *vms); + #endif /* QEMU_ARM_VIRT_H */ --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759856; cv=none; d=zohomail.com; s=zohoarc; b=jlR4p5adW/bWORbVxUqV2+pFY2uR8oLbiisbE1M0a4vkGOiz8WFUQvKad6JTJRIUoS6L4qEhek5h1xCDF469LqHWxEaKL0JTg3l49PoxKB82AOwJDzMe9AxIli1mPLgFettn8k2pvxc2KPmh9YoMZyCFLuH9aWVnNjMnmhcjzII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759856; 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=KLJXCxRspSRDpfdk3bPZ4+2wmalBnWy7d7qziX03lt0=; b=N6aKX+3IyT9zoVL9R3sPoq4RjUJNtaLzOM24HfUEVccSFaEQVuRoprQ02CbgVNmb4sdCO3VzEKJtHDPLMbSPvxbV8BCL/wXw2JF0oWbprGOdZRC87CVhujF36bHcmJeJiOONmI1Fa5gVAY9MGFDu7fpasiNPxX8ztyYZE7hzW8Y= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759856257268.7579020050414; Wed, 29 Oct 2025 10:44:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5d-0003ed-VH; Wed, 29 Oct 2025 13:36: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 1vEA5a-0003cg-So for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:03 -0400 Received: from p-east2-cluster1-host10-snip4-10.eps.apple.com ([57.103.76.123] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5G-0003ML-Ti for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:02 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 6BE44181D3AF; Wed, 29 Oct 2025 17:35:30 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id DBB271860BDB; Wed, 29 Oct 2025 16:55:45 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=KLJXCxRspSRDpfdk3bPZ4+2wmalBnWy7d7qziX03lt0=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=QdP+b2PVDIunvxDTUJ0lwUBWvCyRWJ5limi/mMg1uiAhEI8Vy7wJlF0kIHnvelqy3wxyyjUzAghJwhLw2ENzrEkrbyIBmSlZhEfhv2zJmBsAMq/suRmea2K7K69RpCoUDk4SRcN/U5SylCtO0Ms+tCamN9Q6p5KjM+XvTlpKoj4xrJmt+W7GK10cOv0pGVNFXfKb1hNFWqyQ7ayxPMhLlKFeeTz9JdWPy3Z/lmp5A7vhLcrbEVfttEeFa0q8Jk1+dREFXXFPyeNjYqfvFrU8JAQAjq+Bp7hU5xhJLhAOooRfY5MYRQj0dVj6uUhwghKKF7EWEJHdW3xEt5zjItYmiw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v10 16/28] hw: arm: virt: rework MSI-X configuration Date: Wed, 29 Oct 2025 17:54:58 +0100 Message-ID: <20251029165510.45824-17-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX5StY7zD41PW9 bQhbAZmxFWC3UDyKyMczHnAsbZwZG5f71ZwjlFB3perfd+B07ZIjJ1705s7bmUqXfB24G/Om/PB TLrcOMIpvLQmvQBEa9E53fuM/1vVVglq3ivOJk4vCy7Y+IAMIsEyU+Moe/xUP8vlViFFvl7yFm8 MsCO42w8ToA0cUgDQ6z9NLV1l/+4JdIll7C6xKS8VVqiTxBwnrEIyx8g8LqYUYp71QZ+ASuF9R1 LSMASsHv1w5QvVFYr9SFDiLQuZwrfr22kqq/t0OmszKNjgSkmuCH3aso9tj2SV77G1A9J/fkg= X-Proofpoint-GUID: QB6S3pWuXHPUIxWDIqwmSGqAoU-FumpJ X-Proofpoint-ORIG-GUID: QB6S3pWuXHPUIxWDIqwmSGqAoU-FumpJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxlogscore=774 adultscore=0 malwarescore=0 suspectscore=0 phishscore=0 mlxscore=0 clxscore=1030 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAAB7diNlRyUEBCFepte1Hz+B96bSckVQMsbzA9CJi8cTUArexr7WjTLr301k4uPJTwTO3JZfgiEX4TvpJ5eppFsJ2hDNvyILtrz+q9/tvKnn28LNp4eKTowtQ51gkzU1UofDsAVZdmC9Q7yoQhReUWkxyXowsvlVyEaHAghtARoWWw5jwfsCdhOK0I7Hi02A0p4Icm028bq3kQ24cJVkwhVpSbohU5QhivRpCqbvooupt18YJ0kROVb2O7QU2TmAcI/VNGknsnNT5fiBt213UIYoM2D4q6GS5DeQTXyNV1MOZUoGea/thzpmCTiLSM3TpY35wC6svqoBM4i921FHYq1jn627S74lg888l9OmN67AOagVx0lK/4dBm+GN/hpBsgpJdpuc+Y90IqFlv19lSMR+gvWTrMH/j8cdkbj/L+nwBPJvvDJYAe1mdb5AeH9G+H7k1sFtafk1jlumqTonr3/HEXnRgSVrk3Tm5E2TDjqJ+rEOrXyX0uvcyzr8A9IsEIq2EOZoOiSHhjU7m9lR5Q11u2bEy+QTt3e6K64S2jWjqUY0SBlTfddKjZXhOtAUS4e6scNauMkY4QpWVyIGR8d9EdkbDVa9oVNMSvniTDz/KiNcZM4BYB7+KXL1lM1bspZJVkhW/6OR+bWJGmA1hQyW1o1v5cMvMguZppsL/+ZYaci40unCTwNOATCglovTEnxLn8b9kBrmYKP1esU6wvKOQTi6Vl0cjaH5hfbSLTk45pBnAz1BA== 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=57.103.76.123; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759858998158500 Content-Type: text/plain; charset="utf-8" Introduce a -M msi=3D argument to be able to control MSI-X support independ= ently from ITS, as part of supporting GICv3 + GICv2m platforms. Remove vms->its as it's no longer needed after that change. Signed-off-by: Mohamed Mediouni --- hw/arm/virt-acpi-build.c | 3 +- hw/arm/virt.c | 110 +++++++++++++++++++++++++++++++-------- include/hw/arm/virt.h | 4 +- 3 files changed, 93 insertions(+), 24 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 8e730731ca..a6a56455a9 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -961,8 +961,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) } } =20 - if (!(vms->gic_version !=3D VIRT_GIC_VERSION_2 && virt_is_its_enabled(= vms)) - && !vms->no_gicv3_with_gicv2m) { + if (virt_is_gicv2m_enabled(vms)) { const uint16_t spi_base =3D vms->irqmap[VIRT_GIC_V2M] + ARM_SPI_BA= SE; =20 /* 5.2.12.16 GIC MSI Frame Structure */ diff --git a/hw/arm/virt.c b/hw/arm/virt.c index dbf9a28b8d..6978d4e867 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -964,12 +964,12 @@ static void create_gic(VirtMachineState *vms, MemoryR= egion *mem) =20 fdt_add_gic_node(vms); =20 - if (vms->gic_version !=3D VIRT_GIC_VERSION_2 && virt_is_its_enabled(vm= s)) { + if (virt_is_its_enabled(vms)) { create_its(vms); - } else if (vms->gic_version !=3D VIRT_GIC_VERSION_2 && !vms->no_gicv3_= with_gicv2m) { - create_v2m(vms); - } else if (vms->gic_version =3D=3D VIRT_GIC_VERSION_2) { + } else if (virt_is_gicv2m_enabled(vms)) { create_v2m(vms); + } else { + vms->msi_controller =3D VIRT_MSI_CTRL_NONE; } } =20 @@ -2716,32 +2716,93 @@ static void virt_set_highmem_mmio_size(Object *obj,= Visitor *v, =20 bool virt_is_its_enabled(VirtMachineState *vms) { - if (vms->its =3D=3D ON_OFF_AUTO_OFF) { - return false; + switch (vms->msi_controller) { + case VIRT_MSI_CTRL_NONE: + return false; + case VIRT_MSI_CTRL_ITS: + return true; + case VIRT_MSI_CTRL_GICV2M: + return false; + case VIRT_MSI_CTRL_AUTO: + if (whpx_enabled() && whpx_irqchip_in_kernel()) { + return false; + } + if (vms->gic_version =3D=3D VIRT_GIC_VERSION_2) { + return false; + } + return true; + default: + return false; } - if (vms->its =3D=3D ON_OFF_AUTO_AUTO) { - if (whpx_enabled()) { +} + +bool virt_is_gicv2m_enabled(VirtMachineState *vms) +{ + switch (vms->msi_controller) { + case VIRT_MSI_CTRL_NONE: return false; - } + default: + return !virt_is_its_enabled(vms); } - return true; } =20 -static void virt_get_its(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) +static char *virt_get_msi(Object *obj, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + const char *val; + + switch (vms->msi_controller) { + case VIRT_MSI_CTRL_NONE: + val =3D "off"; + break; + case VIRT_MSI_CTRL_ITS: + val =3D "its"; + break; + case VIRT_MSI_CTRL_GICV2M: + val =3D "gicv2m"; + default: + val =3D "auto"; + break; + } + return g_strdup(val); +} + +static void virt_set_msi(Object *obj, const char *value, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(obj); - OnOffAuto its =3D vms->its; =20 - visit_type_OnOffAuto(v, name, &its, errp); + if (!strcmp(value, "auto")) { + vms->msi_controller =3D VIRT_MSI_CTRL_AUTO; /* Will be overriden l= ater */ + } else if (!strcmp(value, "its")) { + vms->msi_controller =3D VIRT_MSI_CTRL_ITS; + } else if (!strcmp(value, "gicv2m")) { + vms->msi_controller =3D VIRT_MSI_CTRL_GICV2M; + } else if (!strcmp(value, "none")) { + vms->msi_controller =3D VIRT_MSI_CTRL_NONE; + } else { + error_setg(errp, "Invalid msi value"); + error_append_hint(errp, "Valid values are auto, gicv2m, its, off\n= "); + } } =20 -static void virt_set_its(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) +static bool virt_get_its(Object *obj, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(obj); =20 - visit_type_OnOffAuto(v, name, &vms->its, errp); + return virt_is_its_enabled(vms); +} + +static void virt_set_its(Object *obj, bool value, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + if (value) { + vms->msi_controller =3D VIRT_MSI_CTRL_ITS; + } else if (vms->no_gicv3_with_gicv2m) { + vms->msi_controller =3D VIRT_MSI_CTRL_NONE; + } else { + vms->msi_controller =3D VIRT_MSI_CTRL_GICV2M; + } } =20 static bool virt_get_dtb_randomness(Object *obj, Error **errp) @@ -3068,6 +3129,8 @@ static void virt_machine_device_pre_plug_cb(HotplugHa= ndler *hotplug_dev, db_start =3D base_memmap[VIRT_GIC_V2M].base; db_end =3D db_start + base_memmap[VIRT_GIC_V2M].size - 1; break; + case VIRT_MSI_CTRL_AUTO: + g_assert_not_reached(); } resv_prop_str =3D g_strdup_printf("0x%"PRIx64":0x%"PRIx64":%u", db_start, db_end, @@ -3451,13 +3514,18 @@ static void virt_machine_class_init(ObjectClass *oc= , const void *data) "guest CPU which implements the = ARM " "Memory Tagging Extension"); =20 - object_class_property_add(oc, "its", "OnOffAuto", - virt_get_its, virt_set_its, - NULL, NULL); + object_class_property_add_bool(oc, "its", virt_get_its, + virt_set_its); object_class_property_set_description(oc, "its", "Set on/off to enable/disable " "ITS instantiation"); =20 + object_class_property_add_str(oc, "msi", virt_get_msi, + virt_set_msi); + object_class_property_set_description(oc, "msi", + "Set MSI settings. " + "Valid values are auto/gicv2m/it= s/off"); + object_class_property_add_bool(oc, "dtb-randomness", virt_get_dtb_randomness, virt_set_dtb_randomness); @@ -3514,7 +3582,7 @@ static void virt_instance_init(Object *obj) vms->highmem_redists =3D true; =20 /* Default allows ITS instantiation if available */ - vms->its =3D ON_OFF_AUTO_AUTO; + vms->msi_controller =3D VIRT_MSI_CTRL_AUTO; /* Allow ITS emulation if the machine version supports it */ vms->tcg_its =3D !vmc->no_tcg_its; vms->no_gicv3_with_gicv2m =3D false; diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 997dd51678..99db8607e7 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -101,6 +101,8 @@ typedef enum VirtIOMMUType { =20 typedef enum VirtMSIControllerType { VIRT_MSI_CTRL_NONE, + /* This value is overriden at runtime.*/ + VIRT_MSI_CTRL_AUTO, VIRT_MSI_CTRL_GICV2M, VIRT_MSI_CTRL_ITS, } VirtMSIControllerType; @@ -149,7 +151,6 @@ struct VirtMachineState { bool highmem_ecam; bool highmem_mmio; bool highmem_redists; - OnOffAuto its; bool tcg_its; bool virt; bool ras; @@ -219,5 +220,6 @@ static inline int virt_gicv3_redist_region_count(VirtMa= chineState *vms) } =20 bool virt_is_its_enabled(VirtMachineState *vms); +bool virt_is_gicv2m_enabled(VirtMachineState *vms); =20 #endif /* QEMU_ARM_VIRT_H */ --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759536; cv=none; d=zohomail.com; s=zohoarc; b=P84cqbVmcynCETXz3vSziHq259CiWBxcCTCxTmyQnfq6yFc1C+Kr/5aLGhpuLVHQaPUeK8lNZ4954JRB3ujHiedzIpkpIAA5eamPtzO38WaBwGmyGS4hFiElAjbx6taQlrIZyp5ybA5Hkof6dx8kGI+hUDPCPnRm4vx4M1aHYOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759536; 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=UWn29qzaNoAUhaIt83YU72VeuI8u9wWPuGGjPH2xVQg=; b=acLg04c9frCKlfxBzmQbf/30pJqAxDeBMyGqqcbKK/oLbyqSaOBAn74J2DY4SM3KwDYYqnJFg0rnrLTSfB1ZQL0Kj04Sel6dLam0koxgEH70YpVMhkU2NpkzaRRIqz8VehzsGI8w+4EfpDAsmC9Cb5yuqRNcYjX6DbK3LPxwJiY= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176175953664748.76688459256843; Wed, 29 Oct 2025 10:38:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5y-0003qW-QW; Wed, 29 Oct 2025 13:36: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 1vEA5k-0003id-Er for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:12 -0400 Received: from p-east2-cluster1-host8-snip4-9.eps.apple.com ([57.103.76.82] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5O-0003Pm-Oq for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:11 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id C3FED1808524; Wed, 29 Oct 2025 17:35:31 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 86621180D85B; Wed, 29 Oct 2025 16:55:47 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=UWn29qzaNoAUhaIt83YU72VeuI8u9wWPuGGjPH2xVQg=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=bVB8vrO2nDt7QLrJq6/AoEUZnaNmmC7MR+4/cpQx51xWjKpbUVHn+weMNxMsiishMvvtddoZjT4Mvk1vDfVO4bQ5myONW7dawVe9WrImgS7oBjz/Z0DxD0L582o3Wu5EO4KdH+ytDRxjAJxopSqDleuQjL7XAY09IamV/yvwwLxSYL1gGOm/wiuGXLOw4vzQgW2vNqzOW0/BKnup8D6pYxNluPsHuZ3NQJgVspYU3C5RiZcVla9IthBodlwOwdngFxUoXg2u1hC28nrFm8zaGNu9zDe4upNFG8ZdDrIvEuV1mp84oHLnPBcWJUtGAMvf1GWd/f5/sX68k7AefJEiZw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v10 17/28] hw: arm: virt-acpi-build: add hack Date: Wed, 29 Oct 2025 17:54:59 +0100 Message-ID: <20251029165510.45824-18-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX8O1qKTZgT8bV bFqTp84ToT+DmH5uZCCv0+xezXMGsSkFlxxKCZFU+7iRwwHhm8QH2gNhnMbpXLsFNwrzog8Ohxj l7IA7DVNerTUReA9dWazUaaT9NAMDyyN/7WnOeFnQrpSHC6wR6rXWTbFd9KLYH+8OHQURD7abVF lJtymO+Z6Q5SBeF6Ck31jT5H6DL/NRRnWnJmk6WfNnmmvopAAdjlhiRidUF9LAfvPFqLJm8RVm4 Fr62FBpRiEBtqRCCJlCaiaD50PzRD251/hK3d2q7Hod53bq1aysiXEBrMashN6n/pth9soPLQ= X-Proofpoint-GUID: tCH4uJp5n3WFJR6ZXqtSBKLjhyNiuLhr X-Proofpoint-ORIG-GUID: tCH4uJp5n3WFJR6ZXqtSBKLjhyNiuLhr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 bulkscore=0 mlxlogscore=654 clxscore=1030 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAAB14yAvUwUYTOY0sCI9dfMyVvuRLMg+Lj054HfyGIyQzQyhWfH70VvSNWEXAf08TD3WLSfFuBrXeisnLqBGXcAeCxb7rW6IJNy7NNYQ0tt8oC+bpqySfekIpseVgLW4zqy5IqBihqoC1AVlFff6Y/eOsVNXkJk/i0Mchfp+8Cks/M1EWVAG1nrWKLdE6pXMSb1DObCSh9a8DPrE0vG+bHIIj49na4j+UMrVY/e/FAeI8fZsEHF/dB66KdzzwQgIaOfr2QhN8i0X67arhkWbXNMNRMeXv8uOGHnkdwJNWY9XeXgXQf23hnBMx5n3jy17ageHZzc6qBIzBrKJ1ZvIaMLXm9JXoNfw0b25N+oMCpgNKfcR/+4cpei+TX5C6B6Y5LOeqQUQCaud/sH9FSVe2fMqz5SB4jcR4cIXHfap2BzoGeMqS/YS14KSky6ZU70aaK5DCIjvD8rOIekBjnEGHzrixZXzxVyG7AT8W5l5JVXXP9EoRerMnhpQTHDm/fukid9mCX46wm8NdBeh3QJG7xs6Qz7UxszYIEaM2MnDdie2UGymesvjJLKdsUC5HLHRGJUU0Do7DATLq5MD6dFAC/BFSHEhfQ/4AgWXTPJnkH5OXyxuhC9MfTxZmc5T3HDpH9UrnAsvoGKw4RKWsVBWk9i2q/lENcGA5hFpqN+QZTYSGYV5tFfZS7IoSp5kkZ8reZQnhR9CD0AqBTY588QN2qshpnuetVk6NmWVsHCuC8h+Gayew5oMeS+5Q== 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=57.103.76.82; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1761759537176158500 Content-Type: text/plain; charset="utf-8" Looks like in the prior Qemu ACPI table handling, GICv2 configurations had vms->its=3D1... Match that assumption to not make the test suite fail. Probably not merge-w= orthy... And then maybe see what to do for older releases too? Signed-off-by: Mohamed Mediouni --- hw/arm/virt-acpi-build.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index a6a56455a9..39dd3d1020 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -472,7 +472,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) nb_nodes =3D num_smmus + 1; /* RC and SMMUv3 */ rc_mapping_count =3D rc_smmu_idmaps_len; =20 - if (virt_is_its_enabled(vms)) { + if (virt_is_its_enabled(vms) || vms->gic_version =3D=3D 2) { /* * Knowing the ID ranges from the RC to the SMMU, it's possibl= e to * determine the ID ranges from RC that go directly to ITS. @@ -483,7 +483,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) rc_mapping_count +=3D rc_its_idmaps->len; } } else { - if (virt_is_its_enabled(vms)) { + if (virt_is_its_enabled(vms) || vms->gic_version =3D=3D 2) { nb_nodes =3D 2; /* RC and ITS */ rc_mapping_count =3D 1; /* Direct map to ITS */ } else { @@ -498,7 +498,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) build_append_int_noprefix(table_data, IORT_NODE_OFFSET, 4); build_append_int_noprefix(table_data, 0, 4); /* Reserved */ =20 - if (virt_is_its_enabled(vms)) { + if (virt_is_its_enabled(vms) || vms->gic_version =3D=3D 2) { /* Table 12 ITS Group Format */ build_append_int_noprefix(table_data, 0 /* ITS Group */, 1); /* Ty= pe */ node_size =3D 20 /* fixed header size */ + 4 /* 1 GIC ITS Identif= ier */; @@ -517,7 +517,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) int smmu_mapping_count, offset_to_id_array; int irq =3D sdev->irq; =20 - if (virt_is_its_enabled(vms)) { + if (virt_is_its_enabled(vms) || vms->gic_version =3D=3D 2) { smmu_mapping_count =3D 1; /* ITS Group node */ offset_to_id_array =3D SMMU_V3_ENTRY_SIZE; /* Just after the h= eader */ } else { @@ -610,7 +610,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) } } =20 - if (virt_is_its_enabled(vms)) { + if (virt_is_its_enabled(vms) || vms->gic_version =3D=3D 2) { /* * Map bypassed (don't go through the SMMU) RIDs (input) to * ITS Group node directly: RC -> ITS. --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759423; cv=none; d=zohomail.com; s=zohoarc; b=EeuEAr8G3g+wv7nlncrjfYBK/8WwNWU8xiZOg156QTv8cv7DxbmR3pAf9RAjRcmLcnM1nKaPBgFv3vNUsBOh3Jc8mf4jpCHbewrLwjpQNMH+TlIUSGL5FFVoc4QjdeNE8a7gotsrpaFmG+d+C0SCiy2UL9gjfFFH/YUCzAb7pKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759423; 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=6QHLe7sI/ta/TpnlofGbhZSXfY72nxkqv2tu61id1Xw=; b=jOetej7uJDOppkaqWsChMk2MKHYJnZyD8vNYmuepH6YgqWMbn845lVFtSNLgSi3sYmHno5UJu7sdvSxoVwz9WSdPgGYEz4dHulF/FbRHcSJ24DPIOtBSJ/9zsfhMnbJSUKiU71SKNYVgquY0yepIideMg0e3uUHAEYmaeI9sda0= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176175942263336.94281238476401; Wed, 29 Oct 2025 10:37:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA5z-0003sK-1r; Wed, 29 Oct 2025 13:36: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 1vEA5k-0003ic-Er for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:12 -0400 Received: from p-east2-cluster4-host3-snip4-2.eps.apple.com ([57.103.78.133] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5O-0003QL-Q6 for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:11 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id CF1C91819DFB; Wed, 29 Oct 2025 17:35:32 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 8FB58185FF7E; Wed, 29 Oct 2025 16:55:49 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=6QHLe7sI/ta/TpnlofGbhZSXfY72nxkqv2tu61id1Xw=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=ACmYPaOK3wlGjvAw7EvZwc3GPi9M6yUHeduX0TArOzYayJqx2WN4hhQ1/eVEcUhDWN68CUoIQ/jJqCsbIt86WyMpwAJtWCE1qoBlRsVGUXgMBEj4TrC/bWmhdWXGKbXR+xdI2v4IIjLwXqFV1VevdimfPuBRwc+0Tipz530Xe/vVlXoCq8bMVwbhDmH7VaUvjdnKIvtBERUN9lcrdl760Y4r+Ywfbjm6tnuOsBLq/fB0JzWMszv8fXnArahqScbWZwmJjZMJbGYFmpji386OZ76DfXlTDwEac6WBOTmfQ9YDK+AXyQXdMrYGPOUS+yz3tLoeXE22wJ+1s6iH46E5Mw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v10 18/28] docs: arm: update virt machine model description Date: Wed, 29 Oct 2025 17:55:00 +0100 Message-ID: <20251029165510.45824-19-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: 09__zpetjAVAmnjb9JSUTN-KIG__7UPg X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX6ZnYYUI/zEGM ZqSFf7B4pEv9lGkP/n1Eu4fWwRx7qUq+3m2bbWDY9X0yhU9aBXFvV83CYjWgB8BQFn33tfKZbmi 0JJ7GHoia9Sq6Lw7gry0rW1ZdHahRQxBdmI+NwMIusBcWhV4IvW+hqx2IFF2gEo524gJzRTdG4y xjVeofpCTOOCqKwE8/FXMJ9n7EbMmvk5Ku2Ir305Z+Lzx7BDkE5Iv1Y8a9z7fT28ahYLwhuNJ11 c7qXzCuHivM4IEaYt0bKV7KKaNHYbt0f2hQ3V8Q1S6ApiDOZTdYm03O4rIqxvHN7+wGFseu24= X-Proofpoint-ORIG-GUID: 09__zpetjAVAmnjb9JSUTN-KIG__7UPg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 phishscore=0 clxscore=1030 mlxscore=0 mlxlogscore=810 bulkscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABO9Iz7HPx/694WUVTKGEvYK73zyEiPiyWIZNVWm+usUBa6BbBQcBTidc3q8tycRfv/30ARlc/rcAA4I7ECnr3/48tVGCw732HwktasRgComaY19RftBVJ1r0qDcoZdA7Nd5554jggJLJZkVxqHdv2kWgLOjM671vzQfA2NOyIw/CBgyxGirNT/2iyoVFoGEjN157w7J5GRUE3A+8DOvOAfhHHf8B0jsXKmm8vAcWLNXpCmYAtq9tD0MVKaCp4b/fDcyqBSL4HsdueJu2SREZb/o44d1aPsEWXOoQO7kT81R7IxTWPDfqDduZrowhL5Pi/VSseXN+ZBnXh/Ynd0njdwFYCjDA0FSOCaL4+OXfpMDfRaZcCf36NiGHDZnlhDVrZerubvJwADRzW7xR1imDxnsu/CMoWEwCtO/u36FXRErcZJWib6YMjcUds5unX076OA9yBtfkiN/Wpst2QuWZqyC01ZnmpZUZge53j0EMIDcBaM+31eqG1wqXxHBbQE2AxouNQeyBdr4W2m32/wc3QPZllit9bjtM+fve3C9e2W9jHvXFYtbZEgcNjx+1WScV+zzikbdtLbZzOZ+lmJDnbUiQr1sIadenzdnNeWe4A7DvDGxfQP5l/yE0Ed7ms3GRG0w0Ji1P1fVBi56fsuFaLsFfnLysacMLmjehnsFLsNbRQj9Ujn3tbXkSkHnHWWf0nxG7xIO7+s5x1TDME7omVVgJIt28AADsu3gNs/6WFgfZFqYFdBkFoqo8= 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=57.103.78.133; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1761759425864158500 Content-Type: text/plain; charset="utf-8" Update the documentation to match current QEMU. Remove the mention of pre-2.7 machine models as those aren't provided anymore. Signed-off-by: Mohamed Mediouni --- docs/system/arm/virt.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst index 10cbffc8a7..fe95be991e 100644 --- a/docs/system/arm/virt.rst +++ b/docs/system/arm/virt.rst @@ -40,9 +40,10 @@ The virt board supports: - An optional SMMUv3 IOMMU - hotpluggable DIMMs - hotpluggable NVDIMMs -- An MSI controller (GICv2M or ITS). GICv2M is selected by default along - with GICv2. ITS is selected by default with GICv3 (>=3D virt-2.7). Note - that ITS is not modeled in TCG mode. +- An MSI controller (GICv2m or ITS). + - When using a GICv3, ITS is selected by default when available on the p= latform. + - If using a GICv2 or when ITS is not available, a GICv2m is provided by= default instead. + - Before virt-10.2, a GICv2m is not provided when the ITS is disabled. - 32 virtio-mmio transport devices - running guests using the KVM accelerator on aarch64 hardware - large amounts of RAM (at least 255GB, and more if using highmem) @@ -167,8 +168,7 @@ gic-version ``4`` if ``virtualization`` is ``on``, but this may change in future) =20 its - Set ``on``/``off`` to enable/disable ITS instantiation. The default is `= `on`` - for machine types later than ``virt-2.7``. + Set ``on``/``off``/``auto`` to control ITS instantiation. The default is= ``auto``. =20 iommu Set the IOMMU type to create for the guest. Valid values are: --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759513; cv=none; d=zohomail.com; s=zohoarc; b=irBec0anHLeNWBbgKzhHD1tefIWHQyIopwSfrnQKHIMA4NiRvU8uy3p6G0eYxKMWRfvgS47R3FZnpD2FYjgHSe4CHPWjjTcnQ493b/wW1nyQ0M2popShO0GTkNkYEyyy6tTFcBmRiJggjFJHrcHmu5EPGzWkIc632QeHZ2aluY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759513; 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=6tFoGYoxbdmSlbVYc9w99fI7VkZAyeHkesY8VkHeUvA=; b=ICu4cY37tNyDihuFXTQZG8at4USMV7Gk7T41Hvp/h4PfZHxryqu99ZpoE1Doy1j2kebp6DSR4IER/eVgLu+QM4qcKCZXrPKli776E+j9Gzuo5Imfudw1zynfEBi2hp3Rp1B1RwDKTU5XPsZVeWTv+9QlyK3jEuvMO6OMWGNj1eE= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759513135396.75565262783084; Wed, 29 Oct 2025 10:38:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA6A-00046X-2r; Wed, 29 Oct 2025 13:36: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 1vEA5x-0003vM-Db for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:27 -0400 Received: from p-east2-cluster4-host3-snip4-10.eps.apple.com ([57.103.78.141] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5U-0003SO-9x for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:24 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 521DE1819DEB; Wed, 29 Oct 2025 17:35:34 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 1D69618017A1; Wed, 29 Oct 2025 16:55:51 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=6tFoGYoxbdmSlbVYc9w99fI7VkZAyeHkesY8VkHeUvA=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=OOJ9x94bivjuHC/fF1i5NybqGuGZdhEUkebCJyakOCgDgLbDhbz3KHlCvIb+46mPgKEhD19I9aHgxwNTngum7O56F4vlV3WIjRqaHABa7KpqHifzYbcqRDSNecXXc7+p/w7NSdiGXvJzUy8qA3tsiIkDCR4/g2NptrTdGF6lFkR3QMoc/P07vRn+J0jbZxBg0/loIEy3XKZ6D18bw17nUxvoRdt366NfkCvkcMRNo7JMR/0JSkrOCLp3FwOYJ3UeCpvHfn/dTOVj76HpGSn8OZVCBnZpfji/jRuSL+YWJCGF425jihoY571pRIbEJWMpJv/5LHholI6zzEFx9BVSig== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 19/28] whpx: arm64: clamp down IPA size Date: Wed, 29 Oct 2025 17:55:01 +0100 Message-ID: <20251029165510.45824-20-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: 5ZZM8oNqKIZFAbKuqcjHdYbW2C73Wk7x X-Proofpoint-GUID: 5ZZM8oNqKIZFAbKuqcjHdYbW2C73Wk7x X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX/wv5+Hdh/WSe 1Xixwg+61oo3zeD2gvM7L6B8dVlbXKJQts/rf5cMzAoJ8DPZqgLqd8/qXU3Ppk6tuu/yiECPEmW 4XQ2Rhhy1XEsc5U++XmBwPvXFBIA1XTeGYBCn+swJOdnEXTZgc6yqB5duEybcgobqaNjbVNVcci hwHtzxec1DBw5ZjaEyRsTTskZ3WSexZgVohYpx++ivqKPCts8/OQU3RR6s92YY29sOrshv9DbcI p6LtPy58Sxg1PRpVNwTNGwbZaH0eiN5ND9cMuIt5N0InG7BuD/DkkNdcsgtTP/NxZ03k3ztls= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxscore=0 suspectscore=0 spamscore=0 clxscore=1030 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABZ1RLwsssfh6sdikzxAax40sENk5CAh72rZ0/AGUsp3ATzR/J+9qEmhemWORQoaapHp7bTKdEomFMUpsxQnHW3Z2szjmqKB6FYTcCbka7U0xPZzBER1clgY6Bgkzf1vB9UJeXb7GfxFQyG2LpPDLXFtDLn2r6uY+xbim7J+86XIeC6C6dLWlQDakiXvNA0dPG4SvZjQDzeFx+QoYezY2FhKpLuz+sPeXVyjq2tZwBtb33WrueOSIeMBVZmhAC7ATD5tCL+/sge1YjaMyeqW+B+5xgJKOsFmY4Wj49uYO5EnfKfrgqRErsa6Vx78EkfO81JkZRHnC8KGyWnF/RsmGkG/811tykqmEcxU+2UM+WH4sZiWKUOqV2KnQ/nEWXL6KcYkK5MSFCL0kH9trH2cP7O+gXuEbOpJ5iUJi4nsIWRxZyiSiiMTU0avWkNUDiyzUSCUwu+p/kUw4W9gkdNCJQuR/W9yhMMYk4OhIEVF/QFdXcPshweBQK1EaomCeFvb/4boTGzrY49Pu4n7Vh7aYmJYYEBDFn50Kj++ySBDktU0dMl/SKT7qTeaYR4UETx4l5X4Sp3rQf5knQ2AvusHt2g+De0La15AMaZZu5I1ZJUhQQ4j7tlixPf3wMI3nPc8d6HfVdooYrBpAzL/YwoFaeN6IhfsDrsUBB7ZprxGrCWEFpuYWk6QIFqlr3ZSDAppJuzvbrawbSob/YqSxRSE4ZaYgxm9agsP+5vnxf/y+A6o20C+Dvt0pDhOa0HToRvqWGwFdFHlryAg== 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=57.103.78.141; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FORGED_SPF_HELO=1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=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=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759515513158500 Content-Type: text/plain; charset="utf-8" Code taken from HVF and adapted for WHPX use. Note that WHPX doesn't have a default vs maximum IPA distinction. Signed-off-by: Mohamed Mediouni Reviewed-by: Pierrick Bouvier --- hw/arm/virt.c | 32 ++++++++++++++++++++++++++ include/hw/boards.h | 1 + target/arm/whpx/meson.build | 2 ++ target/arm/whpx/whpx-all.c | 45 +++++++++++++++++++++++++++++++++++++ target/arm/whpx/whpx-stub.c | 15 +++++++++++++ target/arm/whpx_arm.h | 16 +++++++++++++ 6 files changed, 111 insertions(+) create mode 100644 target/arm/whpx/whpx-stub.c create mode 100644 target/arm/whpx_arm.h diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 6978d4e867..480d165ebc 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -70,6 +70,7 @@ #include "hw/irq.h" #include "kvm_arm.h" #include "hvf_arm.h" +#include "whpx_arm.h" #include "hw/firmware/smbios.h" #include "qapi/visitor.h" #include "qapi/qapi-visit-common.h" @@ -3316,6 +3317,36 @@ static int virt_kvm_type(MachineState *ms, const cha= r *type_str) return fixed_ipa ? 0 : requested_pa_size; } =20 +static int virt_whpx_get_physical_address_range(MachineState *ms) +{ + VirtMachineState *vms =3D VIRT_MACHINE(ms); + + int max_ipa_size =3D whpx_arm_get_ipa_bit_size(); + + /* We freeze the memory map to compute the highest gpa */ + virt_set_memmap(vms, max_ipa_size); + + int requested_ipa_size =3D 64 - clz64(vms->highest_gpa); + + /* + * If we're <=3D the default IPA size just use the default. + * If we're above the default but below the maximum, round up to + * the maximum. hvf_arm_get_max_ipa_bit_size() conveniently only + * returns values that are valid ARM PARange values. + */ + if (requested_ipa_size <=3D max_ipa_size) { + requested_ipa_size =3D max_ipa_size; + } else { + error_report("-m and ,maxmem option values " + "require an IPA range (%d bits) larger than " + "the one supported by the host (%d bits)", + requested_ipa_size, max_ipa_size); + return -1; + } + + return requested_ipa_size; +} + static int virt_hvf_get_physical_address_range(MachineState *ms) { VirtMachineState *vms =3D VIRT_MACHINE(ms); @@ -3408,6 +3439,7 @@ static void virt_machine_class_init(ObjectClass *oc, = const void *data) mc->get_default_cpu_node_id =3D virt_get_default_cpu_node_id; mc->kvm_type =3D virt_kvm_type; mc->hvf_get_physical_address_range =3D virt_hvf_get_physical_address_r= ange; + mc->whpx_get_physical_address_range =3D virt_whpx_get_physical_address= _range; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler =3D virt_machine_get_hotplug_handler; hc->pre_plug =3D virt_machine_device_pre_plug_cb; diff --git a/include/hw/boards.h b/include/hw/boards.h index a48ed4f86a..fb2c531018 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -278,6 +278,7 @@ struct MachineClass { void (*wakeup)(MachineState *state); int (*kvm_type)(MachineState *machine, const char *arg); int (*hvf_get_physical_address_range)(MachineState *machine); + int (*whpx_get_physical_address_range)(MachineState *machine); =20 BlockInterfaceType block_default_type; int units_per_default_bus; diff --git a/target/arm/whpx/meson.build b/target/arm/whpx/meson.build index 1de2ef0283..3df632c9d3 100644 --- a/target/arm/whpx/meson.build +++ b/target/arm/whpx/meson.build @@ -1,3 +1,5 @@ arm_system_ss.add(when: 'CONFIG_WHPX', if_true: files( 'whpx-all.c', )) + +arm_common_system_ss.add(when: 'CONFIG_WHPX', if_false: files('whpx-stub.c= ')) diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c index 8c34650765..e6bafb0601 100644 --- a/target/arm/whpx/whpx-all.c +++ b/target/arm/whpx/whpx-all.c @@ -35,6 +35,7 @@ #include "system/whpx-accel-ops.h" #include "system/whpx-all.h" #include "system/whpx-common.h" +#include "whpx_arm.h" #include "hw/arm/bsa.h" #include "arm-powerctl.h" =20 @@ -657,6 +658,40 @@ static void whpx_cpu_update_state(void *opaque, bool r= unning, RunState state) { } =20 +uint32_t whpx_arm_get_ipa_bit_size(void) +{ + WHV_CAPABILITY whpx_cap; + UINT32 whpx_cap_size; + HRESULT hr; + hr =3D whp_dispatch.WHvGetCapability( + WHvCapabilityCodePhysicalAddressWidth, &whpx_cap, + sizeof(whpx_cap), &whpx_cap_size); + if (FAILED(hr)) { + error_report("WHPX: failed to get supported" + "physical address width, hr=3D%08lx", hr); + } + + /* + * We clamp any IPA size we want to back the VM with to a valid PARange + * value so the guest doesn't try and map memory outside of the valid = range. + * This logic just clamps the passed in IPA bit size to the first valid + * PARange value <=3D to it. + */ + return round_down_to_parange_bit_size(whpx_cap.PhysicalAddressWidth); +} + +static void clamp_id_aa64mmfr0_parange_to_ipa_size(ARMISARegisters *isar) +{ + uint32_t ipa_size =3D whpx_arm_get_ipa_bit_size(); + uint64_t id_aa64mmfr0; + + /* Clamp down the PARange to the IPA size the kernel supports. */ + uint8_t index =3D round_down_to_parange_index(ipa_size); + id_aa64mmfr0 =3D GET_IDREG(isar, ID_AA64MMFR0); + id_aa64mmfr0 =3D (id_aa64mmfr0 & ~R_ID_AA64MMFR0_PARANGE_MASK) | index; + SET_IDREG(isar, ID_AA64MMFR0, id_aa64mmfr0); +} + int whpx_init_vcpu(CPUState *cpu) { HRESULT hr; @@ -735,6 +770,7 @@ int whpx_init_vcpu(CPUState *cpu) val.Reg64 =3D deposit64(arm_cpu->mp_affinity, 31, 1, 1 /* RES1 */); whpx_set_reg(cpu, WHvArm64RegisterMpidrEl1, val); =20 + clamp_id_aa64mmfr0_parange_to_ipa_size(&arm_cpu->isar); return 0; =20 error: @@ -757,6 +793,8 @@ int whpx_accel_init(AccelState *as, MachineState *ms) UINT32 whpx_cap_size; WHV_PARTITION_PROPERTY prop; WHV_CAPABILITY_FEATURES features =3D {0}; + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + int pa_range =3D 0; =20 whpx =3D &whpx_global; /* on arm64 Windows Hypervisor Platform, vGICv3 always used */ @@ -767,6 +805,13 @@ int whpx_accel_init(AccelState *as, MachineState *ms) goto error; } =20 + if (mc->whpx_get_physical_address_range) { + pa_range =3D mc->whpx_get_physical_address_range(ms); + if (pa_range < 0) { + return -EINVAL; + } + } + whpx->mem_quota =3D ms->ram_size; =20 hr =3D whp_dispatch.WHvGetCapability( diff --git a/target/arm/whpx/whpx-stub.c b/target/arm/whpx/whpx-stub.c new file mode 100644 index 0000000000..32e434a5f6 --- /dev/null +++ b/target/arm/whpx/whpx-stub.c @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * WHPX stubs for ARM + * + * Copyright (c) 2025 Mohamed Mediouni + * + */ + +#include "qemu/osdep.h" +#include "whpx_arm.h" + +uint32_t whpx_arm_get_ipa_bit_size(void) +{ + g_assert_not_reached(); +} diff --git a/target/arm/whpx_arm.h b/target/arm/whpx_arm.h new file mode 100644 index 0000000000..de7406b66f --- /dev/null +++ b/target/arm/whpx_arm.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * WHPX support -- ARM specifics + * + * Copyright (c) 2025 Mohamed Mediouni + * + */ + +#ifndef QEMU_WHPX_ARM_H +#define QEMU_WHPX_ARM_H + +#include "target/arm/cpu-qom.h" + +uint32_t whpx_arm_get_ipa_bit_size(void); + +#endif --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759613; cv=none; d=zohomail.com; s=zohoarc; b=grzkcl/5B7YBBPcrreBo8+3+ge1h6fdUV5hbeTmT9w0jhJj5RGZWo7ivqa1B6nd9J8PUfDemKzuZ1IA7eOoZI8C2RMo3wGQ6pVgg3uUi2GySlRpDwEnsFfo6NG02fWxPmgCBNdoIuIfxbXKNh0gXe9whWVmevftfLyj5y5j1nIs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759613; 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=2LnAPGX4HuFpDCVnU0NG6yresAdDa/+GNcrH6VwGz6k=; b=QJNWdgBrHHP28A91vCaF3f6QkliSqB59xRRylIDYsQLYPSf2twtKWKBGw/+UjHcrybTzUXOe3YHqqgVY8VCuaWfpvDPfkAC1bz5SC+vG98dl9rrb92NfaE+El/q6XtoVnag0gy1fN/gMkRlyEjQWdkKeZEv0VkSBx3dE8xOQGZk= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759613852402.5100277090279; Wed, 29 Oct 2025 10:40:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA6D-0004Cz-Uo; Wed, 29 Oct 2025 13:36: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 1vEA5x-0003vf-ME for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:27 -0400 Received: from p-east2-cluster4-host5-snip4-10.eps.apple.com ([57.103.78.201] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5U-0003Sd-MK for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:25 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id A8CB8180C460; Wed, 29 Oct 2025 17:35:35 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id B0B72180E5B4; Wed, 29 Oct 2025 16:55:52 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=2LnAPGX4HuFpDCVnU0NG6yresAdDa/+GNcrH6VwGz6k=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=f/JUOxIocUlANjNJa2PbtpC8aF9+ScnTbv3j9D+1mlVgaY5O7/+h1KKQqMUGPrlzxhhjGFtqbGMuKP3bSq24J4Eu2vD2RFJORvDJ+AHj9xc9+nzOUUefpoiASzpPHQHEp5mk0P6ctyTC2OjD5ba20JL7OJoq0Az1OW3qnf4DEQ/Ce6M8zNBi4tpC/0j1LUcbAXIdg38hDs8eGLg3j5ZEjABwswcBrFmMh3VmbjegbSUvefBwccgDkdYaIr6UGAMZh1yjKCHU2cvpZeyRe76lKTrQKfDkWrtKyRXnRRBbbs1aSyiqIF6Cy4B8j/Q8ctTpmOayHyWtST6PF+L+cyAF2g== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 20/28] hw/arm, accel/hvf, whpx: unify get_physical_address_range between WHPX and HVF Date: Wed, 29 Oct 2025 17:55:02 +0100 Message-ID: <20251029165510.45824-21-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX9gJSiH6aBKY8 FaEPNxbBmBK9vxUU0m7cVS3+DMYphSQxnMktdk9bDKNvEzSdX4idh1/ViutqKv8CZHrW3r8pFdF owppTFaJkBqB1ueqQ7RWJjHWbc+j7URMlC3g5JIHp3XMktgFDPueKnca3McjuJH0cQr3EEeB1ch mq3ISIxnLlzrrOTTM3nz44EFkPfoyukxDKyAtgkI/YNzrjqvFK4SB8Cwx5oROt5k+ZUt5eRlxcd AZTX2YMQWkIjr5cGhsLPjl4o/J9LfzzllNU5+16IvyyNjzjKJCvftLPhizuj/HoPIod8lSRYU= X-Proofpoint-GUID: qGN58SfSDleljuGIt1ifw4oQowlKGKPC X-Proofpoint-ORIG-GUID: qGN58SfSDleljuGIt1ifw4oQowlKGKPC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 malwarescore=0 phishscore=0 clxscore=1030 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAAB7oiVj68Vx0jdBrAUUIi6kUpWwXhpajTClQtwOM+sbNsRNrQXt1TMnJjI7H2oqAH84CAs2TfZKcGz/pSfwoLIJmWUANqSAjnn033Ri3ZAVPDcY7NtQg9yueqyRsc4DlQwBVelciJs/MUp3xmaIA3hzItUuXDxeEvyaiIgSKNu4V47UZ0b4D5/F3pAu+bkIDv3JWxb728ADd7z7Yuatt2U76Ur+l1JU6ssv8YMZcO76N4utfJ66Ryb3ThiN2QKPrxKxq1grnspPMRG6fa06eA76FCnt/d55RQhbV7gYsQe25hOOKgE+lCNp5jFs8MTKJWZVYO1wKpapr4GJriBkMvcLL4qKkjiBVu4LAK4qG8mvsLMCv39vbTnILiMryn6ij+0QIIEusZQQD1pfmmSTqPdyyMNYmlis9rXfQr7EuXwvS19Tf/C+LE/fqEwTgHFQMCZauASZ2H7ijvbKqg/CbrOENZviVKI90fqhICTwnVfqK3qVv9DxGNYp9ugW6NOK3i8pjRkMP8l00Lb9KLW8PvBIq4JoRkPeI3phQu18H8dYmEFLZl8q/ynnQz7T1OXtUQ2c6upGh3BMjPZYZ1xOlcwMyNlZ7mjdrr4YLcNYH/lpQqaue2AXk72JwcmDg+n59cANgyzWDgtOR4eiNyldmC+N4rVJFMY/bgnW241TUki/GBViJtU5Ln13LVgTvmx3AneUROVEUdmx5OaFKVeuTnPvnDOZUE3L61qUBGcUjn3oQErwEMgZ9OB9/SnI0+e92aArh8M0DJC 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=57.103.78.201; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759615641154100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni Reviewed-by: Pierrick Bouvier --- accel/hvf/hvf-all.c | 7 +++++-- hw/arm/virt.c | 41 ++++---------------------------------- include/hw/boards.h | 4 ++-- include/system/hvf_int.h | 2 ++ target/arm/hvf-stub.c | 20 ------------------- target/arm/hvf/hvf.c | 6 +++--- target/arm/hvf_arm.h | 3 --- target/arm/meson.build | 1 - target/arm/whpx/whpx-all.c | 5 +++-- target/i386/hvf/hvf.c | 11 ++++++++++ 10 files changed, 30 insertions(+), 70 deletions(-) delete mode 100644 target/arm/hvf-stub.c diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c index 0a4b498e83..8229ad8640 100644 --- a/accel/hvf/hvf-all.c +++ b/accel/hvf/hvf-all.c @@ -17,6 +17,7 @@ #include "system/hvf_int.h" #include "hw/core/cpu.h" #include "hw/boards.h" +#include "target/arm/hvf_arm.h" #include "trace.h" =20 bool hvf_allowed; @@ -256,8 +257,10 @@ static int hvf_accel_init(AccelState *as, MachineState= *ms) int pa_range =3D 36; MachineClass *mc =3D MACHINE_GET_CLASS(ms); =20 - if (mc->hvf_get_physical_address_range) { - pa_range =3D mc->hvf_get_physical_address_range(ms); + + if (mc->get_physical_address_range) { + pa_range =3D mc->get_physical_address_range(ms, + hvf_arch_get_default_ipa_bit_size(), hvf_arch_get_max_ipa_bit_= size()); if (pa_range < 0) { return -EINVAL; } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 480d165ebc..58fa657cae 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -3317,43 +3317,11 @@ static int virt_kvm_type(MachineState *ms, const ch= ar *type_str) return fixed_ipa ? 0 : requested_pa_size; } =20 -static int virt_whpx_get_physical_address_range(MachineState *ms) +static int virt_get_physical_address_range(MachineState *ms, + int default_ipa_size, int max_ipa_size) { VirtMachineState *vms =3D VIRT_MACHINE(ms); =20 - int max_ipa_size =3D whpx_arm_get_ipa_bit_size(); - - /* We freeze the memory map to compute the highest gpa */ - virt_set_memmap(vms, max_ipa_size); - - int requested_ipa_size =3D 64 - clz64(vms->highest_gpa); - - /* - * If we're <=3D the default IPA size just use the default. - * If we're above the default but below the maximum, round up to - * the maximum. hvf_arm_get_max_ipa_bit_size() conveniently only - * returns values that are valid ARM PARange values. - */ - if (requested_ipa_size <=3D max_ipa_size) { - requested_ipa_size =3D max_ipa_size; - } else { - error_report("-m and ,maxmem option values " - "require an IPA range (%d bits) larger than " - "the one supported by the host (%d bits)", - requested_ipa_size, max_ipa_size); - return -1; - } - - return requested_ipa_size; -} - -static int virt_hvf_get_physical_address_range(MachineState *ms) -{ - VirtMachineState *vms =3D VIRT_MACHINE(ms); - - int default_ipa_size =3D hvf_arm_get_default_ipa_bit_size(); - int max_ipa_size =3D hvf_arm_get_max_ipa_bit_size(); - /* We freeze the memory map to compute the highest gpa */ virt_set_memmap(vms, max_ipa_size); =20 @@ -3362,7 +3330,7 @@ static int virt_hvf_get_physical_address_range(Machin= eState *ms) /* * If we're <=3D the default IPA size just use the default. * If we're above the default but below the maximum, round up to - * the maximum. hvf_arm_get_max_ipa_bit_size() conveniently only + * the maximum. hvf_arch_get_max_ipa_bit_size() conveniently only * returns values that are valid ARM PARange values. */ if (requested_ipa_size <=3D default_ipa_size) { @@ -3438,8 +3406,7 @@ static void virt_machine_class_init(ObjectClass *oc, = const void *data) mc->valid_cpu_types =3D valid_cpu_types; mc->get_default_cpu_node_id =3D virt_get_default_cpu_node_id; mc->kvm_type =3D virt_kvm_type; - mc->hvf_get_physical_address_range =3D virt_hvf_get_physical_address_r= ange; - mc->whpx_get_physical_address_range =3D virt_whpx_get_physical_address= _range; + mc->get_physical_address_range =3D virt_get_physical_address_range; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler =3D virt_machine_get_hotplug_handler; hc->pre_plug =3D virt_machine_device_pre_plug_cb; diff --git a/include/hw/boards.h b/include/hw/boards.h index fb2c531018..fa5f71471d 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -277,8 +277,8 @@ struct MachineClass { void (*reset)(MachineState *state, ResetType type); void (*wakeup)(MachineState *state); int (*kvm_type)(MachineState *machine, const char *arg); - int (*hvf_get_physical_address_range)(MachineState *machine); - int (*whpx_get_physical_address_range)(MachineState *machine); + int (*get_physical_address_range)(MachineState *machine, + int default_ipa_size, int max_ipa_size); =20 BlockInterfaceType block_default_type; int units_per_default_bus; diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h index a3b06a3e75..8b6447c238 100644 --- a/include/system/hvf_int.h +++ b/include/system/hvf_int.h @@ -71,6 +71,8 @@ void assert_hvf_ok_impl(hv_return_t ret, const char *file= , unsigned int line, const char *hvf_return_string(hv_return_t ret); int hvf_arch_init(void); hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range); +uint32_t hvf_arch_get_default_ipa_bit_size(void); +uint32_t hvf_arch_get_max_ipa_bit_size(void); int hvf_arch_init_vcpu(CPUState *cpu); void hvf_arch_vcpu_destroy(CPUState *cpu); int hvf_vcpu_exec(CPUState *); diff --git a/target/arm/hvf-stub.c b/target/arm/hvf-stub.c deleted file mode 100644 index ff137267a0..0000000000 --- a/target/arm/hvf-stub.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * QEMU Hypervisor.framework (HVF) stubs for ARM - * - * Copyright (c) Linaro - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "qemu/osdep.h" -#include "hvf_arm.h" - -uint32_t hvf_arm_get_default_ipa_bit_size(void) -{ - g_assert_not_reached(); -} - -uint32_t hvf_arm_get_max_ipa_bit_size(void) -{ - g_assert_not_reached(); -} diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 0658a99a2d..ecca1a63ec 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -725,7 +725,7 @@ static uint64_t hvf_get_reg(CPUState *cpu, int rt) static void clamp_id_aa64mmfr0_parange_to_ipa_size(ARMISARegisters *isar) { uint32_t ipa_size =3D chosen_ipa_bit_size ? - chosen_ipa_bit_size : hvf_arm_get_max_ipa_bit_size(); + chosen_ipa_bit_size : hvf_arch_get_max_ipa_bit_size(); uint64_t id_aa64mmfr0; =20 /* Clamp down the PARange to the IPA size the kernel supports. */ @@ -816,7 +816,7 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFea= tures *ahcf) return r =3D=3D HV_SUCCESS; } =20 -uint32_t hvf_arm_get_default_ipa_bit_size(void) +uint32_t hvf_arch_get_default_ipa_bit_size(void) { uint32_t default_ipa_size; hv_return_t ret =3D hv_vm_config_get_default_ipa_size(&default_ipa_siz= e); @@ -825,7 +825,7 @@ uint32_t hvf_arm_get_default_ipa_bit_size(void) return default_ipa_size; } =20 -uint32_t hvf_arm_get_max_ipa_bit_size(void) +uint32_t hvf_arch_get_max_ipa_bit_size(void) { uint32_t max_ipa_size; hv_return_t ret =3D hv_vm_config_get_max_ipa_size(&max_ipa_size); diff --git a/target/arm/hvf_arm.h b/target/arm/hvf_arm.h index ea82f2691d..5d19d82e5d 100644 --- a/target/arm/hvf_arm.h +++ b/target/arm/hvf_arm.h @@ -22,7 +22,4 @@ void hvf_arm_init_debug(void); =20 void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu); =20 -uint32_t hvf_arm_get_default_ipa_bit_size(void); -uint32_t hvf_arm_get_max_ipa_bit_size(void); - #endif diff --git a/target/arm/meson.build b/target/arm/meson.build index 61277a627c..9f2eb91635 100644 --- a/target/arm/meson.build +++ b/target/arm/meson.build @@ -41,7 +41,6 @@ arm_common_system_ss.add(files('cpu.c')) arm_common_system_ss.add(when: 'TARGET_AARCH64', if_false: files( 'cpu32-stubs.c')) arm_common_system_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) -arm_common_system_ss.add(when: 'CONFIG_HVF', if_false: files('hvf-stub.c')) arm_common_system_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING', if_true: files('common-semi-target.c')) arm_common_system_ss.add(files( diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c index e6bafb0601..23c7beefaf 100644 --- a/target/arm/whpx/whpx-all.c +++ b/target/arm/whpx/whpx-all.c @@ -805,8 +805,9 @@ int whpx_accel_init(AccelState *as, MachineState *ms) goto error; } =20 - if (mc->whpx_get_physical_address_range) { - pa_range =3D mc->whpx_get_physical_address_range(ms); + if (mc->get_physical_address_range) { + pa_range =3D mc->get_physical_address_range(ms, + whpx_arm_get_ipa_bit_size(), whpx_arm_get_ipa_bit_size()); if (pa_range < 0) { return -EINVAL; } diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 33f723a76a..1d7ec47f59 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -225,6 +225,17 @@ int hvf_arch_init(void) return 0; } =20 +/* 48-bit on all Intel Macs. Function currently unused. */ +uint32_t hvf_arch_get_default_ipa_bit_size(void) +{ + g_assert_not_reached(); +} + +uint32_t hvf_arch_get_max_ipa_bit_size(void) +{ + g_assert_not_reached(); +} + hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range) { return hv_vm_create(HV_VM_DEFAULT); --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759815; cv=none; d=zohomail.com; s=zohoarc; b=LUr2EFtUTy/JvU+lTX9vK1tOcYsRsMWIHDoSeOFMXtL9C1EumMwvr+jA16yRARNh0BPZLaiwI4OzB64uLYTkT76f4nGP9WfaZVWN/ah9mAdilS+LhbavWZsOcKqpVYFqP+8GHEKAnGOwMmOB4Ai3i4f10jaUOXm/eGbI8DvY+6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759815; 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=UOGHA4PGi6Sk/oKzT0z+MFnVyAcKEZbG5DcuwsP+3fI=; b=Dxs53d2lj1/VyDjHDTFnNo3RTmkuiawxIJs/jn5x6SARq05iu2M0jIEcfR+CZ6boow3xfbx/a7FpgWhh8DXqk1Atvihy6qQaO09jBZOitQDCXpSUvlmkXpkDPQ67fEyfamxgZeDvCEKSp42ZhOo9mKtSgP3nh/wQZXXl/Xfe7aE= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759815803149.6366574164265; Wed, 29 Oct 2025 10:43:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA61-00040w-CT; Wed, 29 Oct 2025 13:36: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 1vEA5s-0003pa-29 for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:22 -0400 Received: from p-east2-cluster4-host8-snip4-4.eps.apple.com ([57.103.78.245] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5U-0003SP-9R for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:19 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id BE4A8180E584; Wed, 29 Oct 2025 17:35:36 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 3D35718017A0; Wed, 29 Oct 2025 16:55:55 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=UOGHA4PGi6Sk/oKzT0z+MFnVyAcKEZbG5DcuwsP+3fI=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=D9zGaxu9wNQOUTOm58A2iZ6CP15dmT1RPkA8pnxLBkES+sqm5Nfn24pmtkjFzXIpSWumNORLMiIo8cYSo22k/ueNgn0RL3iL7VMKiL1y76zOTtDBMZ7oUpAuB0pRzgbtP5phIiISb68M5yuwJYHtOwFzm8Ca7yDkDxaA0OOlYbRY8FHGaEhBPvoEpwuhsEOhD+zDRt5MmNqM7v5br9rxZ/k7hpigdcuisA9kbchqBCaKlw1xcJSKZ4FK9wsC5EDsc79P1UN8C9SrAZ+SA1igFrTKOAq+Qt7oX5QLsLTWdaKtgaVcoKZYZ5mCjBv9CsN6BXfAg7JCQezOUFZglL7NLQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 21/28] whpx: arm64: implement -cpu host Date: Wed, 29 Oct 2025 17:55:03 +0100 Message-ID: <20251029165510.45824-22-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX6V96n1Jm+xuM gECQInqZjLfG5KG2KGCaUyt45S1208W2LirybLirdeZaCLZ1KHbCZvMknlEN1lxb2jHrFKLGCFs bryPCDsaUJU6DJaQLU+LKOpKsmw4fieUyXOjPWeZj8ylQazSAH3myQr/5sZ6GFnGJhOehRrji0h TJEXHVtFsNwI61vqdF3rLini+xGVzKMpu23+boWHGB1HVm2ZdtqB0+suiVG4rF49rs6BKS9HnvI UC5Bxx2gf9rMeqR1/mpeaXR2E/EUreOCViJVsbg4XuhTwMpO/CFYo9rqvudH7ZpqwCn9FjMW8= X-Proofpoint-ORIG-GUID: PJueE6EPFzk_Uoo3WP182UDpBJblRUaj X-Proofpoint-GUID: PJueE6EPFzk_Uoo3WP182UDpBJblRUaj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 clxscore=1030 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABx7JyGNJI9H4u5iWDhD4KZ1/WEYiGEcDTrRbWm8N5Pe+zi3+Ty85QRRzlE+yOeIvedMbsl688DL73jOENQruZnnS7zVfkmgP1r+xVs0HC/XU060ayLMO2/DEceOW+kfSzN+aQdCKC6sB7oTFTMj1xC8L+/J3HvFaEMNnXqpYGFTiYVIs2O6QsQWpux7gPV1AdR2az/Fqkz5wiUmZm3B1ia++kf6A5H91aRhjcPRtJJ6ScDjnENsggZdgRRCIL6ElCYubDbFGxdRvX/RiHvZfTWNZ3F8qeyc936jDFM+rSBUwpG/fhsLZ2qVWlOJNq4XfRM4sGiWSDe4lX0fgWX0jajrohrrJpcO7tEevxJ9+9oejBNysIr082KaTRIvt5iKMl83qm5YkKXmNmpcSjZ3kpRdZ+ZZsmEBpyOhzst7sPkCRfLwJwraoGDYUU8Pc0pMRZIkuSQUAnPfqxvFgq1CfJIhkGS7NciVUT1wFS4GQzprB5AQ5xLn7041OtHi5Fytq2Tb90WXtlZA4yz6s5a+NEh+avy+U6+yiXpeNhHKxJFdOj4E8z7dizKMJU8qADVxwwhuQRa2dImwgF4835ZLpaHbDe2eoncp5UlSS9hhf4CKIHwwb+KvRr/Wu4rPb9lR6hMfpYrLUuD1X2UhPekQYxR0C0PwtJRbXNkDoLfm26ZQ2j8nU6uk4BcScMkk5NGvTV4YmK0W5++Ah9zYOmLfbZ7mO6DYvLB+EnD1cTsLByv+2fjkw7hbCuXsj3eTX3petF6PtEyIjSvcxaNBk= 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=57.103.78.245; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1761759818667158500 Content-Type: text/plain; charset="utf-8" Logic to fetch MIDR_EL1 for cpu 0 adapted from: https://github.com/FEX-Emu/FEX/blob/e6de17e72ef03aa88ba14fa0ec13163061608c7= 4/Source/Windows/Common/CPUFeatures.cpp#L62 Signed-off-by: Mohamed Mediouni Reviewed-by: Pierrick Bouvier --- hw/arm/virt.c | 2 +- target/arm/cpu64.c | 19 ++++--- target/arm/whpx/whpx-all.c | 104 +++++++++++++++++++++++++++++++++++++ target/arm/whpx_arm.h | 1 + 4 files changed, 119 insertions(+), 7 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 58fa657cae..9ec3cf00f5 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -3371,7 +3371,7 @@ static void virt_machine_class_init(ObjectClass *oc, = const void *data) #ifdef TARGET_AARCH64 ARM_CPU_TYPE_NAME("cortex-a53"), ARM_CPU_TYPE_NAME("cortex-a57"), -#if defined(CONFIG_KVM) || defined(CONFIG_HVF) +#if defined(CONFIG_KVM) || defined(CONFIG_HVF) || defined(CONFIG_WHPX) ARM_CPU_TYPE_NAME("host"), #endif /* CONFIG_KVM || CONFIG_HVF */ #endif /* TARGET_AARCH64 */ diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 26cf7e6dfa..3f00071081 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -26,10 +26,13 @@ #include "qemu/units.h" #include "system/kvm.h" #include "system/hvf.h" +#include "system/whpx.h" +#include "system/hw_accel.h" #include "system/qtest.h" #include "system/tcg.h" #include "kvm_arm.h" #include "hvf_arm.h" +#include "whpx_arm.h" #include "qapi/visitor.h" #include "hw/qdev-properties.h" #include "internals.h" @@ -522,7 +525,7 @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) isar2 =3D FIELD_DP64(isar2, ID_AA64ISAR2, APA3, 0); isar2 =3D FIELD_DP64(isar2, ID_AA64ISAR2, GPA3, 0); =20 - if (kvm_enabled() || hvf_enabled()) { + if (hwaccel_enabled()) { /* * Exit early if PAuth is enabled and fall through to disable it. * The algorithm selection properties are not present. @@ -599,10 +602,10 @@ void aarch64_add_pauth_properties(Object *obj) =20 /* Default to PAUTH on, with the architected algorithm on TCG. */ qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property); - if (kvm_enabled() || hvf_enabled()) { + if (hwaccel_enabled()) { /* * Mirror PAuth support from the probed sysregs back into the - * property for KVM or hvf. Is it just a bit backward? Yes it is! + * property for HW accel. Is it just a bit backward? Yes it is! * Note that prop_pauth is true whether the host CPU supports the * architected QARMA5 algorithm or the IMPDEF one. We don't * provide the separate pauth-impdef property for KVM or hvf, @@ -773,6 +776,10 @@ static void aarch64_host_initfn(Object *obj) ARMCPU *cpu =3D ARM_CPU(obj); hvf_arm_set_cpu_features_from_host(cpu); aarch64_add_pauth_properties(obj); +#elif defined(CONFIG_WHPX) + ARMCPU *cpu =3D ARM_CPU(obj); + whpx_arm_set_cpu_features_from_host(cpu); + aarch64_add_pauth_properties(obj); #else g_assert_not_reached(); #endif @@ -780,8 +787,8 @@ static void aarch64_host_initfn(Object *obj) =20 static void aarch64_max_initfn(Object *obj) { - if (kvm_enabled() || hvf_enabled()) { - /* With KVM or HVF, '-cpu max' is identical to '-cpu host' */ + if (hwaccel_enabled()) { + /* When hardware acceleration enabled, '-cpu max' is identical to = '-cpu host' */ aarch64_host_initfn(obj); return; } @@ -800,7 +807,7 @@ static const ARMCPUInfo aarch64_cpus[] =3D { { .name =3D "cortex-a57", .initfn =3D aarch64_a57_initfn }, { .name =3D "cortex-a53", .initfn =3D aarch64_a53_initfn }, { .name =3D "max", .initfn =3D aarch64_max_initfn }, -#if defined(CONFIG_KVM) || defined(CONFIG_HVF) +#if defined(CONFIG_KVM) || defined(CONFIG_HVF) || defined(CONFIG_WHPX) { .name =3D "host", .initfn =3D aarch64_host_initfn }, #endif }; diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c index 23c7beefaf..8f0a54f080 100644 --- a/target/arm/whpx/whpx-all.c +++ b/target/arm/whpx/whpx-all.c @@ -41,6 +41,17 @@ =20 #include #include +#include + +typedef struct ARMHostCPUFeatures { + ARMISARegisters isar; + uint64_t features; + uint64_t midr; + uint32_t reset_sctlr; + const char *dtb_compatible; +} ARMHostCPUFeatures; + +static ARMHostCPUFeatures arm_host_cpu_features; =20 struct whpx_reg_match { WHV_REGISTER_NAME reg; @@ -692,6 +703,99 @@ static void clamp_id_aa64mmfr0_parange_to_ipa_size(ARM= ISARegisters *isar) SET_IDREG(isar, ID_AA64MMFR0, id_aa64mmfr0); } =20 +static uint64_t whpx_read_midr(void) +{ + HKEY key; + uint64_t midr_el1; + DWORD size =3D sizeof(midr_el1); + const char *path =3D "Hardware\\Description\\System\\CentralProcessor\= \0\\"; + assert(!RegOpenKeyExA(HKEY_LOCAL_MACHINE, path, 0, KEY_READ, &key)); + assert(!RegGetValueA(key, NULL, "CP 4000", RRF_RT_REG_QWORD, NULL, &mi= dr_el1, &size)); + RegCloseKey(key); + return midr_el1; +} + +static bool whpx_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) +{ + const struct isar_regs { + WHV_REGISTER_NAME reg; + uint64_t *val; + } regs[] =3D { + { WHvArm64RegisterIdAa64Pfr0El1, &ahcf->isar.idregs[ID_AA64PFR0_EL= 1_IDX] }, + { WHvArm64RegisterIdAa64Pfr1El1, &ahcf->isar.idregs[ID_AA64PFR1_EL= 1_IDX] }, + { WHvArm64RegisterIdAa64Dfr0El1, &ahcf->isar.idregs[ID_AA64DFR0_EL= 1_IDX] }, + { WHvArm64RegisterIdAa64Dfr1El1 , &ahcf->isar.idregs[ID_AA64DFR1_E= L1_IDX] }, + { WHvArm64RegisterIdAa64Isar0El1, &ahcf->isar.idregs[ID_AA64ISAR0_= EL1_IDX] }, + { WHvArm64RegisterIdAa64Isar1El1, &ahcf->isar.idregs[ID_AA64ISAR1_= EL1_IDX] }, + { WHvArm64RegisterIdAa64Isar2El1, &ahcf->isar.idregs[ID_AA64ISAR2_= EL1_IDX] }, + { WHvArm64RegisterIdAa64Mmfr0El1, &ahcf->isar.idregs[ID_AA64MMFR0_= EL1_IDX] }, + { WHvArm64RegisterIdAa64Mmfr1El1, &ahcf->isar.idregs[ID_AA64MMFR1_= EL1_IDX] }, + { WHvArm64RegisterIdAa64Mmfr2El1, &ahcf->isar.idregs[ID_AA64MMFR2_= EL1_IDX] }, + { WHvArm64RegisterIdAa64Mmfr3El1, &ahcf->isar.idregs[ID_AA64MMFR2_= EL1_IDX] } + }; + + int i; + WHV_REGISTER_VALUE val; + + ahcf->dtb_compatible =3D "arm,armv8"; + ahcf->features =3D (1ULL << ARM_FEATURE_V8) | + (1ULL << ARM_FEATURE_NEON) | + (1ULL << ARM_FEATURE_AARCH64) | + (1ULL << ARM_FEATURE_PMU) | + (1ULL << ARM_FEATURE_GENERIC_TIMER); + + for (i =3D 0; i < ARRAY_SIZE(regs); i++) { + clean_whv_register_value(&val); + whpx_get_global_reg(regs[i].reg, &val); + *regs[i].val =3D val.Reg64; + } + + /* + * MIDR_EL1 is not a global register on WHPX + * As such, read the CPU0 from the registry to get a consistent value. + * Otherwise, on heterogenous systems, you'll get variance between CPU= s. + */ + ahcf->midr =3D whpx_read_midr(); + + clamp_id_aa64mmfr0_parange_to_ipa_size(&ahcf->isar); + + /* + * Disable SVE, which is not supported by QEMU whpx yet. + * Work needed for SVE support: + * - SVE state save/restore + * - any potentially needed VL management + * Also disable SME at the same time. (not currently supported by Hype= r-V) + */ + SET_IDREG(&ahcf->isar, ID_AA64PFR0, + GET_IDREG(&ahcf->isar, ID_AA64PFR0) & ~R_ID_AA64PFR0_SVE_MAS= K); + + SET_IDREG(&ahcf->isar, ID_AA64PFR1, + GET_IDREG(&ahcf->isar, ID_AA64PFR1) & ~R_ID_AA64PFR1_SME_MAS= K); + + return true; +} + +void whpx_arm_set_cpu_features_from_host(ARMCPU *cpu) +{ + if (!arm_host_cpu_features.dtb_compatible) { + if (!whpx_enabled() || + !whpx_arm_get_host_cpu_features(&arm_host_cpu_features)) { + /* + * We can't report this error yet, so flag that we need to + * in arm_cpu_realizefn(). + */ + cpu->host_cpu_probe_failed =3D true; + return; + } + } + + cpu->dtb_compatible =3D arm_host_cpu_features.dtb_compatible; + cpu->isar =3D arm_host_cpu_features.isar; + cpu->env.features =3D arm_host_cpu_features.features; + cpu->midr =3D arm_host_cpu_features.midr; + cpu->reset_sctlr =3D arm_host_cpu_features.reset_sctlr; +} + int whpx_init_vcpu(CPUState *cpu) { HRESULT hr; diff --git a/target/arm/whpx_arm.h b/target/arm/whpx_arm.h index de7406b66f..df65fd753c 100644 --- a/target/arm/whpx_arm.h +++ b/target/arm/whpx_arm.h @@ -12,5 +12,6 @@ #include "target/arm/cpu-qom.h" =20 uint32_t whpx_arm_get_ipa_bit_size(void); +void whpx_arm_set_cpu_features_from_host(ARMCPU *cpu); =20 #endif --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759600; cv=none; d=zohomail.com; s=zohoarc; b=X2mrfAGWbHFIC7We2Rao0RoXgQQgiqM4hAM+o9mF1rzVD/+tUysus1gxGNvAjQdY/Q4cu2ZX9FKRSbyj4BCrHJm6OyuYmlrAgCn7yrvDNBnI2OZzO4gxHcPDn18Py5Fnu4YSLN5a8vATOQdHRlEFe3LO6aTGkwZeKnuWD8HuU6g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759600; 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=yaziaz//KfkV1qB+UvLaS9dqmb7Qx8vSQ/YVwpl0DrQ=; b=hN60lpLlBR2uFaFPQkRIl+JYHgnB8kj0sDEP+vRkeSeMWf7X5gWh5ND06ti3jWOkhGtPN6GajBGM/t1og9PqfjCMrUaepV6BwihWWIj4vpfCy3NGqurI1LrP7SBp8PRcVPaQKhYkpizI9NBikYnEVO63mHKWx+AW/qwxCMKjKAQ= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759600624629.7149464767897; Wed, 29 Oct 2025 10:40:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA6F-0004GB-Ja; Wed, 29 Oct 2025 13:36: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 1vEA5q-0003np-BI for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:22 -0400 Received: from p-east2-cluster4-host2-snip4-10.eps.apple.com ([57.103.78.171] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5U-0003Se-8r for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:18 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 56FF01819EFF; Wed, 29 Oct 2025 17:35:38 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id E058F1819DCE; Wed, 29 Oct 2025 16:55:56 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=yaziaz//KfkV1qB+UvLaS9dqmb7Qx8vSQ/YVwpl0DrQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=Okg1Ysq6GKITUn4GRJ89GJrwb2Qt61V3Xyu8UN9MQUgn4R6/n6kYRmiOBK/KvuWSs8qvRC7RyDFZQ0ryBVK9olsHYOEufATMPDbkqPtEoUh4QrMRlxPNE2CCgversWqMe83ChycBakVej3HJ2ksYlLBPnwqQjlcHOFeL2tNmUEzfCq8KwEpaUtAjeRf3deplzioXDQNPjL0WxZaoHuTzVw05LUxi3kR6yD05iD8mmeKn/9mRa7RSCwYSYbCAl/1C2PQmX61ZpP01jubXd93DmXEvOin33zdewB4GxoUcYid0jLxVIPa0Yiv5ds9ESdWp7XFpoT+PIsTf2EMjytYwgw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 22/28] target/arm: whpx: instantiate GIC early Date: Wed, 29 Oct 2025 17:55:04 +0100 Message-ID: <20251029165510.45824-23-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: 9RUrTVtd-tEMB2yVjVvwteGQaxYB3VL8 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX01CqKE8864TV /4/SLBatpNli1Tyg1zKgB3lfbhHyJ9f1bJOWqCE5zw7LZKVdaxrBna2WO6BqhzyosMU2vnnJQIt Op+VS3wsnm91ZFJW1wWKQiT06iGtAVeTH0NjqBg1WO3lBTHe8NZPI29iDkR65LnmDijvAI8uOmk QWa7odymwWadkS/x57vB31gFSK6e23dGbh/GCaKay4JNYPbbd2mK14VZp7v+LCl7hXKf3LlHKNn MgljAk/+NX1vF+6OpzIoLxF/fZYH8B+ge9nXc0ppHZwrE9eD6rtwuPHfDQ2FC5191JSsC8a0E= X-Proofpoint-ORIG-GUID: 9RUrTVtd-tEMB2yVjVvwteGQaxYB3VL8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=506 phishscore=0 clxscore=1030 suspectscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABS2/51uYAdIPoFS0VD7yXJ9nlPkGwVRNrdYtpYeYxPMNlSl1smlj+Kxkq9vdQ3WMGNihLFmVmkFzS2O9RaCvXawYXWD4o5t6EAGBT/y/poq/jmuTTdO8OS7/loD2AgebTZ1NCvPy1nPQ7G3ALghsI+QafOVpCf6g6ZGAML68Y5woA9y8jwHazSgCNCM98QnmuqDJhi3A07tXcV4bF3KuU3uoca35H6FIja4vwV/TsceZt3TJl2/hWn/GfBIYNb+T8gYHboYo0YLntjx7/owi80E9ICYspFJeep32sOSrHY6rPW3fJYfr4eCrVv6CsdVszU1/D4JFuIJNEGwW5Yg/T9KS/6AQsI0A6T53MrbURbmj44EewZ7WycCHVlNO6XlqlomBx3oNrdxfedLPTM2bgC7KI+g3qy5hxddyI6kNo3pG+bypRAwdlK878agVDv3XrHn9cFiQfrdQle3/uPJvW9WywCopmeATnuXhU9mPgkxX+xCTHsdEthcPBGRFlw6v+Eqgsi8P8UgJI/ZDwGcI4PCe+05ZFgWDX9AdP46QPwVinV/L0R5W21cnU7+bY9Vf4e30m6SsvL9abSzZEuLesd/9Jz8z1cKR+D/fClyM5BUQfpHbBK2EB0Y35lLfJaDEgdE24atQpH1Mk5LvCz8M98sQafG3kqgyqMFlg3v1vniZ8YRS/mRhKPpa/6WCyVsS/jzaa0WVnzLt0VXkUvDsrA6Goy3N2rwPcAEdnA8oYwFoUEoIrVJV544O9C/vQOwCkrBn/OKGfHxX4Vg== 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=57.103.78.171; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759603008154100 Content-Type: text/plain; charset="utf-8" While figuring out a better spot for it, put it in whpx_accel_init. Needs to be done before WHvSetupPartition. Signed-off-by: Mohamed Mediouni Reviewed-by: Pierrick Bouvier --- target/arm/whpx/whpx-all.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c index 8f0a54f080..4d58e5e939 100644 --- a/target/arm/whpx/whpx-all.c +++ b/target/arm/whpx/whpx-all.c @@ -973,6 +973,29 @@ int whpx_accel_init(AccelState *as, MachineState *ms) =20 memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY)); =20 + WHV_ARM64_IC_PARAMETERS ic_params =3D { + .EmulationMode =3D WHvArm64IcEmulationModeGicV3, + .GicV3Parameters =3D { + .GicdBaseAddress =3D 0x08000000, + .GitsTranslaterBaseAddress =3D 0x08080000, + .GicLpiIntIdBits =3D 0, + .GicPpiPerformanceMonitorsInterrupt =3D VIRTUAL_PMU_IRQ, + .GicPpiOverflowInterruptFromCntv =3D ARCH_TIMER_VIRT_IRQ + } + }; + prop.Arm64IcParameters =3D ic_params; + + hr =3D whp_dispatch.WHvSetPartitionProperty( + whpx->partition, + WHvPartitionPropertyCodeArm64IcParameters, + &prop, + sizeof(WHV_PARTITION_PROPERTY)); + if (FAILED(hr)) { + error_report("WHPX: Failed to enable GICv3 interrupt controller, h= r=3D%08lx", hr); + ret =3D -EINVAL; + goto error; + } + hr =3D whp_dispatch.WHvSetupPartition(whpx->partition); if (FAILED(hr)) { error_report("WHPX: Failed to setup partition, hr=3D%08lx", hr); --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759598; cv=none; d=zohomail.com; s=zohoarc; b=V9PjUjnPRK2uMa8SgwURgLpHu6Hpnsk02etfGDR0ArQfAkDuzJb9hxzUownGx3a5NF1R5py+vuPmTk0QGA99iDLN3AuqUzTF0PXq4T+PDlDMgoa+s4PbTT6FkuztC1yxGgvGUFGgmXafOtqcuRAxF/usJJDlhKCFJ7pTHZJHV18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759598; 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=7ELmogO1rP/Q466oRv7Y0E5YhY0QvblNmMS2WwTWd7k=; b=Xqfrn03J6FyIfDy5NV73M2kwipQwFq3Hf9W/obmkFY3rNvCXRaJi+Vi5vj+kgxaTa6dwiht+wUyqS5OIYBfnLY2Zl3C1onSBd+QoO6iBwoRFVEMvCGeJCa2lnjBzZWPhvVUJN9w0nintlVTCOutt7vHJIXHiJ6fq8vVc9Oj+9YI= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759598358695.3150278023649; Wed, 29 Oct 2025 10:39:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA6S-0004PX-1n; Wed, 29 Oct 2025 13:36:56 -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 1vEA5x-0003vK-DU for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:27 -0400 Received: from p-east2-cluster4-host7-snip4-10.eps.apple.com ([57.103.78.241] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5U-0003Sk-Lu for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:24 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 16B6F180853D; Wed, 29 Oct 2025 17:35:39 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 85BDA186291B; Wed, 29 Oct 2025 16:55:58 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=7ELmogO1rP/Q466oRv7Y0E5YhY0QvblNmMS2WwTWd7k=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=AkPeHfz3q96+6VpTtBnyGlw2JeOATwJeQypvXJ1mMFwcl7s2uOR/n26og45HigShzXCszr8HXIsNIg6o6fWcDzmZ5icMeBd1Nrwn02UZawKwE002Xk6kAwp6a3IKMs+Yxte9SpnuyvT2YTzwgVzONhLKCM0GsfUiafAN/B3eL9IYQkwxFUCAo79zzoVgx+FnxrSxDvrO76YweHEDMZ6cw6WVvWbaGo/MH+F/cvvcYDO4M9Z76g0vTaeWCVrdhSYWTQ4cJPsPLIPr4ACz4mlsD+cE4y983rUGJtbNNAlKk2Q24zQxhfnCOvbJDgIR8vMP0jW4bH/N6X2TtnU5TeUvzw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 23/28] whpx: arm64: gicv3: add migration blocker Date: Wed, 29 Oct 2025 17:55:05 +0100 Message-ID: <20251029165510.45824-24-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: XLVWkQuWUAmtva20PGQCEJP3i3DHJtsA X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX4fSt+JxTrBN6 SCvDgRtTh06L/iMQWub8CCHyZHa+iOi+3NQyZeYDuY+LCwFWbUjolvHS+Amht+VEdzD1AvRRWOm x6B7KGEPsPSqbkQuVWK8tGC4oJQBHRhQPKDO5DN9RKdsUp+7hGXK9edBskf9cjz/3YaONAHLz5/ NfkTt0296h2mgllYeqrc277mXqFvtbGQ5X954xw2dBk0/ZMeJHLPsWmiHhcanbEzWalQt/4BO4f wSoBM+erjTTJt6Nd8HB+H85Z1jZ6XEII5VMJO2chhnAJBwrxR9XkMNWQMzugU0Lk28PP+PUXc= X-Proofpoint-GUID: XLVWkQuWUAmtva20PGQCEJP3i3DHJtsA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 suspectscore=0 bulkscore=0 spamscore=0 mlxlogscore=763 malwarescore=0 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABzf1XhVsFpObfHGCDSUXExjYbBwCdUjjpCxUA3Q+BkdS9DbL0gxSxJ/9cTM0OWq9btc5mGrTWMV/tJoqOPz1sZ9S21VW8AQPcqcoMUgWaoVJFWNVdAHosGGr1q0scSPkfFY3YHaqaoQMBCSQTUq79gBG67buqognz5li+toEP3fGSoBrArlAGXKeRNj+MnDDATUgBUZO8DOfsquPFxLrA3bDJ52Nuoavkx6a/PdBOI0fAB2Xfc64hqc+oU1X0EMxjUDeMsW2aG+tobIYqlFLFXUwGqh3ZBtLrNEp8CLGtoBKG2LoR48Vja1uCbECoOJPu5mYSxvGCDuv/QPsplkZZQ57U8QCZWEFXJyym4YRfGbA2wABcuRkVibe2TKNGz4Ebt/3yFpwy8a7v4L9cZkVB0WN5ZAguzinRIETRvQN1xoHTUOb6sKbNfFKpFJRq1VtqjzJtIwVe8+42dmWcS4iiRv6z9qcKDkx2Jpor6jOOoKeSbc06gU/pO68BtQYCbXkhm29oQM74eO6TxiCv+IhfUIZeP91a9EeIEznLVsbM/viNlfxJhdNNSVlLR+2hLtIRY1wQPXRBlMlotACmYo1gHhl+VQNOPYU89TI4Jx4ZBg2XGARA6Ldj1dyPUDc0u0Oqnq7AsvbCFrgztHsdANaAzHSscVn7A7/xpe0terDIAnLX20AeCfQS8Herd2QeMUfN7pi1QRUm4nYnOHVCzzWkhQw31ayZIQQb9R8yV7IodA3amjuwXPF1BkM8cX5wu920dmVW0X5JSjCk0kqZfH14 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=57.103.78.241; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759600942154100 Content-Type: text/plain; charset="utf-8" GICv3 state save-restore is currently not implemented yet. Signed-off-by: Mohamed Mediouni Reviewed-by: Pierrick Bouvier --- hw/intc/arm_gicv3_whpx.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/intc/arm_gicv3_whpx.c b/hw/intc/arm_gicv3_whpx.c index 88a05e5901..6ceae78483 100644 --- a/hw/intc/arm_gicv3_whpx.c +++ b/hw/intc/arm_gicv3_whpx.c @@ -17,6 +17,7 @@ #include "system/whpx-internal.h" #include "gicv3_internal.h" #include "vgic_common.h" +#include "migration/blocker.h" #include "qom/object.h" #include "target/arm/cpregs.h" =20 @@ -205,6 +206,15 @@ static void whpx_gicv3_realize(DeviceState *dev, Error= **errp) error_setg(errp, "Nested virtualisation not currently supported by= WHPX."); return; } + + Error *whpx_migration_blocker =3D NULL; + + error_setg(&whpx_migration_blocker, + "Live migration disabled because GIC state save/restore not suppor= ted on WHPX"); + if (migrate_add_blocker(&whpx_migration_blocker, errp)) { + error_free(whpx_migration_blocker); + return; + } } =20 static void whpx_gicv3_class_init(ObjectClass *klass, const void *data) --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759934; cv=none; d=zohomail.com; s=zohoarc; b=JANuAFwrOXkKV/XDL7qng38n6beDWIxjISKOKfHCXTHAAkAN9Znbw1EPnMhIURqB5nB2cJu7jl0swqnanwu8g8cUl3tcteWQvMQoyIbn6BF/sufQgFAeeqNKl2A0vaNL5RiAT3b8OTgll3Rad9d56/qVmLbrDSB0HACOy5Qp4oo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759934; 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=w3P/pjd9SPTWUADMWm5TSzmLlO2TAvpYEIX8vxIZRXs=; b=gSCEU4CwpbFeX7+OvPfVcP+IS29Asw5f3Sw5btWe3u0oO5Z/XShiBoZAuKAfFt7mlp7Jt3bgqYcklnhuo0j1IE8+bVSQa//4iGHta0PYLqUXOJX+APGpqXAabH3ey7GU1NZjkx+CtH5NrjXvT+fcS27dQBn+lNJ1r51SN0pW4qA= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759934613431.63702000673845; Wed, 29 Oct 2025 10:45:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA6Q-0004Ny-0V; Wed, 29 Oct 2025 13:36:56 -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 1vEA5o-0003n7-Gb for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:17 -0400 Received: from p-east2-cluster4-host11-snip4-10.eps.apple.com ([57.103.78.181] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5U-0003Sl-6m for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:15 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id BF8DE1824483; Wed, 29 Oct 2025 17:35:48 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id B41C3182A801; Wed, 29 Oct 2025 16:56:01 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=w3P/pjd9SPTWUADMWm5TSzmLlO2TAvpYEIX8vxIZRXs=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=OgvunuWpLaKCom1NacconB+cv9N7sCeZ+fVdulohQ+BBTluapFoFW/TtwKFKFCcZ6lIdA43uijHNXY7pha5UwCAMREpmQfuIAebHXHGWIPj0HrPqk41Fkvw8n1kXmZ4vcRa/7NMVJaIqDilzU95N7r9j9twZ51P8uiyUBTGrlxyIsghdnr7UxNuM9FSG1r+E86tezuRGTPgi/JpRiwLcbpTUzHWNE2uux/1ktzMBsX3qOQKxrRiYiiw+oV5HxZaZUrDCVyJyor1AM+MnDDEb2Pue8ig+jXk0k7PvvvS4kPYfCBBNU1jvBqWeKYKkOm7SJwZdMuiVIJFXHiKdXS5Ixw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 24/28] whpx: enable arm64 builds Date: Wed, 29 Oct 2025 17:55:06 +0100 Message-ID: <20251029165510.45824-25-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX+dcQi7zlmUYO AX9d4jv4yAYtleQeY9bLS61CgK5r5iIPNFTizB4iyNzke+azDE7eTbc8ELHlHNtYyLQeXNDfnrw unMPbucttwNFiD5Ie0qpilT2ke3dGizmIucJjgtPU+JOvIoWZiG4uuKtT31tQqvUNcanwEA5vql 5e0Kv3INEmBv2XT003M5on0mi9YVh4pM6PRSXdBHx565zO29ayFCTYaJoNVTKAbYDlOjM3hayx7 YX2fBnwNPG27+Use1CofMLpdbSimcQERoSRvhBPUjXposK78jINXnxf5jnBPqwBhrGNS92BOc= X-Proofpoint-GUID: I3Q3kw4xSCbJU6QujTnVSNVGM4wrtI9P X-Proofpoint-ORIG-GUID: I3Q3kw4xSCbJU6QujTnVSNVGM4wrtI9P X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 mlxlogscore=627 bulkscore=0 spamscore=0 malwarescore=0 phishscore=0 clxscore=1030 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABTyYB3IyHmoXdl5wldOs4RJ2Rfh3B7o3T5Vx+ViEiuU4jsEDwQ3K+rGTLoXgTjW56X9L/0ExF7riSXoYApgBy2azVW4kpB5LzhYEdwsO6LMRKdGQiqR43IMPNKMiz1Oizb2CzxmH+hosuXXsWVOX/VeBByzI0a3pb9Cetk7dN6Wj4VvIxApqZb39H1cFR13Ir3NHYMau/v+0HEbdH1F7IKXgAf7pgqmjOhgq0qIl/5IrpbZEtnHAT4j0HMNI9Zxi39hl5//WvEm7fF/LgSaNy1IwUATCzo9KaFQ03F7lW2/6JNNq4Jj2/B58dK5XsGuSBz9Wb6tGeYZYtLQ6aSclwo/h/nTdup7nV/VNVJluuKCgeD98t5whgOTsmZjRoKySbDAyZEE+iU2F1jhdwhg7UYXNndhXo7RiXaL2GE+VxwPOTNVlfdmWZqnbKjhjDAzOs/A2k7aFUV5v2SQ9lJheICA/Kg8gMCge/NLpeZW2OA4OreZWUg/6TvYVEzYgqrCbX6JoaRHLNHn/37i3+iRchNedHR2mEP/u5QWH3bu6WqancFIzJJSrIp0pI2Jy2zsEdEGZfvoFxYC+RDmTkfBZJJXmUs8RHmhCDZlFd4Xv4g6L/EtGydOxogCqRZnux+gSnUDut3AuHwbQehot3pdBm5RQZwKBHtiaCNqeBSZBN4XLvIlUBaXH1uciiSjvTqDbxT2mO7SwCtZLVmkde3FzYfUnfqBr+O5t24O1lpZXYbmSTc39G2sTed+4+wSOLyuxl 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=57.103.78.181; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.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_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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759935917158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni Reviewed-by: Pierrick Bouvier --- meson.build | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 8ad37c992b..065cb1c493 100644 --- a/meson.build +++ b/meson.build @@ -325,7 +325,8 @@ accelerator_targets +=3D { 'CONFIG_XEN': xen_targets } =20 if cpu =3D=3D 'aarch64' accelerator_targets +=3D { - 'CONFIG_HVF': ['aarch64-softmmu'] + 'CONFIG_HVF': ['aarch64-softmmu'], + 'CONFIG_WHPX': ['aarch64-softmmu'] } elif cpu =3D=3D 'x86_64' accelerator_targets +=3D { @@ -891,13 +892,18 @@ if get_option('mshv').allowed() and host_os =3D=3D 'l= inux' endif =20 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') - elif cc.has_header('winhvplatform.h', required: get_option('whpx')) and \ - cc.has_header('winhvemulation.h', required: get_option('whpx')) - accelerators +=3D 'CONFIG_WHPX' + if cpu =3D=3D 'i386' + if get_option('whpx').enabled() + error('WHPX requires 64-bit host') + endif + # Leave CONFIG_WHPX disabled + else + if cc.has_header('winhvplatform.h', required: get_option('whpx')) and \ + cc.has_header('winhvemulation.h', required: get_option('whpx')) + accelerators +=3D 'CONFIG_WHPX' + endif endif -endif + endif =20 hvf =3D not_found if get_option('hvf').allowed() --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759817; cv=none; d=zohomail.com; s=zohoarc; b=BN7CXbCGS+wB4ED+DIzFSPGKpoGNvoJlVjcNgY7x+tlDCn1kezUBy3Pk6oBwm/lLrnztkBJWCxYsbP3RsccEdJSRONlHJ76e91DucfD87nblY7+nNaPHp6WUr+eCJRflO5lrIquQ07f8kf7RDMA43fdTvcJHlR3AVjVLUT5un8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759817; 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=RQfGDhZ4RUZHZEjwdTSwWBJnMpGjZt55WjAucF76QqE=; b=G5bB+VpzVAkAoXp5d0IOd3DJpVxeBMUruvxBcwAjz1MxrcKRBAxjVTOqSBo9xHNyms3rNhvo+O4HKX2t7md4AmGYRDPS2CX6km+beUHKSfIh1ret5LOeJLhGCmXd8qcUjfK8qst/yBRYIaj8NK/Eg5m4XR+QNFK+AQiHqB4G1JU= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759817758678.2945923203981; Wed, 29 Oct 2025 10:43:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA6T-0004S4-54; Wed, 29 Oct 2025 13:36: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 1vEA64-00044v-72 for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:32 -0400 Received: from p-east2-cluster4-host1-snip4-6.eps.apple.com ([57.103.78.157] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5b-0003UE-6J for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:31 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 36FAD18270CA; Wed, 29 Oct 2025 17:35:51 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 935F1182A805; Wed, 29 Oct 2025 16:56:10 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=RQfGDhZ4RUZHZEjwdTSwWBJnMpGjZt55WjAucF76QqE=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=Og0lpMSAMT6wNRUOD7q7KKlcN4NmvQ5VKPRconC5MGn4v2iYnIQd5SaR1eFjzPUApKfT3dHha8o5aTIwzm/bOwBuE5AbFtXnAbgvwtUeLiPLH8OktuAr7vCi78jRf5Hs8XyjHG525W9HS/jey4IlU5Y76A0hcN6KPvva2yj1Not9xIdvNBKEfiC4ZVizHWn2nPJEhzikFrdHfcW6Gj69EocZ5tTL8I3ZVR5t8XuhTnIdwGAGtH5RPbmQK2ORH7tmS6lDfXFEmfAutKctCioPzjOuukHTk8AbwesFxhK4um9QZfRMELsDIppOWSdQnjSfOKaqNZFbU46Oz13MTH2w0A== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v10 25/28] MAINTAINERS: update maintainers for WHPX Date: Wed, 29 Oct 2025 17:55:07 +0100 Message-ID: <20251029165510.45824-26-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: u_BLb492WGui8n-_TSGCe-N85hjru3_9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX01J0gTkD/B7a mR5aE5y2WwmYlVvBfmn2HydI3m7yWzWZvNwLk6ifNRoEL76ADQiJFnuBqe/ZIk/AYSwMpfr4yTP FR7WvR0OTLAoxqznPjjJVGstifjIr4Wtcfd2ZwTtin9jxajBr7RZleuLByFh2aXbvX8WdQ6iN1z lFP/M8wAqo5Lwtf9KSPg4Yc8kTqtfZ3Xi4pA0EG2lSfhguBxi6Q6A2mhfmrLFDo4CfrSJGc8XDg AwwmH3MjPp6QZXGrzN7aWHJoqaA0FykKNQgkCk2edNLRNFNPWSKdduYPr2la6ksJePDH1aPyA= X-Proofpoint-GUID: u_BLb492WGui8n-_TSGCe-N85hjru3_9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 suspectscore=0 bulkscore=0 spamscore=0 mlxlogscore=611 malwarescore=0 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABhEdBocgLw5z/lTUEAjHxoDxoYPL38zcwLZuVQDTWY8jHATlSWVc0bdGyylpTpXr4DSDStAjL3Bm72OZsQi4QrhHIBqTCVyMxGAGaCbVnNLgg+YwIzHypYr7Pv5bju1z3hrmxTAFAYCXdTV2FS7bRzOYQYfxCGtsdXNxkZN0T/dRuElEcTIK25xTqqHgT/XjotWCVAeYtVGK9jodt4sxKLxq2IUXDZzAdFOOOT27ZbcWI1UIt/uAV5GgpTZEKdQpuwSKG3U3fm/9v6e0fcEOywW30VXC9tfbqvdAQiQ5PeSNiLB/ciuNspPXBdmsdsg61lFG0KD5OYrcWlt14UlyWRr6Wpr8vgzaSip5uZqgz8fUeZ92UlVJVv1rFVx2+WgsAdXuk4o7NoDXbEJfXWplXehXT2+7HQL+L8fObUksZ+MGzkePbjT3E5MPCzDDjqJl5OiREkLqHiRLpksNxXp0xjXJT+jKseM5vdjqg8aDyvczi5gL0mkZcJctTcuoBxEMpOiF8kE38warwUTagF6W+wUhSPBUQY/ZTnMACRYOuwRDUF1KddY8R77huIOlx657SongoUnxV7zJbbUTQWh4rpvzk12d4J8Fp7aRHQMCVFhVFm0Yl7ohuG1haOMe96cqDEMOGI42lMZBTPJWo2tvZX9+DcSkzHZNjwKYZ/Ys4D5UFioIu0aji6BZOQLpNVzPhsTXLiB6Jn2lzc1ACZynQvLTYOsd2En0Thahca2xrBwIVfC5nORdf 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=57.103.78.157; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.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_MSPIKE_H2=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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759820554158500 Content-Type: text/plain; charset="utf-8" And add arm64 files. From Pedro Barbuda (on Teams): > we meant to have that switched a while back. you can add me as the mainta= iner. Pedro Barbuda (pbarbuda@microsoft.com) Signed-off-by: Mohamed Mediouni --- MAINTAINERS | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index c6b7f45459..0e7288116f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -546,11 +546,14 @@ F: accel/stubs/hvf-stub.c F: include/system/hvf.h F: include/system/hvf_int.h =20 -WHPX CPUs -M: Sunil Muthuswamy +WHPX +M: Pedro Barbuda +M: Mohamed Mediouni S: Supported F: accel/whpx/ F: target/i386/whpx/ +F: target/arm/whpx_arm.h +F: target/arm/whpx/ F: accel/stubs/whpx-stub.c F: include/system/whpx.h F: include/system/whpx-accel-ops.h --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759437; cv=none; d=zohomail.com; s=zohoarc; b=GzaTiBBS2r00L6i27Ip26QdeBYdUuVEYIlWIVbmuGc3Fl/FLj1WQbriAkFL89X60WMO5pbG5c/6jaSRrvcAyq/kREv74Knt/DAxMO6M+VY3D4RuEwgbLatRle5d9LJBBJo64kJQbcTrS/xSFxfc+8pRLykux8SUu5MuA2WP3ADI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759437; 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=jo9W/NpYfEdIC6CdCIx10Eqt7ku8SV4hAzngP6kYZbk=; b=J2JgewuODB8G6wlTb1ycM0dRKTJqWBi4NIWzXeZdc2DF7EGXj2It2VoOAslmQyPETT+SwEPgtyQ2JAk6m1uJmErzMN77g+YFet2zFMb1qhglhLLeZNwPMmqAPtTSXbBXHawTIh+bG/LdqRvRwKEfrEOfvczs9foR7j/hAzYIPdk= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759437618254.7138953660659; Wed, 29 Oct 2025 10:37:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA6N-0004MH-3j; Wed, 29 Oct 2025 13:36: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 1vEA64-00044u-75 for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:32 -0400 Received: from p-east2-cluster4-host7-snip4-2.eps.apple.com ([57.103.78.233] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5W-0003UD-Re for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:31 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id AF3E11822229; Wed, 29 Oct 2025 17:35:52 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 1F70C182A829; Wed, 29 Oct 2025 16:56:12 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=jo9W/NpYfEdIC6CdCIx10Eqt7ku8SV4hAzngP6kYZbk=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=fKO4tMTeDao8zb9g9cBp0oH/7TRt/ojvbx6OGogenTqZb6D9CNaSxR40KLTFZEy8JhiLh3iEGzzd66/ekup4sN8XZE7mPCB152q1hRfOYgWksYLCR0OKTMQMPT0xkmTXizzNdphBaLMi/PkX27WkDiTAMaC0gPRUIPSD6bnXDpBNjMQ2GVhOFl5DpKknj/DGCyZi6f2mWaAQ6hG6+Rfp/pXn4PyY9iFmgvqowNVwK1iUGsER7xIfxp89P43wrqyQbhf+G8YRoPHoTRATZ+nuZHIfd53h3Q39J2QHhDRoXSDEbc61KAqx2ZVGSBsvxT1erg4+3Y2T1BkO28DwoNiqkg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v10 26/28] whpx: apic: use non-deprecated APIs to control interrupt controller state Date: Wed, 29 Oct 2025 17:55:08 +0100 Message-ID: <20251029165510.45824-27-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: KIGkLvFYij0r-LB59apV6eRjmKqNHzmz X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX3EX7BAezJXmu ex54krSvUGIi03TT/uJs0SMsq8fUttmpPeGjUXZkeL9Ivw1Uu5Ksc9cAkvpgn6GXdtH9UbeADS0 nfUbRm7rqRVzh+QcrlIq49iGi+s3iSnLJeZqBOFQSjVIZq+OKZb2lXo9COPCWwzb1cUJ/yLGMv/ MDiPyq28GG3Qg0e3245Epi6XaaifOwna2Ne3GjOdb0SpG6sT1l7S83Zi+y+TqHlMYPjks6f4ai5 pgsCmOYtjkL6kYcLY40hbum6xXfwPU8upkUN5/l1zgneRMxUDO97coW5EPSH1B8jj50yXzqFo= X-Proofpoint-GUID: KIGkLvFYij0r-LB59apV6eRjmKqNHzmz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 clxscore=1030 bulkscore=0 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 mlxlogscore=618 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAAB3RRpPt/zdTnoC0Qlep2bJr6VbAHPl85HEcgYnP7TRnbJaG5dZVWZEwLMXVllYWMCr8xarPGkIRDjxybYp/h2H5AZ8QoFEZeEp+0FFWpQG16suzONb9ovFCbCruBNmIvNzsXKEJVDSfWLBkC5aJRmFcOR+YkxfS3pgy8UcmUaItH0alczd+S3wRsnbeMQTzq6431GH/NAswobxr1fZJWG5ihiO2FaiCQr5gjb9MjS+CImqbT2qffrE+NhSKDQ9kh6uBOtwRa/DxW8kQfqZz+CCB1S3usmLOyYG064wiHBRrhLOwEzTi4RDvcg+ywjoXITG2wioYdcecT4DKV6ofgbYinBaB5E2JdHFY8puohAQ9guU4RgXfnbIbM2S4/RsfdhFWUb3p9L+4x2ZlnkP5MWFGzUZOkOz1S6GhlKfd98sVPsSDcmOVMONSSt3clMjPIYwiKkUCvLgEMiwua1parBaXc7Ta1twar3EfyFx20W47cl2Nk8MJj+HfHvaWiMjds8NIJBep7xjMgpBDVlVrtomqSRReofN1u2SMoIwwAS9Xbd7mtiZiCpnQ/Kuuff9rIQLdaRhITh0Ezc/oZSJDVPoCNP654C6iTsclcBaZIe/4wnCqw/u7a8Vq+UDvmcrubzq/rqNf1WNHmex2CLh5eg+ItRpcdY1orBKiGRE5M9CXqozyn6BNLVNSb+Q7MBlaFefC7W0vy6uRmWhvCrOuXJWWL2GteR48P0DiUsWfYMytnaDhheMoPqHaJ0OOLvPekxz8syzxGxKk9jE6iFM0A4TZNgfpwOP3E21P0= 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=57.103.78.233; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.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_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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759468593154100 Content-Type: text/plain; charset="utf-8" WHvGetVirtualProcessorInterruptControllerState2 and WHvSetVirtualProcessorInterruptControllerState2 are deprecated since Windows 10 version 2004. Use the non-deprecated WHvGetVirtualProcessorState and WHvSetVirtualProcessorState when available. Signed-off-by: Mohamed Mediouni Reviewed-by: Pierrick Bouvier --- include/system/whpx-internal.h | 9 +++++++ target/i386/whpx/whpx-apic.c | 46 +++++++++++++++++++++++++--------- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/include/system/whpx-internal.h b/include/system/whpx-internal.h index 81c0c1819f..90b4077b76 100644 --- a/include/system/whpx-internal.h +++ b/include/system/whpx-internal.h @@ -86,6 +86,15 @@ void whpx_apic_get(APICCommonState *s); X(HRESULT, WHvSetVirtualProcessorInterruptControllerState2, \ (WHV_PARTITION_HANDLE Partition, UINT32 VpIndex, PVOID State, \ UINT32 StateSize)) \ + X(HRESULT, WHvGetVirtualProcessorState, \ + (WHV_PARTITION_HANDLE Partition, UINT32 VpIndex, \ + WHV_VIRTUAL_PROCESSOR_STATE_TYPE StateType, PVOID Buffer, \ + UINT32 BufferSizeInBytes, UINT32 *BytesWritten)) \ + X(HRESULT, WHvSetVirtualProcessorState, \ + (WHV_PARTITION_HANDLE Partition, UINT32 VpIndex, \ + WHV_VIRTUAL_PROCESSOR_STATE_TYPE StateType, PVOID Buffer, \ + UINT32 BufferSizeInBytes)) \ + =20 #define LIST_WINHVEMULATION_FUNCTIONS(X) \ X(HRESULT, WHvEmulatorCreateEmulator, (const WHV_EMULATOR_CALLBACKS* Cal= lbacks, WHV_EMULATOR_HANDLE* Emulator)) \ diff --git a/target/i386/whpx/whpx-apic.c b/target/i386/whpx/whpx-apic.c index b934fdcbe1..fa45a64b21 100644 --- a/target/i386/whpx/whpx-apic.c +++ b/target/i386/whpx/whpx-apic.c @@ -137,11 +137,21 @@ static void whpx_apic_put(CPUState *cs, run_on_cpu_da= ta data) whpx_put_apic_base(CPU(s->cpu), s->apicbase); whpx_put_apic_state(s, &kapic); =20 - hr =3D whp_dispatch.WHvSetVirtualProcessorInterruptControllerState2( - whpx_global.partition, - cs->cpu_index, - &kapic, - sizeof(kapic)); + if (whp_dispatch.WHvSetVirtualProcessorState) { + hr =3D whp_dispatch.WHvSetVirtualProcessorState( + whpx_global.partition, + cs->cpu_index, + WHvVirtualProcessorStateTypeInterruptControllerState2, + &kapic, + sizeof(kapic)); + } else { + hr =3D whp_dispatch.WHvSetVirtualProcessorInterruptControllerState= 2( + whpx_global.partition, + cs->cpu_index, + &kapic, + sizeof(kapic)); + } + if (FAILED(hr)) { fprintf(stderr, "WHvSetVirtualProcessorInterruptControllerState failed: %08lx\= n", @@ -155,16 +165,28 @@ void whpx_apic_get(APICCommonState *s) { CPUState *cpu =3D CPU(s->cpu); struct whpx_lapic_state kapic; + HRESULT hr; + + if (whp_dispatch.WHvGetVirtualProcessorState) { + hr =3D whp_dispatch.WHvGetVirtualProcessorState( + whpx_global.partition, + cpu->cpu_index, + WHvVirtualProcessorStateTypeInterruptControllerState2, + &kapic, + sizeof(kapic), + NULL); + } else { + hr =3D whp_dispatch.WHvGetVirtualProcessorInterruptControllerState= 2( + whpx_global.partition, + cpu->cpu_index, + &kapic, + sizeof(kapic), + NULL); + } =20 - HRESULT hr =3D whp_dispatch.WHvGetVirtualProcessorInterruptControllerS= tate2( - whpx_global.partition, - cpu->cpu_index, - &kapic, - sizeof(kapic), - NULL); if (FAILED(hr)) { fprintf(stderr, - "WHvSetVirtualProcessorInterruptControllerState failed: %08lx\= n", + "WHvGetVirtualProcessorInterruptControllerState failed: %08lx\= n", hr); =20 abort(); --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759484; cv=none; d=zohomail.com; s=zohoarc; b=YnKngzW8hOmQbs7d/bx8alzuEYeIOJfA8g/Ej+t5IELhAxwpNeSQ+YnVYNW6uJz8+oP37pCqSX00/w/3tKVpFAY3764+FGVCNCAP0HBWDn2kExocdtBeivV2qyRjNW4mODZSHp0tedy2tDll7rdD/L2CGiOXvwUnfx/BgVI/TAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759484; 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=NOUCweN0BwDWHptjKrVueVuLmTbPgqxKBFU13NRtxRY=; b=ii/eDH9DFhJ9EQGoxdiub2py1G3WbqFAZKRlStSVRyNg52f99cb2zVWOkdgz2griO5p8sO/nfv1fNs1kxok3T1bqWv7/qlC87qR0N5UQ3WG8K4Lsy2uvfWqDTOfo2EGyvMFBB7MjQ9OmlOpMI9iYc55wcGd22vKPbOIB8ZQhNGg= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759484508215.2043796567773; Wed, 29 Oct 2025 10:38:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA6M-0004LZ-Ld; Wed, 29 Oct 2025 13:36: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 1vEA64-00044x-8X for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:32 -0400 Received: from p-east2-cluster4-host4-snip4-10.eps.apple.com ([57.103.78.151] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5c-0003WU-CI for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:31 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 433A118270D7; Wed, 29 Oct 2025 17:35:54 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id BF7F6180DD80; Wed, 29 Oct 2025 16:56:13 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=NOUCweN0BwDWHptjKrVueVuLmTbPgqxKBFU13NRtxRY=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=JiXz4u5ARNp3HoHOx5tOCnrqlTwHaFzOHmpuCA6ZAt3TILLP2MzSXYhcsbw0ID2ZWWXKKApo5jqnnFE6XciiYm/IFJ4bUH0m7+V7nWl+810ga1sX/s981utrFM5hnVbHQxOa4c+fsjhdo+CrSWV7/Zvr/Bd9jIXrunxJmRUZeggktCoo9RrksDzRaRH04anYiKmn7rp8qpsYvSdNT9/K8ghzUX/CmhOqzH1BaE8d0ofUQ+eBUKtYxyCGBvvbV2v/ma/4EeKdtxwJuuRBNy4jk6b7lbeizbhsq1Bxq1zq3fikyTRCbm+T2C+omgwGe9ZD8UTe3stbZuJeOJn5WbjsXw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v10 27/28] whpx: arm64: check for physical address width after WHPX availability Date: Wed, 29 Oct 2025 17:55:09 +0100 Message-ID: <20251029165510.45824-28-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: NgaY8in12Kp1RhqVMaNsMAdawsC0c5yJ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX8IaYA/Yq7yHq xvqZVwtQbOyAQH1PepRFS55qKlKtlZsmUfmIG0mMBczk/nVPcdJRzQFQejc45/LCNz0T7MdKsRb PsvaeLuLFOjEic6JzkmVeCiPo5nA7dkkrb5B3wNDYhnKaW3A71jSr/b+a1d+cnf+44Wi30UHpDW ByjTiFuttXQr0Gwx56qbfjHAILhbJNouorex9uNKrsA9SA09XPV+qTGNsvsvt2sTJSWfRXYU5ow m/FsM2fxwc0Dnb1ZMNyUysa+CU993NoF57a5FRSomEOiw7ijbX6ASOvCA/XaYKE45HGjSKF48= X-Proofpoint-ORIG-GUID: NgaY8in12Kp1RhqVMaNsMAdawsC0c5yJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1030 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=784 phishscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAAB+VxYt4b/atB6I4oT2qs0HWp6bQBQlQLoYuqwTvr4KigekV2wNAKIdwkbgGaZf0EqMhEd6gynn7HxJmwl978kTaMSOObpO6zlwVsljxUHlwW2a6j7iNz1/dgq2Dxpu4PYp/uRqOkconOCPwMdvW+LBhIRRiwmmqnDuAaH2sTYGpkSow3dQipDhOGrZJs1+mzKg4+4DwL5sOqhjmiV5NW+1XdZyKJ77FSiK+eLgXzvZcS/bjRqv1NL+s5fCUbikfTlks31vANc5bSOcKlxdjO8WUu7p2GWexCR10LxlhyFbU1uHu/XBjkoJmZYIAQ69S9W2iW+LNNchhyJjRdTl/x6C+pfAoZa6R5lKO27JvmpZvpKbrO63SwISK7x5rPagEf+1AV645h1R2BZEuF0JLveiPf0DU9XkrTFJPOQOw0vGx/Dl0lY0XApE9RKq37V2EIP+/8pnRTdWyL3+B+DfJAycamRAhVv+64H0DDCqi7Stzh1AZFKZRb3GPIoLs5mdcfPt95T8UpLX6rPqsddYpMyY4t/Nks7hm/CEmkGbOeVDznrS5GZBa5sS/tTfCMIH8uKYzhVB9hSY2jVO/f26aax+ZATVmms6LGKrq9a2Zhf6HiuBxZEC2l99WAeG7iNyibgXrn/ZnNs9dh4EbKv+FXktacYVXGAqjG8ZXhHm0z6bP3FTVlyVFbb+ukZvwwC690/+symaYLFXzXlqNLFD/KTqDRbv3GxTKvsLd3ZDL0R/DXSRJO0v5jEOA== 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=57.103.78.151; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759485447154100 Content-Type: text/plain; charset="utf-8" In the case where WHPX isn't supported on the platform, makes the intended error appear instead of failing at getting the IPA width. Signed-off-by: Mohamed Mediouni --- target/arm/whpx/whpx-all.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c index 4d58e5e939..ce1794952c 100644 --- a/target/arm/whpx/whpx-all.c +++ b/target/arm/whpx/whpx-all.c @@ -678,7 +678,7 @@ uint32_t whpx_arm_get_ipa_bit_size(void) WHvCapabilityCodePhysicalAddressWidth, &whpx_cap, sizeof(whpx_cap), &whpx_cap_size); if (FAILED(hr)) { - error_report("WHPX: failed to get supported" + error_report("WHPX: failed to get supported " "physical address width, hr=3D%08lx", hr); } =20 @@ -909,14 +909,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms) goto error; } =20 - if (mc->get_physical_address_range) { - pa_range =3D mc->get_physical_address_range(ms, - whpx_arm_get_ipa_bit_size(), whpx_arm_get_ipa_bit_size()); - if (pa_range < 0) { - return -EINVAL; - } - } - whpx->mem_quota =3D ms->ram_size; =20 hr =3D whp_dispatch.WHvGetCapability( @@ -943,6 +935,14 @@ int whpx_accel_init(AccelState *as, MachineState *ms) goto error; } =20 + if (mc->get_physical_address_range) { + pa_range =3D mc->get_physical_address_range(ms, + whpx_arm_get_ipa_bit_size(), whpx_arm_get_ipa_bit_size()); + if (pa_range < 0) { + return -EINVAL; + } + } + hr =3D whp_dispatch.WHvCreatePartition(&whpx->partition); if (FAILED(hr)) { error_report("WHPX: Failed to create partition, hr=3D%08lx", hr); --=20 2.50.1 (Apple Git-155) From nobody Fri Nov 14 16:50:30 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1761759555; cv=none; d=zohomail.com; s=zohoarc; b=QBqQCZH1i2HOgxK5MSZxAm/lnboTQ4QoH1V+ykJ+lWHU4Qmh+5dfKOflioxRFFGg5gBVzc11+lrPAv6BLykpMvILJ2oUAN0ucoI/msSaL73UcIBqSos75yU9P5yaKScRtNoy1Dd/aghU5kuwt8pjLoTFumqMw5wlVSBpUjWVn+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761759555; 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=QZTelCEJESaTGcpDgt/uLDUyv+A/CDP1F90Ud1CwiBg=; b=MbWy/kwRDGUdD4a7gQqyvA93Be1v9XVSWuXjkc19g2dG9SKRX0/ABlDKyw498Rl/7O9qnuNPaYs3A1gZHuP7ExFiezRjR/9rk5S83GHOHA5FGd+HyC/rIFPT4f9UhDO7hEOil+u3FVn+oMncZEogN8VwWmPsFxXutmcoqOrQQd0= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761759555549916.5266429682638; Wed, 29 Oct 2025 10:39:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vEA6E-0004DF-HW; Wed, 29 Oct 2025 13:36: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 1vEA64-00044w-7h for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:32 -0400 Received: from p-east2-cluster4-host3-snip4-10.eps.apple.com ([57.103.78.141] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vEA5Z-0003Vv-SM for qemu-devel@nongnu.org; Wed, 29 Oct 2025 13:36:30 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPS id 98D2B18270D2; Wed, 29 Oct 2025 17:35:55 +0000 (UTC) Received: from mac.home (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-60-percent-10 (Postfix) with ESMTPSA id 4EF0E1822209; Wed, 29 Oct 2025 16:56:15 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=QZTelCEJESaTGcpDgt/uLDUyv+A/CDP1F90Ud1CwiBg=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=H8+rdblk0re5FLngKCPfmaE5Asyu83sQcar5AlNQLTqnaH4q+pmbu8cT+tDcZ8WMR9Gsb3gQxo1ji0KDXGXNXrx2VPGWMqzb7f8w5STPLuTElv3QqYbUdRfYWhZ2yfG2TxSozq1RINyYFaHEH5kRc5p2Qm8h7fpTCK+6SN2vZMbysYV57EWniltp8wZaj7i/VB+mFVZDA2MAg13NH4Cs4DeAyOVpxyqOIOO53UI1xbyX7nHvrxGeRZWgAc6xsrI6Ygjou9wn2/biiKfUE3uecXWsh6Eppg+bDDQWYgWzzM5q876Y32aqT1NsaJQbV+bhZzKMdm20kez1qaQ694Djag== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org, mohamed@unpredictable.fr Cc: Pedro Barbuda , Paolo Bonzini , qemu-arm@nongnu.org, Alexander Graf , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v10 28/28] whpx: arm64: add partition-wide reset on the reboot path Date: Wed, 29 Oct 2025 17:55:10 +0100 Message-ID: <20251029165510.45824-29-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251029165510.45824-1-mohamed@unpredictable.fr> References: <20251029165510.45824-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI5MDE0MCBTYWx0ZWRfX7JksRuEiKHEO M8tYfBYjRUQEgv6n/xiu4k8DOLnnhcyGIXbqxLrxVTNZd5zx57rzuPWbOcHlftIL/uoRsIYMWkk litX59MaskxuQFn+tW1G5KGHIxUODmdAqEGa50bE8d3Zwu5bq67mTXFynfIGQEQ8k1HmB0X1Bcy rvHfkZRhmn56qYDXTF9xxv2WHY9NYvBFTElbHwRpZocFnycP+GVlwm2x8Y8GdMFOQ4HYv9rpAqS 61Fx+NeIqlmaqeiQQz2DR3Q3D4M72iKcCuen/pvl9uG0H3q/qZQxrHw0z1epHDDJL2uM6lbls= X-Proofpoint-GUID: mjhdJkluoe-umiJNuDIeslAvSBaqt9ud X-Proofpoint-ORIG-GUID: mjhdJkluoe-umiJNuDIeslAvSBaqt9ud X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-29_07,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 clxscore=1030 mlxlogscore=571 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2510290140 X-JNJ: AAAAAAABcysi5JB0a1mrR7KIauJyAJwdEmd6UmQV5Suxijiss3fvhaa219xPL9VeyjxHsiRdhoF1NsN/rx2to3AWFXDQYKjamTsd0LSBXULwAvpTEJy8cEYdhsHenMMVfFZ3ivmve9vaMhkRg5Mfr3b2Z9ZR6in/06SUQT7vjoflzGDUYRmV4lNckMicnLhOh2ZenKlvEMxBlyJuBgRzvYM7G21guvdu0fGzVASu3bSGZI1woigdrI9yvOEIXH5BrSSc1Y5WZoCroClTh0M9v91P3zggBg4UdURMXIiG19i5ieRbGiaj1Z+DCb77in7DCRDecJBGVH7YobvCl9SlNVjnECNIZj9Y4nBbyLHPju350pG9DMZqlBouTmnRVB7wtJprAdcgVaGua74nrGqJCizLIi2gMrNKH3psH+yGs/Yn6z4KOLT0AtJVwNHEDZS3r7jRey5Iopa5RxYbsVoBPeIuTRvpYh02m0jKBi4/ynKhA3OLypNvnz1SChUJ+DSPm9LDreuuXTY+CmF6K8xfJQzQql31VhKvlAI3XASs6rkpK1g2So6U1rsT0HnyTUrzxC8fBUwsLvuXLxI/9zr3Xr5kXfAd0gRnADGfTuYGVvJtgjpZcCvth0Kpwzu1Sh6JspXGWi68V5kH/0C5lIptSZ9xLtZd4dUGEOs6xxhWsN6m85X81FJuGx4L/4UCO+Pbide6D/QdPdSXfLCpYwqlJdoonVlzXrOHVA== 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=57.103.78.141; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=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 @unpredictable.fr) X-ZM-MESSAGEID: 1761759558394154100 Content-Type: text/plain; charset="utf-8" This resets non-architectural state to allow for reboots to succeed. Signed-off-by: Mohamed Mediouni --- include/system/whpx-internal.h | 2 ++ target/arm/whpx/whpx-all.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/system/whpx-internal.h b/include/system/whpx-internal.h index 90b4077b76..40918c025f 100644 --- a/include/system/whpx-internal.h +++ b/include/system/whpx-internal.h @@ -94,6 +94,8 @@ void whpx_apic_get(APICCommonState *s); (WHV_PARTITION_HANDLE Partition, UINT32 VpIndex, \ WHV_VIRTUAL_PROCESSOR_STATE_TYPE StateType, PVOID Buffer, \ UINT32 BufferSizeInBytes)) \ + X(HRESULT, WHvResetPartition, \ + (WHV_PARTITION_HANDLE Partition)) \ =20 =20 #define LIST_WINHVEMULATION_FUNCTIONS(X) \ diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c index ce1794952c..c558ab8613 100644 --- a/target/arm/whpx/whpx-all.c +++ b/target/arm/whpx/whpx-all.c @@ -497,6 +497,8 @@ int whpx_vcpu_run(CPUState *cpu) if (arm_cpu->power_state !=3D PSCI_OFF) { whpx_psci_cpu_off(arm_cpu); } + /* Partition-wide reset, to reset state for reboots to succeed= . */ + whp_dispatch.WHvResetPartition(whpx->partition); bql_unlock(); break; case WHvRunVpExitReasonNone: --=20 2.50.1 (Apple Git-155)