13
Smallest UTF32 to UTF8 converter
I found some weird opcodes in the s390 instruction set some time ago. I finally want to use it as I have access to such a machine. The result is rather slim:
.globl cu41
.type cu41, @function
cu41:
.L2:
cu41 %r2,%r4
ipm %r1
srl %r1,28
chi %r1,3
je .L2
ltr %r1,%r1
je .L3
lcr %r1,%r1
lgfr %r3,%r1
.L3:
lgr %r2,%r3
br %r14
The cu41 opcode translates UTF32 to UTF8. Each "parameter" is a register pair [1], which describes address and length of the buffer. This opcode will return after a not specified number of translated characters. The rest is boiler plate code for condition code checking. The loop makes sure that anything is converted within the function unless another error occured.
| [1] | An even pair. gcc is not yet able to allocate such pairs on its own, so it is hardcoded. |
PV-GRUB and partitions
Xen 3.3 added a tool called PV-GRUB. It is a GRUB (legacy aka 0.97) built against MiniOS and bootable as a PV kernel. It works fine on a Xen 3.2.1.
It is easy to use, I just set this in my config:
kernel = "/usr/local/lib/xen/boot/pv-grub-x86_64.gz" extra = "(hd0)/boot/grub/menu.lst"
However it decided to not load my config as defined in the config and simply show me that:
GNU GRUB version 0.97 (524288K lower / 0K upper memory)
[ Minimal BASH-like line editing is supported. For
the first word, TAB lists possible command
completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grubdom>
The reason is quite easy:
grubdom> root (hd0) Filesystem type unknown, using whole disk
Some debugging later, the reason is known and fixed.
grubdom> root (hd0) Filesystem type is ext2fs, using whole disk grubdom> kernel /boot/vmlinuz-2.6.27-rc5-amd64 grubdom> initrd /boot/initrd.img-2.6.27-rc5-amd64 grubdom> boot block error -1 for op 2 close blk: backend at /local/domain/0/backend/vbd/23/51712 [ 0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Linux version 2.6.27-rc5-amd64 [...] [ 0.000000] Command line: [ 0.000000] KERNEL supported cpus: [ 0.000000] Intel GenuineIntel [ 0.000000] AMD AuthenticAMD [ 0.000000] Centaur CentaurHauls [ 0.000000] ACPI in unprivileged domain disabled [...] [ 0.022093] Booting paravirtualized kernel on Xen [ 0.022101] Xen version: 3.2-1
