• D
    test: Postcopy · ea0c6d62
    Dr. David Alan Gilbert 提交于
    This is a postcopy test (x86 only) that actually runs the guest
    and checks the memory contents.
    
    The test runs from an x86 boot block with the hex embedded in the test;
    the source for this is:
    
    ...........
    
    .code16
    .org 0x7c00
    	.file	"fill.s"
    	.text
    	.globl	start
    	.type	start, @function
    start:             # at 0x7c00 ?
            cli
            lgdt gdtdesc
            mov $1,%eax
            mov %eax,%cr0  # Protected mode enable
            data32 ljmp $8,$0x7c20
    
    .org 0x7c20
    .code32
            # A20 enable - not sure I actually need this
            inb $0x92,%al
            or  $2,%al
            outb %al, $0x92
    
            # set up DS for the whole of RAM (needed on KVM)
            mov $16,%eax
            mov %eax,%ds
    
            mov $65,%ax
            mov $0x3f8,%dx
            outb %al,%dx
    
            # bl keeps a counter so we limit the output speed
            mov $0, %bl
    mainloop:
            # Start from 1MB
            mov $(1024*1024),%eax
    innerloop:
            incb (%eax)
            add $4096,%eax
            cmp $(100*1024*1024),%eax
            jl innerloop
    
            inc %bl
            jnz mainloop
    
            mov $66,%ax
            mov $0x3f8,%dx
            outb %al,%dx
    
    	jmp mainloop
    
            # GDT magic from old (GPLv2)  Grub startup.S
            .p2align        2       /* force 4-byte alignment */
    gdt:
            .word   0, 0
            .byte   0, 0, 0, 0
    
            /* -- code segment --
             * base = 0x00000000, limit = 0xFFFFF (4 KiB Granularity), present
             * type = 32bit code execute/read, DPL = 0
             */
            .word   0xFFFF, 0
            .byte   0, 0x9A, 0xCF, 0
    
            /* -- data segment --
             * base = 0x00000000, limit 0xFFFFF (4 KiB Granularity), present
             * type = 32 bit data read/write, DPL = 0
             */
            .word   0xFFFF, 0
            .byte   0, 0x92, 0xCF, 0
    
    gdtdesc:
            .word   0x27                    /* limit */
            .long   gdt                     /* addr */
    
    /* I'm a bootable disk */
    .org 0x7dfe
            .byte 0x55
            .byte 0xAA
    
    ...........
    
    and that can be assembled by the following magic:
        as --32 -march=i486 fill.s -o fill.o
        objcopy -O binary fill.o fill.boot
        dd if=fill.boot of=bootsect bs=256 count=2 skip=124
        xxd -i bootsect
    Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
    Reviewed-by: NMarcel Apfelbaum <marcel@redhat.com>
    Message-id: 1465816605-29488-5-git-send-email-dgilbert@redhat.com
    Message-Id: <1465816605-29488-5-git-send-email-dgilbert@redhat.com>
    Signed-off-by: NAmit Shah <amit.shah@redhat.com>
    ea0c6d62
Makefile.include 34.2 KB