All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] ARM hosts: code_gen_alloc() maps code buffer on top of libc heap
@ 2011-10-28 14:32 Peter Maydell
  2011-10-28 16:14 ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2011-10-28 14:32 UTC (permalink / raw)
  To: QEMU Developers; +Cc: David Gilbert

I've been tracking down a bug where qemu run on ARM hosts will
(about half of the time) abort early in execution with:

qemu-system-i386: malloc.c:3096: sYSMALLOc: Assertion `(old_top ==
(((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) -
__builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) ||
((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof
(struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) &
~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) &&
((unsigned long)old_end & pagemask) == 0)' failed.

This turns out to be because code_gen_alloc() is using
mmap(MAP_FIXED) to map the code buffer at address
0x01000000UL, which is in the area glibc happens to be using
for its heap. This tends to make the next malloc() abort,
although occasionally the stars align and we pass that
and fail weirdly later on.

I suspect we need to drop the MAP_FIXED requirement and
fix the TCG code to cope with emitting code for longer-range
branches for calls to host fns etc (calls/branches within the
generated code should be ok to keep using the short-range
branch insn I think). There is already no guarantee that
the generated code and the host C code are within short
branch range of each other...

-- PMM

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

* Re: [Qemu-devel] ARM hosts: code_gen_alloc() maps code buffer on top of libc heap
  2011-10-28 14:32 [Qemu-devel] ARM hosts: code_gen_alloc() maps code buffer on top of libc heap Peter Maydell
@ 2011-10-28 16:14 ` Paolo Bonzini
  2011-10-28 16:32   ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2011-10-28 16:14 UTC (permalink / raw)
  To: Peter Maydell; +Cc: David Gilbert, QEMU Developers

On 10/28/2011 04:32 PM, Peter Maydell wrote:
>
> I suspect we need to drop the MAP_FIXED requirement and
> fix the TCG code to cope with emitting code for longer-range
> branches for calls to host fns etc (calls/branches within the
> generated code should be ok to keep using the short-range
> branch insn I think). There is already no guarantee that
> the generated code and the host C code are within short
> branch range of each other...

Does USE_STATIC_CODE_GEN_BUFFER fix it?  Do you know why "Currently it 
is not recommended to allocate big chunks of data in user mode"?

Paolo

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

* Re: [Qemu-devel] ARM hosts: code_gen_alloc() maps code buffer on top of libc heap
  2011-10-28 16:14 ` Paolo Bonzini
@ 2011-10-28 16:32   ` Peter Maydell
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2011-10-28 16:32 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: David Gilbert, QEMU Developers

On 28 October 2011 17:14, Paolo Bonzini <pbonzini@redhat.com> wrote:
> On 10/28/2011 04:32 PM, Peter Maydell wrote:
>>
>> I suspect we need to drop the MAP_FIXED requirement and
>> fix the TCG code to cope with emitting code for longer-range
>> branches for calls to host fns etc (calls/branches within the
>> generated code should be ok to keep using the short-range
>> branch insn I think). There is already no guarantee that
>> the generated code and the host C code are within short
>> branch range of each other...
>
> Does USE_STATIC_CODE_GEN_BUFFER fix it?

Well, it avoids the malloc abort. We seem to get stuck in an
infinite cycle of the guest trying to start grub and rebooting
before it manages to print the blue-background grub menu screen,
though, so something's still not right. Likely a different bug,
though.

> Do you know why "Currently it is
> not recommended to allocate big chunks of data in user mode"?

Don't know, but my guess is that it is or was likely to clash
with attempts to put the guest binary in the right place in
the address space.

-- PMM

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

end of thread, other threads:[~2011-10-28 16:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-28 14:32 [Qemu-devel] ARM hosts: code_gen_alloc() maps code buffer on top of libc heap Peter Maydell
2011-10-28 16:14 ` Paolo Bonzini
2011-10-28 16:32   ` Peter Maydell

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.