From patchwork Wed Sep 16 09:25:45 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 47885 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8G9QkSY009688 for ; Wed, 16 Sep 2009 09:26:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758393AbZIPJ0j (ORCPT ); Wed, 16 Sep 2009 05:26:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758386AbZIPJ0i (ORCPT ); Wed, 16 Sep 2009 05:26:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22345 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758283AbZIPJ0L (ORCPT ); Wed, 16 Sep 2009 05:26:11 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8G9QEA5013921 for ; Wed, 16 Sep 2009 05:26:14 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8G9QD7h005533; Wed, 16 Sep 2009 05:26:14 -0400 Received: from localhost.localdomain (cleopatra.tlv.redhat.com [10.35.255.11]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 00672250057; Wed, 16 Sep 2009 12:26:11 +0300 (IDT) From: Avi Kivity To: Marcelo Tosatti Cc: kvm@vger.kernel.org Subject: [PATCH QEMU-KVM 10/34] test: port readmode tests to multiboot Date: Wed, 16 Sep 2009 12:25:45 +0300 Message-Id: <1253093169-1423-11-git-send-email-avi@redhat.com> In-Reply-To: <1253093169-1423-1-git-send-email-avi@redhat.com> References: <1253093169-1423-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Signed-off-by: Avi Kivity --- kvm/user/test/x86/realmode.c | 52 ++++++++++++++++++++++++++++++++------- kvm/user/test/x86/realmode.lds | 6 +---- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/kvm/user/test/x86/realmode.c b/kvm/user/test/x86/realmode.c index f9e303f..9bf6cb0 100644 --- a/kvm/user/test/x86/realmode.c +++ b/kvm/user/test/x86/realmode.c @@ -549,7 +549,7 @@ void test_null(void) print_serial("null test: FAIL\n"); } -void start(void) +void realmode_start(void) { test_null(); @@ -570,23 +570,55 @@ void start(void) exit(0); } +unsigned long long r_gdt[] = { 0, 0x9b000000ffff, 0x93000000ffff }; + +struct __attribute__((packed)) { + unsigned short limit; + void *base; +} r_gdt_descr = { sizeof(r_gdt) - 1, &r_gdt }; + asm( + ".section .init \n\t" + + ".code32 \n\t" + + "mb_magic = 0x1BADB002 \n\t" + "mb_flags = 0x0 \n\t" + + "# multiboot header \n\t" + ".long mb_magic, mb_flags, 0 - (mb_magic + mb_flags) \n\t" + + ".globl start \n\t" ".data \n\t" ". = . + 4096 \n\t" "stacktop: \n\t" + ".text \n\t" - "init: \n\t" + "start: \n\t" + "lgdt r_gdt_descr \n\t" + "ljmp $8, $1f; 1: \n\t" + ".code16gcc \n\t" + "mov $16, %eax \n\t" + "mov %ax, %ds \n\t" + "mov %ax, %es \n\t" + "mov %ax, %fs \n\t" + "mov %ax, %gs \n\t" + "mov %ax, %ss \n\t" + "mov %cr0, %eax \n\t" + "btc $0, %eax \n\t" + "mov %eax, %cr0 \n\t" + "ljmp $0, $realmode_entry \n\t" + + "realmode_entry: \n\t" + "xor %ax, %ax \n\t" "mov %ax, %ds \n\t" "mov %ax, %es \n\t" "mov %ax, %ss \n\t" - "mov $0x4000, %cx \n\t" - "xor %esi, %esi \n\t" - "mov %esi, %edi \n\t" - "rep/addr32/cs/movsl \n\t" + "mov %ax, %fs \n\t" + "mov %ax, %gs \n\t" "mov $stacktop, %sp\n\t" - "ljmp $0, $start \n\t" - ".pushsection .boot, \"ax\" \n\t" - "ljmp $0xf000, $init \n\t" - ".popsection" + "ljmp $0, $realmode_start \n\t" + + ".code16gcc \n\t" ); diff --git a/kvm/user/test/x86/realmode.lds b/kvm/user/test/x86/realmode.lds index c9cdd7d..c7386b8 100644 --- a/kvm/user/test/x86/realmode.lds +++ b/kvm/user/test/x86/realmode.lds @@ -1,16 +1,12 @@ -OUTPUT_FORMAT(binary) - SECTIONS { - . = 0; + . = 16K; stext = .; .text : { *(.init) *(.text) } . = ALIGN(4K); .data : { *(.data) *(.rodata*) } . = ALIGN(16); .bss : { *(.bss) } - . = 0xfff0; - .boot : { *(.boot) } edata = .; }