linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: RISC-V: Fix wrong usage of PGDIR_SIZE to check page sizes
@ 2023-01-23  9:29 Alexandre Ghiti
  2023-01-23  9:31 ` Alexandre Ghiti
  2023-01-23 11:03 ` Andrew Jones
  0 siblings, 2 replies; 7+ messages in thread
From: Alexandre Ghiti @ 2023-01-23  9:29 UTC (permalink / raw)
  To: Anup Patel, Atish Patra, Paul Walmsley, Palmer Dabbelt,
	Albert Ou, kvm, kvm-riscv, linux-riscv, linux-kernel
  Cc: Alexandre Ghiti

At the moment, riscv only supports PMD and PUD hugepages. For sv39,
PGDIR_SIZE == PUD_SIZE but not for sv48 and sv57. So fix this by changing
PGDIR_SIZE into PUD_SIZE.

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
---
 arch/riscv/kvm/mmu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
index 34b57e0be2ef..dbc4ca060174 100644
--- a/arch/riscv/kvm/mmu.c
+++ b/arch/riscv/kvm/mmu.c
@@ -585,7 +585,7 @@ bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
 	if (!kvm->arch.pgd)
 		return false;
 
-	WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PGDIR_SIZE);
+	WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE);
 
 	if (!gstage_get_leaf_entry(kvm, range->start << PAGE_SHIFT,
 				   &ptep, &ptep_level))
@@ -603,7 +603,7 @@ bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
 	if (!kvm->arch.pgd)
 		return false;
 
-	WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PGDIR_SIZE);
+	WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE);
 
 	if (!gstage_get_leaf_entry(kvm, range->start << PAGE_SHIFT,
 				   &ptep, &ptep_level))
@@ -645,12 +645,12 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,
 	if (logging || (vma->vm_flags & VM_PFNMAP))
 		vma_pagesize = PAGE_SIZE;
 
-	if (vma_pagesize == PMD_SIZE || vma_pagesize == PGDIR_SIZE)
+	if (vma_pagesize == PMD_SIZE || vma_pagesize == PUD_SIZE)
 		gfn = (gpa & huge_page_mask(hstate_vma(vma))) >> PAGE_SHIFT;
 
 	mmap_read_unlock(current->mm);
 
-	if (vma_pagesize != PGDIR_SIZE &&
+	if (vma_pagesize != PUD_SIZE &&
 	    vma_pagesize != PMD_SIZE &&
 	    vma_pagesize != PAGE_SIZE) {
 		kvm_err("Invalid VMA page size 0x%lx\n", vma_pagesize);
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] KVM: RISC-V: Fix wrong usage of PGDIR_SIZE to check page sizes
  2023-01-23  9:29 [PATCH] KVM: RISC-V: Fix wrong usage of PGDIR_SIZE to check page sizes Alexandre Ghiti
@ 2023-01-23  9:31 ` Alexandre Ghiti
  2023-01-23 11:28   ` Anup Patel
  2023-01-23 11:03 ` Andrew Jones
  1 sibling, 1 reply; 7+ messages in thread
From: Alexandre Ghiti @ 2023-01-23  9:31 UTC (permalink / raw)
  To: Alexandre Ghiti, Anup Patel, Atish Patra, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, kvm, kvm-riscv, linux-riscv,
	linux-kernel

@Anup: Sorry, forgot to add -fixes to the patch title, as I think this 
should go into your fixes branch for 6.2.

On 1/23/23 10:29, Alexandre Ghiti wrote:
> At the moment, riscv only supports PMD and PUD hugepages. For sv39,
> PGDIR_SIZE == PUD_SIZE but not for sv48 and sv57. So fix this by changing
> PGDIR_SIZE into PUD_SIZE.
>
> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> ---
>   arch/riscv/kvm/mmu.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
> index 34b57e0be2ef..dbc4ca060174 100644
> --- a/arch/riscv/kvm/mmu.c
> +++ b/arch/riscv/kvm/mmu.c
> @@ -585,7 +585,7 @@ bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
>   	if (!kvm->arch.pgd)
>   		return false;
>   
> -	WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PGDIR_SIZE);
> +	WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE);
>   
>   	if (!gstage_get_leaf_entry(kvm, range->start << PAGE_SHIFT,
>   				   &ptep, &ptep_level))
> @@ -603,7 +603,7 @@ bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
>   	if (!kvm->arch.pgd)
>   		return false;
>   
> -	WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PGDIR_SIZE);
> +	WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE);
>   
>   	if (!gstage_get_leaf_entry(kvm, range->start << PAGE_SHIFT,
>   				   &ptep, &ptep_level))
> @@ -645,12 +645,12 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,
>   	if (logging || (vma->vm_flags & VM_PFNMAP))
>   		vma_pagesize = PAGE_SIZE;
>   
> -	if (vma_pagesize == PMD_SIZE || vma_pagesize == PGDIR_SIZE)
> +	if (vma_pagesize == PMD_SIZE || vma_pagesize == PUD_SIZE)
>   		gfn = (gpa & huge_page_mask(hstate_vma(vma))) >> PAGE_SHIFT;
>   
>   	mmap_read_unlock(current->mm);
>   
> -	if (vma_pagesize != PGDIR_SIZE &&
> +	if (vma_pagesize != PUD_SIZE &&
>   	    vma_pagesize != PMD_SIZE &&
>   	    vma_pagesize != PAGE_SIZE) {
>   		kvm_err("Invalid VMA page size 0x%lx\n", vma_pagesize);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] KVM: RISC-V: Fix wrong usage of PGDIR_SIZE to check page sizes
  2023-01-23  9:29 [PATCH] KVM: RISC-V: Fix wrong usage of PGDIR_SIZE to check page sizes Alexandre Ghiti
  2023-01-23  9:31 ` Alexandre Ghiti
@ 2023-01-23 11:03 ` Andrew Jones
  2023-01-23 11:16   ` Alexandre Ghiti
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Jones @ 2023-01-23 11:03 UTC (permalink / raw)
  To: Alexandre Ghiti
  Cc: Anup Patel, Atish Patra, Paul Walmsley, Palmer Dabbelt,
	Albert Ou, kvm, kvm-riscv, linux-riscv, linux-kernel

On Mon, Jan 23, 2023 at 10:29:28AM +0100, Alexandre Ghiti wrote:
> At the moment, riscv only supports PMD and PUD hugepages. For sv39,
> PGDIR_SIZE == PUD_SIZE but not for sv48 and sv57. So fix this by changing
> PGDIR_SIZE into PUD_SIZE.

Can you please add a sentence as to how you found this? Some test case
or just by analysis?

Anyway,

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>

> 
> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> ---
>  arch/riscv/kvm/mmu.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
> index 34b57e0be2ef..dbc4ca060174 100644
> --- a/arch/riscv/kvm/mmu.c
> +++ b/arch/riscv/kvm/mmu.c
> @@ -585,7 +585,7 @@ bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
>  	if (!kvm->arch.pgd)
>  		return false;
>  
> -	WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PGDIR_SIZE);
> +	WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE);
>  
>  	if (!gstage_get_leaf_entry(kvm, range->start << PAGE_SHIFT,
>  				   &ptep, &ptep_level))
> @@ -603,7 +603,7 @@ bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
>  	if (!kvm->arch.pgd)
>  		return false;
>  
> -	WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PGDIR_SIZE);
> +	WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE);
>  
>  	if (!gstage_get_leaf_entry(kvm, range->start << PAGE_SHIFT,
>  				   &ptep, &ptep_level))
> @@ -645,12 +645,12 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,
>  	if (logging || (vma->vm_flags & VM_PFNMAP))
>  		vma_pagesize = PAGE_SIZE;
>  
> -	if (vma_pagesize == PMD_SIZE || vma_pagesize == PGDIR_SIZE)
> +	if (vma_pagesize == PMD_SIZE || vma_pagesize == PUD_SIZE)
>  		gfn = (gpa & huge_page_mask(hstate_vma(vma))) >> PAGE_SHIFT;
>  
>  	mmap_read_unlock(current->mm);
>  
> -	if (vma_pagesize != PGDIR_SIZE &&
> +	if (vma_pagesize != PUD_SIZE &&
>  	    vma_pagesize != PMD_SIZE &&
>  	    vma_pagesize != PAGE_SIZE) {
>  		kvm_err("Invalid VMA page size 0x%lx\n", vma_pagesize);
> -- 
> 2.37.2
> 
> 
> -- 
> kvm-riscv mailing list
> kvm-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kvm-riscv

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] KVM: RISC-V: Fix wrong usage of PGDIR_SIZE to check page sizes
  2023-01-23 11:03 ` Andrew Jones
@ 2023-01-23 11:16   ` Alexandre Ghiti
  0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Ghiti @ 2023-01-23 11:16 UTC (permalink / raw)
  To: Andrew Jones
  Cc: Anup Patel, Atish Patra, Paul Walmsley, Palmer Dabbelt,
	Albert Ou, kvm, kvm-riscv, linux-riscv, linux-kernel

On Mon, Jan 23, 2023 at 12:03 PM Andrew Jones <ajones@ventanamicro.com> wrote:
>
> On Mon, Jan 23, 2023 at 10:29:28AM +0100, Alexandre Ghiti wrote:
> > At the moment, riscv only supports PMD and PUD hugepages. For sv39,
> > PGDIR_SIZE == PUD_SIZE but not for sv48 and sv57. So fix this by changing
> > PGDIR_SIZE into PUD_SIZE.
>
> Can you please add a sentence as to how you found this? Some test case
> or just by analysis?

Just by reading the code! That made me think that we can have more
hugepages for riscv since the introduction of sv48 and sv57, I'll send
this patch later.

>
> Anyway,
>
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>

Thanks,

Alex

>
> >
> > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> > ---
> >  arch/riscv/kvm/mmu.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
> > index 34b57e0be2ef..dbc4ca060174 100644
> > --- a/arch/riscv/kvm/mmu.c
> > +++ b/arch/riscv/kvm/mmu.c
> > @@ -585,7 +585,7 @@ bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
> >       if (!kvm->arch.pgd)
> >               return false;
> >
> > -     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PGDIR_SIZE);
> > +     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE);
> >
> >       if (!gstage_get_leaf_entry(kvm, range->start << PAGE_SHIFT,
> >                                  &ptep, &ptep_level))
> > @@ -603,7 +603,7 @@ bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
> >       if (!kvm->arch.pgd)
> >               return false;
> >
> > -     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PGDIR_SIZE);
> > +     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE);
> >
> >       if (!gstage_get_leaf_entry(kvm, range->start << PAGE_SHIFT,
> >                                  &ptep, &ptep_level))
> > @@ -645,12 +645,12 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,
> >       if (logging || (vma->vm_flags & VM_PFNMAP))
> >               vma_pagesize = PAGE_SIZE;
> >
> > -     if (vma_pagesize == PMD_SIZE || vma_pagesize == PGDIR_SIZE)
> > +     if (vma_pagesize == PMD_SIZE || vma_pagesize == PUD_SIZE)
> >               gfn = (gpa & huge_page_mask(hstate_vma(vma))) >> PAGE_SHIFT;
> >
> >       mmap_read_unlock(current->mm);
> >
> > -     if (vma_pagesize != PGDIR_SIZE &&
> > +     if (vma_pagesize != PUD_SIZE &&
> >           vma_pagesize != PMD_SIZE &&
> >           vma_pagesize != PAGE_SIZE) {
> >               kvm_err("Invalid VMA page size 0x%lx\n", vma_pagesize);
> > --
> > 2.37.2
> >
> >
> > --
> > kvm-riscv mailing list
> > kvm-riscv@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/kvm-riscv

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] KVM: RISC-V: Fix wrong usage of PGDIR_SIZE to check page sizes
  2023-01-23  9:31 ` Alexandre Ghiti
@ 2023-01-23 11:28   ` Anup Patel
  2023-01-23 14:34     ` Alexandre Ghiti
  0 siblings, 1 reply; 7+ messages in thread
From: Anup Patel @ 2023-01-23 11:28 UTC (permalink / raw)
  To: Alexandre Ghiti
  Cc: Alexandre Ghiti, Atish Patra, Paul Walmsley, Palmer Dabbelt,
	Albert Ou, kvm, kvm-riscv, linux-riscv, linux-kernel

On Mon, Jan 23, 2023 at 3:01 PM Alexandre Ghiti <alex@ghiti.fr> wrote:
>
> @Anup: Sorry, forgot to add -fixes to the patch title, as I think this
> should go into your fixes branch for 6.2.

Can you provide the Fixes: line here ? I will include it at time of
adding this patch to my fixes branch.

Regards,
Anup

>
> On 1/23/23 10:29, Alexandre Ghiti wrote:
> > At the moment, riscv only supports PMD and PUD hugepages. For sv39,
> > PGDIR_SIZE == PUD_SIZE but not for sv48 and sv57. So fix this by changing
> > PGDIR_SIZE into PUD_SIZE.
> >
> > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> > ---
> >   arch/riscv/kvm/mmu.c | 8 ++++----
> >   1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
> > index 34b57e0be2ef..dbc4ca060174 100644
> > --- a/arch/riscv/kvm/mmu.c
> > +++ b/arch/riscv/kvm/mmu.c
> > @@ -585,7 +585,7 @@ bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
> >       if (!kvm->arch.pgd)
> >               return false;
> >
> > -     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PGDIR_SIZE);
> > +     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE);
> >
> >       if (!gstage_get_leaf_entry(kvm, range->start << PAGE_SHIFT,
> >                                  &ptep, &ptep_level))
> > @@ -603,7 +603,7 @@ bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
> >       if (!kvm->arch.pgd)
> >               return false;
> >
> > -     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PGDIR_SIZE);
> > +     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE);
> >
> >       if (!gstage_get_leaf_entry(kvm, range->start << PAGE_SHIFT,
> >                                  &ptep, &ptep_level))
> > @@ -645,12 +645,12 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,
> >       if (logging || (vma->vm_flags & VM_PFNMAP))
> >               vma_pagesize = PAGE_SIZE;
> >
> > -     if (vma_pagesize == PMD_SIZE || vma_pagesize == PGDIR_SIZE)
> > +     if (vma_pagesize == PMD_SIZE || vma_pagesize == PUD_SIZE)
> >               gfn = (gpa & huge_page_mask(hstate_vma(vma))) >> PAGE_SHIFT;
> >
> >       mmap_read_unlock(current->mm);
> >
> > -     if (vma_pagesize != PGDIR_SIZE &&
> > +     if (vma_pagesize != PUD_SIZE &&
> >           vma_pagesize != PMD_SIZE &&
> >           vma_pagesize != PAGE_SIZE) {
> >               kvm_err("Invalid VMA page size 0x%lx\n", vma_pagesize);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] KVM: RISC-V: Fix wrong usage of PGDIR_SIZE to check page sizes
  2023-01-23 11:28   ` Anup Patel
@ 2023-01-23 14:34     ` Alexandre Ghiti
  2023-01-27  5:38       ` Anup Patel
  0 siblings, 1 reply; 7+ messages in thread
From: Alexandre Ghiti @ 2023-01-23 14:34 UTC (permalink / raw)
  To: Anup Patel
  Cc: Alexandre Ghiti, Atish Patra, Paul Walmsley, Palmer Dabbelt,
	Albert Ou, kvm, kvm-riscv, linux-riscv, linux-kernel

On Mon, Jan 23, 2023 at 12:28 PM Anup Patel <anup@brainfault.org> wrote:
>
> On Mon, Jan 23, 2023 at 3:01 PM Alexandre Ghiti <alex@ghiti.fr> wrote:
> >
> > @Anup: Sorry, forgot to add -fixes to the patch title, as I think this
> > should go into your fixes branch for 6.2.
>
> Can you provide the Fixes: line here ? I will include it at time of
> adding this patch to my fixes branch.

It actually fixes 2 commits: 9955371cc014 ("RISC-V: KVM: Implement MMU
notifiers") and 9d05c1fee837 ("RISC-V: KVM: Implement stage2 page
table programming"). But they were both part of the first KVM
patchset, so I only took the oldest one, but tell me if you want me to
split the patch into 2 different patches that fix one commit at a
time.

Fixes: 9d05c1fee837 ("RISC-V: KVM: Implement stage2 page table programming")

Thanks,

Alex

>
> Regards,
> Anup
>
> >
> > On 1/23/23 10:29, Alexandre Ghiti wrote:
> > > At the moment, riscv only supports PMD and PUD hugepages. For sv39,
> > > PGDIR_SIZE == PUD_SIZE but not for sv48 and sv57. So fix this by changing
> > > PGDIR_SIZE into PUD_SIZE.
> > >
> > > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> > > ---
> > >   arch/riscv/kvm/mmu.c | 8 ++++----
> > >   1 file changed, 4 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
> > > index 34b57e0be2ef..dbc4ca060174 100644
> > > --- a/arch/riscv/kvm/mmu.c
> > > +++ b/arch/riscv/kvm/mmu.c
> > > @@ -585,7 +585,7 @@ bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
> > >       if (!kvm->arch.pgd)
> > >               return false;
> > >
> > > -     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PGDIR_SIZE);
> > > +     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE);
> > >
> > >       if (!gstage_get_leaf_entry(kvm, range->start << PAGE_SHIFT,
> > >                                  &ptep, &ptep_level))
> > > @@ -603,7 +603,7 @@ bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
> > >       if (!kvm->arch.pgd)
> > >               return false;
> > >
> > > -     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PGDIR_SIZE);
> > > +     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE);
> > >
> > >       if (!gstage_get_leaf_entry(kvm, range->start << PAGE_SHIFT,
> > >                                  &ptep, &ptep_level))
> > > @@ -645,12 +645,12 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,
> > >       if (logging || (vma->vm_flags & VM_PFNMAP))
> > >               vma_pagesize = PAGE_SIZE;
> > >
> > > -     if (vma_pagesize == PMD_SIZE || vma_pagesize == PGDIR_SIZE)
> > > +     if (vma_pagesize == PMD_SIZE || vma_pagesize == PUD_SIZE)
> > >               gfn = (gpa & huge_page_mask(hstate_vma(vma))) >> PAGE_SHIFT;
> > >
> > >       mmap_read_unlock(current->mm);
> > >
> > > -     if (vma_pagesize != PGDIR_SIZE &&
> > > +     if (vma_pagesize != PUD_SIZE &&
> > >           vma_pagesize != PMD_SIZE &&
> > >           vma_pagesize != PAGE_SIZE) {
> > >               kvm_err("Invalid VMA page size 0x%lx\n", vma_pagesize);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] KVM: RISC-V: Fix wrong usage of PGDIR_SIZE to check page sizes
  2023-01-23 14:34     ` Alexandre Ghiti
@ 2023-01-27  5:38       ` Anup Patel
  0 siblings, 0 replies; 7+ messages in thread
From: Anup Patel @ 2023-01-27  5:38 UTC (permalink / raw)
  To: Alexandre Ghiti
  Cc: Alexandre Ghiti, Atish Patra, Paul Walmsley, Palmer Dabbelt,
	Albert Ou, kvm, kvm-riscv, linux-riscv, linux-kernel

On Mon, Jan 23, 2023 at 8:04 PM Alexandre Ghiti <alexghiti@rivosinc.com> wrote:
>
> On Mon, Jan 23, 2023 at 12:28 PM Anup Patel <anup@brainfault.org> wrote:
> >
> > On Mon, Jan 23, 2023 at 3:01 PM Alexandre Ghiti <alex@ghiti.fr> wrote:
> > >
> > > @Anup: Sorry, forgot to add -fixes to the patch title, as I think this
> > > should go into your fixes branch for 6.2.
> >
> > Can you provide the Fixes: line here ? I will include it at time of
> > adding this patch to my fixes branch.
>
> It actually fixes 2 commits: 9955371cc014 ("RISC-V: KVM: Implement MMU
> notifiers") and 9d05c1fee837 ("RISC-V: KVM: Implement stage2 page
> table programming"). But they were both part of the first KVM
> patchset, so I only took the oldest one, but tell me if you want me to
> split the patch into 2 different patches that fix one commit at a
> time.
>
> Fixes: 9d05c1fee837 ("RISC-V: KVM: Implement stage2 page table programming")

The Linux-6.3 merge window is near so I have queued this patch
for Linux-6.3

Thanks,
Anup

>
> Thanks,
>
> Alex
>
> >
> > Regards,
> > Anup
> >
> > >
> > > On 1/23/23 10:29, Alexandre Ghiti wrote:
> > > > At the moment, riscv only supports PMD and PUD hugepages. For sv39,
> > > > PGDIR_SIZE == PUD_SIZE but not for sv48 and sv57. So fix this by changing
> > > > PGDIR_SIZE into PUD_SIZE.
> > > >
> > > > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> > > > ---
> > > >   arch/riscv/kvm/mmu.c | 8 ++++----
> > > >   1 file changed, 4 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
> > > > index 34b57e0be2ef..dbc4ca060174 100644
> > > > --- a/arch/riscv/kvm/mmu.c
> > > > +++ b/arch/riscv/kvm/mmu.c
> > > > @@ -585,7 +585,7 @@ bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
> > > >       if (!kvm->arch.pgd)
> > > >               return false;
> > > >
> > > > -     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PGDIR_SIZE);
> > > > +     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE);
> > > >
> > > >       if (!gstage_get_leaf_entry(kvm, range->start << PAGE_SHIFT,
> > > >                                  &ptep, &ptep_level))
> > > > @@ -603,7 +603,7 @@ bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
> > > >       if (!kvm->arch.pgd)
> > > >               return false;
> > > >
> > > > -     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PGDIR_SIZE);
> > > > +     WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE);
> > > >
> > > >       if (!gstage_get_leaf_entry(kvm, range->start << PAGE_SHIFT,
> > > >                                  &ptep, &ptep_level))
> > > > @@ -645,12 +645,12 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,
> > > >       if (logging || (vma->vm_flags & VM_PFNMAP))
> > > >               vma_pagesize = PAGE_SIZE;
> > > >
> > > > -     if (vma_pagesize == PMD_SIZE || vma_pagesize == PGDIR_SIZE)
> > > > +     if (vma_pagesize == PMD_SIZE || vma_pagesize == PUD_SIZE)
> > > >               gfn = (gpa & huge_page_mask(hstate_vma(vma))) >> PAGE_SHIFT;
> > > >
> > > >       mmap_read_unlock(current->mm);
> > > >
> > > > -     if (vma_pagesize != PGDIR_SIZE &&
> > > > +     if (vma_pagesize != PUD_SIZE &&
> > > >           vma_pagesize != PMD_SIZE &&
> > > >           vma_pagesize != PAGE_SIZE) {
> > > >               kvm_err("Invalid VMA page size 0x%lx\n", vma_pagesize);

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-01-27  5:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-23  9:29 [PATCH] KVM: RISC-V: Fix wrong usage of PGDIR_SIZE to check page sizes Alexandre Ghiti
2023-01-23  9:31 ` Alexandre Ghiti
2023-01-23 11:28   ` Anup Patel
2023-01-23 14:34     ` Alexandre Ghiti
2023-01-27  5:38       ` Anup Patel
2023-01-23 11:03 ` Andrew Jones
2023-01-23 11:16   ` Alexandre Ghiti

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).