[Pdbg] [PATCH] libpdbg/kernel: Fix FSI address masking

Amitay Isaacs amitay at ozlabs.org
Tue Aug 11 18:04:36 AEST 2020


On Wed, 2020-07-08 at 16:08 -0500, Reza Arbab wrote:
> With this backend, the FSI master port we're using is implicit, e.g.
> /sys/class/fsi-master/fsi0/slave at 01:00/raw is port 1, and target
> addresses
> should be relative to that. Mask the port from the address
> accordingly.
> 
> Signed-off-by: Reza Arbab <arbab at linux.ibm.com>
> ---
>  libpdbg/kernel.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libpdbg/kernel.c b/libpdbg/kernel.c
> index b2b977bc6c96..18d54a35d4a9 100644
> --- a/libpdbg/kernel.c
> +++ b/libpdbg/kernel.c
> @@ -63,7 +63,7 @@ const char *kernel_get_fsi_path(void)
>  static int kernel_fsi_getcfam(struct fsi *fsi, uint32_t addr64,
> uint32_t *value)
>  {
>  	int rc;
> -	uint32_t tmp, addr = (addr64 & 0x7ffc00) | ((addr64 & 0x3ff) <<
> 2);
> +	uint32_t tmp, addr = (addr64 & 0x7fc00) | ((addr64 & 0x3ff) <<
> 2);

This looks definitely wrong.

addr64 = 0xc09
addr = (0xc09 & 0x7fc00) | ((0xc09 & 0x3ff) << 2)
     = 0xc00 | 0x24
     = 0xc24

addr64 = 0x100c09
addr = (0x100c09 & 0x7fc00) | ((0x100c09 & 0x3ff) << 2)
     = 0xc00 | 0x24
     = 0xc24  (should be 0x100c24)

I am assuming this is same for both P9 and P10.  Or is it supposed to
work for P10 only with modified mask?

>  
>  	rc = lseek(fsi->fd, addr, SEEK_SET);
>  	if (rc < 0) {
> @@ -90,7 +90,7 @@ static int kernel_fsi_getcfam(struct fsi *fsi,
> uint32_t addr64, uint32_t *value)
>  static int kernel_fsi_putcfam(struct fsi *fsi, uint32_t addr64,
> uint32_t data)
>  {
>  	int rc;
> -	uint32_t tmp, addr = (addr64 & 0x7ffc00) | ((addr64 & 0x3ff) <<
> 2);
> +	uint32_t tmp, addr = (addr64 & 0x7fc00) | ((addr64 & 0x3ff) <<
> 2);
>  
>  	rc = lseek(fsi->fd, addr, SEEK_SET);
>  	if (rc < 0) {
> -- 
> 2.17.1
> 

Amitay.
-- 

It's not how far you fall, but how high you bounce.



More information about the Pdbg mailing list