multi-arch+linux-user: Cleanup ELF_MACHINE
PATCH 1/19 linux_user: elfload: Default ELF_MACHINE to ELF_ARCH
In reply to Peter CrosthwaiteIn most (but not all) cases, ELF_MACHINE and ELF_ARCH are safely the same. Default ELF_MACHINE to ELF_ARCH. This makes defining ELF_MACHINE optional for target-*/cpu.h when they are known to match.
--- linux-user/elfload.c | 4 ++++ 1 file changed, 4 insertions(+)
linux-user/elfload.c +4 -0
@@ -1222,6 +1222,10 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i#define ELF_PLATFORM (NULL)#endif +#ifndef ELF_MACHINE +#define ELF_MACHINE ELF_ARCH +#endif +#ifndef ELF_HWCAP #define ELF_HWCAP 0#endif
Signature · 1 line
1.9.1
cover multi-arch+linux-user: Cleanup ELF_MACHINE
Every arch defines ELF_MACHINE in cpu.h to an arch-specific value. This definition is rarely needed by core code (only in a few cases). It conflicts with the multi-arch effort where cpu.h cannot export cpu specifics via macros like this. So remove ELF_MACHINE completely from all the cpu.h's.
Linux-user defines both ELF_ARCH and ELF_MACHINE, but for most cases they are the same. So provide a default of ELF_MACHINE == ELF_ARCH to handle most cases and just minimally define ELF_MACHINE locally in linux-user where there is a genuine difference.
While touching the code cleanup elf_check_arch in linux-user with a similar default-based system to minimise the boiler-plate for arch EM_ code.
Then go arch-by-arch to remove ELF_MACHINE from cpu.h. For many arches this causes the ELF_MACHINE == ELF_ARCH default to kick in. Some arches need their bootloader usages of ELF_MACHINE converted to use EM_FOO directly.
Alpha is unique, in that ELF_MACHINE is completely unused by existing code.
i386 and ppc are the most complex, where there is a genuine need to switch ELF_MACHINE depending on the target sub-arch. In these cases ELF_MACHINE if prefixed to be target specific. This will need further rethinking to get multi-arch support for those two arches.
There is an argument for keeping the per-arch definitions of the EM, but the correct place for this would be as virtual field in the QOM CPU class. Given the refactorings of the series this new field would be initially unused until we have the notion of a generic system mode bootloader or refactor linux-user boot to be more QOMified. So leaving the defs deleted for the moment for later revival.
Regards,
Peter
Peter Crosthwaite (19):
linux_user: elfload: Default ELF_MACHINE to ELF_ARCH
linux-user: elfload: Provide default for elf_check_arch
arm: Remove ELF_MACHINE from cpu.h
mb: Remove ELF_MACHINE from cpu.h
m68k: Remove ELF_MACHINE from cpu.h
cris: Remove ELF_MACHINE from cpu.h
moxie: Remove ELF_MACHINE from cpu.h
unicore: Remove ELF_MACHINE from cpu.h
lm32: Remove ELF_MACHINE from cpu.h
or32: Remove ELF_MACHINE from cpu.h
tricore: Remove ELF_MACHINE from cpu.h
xtensa: Remove ELF_MACHINE from cpu.h
sh4: Remove ELF_MACHINE from cpu.h
s390: Remove ELF_MACHINE from cpu.h
sparc: Remove ELF_MACHINE from cpu.h
mips: Remove ELF_MACHINE from cpu.h
alpha: Remove ELF_MACHINE from cpu.h
i386: Rename ELF_MACHINE to be x86 specific
ppc: Rename ELF_MACHINE to be PPC specific
hw/arm/armv7m.c | 2 +- hw/cris/boot.c | 2 +- hw/i386/multiboot.c | 2 +- hw/lm32/lm32_boards.c | 4 ++-- hw/lm32/milkymist.c | 2 +- hw/m68k/an5206.c | 2 +- hw/m68k/dummy_m68k.c | 2 +- hw/m68k/mcf5208.c | 2 +- hw/microblaze/boot.c | 4 ++-- hw/mips/mips_fulong2e.c | 2 +- hw/mips/mips_malta.c | 2 +- hw/mips/mips_mipssim.c | 2 +- hw/mips/mips_r4k.c | 2 +- hw/moxie/moxiesim.c | 2 +- hw/openrisc/openrisc_sim.c | 2 +- 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 +- hw/s390x/ipl.c | 4 ++-- hw/sparc/leon3.c | 2 +- hw/sparc/sun4m.c | 4 ++-- hw/sparc64/sun4u.c | 4 ++-- hw/tricore/tricore_testboard.c | 2 +- hw/xtensa/sim.c | 4 ++-- hw/xtensa/xtfpga.c | 2 +- linux-user/elfload.c | 37 +++++++++++-------------------------- target-alpha/cpu.h | 2 -- target-arm/cpu.h | 2 -- target-cris/cpu.h | 2 -- target-i386/cpu.h | 4 ++-- target-lm32/cpu.h | 2 -- target-m68k/cpu.h | 2 -- target-microblaze/cpu.h | 2 -- target-mips/cpu.h | 2 -- target-moxie/cpu.h | 2 -- target-openrisc/cpu.h | 1 - target-ppc/cpu.h | 4 ++-- target-s390x/cpu.h | 1 - target-sh4/cpu.h | 2 -- target-sparc/cpu.h | 6 ------ target-tricore/cpu.h | 2 -- target-unicore32/cpu.h | 2 -- target-xtensa/cpu.h | 1 - 47 files changed, 53 insertions(+), 99 deletions(-)
Signature · 1 line
1.9.1
PATCH 3/19 arm: Remove ELF_MACHINE from cpu.h
From: Peter Crosthwaite <[email protected]>
The only generic code relying on this is linux-user. Linux user already has a lot of #ifdef TARGET_ customisation so instead, define ELF_ARCH as either EM_ARM or EM_AARCH64 appropriately.
The armv7m bootloader can just pass EM_ARM directly, as that is architecture specific code. Note that arm_boot already has its own logic selecting an arm specific elf machine so this makes V7M more consistent with arm_boot.
This removes another architecture specific definition from the global namespace.
--- hw/arm/armv7m.c | 2 +- linux-user/elfload.c | 4 ++-- target-arm/cpu.h | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-)
hw/arm/armv7m.c +1 -1
@@ -215,7 +215,7 @@ qemu_irq *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,if (kernel_filename) { image_size =load_elf (kernel_filename,NULL ,NULL , &entry, &lowaddr, -NULL , big_endian,ELF_MACHINE ,1 ); +NULL , big_endian,EM_ARM ,1 );if (image_size <0 ) { image_size =load_image_targphys (kernel_filename,0 , mem_size); lowaddr =0 ;
linux-user/elfload.c +2 -2
@@ -272,7 +272,7 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *en#define ELF_START_MMAP 0x80000000 -#define ELF_ARCH ELF_MACHINE +#define ELF_ARCH EM_ARM#define ELF_CLASS ELFCLASS32 static inline void init_thread(struct target_pt_regs *regs,
@@ -478,7 +478,7 @@ static uint32_t get_elf_hwcap2(void)/* 64 bit ARM definitions */ #define ELF_START_MMAP 0x80000000 -#define ELF_ARCH ELF_MACHINE +#define ELF_ARCH EM_AARCH64#define ELF_CLASS ELFCLASS64#define ELF_PLATFORM "aarch64"
target-arm/cpu.h +0 -2
@@ -26,10 +26,8 @@#if defined(TARGET_AARCH64 )/* AArch64 definitions */ # define TARGET_LONG_BITS 64 -# define ELF_MACHINE EM_AARCH64#else # define TARGET_LONG_BITS 32 -# define ELF_MACHINE EM_ARM#endif #define TARGET_IS_BIENDIAN 1
Signature · 1 line
1.9.1
PATCH 2/19 linux-user: elfload: Provide default for elf_check_arch
In reply to Peter CrosthwaiteFor many arch's this macro is defined as the predicatable behaviour of checking the argument for eqaulity against ELF_ARCH. Provide a default define as such, so only archs with special handling (usually allowing multiple EM values) need to provide a def.
Arches that do any of:
1: provide this def exactly the same way as the new default
(alpha, x86_64)
2: check against ELF_MACHINE while defining ELF_ARCH == ELF_MACHINE
(arm, aarch64)
3: check against EM_FOO directly while defining ELF_ARCH == EM_FOO
(unicore32, sparc32, ppc32, mips, openrisc, sh4, cris, m86k)have their elf_check_arch removed as the default will provide the correct behaviour.
--- linux-user/elfload.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-)
linux-user/elfload.c +4 -24
@@ -145,7 +145,6 @@ static uint32_t get_elf_hwcap(void)#ifdef TARGET_X86_64 #define ELF_START_MMAP 0x2aaaaab000ULL -#define elf_check_arch (x) ( ((x) == ELF_ARCH) )#define ELF_CLASS ELFCLASS64#define ELF_ARCH EM_X86_64
@@ -273,8 +272,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUX86State *en#define ELF_START_MMAP 0x80000000 -#define elf_check_arch (x) ((x) == ELF_MACHINE) -#define ELF_ARCH ELF_MACHINE#define ELF_CLASS ELFCLASS32
@@ -481,8 +478,6 @@ static uint32_t get_elf_hwcap2(void)/* 64 bit ARM definitions */ #define ELF_START_MMAP 0x80000000 -#define elf_check_arch (x) ((x) == ELF_MACHINE) -#define ELF_ARCH ELF_MACHINE#define ELF_CLASS ELFCLASS64#define ELF_PLATFORM "aarch64"
@@ -556,8 +551,6 @@ static uint32_t get_elf_hwcap(void)#define ELF_START_MMAP 0x80000000 -#define elf_check_arch (x) ((x) == EM_UNICORE32) -#define ELF_CLASS ELFCLASS32#define ELF_DATA ELFDATA2LSB#define ELF_ARCH EM_UNICORE32
@@ -666,7 +659,6 @@ static inline void init_thread(struct target_pt_regs *regs,#define ELF_START_MMAP 0x80000000#define ELF_HWCAP (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | HWCAP_SPARC_SWAP \ | HWCAP_SPARC_MULDIV) -#define elf_check_arch (x) ( (x) == EM_SPARC )#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_SPARC
@@ -696,8 +688,6 @@ static inline void init_thread(struct target_pt_regs *regs,#else -#define elf_check_arch (x) ( (x) == EM_PPC ) -#define ELF_CLASS ELFCLASS32#endif
@@ -875,8 +865,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en#define ELF_START_MMAP 0x80000000 -#define elf_check_arch (x) ( (x) == EM_MIPS ) -#ifdef TARGET_MIPS64 #define ELF_CLASS ELFCLASS64#else
@@ -985,8 +973,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMBState *env#define ELF_START_MMAP 0x08000000 -#define elf_check_arch (x) ((x) == EM_OPENRISC) -#define ELF_ARCH EM_OPENRISC#define ELF_CLASS ELFCLASS32#define ELF_DATA ELFDATA2MSB
@@ -1026,8 +1012,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define ELF_START_MMAP 0x80000000 -#define elf_check_arch (x) ( (x) == EM_SH ) -#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_SH
@@ -1110,8 +1094,6 @@ static uint32_t get_elf_hwcap(void)#define ELF_START_MMAP 0x80000000 -#define elf_check_arch (x) ( (x) == EM_CRIS ) -#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_CRIS
@@ -1129,8 +1111,6 @@ static inline void init_thread(struct target_pt_regs *regs,#define ELF_START_MMAP 0x80000000 -#define elf_check_arch (x) ( (x) == EM_68K ) -#define ELF_CLASS ELFCLASS32#define ELF_ARCH EM_68K
@@ -1182,8 +1162,6 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUM68KState *e#define ELF_START_MMAP (0x30000000000ULL) -#define elf_check_arch (x) ( (x) == ELF_ARCH ) -#define ELF_CLASS ELFCLASS64#define ELF_ARCH EM_ALPHA
@@ -1203,8 +1181,6 @@ static inline void init_thread(struct target_pt_regs *regs,#define ELF_START_MMAP (0x20000000000ULL) -#define elf_check_arch (x) ( (x) == ELF_ARCH ) -#define ELF_CLASS ELFCLASS64#define ELF_DATA ELFDATA2MSB#define ELF_ARCH EM_S390
@@ -1226,6 +1202,10 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i#define ELF_MACHINE ELF_ARCH#endif +#ifndef elf_check_arch +#define elf_check_arch (x) ((x) == ELF_ARCH) +#endif +#ifndef ELF_HWCAP #define ELF_HWCAP 0#endif
Signature · 1 line
1.9.1
PATCH 4/19 mb: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
The only generic code relying on this is linux-user, but linux-users' default behaviour or setting ELF_MACHINE to ELF_ARCH will handle this.
The microblaze bootloader can just pass EM_MICROBLAZE directly, as that is architecture specific code.
This removes another architecture specific definition from the global namespace.
--- hw/microblaze/boot.c | 4 ++-- target-microblaze/cpu.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-)
hw/microblaze/boot.c +2 -2
@@ -141,12 +141,12 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base,/* Boots a kernel elf binary. */ kernel_size =load_elf (kernel_filename,NULL ,NULL , &entry, &low, &high, - big_endian,ELF_MACHINE ,0 ); + big_endian,EM_MICROBLAZE ,0 ); base32 = entry;if (base32 ==0xc0000000 ) { kernel_size =load_elf (kernel_filename, translate_kernel_address,NULL , &entry,NULL ,NULL , - big_endian,ELF_MACHINE ,0 ); + big_endian,EM_MICROBLAZE ,0 ); }/* Always boot into physical ram. */ boot_info.bootstrap_pc = (uint32_t )entry;
target-microblaze/cpu.h +0 -2
@@ -34,8 +34,6 @@ typedef struct CPUMBState CPUMBState;#include "mmu.h" #endif -#define ELF_MACHINE EM_MICROBLAZE -#define EXCP_MMU 1#define EXCP_IRQ 2#define EXCP_BREAK 3
Signature · 1 line
1.9.1
PATCH 5/19 m68k: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
The only generic code relying on this is linux-user, but linux users' default behaviour of defaulting ELF_MACHINE to ELF_ARCH will handle this.
The machine model bootloaders can just pass EM_68K directly, as that is architecture specific code.
This removes another architecture specific definition from the global namespace.
--- hw/m68k/an5206.c | 2 +- hw/m68k/dummy_m68k.c | 2 +- hw/m68k/mcf5208.c | 2 +- target-m68k/cpu.h | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-)
hw/m68k/an5206.c +1 -1
@@ -70,7 +70,7 @@ static void an5206_init(MachineState *machine) } kernel_size =load_elf (kernel_filename,NULL ,NULL , &elf_entry, -NULL ,NULL ,1 ,ELF_MACHINE ,0 ); +NULL ,NULL ,1 ,EM_68K ,0 ); entry = elf_entry;if (kernel_size <0 ) { kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,
hw/m68k/dummy_m68k.c +1 -1
@@ -49,7 +49,7 @@ static void dummy_m68k_init(MachineState *machine)/* Load kernel. */ if (kernel_filename) { kernel_size =load_elf (kernel_filename,NULL ,NULL , &elf_entry, -NULL ,NULL ,1 ,ELF_MACHINE ,0 ); +NULL ,NULL ,1 ,EM_68K ,0 ); entry = elf_entry;if (kernel_size <0 ) { kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,
hw/m68k/mcf5208.c +1 -1
@@ -275,7 +275,7 @@ static void mcf5208evb_init(MachineState *machine) } kernel_size =load_elf (kernel_filename,NULL ,NULL , &elf_entry, -NULL ,NULL ,1 ,ELF_MACHINE ,0 ); +NULL ,NULL ,1 ,EM_68K ,0 ); entry = elf_entry;if (kernel_size <0 ) { kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,
target-m68k/cpu.h +0 -2
@@ -32,8 +32,6 @@#define MAX_QREGS 32 -#define ELF_MACHINE EM_68K -#define EXCP_ACCESS 2/* Access (MMU) error. */ #define EXCP_ADDRESS 3/* Address error. */ #define EXCP_ILLEGAL 4/* Illegal instruction. */
Signature · 1 line
1.9.1
PATCH 6/19 cris: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
The only generic code relying on this is linux-user, but linux users' default behaviour of defaulting ELF_MACHINE to ELF_ARCH will handle this.
The bootloader can just pass EM_CRIS directly, as that is architecture specific code.
This removes another architecture specific definition from the global namespace.
--- hw/cris/boot.c | 2 +- target-cris/cpu.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-)
hw/cris/boot.c +1 -1
@@ -72,7 +72,7 @@ void cris_load_image(CRISCPU *cpu, struct cris_load_info *li)/* Boots a kernel elf binary, os/linux-2.6/vmlinux from the axis devboard SDK. */ image_size =load_elf (li->image_filename, translate_kernel_address,NULL , - &entry,NULL , &high,0 ,ELF_MACHINE ,0 ); + &entry,NULL , &high,0 ,EM_CRIS ,0 ); li->entry = entry;if (image_size <0 ) {/* Takes a kimage from the axis devboard SDK. */
target-cris/cpu.h +0 -2
@@ -29,8 +29,6 @@#include "exec/cpu-defs.h" -#define ELF_MACHINE EM_CRIS -#define EXCP_NMI 1#define EXCP_GURU 2#define EXCP_BUSFAULT 3
Signature · 1 line
1.9.1
PATCH 7/19 moxie: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
The bootloader can just pass EM_MOXIE directly, as that is architecture specific code.
This removes another architecture specific definition from the global namespace.
--- hw/moxie/moxiesim.c | 2 +- target-moxie/cpu.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-)
hw/moxie/moxiesim.c +1 -1
@@ -53,7 +53,7 @@ static void load_kernel(MoxieCPU *cpu, LoaderParams *loader_params) kernel_size =load_elf (loader_params->kernel_filename,NULL ,NULL , &entry, &kernel_low, &kernel_high,1 , -ELF_MACHINE ,0 ); +0xFEED /* EM_MOXIE */ ,0 );if (kernel_size <=0 ) { fprintf(stderr, "qemu: could not load kernel '%s'\n",
target-moxie/cpu.h +0 -2
@@ -26,8 +26,6 @@#define CPUArchState struct CPUMoxieState -#define ELF_MACHINE 0xFEED/* EM_MOXIE */ -#define MOXIE_EX_DIV0 0#define MOXIE_EX_BAD 1#define MOXIE_EX_IRQ 2
Signature · 1 line
1.9.1
PATCH 8/19 unicore: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
The only generic code relying on this is linux-user, but linux users' default behaviour of defaulting ELF_MACHINE to ELF_ARCH will handle this.
This removes another architecture specific definition from the global namespace.
--- target-unicore32/cpu.h | 2 -- 1 file changed, 2 deletions(-)
target-unicore32/cpu.h +0 -2
@@ -17,8 +17,6 @@#define TARGET_PHYS_ADDR_SPACE_BITS 32#define TARGET_VIRT_ADDR_SPACE_BITS 32 -#define ELF_MACHINE EM_UNICORE32 -#define CPUArchState struct CPUUniCore32State#include "config.h"
Signature · 1 line
1.9.1
PATCH 10/19 or32: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
The only generic code relying on this is linux-user, but linux users' default behaviour of defaulting ELF_MACHINE to ELF_ARCH will handle this.
The bootloader can just pass EM_OPENRISC directly, as that is architecture specific code.
This removes another architecture specific definition from the global namespace.
--- hw/openrisc/openrisc_sim.c | 2 +- target-openrisc/cpu.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
hw/openrisc/openrisc_sim.c +1 -1
@@ -68,7 +68,7 @@ static void cpu_openrisc_load_kernel(ram_addr_t ram_size,if (kernel_filename && !qtest_enabled ()) { kernel_size =load_elf (kernel_filename,NULL ,NULL , - &elf_entry,NULL ,NULL ,1 ,ELF_MACHINE ,1 ); + &elf_entry,NULL ,NULL ,1 ,EM_OPENRISC ,1 ); entry = elf_entry;if (kernel_size <0 ) { kernel_size = load_uimage(kernel_filename,
target-openrisc/cpu.h +0 -1
@@ -21,7 +21,6 @@#define CPU_OPENRISC_H #define TARGET_LONG_BITS 32 -#define ELF_MACHINE EM_OPENRISC#define CPUArchState struct CPUOpenRISCState
Signature · 1 line
1.9.1
PATCH 11/19 tricore: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
The bootloader can just pass EM_TRICORE directly, as that is architecture specific code.
This removes another architecture specific definition from the global namespace.
--- hw/tricore/tricore_testboard.c | 2 +- target-tricore/cpu.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-)
hw/tricore/tricore_testboard.c +1 -1
@@ -44,7 +44,7 @@ static void tricore_load_kernel(CPUTriCoreState *env) kernel_size =load_elf (tricoretb_binfo.kernel_filename,NULL ,NULL , (uint64_t *)&entry,NULL ,NULL ,0 , -ELF_MACHINE ,1 ); +EM_TRICORE ,1 );if (kernel_size <=0 ) {error_report ("qemu: no kernel file '%s'" , tricoretb_binfo.kernel_filename);
target-tricore/cpu.h +0 -2
@@ -25,8 +25,6 @@#include "exec/cpu-defs.h" #include "fpu/softfloat.h" -#define ELF_MACHINE EM_TRICORE -#define CPUArchState struct CPUTriCoreStatestruct CPUTriCoreState ;
Signature · 1 line
1.9.1
PATCH 12/19 xtensa: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
The bootloaders can just pass EM_XTENSA directly, as that is architecture specific code.
This removes another architecture specific definition from the global namespace.
--- hw/xtensa/sim.c | 4 ++-- hw/xtensa/xtfpga.c | 2 +- target-xtensa/cpu.h | 1 - 3 files changed, 3 insertions(+), 4 deletions(-)
hw/xtensa/sim.c +2 -2
@@ -93,10 +93,10 @@ static void xtensa_sim_init(MachineState *machine)uint64_t elf_lowaddr;#ifdef TARGET_WORDS_BIGENDIAN int success =load_elf (kernel_filename, translate_phys_addr, cpu, - &elf_entry, &elf_lowaddr,NULL ,1 ,ELF_MACHINE ,0 ); + &elf_entry, &elf_lowaddr,NULL ,1 ,EM_XTENSA ,0 );#else int success =load_elf (kernel_filename, translate_phys_addr, cpu, - &elf_entry, &elf_lowaddr,NULL ,0 ,ELF_MACHINE ,0 ); + &elf_entry, &elf_lowaddr,NULL ,0 ,EM_XTENSA ,0 );#endif if (success >0 ) { env->pc = elf_entry;
hw/xtensa/xtfpga.c +1 -1
@@ -340,7 +340,7 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)uint64_t elf_entry;uint64_t elf_lowaddr;int success =load_elf (kernel_filename, translate_phys_addr, cpu, - &elf_entry, &elf_lowaddr,NULL , be,ELF_MACHINE ,0 ); + &elf_entry, &elf_lowaddr,NULL , be,EM_XTENSA ,0 );if (success >0 ) { entry_point = elf_entry; }else {
target-xtensa/cpu.h +0 -1
@@ -30,7 +30,6 @@#define ALIGNED_ONLY #define TARGET_LONG_BITS 32 -#define ELF_MACHINE EM_XTENSA#define CPUArchState struct CPUXtensaState
Signature · 1 line
1.9.1
PATCH 13/19 sh4: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
The only generic code relying on this is linux-user, but linux users' default behaviour of defaulting ELF_MACHINE to ELF_ARCH will handle this.
This removes another architecture specific definition from the global namespace.
--- target-sh4/cpu.h | 2 -- 1 file changed, 2 deletions(-)
target-sh4/cpu.h +0 -2
@@ -24,8 +24,6 @@#define TARGET_LONG_BITS 32 -#define ELF_MACHINE EM_SH -/* CPU Subtypes */ #define SH_CPU_SH7750 (1 << 0)#define SH_CPU_SH7750S (1 << 1)
Signature · 1 line
1.9.1
PATCH 14/19 s390: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
The bootloader can just pass EM_S390 directly, as that is architecture specific code.
This removes another architecture specific definition from the global namespace.
--- hw/s390x/ipl.c | 4 ++-- target-s390x/cpu.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-)
hw/s390x/ipl.c +2 -2
@@ -132,7 +132,7 @@ static int s390_ipl_init(SysBusDevice *dev) bios_size =load_elf (bios_filename, bios_translate_addr, &fwbase, &ipl->bios_start_addr,NULL ,NULL ,1 , -ELF_MACHINE ,0 ); +EM_S390 ,0 );if (bios_size >0 ) {/* Adjust ELF start address to final location */ ipl->bios_start_addr += fwbase;
@@ -154,7 +154,7 @@ static int s390_ipl_init(SysBusDevice *dev)if (ipl->kernel) { kernel_size =load_elf (ipl->kernel,NULL ,NULL , &pentry,NULL , -NULL ,1 ,ELF_MACHINE ,0 ); +NULL ,1 ,EM_S390 ,0 );if (kernel_size <0 ) { kernel_size =load_image_targphys (ipl->kernel,0 , ram_size); }
target-s390x/cpu.h +0 -1
@@ -27,7 +27,6 @@#define TARGET_LONG_BITS 64 -#define ELF_MACHINE EM_S390#define ELF_MACHINE_UNAME "S390X"#define CPUArchState struct CPUS390XState
Signature · 1 line
1.9.1
PATCH 15/19 sparc: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
The bootloaders can just pass EM_SPARC or EM_SPARCV9 directly, as they are architecture specific code (to one or the other).
This removes another architecture specific definition from the global namespace.
--- hw/sparc/leon3.c | 2 +- hw/sparc/sun4m.c | 4 ++-- hw/sparc64/sun4u.c | 4 ++-- target-sparc/cpu.h | 6 ------ 4 files changed, 5 insertions(+), 11 deletions(-)
hw/sparc/leon3.c +1 -1
@@ -193,7 +193,7 @@ static void leon3_generic_hw_init(MachineState *machine)uint64_t entry; kernel_size =load_elf (kernel_filename,NULL ,NULL , &entry,NULL ,NULL , -1 /* big endian */ ,ELF_MACHINE ,0 ); +1 /* big endian */ ,EM_SPARC ,0 );if (kernel_size <0 ) {fprintf (stderr,"qemu: could not load kernel '%s'\n" , kernel_filename);
hw/sparc/sun4m.c +2 -2
@@ -300,7 +300,7 @@ static unsigned long sun4m_load_kernel(const char *kernel_filename, bswap_needed =0 ;#endif kernel_size =load_elf (kernel_filename, translate_kernel_address,NULL , -NULL ,NULL ,NULL ,1 ,ELF_MACHINE ,0 ); +NULL ,NULL ,NULL ,1 ,EM_SPARC ,0 );if (kernel_size <0 ) kernel_size = load_aout(kernel_filename, KERNEL_LOAD_ADDR, RAM_size - KERNEL_LOAD_ADDR, bswap_needed,
@@ -744,7 +744,7 @@ static void prom_init(hwaddr addr, const char *bios_name) filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);if (filename) { ret =load_elf (filename, translate_prom_address, &addr,NULL , -NULL ,NULL ,1 ,ELF_MACHINE ,0 ); +NULL ,NULL ,1 ,EM_SPARC ,0 );if (ret <0 || ret >PROM_SIZE_MAX ) { ret =load_image_targphys (filename, addr,PROM_SIZE_MAX ); }
hw/sparc64/sun4u.c +2 -2
@@ -208,7 +208,7 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename, bswap_needed =0 ;#endif kernel_size =load_elf (kernel_filename,NULL ,NULL , kernel_entry, - kernel_addr, &kernel_top,1 ,ELF_MACHINE ,0 ); + kernel_addr, &kernel_top,1 ,EM_SPARCV9 ,0 );if (kernel_size <0 ) { *kernel_addr =KERNEL_LOAD_ADDR ; *kernel_entry =KERNEL_LOAD_ADDR ;
@@ -671,7 +671,7 @@ static void prom_init(hwaddr addr, const char *bios_name) filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);if (filename) { ret =load_elf (filename, translate_prom_address, &addr, -NULL ,NULL ,NULL ,1 ,ELF_MACHINE ,0 ); +NULL ,NULL ,NULL ,1 ,EM_SPARCV9 ,0 );if (ret <0 || ret >PROM_SIZE_MAX ) { ret =load_image_targphys (filename, addr,PROM_SIZE_MAX ); }
target-sparc/cpu.h +0 -6
@@ -31,12 +31,6 @@#include "fpu/softfloat.h" -#if !defined(TARGET_SPARC64 ) -#define ELF_MACHINE EM_SPARC -#else -#define ELF_MACHINE EM_SPARCV9 -#endif -/*#define EXCP_INTERRUPT 0x100*/ /* trap definitions */
Signature · 1 line
1.9.1
PATCH 16/19 mips: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
The only generic code relying on this is linux-user, but linux users' default behaviour of defaulting ELF_MACHINE to ELF_ARCH will handle this.
The bootloaders can just pass EM_MIPS directly, as that is architecture specific code.
This removes another architecture specific definition from the global namespace.
--- hw/mips/mips_fulong2e.c | 2 +- hw/mips/mips_malta.c | 2 +- hw/mips/mips_mipssim.c | 2 +- hw/mips/mips_r4k.c | 2 +- target-mips/cpu.h | 2 -- 5 files changed, 4 insertions(+), 6 deletions(-)
hw/mips/mips_fulong2e.c +1 -1
@@ -116,7 +116,7 @@ static int64_t load_kernel (CPUMIPSState *env)if (load_elf (loaderparams.kernel_filename, cpu_mips_kseg0_to_phys,NULL , (uint64_t *)&kernel_entry, (uint64_t *)&kernel_low, - (uint64_t *)&kernel_high,0 ,ELF_MACHINE ,1 ) <0 ) { + (uint64_t *)&kernel_high,0 ,EM_MIPS ,1 ) <0 ) {fprintf (stderr,"qemu: could not load kernel '%s'\n" , loaderparams.kernel_filename);exit (1 );
hw/mips/mips_malta.c +1 -1
@@ -795,7 +795,7 @@ static int64_t load_kernel (void)if (load_elf (loaderparams.kernel_filename, cpu_mips_kseg0_to_phys,NULL , (uint64_t *)&kernel_entry,NULL , (uint64_t *)&kernel_high, - big_endian,ELF_MACHINE ,1 ) <0 ) { + big_endian,EM_MIPS ,1 ) <0 ) {fprintf (stderr,"qemu: could not load kernel '%s'\n" , loaderparams.kernel_filename);exit (1 );
hw/mips/mips_mipssim.c +1 -1
@@ -69,7 +69,7 @@ static int64_t load_kernel(void) kernel_size =load_elf (loaderparams.kernel_filename, cpu_mips_kseg0_to_phys,NULL , (uint64_t *)&entry,NULL , (uint64_t *)&kernel_high, big_endian, -ELF_MACHINE ,1 ); +EM_MIPS ,1 );if (kernel_size >=0 ) {if ((entry & ~0x7fffffffULL ) ==0x80000000 ) entry = (int32_t )entry;
hw/mips/mips_r4k.c +1 -1
@@ -87,7 +87,7 @@ static int64_t load_kernel(void) kernel_size =load_elf (loaderparams.kernel_filename, cpu_mips_kseg0_to_phys,NULL , (uint64_t *)&entry,NULL , (uint64_t *)&kernel_high, big_endian, -ELF_MACHINE ,1 ); +EM_MIPS ,1 );if (kernel_size >=0 ) {if ((entry & ~0x7fffffffULL ) ==0x80000000 ) entry = (int32_t )entry;
target-mips/cpu.h +0 -2
@@ -5,8 +5,6 @@#define ALIGNED_ONLY -#define ELF_MACHINE EM_MIPS -#define CPUArchState struct CPUMIPSState#include "config.h"
Signature · 1 line
1.9.1
PATCH 17/19 alpha: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
ELF_MACHINE is unused by target alpha.
--- target-alpha/cpu.h | 2 -- 1 file changed, 2 deletions(-)
target-alpha/cpu.h +0 -2
@@ -32,8 +32,6 @@#include "fpu/softfloat.h" -#define ELF_MACHINE EM_ALPHA -#define ICACHE_LINE_SIZE 32#define DCACHE_LINE_SIZE 32
Signature · 1 line
1.9.1
PATCH 18/19 i386: Rename ELF_MACHINE to be x86 specific
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
Rename ELF_MACHINE to be I386 specific. This is used as-is by the multiboot loader.
Linux-user previously used this definition but will not anymore, falling back to the default bahaviour of using ELF_ARCH as ELF_MACHINE.
This removes another architecture specific definition from the global namespace.
--- hw/i386/multiboot.c | 2 +- target-i386/cpu.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
hw/i386/multiboot.c +1 -1
@@ -195,7 +195,7 @@ int load_multiboot(FWCfgState *fw_cfg, } kernel_size =load_elf (kernel_filename,NULL ,NULL , &elf_entry, - &elf_low, &elf_high,0 ,ELF_MACHINE ,0 ); + &elf_low, &elf_high,0 ,I386_ELF_MACHINE ,0 );if (kernel_size <0 ) {fprintf (stderr,"Error while loading elf kernel\n" );exit (1 );
target-i386/cpu.h +2 -2
@@ -36,10 +36,10 @@#define TARGET_HAS_PRECISE_SMC #ifdef TARGET_X86_64 -#define ELF_MACHINE EM_X86_64 +#define I386_ELF_MACHINE EM_X86_64#define ELF_MACHINE_UNAME "x86_64"#else -#define ELF_MACHINE EM_386 +#define I386_ELF_MACHINE EM_386#define ELF_MACHINE_UNAME "i686"#endif
Signature · 1 line
1.9.1
PATCH 19/19 ppc: Rename ELF_MACHINE to be PPC specific
In reply to Peter CrosthwaiteFrom: Peter Crosthwaite <[email protected]>
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).
--- 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(-)
hw/ppc/e500.c +1 -1
@@ -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
hw/ppc/mac_newworld.c +2 -2
@@ -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,
hw/ppc/mac_oldworld.c +2 -2
@@ -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,
hw/ppc/ppc440_bamboo.c +1 -1
@@ -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; }
hw/ppc/prep.c +1 -1
@@ -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);
hw/ppc/spapr.c +2 -2
@@ -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 ) {
hw/ppc/virtex_ml507.c +1 -1
@@ -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 ) {
linux-user/elfload.c +1 -0
@@ -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 )
target-ppc/cpu.h +2 -2
@@ -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 /*****************************************************************************/
Signature · 1 line
1.9.1
Michael Walle
Acked-byRe: [Qemu-devel] [PATCH 09/19] lm32: Remove ELF_MACHINE from cpu.h
In reply to a message not in the archiveAm 2015-08-16 01:28, schrieb Peter Crosthwaite:
Quoted 10 lines
From: Peter Crosthwaite <[email protected]>
The bootloaders can just pass
EM_LATTICEMICO32directly, as that is architecture specific code.This removes another architecture specific definition from the global namespace.
Cc Michael Walle <[email protected]>Signed-off-by Peter Crosthwaite <[email protected]>
Re: [Qemu-devel] [PATCH 05/19] m68k: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteQuoted 6 lines · Peter Crosthwaite
From: Peter Crosthwaite <[email protected]>
The only generic code relying on this is linux-user, but linux users' default behaviour of defaulting
ELF_MACHINEtoELF_ARCHwill handle this.
Quoted 8 lines
The machine model bootloaders can just pass
EM_68Kdirectly, as that is architecture specific code.This removes another architecture specific definition from the global namespace.
Cc Laurent Vivier <[email protected]>Cc Greg Ungerer <[email protected]>
Quoted 61 lines
Signed-off-by Peter Crosthwaite <[email protected]>--- hw/m68k/an5206.c | 2 +- hw/m68k/dummy_m68k.c | 2 +- hw/m68k/mcf5208.c | 2 +- target-m68k/cpu.h | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-)hw/m68k/an5206.c +1
-1@@ -70,7 +70,7 @@ static void an5206_init(MachineState *machine) } kernel_size =load_elf (kernel_filename,NULL ,NULL , &elf_entry, -NULL ,NULL ,1 ,ELF_MACHINE ,0 ); +NULL ,NULL ,1 ,EM_68K ,0 ); entry = elf_entry;if (kernel_size <0 ) { kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,hw/m68k/dummy_m68k.c +1
-1@@ -49,7 +49,7 @@ static void dummy_m68k_init(MachineState *machine)/* Load kernel. */ if (kernel_filename) { kernel_size =load_elf (kernel_filename,NULL ,NULL , &elf_entry, -NULL ,NULL ,1 ,ELF_MACHINE ,0 ); +NULL ,NULL ,1 ,EM_68K ,0 ); entry = elf_entry;if (kernel_size <0 ) { kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,hw/m68k/mcf5208.c +1
-1@@ -275,7 +275,7 @@ static void mcf5208evb_init(MachineState *machine) } kernel_size =load_elf (kernel_filename,NULL ,NULL , &elf_entry, -NULL ,NULL ,1 ,ELF_MACHINE ,0 ); +NULL ,NULL ,1 ,EM_68K ,0 ); entry = elf_entry;if (kernel_size <0 ) { kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,target-m68k/cpu.h +0
-2@@ -32,8 +32,6 @@#define MAX_QREGS 32 -#define ELF_MACHINE EM_68K -#define EXCP_ACCESS 2/* Access (MMU) error. */ #define EXCP_ADDRESS 3/* Address error. */ #define EXCP_ILLEGAL 4/* Illegal instruction. */
Re: [Qemu-devel] [PATCH 07/19] moxie: Remove ELF_MACHINE from cpu.h
In reply to Peter Crosthwaitehw/moxie/moxiesim.c static void load_kernel(MoxieCPU *cpu, LoaderParams *loader_params) · line 56
Quoted 2 lines · Peter Crosthwaite
hw/moxie/moxiesim.c +1
-1- ELF_MACHINE, 0); + 0xFEED /* EM_MOXIE */, 0);
Please add EM_MOXIE to include/elf.h.
r~
Quoted 12 lines · Peter Crosthwaite
Peter Crosthwaite (19):
linux_user: elfload: DefaultELF_MACHINEtoELF_ARCH
linux-user: elfload: Provide default forelf_check_arch
arm: RemoveELF_MACHINEfromcpu.h
mb: RemoveELF_MACHINEfromcpu.h
m68k: RemoveELF_MACHINEfromcpu.h
cris: RemoveELF_MACHINEfromcpu.h
moxie: RemoveELF_MACHINEfromcpu.h
unicore: RemoveELF_MACHINEfromcpu.h
lm32: RemoveELF_MACHINEfromcpu.h
or32: RemoveELF_MACHINEfromcpu.h
tricore: RemoveELF_MACHINEfromcpu.h
Quoted 8 lines
xtensa: Remove
ELF_MACHINEfromcpu.h
sh4: RemoveELF_MACHINEfromcpu.h
s390: RemoveELF_MACHINEfromcpu.h
sparc: RemoveELF_MACHINEfromcpu.h
mips: RemoveELF_MACHINEfromcpu.h
alpha: RemoveELF_MACHINEfromcpu.h
i386: RenameELF_MACHINEto be x86 specific
ppc: RenameELF_MACHINEto be PPC specific
Modulo the one nit for moxie,
r~
Re: [Qemu-devel] [PATCH 18/19] i386: Rename ELF_MACHINE to be x86 specific
In reply to Peter CrosthwaiteQuoted 8 lines · Peter Crosthwaite
From: Peter Crosthwaite <[email protected]>
Rename
ELF_MACHINEto be I386 specific. This is used as-is by the multiboot loader.Linux-user previously used this definition but will not anymore, falling back to the default bahaviour of using
ELF_ARCHasELF_MACHINE.
Quoted 7 lines
This removes another architecture specific definition from the global namespace.
Cc Paolo Bonzini <[email protected]>Cc Richard Henderson <[email protected]>Cc Eduardo Habkost <[email protected]>Signed-off-by Peter Crosthwaite <[email protected]>
If somebody is going to pull the whole series through another tree:
(It looks like I can't apply this to the x86 tree without patches 1/19 and 2/19)
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH 13/19] sh4: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteQuoted 6 lines · Peter Crosthwaite
From: Peter Crosthwaite <[email protected]>
The only generic code relying on this is linux-user, but linux users' default behaviour of defaulting
ELF_MACHINEtoELF_ARCHwill handle this.
Quoted 8 lines
This removes another architecture specific definition from the global namespace.
Cc Aurelien Jarno <[email protected]>Signed-off-by Peter Crosthwaite <[email protected]>--- target-sh4/cpu.h | 2 -- 1 file changed, 2 deletions(-)
Signature · 2 lines
Aurelien Jarno GPG: 4096R/1DDD8C9B [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 16/19] mips: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteQuoted 15 lines · Peter Crosthwaite
From: Peter Crosthwaite <[email protected]>
The only generic code relying on this is linux-user, but linux users' default behaviour of defaulting
ELF_MACHINEtoELF_ARCHwill handle this.The bootloaders can just pass
EM_MIPSdirectly, as that is architecture specific code.This removes another architecture specific definition from the global namespace.
Cc Aurelien Jarno <[email protected]>Cc Leon Alrae <[email protected]>Signed-off-by Peter Crosthwaite <[email protected]>
Quoted 7 lines
--- hw/mips/mips_fulong2e.c | 2 +- hw/mips/mips_malta.c | 2 +- hw/mips/mips_mipssim.c | 2 +- hw/mips/mips_r4k.c | 2 +- target-mips/cpu.h | 2 -- 5 files changed, 4 insertions(+), 6 deletions(-)
Signature · 2 lines
Aurelien Jarno GPG: 4096R/1DDD8C9B [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 07/19] moxie: Remove ELF_MACHINE from cpu.h
In reply to Richard HendersonQuoted 6 lines · Richard Henderson
hw/moxie/moxiesim.c static void load_kernel(MoxieCPU *cpu, LoaderParams *loader_params) · line 56
Quoted 2 lines · Peter Crosthwaite
hw/moxie/moxiesim.c +1
-1- ELF_MACHINE, 0); + 0xFEED /* EM_MOXIE */, 0);Please add
EM_MOXIEtoinclude/elf.h.
So according to this blog, Moxie actually now has a legit EM:
http://moxielogic.org/blog/ (2nd post from top)
http://www.sco.com/developers/gabi/latest/ch4.eheader.html
Should this 0xFEED be handled the same way as we do for MICROBLAZE_OLD?
#define EM_MICROBLAZE 189
#define EM_MICROBLAZE_OLD 0xBAAB
Regards,
Peter
Quoted 2 lines
r~
Re: [Qemu-devel] [PATCH 07/19] moxie: Remove ELF_MACHINE from cpu.h
Quoted 10 lines · Peter Crosthwaite
Quoted 6 lines · Richard Henderson
hw/moxie/moxiesim.c static void load_kernel(MoxieCPU *cpu, LoaderParams *loader_params) · line 56
Quoted 2 lines · Peter Crosthwaite
hw/moxie/moxiesim.c +1
-1- ELF_MACHINE, 0); + 0xFEED /* EM_MOXIE */, 0);Please add
EM_MOXIEtoinclude/elf.h.So according to this blog, Moxie actually now has a legit EM:
Quoted 7 lines
http://moxielogic.org/blog/ (2nd post from top)
http://www.sco.com/developers/gabi/latest/ch4.eheader.htmlShould this
0xFEEDbe handled the same way as we do forMICROBLAZE_OLD?#define
EM_MICROBLAZE189
#defineEM_MICROBLAZE_OLD0xBAAB
Yes. It seems to have been updated in binutils on 2015-01-09.
r~
Re: [Qemu-devel] [PATCH 11/19] tricore: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteAm 15.08.2015 um 16:28 schrieb Peter Crosthwaite:
Quoted 5 lines
From: Peter Crosthwaite <[email protected]>
The bootloader can just pass
EM_TRICOREdirectly, as that is architecture specific code.
Quoted 7 lines
This removes another architecture specific definition from the global namespace.
Cc Bastian Koppelmann <[email protected]>Signed-off-by Peter Crosthwaite <[email protected]>---
Re: [Qemu-devel] [PATCH 05/19] m68k: Remove ELF_MACHINE from cpu.h
In reply to Peter CrosthwaiteQuoted 15 lines · Peter Crosthwaite
From: Peter Crosthwaite <[email protected]>
The only generic code relying on this is linux-user, but linux users' default behaviour of defaulting
ELF_MACHINEtoELF_ARCHwill handle this.The machine model bootloaders can just pass
EM_68Kdirectly, as that is architecture specific code.This removes another architecture specific definition from the global namespace.
Cc Laurent Vivier <[email protected]>Cc Greg Ungerer <[email protected]>Signed-off-by Peter Crosthwaite <[email protected]>
Quoted 6 lines
--- hw/m68k/an5206.c | 2 +- hw/m68k/dummy_m68k.c | 2 +- hw/m68k/mcf5208.c | 2 +- target-m68k/cpu.h | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-)
Re: [Qemu-devel] [Qemu-ppc] [PATCH 19/19] ppc: Rename ELF_MACHINE to be PPC specific
In reply to Peter CrosthwaiteI'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
Quoted 167 lines · Peter Crosthwaite
From: Peter Crosthwaite <[email protected]>
Rename
ELF_MACHINEto be PPC specific. This is used as-is by the various PPC bootloaders and is locally defined toELF_MACHINEin linux user in PPC specific ifdeffery.This removes another architecture specific definition from the global namespace (as desired by multi-arch).
Cc Alexander Graf <[email protected]>Signed-off-by Peter Crosthwaite <[email protected]>--- 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(-)hw/ppc/e500.c +1
-1@@ -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 hw/ppc/mac_newworld.c +2
-2@@ -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,hw/ppc/mac_oldworld.c +2
-2@@ -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,hw/ppc/ppc440_bamboo.c +1
-1@@ -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; }hw/ppc/prep.c +1
-1@@ -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);hw/ppc/spapr.c +2
-2@@ -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 ) {hw/ppc/virtex_ml507.c +1
-1@@ -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 ) {linux-user/elfload.c +1
-0@@ -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 )target-ppc/cpu.h +2
-2@@ -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 /*****************************************************************************/
Quoted 61 lines · Peter Crosthwaite
Peter Crosthwaite (19):
linux_user: elfload: DefaultELF_MACHINEtoELF_ARCH
linux-user: elfload: Provide default forelf_check_arch
arm: RemoveELF_MACHINEfromcpu.h
mb: RemoveELF_MACHINEfromcpu.h
m68k: RemoveELF_MACHINEfromcpu.h
cris: RemoveELF_MACHINEfromcpu.h
moxie: RemoveELF_MACHINEfromcpu.h
unicore: RemoveELF_MACHINEfromcpu.h
lm32: RemoveELF_MACHINEfromcpu.h
or32: RemoveELF_MACHINEfromcpu.h
tricore: RemoveELF_MACHINEfromcpu.h
xtensa: RemoveELF_MACHINEfromcpu.h
sh4: RemoveELF_MACHINEfromcpu.h
s390: RemoveELF_MACHINEfromcpu.h
sparc: RemoveELF_MACHINEfromcpu.h
mips: RemoveELF_MACHINEfromcpu.h
alpha: RemoveELF_MACHINEfromcpu.h
i386: RenameELF_MACHINEto be x86 specific
ppc: RenameELF_MACHINEto be PPC specifichw/arm/armv7m.c | 2 +- hw/cris/boot.c | 2 +- hw/i386/multiboot.c | 2 +- hw/lm32/lm32_boards.c | 4 ++-- hw/lm32/milkymist.c | 2 +- hw/m68k/an5206.c | 2 +- hw/m68k/dummy_m68k.c | 2 +- hw/m68k/mcf5208.c | 2 +- hw/microblaze/boot.c | 4 ++-- hw/mips/mips_fulong2e.c | 2 +- hw/mips/mips_malta.c | 2 +- hw/mips/mips_mipssim.c | 2 +- hw/mips/mips_r4k.c | 2 +- hw/moxie/moxiesim.c | 2 +- hw/openrisc/openrisc_sim.c | 2 +- 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 +- hw/s390x/ipl.c | 4 ++-- hw/sparc/leon3.c | 2 +- hw/sparc/sun4m.c | 4 ++-- hw/sparc64/sun4u.c | 4 ++-- hw/tricore/tricore_testboard.c | 2 +- hw/xtensa/sim.c | 4 ++-- hw/xtensa/xtfpga.c | 2 +- linux-user/elfload.c | 37 +++++++++++-------------------------- target-alpha/cpu.h | 2 -- target-arm/cpu.h | 2 -- target-cris/cpu.h | 2 -- target-i386/cpu.h | 4 ++-- target-lm32/cpu.h | 2 -- target-m68k/cpu.h | 2 -- target-microblaze/cpu.h | 2 -- target-mips/cpu.h | 2 -- target-moxie/cpu.h | 2 -- target-openrisc/cpu.h | 1 -
Quoted 8 lines
target-ppc/cpu.h | 4 ++-- target-s390x/cpu.h | 1 - target-sh4/cpu.h | 2 -- target-sparc/cpu.h | 6 ------ target-tricore/cpu.h | 2 -- target-unicore32/cpu.h | 2 -- target-xtensa/cpu.h | 1 - 47 files changed, 53 insertions(+), 99 deletions(-)
Quoted 71 lines · Riku Voipio
Quoted 61 lines · Peter Crosthwaite
Peter Crosthwaite (19):
linux_user: elfload: DefaultELF_MACHINEtoELF_ARCH
linux-user: elfload: Provide default forelf_check_arch
arm: RemoveELF_MACHINEfromcpu.h
mb: RemoveELF_MACHINEfromcpu.h
m68k: RemoveELF_MACHINEfromcpu.h
cris: RemoveELF_MACHINEfromcpu.h
moxie: RemoveELF_MACHINEfromcpu.h
unicore: RemoveELF_MACHINEfromcpu.h
lm32: RemoveELF_MACHINEfromcpu.h
or32: RemoveELF_MACHINEfromcpu.h
tricore: RemoveELF_MACHINEfromcpu.h
xtensa: RemoveELF_MACHINEfromcpu.h
sh4: RemoveELF_MACHINEfromcpu.h
s390: RemoveELF_MACHINEfromcpu.h
sparc: RemoveELF_MACHINEfromcpu.h
mips: RemoveELF_MACHINEfromcpu.h
alpha: RemoveELF_MACHINEfromcpu.h
i386: RenameELF_MACHINEto be x86 specific
ppc: RenameELF_MACHINEto be PPC specifichw/arm/armv7m.c | 2 +- hw/cris/boot.c | 2 +- hw/i386/multiboot.c | 2 +- hw/lm32/lm32_boards.c | 4 ++-- hw/lm32/milkymist.c | 2 +- hw/m68k/an5206.c | 2 +- hw/m68k/dummy_m68k.c | 2 +- hw/m68k/mcf5208.c | 2 +- hw/microblaze/boot.c | 4 ++-- hw/mips/mips_fulong2e.c | 2 +- hw/mips/mips_malta.c | 2 +- hw/mips/mips_mipssim.c | 2 +- hw/mips/mips_r4k.c | 2 +- hw/moxie/moxiesim.c | 2 +- hw/openrisc/openrisc_sim.c | 2 +- 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 +- hw/s390x/ipl.c | 4 ++-- hw/sparc/leon3.c | 2 +- hw/sparc/sun4m.c | 4 ++-- hw/sparc64/sun4u.c | 4 ++-- hw/tricore/tricore_testboard.c | 2 +- hw/xtensa/sim.c | 4 ++-- hw/xtensa/xtfpga.c | 2 +- linux-user/elfload.c | 37 +++++++++++-------------------------- target-alpha/cpu.h | 2 -- target-arm/cpu.h | 2 -- target-cris/cpu.h | 2 -- target-i386/cpu.h | 4 ++-- target-lm32/cpu.h | 2 -- target-m68k/cpu.h | 2 -- target-microblaze/cpu.h | 2 -- target-mips/cpu.h | 2 -- target-moxie/cpu.h | 2 -- target-openrisc/cpu.h | 1 -Quoted 8 lines
target-ppc/cpu.h | 4 ++-- target-s390x/cpu.h | 1 - target-sh4/cpu.h | 2 -- target-sparc/cpu.h | 6 ------ target-tricore/cpu.h | 2 -- target-unicore32/cpu.h | 2 -- target-xtensa/cpu.h | 1 - 47 files changed, 53 insertions(+), 99 deletions(-)
Quoted 2 lines
Acked-by Riku Voipio <[email protected]>
Riku, can you send a pull request yourself?
Thanks,
Paolo
Re: [Qemu-devel] [PATCH 07/19] moxie: Remove ELF_MACHINE from cpu.h
In reply to Richard HendersonQuoted 19 lines · Richard Henderson
Quoted 18 lines · Peter Crosthwaite
Quoted 9 lines · Richard Henderson
hw/moxie/moxiesim.c static void load_kernel(MoxieCPU *cpu, LoaderParams *loader_params) · line 56
Quoted 3 lines · Peter Crosthwaite
hw/moxie/moxiesim.c +1
-1- ELF_MACHINE, 0); + 0xFEED /* EM_MOXIE */, 0);Please add
EM_MOXIEtoinclude/elf.h.So according to this blog, Moxie actually now has a legit EM:
http://moxielogic.org/blog/ (2nd post from top)
http://www.sco.com/developers/gabi/latest/ch4.eheader.html
Quoted 8 lines
Quoted 4 lines
Should this
0xFEEDbe handled the same way as we do forMICROBLAZE_OLD?#define
EM_MICROBLAZE189
#defineEM_MICROBLAZE_OLD0xBAABYes. It seems to have been updated in binutils on 2015-01-09.
So I am comparing elf.h to the binutils common.h and there seems to be a strong correlation but with two major differences:
1: The QEMU one has a large number of arch specific defs not in binutils common.h
2: Binutils covers the arches that are not implemented in QEMU
I have started trying to get them a little more synced to aid maintenance. I have got to a stage where you can do a sane diff with binutils common.h. I have synced the whitespace and migrated qemu and arch specifics to a new header. We could however make it like Linux and just periodically sync the headers from binutils or linux verbatim rather than letting QEMU drift with incremental patches?
RFC
Regards,
Peter
Quoted 3 lines
r~
Re: [Qemu-devel] [PATCH 07/19] moxie: Remove ELF_MACHINE from cpu.h
Quoted 1 line · Peter Crosthwaite
just periodically sync the headers from binutils
Careful, binutils is GPLv3, which isn't compatible with QEMU's overall GPLv2 license. It's OK to look at binutils to find the information to write the relevant QEMU code, but copying it wholesale isn't possible.
Having our headers not particularly look like the binutils ones is a good way of demonstrating that we haven't just copied a pile of GPLv3 code...
thanks
-- PMM
Re: [Qemu-devel] [PATCH 07/19] moxie: Remove ELF_MACHINE from cpu.h
In reply to Richard HendersonQuoted 19 lines · Richard Henderson
Quoted 18 lines · Peter Crosthwaite
Quoted 9 lines · Richard Henderson
hw/moxie/moxiesim.c static void load_kernel(MoxieCPU *cpu, LoaderParams *loader_params) · line 56
Quoted 3 lines · Peter Crosthwaite
hw/moxie/moxiesim.c +1
-1- ELF_MACHINE, 0); + 0xFEED /* EM_MOXIE */, 0);Please add
EM_MOXIEtoinclude/elf.h.So according to this blog, Moxie actually now has a legit EM:
http://moxielogic.org/blog/ (2nd post from top)
http://www.sco.com/developers/gabi/latest/ch4.eheader.html
Quoted 8 lines
Quoted 4 lines
Should this
0xFEEDbe handled the same way as we do forMICROBLAZE_OLD?#define
EM_MICROBLAZE189
#defineEM_MICROBLAZE_OLD0xBAABYes. It seems to have been updated in binutils on 2015-01-09.
Patches on list.
Regards,
Peter
Quoted 3 lines
r~
Re: [Qemu-devel] [Qemu-ppc] [PATCH 19/19] ppc: Rename ELF_MACHINE to be PPC specific
In reply to Laurent VivierQuoted 7 lines · Laurent Vivier
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_PPCwith e500, ppc440,virtex_ml507,
Definitely right for virtex_ml507.
Quoted 4 lines
prep and oldworld, and
EM_PPC64with pseries/spapr. Newworld mac should be able to runEM_PPCandEM_PPC64kernel (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
Quoted 170 lines
Laurent
Quoted 167 lines · Peter Crosthwaite
From: Peter Crosthwaite <[email protected]>
Rename
ELF_MACHINEto be PPC specific. This is used as-is by the various PPC bootloaders and is locally defined toELF_MACHINEin linux user in PPC specific ifdeffery.This removes another architecture specific definition from the global namespace (as desired by multi-arch).
Cc Alexander Graf <[email protected]>Signed-off-by Peter Crosthwaite <[email protected]>--- 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(-)hw/ppc/e500.c +1
-1@@ -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 hw/ppc/mac_newworld.c +2
-2@@ -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,hw/ppc/mac_oldworld.c +2
-2@@ -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,hw/ppc/ppc440_bamboo.c +1
-1@@ -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; }hw/ppc/prep.c +1
-1@@ -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);hw/ppc/spapr.c +2
-2@@ -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 ) {hw/ppc/virtex_ml507.c +1
-1@@ -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 ) {linux-user/elfload.c +1
-0@@ -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 )target-ppc/cpu.h +2
-2@@ -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 /*****************************************************************************/
Re: [Qemu-devel] [Qemu-ppc] [PATCH 19/19] ppc: Rename ELF_MACHINE to be PPC specific
Quoted 11 lines · Peter Crosthwaite
Quoted 7 lines · Laurent Vivier
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_PPCwith e500, ppc440,virtex_ml507,Definitely right for
virtex_ml507.
Quoted 8 lines
Quoted 4 lines
prep and oldworld, and
EM_PPC64with pseries/spapr. Newworld mac should be able to runEM_PPCandEM_PPC64kernel (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
Quoted 99 lines · Peter Crosthwaite
Every arch defines
ELF_MACHINEincpu.hto an arch-specific value. This definition is rarely needed by core code (only in a few cases). It conflicts with the multi-arch effort wherecpu.hcannot export cpu specifics via macros like this. So removeELF_MACHINEcompletely from all the cpu.h's.Linux-user defines both
ELF_ARCHandELF_MACHINE, but for most cases they are the same. So provide a default ofELF_MACHINE==ELF_ARCHto handle most cases and just minimally defineELF_MACHINElocally in linux-user where there is a genuine difference.While touching the code cleanup
elf_check_archin linux-user with a similar default-based system to minimise the boiler-plate for archEM_code.Then go arch-by-arch to remove
ELF_MACHINEfromcpu.h. For many arches this causes theELF_MACHINE==ELF_ARCHdefault to kick in. Some arches need their bootloader usages ofELF_MACHINEconverted to useEM_FOOdirectly.Alpha is unique, in that
ELF_MACHINEis completely unused by existing code.i386 and ppc are the most complex, where there is a genuine need to switch
ELF_MACHINEdepending on the target sub-arch. In these casesELF_MACHINEif prefixed to be target specific. This will need further rethinking to get multi-arch support for those two arches.There is an argument for keeping the per-arch definitions of the EM, but the correct place for this would be as virtual field in the QOM CPU class. Given the refactorings of the series this new field would be initially unused until we have the notion of a generic system mode bootloader or refactor linux-user boot to be more QOMified. So leaving the defs deleted for the moment for later revival.
Regards,
PeterPeter Crosthwaite (19):
linux_user: elfload: DefaultELF_MACHINEtoELF_ARCH
linux-user: elfload: Provide default forelf_check_arch
arm: RemoveELF_MACHINEfromcpu.h
mb: RemoveELF_MACHINEfromcpu.h
m68k: RemoveELF_MACHINEfromcpu.h
cris: RemoveELF_MACHINEfromcpu.h
moxie: RemoveELF_MACHINEfromcpu.h
unicore: RemoveELF_MACHINEfromcpu.h
lm32: RemoveELF_MACHINEfromcpu.h
or32: RemoveELF_MACHINEfromcpu.h
tricore: RemoveELF_MACHINEfromcpu.h
xtensa: RemoveELF_MACHINEfromcpu.h
sh4: RemoveELF_MACHINEfromcpu.h
s390: RemoveELF_MACHINEfromcpu.h
sparc: RemoveELF_MACHINEfromcpu.h
mips: RemoveELF_MACHINEfromcpu.h
alpha: RemoveELF_MACHINEfromcpu.h
i386: RenameELF_MACHINEto be x86 specific
ppc: RenameELF_MACHINEto be PPC specifichw/arm/armv7m.c | 2 +- hw/cris/boot.c | 2 +- hw/i386/multiboot.c | 2 +- hw/lm32/lm32_boards.c | 4 ++-- hw/lm32/milkymist.c | 2 +- hw/m68k/an5206.c | 2 +- hw/m68k/dummy_m68k.c | 2 +- hw/m68k/mcf5208.c | 2 +- hw/microblaze/boot.c | 4 ++-- hw/mips/mips_fulong2e.c | 2 +- hw/mips/mips_malta.c | 2 +- hw/mips/mips_mipssim.c | 2 +- hw/mips/mips_r4k.c | 2 +- hw/moxie/moxiesim.c | 2 +- hw/openrisc/openrisc_sim.c | 2 +- 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 +- hw/s390x/ipl.c | 4 ++-- hw/sparc/leon3.c | 2 +- hw/sparc/sun4m.c | 4 ++-- hw/sparc64/sun4u.c | 4 ++-- hw/tricore/tricore_testboard.c | 2 +- hw/xtensa/sim.c | 4 ++-- hw/xtensa/xtfpga.c | 2 +- linux-user/elfload.c | 37 +++++++++++-------------------------- target-alpha/cpu.h | 2 -- target-arm/cpu.h | 2 -- target-cris/cpu.h | 2 -- target-i386/cpu.h | 4 ++-- target-lm32/cpu.h | 2 -- target-m68k/cpu.h | 2 -- target-microblaze/cpu.h | 2 -- target-mips/cpu.h | 2 -- target-moxie/cpu.h | 2 -- target-openrisc/cpu.h | 1 -
Quoted 9 lines
target-ppc/cpu.h | 4 ++-- target-s390x/cpu.h | 1 - target-sh4/cpu.h | 2 -- target-sparc/cpu.h | 6 ------ target-tricore/cpu.h | 2 -- target-unicore32/cpu.h | 2 -- target-xtensa/cpu.h | 1 - 47 files changed, 53 insertions(+), 99 deletions(-)
Peter, I suggest that you send a pull request yourself for this and the Moxie change.
Paolo
Quoted 112 lines · Paolo Bonzini
Quoted 99 lines · Peter Crosthwaite
Every arch defines
ELF_MACHINEincpu.hto an arch-specific value. This definition is rarely needed by core code (only in a few cases). It conflicts with the multi-arch effort wherecpu.hcannot export cpu specifics via macros like this. So removeELF_MACHINEcompletely from all the cpu.h's.Linux-user defines both
ELF_ARCHandELF_MACHINE, but for most cases they are the same. So provide a default ofELF_MACHINE==ELF_ARCHto handle most cases and just minimally defineELF_MACHINElocally in linux-user where there is a genuine difference.While touching the code cleanup
elf_check_archin linux-user with a similar default-based system to minimise the boiler-plate for archEM_code.Then go arch-by-arch to remove
ELF_MACHINEfromcpu.h. For many arches this causes theELF_MACHINE==ELF_ARCHdefault to kick in. Some arches need their bootloader usages ofELF_MACHINEconverted to useEM_FOOdirectly.Alpha is unique, in that
ELF_MACHINEis completely unused by existing code.i386 and ppc are the most complex, where there is a genuine need to switch
ELF_MACHINEdepending on the target sub-arch. In these casesELF_MACHINEif prefixed to be target specific. This will need further rethinking to get multi-arch support for those two arches.There is an argument for keeping the per-arch definitions of the EM, but the correct place for this would be as virtual field in the QOM CPU class. Given the refactorings of the series this new field would be initially unused until we have the notion of a generic system mode bootloader or refactor linux-user boot to be more QOMified. So leaving the defs deleted for the moment for later revival.
Regards,
PeterPeter Crosthwaite (19):
linux_user: elfload: DefaultELF_MACHINEtoELF_ARCH
linux-user: elfload: Provide default forelf_check_arch
arm: RemoveELF_MACHINEfromcpu.h
mb: RemoveELF_MACHINEfromcpu.h
m68k: RemoveELF_MACHINEfromcpu.h
cris: RemoveELF_MACHINEfromcpu.h
moxie: RemoveELF_MACHINEfromcpu.h
unicore: RemoveELF_MACHINEfromcpu.h
lm32: RemoveELF_MACHINEfromcpu.h
or32: RemoveELF_MACHINEfromcpu.h
tricore: RemoveELF_MACHINEfromcpu.h
xtensa: RemoveELF_MACHINEfromcpu.h
sh4: RemoveELF_MACHINEfromcpu.h
s390: RemoveELF_MACHINEfromcpu.h
sparc: RemoveELF_MACHINEfromcpu.h
mips: RemoveELF_MACHINEfromcpu.h
alpha: RemoveELF_MACHINEfromcpu.h
i386: RenameELF_MACHINEto be x86 specific
ppc: RenameELF_MACHINEto be PPC specifichw/arm/armv7m.c | 2 +- hw/cris/boot.c | 2 +- hw/i386/multiboot.c | 2 +- hw/lm32/lm32_boards.c | 4 ++-- hw/lm32/milkymist.c | 2 +- hw/m68k/an5206.c | 2 +- hw/m68k/dummy_m68k.c | 2 +- hw/m68k/mcf5208.c | 2 +- hw/microblaze/boot.c | 4 ++-- hw/mips/mips_fulong2e.c | 2 +- hw/mips/mips_malta.c | 2 +- hw/mips/mips_mipssim.c | 2 +- hw/mips/mips_r4k.c | 2 +- hw/moxie/moxiesim.c | 2 +- hw/openrisc/openrisc_sim.c | 2 +- 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 +- hw/s390x/ipl.c | 4 ++-- hw/sparc/leon3.c | 2 +- hw/sparc/sun4m.c | 4 ++-- hw/sparc64/sun4u.c | 4 ++-- hw/tricore/tricore_testboard.c | 2 +- hw/xtensa/sim.c | 4 ++-- hw/xtensa/xtfpga.c | 2 +- linux-user/elfload.c | 37 +++++++++++-------------------------- target-alpha/cpu.h | 2 -- target-arm/cpu.h | 2 -- target-cris/cpu.h | 2 -- target-i386/cpu.h | 4 ++-- target-lm32/cpu.h | 2 -- target-m68k/cpu.h | 2 -- target-microblaze/cpu.h | 2 -- target-mips/cpu.h | 2 -- target-moxie/cpu.h | 2 -- target-openrisc/cpu.h | 1 -Quoted 9 lines
target-ppc/cpu.h | 4 ++-- target-s390x/cpu.h | 1 - target-sh4/cpu.h | 2 -- target-sparc/cpu.h | 6 ------ target-tricore/cpu.h | 2 -- target-unicore32/cpu.h | 2 -- target-xtensa/cpu.h | 1 - 47 files changed, 53 insertions(+), 99 deletions(-)
Quoted 3 lines
Peter, I suggest that you send a pull request yourself for this and the Moxie change.
Sure, will do. I don't have PULL scriptage (as I never do them) but will figure it.
Regards,
Peter
Quoted 1 line
Paolo