[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/5] configure: move TARGET_*_ALIGNMENT to targe
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 1/5] configure: move TARGET_*_ALIGNMENT to target-*/cpu.h |
Date: |
Wed, 03 Apr 2013 10:55:42 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 |
Il 02/04/2013 19:47, Peter Maydell ha scritto:
> On 2 April 2013 18:26, Paolo Bonzini <address@hidden> wrote:
>> I think "a thing the size of a pointer" should be abi_long/ulong. The
>> pointer is not a CPU concept.
>
> Yeah. OTOH type alignment isn't a CPU concept either, so I'm
> a little suspicious of these defines in general.
Ok, the main case where the target alignment matters is in 'struct
target_elf_prstatus' (linux-user/elfload.c).
Linux, in its n32 implementation, explicitly uses a different struct
that changes some longs to ints (pr_sigpend, pr_sighold, pr_flag) and
keeps longs for others (pr_reg).
---
typedef unsigned long elf_greg_t;
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
#define elf_prstatus elf_prstatus32
struct elf_prstatus32
{
struct elf_siginfo pr_info;
short pr_cursig; /* Current signal */
unsigned int pr_sigpend; /* Set of pending signals */
unsigned int pr_sighold; /* Set of held signals */
pid_t pr_pid;
pid_t pr_ppid;
pid_t pr_pgrp;
pid_t pr_sid;
struct compat_timeval pr_utime; /* User time */
struct compat_timeval pr_stime; /* System time */
struct compat_timeval pr_cutime;/* Cumulative user time */
struct compat_timeval pr_cstime;/* Cumulative system time */
elf_gregset_t pr_reg; /* GP registers */
int pr_fpvalid;
};
---
Instead, we use target_ulong for both (possibly via the
target_elf_greg_t typedef).
sparc32plus and ppc64abi32 instead use 32-bit for pr_reg too (see
include/linux/elfcore-compat.h and fs/compat_binfmt_elf.c). This is
also wrong.
In any case, what we are doing is doubly wrong. Things that have 4-byte
alignment should also have 4-byte size. Things that have 8-byte
alignment should also have 8-byte size.
Paolo
[Qemu-devel] [PATCH 3/5] configure: move CONFIG_QEMU_LDST_OPTIMIZATION to config-host.mak, Paolo Bonzini, 2013/04/02
[Qemu-devel] [PATCH 4/5] configure: move common libraries to config-host.mak, Paolo Bonzini, 2013/04/02
[Qemu-devel] [PATCH 2/5] cpu: default TARGET_LONG_ALIGNMENT to TARGET_LONG_SIZE, Paolo Bonzini, 2013/04/02