From c0f015aff6447a4ce90af6b9e27750e7c8516373 Mon Sep 17 00:00:00 2001
From: Yurii Zubrytskyi <zyy@google.com>
Date: Wed, 24 Aug 2016 14:58:07 -0700
Subject: [PATCH] [pipe] Fix the pipe driver for x64 platform + correct pages
 count

- first_page and last_page are page start addresses, so the type
  has to be long for x64

- as those variables are addresses, their difference doesn't
  give the number of pages.

Signed-off-by: Yurii Zubrytskyi <zyy@google.com>
Change-Id: Ia00420c3261dea0ca4bba1f72125a1641c503000
---
 drivers/platform/goldfish/goldfish_pipe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index d0ec615ef95a..e945f190b424 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -308,7 +308,7 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer,
 		unsigned long page_end = (address & PAGE_MASK) + PAGE_SIZE;
 		unsigned long next, avail;
 		int status, wakeBit, page_i, num_contiguous_pages;
-		int first_page, last_page, requested_pages;
+		long first_page, last_page, requested_pages;
 		unsigned long xaddr, xaddr_prev, xaddr_i;
 
 		/*
@@ -316,7 +316,7 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer,
 		 */
 		first_page = address & PAGE_MASK;
 		last_page = (address_end - 1) & PAGE_MASK;
-		requested_pages = (last_page - first_page + 1);
+		requested_pages = ((last_page - first_page) >> PAGE_SHIFT) + 1;
 		if (requested_pages > MAX_PAGES_TO_GRAB) {
 			requested_pages = MAX_PAGES_TO_GRAB;
 		}
-- 
GitLab