Re: [PATCH] commands: mem: truncate mem device size to fit the loff_t file size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Lucas,

On Tue, Nov 06, 2018 at 05:14:07PM +0100, Lucas Stach wrote:
> On 64bit arches the file covering the whole address space is larger than
> what can be represented in the loff_t type (s64) used for the file size.
> Thus the size of this device is interpreted as negative in a lot of
> places. Fix this by truncating the size to fit the file size type.

While this is probably an appropriate solution for some architectures, it will 
cause problems on MIPS64. The root of evil is MIPS64 address space 
segmentation: https://docplayer.net/docs-images/25/4553906/images/21-0.png).  
Most notably your patch prevents access to the xkphys segment, where most 
peripheral devices of a SoC are accessible.

Regards,
Peter

> 
> Signed-off-by: Lucas Stach <l.stach@xxxxxxxxxxxxxx>
> ---
>  commands/mem.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/commands/mem.c b/commands/mem.c
> index eb91ade05a88..cdd7a492d0d5 100644
> --- a/commands/mem.c
> +++ b/commands/mem.c
> @@ -96,7 +96,8 @@ static int mem_probe(struct device_d *dev)
>  	dev->priv = cdev;
>  
>  	cdev->name = (char*)dev->resource[0].name;
> -	cdev->size = (unsigned long)resource_size(&dev->resource[0]);
> +	cdev->size = min(resource_size(&dev->resource[0]),
> +			 (unsigned long long)S64_MAX);
>  	cdev->ops = &memops;
>  	cdev->dev = dev;
>  
> -- 
> 2.19.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@xxxxxxxxxxxxxxxxxxx
> http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux