public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: David Woodhouse <dwmw2@infradead.org>,
	Mike Maslenkin <mihailm@parallels.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>
Subject: Re: [edk2] [PATCH] OvmfPkg: QemuVideoDxe: Int10h stub for Windows 2008 R2 SP1 (stdvga, QXL)
Date: Wed, 19 Jun 2019 23:57:04 +0200	[thread overview]
Message-ID: <d010f0eb-4d13-cd59-73dd-d2242e230e21@redhat.com> (raw)
In-Reply-To: <5bb64abf34399bae00b678d0cd8b5df1ac81871b.camel@infradead.org>

Hi David,

On 06/17/19 12:52, David Woodhouse wrote:
> On Mon, 2014-05-12 at 20:21 +0400, Mike Maslenkin wrote:
>>>
>>>>> +  Segment0      = 0;
>>>>> +  Segment0Pages = 1;
>>>>> +  Status = gBS->AllocatePages (AllocateAddress, EfiReservedMemoryType,
>>>>> +                  Segment0Pages, &Segment0);
>>>>> +  if (EFI_ERROR (Status)) {
>>>>> +    goto RestorePam1;
>>>>> +  }
>>>>
>>>> If CSM is enabled, we will fail to allocate, right?
>>
>> Allocation at LegacyBiosInstall() function will fail, but no one cares
>> about it and MemoryAddress remains uninitialized. This is because uefi
>> video driver is being initialized earlier.
> 
> Right... at the time the above code runs, the CSM has already been
> initialised and installed a stub 'iret' handler for INT 10h, which in
> my case happens to be at F000:F065.
> 
> Because the CSM chose to put that in the F-segment not the E-segment,
> that happens not to trigger the check for an existing handler:
> 
>     //
>     // Check if a video BIOS handler has been installed previously -- we
>     // shouldn't override a real video BIOS with our shim, nor our own shim if
>     // it's already present.
>     //
>     Handler = (Int0x10->Segment << 4) + Int0x10->Offset;
>     if (Handler >= SegmentC && Handler < SegmentF) {
>       DEBUG ((EFI_D_INFO, "%a: Video BIOS handler found at %04x:%04x\n",
>         __FUNCTION__, Int0x10->Segment, Int0x10->Offset));
>       return;
>     }
> 
> So InstallVbeShim() goes ahead and copies the shim to the C-segment and
> points the INT10 vector to it (at C000:0200 it seems).
> 
> Later, LegacyBiosInstallRom() shadows the video OpROM, stomping on the
> shim. The very *next* thing it does before actually invoking the newly-
> shadowed OpROM is make an INT 10h call to put the display into a plain
> text mode. Which blows up since there's nothing useful at C000:0200 any
> more.
> 
> 
> There are a few ways we could fix this...
> 
> If I just move that PrepareToScanRom hook invocation (that sets the
> text mode) to happen before the CopyMem() of the shadowing, that makes
> things work again. But mostly by luck.
> 
> If I change the check in InstallVbeShim() to be '<= SegmentF' then the
> VBE shim won't install itself even over the CSM's iret stub. This is
> basically equivalent to making the VBE Shim refuse to install if
> CSM_ENABLE is set. And might be the right thing to do, since the VBE
> Shim isn't enough to actually make legacy code work.
> 
> It might also work if you were to allocate the space for the VBE shim
> so that we don't later try to shadow the real ROM to the same location.
> 
> Or maybe we should be letting the legacy BIOS video driver take
> precedence if the CSM has a video BIOS, and not letting the native
> drivers bind at all?
> 

In 2013, you submitted the following patch:

  OvmfPkg: Don't build in QemuVideoDxe when we have CSM

The thread starts here:

  https://www.mail-archive.com/edk2-devel@lists.sourceforge.net/msg01871.html

After an update:

  http://mid.mail-archive.com/1360493281.7383.26.camel@shinybook.infradead.org

I had given my R-b:

  http://mid.mail-archive.com/511816AD.9000603@redhat.com

But, the patch was never merged.

The commit hash referenced in those messages still works (pointing into your personal repo):

  http://git.infradead.org/users/dwmw2/edk2.git/commitdiff/22253c949e5

Can you resubmit that patch please?

Thanks,
Laszlo

  reply	other threads:[~2019-06-19 21:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1399571116-26442-1-git-send-email-lersek@redhat.com>
     [not found] ` <CAFe8ug8xKBXpvwP_O1AdzC1Ph4hYhp6PMRX+SmaBXaWxZ2J5VQ@mail.gmail.com>
     [not found]   ` <5370CA20.1030504@redhat.com>
     [not found]     ` <1399911663.21359.36.camel@mg-think.sw.ru>
2019-06-17 10:52       ` [edk2] [PATCH] OvmfPkg: QemuVideoDxe: Int10h stub for Windows 2008 R2 SP1 (stdvga, QXL) David Woodhouse
2019-06-19 21:57         ` Laszlo Ersek [this message]
2019-06-20  8:59           ` David Woodhouse
2019-06-20 14:41             ` [edk2-devel] " Laszlo Ersek
2019-06-20 16:08               ` David Woodhouse
2019-06-24 13:10               ` David Woodhouse

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-list 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=d010f0eb-4d13-cd59-73dd-d2242e230e21@redhat.com \
    --to=devel@edk2.groups.io \
    /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