public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: York Sun <yorksun@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 1/7] armv8: New MMU setup code allowing to use 48+ bits PA/VA
Date: Thu, 13 Aug 2015 08:28:38 -0700	[thread overview]
Message-ID: <55CCB7A6.5030202@freescale.com> (raw)
In-Reply-To: <1439478903-32257-2-git-send-email-s.temerkhanov@gmail.com>



On 08/13/2015 08:14 AM, Sergey Temerkhanov wrote:
> This patch adds code which sets up 2-level page tables on ARM64 thus
> extending available VA space. CPUs implementing 64k translation
> granule are able to use direct PA-VA mapping of the whole 48 bit
> address space.
> It also adds the ability to reset the SCTRL register at the very beginning
> of execution to avoid interference from stale mappings set up by early
> firmware/loaders/etc.
> 
> Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com>
> Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>
> 
> ---
> 
> Changes in v3:
> - Reduced code duplication
> - Renamed CONFIG_SYS_PTL1_BITS to CONFIG_SYS_PTL2_BITS
> - Moved 'reset_sctrl' call to the 'reset' label
> - Rebased to the actual upstream tree
> - Documented newly added config options
> 
> Changes in v2:
> - Changed code licensing
> - Completed the patchset
> 
>  arch/arm/cpu/armv8/cache_v8.c      | 80 +++++++++++++++++++++++++++++++++++++-
>  arch/arm/cpu/armv8/start.S         | 36 +++++++++++++++++
>  arch/arm/include/asm/armv8/mmu.h   | 79 ++++++++++++++++++++++++++++++++++---
>  arch/arm/include/asm/global_data.h |  1 +
>  arch/arm/include/asm/system.h      |  7 ++++
>  arch/arm/lib/board.c               |  6 ++-
>  doc/README.arm64                   | 35 ++++++++++++++---
>  7 files changed, 229 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
> index c22f7b6..00778f2 100644
> --- a/arch/arm/cpu/armv8/cache_v8.c
> +++ b/arch/arm/cpu/armv8/cache_v8.c
> @@ -12,6 +12,69 @@
>  DECLARE_GLOBAL_DATA_PTR;
>  
>  #ifndef CONFIG_SYS_DCACHE_OFF
> +
> +#ifdef CONFIG_SYS_FULL_VA
> +static void set_ptl1_entry(u64 index, u64 ptl2_entry)
> +{
> +	u64 *pgd = (u64 *)gd->arch.tlb_addr;
> +	u64 value;
> +
> +	value = ptl2_entry | PTL1_TYPE_TABLE;
> +	pgd[index] = value;
> +}
> +
> +static void set_ptl2_block(u64 ptl1, u64 bfn, u64 address, u64 memory_type)
> +{
> +	u64 *pmd = (u64 *)ptl1;
> +	u64 value;
> +
> +	value = address | PTL2_TYPE_BLOCK | PTL2_BLOCK_AF;
> +	value |= PMD_ATTRINDX(memory_type);
> +	pmd[bfn] = value;
> +}
> +
> +static struct mm_region mem_map[] = CONFIG_SYS_MEM_MAP;
> +
> +#define PTL1_ENTRIES CONFIG_SYS_PTL1_ENTRIES
> +#define PTL2_ENTRIES CONFIG_SYS_PTL2_ENTRIES
> +
> +static void setup_pgtables(void)
> +{
> +	int l1_e, l2_e;
> +	unsigned long pmd = 0;
> +	unsigned long address;
> +
> +	/* Setup the PMD pointers */
> +	for (l1_e = 0; l1_e < CONFIG_SYS_MEM_MAP_SIZE; l1_e++) {
> +		gd->arch.pmd_addr[l1_e] = gd->arch.tlb_addr +
> +						PTL1_ENTRIES * sizeof(u64);
> +		gd->arch.pmd_addr[l1_e] += PTL2_ENTRIES * sizeof(u64) * l1_e;
> +		gd->arch.pmd_addr[l1_e] += 0xffffUL;
> +		gd->arch.pmd_addr[l1_e] &= ~0xffffUL;
> +	}
> +
> +	/* Setup the page tables */
> +	for (l1_e = 0; l1_e < PTL1_ENTRIES; l1_e++) {
> +		if (mem_map[pmd].base ==
> +			(uintptr_t)l1_e << PTL2_BITS) {
> +			set_ptl1_entry(l1_e, gd->arch.pmd_addr[pmd]);
> +
> +			for (l2_e = 0; l2_e < PTL2_ENTRIES; l2_e++) {
> +				address = mem_map[pmd].base
> +					+ (uintptr_t)l2_e * BLOCK_SIZE;
> +				set_ptl2_block(gd->arch.pmd_addr[pmd], l2_e,
> +					       address, mem_map[pmd].attrs);
> +			}
> +
> +			pmd++;
> +		} else {
> +			set_ptl1_entry(l1_e, 0);
> +		}
> +	}
> +}
> +
> +#else
> +
>  void set_pgtable_section(u64 *page_table, u64 index, u64 section,
>  			 u64 memory_type)
>  {
> @@ -22,13 +85,25 @@ void set_pgtable_section(u64 *page_table, u64 index, u64 section,
>  	page_table[index] = value;
>  }
>  
> +#endif
> +
> +


Sergey,

FYI, we have a patch under review[1], rewriting MMU code for Freescale ARMv8
SoCs. It doesn't conflict with your proposed change, but modifies the common
file cache_v8.c.

[1] http://patchwork.ozlabs.org/patch/502980/

York

  reply	other threads:[~2015-08-13 15:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13 15:14 [U-Boot] [PATCH v3 0/7] This patch series adds support for Cavium ThunderX 88xx SoC family Sergey Temerkhanov
2015-08-13 15:14 ` [U-Boot] [PATCH v3 1/7] armv8: New MMU setup code allowing to use 48+ bits PA/VA Sergey Temerkhanov
2015-08-13 15:28   ` York Sun [this message]
2015-08-13 15:14 ` [U-Boot] [PATCH v3 2/7] armv8: Add SMC calls infrastructure Sergey Temerkhanov
2015-08-14 18:56   ` Simon Glass
2015-08-15  1:45     ` Sergei Temerkhanov
2015-08-15 13:10       ` Simon Glass
2015-08-13 15:14 ` [U-Boot] [PATCH v3 3/7] armv8: Add psci.h from the Linux kernel Sergey Temerkhanov
2015-08-13 15:14 ` [U-Boot] [PATCH v3 4/7] arm: serial: Add ability to use pre-initialized UARTs Sergey Temerkhanov
2015-08-14 18:56   ` Simon Glass
2015-08-13 15:15 ` [U-Boot] [PATCH v3 5/7] armv8: cavium: Add ThunderX 88xx board definition Sergey Temerkhanov
2015-08-13 15:15 ` [U-Boot] [PATCH v3 6/7] armv8: cavium: Add an implementation of ATF calling functions Sergey Temerkhanov
2015-08-13 15:15 ` [U-Boot] [PATCH v3 7/7] armv8: cavium: Get DRAM size from ATF Sergey Temerkhanov
2015-08-13 16:29 ` [U-Boot] [PATCH v3 0/7] This patch series adds support for Cavium ThunderX 88xx SoC family Sergei Temerkhanov

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=55CCB7A6.5030202@freescale.com \
    --to=yorksun@freescale.com \
    --cc=u-boot@lists.denx.de \
    /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