From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by mx.groups.io with SMTP id smtpd.web11.1137.1680107504163794846 for ; Wed, 29 Mar 2023 09:31:44 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=f36acfXL; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: quicinc.com, ip: 205.220.168.131, mailfrom: quic_llindhol@quicinc.com) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32TB4WZB002621; Wed, 29 Mar 2023 16:31:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=qcppdkim1; bh=/kb1ph3eBs3J+kGTK7BCZs+GWJLkIL5HYo7siVyO/hM=; b=f36acfXLLEnTZwHoCxIt/cg5NMcBBugCmNTKaYp4c18Sd5tNv8WYjbo3UaQ85mBnlkgQ Xnst+HAOKF9kTT97jHR7erpPlIxyWPoGw6V00A02Yu/M3dS4mUUy0FDV7mMWHbQnNTnP gAexhSfDys0DLW17s0+tDq21rSmMwk3d4wc5sXT9gQUg6KZbMuyA4bhYnSgG4c1H82Jm jKlCcGUE/icOCgAPDR9HzrA0FK4uE28cs9fjVQLnvyUWPgwduzwlMe/8U92AiUFVQr5E d632x+hTVnF8XzzOFCogKcluzUPfBa3ccDkyjzrvTRlbkgqq+ibWcElDaxfWv/WcTeKd /g== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pmd6uhsdw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Mar 2023 16:31:34 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32TGVXfR025902 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Mar 2023 16:31:33 GMT Received: from qc-i7.hemma.eciton.net (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Wed, 29 Mar 2023 09:31:30 -0700 Date: Wed, 29 Mar 2023 17:31:26 +0100 From: "Leif Lindholm" To: Ard Biesheuvel CC: , Michael Kinney , Liming Gao , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Sami Mujawar , Taylor Beebe , Marvin =?iso-8859-1?Q?H=E4user?= , Bob Feng Subject: Re: [PATCH v2 00/17] Enable BTI support in memory attributes table Message-ID: References: <20230327110112.262503-1-ardb@kernel.org> MIME-Version: 1.0 In-Reply-To: <20230327110112.262503-1-ardb@kernel.org> X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: -UQH_mke4rMKwSbwQGFfVd_1-GdTxZmz X-Proofpoint-ORIG-GUID: -UQH_mke4rMKwSbwQGFfVd_1-GdTxZmz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-29_10,2023-03-28_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 mlxscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=942 malwarescore=0 clxscore=1015 phishscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303290128 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline On Mon, Mar 27, 2023 at 13:00:55 +0200, Ard Biesheuvel wrote: > Implement version 2 of the memory attributes table, which now contains a > flag informing the OS whether or not code regions may be mapped with CFI > mitigations such as IBT or BTI enabled. > > This series covers roughly the following parts: > > - (AARCH64) Annotate ELF objects generated from asm as BTI compatible > when BTI codegen is enabled > - Update the BaseTools to emit the appropriate PE/COFF annotation when a > BTI/IBT compatible ELF executable is converted to PE/COFF > - Take this PE/COFF annotation into account when populating the memory > attributes table in the DXE core For any patches I haven't explicitly commented on in this set: Reviewed-by: Leif Lindholm (but I did comment on patch 17 in the review of patch 15) / Leif > TODO: > - X64 changes to make the code IBT compatible and emit the ELF note > - Figure out how to generate such executables with native PE toolchains > - Implement BTI/IBT enforcement at boot time - this is something I > intend to look into next. > > Can be tested with the CLANG38 toolchain (both Clang compiler and LLD > linker, version 3.8 or newer) with the following build options. > > [BuildOptions] > GCC:*_*_AARCH64_PP_FLAGS = -mbranch-protection=bti > GCC:*_*_AARCH64_CC_FLAGS = -mbranch-protection=bti > GCC:*_*_AARCH64_DLINK_FLAGS = -fuse-ld=lld -Wl,--no-relax,--no-pie,-z,bti-report=error > > Cc: Michael Kinney > Cc: Liming Gao > Cc: Jiewen Yao > Cc: Michael Kubacki > Cc: Sean Brogan > Cc: Rebecca Cran > Cc: Leif Lindholm > Cc: Sami Mujawar > Cc: Taylor Beebe > Cc: Marvin H??user > Cc: Bob Feng > > Ard Biesheuvel (17): > MdePkg/ProcessorBind AARCH64: Add asm macro to emit GNU BTI note > MdePkg/BaseCpuLib AARCH64: Make asm files BTI compatible > MdePkg/BaseIoLibIntrinsic AARCH64: Make asm files BTI compatible > MdePkg/BaseLib AARCH64: Make LongJump() BTI compatible > MdePkg/BaseLib AARCH64: Make asm files BTI compatible > MdePkg/BaseMemoryLibOptDxe AARCH64: Make asm files BTI compatible > MdePkg/BaseSynchronizationLib AARCH64: Make asm files BTI compatible > MdePkg/BaseRngLib AARCH64: Make asm files BTI compatible > ArmPkg: Emit BTI opcodes when BTI codegen is enabled > ArmPkg/GccLto AARCH64: Add BTI note to LTO helper library > ArmPkg, BaseTools AARCH64: Add BTI ELF note to .hii objects > ArmPlatformPkg/PrePeiCore: Make vector table object BTI compatible > BaseTools/GenFw: Parse IBT/BTI support status from ELF note > BaseTools/GenFw: Add DllCharacteristicsEx field to debug data > MdePkg: Update MemoryAttributesTable to v2.10 > MdePkg/PeCoffLib: Capture DLL characteristics fieldis in image context > MdeModulePkg: Enable forward edge CFI in mem attributes table > > ArmPkg/Include/AsmMacroIoLibV8.h | 3 +- > ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S | 3 +- > ArmPkg/Library/ArmSvcLib/AArch64/ArmSvc.S | 4 +- > ArmPkg/Library/GccLto/liblto-aarch64.a | Bin 1016 -> 1128 bytes > ArmPkg/Library/GnuNoteBti.bin | Bin 0 -> 32 bytes > ArmPlatformPkg/PrePeiCore/AArch64/Exception.S | 2 + > ArmVirtPkg/Library/ArmPlatformLibQemu/IdMap.S | 2 + > BaseTools/Conf/tools_def.template | 4 +- > BaseTools/Source/C/GenFw/Elf64Convert.c | 104 +++++++++++++++++--- > BaseTools/Source/C/GenFw/GenFw.c | 3 +- > BaseTools/Source/C/GenFw/elf_common.h | 9 ++ > BaseTools/Source/C/Include/IndustryStandard/PeImage.h | 13 ++- > MdeModulePkg/Core/Dxe/DxeMain.h | 2 + > MdeModulePkg/Core/Dxe/Image/Image.c | 10 ++ > MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c | 8 +- > MdePkg/Include/AArch64/ProcessorBind.h | 31 ++++++ > MdePkg/Include/Guid/MemoryAttributesTable.h | 8 +- > MdePkg/Include/IndustryStandard/PeImage.h | 13 ++- > MdePkg/Include/Library/PeCoffLib.h | 6 ++ > MdePkg/Library/BaseCpuLib/AArch64/CpuFlushTlb.S | 1 + > MdePkg/Library/BaseCpuLib/AArch64/CpuSleep.S | 1 + > MdePkg/Library/BaseIoLibIntrinsic/AArch64/ArmVirtMmio.S | 8 ++ > MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S | 1 + > MdePkg/Library/BaseLib/AArch64/DisableInterrupts.S | 1 + > MdePkg/Library/BaseLib/AArch64/EnableInterrupts.S | 1 + > MdePkg/Library/BaseLib/AArch64/GetInterruptsState.S | 1 + > MdePkg/Library/BaseLib/AArch64/MemoryFence.S | 1 + > MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S | 5 +- > MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.S | 1 + > MdePkg/Library/BaseLib/AArch64/SwitchStack.S | 2 + > MdePkg/Library/BaseMemoryLibOptDxe/AArch64/CompareGuid.S | 1 + > MdePkg/Library/BaseMemoryLibOptDxe/AArch64/CompareMem.S | 1 + > MdePkg/Library/BaseMemoryLibOptDxe/AArch64/CopyMem.S | 1 + > MdePkg/Library/BaseMemoryLibOptDxe/AArch64/ScanMem.S | 1 + > MdePkg/Library/BaseMemoryLibOptDxe/AArch64/SetMem.S | 5 + > MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 46 ++++++--- > MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.S | 3 +- > MdePkg/Library/BaseRngLib/AArch64/ArmRng.S | 1 + > MdePkg/Library/BaseSynchronizationLib/AArch64/Synchronization.S | 5 + > 39 files changed, 270 insertions(+), 42 deletions(-) > create mode 100644 ArmPkg/Library/GnuNoteBti.bin > > -- > 2.39.2 >