From nobody Sun May 19 16:31:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+92781+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+92781+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1661396123; cv=none; d=zohomail.com; s=zohoarc; b=aR1m+v8HSMp0PY890pQJEkgHWA5/2PRcZsYxEpZ5O1SLqKdRMn1VQjCpMaibZ13T03b3f91+P32bsZJUz/Hpvu0/9jOQg0NB80DXUf3stbH+FUU1Uf3zXoqkH/QQkCOH1hY22EHvO4+/JoqkZSwExW7cxU05elFFRQDZ/OQf4mw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661396123; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=safWI6goHIheAnm9HFZyR7F0A2MOHA8C9Rr8wG3Qqvw=; b=O0QGkQyr/hOz+aAoi16HnysAvNz6sZgpIMs0JvEmks0Q+NciTFr5meU1vu4x2/81IXpKeL62jt4DiNIyYK1d58t524eErzVLPIvLUdIW8UHN26qNshs7yULGJ28qLtL3eWX39DFCL9Pwfkhb0t0POLserMP25h4iXQhMJSgAzkw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+92781+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1661396123559523.8190429398153; Wed, 24 Aug 2022 19:55:23 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id S0F6YY1788612xGXBMCZSQc2; Wed, 24 Aug 2022 19:55:23 -0700 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.19719.1661396118095781814 for ; Wed, 24 Aug 2022 19:55:22 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10449"; a="355855725" X-IronPort-AV: E=Sophos;i="5.93,262,1654585200"; d="scan'208";a="355855725" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2022 19:55:22 -0700 X-IronPort-AV: E=Sophos;i="5.93,262,1654585200"; d="scan'208";a="670782645" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.151]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2022 19:55:20 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Zhiguang Liu , Eric Dong , Ray Ni , Rahul Kumar Subject: [edk2-devel] [PATCH] UefiCpuPkg/MpInitLib: Fix potential issue when IDT table is at above 4G Date: Thu, 25 Aug 2022 10:55:04 +0800 Message-Id: <20220825025506.2323-2-zhiguang.liu@intel.com> In-Reply-To: <20220825025506.2323-1-zhiguang.liu@intel.com> References: <20220825025506.2323-1-zhiguang.liu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhiguang.liu@intel.com X-Gm-Message-State: 0vXj4r0FXYgW7fuNZgKnTdkGx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1661396123; bh=A62guTtl6mX31Nfbfe+v1Jb1xXOIIUSziBOl5ms0ODE=; h=Cc:Date:From:Reply-To:Subject:To; b=mgPS9QjgGT7JDt4qK7YnY2WtJ0zBVQcAyGuTxtGw0d4WJGDzrdsVYNhsFbIuSLRhpAy 4oMzfxY9WwrbcZ9WnsD17fFE0uZ1tph/pOtUSWr59jfB+n+Gx8IiNpNkDV1bmdpqYcwQA BGldkOzQfBmJle6zmgk59e+zQLtsmmk2Myw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1661396123996100001 Content-Type: text/plain; charset="utf-8" Currently, when waking up AP, IDT table of AP will be set in 16 bit code, and assume the IDT table base is 32 bit. However, the IDT table is created by BSP. Issue will happen if the BSP allocates memory above 4G for BSP's IDT table. Moreover, even the IDT table location is below 4G, the handler function inside the IDT table is 64 bit, and it won't take effect until CPU transfers to 64 bit long mode. There is no benefit to set IDT table in such an early phase. To avoid such issue, this patch moves the LIDT instruction into 64 bit code. Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Signed-off-by: Zhiguang Liu Reviewed-by: Ray Ni --- UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm b/UefiCpuPkg/Lib= rary/MpInitLib/X64/MpFuncs.nasm index 1daaa72b1e..cd95b03da8 100644 --- a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm +++ b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm @@ -64,9 +64,6 @@ BITS 16 mov si, MP_CPU_EXCHANGE_INFO_FIELD (GdtrProfile) o32 lgdt [cs:si] =20 - mov si, MP_CPU_EXCHANGE_INFO_FIELD (IdtrProfile) -o32 lidt [cs:si] - ; ; Switch to protected mode ; @@ -154,6 +151,11 @@ BITS 64 =20 LongModeStart: mov esi, ebx + + ; Set IDT table at the start of 64 bit code + lea edi, [esi + MP_CPU_EXCHANGE_INFO_FIELD (IdtrProfile)] + lidt [edi] + lea edi, [esi + MP_CPU_EXCHANGE_INFO_FIELD (InitFlag)] cmp qword [edi], 1 ; ApInitConfig jnz GetApicId --=20 2.31.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92781): https://edk2.groups.io/g/devel/message/92781 Mute This Topic: https://groups.io/mt/93241591/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-