2020-07-12 10:06:10

by Jon Hunter

[permalink] [raw]
Subject: [PATCH 0/5] firmware: tegra: Add support for in-band debug

This series adds support for in-band debug messaging for the BPMP and
updates the BPMP ABI to align with the latest version.

Jon Hunter (4):
firmware: tegra: Use consistent return variable name
firmware: tegra: Prepare for supporting in-band debugfs
firmware: tegra: Add support for in-band debug
firmware: tegra: Update BPMP ABI

Timo Alho (1):
firmware: tegra: add return code checks and increase debugfs size

drivers/firmware/tegra/bpmp-debugfs.c | 436 ++++++++++--
drivers/firmware/tegra/bpmp.c | 6 +-
include/soc/tegra/bpmp-abi.h | 913 ++++++++++++++++++--------
3 files changed, 1038 insertions(+), 317 deletions(-)

--
2.17.1


2020-07-12 10:06:10

by Jon Hunter

[permalink] [raw]
Subject: [PATCH 1/5] firmware: tegra: add return code checks and increase debugfs size

From: Timo Alho <[email protected]>

Add checking of the BPMP-FW return code values for MRQ_DEBUGFS calls.

Also, development versions of the firmware may have debugfs with
directory structure larger than 256Kb. Hence increase the size of the
memory buffer to accommodate those firmware revisions.

And finally, ensure that no access outside of allocated memory buffer
happens in case BPMP-FW returns an invalid response size (nbytes) from
mrq_debugfs_dumpdir() call.

Signed-off-by: Timo Alho <[email protected]>
Signed-off-by: Jon Hunter <[email protected]>
---
drivers/firmware/tegra/bpmp-debugfs.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/tegra/bpmp-debugfs.c b/drivers/firmware/tegra/bpmp-debugfs.c
index 3f0a89ce131a..08e0f05f46c6 100644
--- a/drivers/firmware/tegra/bpmp-debugfs.c
+++ b/drivers/firmware/tegra/bpmp-debugfs.c
@@ -127,6 +127,8 @@ static int mrq_debugfs_read(struct tegra_bpmp *bpmp,
err = tegra_bpmp_transfer(bpmp, &msg);
if (err < 0)
return err;
+ else if (msg.rx.ret < 0)
+ return -EINVAL;

*nbytes = (size_t)resp.fop.nbytes;

@@ -184,6 +186,8 @@ static int mrq_debugfs_dumpdir(struct tegra_bpmp *bpmp, dma_addr_t addr,
err = tegra_bpmp_transfer(bpmp, &msg);
if (err < 0)
return err;
+ else if (msg.rx.ret < 0)
+ return -EINVAL;

*nbytes = (size_t)resp.dumpdir.nbytes;

@@ -374,7 +378,7 @@ int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp)
{
dma_addr_t phys;
void *virt;
- const size_t sz = SZ_256K;
+ const size_t sz = SZ_512K;
size_t nbytes;
int ret;
struct dentry *root;
@@ -394,8 +398,12 @@ int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp)
}

ret = mrq_debugfs_dumpdir(bpmp, phys, sz, &nbytes);
- if (ret < 0)
+ if (ret < 0) {
+ goto free;
+ } else if (nbytes > sz) {
+ ret = -EINVAL;
goto free;
+ }

ret = create_debugfs_mirror(bpmp, virt, nbytes, root);
free:
--
2.17.1

2020-07-14 16:20:36

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH 0/5] firmware: tegra: Add support for in-band debug

On Sun, Jul 12, 2020 at 11:01:13AM +0100, Jon Hunter wrote:
> This series adds support for in-band debug messaging for the BPMP and
> updates the BPMP ABI to align with the latest version.
>
> Jon Hunter (4):
> firmware: tegra: Use consistent return variable name
> firmware: tegra: Prepare for supporting in-band debugfs
> firmware: tegra: Add support for in-band debug
> firmware: tegra: Update BPMP ABI
>
> Timo Alho (1):
> firmware: tegra: add return code checks and increase debugfs size
>
> drivers/firmware/tegra/bpmp-debugfs.c | 436 ++++++++++--
> drivers/firmware/tegra/bpmp.c | 6 +-
> include/soc/tegra/bpmp-abi.h | 913 ++++++++++++++++++--------
> 3 files changed, 1038 insertions(+), 317 deletions(-)

All applied, thanks. I had to tweak a couple of things to make
checkpatch happy, though. checkpatch also wasn't happy with the ABI
header update, but I left it as-is to make it easier to update in the
future.

Thierry


Attachments:
(No filename) (992.00 B)
signature.asc (849.00 B)
Download all attachments

2020-07-14 18:12:58

by Jon Hunter

[permalink] [raw]
Subject: Re: [PATCH 0/5] firmware: tegra: Add support for in-band debug


On 14/07/2020 17:18, Thierry Reding wrote:
> On Sun, Jul 12, 2020 at 11:01:13AM +0100, Jon Hunter wrote:
>> This series adds support for in-band debug messaging for the BPMP and
>> updates the BPMP ABI to align with the latest version.
>>
>> Jon Hunter (4):
>> firmware: tegra: Use consistent return variable name
>> firmware: tegra: Prepare for supporting in-band debugfs
>> firmware: tegra: Add support for in-band debug
>> firmware: tegra: Update BPMP ABI
>>
>> Timo Alho (1):
>> firmware: tegra: add return code checks and increase debugfs size
>>
>> drivers/firmware/tegra/bpmp-debugfs.c | 436 ++++++++++--
>> drivers/firmware/tegra/bpmp.c | 6 +-
>> include/soc/tegra/bpmp-abi.h | 913 ++++++++++++++++++--------
>> 3 files changed, 1038 insertions(+), 317 deletions(-)
>
> All applied, thanks. I had to tweak a couple of things to make
> checkpatch happy, though. checkpatch also wasn't happy with the ABI
> header update, but I left it as-is to make it easier to update in the
> future.

Thanks. Yes I noticed that as well with the ABI update. I wonder if we
should get them to fix that.

Jon

--
nvpublic