From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by mx.groups.io with SMTP id smtpd.web10.537.1678903384171967975 for ; Wed, 15 Mar 2023 11:03:04 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=EFL4IlFJ; 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.180.131, mailfrom: quic_llindhol@quicinc.com) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FHXW1i008012; Wed, 15 Mar 2023 18:02:53 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=ItwOLNkyMeb8BVJGwtmciyV20TDVuY+JYpOAU48pq1U=; b=EFL4IlFJyDf7W+g/LCgO+xHzaebI3riT3EJhjSr/TRj+bkIcEBCbJHLZz8Zj7HJYiUCO C2wSLFSnfOOuGunzAqoh5/psDi0C1t/DQDw/SV0ew35HTxrDOSLUucZPBdI/Sp6znE9x XexJbjjsjF60xFJYmrepvZ39OMSlV/+xS1UCH3k3PynoQ6Aq3L+wXC7T6baGz2qwnTot m7J0VhBlLGQKVzDtMi2WqEtvFrvUj5JGtBqdWUN3dBofdGGSSKQ0ydeq69k+JHy6APPG SzdCVOMI58T5YJxxzHv2TC6cH3fQ2h5c/VexSxOdWUe+oRglt9jBwSmdC7BXLfI7ggQr ZA== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pbecegx6g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 18:02:52 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32FI2pUB003501 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 18:02:51 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; Wed, 15 Mar 2023 11:02:49 -0700 Date: Wed, 15 Mar 2023 18:02:46 +0000 From: "Leif Lindholm" To: Ard Biesheuvel CC: , Michael Kinney , Liming Gao , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Sami Mujawar , Taylor Beebe Subject: Re: [edk2-devel] [PATCH v5 08/38] ArmPkg/ArmMmuLib: Avoid splitting block entries if possible Message-ID: References: <20230313171714.3866151-1-ardb@kernel.org> <20230313171714.3866151-9-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-ORIG-GUID: BcfQIyEWrEwtYZuw7PWpQixhfGwE8YEU X-Proofpoint-GUID: BcfQIyEWrEwtYZuw7PWpQixhfGwE8YEU 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-15_09,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 malwarescore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150149 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline On Tue, Mar 14, 2023 at 19:29:39 +0100, Ard Biesheuvel wrote: > On Tue, 14 Mar 2023 at 19:13, Leif Lindholm wrote: > > > > On Mon, Mar 13, 2023 at 18:16:44 +0100, Ard Biesheuvel wrote: > > > Currently, the ARM MMU page table logic will break down any block entry > > > that overlaps with the region being mapped, even if the block entry in > > > question is using the same attributes as the new region. > > > > > > This means that creating a non-executable mapping inside a region that > > > is already mapped non-executable at a coarser granularity may trigger a > > > call to AllocatePages (), which may recurse back into the page table > > > code to update the attributes on the newly allocated page tables. > > > > > > Let's avoid this, by preserving the block entry if it already covers the > > > region being mapped with the correct attributes. > > > > So if a later mapping is made inside the same block with conflicting > > attributes? That triggers the break down at that point and because the > > existing mapping did not conflict, it'll all flush out? > > > > Indeed. > > The case here is simply, e.g., mapping a single page XP that is > already covered by a 2 MB XP block: without this patch, we break down > that 2 MB block into page mappings that all have the same attributes. > If the 4k page being remapped is being allocated for a page table, we > may end up with unbounded recursion. > > If the attributes are actually different, the split still happens. But > otherwise, the block mapping is retained. Makes sense. Reviewed-by: Leif Lindholm