From: "Yuanhao Xie" <yuanhao.xie@intel.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: "Dong, Guo" <guo.dong@intel.com>, "Ni, Ray" <ray.ni@intel.com>,
"Rhodes, Sean" <sean@starlabs.systems>,
"Lu, James" <james.lu@intel.com>, "Guo, Gua" <gua.guo@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Subject: Re: [edk2-devel] [PATCH 2/5] UefiCpuPkg: Contiguous memory allocation and code clean-up.
Date: Fri, 10 Feb 2023 09:12:08 +0000 [thread overview]
Message-ID: <CO1PR11MB502636B4266078B276BC9F29F0DE9@CO1PR11MB5026.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230208110933.bho5lybb6evnqcoh@sirius.home.kraxel.org>
Hi Gerd,
1) You convert size to pages, pages to size, size to pages again.
Agree. I will update it.
2) Also you don't want stack and code being on the same page
Patch 5 ensures that stack and code are in different pages and also ensure alignment. I will update it patch2 as well in v2.
3) The special case you have to handle is not running on a AMD Processor, but AmdSev being active (i.e. UseSevEsAPMethod == True). Otherwise it should be just standard
Ia32 and X64, there should be no need to check whenever you are running on a AMD processor.
I understand your point, but for both cases (check AmdSev, standard Ia32 and X64), AMD related code will be changed. We would like to keep the original implementation as much as possible.
Best regards,
Yuanhao
-----Original Message-----
From: Gerd Hoffmann <kraxel@redhat.com>
Sent: Wednesday, February 8, 2023 7:10 PM
To: devel@edk2.groups.io; Xie, Yuanhao <yuanhao.xie@intel.com>
Cc: Dong, Guo <guo.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Rhodes, Sean <sean@starlabs.systems>; Lu, James <james.lu@intel.com>; Guo, Gua <gua.guo@intel.com>
Subject: Re: [edk2-devel] [PATCH 2/5] UefiCpuPkg: Contiguous memory allocation and code clean-up.
> + AllocSize = EFI_PAGES_TO_SIZE (
> + EFI_SIZE_TO_PAGES (
> + CpuMpData->CpuCount * AP_SAFE_STACK_SIZE + ApLoopFuncSize
> + )
> + );
> + Status = gBS->AllocatePages (
> + AllocateMaxAddress,
> + EfiReservedMemoryType,
> + EFI_SIZE_TO_PAGES (AllocSize),
> + &Address
> + );
Hmm? You convert size to pages, pages to size, size to pages again.
Also you don't want stack and code being on the same page, so I guess the logic you actually need is this:
StackPages = EFI_SIZE_TO_PAGES(CpuMpData->CpuCount * AP_SAFE_STACK_SIZE); FuncPages = EFI_SIZE_TO_PAGES(ApLoopFuncSize)
gBS->AllocatePages(..., StackPages + FuncPages, ...);
> +//
> +// Union holds the relocate APs loop entries for different cases //
> +typedef union {
> + VOID *Data;
> + ASM_RELOCATE_AP_LOOP_AMD64 Amd64Entry; // 64-bit AMD Processor
> + ASM_RELOCATE_AP_LOOP GenericEntry; // Intel Processor (32-bit or 64-bit), or 32-bit AMD Processor
> +} RELOCATE_AP_LOOP_ENTRY;
I'm sure I've mentioned this before. The special case you have to handle is not running on a AMD Processor, but AmdSev being active (i.e. UseSevEsAPMethod == True). Otherwise it should be just standard
Ia32 and X64, there should be no need to check whenever you are running on a AMD processor.
take care,
Gerd
next prev parent reply other threads:[~2023-02-10 9:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 13:49 [PATCH 0/5] Put APs in 64 bit mode before handoff to OS Yuanhao Xie
2023-02-07 13:49 ` [PATCH 1/5] UefiCpuPkg: Duplicate RelocateApLoop for Amd x64 processors Yuanhao Xie
2023-02-07 13:49 ` [PATCH 2/5] UefiCpuPkg: Contiguous memory allocation and code clean-up Yuanhao Xie
2023-02-07 16:40 ` [edk2-devel] " Marvin Häuser
2023-02-07 16:43 ` Marvin Häuser
2023-02-08 10:36 ` Yuanhao Xie
2023-02-08 11:09 ` Gerd Hoffmann
2023-02-10 9:12 ` Yuanhao Xie [this message]
2023-02-10 11:09 ` Gerd Hoffmann
2023-02-10 12:52 ` Ni, Ray
2023-02-07 13:49 ` [PATCH 3/5] OvmfPkg: Add CpuPageTableLib required by MpInitLib Yuanhao Xie
2023-02-08 10:53 ` Gerd Hoffmann
2023-02-09 16:30 ` [edk2-devel] " Ard Biesheuvel
2023-02-07 13:49 ` [PATCH 4/5] UefiPayloadPkg: " Yuanhao Xie
2023-02-08 5:38 ` Guo, Gua
2023-02-08 17:02 ` Guo Dong
2023-02-07 13:49 ` [PATCH 5/5] UefiCpuPkg: Put APs in 64 bit mode before handoff to OS Yuanhao Xie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CO1PR11MB502636B4266078B276BC9F29F0DE9@CO1PR11MB5026.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox