From nobody Mon Mar 23 21:24:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1773314541; cv=pass; d=zohomail.com; s=zohoarc; b=GkK9Iy97z0nwBpnjrL8hXSigVNCy+LvOm421avtW7/NC5jNSJhDp6uGj+qSsn44d78xUktni2FC3+43SDy+W3Yz0wVnyFd8hgqA4w9qUeMhREgai0KHByXYmI1+x+4NCX28iGXQmxC/Mu8dUuBIWwlUARhDQ7NIBwRzUVjdfXbA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773314541; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=N3XZe9B6SBQbKn8ypeUZSmODNlvYz970OWYJkLumTS8=; b=lFVpF22hA3WbNE1muHzXCxqV46CGTPbve9Ma+/DhefE2+eHmNvyhClb8sSvYyJHuOM+/FLxjMOdIfbjv7rmgjehtHaKB0ReS1YYuxVdXy6a35b8iGBJRTDgJ/We0ep/tfPrGmxbrk1D1Y1B8lkK0avrRqZOS88aCntx7YUNXiOA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1773314541746704.5686581647931; Thu, 12 Mar 2026 04:22:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1252080.1548895 (Exim 4.92) (envelope-from ) id 1w0e74-0007g3-LV; Thu, 12 Mar 2026 11:21:58 +0000 Received: by outflank-mailman (output) from mailman id 1252080.1548895; Thu, 12 Mar 2026 11:21:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0e74-0007ft-GR; Thu, 12 Mar 2026 11:21:58 +0000 Received: by outflank-mailman (input) for mailman id 1252080; Thu, 12 Mar 2026 11:21:57 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0e73-0006gG-1e for xen-devel@lists.xenproject.org; Thu, 12 Mar 2026 11:21:57 +0000 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazlp170100005.outbound.protection.outlook.com [2a01:111:f403:c111::5]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ac67d48b-1e05-11f1-9ccf-f158ae23cfc8; Thu, 12 Mar 2026 12:21:55 +0100 (CET) Received: from BLAPR03CA0173.namprd03.prod.outlook.com (2603:10b6:208:32f::35) by DS5PPFD22966BE3.namprd12.prod.outlook.com (2603:10b6:f:fc00::662) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9723.6; Thu, 12 Mar 2026 11:21:49 +0000 Received: from MN1PEPF0000F0DF.namprd04.prod.outlook.com (2603:10b6:208:32f:cafe::ae) by BLAPR03CA0173.outlook.office365.com (2603:10b6:208:32f::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.27 via Frontend Transport; Thu, 12 Mar 2026 11:21:44 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by MN1PEPF0000F0DF.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.18 via Frontend Transport; Thu, 12 Mar 2026 11:21:49 +0000 Received: from xcbagarciav01.xilinx.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 12 Mar 2026 06:21:46 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ac67d48b-1e05-11f1-9ccf-f158ae23cfc8 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SdwFOJLt9vlEHVBamaCRsdGomWgkR28q8jXTETF5GHnCNPqjGoDJdAFndp9JJoWrfCWVpUl2NDqxwAD3MJDJxWOqsHT5U7EXkxcgHF9JCu//OgmNxtFrj6ISbPZU0u6PCkCBmTtl9uscQZ/d0hzKXy23NbyPFr9Z3CmRdLGigtmGy2wH6hx82PSQby/TcrnjV5I0gYiEzeJtKbBwH7ujOUuZHGKsh9jES2E5dSscchqMH8T4r9SgAmhZ/bUYXiNSYIB1MzlYXQp12ybV/H9MbSXL7Rbv+LMrX7vu4P1X7rkDJtFYwwYcoXXJhW9f1GWis6+yn3/h2TedMdgz+qp+NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=N3XZe9B6SBQbKn8ypeUZSmODNlvYz970OWYJkLumTS8=; b=Zotl9oheACloDlcH4fuVeVA9pA8kTKNjs16BsFs/tKGQja2orxHsq1wFixX8KelCj3uJhDKDKjvoCKp+KYWioTv1DD7cMUEfm5+owSBS+E9SwWqTSc4lkFWf/BIPmcU2tdcaW6ukh+RDBvrsfmnOQPdkYZAIGzb4AZj0TMWDfDS4Rouu3RNKCHXLUKWXMgY78quJbIta9OhHd+B6FQtpl8jl0IRSBeg/FigYY/rxvjrUhAqGIFr++26vZ0/Awqe6vpg/VbVwxK/ri1W0z2J6ApSnvajgUZpF9N7lM68Lpc4sjhunzezmMCM0I0L8ZKP1cdfwR4rPHNZjGiJQw3/FaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N3XZe9B6SBQbKn8ypeUZSmODNlvYz970OWYJkLumTS8=; b=I41yhbnbCCdgxN4HPe7jxHsRLs1+DJQrW9TQO00TYuJ/OSljlFN4UBfqukqJvevuauTZqYEflT6OLCOYSyc/G8Fyby3dhwRVh0SZ5ruM2gemQMqCL9ocIU9f/Da7TbK3vcP5ThSXoijyFo0PY74TtprOviLMjTNMqz4wj5b6QWw= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Alejandro Vallejo To: CC: Alejandro Vallejo , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 5/5] x86/hvm: Un-indent the HVM_FEP block in the #UD handler Date: Thu, 12 Mar 2026 12:21:14 +0100 Message-ID: <20260312112116.22563-6-alejandro.garciavallejo@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260312112116.22563-1-alejandro.garciavallejo@amd.com> References: <20260312112116.22563-1-alejandro.garciavallejo@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0DF:EE_|DS5PPFD22966BE3:EE_ X-MS-Office365-Filtering-Correlation-Id: a1bddbd4-34bb-46d9-c773-08de80298d9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|376014|82310400026|22082099003|56012099003|18002099003; X-Microsoft-Antispam-Message-Info: M80IomQrWaBTjaPrn8qRafC1MRET4Uc6BdN07XML7ADd693QHE5w2s9Cuo3TLolDUQ3EmEEeoKhKEIdYd1CN3W5+AMlwvYiKaCUYSHeIostRq1zQUsxAvFFEtWRDhyIcjVr2LovdS10gt2VFpyeLzoaNh3bZ260M9S0fVAFiQ066nCwbuY9+wwINvEgqbU/EQzj0UayNNZrlp8/Ezq71sZsQKoRGwP43Up8vgdIFB5Zxs8ofww+BRNCHNIV5MGLu0V9UNt3iFOlfR+fKimKl5VF3fVh58XPeik2nztJ4GJQ0UVSr+T+eGzEvQe7qOxH4yxVgWLeL9weS1QyoaMmeJ0AutRg1H3pooPAOz+2+i8t102/2zk5ZTzl5XLoeoV+T6j8Z7cvwm6opHEpAHMRX/E5jt8WQ1pmEt1nKUw3TqA8jmTyxG85+qgt7k7eFaTJZyHgBL0XK+yjIdpTizYUmlX87dJcO6gSp2EbslL2WumxbGnpqF13sHWTEDqK0GmS+NceIyUBGC/Tg/irjtPyBmYXyD19c5N8m7uOxFTcMMBgghPyBatdf6pI7/i04XdjDGgD3mjBuIw15u3KKqoPAPFiPNiSjRJNng2nTJxRObFbfEujH8SoshdBDDScQcCEBzWOoD4Xlr0f+Qr/NDMZlTWgQ1CI5mz1sO0npf1DiZuzOFi6En7RXrjJqFFBWg/fEoy87oeOxKsxwLco6LrstBppVr0GqRvL6mrIxJaAKtldol5eqvaV2ar9EkWbZSHwU/XjscZYttzBclzf9fGpitg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(376014)(82310400026)(22082099003)(56012099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B41kkjv6oc6ttN8PFcrSRImCRottItfd9+FR7GwO7jGjKS49tWsrbJhr/ILyeKRVnEE716wUw74R5GijJ2DoirUR3xeIoY/tmpjmvwqImm9bJnXoyU3C5HHoL8+OcAE8W6I3F1b+JycSXR+NrRUu5676LYU+XiqGDkbi6IOXzYO/X5vJ6dq1ZeKA1aenS8vefk5Fz9TFUqW7CLgwtmXVfdtb24rZYXBU4uTqteY1TPQG8CEwa/KoLXzUv+Sl1oiRL2Kmt0RiJixNPm++cz9lV6glzSosEZp2u6uIhGTL0QAcix++qAxidQtxgOhN+fyp+Eiohzl+NOQH/GK6tZo8LBAYiAazvNxASs1D6WA/y+NJSmWJbFK6C1iU2vwxmGgQZMYHVnejY/zQdiXJxqMEfjxJS7tlr0ZEFBZiZjZKuC0ikPtg3uZ+aTUX6pinKXJN X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2026 11:21:49.0692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1bddbd4-34bb-46d9-c773-08de80298d9d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0DF.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS5PPFD22966BE3 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1773314544242154100 Content-Type: text/plain; charset="utf-8" FEP is now the only reason for the #UD handler to run. Signed-off-by: Alejandro Vallejo --- xen/arch/x86/hvm/hvm.c | 43 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index c8cae41705d..4c00cf4c4fe 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -3837,35 +3837,34 @@ void hvm_ud_intercept(struct cpu_user_regs *regs) struct vcpu *cur =3D current; bool should_emulate =3D false; struct hvm_emulate_ctxt ctxt; + const struct segment_register *cs; + uint32_t walk; + unsigned long addr; + char sig[5]; /* ud2; .ascii "xen" */ =20 hvm_emulate_init_once(&ctxt, NULL, regs); =20 - if ( opt_hvm_fep ) + cs =3D &ctxt.seg_reg[x86_seg_cs]; + walk =3D ((ctxt.seg_reg[x86_seg_ss].dpl =3D=3D 3) + ? PFEC_user_mode : 0) | PFEC_insn_fetch; + + if ( hvm_virtual_to_linear_addr(x86_seg_cs, cs, regs->rip, + sizeof(sig), hvm_access_insn_fetch, + cs, &addr) && + (hvm_copy_from_guest_linear(sig, addr, sizeof(sig), + walk, NULL) =3D=3D HVMTRANS_okay) && + (memcmp(sig, "\xf\xb" "xen", sizeof(sig)) =3D=3D 0) ) { - const struct segment_register *cs =3D &ctxt.seg_reg[x86_seg_cs]; - uint32_t walk =3D ((ctxt.seg_reg[x86_seg_ss].dpl =3D=3D 3) - ? PFEC_user_mode : 0) | PFEC_insn_fetch; - unsigned long addr; - char sig[5]; /* ud2; .ascii "xen" */ - - if ( hvm_virtual_to_linear_addr(x86_seg_cs, cs, regs->rip, - sizeof(sig), hvm_access_insn_fetch, - cs, &addr) && - (hvm_copy_from_guest_linear(sig, addr, sizeof(sig), - walk, NULL) =3D=3D HVMTRANS_okay)= && - (memcmp(sig, "\xf\xb" "xen", sizeof(sig)) =3D=3D 0) ) - { - regs->rip +=3D sizeof(sig); - regs->eflags &=3D ~X86_EFLAGS_RF; + regs->rip +=3D sizeof(sig); + regs->eflags &=3D ~X86_EFLAGS_RF; =20 - /* Zero the upper 32 bits of %rip if not in 64bit mode. */ - if ( !(hvm_long_mode_active(cur) && cs->l) ) - regs->rip =3D (uint32_t)regs->rip; + /* Zero the upper 32 bits of %rip if not in 64bit mode. */ + if ( !(hvm_long_mode_active(cur) && cs->l) ) + regs->rip =3D (uint32_t)regs->rip; =20 - add_taint(TAINT_HVM_FEP); + add_taint(TAINT_HVM_FEP); =20 - should_emulate =3D true; - } + should_emulate =3D true; } =20 if ( !should_emulate ) --=20 2.43.0