From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: Thomas Huth <thuth@redhat.com>,
kvm@vger.kernel.org, pbonzini@redhat.com, frankja@linux.ibm.com,
david@redhat.com, drjones@redhat.com, jmattson@google.com
Subject: Re: [kvm-unit-tests PATCH v1 2/2] lib/alloc_page: Fix compilation issue on 32bit archs
Date: Tue, 14 Jul 2020 07:05:34 -0700 [thread overview]
Message-ID: <20200714140534.GB14404@linux.intel.com> (raw)
In-Reply-To: <20200714134123.022b3117@ibm-vm>
On Tue, Jul 14, 2020 at 01:41:23PM +0200, Claudio Imbrenda wrote:
> On Tue, 14 Jul 2020 13:20:16 +0200
> Thomas Huth <thuth@redhat.com> wrote:
>
> > On 14/07/2020 13.09, Claudio Imbrenda wrote:
> > > The assert in lib/alloc_page is hardcoded to long, and size_t is
> > > just an int on 32 bit architectures.
> > >
> > > Adding a cast makes the compiler happy.
> > >
> > > Fixes: 73f4b202beb39 ("lib/alloc_page: change some parameter types")
> > > Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> > > ---
> > > lib/alloc_page.c | 5 +++--
> > > 1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/lib/alloc_page.c b/lib/alloc_page.c
> > > index fa3c527..617b003 100644
> > > --- a/lib/alloc_page.c
> > > +++ b/lib/alloc_page.c
> > > @@ -29,11 +29,12 @@ void free_pages(void *mem, size_t size)
> > > assert_msg((unsigned long) mem % PAGE_SIZE == 0,
> > > "mem not page aligned: %p", mem);
> > >
> > > - assert_msg(size % PAGE_SIZE == 0, "size not page aligned:
> > > %#lx", size);
> > > + assert_msg(size % PAGE_SIZE == 0, "size not page aligned:
> > > %#lx",
> > > + (unsigned long)size);
> > >
> > > assert_msg(size == 0 || (uintptr_t)mem == -size ||
> > > (uintptr_t)mem + size > (uintptr_t)mem,
> > > - "mem + size overflow: %p + %#lx", mem, size);
> > > + "mem + size overflow: %p + %#lx", mem,
> > > (unsigned long)size);
> >
> > Looking at lib/printf.c, it seems like it also supports %z ... have
> > you tried?
>
> no, but in hindsight I should have. It's probably a much cleaner
> solution. I'll try and respin.
I'm not opposed to using size_t, but if we go that route then the entirety
of alloc_page.c should be converted to size_t. As is, there is code like:
void free_pages_by_order(void *mem, unsigned int order)
{
free_pages(mem, 1ul << (order + PAGE_SHIFT));
}
and
void *alloc_pages(unsigned int order)
{
...
/* Looking for a run of length (1 << order). */
unsigned long run = 0;
const unsigned long n = 1ul << order;
const unsigned long align_mask = (n << PAGE_SHIFT) - 1;
void *run_start = NULL;
void *run_prev = NULL;
unsigned long run_next_pa = 0;
unsigned long pa;
assert(order < sizeof(unsigned long) * 8);
...
}
that very explicitly uses 'unsigned long' for the size.
next prev parent reply other threads:[~2020-07-14 14:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-14 11:09 [kvm-unit-tests PATCH v1 0/2] Fix some compilation issues on 32bit Claudio Imbrenda
2020-07-14 11:09 ` [kvm-unit-tests PATCH v1 1/2] x86/cstart: Fix compilation issue in 32 bit mode Claudio Imbrenda
2020-07-14 11:09 ` [kvm-unit-tests PATCH v1 2/2] lib/alloc_page: Fix compilation issue on 32bit archs Claudio Imbrenda
2020-07-14 11:20 ` Thomas Huth
2020-07-14 11:41 ` Claudio Imbrenda
2020-07-14 14:05 ` Sean Christopherson [this message]
2020-07-14 14:11 ` Claudio Imbrenda
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=20200714140534.GB14404@linux.intel.com \
--to=sean.j.christopherson@intel.com \
--cc=david@redhat.com \
--cc=drjones@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=thuth@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox