linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 1/7] ARM: KVM: simplify HYP mapping population
Date: Fri, 26 Apr 2013 11:45:06 +0100	[thread overview]
Message-ID: <20130426104506.GD5007@localhost.cambridge.arm.com> (raw)
In-Reply-To: <1365790327-2138-2-git-send-email-marc.zyngier@arm.com>

On Fri, Apr 12, 2013 at 07:12:01PM +0100, Marc Zyngier wrote:
> diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
> index 2f12e40..3003321 100644
> --- a/arch/arm/kvm/mmu.c
> +++ b/arch/arm/kvm/mmu.c
...
> -static int __create_hyp_mappings(void *from, void *to, unsigned long *pfn_base)
> +static int __create_hyp_mappings(pgd_t *pgdp,
> +				 unsigned long start, unsigned long end,
> +				 unsigned long pfn, pgprot_t prot)
>  {
> -	unsigned long start = (unsigned long)from;
> -	unsigned long end = (unsigned long)to;
>  	pgd_t *pgd;
>  	pud_t *pud;
>  	pmd_t *pmd;
> @@ -209,21 +181,14 @@ static int __create_hyp_mappings(void *from, void *to, unsigned long *pfn_base)
>  
>  	if (start >= end)
>  		return -EINVAL;
> -	/* Check for a valid kernel memory mapping */
> -	if (!pfn_base && (!virt_addr_valid(from) || !virt_addr_valid(to - 1)))
> -		return -EINVAL;
> -	/* Check for a valid kernel IO mapping */
> -	if (pfn_base && (!is_vmalloc_addr(from) || !is_vmalloc_addr(to - 1)))
> -		return -EINVAL;
>  
>  	mutex_lock(&kvm_hyp_pgd_mutex);
> -	for (addr = start; addr < end; addr = next) {
> -		unsigned long hyp_addr = KERN_TO_HYP(addr);
> -		pgd = hyp_pgd + pgd_index(hyp_addr);
> -		pud = pud_offset(pgd, hyp_addr);
> +	for (addr = start & PAGE_MASK; addr < end; addr = next) {
> +		pgd = pgdp + pgd_index(addr);
> +		pud = pud_offset(pgd, addr);
>  
>  		if (pud_none_or_clear_bad(pud)) {
> -			pmd = pmd_alloc_one(NULL, hyp_addr);
> +			pmd = pmd_alloc_one(NULL, addr);
>  			if (!pmd) {
>  				kvm_err("Cannot allocate Hyp pmd\n");
>  				err = -ENOMEM;
> @@ -233,9 +198,10 @@ static int __create_hyp_mappings(void *from, void *to, unsigned long *pfn_base)
>  		}
>  
>  		next = pgd_addr_end(addr, end);
> -		err = create_hyp_pmd_mappings(pud, addr, next, pfn_base);
> +		err = create_hyp_pmd_mappings(pud, addr, next, pfn, prot);

I would add another indirection function here like
create_hyp_pud_mappings() if we are to share this code with arm64. If
written correctly, the compiler should turn it into no-op. But here you
just make the assumption that pgd/pud are the same.

(it can be additional patch at some point if you already prepared these
patches for upstream)

-- 
Catalin

  reply	other threads:[~2013-04-26 10:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-12 18:12 [PATCH v4 0/7] ARM: KVM: Revamping the HYP init code for fun and profit Marc Zyngier
2013-04-12 18:12 ` [PATCH v4 1/7] ARM: KVM: simplify HYP mapping population Marc Zyngier
2013-04-26 10:45   ` Catalin Marinas [this message]
2013-04-26 10:59     ` Marc Zyngier
2013-04-12 18:12 ` [PATCH v4 2/7] ARM: KVM: fix HYP mapping limitations around zero Marc Zyngier
2013-04-12 18:12 ` [PATCH v4 3/7] ARM: KVM: move to a KVM provided HYP idmap Marc Zyngier
2013-04-17 19:37   ` Christoffer Dall
2013-04-18  9:08     ` Will Deacon
2013-04-12 18:12 ` [PATCH v4 4/7] ARM: KVM: enforce maximum size for identity mapped code Marc Zyngier
2013-04-12 18:12 ` [PATCH v4 5/7] ARM: KVM: rework HYP page table freeing Marc Zyngier
2013-04-26 11:05   ` Catalin Marinas
2013-04-26 16:45     ` Marc Zyngier
2013-04-26 21:07       ` Christoffer Dall
2013-04-27 15:21         ` Catalin Marinas
2013-04-12 18:12 ` [PATCH v4 6/7] ARM: KVM: switch to a dual-step HYP init code Marc Zyngier
2013-04-12 18:12 ` [PATCH v4 7/7] ARM: KVM: perform HYP initilization for hotplugged CPUs Marc Zyngier

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=20130426104506.GD5007@localhost.cambridge.arm.com \
    --to=catalin.marinas@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;
as well as URLs for NNTP newsgroup(s).