From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] KVM: ARM: Transparent huge pages and hugetlbfs support
Date: Mon, 23 Sep 2013 15:46:27 +0100 [thread overview]
Message-ID: <52405443.7000709@arm.com> (raw)
In-Reply-To: <524013BB.4090303@arm.com>
On 23/09/13 11:11, Marc Zyngier wrote:
> Hi Christoffer,
>
> Finally taking some time to review this patch. Sorry for the delay...
>
> On 09/08/13 05:07, Christoffer Dall wrote:
>> From: Christoffer Dall <cdall@cs.columbia.edu>
>>
>> Support transparent huge pages in KVM/ARM 32-bit and 64-bit. The whole
>> transparent_hugepage_adjust stuff is far from pretty, but this is how
>> it's solved on x86 so we duplicate their logic. This should be shared
>> across architectures if possible (like many other things), but can
>> always be changed down the road.
>>
>> The pud_huge checking on the unmap path may feel a bit silly as the
>> pud_huge check is always defined to false, but the compiler should be
>> smart about this.
>>
>> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
>> ---
>> arch/arm/include/asm/kvm_mmu.h | 17 +++-
>> arch/arm/kvm/mmu.c | 200 ++++++++++++++++++++++++++++++++------
>> arch/arm64/include/asm/kvm_mmu.h | 12 ++-
>> 3 files changed, 194 insertions(+), 35 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h
>> index 472ac70..ff3ff67 100644
>> --- a/arch/arm/include/asm/kvm_mmu.h
>> +++ b/arch/arm/include/asm/kvm_mmu.h
>> @@ -62,6 +62,12 @@ phys_addr_t kvm_get_idmap_vector(void);
>> int kvm_mmu_init(void);
>> void kvm_clear_hyp_idmap(void);
>>
>> +static inline void kvm_set_pmd(pmd_t *pmd, pmd_t new_pmd)
>> +{
>> + *pmd = new_pmd;
>> + flush_pmd_entry(pmd);
>> +}
>> +
>> static inline void kvm_set_pte(pte_t *pte, pte_t new_pte)
>> {
>> pte_val(*pte) = new_pte;
>> @@ -103,9 +109,15 @@ static inline void kvm_set_s2pte_writable(pte_t *pte)
>> pte_val(*pte) |= L_PTE_S2_RDWR;
>> }
>>
>> +static inline void kvm_set_s2pmd_writable(pmd_t *pmd)
>> +{
>> + pmd_val(*pmd) |= L_PTE_S2_RDWR;
>> +}
>> +
>> struct kvm;
>>
>> -static inline void coherent_icache_guest_page(struct kvm *kvm, gfn_t gfn)
>> +static inline void coherent_icache_guest_page(struct kvm *kvm, hva_t hva,
>> + unsigned long size)
>> {
>> /*
>> * If we are going to insert an instruction page and the icache is
>> @@ -120,8 +132,7 @@ static inline void coherent_icache_guest_page(struct kvm *kvm, gfn_t gfn)
>> * need any kind of flushing (DDI 0406C.b - Page B3-1392).
>> */
>> if (icache_is_pipt()) {
>> - unsigned long hva = gfn_to_hva(kvm, gfn);
>> - __cpuc_coherent_user_range(hva, hva + PAGE_SIZE);
>> + __cpuc_coherent_user_range(hva, hva + size);
>> } else if (!icache_is_vivt_asid_tagged()) {
>> /* any kind of VIPT cache */
>> __flush_icache_all();
>> diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
>> index 0988d9e..26ced77 100644
>> --- a/arch/arm/kvm/mmu.c
>> +++ b/arch/arm/kvm/mmu.c
>> @@ -19,6 +19,7 @@
>> #include <linux/mman.h>
>> #include <linux/kvm_host.h>
>> #include <linux/io.h>
>> +#include <linux/hugetlb.h>
>> #include <trace/events/kvm.h>
>> #include <asm/pgalloc.h>
>> #include <asm/cacheflush.h>
>> @@ -41,6 +42,8 @@ static unsigned long hyp_idmap_start;
>> static unsigned long hyp_idmap_end;
>> static phys_addr_t hyp_idmap_vector;
>>
>> +#define kvm_pmd_huge(_x) (pmd_huge(_x) || pmd_trans_huge(_x))
Also, have a look at Steve's latest patch:
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-September/199812.html
He has the exact same define, so there's room for consolidation there as
well. Not a big issue though, and we can keep that for a later cleanup.
Cheers,
M.
--
Jazz is not dead. It just smells funny...
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <marc.zyngier@arm.com>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Christoffer Dall <cdall@cs.columbia.edu>,
"linaro-kernel@lists.linaro.org" <linaro-kernel@lists.linaro.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"patches@linaro.org" <patches@linaro.org>,
"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 3/3] KVM: ARM: Transparent huge pages and hugetlbfs support
Date: Mon, 23 Sep 2013 15:46:27 +0100 [thread overview]
Message-ID: <52405443.7000709@arm.com> (raw)
In-Reply-To: <524013BB.4090303@arm.com>
On 23/09/13 11:11, Marc Zyngier wrote:
> Hi Christoffer,
>
> Finally taking some time to review this patch. Sorry for the delay...
>
> On 09/08/13 05:07, Christoffer Dall wrote:
>> From: Christoffer Dall <cdall@cs.columbia.edu>
>>
>> Support transparent huge pages in KVM/ARM 32-bit and 64-bit. The whole
>> transparent_hugepage_adjust stuff is far from pretty, but this is how
>> it's solved on x86 so we duplicate their logic. This should be shared
>> across architectures if possible (like many other things), but can
>> always be changed down the road.
>>
>> The pud_huge checking on the unmap path may feel a bit silly as the
>> pud_huge check is always defined to false, but the compiler should be
>> smart about this.
>>
>> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
>> ---
>> arch/arm/include/asm/kvm_mmu.h | 17 +++-
>> arch/arm/kvm/mmu.c | 200 ++++++++++++++++++++++++++++++++------
>> arch/arm64/include/asm/kvm_mmu.h | 12 ++-
>> 3 files changed, 194 insertions(+), 35 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h
>> index 472ac70..ff3ff67 100644
>> --- a/arch/arm/include/asm/kvm_mmu.h
>> +++ b/arch/arm/include/asm/kvm_mmu.h
>> @@ -62,6 +62,12 @@ phys_addr_t kvm_get_idmap_vector(void);
>> int kvm_mmu_init(void);
>> void kvm_clear_hyp_idmap(void);
>>
>> +static inline void kvm_set_pmd(pmd_t *pmd, pmd_t new_pmd)
>> +{
>> + *pmd = new_pmd;
>> + flush_pmd_entry(pmd);
>> +}
>> +
>> static inline void kvm_set_pte(pte_t *pte, pte_t new_pte)
>> {
>> pte_val(*pte) = new_pte;
>> @@ -103,9 +109,15 @@ static inline void kvm_set_s2pte_writable(pte_t *pte)
>> pte_val(*pte) |= L_PTE_S2_RDWR;
>> }
>>
>> +static inline void kvm_set_s2pmd_writable(pmd_t *pmd)
>> +{
>> + pmd_val(*pmd) |= L_PTE_S2_RDWR;
>> +}
>> +
>> struct kvm;
>>
>> -static inline void coherent_icache_guest_page(struct kvm *kvm, gfn_t gfn)
>> +static inline void coherent_icache_guest_page(struct kvm *kvm, hva_t hva,
>> + unsigned long size)
>> {
>> /*
>> * If we are going to insert an instruction page and the icache is
>> @@ -120,8 +132,7 @@ static inline void coherent_icache_guest_page(struct kvm *kvm, gfn_t gfn)
>> * need any kind of flushing (DDI 0406C.b - Page B3-1392).
>> */
>> if (icache_is_pipt()) {
>> - unsigned long hva = gfn_to_hva(kvm, gfn);
>> - __cpuc_coherent_user_range(hva, hva + PAGE_SIZE);
>> + __cpuc_coherent_user_range(hva, hva + size);
>> } else if (!icache_is_vivt_asid_tagged()) {
>> /* any kind of VIPT cache */
>> __flush_icache_all();
>> diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
>> index 0988d9e..26ced77 100644
>> --- a/arch/arm/kvm/mmu.c
>> +++ b/arch/arm/kvm/mmu.c
>> @@ -19,6 +19,7 @@
>> #include <linux/mman.h>
>> #include <linux/kvm_host.h>
>> #include <linux/io.h>
>> +#include <linux/hugetlb.h>
>> #include <trace/events/kvm.h>
>> #include <asm/pgalloc.h>
>> #include <asm/cacheflush.h>
>> @@ -41,6 +42,8 @@ static unsigned long hyp_idmap_start;
>> static unsigned long hyp_idmap_end;
>> static phys_addr_t hyp_idmap_vector;
>>
>> +#define kvm_pmd_huge(_x) (pmd_huge(_x) || pmd_trans_huge(_x))
Also, have a look at Steve's latest patch:
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-September/199812.html
He has the exact same define, so there's room for consolidation there as
well. Not a big issue though, and we can keep that for a later cleanup.
Cheers,
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2013-09-23 14:46 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-09 4:07 [PATCH 0/3] KVM/ARM Huge pages support Christoffer Dall
2013-08-09 4:07 ` Christoffer Dall
2013-08-09 4:07 ` [PATCH 1/3] KVM: Move gfn_to_index to x86 specific code Christoffer Dall
2013-08-09 4:07 ` Christoffer Dall
2013-08-09 4:07 ` [PATCH 2/3] KVM: ARM: Get rid of KVM_HPAGE_XXX defines Christoffer Dall
2013-08-09 4:07 ` Christoffer Dall
2013-08-09 4:07 ` [PATCH 3/3] KVM: ARM: Transparent huge pages and hugetlbfs support Christoffer Dall
2013-08-09 4:07 ` Christoffer Dall
2013-09-23 10:11 ` Marc Zyngier
2013-09-23 10:11 ` Marc Zyngier
2013-09-23 14:46 ` Marc Zyngier [this message]
2013-09-23 14:46 ` Marc Zyngier
2013-09-24 15:41 ` Steve Capper
2013-09-24 15:41 ` Steve Capper
2013-10-02 22:36 ` Christoffer Dall
2013-10-02 22:36 ` Christoffer Dall
2013-10-03 20:33 ` Christoffer Dall
2013-10-03 20:33 ` Christoffer Dall
2013-10-04 9:23 ` Marc Zyngier
2013-10-04 9:23 ` Marc Zyngier
2013-08-09 14:30 ` [PATCH 2/3] KVM: ARM: Get rid of KVM_HPAGE_ defines Christoffer Dall
2013-08-09 14:30 ` Christoffer Dall
2013-08-25 14:05 ` Gleb Natapov
2013-08-25 14:05 ` Gleb Natapov
2013-08-25 14:29 ` Peter Maydell
2013-08-25 14:29 ` Peter Maydell
2013-08-25 14:48 ` Gleb Natapov
2013-08-25 14:48 ` Gleb Natapov
2013-08-25 15:18 ` Peter Maydell
2013-08-25 15:18 ` Peter Maydell
2013-08-25 15:27 ` Alexander Graf
2013-08-25 15:27 ` Alexander Graf
2013-08-26 10:55 ` Gleb Natapov
2013-08-26 10:55 ` Gleb Natapov
2013-08-26 0:46 ` Christoffer Dall
2013-08-26 0:46 ` Christoffer Dall
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=52405443.7000709@arm.com \
--to=marc.zyngier@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 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.