ext
ext

Reputation: 2903

Linux VM with custom architecture

I'm looking into creating a couple of VMs (probably but not necessarily using QEMU) with different parameters/architecture.

I'm familiar with building my own kernel, gcc, glibc etc but I'm not entirely sure what actually decides those parameters (assuming it is related to the CPU somehow). In my case the performance would be irrelevant, the purpose is only to test builds (mostly networking related) under different environments.

Is this possible at all? Can someone push me in the right direction? I will gladly read documentation but I'm not sure where to start.

Upvotes: 1

Views: 99

Answers (1)

user862787
user862787

Reputation:

I'm familiar with building my own kernel, gcc, glibc etc but I'm not entirely sure what actually decides those parameters (assuming it is related to the CPU somehow).

If by "those parameters" you mean the items in your bullet list, yes, they are determined by the instruction set architecture of the CPU. On pretty much anything on which you'll be running Linux, sizeof(int) will be 4, i.e. 32 bits, even on 64-bit machines, but sizeof(long) and sizeof({something} *) will be 4 on 32-bit machines and 8 on 64-bit machines. So:

  • sizeof(long)/sizeof({pointer type}): 4 on 32-bit x86/32-bit PowerPC/32-bit SPARC/etc., 8 on 64-bit x86(x86-64)/64-bit PowerPC/64-bit SPARC/etc.
  • endianness: little-endian on x86, ARM, and some others, big-endian on PowerPC, SPARC, and some others (I think Linux might support both little-endian and big-endian mode on some bi-endian architectures)
  • alignment rules: x86 doesn't require alignment but some processors may run faster with better alignment, I think PowerPC doesn't fully require it although it might have issues with misaligned operands crossing page boundaries - SPARC is one architecture I know of that requires strict alignment.

So I'm guessing that the host machine will probably be some flavor of x86, so there probably won't be any need to emulate that.

From looking at the source to the QEMU 2.3.0 release, it appears that QEMU can emulate both 32-bit and 64-bit SPARC; I'd suggest having a SPARC virtual machine if you can, to catch both byte-order and alignment issues. You should, if possible, have both 32-bit and 64-bit x86 and SPARC.

After that, I'd look at ARM (it looks from the source as if 64-bit ARM is being worked on, if not yet available), and then PowerPC (32-bit and 64-bit; I'm not sure whether they emulate any 64-bit platforms, however) and MIPS (32-bit and 64-bit, and both byte orders, if possible).

After that, if you're really ambitious, you could set up a Linux box emulating the descendants of machines like this one; QEMU seems to support S/390 and/or z/Architecture, or you could go with Hercules. You could also try some of the additional embedded architectures that support Linux.

Upvotes: 2

Related Questions