All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: David Matlack <dmatlack@google.com>
Cc: kvm list <kvm@vger.kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Andrew Jones <drjones@redhat.com>,
	Ben Gardon <bgardon@google.com>
Subject: Re: [PATCH] KVM: selftests: Fix 32-bit truncation of vm_get_max_gfn()
Date: Thu, 20 May 2021 18:46:37 -0400	[thread overview]
Message-ID: <YKbmzUpR9AIoa9na@t490s> (raw)
In-Reply-To: <CALzav=dixRORFDyeaj67=SyXko9t++qGgnCJrhWD7bBKqz_3mA@mail.gmail.com>

On Thu, May 20, 2021 at 02:56:41PM -0700, David Matlack wrote:
> On Thu, May 20, 2021 at 2:47 PM Peter Xu <peterx@redhat.com> wrote:
> >
> > On Thu, May 20, 2021 at 09:26:54PM +0000, David Matlack wrote:
> > > vm_get_max_gfn() casts vm->max_gfn from a uint64_t to an unsigned int,
> > > which causes the upper 32-bits of the max_gfn to get truncated.
> > >
> > > Nobody noticed until now likely because vm_get_max_gfn() is only used
> > > as a mechanism to create a memslot in an unused region of the guest
> > > physical address space (the top), and the top of the 32-bit physical
> > > address space was always good enough.
> >
> > s/top/bottom/?
> 
> I guess it depends on your reference point :). The existing comments
> under tools/testing/selftests/kvm use the convention that "top" ==
> high addresses.

Ah I was thinking in another way (converting the unsigned int to u64 is taking
the "bottom" of the 8bytes field), while you meant we allocate memory from the
top. Yeah then it looks good.

> 
> >
> > Looks right.. thanks for fixing it!
> >
> > >
> > > This fix reveals a bug in memslot_modification_stress_test which was
> > > trying to create a dummy memslot past the end of guest physical memory.
> > > Fix that by moving the dummy memslot lower.
> >
> > Would it be better to split the different fixes?
> 
> I'm fine either way. I figured the net delta was small enough and the
> fixes tightly coupled so sending as one patch made the most sense. Is
> there value in splitting this up?

Feel free to keep it a single patch if no one else complains. :)

Thanks,

-- 
Peter Xu


  reply	other threads:[~2021-05-20 22:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 21:26 [PATCH] KVM: selftests: Fix 32-bit truncation of vm_get_max_gfn() David Matlack
2021-05-20 21:47 ` Peter Xu
2021-05-20 21:56   ` David Matlack
2021-05-20 22:46     ` Peter Xu [this message]
2021-05-20 23:41 ` Venkatesh Srinivas

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=YKbmzUpR9AIoa9na@t490s \
    --to=peterx@redhat.com \
    --cc=bgardon@google.com \
    --cc=dmatlack@google.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /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.