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.34133.1679921820358920305 for ; Mon, 27 Mar 2023 05:57:00 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=LeliXJjP; 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 (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32RCjAJW002050; Mon, 27 Mar 2023 12:56:48 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=1gKpkLdnKjeIaYxx1aWTjVjMO/XSyYBmvKCpwesNx/A=; b=LeliXJjP35td9f3Vjq5GKwF4ApW4yMvAznOE49pccqOVD+sVqMbjbKg5V6vAiTvAOiTY amOxlrNlblU2QUz4ejTAtSOFykkp76iGMx1xJ4sm/m8oXSfk+lGd6vKVqMLPZMQL+zLT i6ZVdw06lZEsutS6n3XQrJYg/h5DR9nJKq/SVBt4WgPLeByaVkem4GUPxoFvVcOckK22 nIxtl0csjh5AHDYRHEVb4nWp+pQPGLEAGGBh5ZJTSmRD50vp1dRfJWfIPCjh2/TxSQcO xsOKIEQqUb8L8lQO7A8xJk3dZkkTjoKyJDnFsmrHwKbuAQ8F/HSue16640D+d+3DJctb aA== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pht8f4dsd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 12:56:48 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32RCulUV003152 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Mar 2023 12:56:47 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.41; Mon, 27 Mar 2023 05:56:44 -0700 Date: Mon, 27 Mar 2023 13:56:41 +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 01/17] MdePkg/ProcessorBind AARCH64: Add asm macro to emit GNU BTI note Message-ID: References: <20230327110112.262503-1-ardb@kernel.org> <20230327110112.262503-2-ardb@kernel.org> MIME-Version: 1.0 In-Reply-To: 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: KOBFrnJ4wADVawqKYFdKZ7_DDI9QlAIx X-Proofpoint-ORIG-GUID: KOBFrnJ4wADVawqKYFdKZ7_DDI9QlAIx 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-24_11,2023-03-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 suspectscore=0 malwarescore=0 impostorscore=0 clxscore=1015 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303270101 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline On Mon, Mar 27, 2023 at 14:15:09 +0200, Ard Biesheuvel wrote: > On Mon, 27 Mar 2023 at 13:53, Leif Lindholm wrote: > > > > On Mon, Mar 27, 2023 at 13:00:56 +0200, Ard Biesheuvel wrote: > > > Implement a CPP macro that can be called from .S files to emit the .note > > > section carrying the annotation that informs the linker that the object > > > file is compatible with BTI control flow integrity checks. > > > > > > Signed-off-by: Ard Biesheuvel > > > --- > > > MdePkg/Include/AArch64/ProcessorBind.h | 31 ++++++++++++++++++++ > > > 1 file changed, 31 insertions(+) > > > > > > diff --git a/MdePkg/Include/AArch64/ProcessorBind.h b/MdePkg/Include/AArch64/ProcessorBind.h > > > index abe2571245c665f3..11814f1ffaef698a 100644 > > > --- a/MdePkg/Include/AArch64/ProcessorBind.h > > > +++ b/MdePkg/Include/AArch64/ProcessorBind.h > > > @@ -186,6 +186,37 @@ typedef INT64 INTN; > > > #define GCC_ASM_IMPORT(func__) \ > > > .extern _CONCATENATE (__USER_LABEL_PREFIX__, func__) > > > > > > +#if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1 > > > +#define AARCH64_BTI(__type) \ > > > + .ifnc __type, ;\ > > > + bti __type ;\ > > > + .endif ;\ > > > + .ifndef .Lgnu_bti_notesize ;\ > > > + .pushsection .note.gnu.property, "a" ;\ > > > + .set NT_GNU_PROPERTY_TYPE_0, 0x5 ;\ > > > + .set GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000 ;\ > > > + .set GNU_PROPERTY_AARCH64_FEATURE_1_BTI, 0x1 ;\ > > > + .align 3 ;\ > > > + .long .Lnamesize ;\ > > > + .long .Lgnu_bti_notesize ;\ > > > + .long NT_GNU_PROPERTY_TYPE_0 ;\ > > > +0: .asciz "GNU" ;\ > > > + .set .Lnamesize, . - 0b ;\ > > > + .align 3 ;\ > > > +1: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND ;\ > > > + .long .Lvalsize ;\ > > > +2: .long GNU_PROPERTY_AARCH64_FEATURE_1_BTI ;\ > > > + .set .Lvalsize, . - 2b ;\ > > > + .align 3 ;\ > > > + .set .Lgnu_bti_notesize, . - 1b ;\ > > > + .popsection ;\ > > > + .endif > > > +#endif > > > + > > > +#endif > > > > Is that second endif superflouous? > > > > No the diff just turned out a bit odd. Oh, I see - it's because you add this inside the if __GNUC__ || __clang__ and add the #ifndef AARCH64_BTI outside it. Which is necessary. Moving on. / Leif