From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=104.47.36.121; helo=nam02-sn1-obe.outbound.protection.outlook.com; envelope-from=christopher.co@microsoft.com; receiver=edk2-devel@lists.01.org Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0121.outbound.protection.outlook.com [104.47.36.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4F0122244E3EB for ; Mon, 16 Apr 2018 12:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=QQSJQsRcAxzUTZUckLnvqr1sy/HFXfRS64xKcq3XUpM=; b=czQbjQQt2a8ap5wgK1vBnQk44S6tbUhShLDyu+yJVIGhphlJas681SXN4YaJCZ1ijVeDspQxCnfwJc+c8fuJmY+Kju7qAwY+sbIutjSQmuuBhFv8JquarvCOThoYyeggOV0vRX4m0xTaCPHGHz9zTVWHTEQo20I0WDVk/2s/D9U= Received: from MWHPR21MB0478.namprd21.prod.outlook.com (10.172.102.17) by MWHPR21MB0766.namprd21.prod.outlook.com (10.173.51.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.715.4; Mon, 16 Apr 2018 19:45:54 +0000 Received: from MWHPR21MB0478.namprd21.prod.outlook.com ([fe80::9075:c5cc:66f5:d3cf]) by MWHPR21MB0478.namprd21.prod.outlook.com ([fe80::9075:c5cc:66f5:d3cf%9]) with mapi id 15.20.0715.005; Mon, 16 Apr 2018 19:45:54 +0000 From: Chris Co To: Leif Lindholm CC: "edk2-devel@lists.01.org" , Ard Biesheuvel Thread-Topic: [PATCH] ArmPkg/ArmMmuLib ARM: fix Mva to use idx instead of table base Thread-Index: AQHT04E4VUgPATGz0UKOjPVxqXpwYaQDOLQAgACVRiA= Date: Mon, 16 Apr 2018 19:45:54 +0000 Message-ID: References: <20180416104412.npzwcvl6zlrh426k@bivouac.eciton.net> In-Reply-To: <20180416104412.npzwcvl6zlrh426k@bivouac.eciton.net> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=chrco@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2018-04-16T19:45:52.9460500Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General x-originating-ip: [2001:4898:80e8:8::726] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR21MB0766; 7:agwz+PwEbEsYc1kIk3uaUyoTt/P9EJfSHE0SGV8a7p6ixG7CTrtxxaisKfGOdFG5qoeglsT48/KT1FfUJKjyUkda1031OHMPZuDau0DseLjxInIE7nMMmsV/AjqApvISsxxkCFDFuWbGv5SB8ue4csG/1w7Vs0fF7DwHdywwTJn9YMp+V4swLsH4r+Yz3ivIEDk9eHXYO5IzwKC/UXsXTb8z4fngMwj7TS0FGBP/RLDQ6CSQVOO/+nybWBtEBVLg; 20:IC3AIUSG3Ug3mk5g5ikW+nM3md7vRAZWGYN6QRHW5WnS02WsvRiMZxAcPvlBky+o+/LH3pAp31oazdYfBpbBr5i+gqE57zM1PuAnJyXH3j/3UtHoNd45ffweudmT6QI3pj7iI6A6LXIBZ92cEQMOwIYMesc84y5IJloXExegPgQ= x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(2017052603328)(7193020); SRVR:MWHPR21MB0766; x-ms-traffictypediagnostic: MWHPR21MB0766: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Christopher.Co@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(162533806227266); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(3231232)(944501347)(52105095)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:MWHPR21MB0766; BCL:0; PCL:0; RULEID:; SRVR:MWHPR21MB0766; x-forefront-prvs: 0644578634 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(396003)(346002)(39860400002)(39380400002)(366004)(13464003)(189003)(199004)(59450400001)(6436002)(99286004)(72206003)(6506007)(53546011)(106356001)(76176011)(7696005)(8936002)(2906002)(74316002)(305945005)(8676002)(4326008)(81156014)(81166006)(7736002)(2900100001)(5660300001)(478600001)(33656002)(10290500003)(3660700001)(14454004)(25786009)(3280700002)(86612001)(446003)(8990500004)(11346002)(53936002)(22452003)(486006)(55016002)(476003)(5250100002)(6116002)(6246003)(97736004)(46003)(68736007)(105586002)(54906003)(86362001)(186003)(102836004)(9686003)(316002)(10090500001)(229853002)(6916009); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR21MB0766; H:MWHPR21MB0478.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: ogDUiv48amcZGweStR5eiW277TztZKd6T/r+qFE+Nt/7Ov8lGiOJ8jlrhP//GxP9LRe5zyXvCbwKn5fNI92p1hZCrCbBmEyxEs+HjWmvMjZBVdQWO8C8nOu6o913j3/RpMJ4KNTy70tMS5GHXSKoqQpawTDay7Lk2yPLrtHwgRlgkAY3yuGjRELkoEPxtn0a spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 15e54369-2169-41ab-f3d7-08d5a3d2aabd X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15e54369-2169-41ab-f3d7-08d5a3d2aabd X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Apr 2018 19:45:54.4076 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR21MB0766 Subject: Re: [PATCH] ArmPkg/ArmMmuLib ARM: fix Mva to use idx instead of table base X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Apr 2018 19:45:57 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Leif, > -----Original Message----- > From: Leif Lindholm > Sent: Monday, April 16, 2018 3:44 AM > To: Chris Co > Cc: edk2-devel@lists.01.org; Ard Biesheuvel > Subject: Re: [PATCH] ArmPkg/ArmMmuLib ARM: fix Mva to use idx instead > of table base >=20 > On Fri, Apr 13, 2018 at 11:43:27PM +0000, Chris Co wrote: > > Mva address calculation should use the left-shifted current section > > index instead of the left-shifted table base address. > > > > Using the table base address here has the side-effect of potentially > > causing an access violation depending on the base address value. > > > > Cc: Leif Lindholm > > Cc: Ard Biesheuvel > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Christopher Co > > --- > > ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c > > b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c > > index 774a7ccf59..9bf4ba03fd 100644 > > --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c > > +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c > > @@ -716,7 +716,7 @@ UpdateSectionEntries ( > > Descriptor |=3D EntryValue; > > > > if (CurrentDescriptor !=3D Descriptor) { > > - Mva =3D (VOID *)(UINTN)(((UINTN)FirstLevelTable) << > TT_DESCRIPTOR_SECTION_BASE_SHIFT); > > + Mva =3D (VOID *)(UINTN)(((UINTN)FirstLevelIdx + i) << > > + TT_DESCRIPTOR_SECTION_BASE_SHIFT); >=20 > So, this clearly looks like you've found a bug - thanks! >=20 > But I am a little bit confused about the patch - should this not need to > incorporate the descriptor size in some way? > I.e. something like > Mva =3D (VOID *)(UINTN)(((UINTN)FirstLevelIdx + (i * sizeof(UINTN))) << > TT_DESCRIPTOR_SECTION_BASE_SHIFT); > or > ... &FirstLevelTable[FirstLevelIndex + i] ... >=20 > ? >=20 > Regards, >=20 > Leif >=20 I don't think descriptor size is needed here. =20 My understanding is that Mva is the base address of the current section.=20 FirstLevelidx is derived by the first section's BaseAddress >> 20. The cur= rent section index is then (FirstLevelIdx + i), which makes the base address of the curr= ent=20 section (FirstLeveLidx + i) << 20. Thanks, Chris > > > > // Clean/invalidate the cache for this section, but only > > // if we are modifying the memory type attributes > > -- > > 2.15.1.gvfs.2.39.g03d366a > >