Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F732EB8FD4 for ; Wed, 6 Sep 2023 13:54:22 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AB12686519; Wed, 6 Sep 2023 15:54:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="rkergUcH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6710C86546; Wed, 6 Sep 2023 15:54:19 +0200 (CEST) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6617185DFA for ; Wed, 6 Sep 2023 15:54:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=afd@ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 386DsDbi020696; Wed, 6 Sep 2023 08:54:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1694008453; bh=yDpJ4V7UiBzjurLNbiO3WuRvlYb29+jsp5rx+fsq2ek=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=rkergUcHg0cjKV+7q96E4Xm7IqHWcQHLTsFx9aQd6F/UPtzFz/3kxXxpssr06WVvi jOG2Xhs6oOoODr7Frz3Tf0Rc9lTPHKXTCQoP2DeincTDVuFovtq/ILarvPTeE82+Z1 Bi+vSZVZPNBcMwaGXAEmAe9fSD7lE/77i+9o+tT4= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 386DsDdM028684 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 6 Sep 2023 08:54:13 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 6 Sep 2023 08:54:11 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 6 Sep 2023 08:54:11 -0500 Received: from [10.250.38.120] (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 386DsBNY073518; Wed, 6 Sep 2023 08:54:11 -0500 Message-ID: <4eb25acc-0d36-fa59-eb89-b8e3321dae3e@ti.com> Date: Wed, 6 Sep 2023 08:54:11 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [RFC PATCH 2/2] binman: j721e: Add firewall configurations for atf To: Manorit Chawdhry CC: Simon Glass , Alper Nebi Yasak , Neha Malcom Francis , Vignesh Raghavendra , , Udit Kumar , Praneeth Bajjuri , Kamlesh Gurudasani , Nishanth Menon References: <20230905-binman-firewalling-v1-0-3894520bff8a@ti.com> <20230905-binman-firewalling-v1-2-3894520bff8a@ti.com> <72516776-1b6f-cd79-2e00-a28b920f722f@ti.com> <20230906051840.3747bkybpqd2m4gg@ula0497581> Content-Language: en-US From: Andrew Davis In-Reply-To: <20230906051840.3747bkybpqd2m4gg@ula0497581> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On 9/6/23 12:18 AM, Manorit Chawdhry wrote: > Hi Andrew, > > On 10:22-20230905, Andrew Davis wrote: >> On 9/5/23 3:21 AM, Manorit Chawdhry wrote: >>> The following commits adds the configuration of firewalls required to >>> protect ATF and OP-TEE memory region from non-secure reads and >>> writes using master and slave firewalls present in our K3 SOCs. >>> >>> Signed-off-by: Manorit Chawdhry >>> --- >>> arch/arm/dts/k3-j721e-binman.dtsi | 161 ++++++++++++++++++++++++++++++++++++++ >>> 1 file changed, 161 insertions(+) >>> >>> diff --git a/arch/arm/dts/k3-j721e-binman.dtsi b/arch/arm/dts/k3-j721e-binman.dtsi >>> index 4f566c21a9af..0569a592597e 100644 >>> --- a/arch/arm/dts/k3-j721e-binman.dtsi >>> +++ b/arch/arm/dts/k3-j721e-binman.dtsi >>> @@ -330,6 +330,73 @@ >>> ti-secure { >>> content = <&atf>; >>> keyfile = "custMpk.pem"; >>> + auth_in_place = <0xa02>; >>> + >>> + // cpu_0_cpu_0_msmc Background Firewall - 0 >> >> I don't have a personal preference, but I see most comments in DTS >> are C style /* */. >> >> Also it might be easier to understand if you put the comments right before >> the properties that they relate to, i.g. >> >> firewall-0 { >> /* cpu_0_cpu_0_msmc */ >> id = <257>; >> region = <0>; >> /* Background, Locked */ >> control = <0x31a>; >> permissions = <0xc3ffff>; >> start_address = <0x0 0x0>; >> end_address = <0xff 0xffffffff>; >> }; >> >> For permissions, I wonder if it would be easier to read if we add >> some helper macros: >> >> #define FWPRIVID_ALL 0xc3 >> >> #define FWPERM_SECURE_PRIV_WRITE BIT(0) >> #define FWPERM_SECURE_PRIV_READ BIT(1) >> #define FWPERM_SECURE_PRIV_CACHEABLE BIT(2) >> #define FWPERM_SECURE_PRIV_DEBUG BIT(3) >> #define FWPERM_SECURE_USER_WRITE BIT(4) >> ... >> >> Then you would have: >> >> permissions = > I think we'll have to do some shift here for the right calculations. > > #define FWPRIVID_SHIFT 8 > > permissions = <(FWPRIVID_ALL << FWPRIVID_SHIFT) Right, I must have meant #define FWPRIVID_ALL 0xc30000 above, but a shift looks better. >> FWPERM_SECURE_PRIV_WRITE | >> FWPERM_SECURE_PRIV_READ | > > Also, I would like to make FWPERM_SECURE_PRIV_RWCD too as it'll be > commonly used. > > Would be sending another RFC with this change if you are fine with the > suggestions. Thank you for reviewing! > Works for me, should get rid of several of these magic numbers. Andrew > Regards, > Manorit > >> ... > > >>> ; >> >>> + firewall-0 { >>> + id = <257>; >>> + region = <0>; >>> + control = <0x31a>; >>> + permissions = <0xc3ffff>; >>> + start_address = <0x0 0x0>; >>> + end_address = <0xff 0xffffffff>; >>> + }; >>> + >>> + // cpu_0_cpu_0_msmc Foreground Firewall >>> + firewall-1 { >>> + id = <257>; >>> + region = <1>; >>> + control = <0x1a>; >>> + permissions = <0x0100ff>; >>> + start_address = <0x0 0x70000000>; >> >> This address might change if one moves ATF, might work to use CONFIG_K3_ATF_LOAD_ADDR? >> Not sure how you would get the end address as we don't really know ATF size.. >> >> Andrew