Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: c68cfb718c8f ("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>

authored by

Srinivas Kandagatla and committed by
Greg Kroah-Hartman
02b45b47 25e8dfb8

+9 -2
+9 -2
drivers/misc/fastrpc.c
··· 712 712 struct fastrpc_phy_page *pages; 713 713 int inbufs, i, oix, err = 0; 714 714 u64 len, rlen, pkt_size; 715 + u64 pg_start, pg_end; 715 716 uintptr_t args; 716 717 int metalen; 717 718 ··· 752 751 if (!len) 753 752 continue; 754 753 755 - pages[i].size = roundup(len, PAGE_SIZE); 756 - 757 754 if (ctx->maps[i]) { 758 755 struct vm_area_struct *vma = NULL; 759 756 ··· 762 763 if (vma) 763 764 pages[i].addr += ctx->args[i].ptr - 764 765 vma->vm_start; 766 + 767 + pg_start = (ctx->args[i].ptr & PAGE_MASK) >> PAGE_SHIFT; 768 + pg_end = ((ctx->args[i].ptr + len - 1) & PAGE_MASK) >> 769 + PAGE_SHIFT; 770 + pages[i].size = (pg_end - pg_start + 1) * PAGE_SIZE; 765 771 766 772 } else { 767 773 ··· 786 782 (pkt_size - rlen); 787 783 pages[i].addr = pages[i].addr & PAGE_MASK; 788 784 785 + pg_start = (args & PAGE_MASK) >> PAGE_SHIFT; 786 + pg_end = ((args + len - 1) & PAGE_MASK) >> PAGE_SHIFT; 787 + pages[i].size = (pg_end - pg_start + 1) * PAGE_SIZE; 789 788 args = args + mlen; 790 789 rlen -= mlen; 791 790 }