From patchwork Sun Sep 13 15:18:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 47163 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 n8DFJBwm027210 for ; Sun, 13 Sep 2009 15:19:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754669AbZIMPTG (ORCPT ); Sun, 13 Sep 2009 11:19:06 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754452AbZIMPTF (ORCPT ); Sun, 13 Sep 2009 11:19:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38243 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754529AbZIMPSz (ORCPT ); Sun, 13 Sep 2009 11:18:55 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8DFIwYv026646 for ; Sun, 13 Sep 2009 11:18:59 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8DFIvn7004511; Sun, 13 Sep 2009 11:18:58 -0400 Received: from localhost.localdomain (cleopatra.tlv.redhat.com [10.35.255.11]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 1CCCC250057; Sun, 13 Sep 2009 18:18:56 +0300 (IDT) From: Avi Kivity To: Marcelo Tosatti Cc: kvm@vger.kernel.org Subject: [PATCH 10/10] test: port readmode tests to multiboot Date: Sun, 13 Sep 2009 18:18:55 +0300 Message-Id: <1252855135-2519-11-git-send-email-avi@redhat.com> In-Reply-To: <1252855135-2519-1-git-send-email-avi@redhat.com> References: <1252855135-2519-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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 = .; }