mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zachary Amsden <zach@vmware.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Andrew Morton <akpm@osdl.org>, Chris Wright <chrisw@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Virtualization Mailing List <virtualization@lists.osdl.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Zwane Mwaikambo <zwane@arm.linux.org.uk>,
	Martin Bligh <mbligh@mbligh.org>,
	Pratap Subrahmanyam <pratap@vmware.com>,
	Christopher Li <chrisl@vmware.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH 4/21] i386 Broken bios common
Date: Tue, 08 Nov 2005 13:07:10 -0800	[thread overview]
Message-ID: <4371137E.50202@vmware.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0511080703530.3247@g5.osdl.org>

Linus Torvalds wrote:

>On Mon, 7 Nov 2005, Zachary Amsden wrote:
>  
>
>>Both the APM BIOS and PnP BIOS code use a segment hack to simulate real
>>mode selector 0x40 (which points to the BIOS data area at 0x00400 in
>>real mode).  Several broken BIOSen use selector 0x40 as if they were
>>running in real mode, which we make work by faking up selector 0x40 in
>>the GDT to point to physical memory starting at 0x400.  We limit the
>>access to the remainder of this physical page using a byte granular
>>limit.  Rather than have this tricky code in multiple places, it makes
>>sense to define it in one place, and the GDT makes a very convenient
>>place for it.  Use GDT entry 4 as the BAD_BIOS_CACHE segment.
>>    
>>
>
>I'd much rather use entry 8 instead, which should just automatically mean 
>that selector 0x40 _always_ points to virtual address 0x400. No switching 
>etc..
>
>Isn't this what Wine already has to work around, or something?
>
>Ingo, can we move the TLS selectors upwards, or does user space perhaps 
>know about the current TLS layout? Wine in particular may well know ;(
>  
>

Looking at the Wine code, it doesn't seem to know.  It uses a GDT entry 
if possible in preference to an LDT entry, and appears to not care which 
TLS descriptor it gets.  So I think it would be safe to reserve selector 
0x40 for the BIOS real mode segment and move TLS up.  That's kind of a 
scary change, but I don't see anything wrong with it other than the 
testing implications.  Hopefully DOSEmu is not affected..


/***********************************************************************
 *           wine_ldt_alloc_fs
 *
 * Allocate an LDT entry for a %fs selector, reusing a global
 * GDT selector if possible. Return the selector value.
 */
unsigned short wine_ldt_alloc_fs(void)
{
    if (global_fs_sel == -1)
    {
        struct modify_ldt_s ldt_info;
        int ret;

        ldt_info.entry_number = -1;   <---------  note it doesn't care
        fill_modify_ldt_struct( &ldt_info, &null_entry );
        if ((ret = set_thread_area( &ldt_info ) < 0))
        {
            global_fs_sel = 0;  /* don't try it again */
            if (errno != ENOSYS) perror( "set_thread_area" );
        }
        else global_fs_sel = (ldt_info.entry_number << 3) | 3;
    }
    if (global_fs_sel > 0) return global_fs_sel;
    return wine_ldt_alloc_entries( 1 );




  parent reply	other threads:[~2005-11-08 21:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-08  4:22 Zachary Amsden
2005-11-08  7:19 ` Ingo Molnar
2005-11-08 12:48   ` Zachary Amsden
2005-11-08 12:57     ` Ingo Molnar
2005-11-08 15:06 ` Linus Torvalds
2005-11-08 15:16   ` H. Peter Anvin
2005-11-08 21:07   ` Zachary Amsden [this message]
2005-11-08 21:52   ` Zachary Amsden

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4371137E.50202@vmware.com \
    --to=zach@vmware.com \
    --cc=akpm@osdl.org \
    --cc=chrisl@vmware.com \
    --cc=chrisw@osdl.org \
    --cc=ebiederm@xmission.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbligh@mbligh.org \
    --cc=mingo@elte.hu \
    --cc=pratap@vmware.com \
    --cc=torvalds@osdl.org \
    --cc=virtualization@lists.osdl.org \
    --cc=zwane@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome