From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.55299.1682351977846959544 for ; Mon, 24 Apr 2023 08:59:38 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ebGLDwgO; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 38ADB61E1A for ; Mon, 24 Apr 2023 15:59:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AC43C433EF for ; Mon, 24 Apr 2023 15:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682351976; bh=X98SpVhHnAnxOWVc2qswtK9zIfVYtHxVswQkXxNP8D0=; h=References:In-Reply-To:From:Date:Subject:To:From; b=ebGLDwgOHJLPvcQnEOyjCretQM0Ii91ztewTiiFTxK+PgnoJGn9VSQPCPoWrNtwVn xb6Jequ2ZqTIgMxyf5xQJ4SIH6N7pnNuZZHUDwB7Y+nSh4oTLrONvkC37BuJTYhFLk dSMUL2ZYrvxlZXvbWo5Yr1jcoD1DCXXJyNo5ZwcEC8VKhXbk1ppTwK20CRznGyyHNu xZ6tGTF2jUcwqZry0gW/gkPYzKyS/hv6nnhy6q8cc1dm8FyPn2sV+LySd37yoDPKG0 XY+ur4/l+c5ZGNZDo1fDal0q30l2GH2VoynkUmVENJBpsx9JdekmE00CUvslSDUGk/ pqSvq9yEs0kJg== Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-4edcc885d8fso5060161e87.1 for ; Mon, 24 Apr 2023 08:59:36 -0700 (PDT) X-Gm-Message-State: AAQBX9d8TLGHQ4Uu1mChKhmbPRYlctq1RkHsye6eR9mqY/3XLSyCN72x 2yAgKwZP8/F1aeovkBVCUqTSGOaqpqh9mv7/Gmw= X-Google-Smtp-Source: AKy350ZYtM2tPpVu0LvHGQEBUXEewPe//+CrQpRfI8GtMigq66Ee9TZonYmt4bpy/SpnoswoOSu0pd/H+dMZI8hlt9Q= X-Received: by 2002:ac2:5a19:0:b0:4ed:c76b:6aaf with SMTP id q25-20020ac25a19000000b004edc76b6aafmr3570318lfn.56.1682351974555; Mon, 24 Apr 2023 08:59:34 -0700 (PDT) MIME-Version: 1.0 References: <20230331093344.2609-1-dun.tan@intel.com> <20230331093344.2609-6-dun.tan@intel.com> In-Reply-To: From: "Ard Biesheuvel" Date: Mon, 24 Apr 2023 17:59:23 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [Patch V2 5/8] MdeModulePkg: Add UefiCpuPkg.dec to pass DependencyCheck To: devel@edk2.groups.io, ray.ni@intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, 16 Apr 2023 at 07:21, Ni, Ray wrote: > > Mike, > > MdeModule belongs to the common-package category. > > I agree that the common-package should not depend on a specific arch. > > MdeModule depending on UefiCpu because DxeIpl needs to prepare an arch sp= ecific environment for DXE phase. > > > > So, I am thinking if the arch-specific-env-preparation can be abstracted = through an arch-agnostic API. > > Then each arch can implement a concrete instance for that API. The API it= self can be in MdeModule pkg. > > > > In fact, the API is almost already there: =E2=80=9CHandOffToDxeCore=E2=80= =9D. > > > > So, we could: > > Create a new API HandOffToDxeCore() in a new TBD lib class > Implement different instances for different arch. > Default instance does nothing arch specific and can be used by EmulatorPk= g platform > > Today EmulatorPkg uses X64 version of HandOffToDxeCore and skips page tab= le building by setting PcdDxeIplBuildPageTables to FALSE. > > UefiCpuPkg implements the HandOffToDxe() for IA32 and X64. > > > > So, the dependency is reversed: only UefiCpu depends on MdeModule. > > > > This also removes the arch-specific contents from MdeModulePkg. > > > > One side effect is: every platform needs to include the new TBD lib class= . > > > > I agree that moving to MdePkg also works. But we might end up with a bigg= er and bigger MdePkg by including more and more. > > > I would prefer this approach. CpuPageTableLib is very x86-specific and does not comply with the requirements for MdePkg. Loading DXE core and mapping it with restricted permissions (to avoid W+X memory) will require some kind of abstraction here in any case, so it would be better to let the x86 specific version of that live in UefiCpuPkg, and keep this out of MdePkg entirely.