From: Paul Burton <paul.burton@imgtec.com>
To: <linux-mips@linux-mips.org>, Ralf Baechle <ralf@linux-mips.org>
Cc: James Hogan <james.hogan@imgtec.com>,
Paul Burton <paul.burton@imgtec.com>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
David Hildenbrand <dahi@linux.vnet.ibm.com>,
<linux-kernel@vger.kernel.org>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: [PATCH v2 12/13] MIPS: mm: Don't do MTHC0 if XPA not present
Date: Mon, 18 Apr 2016 10:35:32 +0100 [thread overview]
Message-ID: <1460972133-16973-13-git-send-email-paul.burton@imgtec.com> (raw)
In-Reply-To: <1460972133-16973-1-git-send-email-paul.burton@imgtec.com>
From: James Hogan <james.hogan@imgtec.com>
Performing an MTHC0 instruction without XPA being present will trigger a
reserved instruction exception, therefore conditionalise the use of this
instruction when building TLB handlers (build_update_entries()), and in
__update_tlb().
This allows an XPA kernel to run on non XPA hardware without that
instruction implemented, just like it can run on XPA capable hardware
without XPA in use (with the noxpa kernel argument) or with XPA not
configured in hardware.
[paul.burton@imgtec.com:
- Rebase atop other TLB work.
- Add "mm" to subject.
- Handle the __kmap_pgprot case.]
Fixes: c5b367835cfc ("MIPS: Add support for XPA.")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
---
Changes in v2: None
arch/mips/mm/init.c | 12 +++++++-----
arch/mips/mm/tlb-r4k.c | 6 ++++--
arch/mips/mm/tlbex.c | 16 ++++++++++------
3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 0e57893..1588409 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -111,11 +111,13 @@ static void *__kmap_pgprot(struct page *page, unsigned long addr, pgprot_t prot)
write_c0_entryhi(vaddr & (PAGE_MASK << 1));
write_c0_entrylo0(entrylo);
write_c0_entrylo1(entrylo);
-#ifdef CONFIG_XPA
- entrylo = (pte.pte_low & _PFNX_MASK);
- writex_c0_entrylo0(entrylo);
- writex_c0_entrylo1(entrylo);
-#endif
+
+ if (config_enabled(CONFIG_XPA) && cpu_has_xpa) {
+ entrylo = (pte.pte_low & _PFNX_MASK);
+ writex_c0_entrylo0(entrylo);
+ writex_c0_entrylo1(entrylo);
+ }
+
tlbidx = read_c0_wired();
write_c0_wired(tlbidx + 1);
write_c0_index(tlbidx);
diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
index c17d762..b99695c 100644
--- a/arch/mips/mm/tlb-r4k.c
+++ b/arch/mips/mm/tlb-r4k.c
@@ -336,10 +336,12 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)
#if defined(CONFIG_PHYS_ADDR_T_64BIT) && defined(CONFIG_CPU_MIPS32)
#ifdef CONFIG_XPA
write_c0_entrylo0(pte_to_entrylo(ptep->pte_high));
- writex_c0_entrylo0(ptep->pte_low & _PFNX_MASK);
+ if (cpu_has_xpa)
+ writex_c0_entrylo0(ptep->pte_low & _PFNX_MASK);
ptep++;
write_c0_entrylo1(pte_to_entrylo(ptep->pte_high));
- writex_c0_entrylo1(ptep->pte_low & _PFNX_MASK);
+ if (cpu_has_xpa)
+ writex_c0_entrylo1(ptep->pte_low & _PFNX_MASK);
#else
write_c0_entrylo0(ptep->pte_high);
ptep++;
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index c7c14bd..3f1a8a2 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -1022,17 +1022,21 @@ static void build_update_entries(u32 **p, unsigned int tmp, unsigned int ptep)
UASM_i_ROTR(p, tmp, tmp, ilog2(_PAGE_GLOBAL));
UASM_i_MTC0(p, tmp, C0_ENTRYLO0);
- uasm_i_lw(p, tmp, 0, ptep);
- uasm_i_ext(p, tmp, tmp, 0, 24);
- uasm_i_mthc0(p, tmp, C0_ENTRYLO0);
+ if (cpu_has_xpa && !mips_xpa_disabled) {
+ uasm_i_lw(p, tmp, 0, ptep);
+ uasm_i_ext(p, tmp, tmp, 0, 24);
+ uasm_i_mthc0(p, tmp, C0_ENTRYLO0);
+ }
uasm_i_lw(p, tmp, pte_off_odd, ptep); /* odd pte */
UASM_i_ROTR(p, tmp, tmp, ilog2(_PAGE_GLOBAL));
UASM_i_MTC0(p, tmp, C0_ENTRYLO1);
- uasm_i_lw(p, tmp, sizeof(pte_t), ptep);
- uasm_i_ext(p, tmp, tmp, 0, 24);
- uasm_i_mthc0(p, tmp, C0_ENTRYLO1);
+ if (cpu_has_xpa && !mips_xpa_disabled) {
+ uasm_i_lw(p, tmp, sizeof(pte_t), ptep);
+ uasm_i_ext(p, tmp, tmp, 0, 24);
+ uasm_i_mthc0(p, tmp, C0_ENTRYLO1);
+ }
return;
}
--
2.8.0
next prev parent reply other threads:[~2016-04-18 9:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1460972133-16973-1-git-send-email-paul.burton@imgtec.com>
2016-04-18 9:35 ` [PATCH v2 01/13] MIPS: Separate XPA CPU feature into LPA and MVH Paul Burton
2016-04-18 9:35 ` [PATCH v2 02/13] MIPS: Fix HTW config on XPA kernel without LPA enabled Paul Burton
2016-04-18 9:35 ` [PATCH v2 03/13] MIPS: Remove redundant asm/pgtable-bits.h inclusions Paul Burton
2016-04-18 12:36 ` Sergei Shtylyov
2016-04-18 9:35 ` [PATCH v2 04/13] MIPS: Use enums to make asm/pgtable-bits.h readable Paul Burton
2016-04-18 9:35 ` [PATCH v2 06/13] MIPS: mm: Unify pte_page definition Paul Burton
2016-04-18 9:35 ` [PATCH v2 08/13] MIPS: mm: Don't clobber $1 on XPA TLB refill Paul Burton
2016-04-18 9:35 ` [PATCH v2 09/13] MIPS: mm: Pass scratch register through to iPTE_SW Paul Burton
2016-04-18 9:35 ` [PATCH v2 10/13] MIPS: mm: Be more explicit about PTE mode bit handling Paul Burton
2016-04-18 9:35 ` [PATCH v2 11/13] MIPS: mm: Simplify build_update_entries Paul Burton
2016-04-18 9:35 ` Paul Burton [this message]
2016-04-18 9:35 ` [PATCH v2 13/13] MIPS: mm: Panic if an XPA kernel is run without RIXI Paul Burton
2016-04-18 10:04 ` James Hogan
[not found] ` <1460972133-16973-8-git-send-email-paul.burton@imgtec.com>
2016-04-18 14:34 ` [PATCH v2 07/13] MIPS: mm: Fix MIPS32 36b physical addressing (alchemy, netlogic) Manuel Lauss
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1460972133-16973-13-git-send-email-paul.burton@imgtec.com \
--to=paul.burton@imgtec.com \
--cc=akpm@linux-foundation.org \
--cc=dahi@linux.vnet.ibm.com \
--cc=james.hogan@imgtec.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=mingo@kernel.org \
--cc=paul.gortmaker@windriver.com \
--cc=peterz@infradead.org \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®