From nobody Sat May 4 14:15:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+55520+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55520+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1583413159; cv=none; d=zohomail.com; s=zohoarc; b=hZgWOjR5m7UZOLi2HXcHV5H9PRUfbuCQ0jMIx1EvHXHPJc2qBjAU1yVLtnucN3U1ASu5A5rZTL0ZI4sBw8KxBgTyTEwNspcH02Pgz1V/MT89aJ5b6ZiJbJPIg8V4SQ1uG2Wej1TJidtm5HZyCZ/orYwtrZXr/159q1ZLbPgQjEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583413159; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=6istVcPypUFEDqpduiiSxEvW3ELlnND1Xgq30awrKCI=; b=dTZai37OzI8bmAFTzamfCUBolJ5far/RVyB14hUxeiZpZ7te0nGDuOqSqI850iGHKFhZZ1zX3+L/YX4Ob3CmZ+JKDKZabMN56vbTcT+Ey78P0pJP4JuaQxiM9U9T8B/X/pnIlFFt3Lu/KXvScU+CECcZ5DS1IVxj3sTxWBysbjs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55520+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1583413159974935.035725520078; Thu, 5 Mar 2020 04:59:19 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 3G9iYY1788612xIuhz9a94eE; Thu, 05 Mar 2020 04:59:19 -0800 X-Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web09.11907.1583413158640837158 for ; Thu, 05 Mar 2020 04:59:19 -0800 X-Received: by mail-wr1-f65.google.com with SMTP id 6so1472846wre.4 for ; Thu, 05 Mar 2020 04:59:18 -0800 (PST) X-Gm-Message-State: 2J0D4iTzXHFY8xVlS28wLdnnx1787277AA= X-Google-Smtp-Source: ADFU+vve+GwgOFujE+1GKm+ppwXu5XjgmONTRmJixoUSuIzM5bBfB6ER6coE/WiKClEKWiWujfowCA== X-Received: by 2002:adf:fd92:: with SMTP id d18mr10607843wrr.16.1583413156963; Thu, 05 Mar 2020 04:59:16 -0800 (PST) X-Received: from e123331-lin.home ([2a01:cb1d:112:6f00:816e:ff0d:fb69:f613]) by smtp.gmail.com with ESMTPSA id v8sm43019476wrw.2.2020.03.05.04.59.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 04:59:16 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH 1/2] ArmPkg/ArmMmuLib ARM: simplify assignment of TTBR0 system register Date: Thu, 5 Mar 2020 13:59:06 +0100 Message-Id: <20200305125907.13680-2-ard.biesheuvel@linaro.org> In-Reply-To: <20200305125907.13680-1-ard.biesheuvel@linaro.org> References: <20200305125907.13680-1-ard.biesheuvel@linaro.org> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ard.biesheuvel@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1583413159; bh=678ImIZT+NxZhnrrQbUqaewBYwfGhD988wRvSZqXZbI=; h=Cc:Date:From:Reply-To:Subject:To; b=pqrMzg1sOejbyctL5ceYNQt2diLkXj6GMCqvRpCqAVkaCA0F67MaTIKlIm3dm+CB7tZ Ct6jlUxnHJmh9h5VFCeoDIJ1E0RmaZbQvFytHkKtCyFHw/83thouaGTs/6ah1oo3vmJ2K Q2etiaeITIaY6N8Xdvht5BurWqHnZw4gHFM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The expression passed into ArmSetTTBR0 () in ArmConfigureMmu() is sub-optimal at several levels: - TranslationTable is already aligned, and if it wasn't, doing it here wouldn't help - TTBRAttributes is guaranteed not to have any bits set outside of the 0x7f mask, so the mask operation is pointless as well, - an additional (UINTN) cast for good measure is also not needed. So simplify the expression. Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- 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 11a1e704beab..a6f44dbd5f21 100644 --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c @@ -392,7 +392,7 @@ ArmConfigureMmu ( } } =20 - ArmSetTTBR0 ((VOID *)(UINTN)(((UINTN)TranslationTable & ~TRANSLATION_TAB= LE_SECTION_ALIGNMENT_MASK) | (TTBRAttributes & 0x7F))); + ArmSetTTBR0 ((VOID *)((UINTN)TranslationTable | TTBRAttributes)); =20 // // The TTBCR register value is undefined at reset in the Non-Secure worl= d. --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#55520): https://edk2.groups.io/g/devel/message/55520 Mute This Topic: https://groups.io/mt/71748690/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 4 14:15:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+55521+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55521+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1583413161; cv=none; d=zohomail.com; s=zohoarc; b=F9f+vkMaiwxyMA6idBhxB+1CyK5Wr67aS2pcskjWwtDJP/6WY8tnMPjPdt0Zx4sM9naXvUdlyI4Yi14noej2IRHPq8lDivmz19Xg6xJ+mXMCtN5j/tHcV2QhLQHqF3MI7k8Sm4OBO7AQ+HlAurSJ1vmPI1ZjzcR89dcb4OSkAt0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583413161; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=slCV9bS1fUpNKBhu6wLlTGD2MGsvtEC59ONLgIwDc2E=; b=YvH26G+iygaOZRdhr/X1Hp4+G8vv7Eah710PMHiAT0t5B+jbhUxQ02Y7k7sgmeHQNRI3LWAu9O917KLwzMs0jc2k4Tb0bFJK0F9z72c/BsXYSjrs/2srm+aL4bjDyy4ymaFFIbM40X8FacfFzEqZPFDlGgrd46FMwmeIU+tcEUM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55521+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1583413161141192.2212805726872; Thu, 5 Mar 2020 04:59:21 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id d433YY1788612xw6JLL7XBjh; Thu, 05 Mar 2020 04:59:20 -0800 X-Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by mx.groups.io with SMTP id smtpd.web09.11908.1583413159967430933 for ; Thu, 05 Mar 2020 04:59:20 -0800 X-Received: by mail-wm1-f68.google.com with SMTP id a5so6205337wmb.0 for ; Thu, 05 Mar 2020 04:59:19 -0800 (PST) X-Gm-Message-State: IR8Tuh5XxbIZFJvLam5tFcOZx1787277AA= X-Google-Smtp-Source: ADFU+vvVbc9+REWlApIscg955oFNcRH8M0pAKN7bodosjbnldrdjF8Mq/2zz2nkZwHel9OTBK2lkgA== X-Received: by 2002:a1c:7ed0:: with SMTP id z199mr10075736wmc.52.1583413158167; Thu, 05 Mar 2020 04:59:18 -0800 (PST) X-Received: from e123331-lin.home ([2a01:cb1d:112:6f00:816e:ff0d:fb69:f613]) by smtp.gmail.com with ESMTPSA id v8sm43019476wrw.2.2020.03.05.04.59.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 04:59:17 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH 2/2] ArmPkg/ArmMmuLib ARM: drop memory type check for page tables Date: Thu, 5 Mar 2020 13:59:07 +0100 Message-Id: <20200305125907.13680-3-ard.biesheuvel@linaro.org> In-Reply-To: <20200305125907.13680-1-ard.biesheuvel@linaro.org> References: <20200305125907.13680-1-ard.biesheuvel@linaro.org> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ard.biesheuvel@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1583413160; bh=xUCQytEhFgIgmyo5U8UqxluCX1A/lk9BbIGjIu0J2VA=; h=Cc:Date:From:Reply-To:Subject:To; b=YwyHVAEYFbzOqOF7q/4RWO3NNcXeav+Xw22lacIxrFirCmLQw3lXy8lY/Y56UQWAtsb xlsuLlC/jA/xT6hKvuVbplw+SP9Wmr6i0tIBJHKr6tqRxksX5P4JdowWj8+wJ+RY7xgYi PuuHaFV4j/0RKzkviDCqsUlIlvhFeyg0QNU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We already expect normal memory to be mapped writeback cacheable if EDK2 itself is to make use of it, so doing an early sanity check on the memory type of the allocation that the page tables happened to land in isn't very useful. So let's drop it. Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c b/ArmPkg/Library/= ArmMmuLib/Arm/ArmMmuLibCore.c index a6f44dbd5f21..15e836e75e8e 100644 --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c @@ -328,7 +328,6 @@ ArmConfigureMmu ( ) { VOID *TranslationTable; - ARM_MEMORY_REGION_ATTRIBUTES TranslationTableAttribute; UINT32 TTBRAttributes; =20 TranslationTable =3D AllocateAlignedPages ( @@ -353,28 +352,13 @@ ArmConfigureMmu ( InvalidateDataCacheRange (TranslationTable, TRANSLATION_TABLE_SECTION_SI= ZE); ZeroMem (TranslationTable, TRANSLATION_TABLE_SECTION_SIZE); =20 - // By default, mark the translation table as belonging to a uncached reg= ion - TranslationTableAttribute =3D ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUF= FERED; while (MemoryTable->Length !=3D 0) { - // Find the memory attribute for the Translation Table - if (((UINTN)TranslationTable >=3D MemoryTable->PhysicalBase) && ((UINT= N)TranslationTable <=3D MemoryTable->PhysicalBase - 1 + MemoryTable->Length= )) { - TranslationTableAttribute =3D MemoryTable->Attributes; - } - FillTranslationTable (TranslationTable, MemoryTable); MemoryTable++; } =20 - // Translate the Memory Attributes into Translation Table Register Attri= butes - if ((TranslationTableAttribute =3D=3D ARM_MEMORY_REGION_ATTRIBUTE_WRITE_= BACK) || - (TranslationTableAttribute =3D=3D ARM_MEMORY_REGION_ATTRIBUTE_NONSEC= URE_WRITE_BACK)) { - TTBRAttributes =3D ArmHasMpExtensions () ? TTBR_MP_WRITE_BACK_ALLOC : = TTBR_WRITE_BACK_ALLOC; - } else { - // Page tables must reside in memory mapped as write-back cacheable - ASSERT (0); - return RETURN_UNSUPPORTED; - } - + TTBRAttributes =3D ArmHasMpExtensions () ? TTBR_MP_WRITE_BACK_ALLOC + : TTBR_WRITE_BACK_ALLOC; if (TTBRAttributes & TTBR_SHAREABLE) { if (PreferNonshareableMemory ()) { TTBRAttributes ^=3D TTBR_SHAREABLE; --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#55521): https://edk2.groups.io/g/devel/message/55521 Mute This Topic: https://groups.io/mt/71748691/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-