All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pratyush Anand <panand@redhat.com>
To: Azriel Samson <asamson@codeaurora.org>
Cc: timur@codeaurora.org, kexec@lists.infradead.org,
	rruigrok@codeaurora.org, Mansi Patel <mansip@codeaurora.org>,
	sgoel@codeaurora.org, virajm@codeaurora.org
Subject: Re: [PATCH] arm64: Add support for 4level 4K page translations table
Date: Wed, 6 Jan 2016 12:26:47 +0530	[thread overview]
Message-ID: <20160106065647.GA29776@dhcppc13.redhat.com> (raw)
In-Reply-To: <1452039159-5559-1-git-send-email-asamson@codeaurora.org>

Hi Azriel,

Thanks for working on 4 level 4K page support.

On 05/01/2016:05:12:39 PM, Azriel Samson wrote:
> Add PUD translation for 4 level page tables.
> 
> Signed-off-by: Mansi Patel <mansip@codeaurora.org>
> Signed-off-by: Azriel Samson <asamson@codeaurora.org>
> ---
> This change targets the arm64_support branch of Pratush Anand's repository at:
> https://github.com/pratyushanand/makedumpfile.git
> 
>  arch/arm64.c | 25 ++++++++++++++++++-------
>  1 file changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/arm64.c b/arch/arm64.c
> index 59825fa..62c76e3 100644
> --- a/arch/arm64.c
> +++ b/arch/arm64.c
> @@ -35,15 +35,10 @@ typedef struct {
>  	pud_t pud;
>  } pmd_t;
>  
> -#define pud_offset(pgd, vaddr) 	((pud_t *)pgd)
> -
>  #define pgd_val(x)		((x).pgd)
>  #define pud_val(x)		(pgd_val((x).pgd))
>  #define pmd_val(x)		(pud_val((x).pud))
>  
> -#define PUD_SHIFT		PGDIR_SHIFT
> -#define PUD_SIZE		(1UL << PUD_SHIFT)
> -
>  typedef struct {
>  	unsigned long pte;
>  } pte_t;
> @@ -59,6 +54,10 @@ typedef struct {
>  #define PMD_SIZE		(1UL << PMD_SHIFT)
>  #define PMD_MASK		(~(PMD_SIZE - 1))
>  #define PTRS_PER_PMD		PTRS_PER_PTE
> +#define PUD_SHIFT		((PAGE_SHIFT - 3) * 3 + 3)

It will break system with pgtable_level <= 3. I think it would be better to keep
it like as follows:

static int
get_pud_shift_arm64(void)
{
        if (pgtable_level == 4)
                return ((PAGE_SHIFT - 3) * 3 + 3);
        else
                return PGDIR_SHIFT;
}
#define PUD_SHIFT               get_pud_shift_arm64()

> +#define PUD_SIZE		(1UL << PUD_SHIFT)
> +#define PUD_MASK		(~(PUD_SIZE - 1))
> +#define PTRS_PER_PUD		PTRS_PER_PTE
>  
>  #define PAGE_PRESENT		(1 << 0)
>  #define SECTIONS_SIZE_BITS	30
> @@ -95,6 +94,10 @@ typedef struct {
>  #define pud_page_vaddr(pud)		(__va(pud_val(pud) & PHYS_MASK & (int32_t)PAGE_MASK))
>  #define pmd_offset_pgtbl_lvl_3(pud, vaddr) ((pmd_t *)pud_page_vaddr((*pud)) + pmd_index(vaddr))
>  

Since above definition for PTRS_PER_PUD is true only for 4 level page table so
better to keep that define here.

> +#define pud_index(vaddr)		(((vaddr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
> +#define pgd_page_vaddr(pgd)		   (__va(pgd_val(pgd) & PHYS_MASK & (int32_t)PAGE_MASK))
> +#define pud_offset(pgd, vaddr) ((pud_t *)pgd_page_vaddr((*pgd)) + pud_index(vaddr))
> +

May be following would be better:

static pud_t * 
pud_offset(pgd_t *pgd, unsigned long vaddr)
{
        if (pgtable_level == 4)
                return ((pud_t *)pgd_page_vaddr((*pgd)) + pud_index(vaddr));
        else
                return (pud_t *)pgd;
}


>  /* kernel struct page size can be kernel version dependent, currently
>   * keep it constant.
>   */
> @@ -244,7 +247,7 @@ vtop_arm64(unsigned long vaddr)
>  {
>  	unsigned long long paddr = NOT_PADDR;
>  	pgd_t	*pgda, pgdv;
> -	pud_t	pudv;
> +	pud_t	*puda, pudv;
>  	pmd_t	*pmda, pmdv;
>  	pte_t 	*ptea, ptev;
>  
> @@ -259,7 +262,15 @@ vtop_arm64(unsigned long vaddr)
>  		return NOT_PADDR;
>  	}
>  
> -	pudv.pgd = pgdv;
> +	if (pgtable_level <= 3) {
> +		pudv.pgd = pgdv;
> +	} else {

With suggested pud_offset() definition, we can get rid of above "if" condition and
then pud calculation code would be in sync with other calculations like that of
pgd and pmd.

> +		puda = pud_offset(&pgdv, vaddr);
> +		if (!readmem(VADDR, (unsigned long long)puda, &pudv, sizeof(pudv))) {
> +			ERRMSG("Can't read pud\n");
> +			return NOT_PADDR;
> +		}
> +	}

~Pratyush

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

      reply	other threads:[~2016-01-06  6:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-06  0:12 [PATCH] arm64: Add support for 4level 4K page translations table Azriel Samson
2016-01-06  6:56 ` Pratyush Anand [this message]

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=20160106065647.GA29776@dhcppc13.redhat.com \
    --to=panand@redhat.com \
    --cc=asamson@codeaurora.org \
    --cc=kexec@lists.infradead.org \
    --cc=mansip@codeaurora.org \
    --cc=rruigrok@codeaurora.org \
    --cc=sgoel@codeaurora.org \
    --cc=timur@codeaurora.org \
    --cc=virajm@codeaurora.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 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.