diff options
author | James Hogan <james.hogan@imgtec.com> | 2016-09-07 08:37:01 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2016-09-21 09:56:10 -0400 |
commit | 554af0c396380baf416f54c439b99b495180b2f4 (patch) | |
tree | 2f0a0838e7c4fd684846c531d3322fb7355eeb0e | |
parent | 08bccf43627e1972035c1fed5b4f570bdbde1b1e (diff) |
MIPS: vDSO: Fix Malta EVA mapping to vDSO page structs
The page structures associated with the vDSO pages in the kernel image
are calculated using virt_to_page(), which uses __pa() under the hood to
find the pfn associated with the virtual address. The vDSO data pointers
however point to kernel symbols, so __pa_symbol() should really be used
instead.
Since there is no equivalent to virt_to_page() which uses __pa_symbol(),
fix init_vdso_image() to work directly with pfns, calculated with
__phys_to_pfn(__pa_symbol(...)).
This issue broke the Malta Enhanced Virtual Addressing (EVA)
configuration which has a non-default implementation of __pa_symbol().
This is because it uses a physical alias so that the kernel executes
from KSeg0 (VA 0x80000000 -> PA 0x00000000), while RAM is provided to
the kernel in the KUSeg range (VA 0x00000000 -> PA 0x80000000) which
uses the same underlying RAM.
Since there are no page structures associated with the low physical
address region, some arbitrary kernel memory would be interpreted as a
page structure for the vDSO pages and badness ensues.
Fixes: ebb5e78cc634 ("MIPS: Initial implementation of a VDSO")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Leonid Yegoshin <leonid.yegoshin@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: <stable@vger.kernel.org> # 4.4.x-
Patchwork: https://patchwork.linux-mips.org/patch/14229/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/kernel/vdso.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c index 9abe447a4b48..f9dbfb14af33 100644 --- a/arch/mips/kernel/vdso.c +++ b/arch/mips/kernel/vdso.c | |||
@@ -39,16 +39,16 @@ static struct vm_special_mapping vdso_vvar_mapping = { | |||
39 | static void __init init_vdso_image(struct mips_vdso_image *image) | 39 | static void __init init_vdso_image(struct mips_vdso_image *image) |
40 | { | 40 | { |
41 | unsigned long num_pages, i; | 41 | unsigned long num_pages, i; |
42 | unsigned long data_pfn; | ||
42 | 43 | ||
43 | BUG_ON(!PAGE_ALIGNED(image->data)); | 44 | BUG_ON(!PAGE_ALIGNED(image->data)); |
44 | BUG_ON(!PAGE_ALIGNED(image->size)); | 45 | BUG_ON(!PAGE_ALIGNED(image->size)); |
45 | 46 | ||
46 | num_pages = image->size / PAGE_SIZE; | 47 | num_pages = image->size / PAGE_SIZE; |
47 | 48 | ||
48 | for (i = 0; i < num_pages; i++) { | 49 | data_pfn = __phys_to_pfn(__pa_symbol(image->data)); |
49 | image->mapping.pages[i] = | 50 | for (i = 0; i < num_pages; i++) |
50 | virt_to_page(image->data + (i * PAGE_SIZE)); | 51 | image->mapping.pages[i] = pfn_to_page(data_pfn + i); |
51 | } | ||
52 | } | 52 | } |
53 | 53 | ||
54 | static int __init init_vdso(void) | 54 | static int __init init_vdso(void) |