From: "David Woodhouse" <dwmw2@infradead.org>
To: Mike Maslenkin <mihailm@parallels.com>, Laszlo Ersek <lersek@redhat.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: Mon, 17 Jun 2019 11:52:53 +0100 [thread overview]
Message-ID: <5bb64abf34399bae00b678d0cd8b5df1ac81871b.camel@infradead.org> (raw)
In-Reply-To: <1399911663.21359.36.camel@mg-think.sw.ru>
[-- Attachment #1: Type: text/plain, Size: 2695 bytes --]
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?
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5174 bytes --]
next parent reply other threads:[~2019-06-17 10:53 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 ` David Woodhouse [this message]
2019-06-19 21:57 ` [edk2] [PATCH] OvmfPkg: QemuVideoDxe: Int10h stub for Windows 2008 R2 SP1 (stdvga, QXL) Laszlo Ersek
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=5bb64abf34399bae00b678d0cd8b5df1ac81871b.camel@infradead.org \
--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