From patchwork Tue May 2 14:59:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13229031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7EB87C7EE29 for ; Tue, 2 May 2023 15:02:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.528708.822195 (Exim 4.92) (envelope-from ) id 1ptrWF-0000eY-CN; Tue, 02 May 2023 15:02:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 528708.822195; Tue, 02 May 2023 15:02:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ptrWF-0000eP-9W; Tue, 02 May 2023 15:02:19 +0000 Received: by outflank-mailman (input) for mailman id 528708; Tue, 02 May 2023 15:02:17 +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 1ptrWD-0000eD-G4 for xen-devel@lists.xenproject.org; Tue, 02 May 2023 15:02:17 +0000 Received: from esa1.hc3370-68.iphmx.com (esa1.hc3370-68.iphmx.com [216.71.145.142]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 51e990ee-e8fa-11ed-8611-37d641c3527e; Tue, 02 May 2023 17:02:15 +0200 (CEST) Received: from mail-mw2nam12lp2045.outbound.protection.outlook.com (HELO NAM12-MW2-obe.outbound.protection.outlook.com) ([104.47.66.45]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 May 2023 10:59:43 -0400 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) by DM4PR03MB6175.namprd03.prod.outlook.com (2603:10b6:5:39b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.20; Tue, 2 May 2023 14:59:41 +0000 Received: from SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::b0b8:8f54:2603:54ec]) by SJ0PR03MB6423.namprd03.prod.outlook.com ([fe80::b0b8:8f54:2603:54ec%3]) with mapi id 15.20.6340.031; Tue, 2 May 2023 14:59:41 +0000 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: 51e990ee-e8fa-11ed-8611-37d641c3527e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1683039735; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=w09wlSCp9EquAfQqRS+hpjyg6dxzrD1D0xfiQn0bbHI=; b=Zu2mt+6DvnN6FEgS6o8X/FvpnZZTo+ylZWoNrFr52N4uZSkxj6kE1Yxn I5Vj3oyOoXVHkI4pkDkxEnHVsbYnl1dVOsixoqairJnfhgd48KXHdbbbt RI+/68HtC+sFVOW46bAZKjkt6CXAG66mBfZ2vaeW/GpfTgZbbEtTgOL3j A=; X-IronPort-RemoteIP: 104.47.66.45 X-IronPort-MID: 107998060 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:W51CSaNPUDEqF0jvrR2ElsFynXyQoLVcMsEvi/4bfWQNrUpw0GcOy WAbXDqFOf6DM2Lwc4p+b4iy909XuM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stz8o9seLUNS5vHRuzkw2Fe9py X-IronPort-AV: E=Sophos;i="5.99,244,1677560400"; d="scan'208";a="107998060" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fke3hhsVQYoZkWY7of+dP26OVNizg8F/s6TN5197GLmFyyOFoFQmSscbqHRFDo0122+axJtV7QW6LG/Z17rANCQKeJz996yrbvf3j84nLlMGiMwDf268OKkCWpqzHb+XxszKOyji/456g1ldjikLtc+U3MVcFZpWK9ZajQcaVrSa0PEYMSXSFNparEQDpGSvsmmThY/DKCb1cSTecif/m1AgmS3Jm7GJWWzJi1y0f7/xSJFTMxepF7Kzkm3Xiq7LKUN6wX7SUDHW2Dy0S7eZfTtORUY1xA8i8Cb9bh2mrzPs/WJmsbGc3SVUwUzRr5Bd/VVCpEjh2jpORS3Wqfg49w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=Q9yYdD46obGJvl7PXXkeV3azaYqYy0EKOnWgIgsZyZ0=; b=MG2KD3oaXiAfG1K4iMnyoD8MJcMeZY15TE5U3dZew/1v/z5zGpgccgt3EoOqFyto4R/SAJgb+oSrlCtE0KkvnP47cfexyEu4Hf/LHv0ykFjWkvgtuoimbJAp76PpZGvoXCs4gm5JoSbdn078MVVmIRTKUxe0+X0EjR0n8fqvaarduzj41TCLzZMfQAW86bytPjdbXQ4Rhfe5kb5mALpWCA4y6KOQ/B3LEksERsi2+bgfBGuNsVJs7xhdcGi6afPZMn1GbnOBr/mEtlLIk+Wnge398XIWy4cOo/rtTYhxKT1Dqyxqh97wMOfjV1nNStFKAm+bBFkXRv3YQDhCvg+wWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q9yYdD46obGJvl7PXXkeV3azaYqYy0EKOnWgIgsZyZ0=; b=GAbjRitQaPs/RQ3B6NB4CTHQZWFPm30fMYXBD2hNvQOdjJJPr1uJ5zZAzmLSqEqX9HSpSH7ieDFeogx7xQDxDq6Di4kqqyzLENB+mmGUnvy2MnTcAx7tWR+sBB5rWOY+dXaBP3d33Zn1SU1Fg+Z2kJd3gCW+BWrHVkU7f+MYZfg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v2 2/2] x86/trampoline: load the GDT located in the trampoline page Date: Tue, 2 May 2023 16:59:20 +0200 Message-Id: <20230502145920.56588-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230502145920.56588-1-roger.pau@citrix.com> References: <20230502145920.56588-1-roger.pau@citrix.com> X-ClientProxiedBy: LO0P265CA0005.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:355::10) To SJ0PR03MB6423.namprd03.prod.outlook.com (2603:10b6:a03:38d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6423:EE_|DM4PR03MB6175:EE_ X-MS-Office365-Filtering-Correlation-Id: 17f44865-2af3-4561-258c-08db4b1ddb67 X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr,ExtFwd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RaIJeM2fVvwbWRpBBpvJFlB3N+owt56dnnojhjUnrg0uEOacxQpa6ouDRK00ZEdCvREEL0ZQvkUOi/JZM9Vw6qbU2aM47Q1De6HrNF8+fhKVtNniJJVc4f5R2xFB0BdVIqIIf0TnvTxMlkQu8adnb6OuAcyxizFB9Y31wdeEsaLqeXhH5ZzCrMglINIMEsorE45a/SkI7zKJGRrR8PWy8gA/ctE9nPyyZtDuLfj00vfgJIwThpusCcNhcZIsZYc89H9FeChdz+3xZgL2pABC4zHoejHMdvUTnGGxB6Wui5NpAzJDcHwdJMEgzwPGmuxA1ThmZX5rnMQwvhFKVEbfMi3VUG+/Pmp9W5+K7eI8X+6W0t8MeOcRH2GTcc3yiIYyPd2jlxMZb2CUTOI20OGf2it8MznxUdPCC0tfyK7xBZKUoqK3d3SVC4JpTZkCc1Zb0EqLFFJcZmnRX/AmQQoXiejGUlr5ifjEeJtNfYw4uChFMDf2dvsuxMPfvqKfZdop1XiM7sAlwl5KiMHtOwLmjcMRyWkq+8e2XugkK0ZHwLZ626oTh7lcBVjQzags6MxO X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB6423.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(396003)(346002)(376002)(366004)(39860400002)(451199021)(82960400001)(38100700002)(2906002)(8936002)(5660300002)(8676002)(36756003)(86362001)(2616005)(478600001)(6666004)(54906003)(6512007)(6506007)(26005)(1076003)(6486002)(186003)(66946007)(4326008)(66556008)(66476007)(6916009)(41300700001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?48n4sVTFK1flokVCyiQ01vd0UeNs?= =?utf-8?q?rzffVwVQZZSWRElyh3wMMlNDnPvrLWqfLiKymawya9bHLZF78noKzVBj10PK10XXV?= =?utf-8?q?11x911A8HiFL1Mlzua+8CMasXyLx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B8S5uGmBiVxv1kaQAELWMcg+WUuxs5CGM?= =?utf-8?q?WJ17qpZgHcQFBgcSuSimOjolLREXOHrhj/ZK+G+UXW0fOleUb8RixwR+hZ0GHULNu?= =?utf-8?q?ayKeqlien5/H2hf0Hgf8hh6vDdkzMMuXlAB9Uvr4g4frOBlCkD4I/XfGcYno5qb8g?= =?utf-8?q?ZSwt2RmnVf7+pfXIhfjIF2xiDRvZzb0j85rM/AEO2lYamhP2qrHHu1PuvrZNf7WSY?= =?utf-8?q?CV+Z1+IY0P7dyxCcDWTO66VdToKKnD5FevppSoca6Gmq1vKqmfWdZh7KvcgPh+ba/?= =?utf-8?q?afZ8jJKbQaaAU0nSwRZNt2dUnm6zgSeMwv5R/5+MBt6T0sPHU9kxNbbBn/nDtSwHi?= =?utf-8?q?yG4ikpItla+qiZ/VYAzlZjxcaNjLMLBTIzjLzDYDoeqOGW1hLQ2+044RfLujPOEGL?= =?utf-8?q?BteLE7nhwXMFbjMysHvu+NzhEJhsEwacodAn/TUmPp6D7H9zcl78pJWEuBP1d3YRA?= =?utf-8?q?rU/BK/560tEQMHkVeTiIU2YDRXwRvCfC/T4FMwe37dJoqth8hRhcx02S0J2TreVOL?= =?utf-8?q?d6pdVhgwJXtqV4cZa6tWk8ThAGMoKCWW1w=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: PLpHV08toh8qnxZmyT89R30wwyje0D4ymb97lqkUZczv2q2Q5qZbMDVb5Avex+q5TT5KZhUTA6yNrrMiwadQCKe3fSHa5GQADumDWZZoX8wRuhbywTUlG7959mTgWDUI6jTcL+ASDNgPMg2ffjaExggM+2v2FobrmEkHNiOinM6ebDS3qQa8EH4jpqSlCXSvD0jcpRqTr0LcnucQc7x/CgeXuNQ8FxSydlM1CR+OfS12HKNselKXSSpcHa+RMmdwLXDpz11S5xV07JsOkkKEBSmVbtz0nojSczpFKxKZ+9uugPwn/vu70P61BCf4W8jq5pPqkM1nxzXUQUqwzVEiZ1hxW1LOo0IPBhCPkLTgGoFh8jQX9dXsPkqbVhbynAdbM/5coYXXBXzxVecqcp9hAeY5N3eGh1vNGLebd1AF4TyOY3h+V9DzcsISd3RIL7KXAsLsefNVIxQgS6WkVkM+bBPbJ8VjyZO0lvQwviEHuKOi5UaCUJcXXV4qKAovDdL2lrIUnSW9HT2ToEpfckcMyFpwQjUESZ8LAzJd3LcIWccooWq4gb7pwFDIYKOPPjRuoanw1B6Qc4NHfXCVqfjD5dfFJjkFd8yeUMr9tPD+d4jg1CA+/JNkHUjsb7CgB64SmjMOvdSbVnSLyJCbxiVoClwu+0RzUDO8+SoD12/moXTRZDrEY+1sZXjy2kN7ZNoGySuBUpJ5h1CpeXS2UiFxFOmsBGbjxGbEhcabod3SKIlBi1+F58q5TyTF2BQqHXKR6deg5RTgUgb3JMu1kf7JQyVgmJTJJyAqMI6U2G5+C0UBzRTpoi049RgqgvBQpsG6 X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 17f44865-2af3-4561-258c-08db4b1ddb67 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6423.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 May 2023 14:59:41.3542 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: farOd407qZUcrtAYtbDIio7yzBzSZVOF0SoMAcWNN7zkAYITpZHTI5EMsTMU9RR1Wsger1gY2vGhsG29O2Pfsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR03MB6175 When booting the BSP the portion of the code executed from the trampoline page will be using the GDT located in the hypervisor .text.head section rather than the GDT located in the relocated trampoline page. If skip_realmode is not set the GDT located in the trampoline page will be loaded after having executed the BIOS call, otherwise the GDT from .text.head will be used for all the protected mode trampoline code execution. Note that both gdt_boot_descr and gdt_48 contain the same entries, but the former is located inside the hypervisor .text section, while the later lives in the relocated trampoline page. This is not harmful as-is, as both GDTs contain the same entries, but for consistency with the APs switch the BSP trampoline code to also use the GDT on the relocated trampoline page. Signed-off-by: Roger Pau Monné Reviewed-by: Andrew Cooper --- Changes since v1: - Reword comment. --- xen/arch/x86/boot/trampoline.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S index cdecf949b410..c6005fa33d1f 100644 --- a/xen/arch/x86/boot/trampoline.S +++ b/xen/arch/x86/boot/trampoline.S @@ -164,6 +164,9 @@ GLOBAL(trampoline_cpu_started) .code32 trampoline_boot_cpu_entry: + /* Switch to relocated trampoline GDT. */ + lgdt bootsym_rel(gdt_48, 4) + cmpb $0,bootsym_rel(skip_realmode,5) jnz .Lskip_realmode