Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1349173ybn; Wed, 2 Oct 2019 14:50:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXvl3TYCQd72DAlwZamj0OS4otSenFAxvJZ1DHAq3Lnyl4ZdocSZQHKA1KBKXySwzNDfk3 X-Received: by 2002:a17:906:4ad2:: with SMTP id u18mr5000126ejt.117.1570053047874; Wed, 02 Oct 2019 14:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570053047; cv=none; d=google.com; s=arc-20160816; b=u0VqOp7Dr1hCAV6aGbex5X9whtcMzcb21K0lYF2kErNoAw9fGZqYN9UeYlhnEgUjJH fXyDQm18Y8OdLMc4MtJPcuqyg6zRSNIkEfqgqM9cpN6K6nwWqG6Fp0aVh9JOtU+yzv6a In0HTXhFpTbSKgTORN/WtBPHS4acOsAvtMVFncNF3cLd6dgYHprIGAqECR5E1G6mk1+6 +uDJ28Io2tU6pdw8AuI4n6UQ69iR7wHgAhQ2SoDs0J3t12glvr2nrlRUvejP5us9w+Bb PkR+APhADY0gRuK9aWGKRYHSpMfsrRVg6Tj1WSCr3RawVktvNKwx24uUOhirsrwHC5MC Bm8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=MCGITbqxvMzcSnG0lEdlzIrfLrFGMXd0z/Adzd6pQV8=; b=uQbry2UFOqnrUfUQdtCeBxYo/8JNLi7Lz6eoIw4mkNDIkaTj1Uw0UeGD/P1Bi8VKLL WI5b4yndxNIIfhQ6PljLCWraQO4uBmB6Pv/dPttw9ggPtRWC9jL0k6frxvSqp1+swEne sMcMAykA9SdS1H2QUii1yJGEwNwBh0eq6P7Y+CbEfp7hkVyXTq/hNP4dnu/XbUSa7DZX dezrAjF8YwrT6Vi1IO0FbZYYUZnnvnQ5QLpjx9Awu1w3q8KArDUuXjV4y6LrN/gjsvm6 HkH7A9EWGI24C61qK5qoWJprLpM3AV+UcHZDpSsywBgic7dJBTF8ST/d7Xj3rXD7p9Ym DKGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a41si263987eda.366.2019.10.02.14.50.23; Wed, 02 Oct 2019 14:50:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728081AbfJBUa5 (ORCPT + 99 others); Wed, 2 Oct 2019 16:30:57 -0400 Received: from avon.wwwdotorg.org ([104.237.132.123]:44176 "EHLO avon.wwwdotorg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725799AbfJBUa4 (ORCPT ); Wed, 2 Oct 2019 16:30:56 -0400 Received: from [10.20.204.51] (unknown [216.228.112.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPSA id 1D3BD1C00ED; Wed, 2 Oct 2019 14:30:55 -0600 (MDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.3 at avon.wwwdotorg.org Subject: Re: [PATCH] arm64: tegra: only map accessible sysram To: Mian Yousaf Kaukab Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, treding@nvidia.com, jonathanh@nvidia.com, linux-tegra@vger.kernel.org References: <20190929200851.14228-1-ykaukab@suse.de> <5d2e47ec-8304-d648-9c4a-80c7c02050a9@wwwdotorg.org> <20190930100212.GA21324@suse.de> From: Stephen Warren Message-ID: Date: Wed, 2 Oct 2019 14:30:53 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190930100212.GA21324@suse.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/30/19 4:02 AM, Mian Yousaf Kaukab wrote: > On Sun, Sep 29, 2019 at 11:28:43PM -0600, Stephen Warren wrote: >> On 9/29/19 2:08 PM, Mian Yousaf Kaukab wrote: >>> Most of the SysRAM is secure and only accessible by TF-A. >>> Don't map this inaccessible memory in kernel. Only map pages >>> used by bpmp driver. >> >> I don't believe this change is correct. The actual patch doesn't >> implement mapping a subset of the RAM (a software issue), but rather it >> changes the DT representation of the SYSRAM hardware. The SYSRAM >> hardware always does start at 0x30000000, even if a subset of the >> address range is dedicated to a specific purpose. If the kernel must map >> only part of the RAM, then some additional property should indicate >> this.[...] > I agree the hardware description becomes inaccurate with this change. > > In the current setup complete 0x3000_0000 to 0x3005_0000 range is being mapped > as normal memory (MT_NORMAL_NC). Though only 0x3004_E000 to 0x3005_0000 are > accessible by the kernel. Nit: I expect that a much larger region than that is *accessible*, although it's quite plausible that only that region is actually *accessed*/used right now. > I am seeing an issue where a read access (which I > believe is speculative) to inaccessible range causes an SError. Another > solution for this problem could be to add "no-memory-wc" to SysRAM node so that > it is mapped as device memory (MT_DEVICE_nGnRE). Would that be acceptable? Why does the driver blindly map the entire memory at all? Surely it should only map the portions of RAM that other drivers request/use? And surely the BPMP driver or DT node is already providing that information? But yes, changing the mapping type to avoid speculation might be an acceptable solution for now, although I think we'd want to work things out better later. I don't know if there would be any impact to the BPMP driver related to the slower SRAM access due to this change. Best consult a BPMP expert or Tegra maintainer about that. >> [...] Also, I believe it's incorrect to hard-code into the kernel's DT >> the range of addresses used by the secure monitor/OS, since this can >> vary depending on what the user actually chooses to install as the >> secure monitor/OS. Any indication of such regions should be filled in at >> runtime by some boot firmware or the secure monitor/OS itself, or >> retrieved using some runtime API rather than DT. > Secure-OS addresses are not of interest here. SysRAM is partitioned > between secure-OS and BPMP and kernel is only interested in the BPMP > part. The firmware can update these addresses in the device-tree if it > wants to. Would you prefer something similar implemented in u-boot so > that it updates SysRAM node to only expose kernel accessible part of it > to the kernel? > > Can u-boot dynamically figure out the Secure-OS vs BPMP partition? > > BR, > Yousaf >