diff mbox series

KVM: arm64: Fix the upper limit of the walker range

Message ID 20250114145050.563658-2-sebastianene@google.com (mailing list archive)
State New
Headers show
Series KVM: arm64: Fix the upper limit of the walker range | expand

Commit Message

Sebastian Ene Jan. 14, 2025, 2:50 p.m. UTC
Prevent the walker from running into weeds when walking an
entire address range.

Signed-off-by: Sebastian Ene <sebastianene@google.com>
---
 arch/arm64/kvm/hyp/pgtable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marc Zyngier Jan. 14, 2025, 2:55 p.m. UTC | #1
On Tue, 14 Jan 2025 14:50:51 +0000,
Sebastian Ene <sebastianene@google.com> wrote:
> 
> Prevent the walker from running into weeds when walking an
> entire address range.
> 
> Signed-off-by: Sebastian Ene <sebastianene@google.com>
> ---
>  arch/arm64/kvm/hyp/pgtable.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c
> index 40bd55966..2ffb5571e 100644
> --- a/arch/arm64/kvm/hyp/pgtable.c
> +++ b/arch/arm64/kvm/hyp/pgtable.c
> @@ -260,7 +260,7 @@ static int _kvm_pgtable_walk(struct kvm_pgtable *pgt, struct kvm_pgtable_walk_da
>  {
>  	u32 idx;
>  	int ret = 0;
> -	u64 limit = BIT(pgt->ia_bits);
> +	u64 limit = BIT(pgt->ia_bits) - 1;
>  
>  	if (data->addr > limit || data->end > limit)
>  		return -ERANGE;

Huh, nice catch. I guess this deserves a

Fixes: b1e57de62cfb4 ("KVM: arm64: Add stand-alone page-table walker infrastructure")
Cc: stable@vger.kernel.org

right?

	M.
Sebastian Ene Jan. 14, 2025, 3:03 p.m. UTC | #2
On Tue, Jan 14, 2025 at 02:55:17PM +0000, Marc Zyngier wrote:
> On Tue, 14 Jan 2025 14:50:51 +0000,
> Sebastian Ene <sebastianene@google.com> wrote:
> > 
> > Prevent the walker from running into weeds when walking an
> > entire address range.
> > 
> > Signed-off-by: Sebastian Ene <sebastianene@google.com>
> > ---
> >  arch/arm64/kvm/hyp/pgtable.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c
> > index 40bd55966..2ffb5571e 100644
> > --- a/arch/arm64/kvm/hyp/pgtable.c
> > +++ b/arch/arm64/kvm/hyp/pgtable.c
> > @@ -260,7 +260,7 @@ static int _kvm_pgtable_walk(struct kvm_pgtable *pgt, struct kvm_pgtable_walk_da
> >  {
> >  	u32 idx;
> >  	int ret = 0;
> > -	u64 limit = BIT(pgt->ia_bits);
> > +	u64 limit = BIT(pgt->ia_bits) - 1;
> >  
> >  	if (data->addr > limit || data->end > limit)
> >  		return -ERANGE;
> 
> Huh, nice catch. I guess this deserves a
> 
> Fixes: b1e57de62cfb4 ("KVM: arm64: Add stand-alone page-table walker infrastructure")
> Cc: stable@vger.kernel.org
> 
> right?
> 
> 	M.

Hi Marc,

Thanks for the prompt review. Adding the missing bits now and re-spinnig
v2.

> 
> -- 
> Without deviation from the norm, progress is not possible.

Cheers
Sebastian
Marc Zyngier Jan. 14, 2025, 3:07 p.m. UTC | #3
On Tue, 14 Jan 2025 14:50:51 +0000, Sebastian Ene wrote:
> Prevent the walker from running into weeds when walking an
> entire address range.
> 
> 

Applied to next, thanks!

[1/1] KVM: arm64: Fix the upper limit of the walker range
      commit: bc9e4ec6e98838314c07575a5fbc06755d21913c

Cheers,

	M.
Marc Zyngier Jan. 14, 2025, 3:08 p.m. UTC | #4
On Tue, 14 Jan 2025 15:03:37 +0000,
Sebastian Ene <sebastianene@google.com> wrote:
> 
> On Tue, Jan 14, 2025 at 02:55:17PM +0000, Marc Zyngier wrote:
> > On Tue, 14 Jan 2025 14:50:51 +0000,
> > Sebastian Ene <sebastianene@google.com> wrote:
> > > 
> > > Prevent the walker from running into weeds when walking an
> > > entire address range.
> > > 
> > > Signed-off-by: Sebastian Ene <sebastianene@google.com>
> > > ---
> > >  arch/arm64/kvm/hyp/pgtable.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c
> > > index 40bd55966..2ffb5571e 100644
> > > --- a/arch/arm64/kvm/hyp/pgtable.c
> > > +++ b/arch/arm64/kvm/hyp/pgtable.c
> > > @@ -260,7 +260,7 @@ static int _kvm_pgtable_walk(struct kvm_pgtable *pgt, struct kvm_pgtable_walk_da
> > >  {
> > >  	u32 idx;
> > >  	int ret = 0;
> > > -	u64 limit = BIT(pgt->ia_bits);
> > > +	u64 limit = BIT(pgt->ia_bits) - 1;
> > >  
> > >  	if (data->addr > limit || data->end > limit)
> > >  		return -ERANGE;
> > 
> > Huh, nice catch. I guess this deserves a
> > 
> > Fixes: b1e57de62cfb4 ("KVM: arm64: Add stand-alone page-table walker infrastructure")
> > Cc: stable@vger.kernel.org
> > 
> > right?
> > 
> > 	M.
> 
> Hi Marc,
> 
> Thanks for the prompt review. Adding the missing bits now and re-spinnig
> v2.

Too late! ;-)

	M.
diff mbox series

Patch

diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c
index 40bd55966..2ffb5571e 100644
--- a/arch/arm64/kvm/hyp/pgtable.c
+++ b/arch/arm64/kvm/hyp/pgtable.c
@@ -260,7 +260,7 @@  static int _kvm_pgtable_walk(struct kvm_pgtable *pgt, struct kvm_pgtable_walk_da
 {
 	u32 idx;
 	int ret = 0;
-	u64 limit = BIT(pgt->ia_bits);
+	u64 limit = BIT(pgt->ia_bits) - 1;
 
 	if (data->addr > limit || data->end > limit)
 		return -ERANGE;