qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] linux-user: ppc: mark as long long aligned
@ 2012-09-30  1:32 Alexander Graf
  2012-09-30  1:32 ` [Qemu-devel] [PATCH 2/2] linux-user: register align p{read, write}64 Alexander Graf
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Alexander Graf @ 2012-09-30  1:32 UTC (permalink / raw)
  To: qemu-devel qemu-devel
  Cc: Peter Maydell, Riku Voipio, qemu-ppc@nongnu.org List

The PPC32 ABI dictates that long long (64bit) parameters are pass in odd/even
register pairs. Because unlike ARM and MIPS we start at an odd register number,
we can reuse the same aligning code that ARM and MIPS use.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 linux-user/syscall.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 1a38169..8cd56f2 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -587,12 +587,16 @@ extern int setfsgid(int);
 extern int setgroups(int, gid_t *);
 
 /* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */
-#ifdef TARGET_ARM 
+#ifdef TARGET_ARM
 static inline int regpairs_aligned(void *cpu_env) {
     return ((((CPUARMState *)cpu_env)->eabi) == 1) ;
 }
 #elif defined(TARGET_MIPS)
 static inline int regpairs_aligned(void *cpu_env) { return 1; }
+#elif defined(TARGET_PPC) && !defined(TARGET_PPC64)
+/* PPC32 expects 64bit parameters to be passed on odd/even pairs of registers
+   which translates to the same as ARM/MIPS, because we start with r3 as arg1 */
+static inline int regpairs_aligned(void *cpu_env) { return 1; }
 #else
 static inline int regpairs_aligned(void *cpu_env) { return 0; }
 #endif
-- 
1.6.0.2

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

* [Qemu-devel] [PATCH 2/2] linux-user: register align p{read, write}64
  2012-09-30  1:32 [Qemu-devel] [PATCH 1/2] linux-user: ppc: mark as long long aligned Alexander Graf
@ 2012-09-30  1:32 ` Alexander Graf
  2012-10-01 17:31   ` Alex Barcelo
  2012-10-12 11:42   ` Peter Maydell
  2012-10-01 13:04 ` [Qemu-devel] [PATCH 1/2] linux-user: ppc: mark as long long aligned Andreas Färber
  2012-10-01 17:27 ` malc
  2 siblings, 2 replies; 7+ messages in thread
From: Alexander Graf @ 2012-09-30  1:32 UTC (permalink / raw)
  To: qemu-devel qemu-devel
  Cc: Peter Maydell, Riku Voipio, qemu-ppc@nongnu.org List

pread64 and pwrite64 pass 64bit parameters which for some architectures need
to be aligned to special argument pairs, creating a gap argument.

Handle this special case the same way we handle it in other places of the code.

Reported-by: Alex Barcelo <abarcelo@ac.upc.edu>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 linux-user/syscall.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8cd56f2..7992b1b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7423,12 +7423,20 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_pread64
     case TARGET_NR_pread64:
+        if (regpairs_aligned(cpu_env)) {
+            arg4 = arg5;
+            arg5 = arg6;
+        }
         if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
             goto efault;
         ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5)));
         unlock_user(p, arg2, ret);
         break;
     case TARGET_NR_pwrite64:
+        if (regpairs_aligned(cpu_env)) {
+            arg4 = arg5;
+            arg5 = arg6;
+        }
         if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
             goto efault;
         ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5)));
-- 
1.6.0.2

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

* Re: [Qemu-devel] [PATCH 1/2] linux-user: ppc: mark as long long aligned
  2012-09-30  1:32 [Qemu-devel] [PATCH 1/2] linux-user: ppc: mark as long long aligned Alexander Graf
  2012-09-30  1:32 ` [Qemu-devel] [PATCH 2/2] linux-user: register align p{read, write}64 Alexander Graf
@ 2012-10-01 13:04 ` Andreas Färber
  2012-10-01 13:10   ` Alexander Graf
  2012-10-01 17:27 ` malc
  2 siblings, 1 reply; 7+ messages in thread
From: Andreas Färber @ 2012-10-01 13:04 UTC (permalink / raw)
  To: Alexander Graf
  Cc: Peter Maydell, Riku Voipio, qemu-ppc@nongnu.org List,
	qemu-devel qemu-devel

Am 30.09.2012 03:32, schrieb Alexander Graf:
> The PPC32 ABI dictates that long long (64bit) parameters are pass in odd/even
> register pairs. Because unlike ARM and MIPS we start at an odd register number,
> we can reuse the same aligning code that ARM and MIPS use.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  linux-user/syscall.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 1a38169..8cd56f2 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -587,12 +587,16 @@ extern int setfsgid(int);
>  extern int setgroups(int, gid_t *);
>  
>  /* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */
> -#ifdef TARGET_ARM 
> +#ifdef TARGET_ARM

For anyone wondering, this is dropping a whitespace at end of line. ;)

>  static inline int regpairs_aligned(void *cpu_env) {
>      return ((((CPUARMState *)cpu_env)->eabi) == 1) ;
>  }
>  #elif defined(TARGET_MIPS)
>  static inline int regpairs_aligned(void *cpu_env) { return 1; }
> +#elif defined(TARGET_PPC) && !defined(TARGET_PPC64)
> +/* PPC32 expects 64bit parameters to be passed on odd/even pairs of registers
> +   which translates to the same as ARM/MIPS, because we start with r3 as arg1 */
> +static inline int regpairs_aligned(void *cpu_env) { return 1; }
>  #else
>  static inline int regpairs_aligned(void *cpu_env) { return 0; }
>  #endif

It is obvious that this function has been copied unmodified from mips,
but shouldn't new code use bool and true, assuming that there is no
magic performed on the return value? :)

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [PATCH 1/2] linux-user: ppc: mark as long long aligned
  2012-10-01 13:04 ` [Qemu-devel] [PATCH 1/2] linux-user: ppc: mark as long long aligned Andreas Färber
@ 2012-10-01 13:10   ` Alexander Graf
  0 siblings, 0 replies; 7+ messages in thread
From: Alexander Graf @ 2012-10-01 13:10 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Peter Maydell, Riku Voipio, qemu-ppc@nongnu.org List,
	qemu-devel qemu-devel


On 01.10.2012, at 15:04, Andreas Färber wrote:

> Am 30.09.2012 03:32, schrieb Alexander Graf:
>> The PPC32 ABI dictates that long long (64bit) parameters are pass in odd/even
>> register pairs. Because unlike ARM and MIPS we start at an odd register number,
>> we can reuse the same aligning code that ARM and MIPS use.
>> 
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>> ---
>> linux-user/syscall.c |    6 +++++-
>> 1 files changed, 5 insertions(+), 1 deletions(-)
>> 
>> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
>> index 1a38169..8cd56f2 100644
>> --- a/linux-user/syscall.c
>> +++ b/linux-user/syscall.c
>> @@ -587,12 +587,16 @@ extern int setfsgid(int);
>> extern int setgroups(int, gid_t *);
>> 
>> /* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */
>> -#ifdef TARGET_ARM 
>> +#ifdef TARGET_ARM
> 
> For anyone wondering, this is dropping a whitespace at end of line. ;)

Yeah, my vi scripts marked it as red, which always makes me nervous :).

> 
>> static inline int regpairs_aligned(void *cpu_env) {
>>     return ((((CPUARMState *)cpu_env)->eabi) == 1) ;
>> }
>> #elif defined(TARGET_MIPS)
>> static inline int regpairs_aligned(void *cpu_env) { return 1; }
>> +#elif defined(TARGET_PPC) && !defined(TARGET_PPC64)
>> +/* PPC32 expects 64bit parameters to be passed on odd/even pairs of registers
>> +   which translates to the same as ARM/MIPS, because we start with r3 as arg1 */
>> +static inline int regpairs_aligned(void *cpu_env) { return 1; }
>> #else
>> static inline int regpairs_aligned(void *cpu_env) { return 0; }
>> #endif
> 
> It is obvious that this function has been copied unmodified from mips,
> but shouldn't new code use bool and true, assuming that there is no
> magic performed on the return value? :)

The asm result should be the same, since they're all getting inlined, no? And it wouldn't tremendously increase readability either. So for now, I'd say either

  a) send a separate cleanup patch

or

  b) leave it as is :)


Alex

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

* Re: [Qemu-devel] [PATCH 1/2] linux-user: ppc: mark as long long aligned
  2012-09-30  1:32 [Qemu-devel] [PATCH 1/2] linux-user: ppc: mark as long long aligned Alexander Graf
  2012-09-30  1:32 ` [Qemu-devel] [PATCH 2/2] linux-user: register align p{read, write}64 Alexander Graf
  2012-10-01 13:04 ` [Qemu-devel] [PATCH 1/2] linux-user: ppc: mark as long long aligned Andreas Färber
@ 2012-10-01 17:27 ` malc
  2 siblings, 0 replies; 7+ messages in thread
From: malc @ 2012-10-01 17:27 UTC (permalink / raw)
  To: Alexander Graf
  Cc: Peter Maydell, Riku Voipio, qemu-ppc@nongnu.org List,
	qemu-devel qemu-devel

On Sun, 30 Sep 2012, Alexander Graf wrote:

> The PPC32 ABI dictates that long long (64bit) parameters are pass in odd/even
> register pairs. Because unlike ARM and MIPS we start at an odd register number,
> we can reuse the same aligning code that ARM and MIPS use.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  linux-user/syscall.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 1a38169..8cd56f2 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -587,12 +587,16 @@ extern int setfsgid(int);
>  extern int setgroups(int, gid_t *);
>  
>  /* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */
> -#ifdef TARGET_ARM 
> +#ifdef TARGET_ARM
>  static inline int regpairs_aligned(void *cpu_env) {
>      return ((((CPUARMState *)cpu_env)->eabi) == 1) ;
>  }
>  #elif defined(TARGET_MIPS)
>  static inline int regpairs_aligned(void *cpu_env) { return 1; }
> +#elif defined(TARGET_PPC) && !defined(TARGET_PPC64)
> +/* PPC32 expects 64bit parameters to be passed on odd/even pairs of registers
> +   which translates to the same as ARM/MIPS, because we start with r3 as arg1 */

This is inaccurate, PPC32 doesn't expect anything, SysV ABI for PPC32,
which linux uses, does. This is linux-user so SysV ABI is a given but
still i'd reword it.

> +static inline int regpairs_aligned(void *cpu_env) { return 1; }
>  #else
>  static inline int regpairs_aligned(void *cpu_env) { return 0; }
>  #endif
> 

-- 
mailto:av1474@comtv.ru

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

* Re: [Qemu-devel] [PATCH 2/2] linux-user: register align p{read, write}64
  2012-09-30  1:32 ` [Qemu-devel] [PATCH 2/2] linux-user: register align p{read, write}64 Alexander Graf
@ 2012-10-01 17:31   ` Alex Barcelo
  2012-10-12 11:42   ` Peter Maydell
  1 sibling, 0 replies; 7+ messages in thread
From: Alex Barcelo @ 2012-10-01 17:31 UTC (permalink / raw)
  To: Alexander Graf
  Cc: Peter Maydell, Riku Voipio, qemu-ppc@nongnu.org List,
	qemu-devel qemu-devel

On Sun, Sep 30, 2012 at 3:32 AM, Alexander Graf <agraf@suse.de> wrote:
> pread64 and pwrite64 pass 64bit parameters which for some architectures need
> to be aligned to special argument pairs, creating a gap argument.
>
> Handle this special case the same way we handle it in other places of the code.
>
> Reported-by: Alex Barcelo <abarcelo@ac.upc.edu>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  linux-user/syscall.c |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 8cd56f2..7992b1b 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -7423,12 +7423,20 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>  #endif
>  #ifdef TARGET_NR_pread64
>      case TARGET_NR_pread64:
> +        if (regpairs_aligned(cpu_env)) {
> +            arg4 = arg5;
> +            arg5 = arg6;
> +        }
>          if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
>              goto efault;
>          ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5)));
>          unlock_user(p, arg2, ret);
>          break;
>      case TARGET_NR_pwrite64:
> +        if (regpairs_aligned(cpu_env)) {
> +            arg4 = arg5;
> +            arg5 = arg6;
> +        }
>          if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
>              goto efault;
>          ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5)));
> --
> 1.6.0.2
>
>

Tested-by: Alex Barcelo <abarcelo@ac.upc.edu>

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

* Re: [Qemu-devel] [PATCH 2/2] linux-user: register align p{read, write}64
  2012-09-30  1:32 ` [Qemu-devel] [PATCH 2/2] linux-user: register align p{read, write}64 Alexander Graf
  2012-10-01 17:31   ` Alex Barcelo
@ 2012-10-12 11:42   ` Peter Maydell
  1 sibling, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2012-10-12 11:42 UTC (permalink / raw)
  To: Alexander Graf
  Cc: Riku Voipio, qemu-ppc@nongnu.org List, qemu-devel qemu-devel

On 30 September 2012 02:32, Alexander Graf <agraf@suse.de> wrote:
> pread64 and pwrite64 pass 64bit parameters which for some architectures need
> to be aligned to special argument pairs, creating a gap argument.
>
> Handle this special case the same way we handle it in other places of the code.
>
> Reported-by: Alex Barcelo <abarcelo@ac.upc.edu>
> Signed-off-by: Alexander Graf <agraf@suse.de>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

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

end of thread, other threads:[~2012-10-12 11:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-30  1:32 [Qemu-devel] [PATCH 1/2] linux-user: ppc: mark as long long aligned Alexander Graf
2012-09-30  1:32 ` [Qemu-devel] [PATCH 2/2] linux-user: register align p{read, write}64 Alexander Graf
2012-10-01 17:31   ` Alex Barcelo
2012-10-12 11:42   ` Peter Maydell
2012-10-01 13:04 ` [Qemu-devel] [PATCH 1/2] linux-user: ppc: mark as long long aligned Andreas Färber
2012-10-01 13:10   ` Alexander Graf
2012-10-01 17:27 ` malc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).