All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH] powerpc/powernv: Fix vma page prot flags in opal-prd driver
@ 2015-06-29  5:17 Vaidyanathan Srinivasan
  2015-06-29  5:20 ` Jeremy Kerr
  2015-07-07 10:38 ` [RESEND] " Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Vaidyanathan Srinivasan @ 2015-06-29  5:17 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Jeremy Kerr

opal-prd driver will mmap() firmware code/data area as private
mapping to prd user space daemon.  Write to this page will
trigger COW faults.  The new COW pages are normal kernel RAM
pages accounted by the kernel and are not special.

vma->vm_page_prot value will be used at page fault time
for the new COW pages, while pgprot_t value passed in
remap_pfn_range() is used for the initial page table entry.

Hence:
* Do not add _PAGE_SPECIAL in vma, but only for remap_pfn_range()
* Also remap_pfn_range() will add the _PAGE_SPECIAL flag using
  pte_mkspecial() call, hence no need to specify in the driver

This fix resolves the page accounting warning shown below:
BUG: Bad rss-counter state mm:c0000007d34ac600 idx:1 val:19

The above warning is triggered since _PAGE_SPECIAL was incorrectly
being set for the normal kernel COW pages.

Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/opal-prd.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Resending the patch for inclusion until we have a working solution
without PAGE_SPECIAL.

Kindly queue this patch to fix the mmap issue in opal-prd driver.
The next version/fix with vm_insert_page() will replace this code.
There is no API change on the driver side and hence no side effects of
including this fix until a better solution is available.

diff --git a/arch/powerpc/platforms/powernv/opal-prd.c b/arch/powerpc/platforms/powernv/opal-prd.c
index 46cb3fe..4ece8e4 100644
--- a/arch/powerpc/platforms/powernv/opal-prd.c
+++ b/arch/powerpc/platforms/powernv/opal-prd.c
@@ -112,6 +112,7 @@ static int opal_prd_open(struct inode *inode, struct file *file)
 static int opal_prd_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	size_t addr, size;
+	pgprot_t page_prot;
 	int rc;
 
 	pr_devel("opal_prd_mmap(0x%016lx, 0x%016lx, 0x%lx, 0x%lx)\n",
@@ -125,13 +126,11 @@ static int opal_prd_mmap(struct file *file, struct vm_area_struct *vma)
 	if (!opal_prd_range_is_valid(addr, size))
 		return -EINVAL;
 
-	vma->vm_page_prot = __pgprot(pgprot_val(phys_mem_access_prot(file,
-						vma->vm_pgoff,
-						 size, vma->vm_page_prot))
-					| _PAGE_SPECIAL);
+	page_prot = phys_mem_access_prot(file, vma->vm_pgoff,
+					 size, vma->vm_page_prot);
 
 	rc = remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, size,
-			vma->vm_page_prot);
+				page_prot);
 
 	return rc;
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RESEND PATCH] powerpc/powernv: Fix vma page prot flags in opal-prd driver
  2015-06-29  5:17 [RESEND PATCH] powerpc/powernv: Fix vma page prot flags in opal-prd driver Vaidyanathan Srinivasan
@ 2015-06-29  5:20 ` Jeremy Kerr
  2015-07-07 10:38 ` [RESEND] " Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Jeremy Kerr @ 2015-06-29  5:20 UTC (permalink / raw)
  To: Vaidyanathan Srinivasan, linuxppc-dev

Hi Vaidy,

> opal-prd driver will mmap() firmware code/data area as private
> mapping to prd user space daemon.  Write to this page will
> trigger COW faults.  The new COW pages are normal kernel RAM
> pages accounted by the kernel and are not special.
> 
> vma->vm_page_prot value will be used at page fault time
> for the new COW pages, while pgprot_t value passed in
> remap_pfn_range() is used for the initial page table entry.
> 
> Hence:
> * Do not add _PAGE_SPECIAL in vma, but only for remap_pfn_range()
> * Also remap_pfn_range() will add the _PAGE_SPECIAL flag using
>   pte_mkspecial() call, hence no need to specify in the driver
> 
> This fix resolves the page accounting warning shown below:
> BUG: Bad rss-counter state mm:c0000007d34ac600 idx:1 val:19
> 
> The above warning is triggered since _PAGE_SPECIAL was incorrectly
> being set for the normal kernel COW pages.
> 
> Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>

Acked-by: Jeremy Kerr <jk@ozlabs.org>

Cheers,


Jeremy

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RESEND] powerpc/powernv: Fix vma page prot flags in opal-prd driver
  2015-06-29  5:17 [RESEND PATCH] powerpc/powernv: Fix vma page prot flags in opal-prd driver Vaidyanathan Srinivasan
  2015-06-29  5:20 ` Jeremy Kerr
@ 2015-07-07 10:38 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2015-07-07 10:38 UTC (permalink / raw)
  To: Vaidyanathan Srinivasan, linuxppc-dev; +Cc: Jeremy Kerr

On Mon, 2015-29-06 at 05:17:55 UTC, Vaidyanathan Srinivasan wrote:
> opal-prd driver will mmap() firmware code/data area as private
> mapping to prd user space daemon.  Write to this page will
> trigger COW faults.  The new COW pages are normal kernel RAM
> pages accounted by the kernel and are not special.
> 
> vma->vm_page_prot value will be used at page fault time
> for the new COW pages, while pgprot_t value passed in
> remap_pfn_range() is used for the initial page table entry.
> 
> Hence:
> * Do not add _PAGE_SPECIAL in vma, but only for remap_pfn_range()
> * Also remap_pfn_range() will add the _PAGE_SPECIAL flag using
>   pte_mkspecial() call, hence no need to specify in the driver
> 
> This fix resolves the page accounting warning shown below:
> BUG: Bad rss-counter state mm:c0000007d34ac600 idx:1 val:19
> 
> The above warning is triggered since _PAGE_SPECIAL was incorrectly
> being set for the normal kernel COW pages.
> 
> Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
> Acked-by: Jeremy Kerr <jk@ozlabs.org>

Applied to powerpc fixes, thanks.

https://git.kernel.org/cgit/linux/kernel/git/powerpc/linux.git/commit/?h=fixes&id=d8ea782b56d9d2c46a47b3231cfd16ecfb538c60

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-07 10:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-29  5:17 [RESEND PATCH] powerpc/powernv: Fix vma page prot flags in opal-prd driver Vaidyanathan Srinivasan
2015-06-29  5:20 ` Jeremy Kerr
2015-07-07 10:38 ` [RESEND] " Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.