From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.5318.1672974731051931705 for ; Thu, 05 Jan 2023 19:12:11 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=ezm5N9sv; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: yuanhao.xie@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672974731; x=1704510731; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=6gOBLAU8FnVhoAxyEArByhGFrt3Y63nHoTl5CGoqdks=; b=ezm5N9svV30ECp1mjguJIxKkOHsB8m1Vip3O7LkOBqLdVpRGyHkOOYsp 7baR/nUV3SbScNWTMS8GXT6l5LRqqA3xElYGIzJzA7tXRFvVMakDg5048 MXMNhOrdOFPyeOz0ZvPVAKxnLFaQN++cTAZYSfR4loo0pA5Ut/acYVAgx estrTEYoZTPtsL2NgpAEN+opgfoAT/NPx9U+ZKldSrM1gdvpjjDZnrrI3 oxd5UZOqAddE6+pAv+Eg7L8pDzbdGo9qH3bThHi17y1FioNODx/kFBgDN ypcyGeiuVTkwN1cqB3dO/NK4n47wMhc92C7LvPbyICEWsyXQrIUbqML67 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10581"; a="323642138" X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="323642138" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2023 19:11:55 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10581"; a="686338623" X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="686338623" Received: from shwdeopenlab705.ccr.corp.intel.com ([10.239.182.166]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2023 19:11:53 -0800 From: "Yuanhao Xie" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar Subject: [Patch V2 1/2] UefiCpuPkg:Fix stack offset mismatch in 32bit AsmRelocateApLoopStart Date: Fri, 6 Jan 2023 11:11:40 +0800 Message-Id: <20230106031141.460-1-yuanhao.xie@intel.com> X-Mailer: git-send-email 2.36.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Fix 32bit version of AsmRelocateApLoopStart to retrieve the parameters from correct stack offset. Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=4234 Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Signed-off-by: Yuanhao Xie --- UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 2 +- UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c index beab06a5b1..acbbf155c0 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c @@ -389,7 +389,7 @@ RelocateApLoop ( MpInitLibWhoAmI (&ProcessorNumber); CpuMpData = GetCpuMpData (); MwaitSupport = IsMwaitSupport (); - if (StandardSignatureIsAuthenticAMD ()) { + if (StandardSignatureIsAuthenticAMD () && (sizeof (UINTN) == sizeof (UINT64))) { StackStart = CpuMpData->UseSevEsAPMethod ? CpuMpData->SevEsAPResetStackStart : mReservedTopOfApStack; AsmRelocateApLoopFuncAmd = (ASM_RELOCATE_AP_LOOP_AMD)(UINTN)mReservedApLoopFunc; AsmRelocateApLoopFuncAmd ( diff --git a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm index bfcdbd31c1..5cffa632ab 100644 --- a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm +++ b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm @@ -219,20 +219,17 @@ SwitchToRealProcEnd: RendezvousFunnelProcEnd: ;------------------------------------------------------------------------------------- -; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish, Pm16CodeSegment, SevEsAPJumpTable, WakeupBuffer); -; -; The last three parameters (Pm16CodeSegment, SevEsAPJumpTable and WakeupBuffer) are -; specific to SEV-ES support and are not applicable on IA32. +; AsmRelocateApLoop (MwaitSupport, ApTargetCState, TopOfApStack, CountTofinish, Cr3); ;------------------------------------------------------------------------------------- AsmRelocateApLoopStart: mov eax, esp - mov esp, [eax + 16] ; TopOfApStack + mov esp, [eax + 12] ; TopOfApStack push dword [eax] ; push return address for stack trace push ebp mov ebp, esp mov ebx, [eax + 8] ; ApTargetCState mov ecx, [eax + 4] ; MwaitSupport - mov eax, [eax + 20] ; CountTofinish + mov eax, [eax + 16] ; CountTofinish lock dec dword [eax] ; (*CountTofinish)-- cmp cl, 1 ; Check mwait-monitor support jnz HltLoop -- 2.36.1.windows.1