From patchwork Sun Jan 6 12:36:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 209750 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9ACC22C0085 for ; Sun, 6 Jan 2013 23:36:51 +1100 (EST) Received: from localhost ([::1]:45651 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TrpT7-0002pg-JU for incoming@patchwork.ozlabs.org; Sun, 06 Jan 2013 07:36:49 -0500 Received: from eggs.gnu.org ([208.118.235.92]:56028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TrpSx-0002pY-8z for qemu-devel@nongnu.org; Sun, 06 Jan 2013 07:36:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TrpSw-0000zy-9S for qemu-devel@nongnu.org; Sun, 06 Jan 2013 07:36:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51442) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TrpSw-0000zu-1g for qemu-devel@nongnu.org; Sun, 06 Jan 2013 07:36:38 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r06CaaOt026350 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 6 Jan 2013 07:36:37 -0500 Received: from dhcp-1-237.tlv.redhat.com (dhcp-4-26.tlv.redhat.com [10.35.4.26]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r06CaaTH031982; Sun, 6 Jan 2013 07:36:36 -0500 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 9D0A018D479; Sun, 6 Jan 2013 14:36:35 +0200 (IST) Date: Sun, 6 Jan 2013 14:36:35 +0200 From: Gleb Natapov To: Alexander Graf Message-ID: <20130106123635.GC3440@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] linuxboot optionrom: do not jump into loaded kernel in a big real mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Big real mode is fully emulated by KVM now, so if control is passed to the loaded kernel while one of the segment registers is in big real mode all the real mode part of the Linux start up is emulated. This slows boot process down. Fix that by resetting ES limit to 0xffff before jumping into the kernel. The patch also removes unused code segment definition from GDT and changes ES register to be 16bit in protected mode since CS stays 16bit too and it is CS segment that determines effective operands and addresses length. Signed-off-by: Gleb Natapov --- Gleb. diff --git a/pc-bios/optionrom/linuxboot.S b/pc-bios/optionrom/linuxboot.S index 748c831..afe39a5 100644 --- a/pc-bios/optionrom/linuxboot.S +++ b/pc-bios/optionrom/linuxboot.S @@ -101,18 +101,20 @@ copy_kernel: mov $1, %eax mov %eax, %cr0 - /* So we can set ES to a 32-bit segment */ + /* So we can enlarge ES segment limit */ mov $0x10, %eax mov %eax, %es - /* We're now running in 16-bit CS, but 32-bit ES! */ - /* Load kernel and initrd */ read_fw_blob_addr32(FW_CFG_KERNEL) read_fw_blob_addr32(FW_CFG_INITRD) read_fw_blob_addr32(FW_CFG_CMDLINE) read_fw_blob_addr32(FW_CFG_SETUP) + /* Do not leave ES in big real mode */ + mov $0x08, %eax + mov %eax, %es + /* And now jump into Linux! */ mov $0, %eax mov %eax, %cr0 @@ -130,10 +132,10 @@ gdt: /* 0x00 */ .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - /* 0x08: code segment (base=0, limit=0xfffff, type=32bit code exec/read, DPL=0, 4k) */ -.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00 + /* 0x08: data segment (base=0, limit=0xffff, type=16bit data read/write, DPL=0, 4k) */ +.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00 - /* 0x10: data segment (base=0, limit=0xfffff, type=32bit data read/write, DPL=0, 4k) */ -.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00 + /* 0x10: data segment (base=0, limit=0xfffff, type=16bit data read/write, DPL=0, 4k) */ +.byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0x8f, 0x00 BOOT_ROM_END