On Thu, 2009-03-12 at 11:58 -0500, William Pitcock wrote:
> On Wed, 2009-03-11 at 07:57 +0000, Ian Campbell wrote:
> > Oh, hang, on, you aren't trying to load a bzImage dom0 kernel are you?
> 
> Yes, I am. But, we need to make sure that squeeze ships with support for
> this.

Given the timescales involved it certainly will since Xen 3.4 is due
fairly soon (a matter of months I guess).

> I suppose I could feed the hypervisor the raw vmlinux binary on a
> production-like machine in the meantime. That should work. At least,
> that's what we do for non-pvops kernels.

Yes, you could even strip+gzip it, which is all the 2.6.18-xen build
system does. Or the attached bzexplode.c will even extract the necessary
bits from a bzImage for you if that's all you have.

Ian.
-- 
Ian Campbell

Since we're all here, we must not be all there.
                -- Bob "Mountain" Beck
#include <stdio.h>
#include <fcntl.h>
#include <stdint.h>
#include <unistd.h>

#include <inttypes.h>

#include <err.h>

#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>

int main(int argc, char **argv)
{
	int fd;
	struct stat sb;
	void *p;
	uint8_t *hdr;
	int setup_sectors;
	uint32_t compressed_payload_offset;
	uint32_t compressed_payload_length;

	if (argc != 2)
		errx(1, "usage: bzexplode <bzImage>");

	fd = open(argv[1], O_RDONLY);
	if (fd < 0)
		err(1, "open");

	if (fstat(fd, &sb) < 0)
		err(1, "fstat");

	p = mmap(0, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
	if (p == MAP_FAILED)
		err(1, "mmap");

	hdr = p;
	setup_sectors = hdr[0x1f1];
	compressed_payload_offset = *(uint32_t*)&hdr[0x248];

	fprintf(stderr, "setup sectors %d\n", setup_sectors);

	compressed_payload_offset += (setup_sectors+1) * 512;

	//compressed_payload_length = *(uint32_t*)(p + compressed_payload_offset - 4);
	compressed_payload_length = *(uint32_t*)&hdr[0x24c];

	fprintf(stderr, "compressed_payload_offset %"PRIx32" (abs)\n",
		compressed_payload_offset);
	fprintf(stderr, "compressed_payload_length %"PRIx32"\n",
		compressed_payload_length);

	write(1,
	      p + compressed_payload_offset,
	      compressed_payload_length);
	return 0;
}

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to