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.web09.5840.1666171344155283119 for ; Wed, 19 Oct 2022 02:22:24 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ok9aiQxZ; 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 67838617F4; Wed, 19 Oct 2022 09:22:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4025C433D6; Wed, 19 Oct 2022 09:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666171343; bh=CYjM98nJo4fBD4/4wQECcE2Ag0UPWdfcaVvnFa89kCM=; h=From:To:Cc:Subject:Date:From; b=ok9aiQxZ987A6fruxTn4yc4G4OmOM2XOd+K4wqPQVaDGbqwWeNR/Oa9dxGZ/QE+7U ZOG+WB8OicuMVGxix3FGYlmprpXNcsrCchsUoAfCt+cklLJJPYp7dmVtStu1BIqiyP gF/5y5A7KCFik9U6TznF2P5wpaL1C+KsqxpeJpGu9w0noOkmxeTrwVvy8/jRIt4J0y 1nVDOnb0Blw1VX+6YJ3n6rFT9pA1IE/vO/RGhh0vTjLwosQf2+5yBUQHUW8mT8wqWI BH4qdfjCt6ZeZ/tQqmhI4yi5CxtTSRT+w7hqRi+9CRI35LJCWAV4KJeIVTqk51CUUQ TxCpeYpTrE0yw== From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf , Gerd Hoffmann , Sami Mujawar Subject: [PATCH v3 resend 00/11] ArmVirtPkg/ArmVirtQemu: Performance streamlining Date: Wed, 19 Oct 2022 11:22:00 +0200 Message-Id: <20221019092211.465699-1-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable We currently do a substantial amount of processing before enabling the=0D MMU and caches, which is bad for performance, but also fragile, as it=0D requires cache coherency to be managed in software.=0D =0D It also means that when running under virtualization, the hypervisor=0D must do a non-trivial amount of work to ensure that the host's cached=0D view of memory is consistent with the guest's uncached view.=0D =0D Now that the AArch64 version of ArmMmuLib has been updated to allow it=0D to be invoked with the MMU already enabled, and to no longer disable the=0D MMU temporarily to make modifications to the page tables that require=0D break before make (BBM) [e.g., to split block mappings into table=0D mappings], we can remove all remaining manipulations of main memory that=0D occur with the MMU and caches disabled, by using a compile time=0D generated ID map that covers the first bank of NOR flash, the first MMIO=0D region (for the UART), and the first 128 MiB of DRAM, and switching to=0D it straight out of reset.=0D =0D The resulting build no longer performs any non-coherent memory accesses=0D via the data side, and only relies on instruction fetches before the MMU=0D is enabled. It also avoids any cache maintenance to the PoC.=0D =0D Changes since v3:=0D - drop ArmMmuLib changes that have since been merged=0D =0D Changes since v2:=0D - drop shadow page table approach - it only works at EL1, and is a bit=0D more intrusive than needed; instead, do a proper break-before-make=0D (BBM) unless the break unmaps the page table itself or the code that=0D is modifying it;=0D - add a couple of only tangentially related performance streamlining=0D changes, to avoid dispatching and shadowing drivers that we don't need=0D =0D Changes since v1:=0D - coding style tweaks to placate our CI overlord=0D - drop -mstrict-align which is no longer needed now that all C code runs=0D with the MMU and caches on=0D =0D Cc: Leif Lindholm =0D Cc: Alexander Graf =0D Cc: Gerd Hoffmann =0D Cc: Sami Mujawar =0D =0D Ard Biesheuvel (11):=0D ArmVirtPkg: remove EbcDxe from all platforms=0D ArmVirtPkg: do not enable iSCSI driver by default=0D ArmVirtPkg: make EFI_LOADER_DATA non-executable=0D ArmVirtPkg/ArmVirtQemu: wire up timeout PCD to Timeout variable=0D ArmVirtPkg/ArmVirtQemu: implement ArmPlatformLib with static ID map=0D ArmVirtPkg/ArmVirtQemu: use first 128 MiB as permanent PEI memory=0D ArmVirtPkg/ArmVirtQemu: enable initial ID map at early boot=0D ArmVirtPkg/ArmVirtQemu: Drop unused variable PEIM=0D ArmVirtPkg/ArmVirtQemu: avoid shadowing PEIMs unless necessary=0D ArmVirtPkg/QemuVirtMemInfoLib: use HOB not PCD to record the memory=0D size=0D ArmVirtPkg/ArmVirtQemu: omit PCD PEIM unless TPM support is enabled=0D =0D ArmVirtPkg/ArmVirt.dsc.inc = | 7 +-=0D ArmVirtPkg/ArmVirtCloudHv.fdf = | 5 -=0D ArmVirtPkg/ArmVirtPkg.dec = | 1 +=0D ArmVirtPkg/ArmVirtQemu.dsc = | 53 ++++++---=0D ArmVirtPkg/ArmVirtQemu.fdf = | 5 +-=0D ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc = | 5 -=0D ArmVirtPkg/ArmVirtQemuKernel.dsc = | 1 -=0D ArmVirtPkg/ArmVirtXen.fdf = | 5 -=0D ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S = | 115 ++++++++++++++++++++=0D ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.c = | 64 +++++++++++=0D ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.inf = | 40 +++++++=0D ArmVirtPkg/Library/ArmPlatformLibQemu/IdMap.S = | 57 ++++++++++=0D ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c = | 14 ++-=0D ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf = | 1 +=0D ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c = | 35 +++++-=0D ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf = | 5 +-=0D ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf = | 8 +-=0D ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLibConstructor.c = | 30 +++--=0D ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c = | 104 ++++++++++++++++++=0D ArmVirtPkg/{Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf = =3D> MemoryInitPei/MemoryInitPeim.inf} | 36 +++---=0D 20 files changed, 510 insertions(+), 81 deletions(-)=0D create mode 100644 ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatfo= rmHelper.S=0D create mode 100644 ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQem= u.c=0D create mode 100644 ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQem= u.inf=0D create mode 100644 ArmVirtPkg/Library/ArmPlatformLibQemu/IdMap.S=0D create mode 100644 ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c=0D copy ArmVirtPkg/{Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.i= nf =3D> MemoryInitPei/MemoryInitPeim.inf} (64%)=0D =0D -- =0D 2.35.1=0D =0D