From: vladimir.murzin@arm.com (Vladimir Murzin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 1/3] arm64: mm: Support Common Not Private translations
Date: Mon, 30 Jul 2018 11:08:27 +0100 [thread overview]
Message-ID: <f3da236e-504d-66ab-19da-9f89eba253f1@arm.com> (raw)
In-Reply-To: <20180727113502.3qdbyffuvysva6bz@armageddon.cambridge.arm.com>
On 27/07/18 12:35, Catalin Marinas wrote:
> Hi Vladimir,
>
> On Tue, Jun 19, 2018 at 11:18:20AM +0100, Vladimir Murzin wrote:
>> diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h
>> index 39ec0b8..c506fb7 100644
>> --- a/arch/arm64/include/asm/mmu_context.h
>> +++ b/arch/arm64/include/asm/mmu_context.h
>> @@ -149,6 +149,18 @@ static inline void cpu_replace_ttbr1(pgd_t *pgdp)
>>
>> phys_addr_t pgd_phys = virt_to_phys(pgdp);
>>
>> + if (system_supports_cnp() && !WARN_ON(pgdp != lm_alias(swapper_pg_dir))) {
>> + /*
>> + * cpu_replace_ttbr1() is used when there's a boot CPU
>> + * up (i.e. cpufeature framework is not up yet) and
>> + * latter only when we enable CNP via cpufeature's
>> + * enable() callback.
>> + * Also we rely on the cpu_hwcap bit being set before
>> + * calling the enable() function.
>> + */
>> + pgd_phys |= TTBR_CNP_BIT;
>> + }
>> +
>> replace_phys = (void *)__pa_symbol(idmap_cpu_replace_ttbr1);
>
> So the above code sets the TTBR_CNP_BIT (bit 0) in pgd_phys and calls
> the idmap_cpu_replace_ttbr1() with this value. Looking at the latter, it
> performs a phys_to_ttbr transformation of pgd_phys which masks out the
> bottom 2 bits when CONFIG_ARM64_PA_BITS_52 is enabled. I think we need
> to tweak TTBR_BADDR_MASK_52 to start from bit 0.
>
> (cc'ing Kristina as she added this code, in case there is any issue with
> extending the mask)
>
Something like bellow?
diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
index 0bcc98d..e0b4b2f 100644
--- a/arch/arm64/include/asm/assembler.h
+++ b/arch/arm64/include/asm/assembler.h
@@ -524,11 +524,10 @@ USER(\label, ic ivau, \tmp2) // invalidate I line PoU
* ttbr: returns the TTBR value
*/
.macro phys_to_ttbr, ttbr, phys
-#ifdef CONFIG_ARM64_PA_BITS_52
- orr \ttbr, \phys, \phys, lsr #46
- and \ttbr, \ttbr, #TTBR_BADDR_MASK_52
-#else
mov \ttbr, \phys
+#ifdef CONFIG_ARM64_PA_BITS_52
+ ubfx \ttbr, \ttbr, #48, #4
+ orr \ttbr, \phys, \ttbr, lsl #2
#endif
.endm
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 1bdeca8..1b9d0e9 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -770,7 +770,7 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,
#define kc_offset_to_vaddr(o) ((o) | VA_START)
#ifdef CONFIG_ARM64_PA_BITS_52
-#define phys_to_ttbr(addr) (((addr) | ((addr) >> 46)) & TTBR_BADDR_MASK_52)
+#define phys_to_ttbr(addr) ((addr) | (((addr) >> 46) & TTBR_BADDR_MASK_52))
#else
#define phys_to_ttbr(addr) (addr)
#endif
Vladimir
next prev parent reply other threads:[~2018-07-30 10:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-19 10:18 [PATCH v5 0/3] Support Common Not Private translations Vladimir Murzin
2018-06-19 10:18 ` [PATCH v5 1/3] arm64: mm: " Vladimir Murzin
2018-07-27 11:35 ` Catalin Marinas
2018-07-30 10:08 ` Vladimir Murzin [this message]
2018-07-30 15:42 ` Catalin Marinas
2018-07-30 16:29 ` Robin Murphy
2018-07-30 17:03 ` Catalin Marinas
2018-07-31 10:17 ` Vladimir Murzin
2018-07-31 11:29 ` Catalin Marinas
2018-07-30 16:24 ` Suzuki K Poulose
2018-07-31 10:18 ` Vladimir Murzin
2018-06-19 10:18 ` [PATCH v5 2/3] arm64: KVM: Enable " Vladimir Murzin
2018-07-27 11:41 ` Catalin Marinas
2018-07-27 12:02 ` Marc Zyngier
2018-06-19 10:18 ` [PATCH v5 3/3] arm64: Introduce command line parameter to disable CNP Vladimir Murzin
2018-07-27 11:43 ` Catalin Marinas
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=f3da236e-504d-66ab-19da-9f89eba253f1@arm.com \
--to=vladimir.murzin@arm.com \
--cc=linux-arm-kernel@lists.infradead.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