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.13370.1678976466716871181 for ; Thu, 16 Mar 2023 07:21:06 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CBAxg9dR; 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 0642E62031 for ; Thu, 16 Mar 2023 14:21:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 513C0C4339E for ; Thu, 16 Mar 2023 14:21:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678976465; bh=88OmzcXKov++O4nk26L3svtIKV5XrxFEO5IVlVbhHas=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=CBAxg9dRA1pNoge+FhABJ7pAV/OGrxCa2X0VQJfyq72wOvjYFg3G60DNTxnE6SnSB j1jZHUuIuPBwxQYKLrQCehSApMLMQM/Uz3qlX+/4FtbMfXhrZyI0rv15MyjBLzhATY QuKsB8WV6oimYO2ykednb89yosvw6e0uQUQx10mjvSfl9uQ4pPPE6jJ2XRPzjBDjYF nhPxHvssfGGa3mlZcgT7ruPOhFt5EivynkSoh2y/mUH5+0CCdv3qfhk6QvJBBOvjk8 lYBW7R4NyENVreMOHxngPytg+Yvp4ESaIAD/Zr4ISFOt1l0dwD5Fm4S5CqTANcaSBo P3RUzblgt/big== Received: by mail-lj1-f180.google.com with SMTP id x36so1863149ljq.7 for ; Thu, 16 Mar 2023 07:21:05 -0700 (PDT) X-Gm-Message-State: AO0yUKW9k5YJTuWy2NxfQ5H49swD+FZAOuoInn00URq0dugIVwcaRWPS MhCCZgx6Z6NK4GFILqybgkTzui+EPVYQgablY3w= X-Google-Smtp-Source: AK7set/EzEtSMUEk7iNEUd2/tLxgJbgLuhWk166JGgshYeULerTNVjIHndSQP89oHipZ0Art93bqN5g13qYYcNh8w+M= X-Received: by 2002:a05:651c:108:b0:299:ac5e:376e with SMTP id a8-20020a05651c010800b00299ac5e376emr443294ljb.2.1678976463257; Thu, 16 Mar 2023 07:21:03 -0700 (PDT) MIME-Version: 1.0 References: <20230313171714.3866151-1-ardb@kernel.org> <20230313171714.3866151-22-ardb@kernel.org> In-Reply-To: From: "Ard Biesheuvel" Date: Thu, 16 Mar 2023 15:20:52 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH v5 21/38] ArmPkg: Implement ArmSetMemoryOverrideLib To: devel@edk2.groups.io, quic_llindhol@quicinc.com Cc: Michael Kinney , Liming Gao , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Sami Mujawar , Taylor Beebe Content-Type: text/plain; charset="UTF-8" On Thu, 16 Mar 2023 at 14:27, Leif Lindholm wrote: > > On Mon, Mar 13, 2023 at 18:16:57 +0100, Ard Biesheuvel wrote: > > Implement the ARM version of a NULL class library that can be overlaid > > on top of the DXE core to equip it right from its launch with an > > implementation of the CPU arch protocol member that sets type and > > permission attributes on memory regions. > > > > This bridges the gap between dispatch of DXE core and dispatch of the > > DXE driver that implements the CPU arch protocol, removing the need to > > rely on memory mappings that are writable and executable at the same > > time. > > > > Signed-off-by: Ard Biesheuvel > > --- > > ArmPkg/ArmPkg.dsc | 1 + > > ArmPkg/Library/ArmSetMemoryOverrideLib/ArmSetMemoryOverrideLib.c | 78 ++++++++++++++++++++ > > ArmPkg/Library/ArmSetMemoryOverrideLib/ArmSetMemoryOverrideLib.inf | 28 +++++++ > > 3 files changed, 107 insertions(+) > > > > diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc > > index 3fb95d1951a9..43eb0f4f463e 100644 > > --- a/ArmPkg/ArmPkg.dsc > > +++ b/ArmPkg/ArmPkg.dsc > > @@ -119,6 +119,7 @@ [Components.common] > > ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.inf > > ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf > > ArmPkg/Library/ArmExceptionLib/ArmRelocateExceptionLib.inf > > + ArmPkg/Library/ArmSetMemoryOverrideLib/ArmSetMemoryOverrideLib.inf > > > > ArmPkg/Drivers/CpuDxe/CpuDxe.inf > > ArmPkg/Drivers/CpuPei/CpuPei.inf > > diff --git a/ArmPkg/Library/ArmSetMemoryOverrideLib/ArmSetMemoryOverrideLib.c b/ArmPkg/Library/ArmSetMemoryOverrideLib/ArmSetMemoryOverrideLib.c > > new file mode 100644 > > index 000000000000..866dbbdaa7d5 > > --- /dev/null > > +++ b/ArmPkg/Library/ArmSetMemoryOverrideLib/ArmSetMemoryOverrideLib.c > > @@ -0,0 +1,78 @@ > > +/** @file > > + Overlay implementation of DXE core gCpuSetMemoryAttributes for ARM. > > + > > + Copyright (c) 2023, Google LLC. All rights reserved. > > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > +**/ > > + > > +#include > > + > > +#include > > +#include > > +#include > > + > > +extern EFI_CPU_SET_MEMORY_ATTRIBUTES gCpuSetMemoryAttributes; > > Could this declaration live in a global include? > Yes, In fact, instead of modeling this as a NULL library class, we could actually define a library class for this, whose include file only has this extern declaration and nothing else (and a big fat comment, obviously, describing the point of that)