diff mbox

[19/19] ppc: Rename ELF_MACHINE to be PPC specific

Message ID 83971ae84feec2ff2df8ed57a7f819f5d70232fc.1439679104.git.crosthwaite.peter@gmail.com
State New
Headers show

Commit Message

Peter Crosthwaite Aug. 15, 2015, 11:28 p.m. UTC
From: Peter Crosthwaite <crosthwaitepeter@gmail.com>

Rename ELF_MACHINE to be PPC specific. This is used as-is by the
various PPC bootloaders and is locally defined to ELF_MACHINE in linux
user in PPC specific ifdeffery.

This removes another architecture specific definition from the global
namespace (as desired by multi-arch).

Cc: Alexander Graf <agraf@suse.de>
Cc: qemu-ppc@nongnu.org
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
 hw/ppc/e500.c          | 2 +-
 hw/ppc/mac_newworld.c  | 4 ++--
 hw/ppc/mac_oldworld.c  | 4 ++--
 hw/ppc/ppc440_bamboo.c | 2 +-
 hw/ppc/prep.c          | 2 +-
 hw/ppc/spapr.c         | 4 ++--
 hw/ppc/virtex_ml507.c  | 2 +-
 linux-user/elfload.c   | 1 +
 target-ppc/cpu.h       | 4 ++--
 9 files changed, 13 insertions(+), 12 deletions(-)

Comments

Laurent Vivier Aug. 19, 2015, 1:04 a.m. UTC | #1
I'm wondering if the existing behavior is good:

what I have understood is we define ppc32 guests in ppc64 target to be
able to run 32bit guest with 64bit qemu, but I don't think it means an
oldworld mac is able to run a ppc64 kernel.

So I think we could use directly EM_PPC with e500, ppc440, virtex_ml507,
prep and oldworld, and EM_PPC64 with pseries/spapr. Newworld mac should
be able to run EM_PPC and EM_PPC64 kernel (G3/G4 <-> G5), according to
the machine type and not to the target.

Laurent

On 15/08/2015 16:28, Peter Crosthwaite wrote:
> From: Peter Crosthwaite <crosthwaitepeter@gmail.com>
> 
> Rename ELF_MACHINE to be PPC specific. This is used as-is by the
> various PPC bootloaders and is locally defined to ELF_MACHINE in linux
> user in PPC specific ifdeffery.
> 
> This removes another architecture specific definition from the global
> namespace (as desired by multi-arch).
> 
> Cc: Alexander Graf <agraf@suse.de>
> Cc: qemu-ppc@nongnu.org
> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
> ---
>  hw/ppc/e500.c          | 2 +-
>  hw/ppc/mac_newworld.c  | 4 ++--
>  hw/ppc/mac_oldworld.c  | 4 ++--
>  hw/ppc/ppc440_bamboo.c | 2 +-
>  hw/ppc/prep.c          | 2 +-
>  hw/ppc/spapr.c         | 4 ++--
>  hw/ppc/virtex_ml507.c  | 2 +-
>  linux-user/elfload.c   | 1 +
>  target-ppc/cpu.h       | 4 ++--
>  9 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
> index d300846..8b45bf6 100644
> --- a/hw/ppc/e500.c
> +++ b/hw/ppc/e500.c
> @@ -1017,7 +1017,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
>      filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
>  
>      bios_size = load_elf(filename, NULL, NULL, &bios_entry, &loadaddr, NULL,
> -                         1, ELF_MACHINE, 0);
> +                         1, PPC_ELF_MACHINE, 0);
>      if (bios_size < 0) {
>          /*
>           * Hrm. No ELF image? Try a uImage, maybe someone is giving us an
> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
> index 77d5c81..81d744c 100644
> --- a/hw/ppc/mac_newworld.c
> +++ b/hw/ppc/mac_newworld.c
> @@ -219,7 +219,7 @@ static void ppc_core99_init(MachineState *machine)
>      /* Load OpenBIOS (ELF) */
>      if (filename) {
>          bios_size = load_elf(filename, NULL, NULL, NULL,
> -                             NULL, NULL, 1, ELF_MACHINE, 0);
> +                             NULL, NULL, 1, PPC_ELF_MACHINE, 0);
>  
>          g_free(filename);
>      } else {
> @@ -242,7 +242,7 @@ static void ppc_core99_init(MachineState *machine)
>          kernel_base = KERNEL_LOAD_ADDR;
>  
>          kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
> -                               NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
> +                               NULL, &lowaddr, NULL, 1, PPC_ELF_MACHINE, 0);
>          if (kernel_size < 0)
>              kernel_size = load_aout(kernel_filename, kernel_base,
>                                      ram_size - kernel_base, bswap_needed,
> diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
> index 06fdbaf..00cb080 100644
> --- a/hw/ppc/mac_oldworld.c
> +++ b/hw/ppc/mac_oldworld.c
> @@ -147,7 +147,7 @@ static void ppc_heathrow_init(MachineState *machine)
>      /* Load OpenBIOS (ELF) */
>      if (filename) {
>          bios_size = load_elf(filename, 0, NULL, NULL, NULL, NULL,
> -                             1, ELF_MACHINE, 0);
> +                             1, PPC_ELF_MACHINE, 0);
>          g_free(filename);
>      } else {
>          bios_size = -1;
> @@ -168,7 +168,7 @@ static void ppc_heathrow_init(MachineState *machine)
>  #endif
>          kernel_base = KERNEL_LOAD_ADDR;
>          kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
> -                               NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
> +                               NULL, &lowaddr, NULL, 1, PPC_ELF_MACHINE, 0);
>          if (kernel_size < 0)
>              kernel_size = load_aout(kernel_filename, kernel_base,
>                                      ram_size - kernel_base, bswap_needed,
> diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
> index 032fa80..c54f79d 100644
> --- a/hw/ppc/ppc440_bamboo.c
> +++ b/hw/ppc/ppc440_bamboo.c
> @@ -256,7 +256,7 @@ static void bamboo_init(MachineState *machine)
>                                NULL, NULL);
>          if (success < 0) {
>              success = load_elf(kernel_filename, NULL, NULL, &elf_entry,
> -                               &elf_lowaddr, NULL, 1, ELF_MACHINE, 0);
> +                               &elf_lowaddr, NULL, 1, PPC_ELF_MACHINE, 0);
>              entry = elf_entry;
>              loadaddr = elf_lowaddr;
>          }
> diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
> index 45b5f62..b421bff 100644
> --- a/hw/ppc/prep.c
> +++ b/hw/ppc/prep.c
> @@ -610,7 +610,7 @@ static void ppc_prep_init(MachineState *machine)
>          bios_name = BIOS_FILENAME;
>      }
>      qdev_prop_set_string(dev, "bios-name", bios_name);
> -    qdev_prop_set_uint32(dev, "elf-machine", ELF_MACHINE);
> +    qdev_prop_set_uint32(dev, "elf-machine", PPC_ELF_MACHINE);
>      pcihost = PCI_HOST_BRIDGE(dev);
>      object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL);
>      qdev_init_nofail(dev);
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index bf0c64f..4500497 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1636,11 +1636,11 @@ static void ppc_spapr_init(MachineState *machine)
>          uint64_t lowaddr = 0;
>  
>          kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
> -                               NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
> +                               NULL, &lowaddr, NULL, 1, PPC_ELF_MACHINE, 0);
>          if (kernel_size == ELF_LOAD_WRONG_ENDIAN) {
>              kernel_size = load_elf(kernel_filename,
>                                     translate_kernel_address, NULL,
> -                                   NULL, &lowaddr, NULL, 0, ELF_MACHINE, 0);
> +                                   NULL, &lowaddr, NULL, 0, PPC_ELF_MACHINE, 0);
>              kernel_le = kernel_size > 0;
>          }
>          if (kernel_size < 0) {
> diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
> index de86f7c..d3cf437 100644
> --- a/hw/ppc/virtex_ml507.c
> +++ b/hw/ppc/virtex_ml507.c
> @@ -257,7 +257,7 @@ static void virtex_init(MachineState *machine)
>  
>          /* Boots a kernel elf binary.  */
>          kernel_size = load_elf(kernel_filename, NULL, NULL,
> -                               &entry, &low, &high, 1, ELF_MACHINE, 0);
> +                               &entry, &low, &high, 1, PPC_ELF_MACHINE, 0);
>          boot_info.bootstrap_pc = entry & 0x00ffffff;
>  
>          if (kernel_size < 0) {
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index 09e1e6a..4ade8e9 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -678,6 +678,7 @@ static inline void init_thread(struct target_pt_regs *regs,
>  
>  #ifdef TARGET_PPC
>  
> +#define ELF_MACHINE    PPC_ELF_MACHINE
>  #define ELF_START_MMAP 0x80000000
>  
>  #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
> diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
> index 6f76674..2bb3934 100644
> --- a/target-ppc/cpu.h
> +++ b/target-ppc/cpu.h
> @@ -81,9 +81,9 @@
>  #include "fpu/softfloat.h"
>  
>  #if defined (TARGET_PPC64)
> -#define ELF_MACHINE     EM_PPC64
> +#define PPC_ELF_MACHINE     EM_PPC64
>  #else
> -#define ELF_MACHINE     EM_PPC
> +#define PPC_ELF_MACHINE     EM_PPC
>  #endif
>  
>  /*****************************************************************************/
>
Peter Crosthwaite Sept. 7, 2015, 5:04 a.m. UTC | #2
On Tue, Aug 18, 2015 at 6:04 PM, Laurent Vivier <lvivier@redhat.com> wrote:
> I'm wondering if the existing behavior is good:
>
> what I have understood is we define ppc32 guests in ppc64 target to be
> able to run 32bit guest with 64bit qemu, but I don't think it means an
> oldworld mac is able to run a ppc64 kernel.
>
> So I think we could use directly EM_PPC with e500, ppc440, virtex_ml507,

Definitely right for virtex_ml507.

> prep and oldworld, and EM_PPC64 with pseries/spapr. Newworld mac should
> be able to run EM_PPC and EM_PPC64 kernel (G3/G4 <-> G5), according to
> the machine type and not to the target.
>

Sounds good, can the PPC maintainers give a nod to this idea?
Otherwise I'd like to run with the patch as is, as the patch as-is is
non-functional which is the intent of the overall series.

Regards,
Peter

> Laurent
>
> On 15/08/2015 16:28, Peter Crosthwaite wrote:
>> From: Peter Crosthwaite <crosthwaitepeter@gmail.com>
>>
>> Rename ELF_MACHINE to be PPC specific. This is used as-is by the
>> various PPC bootloaders and is locally defined to ELF_MACHINE in linux
>> user in PPC specific ifdeffery.
>>
>> This removes another architecture specific definition from the global
>> namespace (as desired by multi-arch).
>>
>> Cc: Alexander Graf <agraf@suse.de>
>> Cc: qemu-ppc@nongnu.org
>> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
>> ---
>>  hw/ppc/e500.c          | 2 +-
>>  hw/ppc/mac_newworld.c  | 4 ++--
>>  hw/ppc/mac_oldworld.c  | 4 ++--
>>  hw/ppc/ppc440_bamboo.c | 2 +-
>>  hw/ppc/prep.c          | 2 +-
>>  hw/ppc/spapr.c         | 4 ++--
>>  hw/ppc/virtex_ml507.c  | 2 +-
>>  linux-user/elfload.c   | 1 +
>>  target-ppc/cpu.h       | 4 ++--
>>  9 files changed, 13 insertions(+), 12 deletions(-)
>>
>> diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
>> index d300846..8b45bf6 100644
>> --- a/hw/ppc/e500.c
>> +++ b/hw/ppc/e500.c
>> @@ -1017,7 +1017,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
>>      filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
>>
>>      bios_size = load_elf(filename, NULL, NULL, &bios_entry, &loadaddr, NULL,
>> -                         1, ELF_MACHINE, 0);
>> +                         1, PPC_ELF_MACHINE, 0);
>>      if (bios_size < 0) {
>>          /*
>>           * Hrm. No ELF image? Try a uImage, maybe someone is giving us an
>> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
>> index 77d5c81..81d744c 100644
>> --- a/hw/ppc/mac_newworld.c
>> +++ b/hw/ppc/mac_newworld.c
>> @@ -219,7 +219,7 @@ static void ppc_core99_init(MachineState *machine)
>>      /* Load OpenBIOS (ELF) */
>>      if (filename) {
>>          bios_size = load_elf(filename, NULL, NULL, NULL,
>> -                             NULL, NULL, 1, ELF_MACHINE, 0);
>> +                             NULL, NULL, 1, PPC_ELF_MACHINE, 0);
>>
>>          g_free(filename);
>>      } else {
>> @@ -242,7 +242,7 @@ static void ppc_core99_init(MachineState *machine)
>>          kernel_base = KERNEL_LOAD_ADDR;
>>
>>          kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
>> -                               NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
>> +                               NULL, &lowaddr, NULL, 1, PPC_ELF_MACHINE, 0);
>>          if (kernel_size < 0)
>>              kernel_size = load_aout(kernel_filename, kernel_base,
>>                                      ram_size - kernel_base, bswap_needed,
>> diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
>> index 06fdbaf..00cb080 100644
>> --- a/hw/ppc/mac_oldworld.c
>> +++ b/hw/ppc/mac_oldworld.c
>> @@ -147,7 +147,7 @@ static void ppc_heathrow_init(MachineState *machine)
>>      /* Load OpenBIOS (ELF) */
>>      if (filename) {
>>          bios_size = load_elf(filename, 0, NULL, NULL, NULL, NULL,
>> -                             1, ELF_MACHINE, 0);
>> +                             1, PPC_ELF_MACHINE, 0);
>>          g_free(filename);
>>      } else {
>>          bios_size = -1;
>> @@ -168,7 +168,7 @@ static void ppc_heathrow_init(MachineState *machine)
>>  #endif
>>          kernel_base = KERNEL_LOAD_ADDR;
>>          kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
>> -                               NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
>> +                               NULL, &lowaddr, NULL, 1, PPC_ELF_MACHINE, 0);
>>          if (kernel_size < 0)
>>              kernel_size = load_aout(kernel_filename, kernel_base,
>>                                      ram_size - kernel_base, bswap_needed,
>> diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
>> index 032fa80..c54f79d 100644
>> --- a/hw/ppc/ppc440_bamboo.c
>> +++ b/hw/ppc/ppc440_bamboo.c
>> @@ -256,7 +256,7 @@ static void bamboo_init(MachineState *machine)
>>                                NULL, NULL);
>>          if (success < 0) {
>>              success = load_elf(kernel_filename, NULL, NULL, &elf_entry,
>> -                               &elf_lowaddr, NULL, 1, ELF_MACHINE, 0);
>> +                               &elf_lowaddr, NULL, 1, PPC_ELF_MACHINE, 0);
>>              entry = elf_entry;
>>              loadaddr = elf_lowaddr;
>>          }
>> diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
>> index 45b5f62..b421bff 100644
>> --- a/hw/ppc/prep.c
>> +++ b/hw/ppc/prep.c
>> @@ -610,7 +610,7 @@ static void ppc_prep_init(MachineState *machine)
>>          bios_name = BIOS_FILENAME;
>>      }
>>      qdev_prop_set_string(dev, "bios-name", bios_name);
>> -    qdev_prop_set_uint32(dev, "elf-machine", ELF_MACHINE);
>> +    qdev_prop_set_uint32(dev, "elf-machine", PPC_ELF_MACHINE);
>>      pcihost = PCI_HOST_BRIDGE(dev);
>>      object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL);
>>      qdev_init_nofail(dev);
>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>> index bf0c64f..4500497 100644
>> --- a/hw/ppc/spapr.c
>> +++ b/hw/ppc/spapr.c
>> @@ -1636,11 +1636,11 @@ static void ppc_spapr_init(MachineState *machine)
>>          uint64_t lowaddr = 0;
>>
>>          kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
>> -                               NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
>> +                               NULL, &lowaddr, NULL, 1, PPC_ELF_MACHINE, 0);
>>          if (kernel_size == ELF_LOAD_WRONG_ENDIAN) {
>>              kernel_size = load_elf(kernel_filename,
>>                                     translate_kernel_address, NULL,
>> -                                   NULL, &lowaddr, NULL, 0, ELF_MACHINE, 0);
>> +                                   NULL, &lowaddr, NULL, 0, PPC_ELF_MACHINE, 0);
>>              kernel_le = kernel_size > 0;
>>          }
>>          if (kernel_size < 0) {
>> diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
>> index de86f7c..d3cf437 100644
>> --- a/hw/ppc/virtex_ml507.c
>> +++ b/hw/ppc/virtex_ml507.c
>> @@ -257,7 +257,7 @@ static void virtex_init(MachineState *machine)
>>
>>          /* Boots a kernel elf binary.  */
>>          kernel_size = load_elf(kernel_filename, NULL, NULL,
>> -                               &entry, &low, &high, 1, ELF_MACHINE, 0);
>> +                               &entry, &low, &high, 1, PPC_ELF_MACHINE, 0);
>>          boot_info.bootstrap_pc = entry & 0x00ffffff;
>>
>>          if (kernel_size < 0) {
>> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
>> index 09e1e6a..4ade8e9 100644
>> --- a/linux-user/elfload.c
>> +++ b/linux-user/elfload.c
>> @@ -678,6 +678,7 @@ static inline void init_thread(struct target_pt_regs *regs,
>>
>>  #ifdef TARGET_PPC
>>
>> +#define ELF_MACHINE    PPC_ELF_MACHINE
>>  #define ELF_START_MMAP 0x80000000
>>
>>  #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
>> diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
>> index 6f76674..2bb3934 100644
>> --- a/target-ppc/cpu.h
>> +++ b/target-ppc/cpu.h
>> @@ -81,9 +81,9 @@
>>  #include "fpu/softfloat.h"
>>
>>  #if defined (TARGET_PPC64)
>> -#define ELF_MACHINE     EM_PPC64
>> +#define PPC_ELF_MACHINE     EM_PPC64
>>  #else
>> -#define ELF_MACHINE     EM_PPC
>> +#define PPC_ELF_MACHINE     EM_PPC
>>  #endif
>>
>>  /*****************************************************************************/
>>
Alexander Graf Sept. 7, 2015, 9:32 a.m. UTC | #3
On 07.09.15 07:04, Peter Crosthwaite wrote:
> On Tue, Aug 18, 2015 at 6:04 PM, Laurent Vivier <lvivier@redhat.com> wrote:
>> I'm wondering if the existing behavior is good:
>>
>> what I have understood is we define ppc32 guests in ppc64 target to be
>> able to run 32bit guest with 64bit qemu, but I don't think it means an
>> oldworld mac is able to run a ppc64 kernel.
>>
>> So I think we could use directly EM_PPC with e500, ppc440, virtex_ml507,
> 
> Definitely right for virtex_ml507.
> 
>> prep and oldworld, and EM_PPC64 with pseries/spapr. Newworld mac should
>> be able to run EM_PPC and EM_PPC64 kernel (G3/G4 <-> G5), according to
>> the machine type and not to the target.
>>
> 
> Sounds good, can the PPC maintainers give a nod to this idea?
> Otherwise I'd like to run with the patch as is, as the patch as-is is
> non-functional which is the intent of the overall series.

I think the idea is sound, but I'd prefer to see it as a follow-up patch
converting each machine individually. That way bisecting things will be
easier and if we have to revert anything, we only revert the functional
change.


Alex
diff mbox

Patch

diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index d300846..8b45bf6 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -1017,7 +1017,7 @@  void ppce500_init(MachineState *machine, PPCE500Params *params)
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
 
     bios_size = load_elf(filename, NULL, NULL, &bios_entry, &loadaddr, NULL,
-                         1, ELF_MACHINE, 0);
+                         1, PPC_ELF_MACHINE, 0);
     if (bios_size < 0) {
         /*
          * Hrm. No ELF image? Try a uImage, maybe someone is giving us an
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 77d5c81..81d744c 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -219,7 +219,7 @@  static void ppc_core99_init(MachineState *machine)
     /* Load OpenBIOS (ELF) */
     if (filename) {
         bios_size = load_elf(filename, NULL, NULL, NULL,
-                             NULL, NULL, 1, ELF_MACHINE, 0);
+                             NULL, NULL, 1, PPC_ELF_MACHINE, 0);
 
         g_free(filename);
     } else {
@@ -242,7 +242,7 @@  static void ppc_core99_init(MachineState *machine)
         kernel_base = KERNEL_LOAD_ADDR;
 
         kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
-                               NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
+                               NULL, &lowaddr, NULL, 1, PPC_ELF_MACHINE, 0);
         if (kernel_size < 0)
             kernel_size = load_aout(kernel_filename, kernel_base,
                                     ram_size - kernel_base, bswap_needed,
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index 06fdbaf..00cb080 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -147,7 +147,7 @@  static void ppc_heathrow_init(MachineState *machine)
     /* Load OpenBIOS (ELF) */
     if (filename) {
         bios_size = load_elf(filename, 0, NULL, NULL, NULL, NULL,
-                             1, ELF_MACHINE, 0);
+                             1, PPC_ELF_MACHINE, 0);
         g_free(filename);
     } else {
         bios_size = -1;
@@ -168,7 +168,7 @@  static void ppc_heathrow_init(MachineState *machine)
 #endif
         kernel_base = KERNEL_LOAD_ADDR;
         kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
-                               NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
+                               NULL, &lowaddr, NULL, 1, PPC_ELF_MACHINE, 0);
         if (kernel_size < 0)
             kernel_size = load_aout(kernel_filename, kernel_base,
                                     ram_size - kernel_base, bswap_needed,
diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
index 032fa80..c54f79d 100644
--- a/hw/ppc/ppc440_bamboo.c
+++ b/hw/ppc/ppc440_bamboo.c
@@ -256,7 +256,7 @@  static void bamboo_init(MachineState *machine)
                               NULL, NULL);
         if (success < 0) {
             success = load_elf(kernel_filename, NULL, NULL, &elf_entry,
-                               &elf_lowaddr, NULL, 1, ELF_MACHINE, 0);
+                               &elf_lowaddr, NULL, 1, PPC_ELF_MACHINE, 0);
             entry = elf_entry;
             loadaddr = elf_lowaddr;
         }
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 45b5f62..b421bff 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -610,7 +610,7 @@  static void ppc_prep_init(MachineState *machine)
         bios_name = BIOS_FILENAME;
     }
     qdev_prop_set_string(dev, "bios-name", bios_name);
-    qdev_prop_set_uint32(dev, "elf-machine", ELF_MACHINE);
+    qdev_prop_set_uint32(dev, "elf-machine", PPC_ELF_MACHINE);
     pcihost = PCI_HOST_BRIDGE(dev);
     object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL);
     qdev_init_nofail(dev);
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index bf0c64f..4500497 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1636,11 +1636,11 @@  static void ppc_spapr_init(MachineState *machine)
         uint64_t lowaddr = 0;
 
         kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
-                               NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
+                               NULL, &lowaddr, NULL, 1, PPC_ELF_MACHINE, 0);
         if (kernel_size == ELF_LOAD_WRONG_ENDIAN) {
             kernel_size = load_elf(kernel_filename,
                                    translate_kernel_address, NULL,
-                                   NULL, &lowaddr, NULL, 0, ELF_MACHINE, 0);
+                                   NULL, &lowaddr, NULL, 0, PPC_ELF_MACHINE, 0);
             kernel_le = kernel_size > 0;
         }
         if (kernel_size < 0) {
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
index de86f7c..d3cf437 100644
--- a/hw/ppc/virtex_ml507.c
+++ b/hw/ppc/virtex_ml507.c
@@ -257,7 +257,7 @@  static void virtex_init(MachineState *machine)
 
         /* Boots a kernel elf binary.  */
         kernel_size = load_elf(kernel_filename, NULL, NULL,
-                               &entry, &low, &high, 1, ELF_MACHINE, 0);
+                               &entry, &low, &high, 1, PPC_ELF_MACHINE, 0);
         boot_info.bootstrap_pc = entry & 0x00ffffff;
 
         if (kernel_size < 0) {
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 09e1e6a..4ade8e9 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -678,6 +678,7 @@  static inline void init_thread(struct target_pt_regs *regs,
 
 #ifdef TARGET_PPC
 
+#define ELF_MACHINE    PPC_ELF_MACHINE
 #define ELF_START_MMAP 0x80000000
 
 #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index 6f76674..2bb3934 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -81,9 +81,9 @@ 
 #include "fpu/softfloat.h"
 
 #if defined (TARGET_PPC64)
-#define ELF_MACHINE     EM_PPC64
+#define PPC_ELF_MACHINE     EM_PPC64
 #else
-#define ELF_MACHINE     EM_PPC
+#define PPC_ELF_MACHINE     EM_PPC
 #endif
 
 /*****************************************************************************/