public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: marc.zyngier@arm•com (Marc Zyngier)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v2 07/17] kvm-arm: arm32: Introduce stage2 page table helpers
Date: Thu, 14 Apr 2016 15:22:58 +0100	[thread overview]
Message-ID: <570FA7C2.1090902@arm.com> (raw)
In-Reply-To: <1460640065-27658-8-git-send-email-suzuki.poulose@arm.com>

On 14/04/16 14:20, Suzuki K Poulose wrote:
> Define the page table helpers for walking the stage2 pagetable
> for arm. Since both hyp and stage2 have the same number of levels,
> as that of the host we reuse the host helpers.
> 
> The exceptions are the p.d_addr_end routines which have to deal
> with IPA > 32bit, hence we use the open coded version of their host helpers
> which supports 64bit.
> 
> Cc: Marc Zyngier <marc.zyngier@arm•com>
> Reviewed-by: Christoffer Dall <christoffer.dall@linaro•org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm•com>
> ---
> Changes since v1:
>   - Drop mm (which is always NULL) parameter to stage2_p.d_xxx. Pass NULL
>     explicitly to the host helpers.
> ---
>  arch/arm/include/asm/kvm_mmu.h        |    1 +
>  arch/arm/include/asm/stage2_pgtable.h |   59 +++++++++++++++++++++++++++++++++
>  2 files changed, 60 insertions(+)
>  create mode 100644 arch/arm/include/asm/stage2_pgtable.h
> 
> diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h
> index c2b2b27..7d207b4 100644
> --- a/arch/arm/include/asm/kvm_mmu.h
> +++ b/arch/arm/include/asm/kvm_mmu.h
> @@ -47,6 +47,7 @@
>  #include <linux/highmem.h>
>  #include <asm/cacheflush.h>
>  #include <asm/pgalloc.h>
> +#include <asm/stage2_pgtable.h>
>  
>  int create_hyp_mappings(void *from, void *to);
>  int create_hyp_io_mappings(void *from, void *to, phys_addr_t);
> diff --git a/arch/arm/include/asm/stage2_pgtable.h b/arch/arm/include/asm/stage2_pgtable.h
> new file mode 100644
> index 0000000..5b61196
> --- /dev/null
> +++ b/arch/arm/include/asm/stage2_pgtable.h
> @@ -0,0 +1,59 @@
> +/*
> + * Copyright (C) 2016 - ARM Ltd
> + *
> + * stage2 page table helpers
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#ifndef __ARM_S2_PGTABLE_H_
> +#define __ARM_S2_PGTABLE_H_
> +
> +#define stage2_pgd_none(pgd)			pgd_none(pgd)
> +#define stage2_pgd_clear(pgd)			pgd_clear(pgd)
> +#define stage2_pgd_present(pgd)			pgd_present(pgd)
> +#define stage2_pgd_populate(pgd, pud)		pgd_populate(NULL, pgd, pud)
> +#define stage2_pud_offset(pgd, address)		pud_offset(pgd, address)
> +#define stage2_pud_free(pud)			pud_free(NULL, pud)
> +
> +#define stage2_pud_none(pud)			pud_none(pud)
> +#define stage2_pud_clear(pud)			pud_clear(pud)
> +#define stage2_pud_present(pud)			pud_present(pud)
> +#define stage2_pud_populate(pud, pmd)		pud_populate(NULL, pud, pmd)
> +#define stage2_pmd_offset(pud, address)		pmd_offset(pud, address)
> +#define stage2_pmd_free(pmd)			pmd_free(NULL, pmd)
> +
> +#define stage2_pud_huge(pud)			pud_huge(pud)
> +
> +/* Open coded p*d_addr_end that can deal with 64bit addresses */
> +static inline phys_addr_t stage2_pgd_addr_end(phys_addr_t addr, phys_addr_t end)
> +{
> +	phys_addr_t boundary = (addr + PGDIR_SIZE) & PGDIR_MASK;
> +	return (boundary - 1 < end - 1) ? boundary : end;
> +}
> +
> +#define stage2_pud_addr_end(addr, end)		(end)
> +
> +static inline phys_addr_t stage2_pmd_addr_end(phys_addr_t addr, phys_addr_t end)
> +{
> +	phys_addr_t boundary = (addr + PMD_SIZE) & PMD_MASK;
> +	return (boundary - 1 < end - 1) ? boundary : end;
> +}
> +
> +#define stage2_pgd_index(addr)				pgd_index(addr)
> +
> +#define stage2_pte_table_empty(ptep)			kvm_page_empty(ptep)
> +#define stage2_pmd_table_empty(pmdp)			kvm_page_empty(pmdp)
> +#define stage2_pud_table_empty(pudp)			0

nit: given that the kvm_page_empty returns a boolean, I'd have defined
this to 'false' instead of zero. No need to respin for this though.

Another concern is that while stage2_* looks pretty generic, the
implementation is very KVM specific. As long as KVM is the only
in-kernel hypervisor, it doesn't matter.

> +
> +#endif	/* __ARM_S2_PGTABLE_H_ */
> 

Irrespective of the above:

Acked-by: Marc Zyngier <marc.zyngier@arm•com>

	M.
-- 
Jazz is not dead. It just smells funny...

  reply	other threads:[~2016-04-14 14:22 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-14 13:20 [PATCH v2 00/17] kvm-arm: Add stage2 page table walker Suzuki K Poulose
2016-04-14 13:20 ` [PATCH v2 01/17] arm64: Reuse TCR field definitions for EL1 and EL2 Suzuki K Poulose
2016-04-14 14:11   ` Marc Zyngier
2016-04-15 15:15   ` Will Deacon
2016-04-14 13:20 ` [PATCH v2 02/17] arm64: Cleanup VTCR_EL2 and VTTBR field values Suzuki K Poulose
2016-04-14 14:12   ` Marc Zyngier
2016-04-14 13:20 ` [PATCH v2 03/17] kvm arm: Move fake PGD handling to arch specific files Suzuki K Poulose
2016-04-14 13:20 ` [PATCH v2 04/17] arm64: Introduce pmd_thp_or_huge Suzuki K Poulose
2016-04-14 14:14   ` Marc Zyngier
2016-04-15 15:17   ` Will Deacon
2016-04-14 13:20 ` [PATCH v2 05/17] kvm-arm: Replace kvm_pmd_huge with pmd_thp_or_huge Suzuki K Poulose
2016-04-14 14:15   ` Marc Zyngier
2016-04-14 13:20 ` [PATCH v2 06/17] kvm-arm: Remove kvm_pud_huge() Suzuki K Poulose
2016-04-14 14:16   ` Marc Zyngier
2016-04-14 13:20 ` [PATCH v2 07/17] kvm-arm: arm32: Introduce stage2 page table helpers Suzuki K Poulose
2016-04-14 14:22   ` Marc Zyngier [this message]
2016-04-14 13:20 ` [PATCH v2 08/17] kvm-arm: arm: Introduce hyp page table empty checks Suzuki K Poulose
2016-04-14 14:23   ` Marc Zyngier
2016-04-14 13:20 ` [PATCH v2 09/17] kvm-arm: arm64: Introduce stage2 page table helpers Suzuki K Poulose
2016-04-14 14:31   ` Marc Zyngier
2016-04-14 13:20 ` [PATCH v2 10/17] kvm-arm: arm64: Introduce hyp page table empty checks Suzuki K Poulose
2016-04-14 14:45   ` Marc Zyngier
2016-04-14 13:20 ` [PATCH v2 11/17] kvm-arm: Use explicit stage2 helper routines Suzuki K Poulose
2016-04-14 13:21 ` [PATCH v2 12/17] kvm-arm: Add explicit hyp page table modifiers Suzuki K Poulose
2016-04-14 15:06   ` Christoffer Dall
2016-04-14 13:21 ` [PATCH v2 13/17] kvm-arm: Add stage2 " Suzuki K Poulose
2016-04-14 13:21 ` [PATCH v2 14/17] kvm-arm: Cleanup kvm_* wrappers Suzuki K Poulose
2016-04-14 13:21 ` [PATCH v2 15/17] kvm: arm64: Get rid of fake page table levels Suzuki K Poulose
2016-04-14 15:08   ` Christoffer Dall
2016-04-14 13:21 ` [PATCH v2 16/17] kvm-arm: Cleanup stage2 pgd handling Suzuki K Poulose
2016-04-14 13:21 ` [PATCH v2 17/17] arm64: kvm: Add support for 16K pages Suzuki K Poulose
2016-04-14 13:29 ` [PATCH v2 00/17] kvm-arm: Add stage2 page table walker Suzuki K Poulose
2016-04-14 16:03   ` Christoffer Dall
2016-04-14 16:10     ` Marc Zyngier
2016-04-14 16:11     ` Suzuki K Poulose
2016-04-14 16:41       ` Christoffer Dall
2016-04-14 16:51         ` Suzuki K Poulose

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=570FA7C2.1090902@arm.com \
    --to=marc.zyngier@arm$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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