From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.12800.1677224299684311609 for ; Thu, 23 Feb 2023 23:38:20 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E6kl+Aef; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677224298; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MkxP2NjXldNax66YtrmoHWnlxemDr2NYICqc/U/9iTY=; b=E6kl+AefZxQRvOMqkWn8/n3U3M4yIUADj71Zoqe5Lm2UQmuZRrxlREtsLVzwKMcsQU8XuR KpKGEVS6t+NsDKURiJhcsLiBhgiA5F8Qc6mU5UtPkwqOuP9NpE4uBI8QamuWLqEMVOfmDA CjAdSlVf34vfAivcVFnYo7YyaxHZPlw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-110-N31A6q6sOWuBnsVXGu_s2w-1; Fri, 24 Feb 2023 02:38:14 -0500 X-MC-Unique: N31A6q6sOWuBnsVXGu_s2w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 44C75101A52E; Fri, 24 Feb 2023 07:38:14 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5BEEC440DE; Fri, 24 Feb 2023 07:38:13 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id EF39B1800624; Fri, 24 Feb 2023 08:38:11 +0100 (CET) Date: Fri, 24 Feb 2023 08:38:11 +0100 From: "Gerd Hoffmann" To: devel@edk2.groups.io, yuanhao.xie@intel.com Cc: Guo Dong , Ray Ni , Sean Rhodes , James Lu , Gua Guo Subject: Re: [edk2-devel] [Patch V3 2/6] UefiCpuPkg: Duplicate AsmRelocateApLoopAmd. Message-ID: <20230224073811.bym6ktw4sxaayktm@sirius.home.kraxel.org> References: <20230223180535.10383-1-yuanhao.xie@intel.com> <20230223180535.10383-3-yuanhao.xie@intel.com> MIME-Version: 1.0 In-Reply-To: <20230223180535.10383-3-yuanhao.xie@intel.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Feb 24, 2023 at 02:05:31AM +0800, Yuanhao Xie wrote: > Duplicate AsmRelocateApLoopAmd for non-SEV-ES enabled processors. > > Cc: Guo Dong > Cc: Ray Ni > Cc: Sean Rhodes > Cc: James Lu > Cc: Gua Guo > Signed-off-by: Yuanhao Xie > Test-by: Yuanhao Xie > --- > UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 68 ++++++++++++++++++++++++++++++++++++++++++++------------------------ > UefiCpuPkg/Library/MpInitLib/MpEqu.inc | 22 ++++++++++++---------- > UefiCpuPkg/Library/MpInitLib/MpLib.h | 31 +++++++++++++++++++++++++++++-- > UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm | 33 +++++++++++++++++---------------- > UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 5 files changed, 273 insertions(+), 52 deletions(-) > > diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > index a84e9e33ba..dd935a79d3 100644 > --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c > @@ -1,7 +1,7 @@ > /** @file > MP initialize support functions for DXE phase. > > - Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.
> + Copyright (c) 2016 - 2023, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent > > **/ > @@ -378,32 +378,44 @@ RelocateApLoop ( > IN OUT VOID *Buffer > ) > { > - CPU_MP_DATA *CpuMpData; > - BOOLEAN MwaitSupport; > - ASM_RELOCATE_AP_LOOP AsmRelocateApLoopFunc; > - UINTN ProcessorNumber; > - UINTN StackStart; > + CPU_MP_DATA *CpuMpData; > + BOOLEAN MwaitSupport; > + ASM_RELOCATE_AP_LOOP AsmRelocateApLoopFunc; > + ASM_RELOCATE_AP_LOOP_AMDSEV AsmRelocateApLoopFuncAmdSev; > + UINTN ProcessorNumber; > + UINTN StackStart; > > MpInitLibWhoAmI (&ProcessorNumber); > CpuMpData = GetCpuMpData (); > MwaitSupport = IsMwaitSupport (); > if (CpuMpData->UseSevEsAPMethod) { > - StackStart = CpuMpData->SevEsAPResetStackStart; > + StackStart = CpuMpData->SevEsAPResetStackStart; > + AsmRelocateApLoopFuncAmdSev = (ASM_RELOCATE_AP_LOOP)(UINTN)mReservedApLoopFunc; mReservedApLoopFuncAmdSev ? > diff --git a/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm b/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm > index c1e8a045a4..6b48913306 100644 > --- a/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm > +++ b/UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm > @@ -347,12 +347,13 @@ PM16Mode: > > SwitchToRealProcEnd: > ;------------------------------------------------------------------------------------- > -; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish, Pm16CodeSegment, SevEsAPJumpTable, WakeupBuffer); > +; AsmRelocateApLoopAmdSev (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish, Pm16CodeSegment, SevEsAPJumpTable, WakeupBuffer); > ;------------------------------------------------------------------------------------- > -AsmRelocateApLoopStart: > + > +AsmRelocateApLoopStartAmdSev: I'd suggest to do the rename in patch #1 too. > +;------------------------------------------------------------------------------------- > +; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish, Pm16CodeSegment, SevEsAPJumpTable, WakeupBuffer); > +;------------------------------------------------------------------------------------- > +AsmRelocateApLoopStart: > +BITS 64 > + cmp qword [rsp + 56], 0 ; SevEsAPJumpTable > + je NoSevEs Now you are adding back the AmdSev version. It should be the generic version though. If you want add the generic version later in the in the patch series (when changing the function prototype to drop sev support and add paging support) you can temporary call AsmRelocateApLoopStartAmdSev in the generic code path too. take care, Gerd