* [PATCH] KVM: PPC: Book3S HV: Fix reverse map real-mode address lookup with huge vmalloc
@ 2021-05-23 15:53 ` Nicholas Piggin
0 siblings, 0 replies; 6+ messages in thread
From: Nicholas Piggin @ 2021-05-23 15:53 UTC (permalink / raw)
To: kvm-ppc; +Cc: linuxppc-dev, Nicholas Piggin
real_vmalloc_addr() does not currently work for huge vmalloc, which is
what the reverse map can be allocated with for radix host, hash guest.
Add huge page awareness to the function.
Fixes: 8abddd968a30 ("powerpc/64s/radix: Enable huge vmalloc mappings")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/kvm/book3s_hv_rm_mmu.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
index 7af7c70f1468..5f68cb5cc009 100644
--- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
+++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
@@ -26,16 +26,23 @@
static void *real_vmalloc_addr(void *x)
{
unsigned long addr = (unsigned long) x;
+ unsigned long mask;
+ int shift;
pte_t *p;
+
/*
- * assume we don't have huge pages in vmalloc space...
- * So don't worry about THP collapse/split. Called
- * Only in realmode with MSR_EE = 0, hence won't need irq_save/restore.
+ * This is called only in realmode with MSR_EE = 0, hence won't need
+ * irq_save/restore around find_init_mm_pte.
*/
- p = find_init_mm_pte(addr, NULL);
+ p = find_init_mm_pte(addr, &shift);
if (!p || !pte_present(*p))
return NULL;
- addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & ~PAGE_MASK);
+ if (!shift)
+ shift = PAGE_SHIFT;
+
+ mask = (1UL << shift) - 1;
+ addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & mask);
+
return __va(addr);
}
--
2.23.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] KVM: PPC: Book3S HV: Fix reverse map real-mode address lookup with huge vmalloc
@ 2021-05-23 15:53 ` Nicholas Piggin
0 siblings, 0 replies; 6+ messages in thread
From: Nicholas Piggin @ 2021-05-23 15:53 UTC (permalink / raw)
To: kvm-ppc; +Cc: linuxppc-dev, Nicholas Piggin
real_vmalloc_addr() does not currently work for huge vmalloc, which is
what the reverse map can be allocated with for radix host, hash guest.
Add huge page awareness to the function.
Fixes: 8abddd968a30 ("powerpc/64s/radix: Enable huge vmalloc mappings")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/kvm/book3s_hv_rm_mmu.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
index 7af7c70f1468..5f68cb5cc009 100644
--- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
+++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
@@ -26,16 +26,23 @@
static void *real_vmalloc_addr(void *x)
{
unsigned long addr = (unsigned long) x;
+ unsigned long mask;
+ int shift;
pte_t *p;
+
/*
- * assume we don't have huge pages in vmalloc space...
- * So don't worry about THP collapse/split. Called
- * Only in realmode with MSR_EE = 0, hence won't need irq_save/restore.
+ * This is called only in realmode with MSR_EE = 0, hence won't need
+ * irq_save/restore around find_init_mm_pte.
*/
- p = find_init_mm_pte(addr, NULL);
+ p = find_init_mm_pte(addr, &shift);
if (!p || !pte_present(*p))
return NULL;
- addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & ~PAGE_MASK);
+ if (!shift)
+ shift = PAGE_SHIFT;
+
+ mask = (1UL << shift) - 1;
+ addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & mask);
+
return __va(addr);
}
--
2.23.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] KVM: PPC: Book3S HV: Fix reverse map real-mode address lookup with huge vmalloc
2021-05-23 15:53 ` Nicholas Piggin
@ 2021-05-23 16:10 ` Christophe Leroy
-1 siblings, 0 replies; 6+ messages in thread
From: Christophe Leroy @ 2021-05-23 16:10 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linuxppc-dev, kvm-ppc
Nicholas Piggin <npiggin@gmail.com> a écrit :
> real_vmalloc_addr() does not currently work for huge vmalloc, which is
> what the reverse map can be allocated with for radix host, hash guest.
>
> Add huge page awareness to the function.
>
> Fixes: 8abddd968a30 ("powerpc/64s/radix: Enable huge vmalloc mappings")
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> arch/powerpc/kvm/book3s_hv_rm_mmu.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> index 7af7c70f1468..5f68cb5cc009 100644
> --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> @@ -26,16 +26,23 @@
> static void *real_vmalloc_addr(void *x)
> {
> unsigned long addr = (unsigned long) x;
> + unsigned long mask;
> + int shift;
> pte_t *p;
> +
> /*
> - * assume we don't have huge pages in vmalloc space...
> - * So don't worry about THP collapse/split. Called
> - * Only in realmode with MSR_EE = 0, hence won't need irq_save/restore.
> + * This is called only in realmode with MSR_EE = 0, hence won't need
> + * irq_save/restore around find_init_mm_pte.
> */
> - p = find_init_mm_pte(addr, NULL);
> + p = find_init_mm_pte(addr, &shift);
> if (!p || !pte_present(*p))
> return NULL;
> - addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & ~PAGE_MASK);
> + if (!shift)
> + shift = PAGE_SHIFT;
> +
> + mask = (1UL << shift) - 1;
> + addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & mask);
Looks strange, before we have ~MASK now we have mask without the ~
Also use PFN_PHYS() instead of open coding ?
> +
> return __va(addr);
> }
>
> --
> 2.23.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] KVM: PPC: Book3S HV: Fix reverse map real-mode address lookup with huge vmalloc
@ 2021-05-23 16:10 ` Christophe Leroy
0 siblings, 0 replies; 6+ messages in thread
From: Christophe Leroy @ 2021-05-23 16:10 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linuxppc-dev, kvm-ppc
Nicholas Piggin <npiggin@gmail.com> a écrit :
> real_vmalloc_addr() does not currently work for huge vmalloc, which is
> what the reverse map can be allocated with for radix host, hash guest.
>
> Add huge page awareness to the function.
>
> Fixes: 8abddd968a30 ("powerpc/64s/radix: Enable huge vmalloc mappings")
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> arch/powerpc/kvm/book3s_hv_rm_mmu.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> index 7af7c70f1468..5f68cb5cc009 100644
> --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> @@ -26,16 +26,23 @@
> static void *real_vmalloc_addr(void *x)
> {
> unsigned long addr = (unsigned long) x;
> + unsigned long mask;
> + int shift;
> pte_t *p;
> +
> /*
> - * assume we don't have huge pages in vmalloc space...
> - * So don't worry about THP collapse/split. Called
> - * Only in realmode with MSR_EE = 0, hence won't need irq_save/restore.
> + * This is called only in realmode with MSR_EE = 0, hence won't need
> + * irq_save/restore around find_init_mm_pte.
> */
> - p = find_init_mm_pte(addr, NULL);
> + p = find_init_mm_pte(addr, &shift);
> if (!p || !pte_present(*p))
> return NULL;
> - addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & ~PAGE_MASK);
> + if (!shift)
> + shift = PAGE_SHIFT;
> +
> + mask = (1UL << shift) - 1;
> + addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & mask);
Looks strange, before we have ~MASK now we have mask without the ~
Also use PFN_PHYS() instead of open coding ?
> +
> return __va(addr);
> }
>
> --
> 2.23.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] KVM: PPC: Book3S HV: Fix reverse map real-mode address lookup with huge vmalloc
2021-05-23 16:10 ` Christophe Leroy
@ 2021-05-24 7:59 ` Aneesh Kumar K.V
-1 siblings, 0 replies; 6+ messages in thread
From: Aneesh Kumar K.V @ 2021-05-24 7:47 UTC (permalink / raw)
To: Christophe Leroy, Nicholas Piggin; +Cc: linuxppc-dev, kvm-ppc
Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Nicholas Piggin <npiggin@gmail.com> a écrit :
>
>> real_vmalloc_addr() does not currently work for huge vmalloc, which is
>> what the reverse map can be allocated with for radix host, hash guest.
>>
>> Add huge page awareness to the function.
>>
>> Fixes: 8abddd968a30 ("powerpc/64s/radix: Enable huge vmalloc mappings")
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> ---
>> arch/powerpc/kvm/book3s_hv_rm_mmu.c | 17 ++++++++++++-----
>> 1 file changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
>> b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
>> index 7af7c70f1468..5f68cb5cc009 100644
>> --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
>> +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
>> @@ -26,16 +26,23 @@
>> static void *real_vmalloc_addr(void *x)
>> {
>> unsigned long addr = (unsigned long) x;
>> + unsigned long mask;
>> + int shift;
>> pte_t *p;
>> +
>> /*
>> - * assume we don't have huge pages in vmalloc space...
>> - * So don't worry about THP collapse/split. Called
>> - * Only in realmode with MSR_EE = 0, hence won't need irq_save/restore.
>> + * This is called only in realmode with MSR_EE = 0, hence won't need
>> + * irq_save/restore around find_init_mm_pte.
>> */
>> - p = find_init_mm_pte(addr, NULL);
>> + p = find_init_mm_pte(addr, &shift);
>> if (!p || !pte_present(*p))
>> return NULL;
>> - addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & ~PAGE_MASK);
>> + if (!shift)
>> + shift = PAGE_SHIFT;
>> +
>> + mask = (1UL << shift) - 1;
>> + addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & mask);
>
> Looks strange, before we have ~MASK now we have mask without the ~
#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
-aneesh
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] KVM: PPC: Book3S HV: Fix reverse map real-mode address lookup with huge vmalloc
@ 2021-05-24 7:59 ` Aneesh Kumar K.V
0 siblings, 0 replies; 6+ messages in thread
From: Aneesh Kumar K.V @ 2021-05-24 7:59 UTC (permalink / raw)
To: Christophe Leroy, Nicholas Piggin; +Cc: linuxppc-dev, kvm-ppc
Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Nicholas Piggin <npiggin@gmail.com> a écrit :
>
>> real_vmalloc_addr() does not currently work for huge vmalloc, which is
>> what the reverse map can be allocated with for radix host, hash guest.
>>
>> Add huge page awareness to the function.
>>
>> Fixes: 8abddd968a30 ("powerpc/64s/radix: Enable huge vmalloc mappings")
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> ---
>> arch/powerpc/kvm/book3s_hv_rm_mmu.c | 17 ++++++++++++-----
>> 1 file changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
>> b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
>> index 7af7c70f1468..5f68cb5cc009 100644
>> --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
>> +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
>> @@ -26,16 +26,23 @@
>> static void *real_vmalloc_addr(void *x)
>> {
>> unsigned long addr = (unsigned long) x;
>> + unsigned long mask;
>> + int shift;
>> pte_t *p;
>> +
>> /*
>> - * assume we don't have huge pages in vmalloc space...
>> - * So don't worry about THP collapse/split. Called
>> - * Only in realmode with MSR_EE = 0, hence won't need irq_save/restore.
>> + * This is called only in realmode with MSR_EE = 0, hence won't need
>> + * irq_save/restore around find_init_mm_pte.
>> */
>> - p = find_init_mm_pte(addr, NULL);
>> + p = find_init_mm_pte(addr, &shift);
>> if (!p || !pte_present(*p))
>> return NULL;
>> - addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & ~PAGE_MASK);
>> + if (!shift)
>> + shift = PAGE_SHIFT;
>> +
>> + mask = (1UL << shift) - 1;
>> + addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & mask);
>
> Looks strange, before we have ~MASK now we have mask without the ~
#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
-aneesh
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-05-24 7:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-23 15:53 [PATCH] KVM: PPC: Book3S HV: Fix reverse map real-mode address lookup with huge vmalloc Nicholas Piggin
2021-05-23 15:53 ` Nicholas Piggin
2021-05-23 16:10 ` Christophe Leroy
2021-05-23 16:10 ` Christophe Leroy
2021-05-24 7:47 ` Aneesh Kumar K.V
2021-05-24 7:59 ` Aneesh Kumar K.V
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.