From patchwork Thu Feb 18 16:13:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 80328 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1IGDrN7022634 for ; Thu, 18 Feb 2010 16:13:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757850Ab0BRQNu (ORCPT ); Thu, 18 Feb 2010 11:13:50 -0500 Received: from thoth.sbs.de ([192.35.17.2]:20574 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755850Ab0BRQNt (ORCPT ); Thu, 18 Feb 2010 11:13:49 -0500 Received: from mail2.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id o1IGDQim019220; Thu, 18 Feb 2010 17:13:26 +0100 Received: from [139.25.109.167] (mchn012c.mchp.siemens.de [139.25.109.167] (may be forged)) by mail2.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o1IGDPqt000680; Thu, 18 Feb 2010 17:13:26 +0100 Message-ID: <4B7D6725.1090202@siemens.com> Date: Thu, 18 Feb 2010 17:13:25 +0100 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Avi Kivity , Marcelo Tosatti CC: kvm , Anthony Liguori Subject: [PATCH 1/2] qemu-kvm: extboot: Keep variables in RAM Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 18 Feb 2010 16:13:53 +0000 (UTC) diff --git a/pc-bios/optionrom/extboot.S b/pc-bios/optionrom/extboot.S index 1e60f68..1eeb172 100644 --- a/pc-bios/optionrom/extboot.S +++ b/pc-bios/optionrom/extboot.S @@ -19,6 +19,9 @@ * Authors: Anthony Liguori */ +#define OLD_INT19 (0x80 * 4) /* re-use INT 0x80 BASIC vector */ +#define OLD_INT13 (0x81 * 4) /* re-use INT 0x81 BASIC vector */ + .code16 .text .global _start @@ -37,7 +40,7 @@ _start: /* save old int 19 */ mov (0x19*4), %eax - mov %eax, %cs:old_int19 + mov %eax, (OLD_INT19) /* install out int 19 handler */ movw $int19_handler, (0x19*4) @@ -48,6 +51,7 @@ _start: lret int19_handler: + push %eax /* reserve space for lret */ push %eax push %bx push %cx @@ -69,7 +73,7 @@ int19_handler: 1: /* hook int13: intb(0x404) == 1 */ /* save old int 13 to int 2c */ mov (0x13*4), %eax - mov %eax, %cs:old_int13 + mov %eax, (OLD_INT13) /* install our int 13 handler */ movw $int13_handler, (0x13*4) @@ -90,15 +94,21 @@ int19_handler: 3: /* fall through: inb(0x404) == 0 */ /* restore previous int $0x19 handler */ - mov %cs:old_int19,%eax + mov (OLD_INT19),%eax mov %eax,(0x19*4) - + + /* write old handler as return address onto stack */ + push %bp + mov %sp, %bp + mov %eax, 14(%bp) + pop %bp + pop %ds pop %dx pop %cx pop %bx pop %eax - ljmpw *%cs:old_int19 + lret #define FLAGS_CF 0x01 @@ -626,7 +636,21 @@ terminate_disk_emulation: int13_handler: cmp $0x80, %dl je 1f - ljmpw *%cs:old_int13 + + /* write old handler as return address onto stack */ + push %eax + push %eax + push %ds + push %bp + mov %sp, %bp + xor %ax, %ax + mov %ax, %ds + mov (OLD_INT13), %eax + mov %eax, 8(%bp) + pop %bp + pop %ds + pop %eax + lret 1: cmp $0x0, %ah jne 1f @@ -686,10 +710,5 @@ int13_handler: int $0x18 /* boot failed */ iret -/* Variables */ -.align 4, 0 -old_int13: .long 0 -old_int19: .long 0 - .align 512, 0 _end: