mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	misc: fastrpc: fix remote page size calculation
Remote page size should be calculated based on address and size, fix this!
Without this we will endup with one page less in cases where the buffer
is across 3 pages.
Fixes: c68cfb718c ("misc: fastrpc: Add support for context Invoke method")
Reported-by: Krishnaiah Tadakamalla <ktadakam@qti.qualcomm.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
			
			
This commit is contained in:
		
							parent
							
								
									25e8dfb83c
								
							
						
					
					
						commit
						02b45b47fb
					
				
					 1 changed files with 9 additions and 2 deletions
				
			
		| 
						 | 
					@ -712,6 +712,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 | 
				
			||||||
	struct fastrpc_phy_page *pages;
 | 
						struct fastrpc_phy_page *pages;
 | 
				
			||||||
	int inbufs, i, oix, err = 0;
 | 
						int inbufs, i, oix, err = 0;
 | 
				
			||||||
	u64 len, rlen, pkt_size;
 | 
						u64 len, rlen, pkt_size;
 | 
				
			||||||
 | 
						u64 pg_start, pg_end;
 | 
				
			||||||
	uintptr_t args;
 | 
						uintptr_t args;
 | 
				
			||||||
	int metalen;
 | 
						int metalen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -751,8 +752,6 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 | 
				
			||||||
		if (!len)
 | 
							if (!len)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		pages[i].size = roundup(len, PAGE_SIZE);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (ctx->maps[i]) {
 | 
							if (ctx->maps[i]) {
 | 
				
			||||||
			struct vm_area_struct *vma = NULL;
 | 
								struct vm_area_struct *vma = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -764,6 +763,11 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 | 
				
			||||||
				pages[i].addr += ctx->args[i].ptr -
 | 
									pages[i].addr += ctx->args[i].ptr -
 | 
				
			||||||
						 vma->vm_start;
 | 
											 vma->vm_start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								pg_start = (ctx->args[i].ptr & PAGE_MASK) >> PAGE_SHIFT;
 | 
				
			||||||
 | 
								pg_end = ((ctx->args[i].ptr + len - 1) & PAGE_MASK) >>
 | 
				
			||||||
 | 
									  PAGE_SHIFT;
 | 
				
			||||||
 | 
								pages[i].size = (pg_end - pg_start + 1) * PAGE_SIZE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (ctx->olaps[oix].offset == 0) {
 | 
								if (ctx->olaps[oix].offset == 0) {
 | 
				
			||||||
| 
						 | 
					@ -782,6 +786,9 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
 | 
				
			||||||
					(pkt_size - rlen);
 | 
										(pkt_size - rlen);
 | 
				
			||||||
			pages[i].addr = pages[i].addr &	PAGE_MASK;
 | 
								pages[i].addr = pages[i].addr &	PAGE_MASK;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								pg_start = (args & PAGE_MASK) >> PAGE_SHIFT;
 | 
				
			||||||
 | 
								pg_end = ((args + len - 1) & PAGE_MASK) >> PAGE_SHIFT;
 | 
				
			||||||
 | 
								pages[i].size = (pg_end - pg_start + 1) * PAGE_SIZE;
 | 
				
			||||||
			args = args + mlen;
 | 
								args = args + mlen;
 | 
				
			||||||
			rlen -= mlen;
 | 
								rlen -= mlen;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue