From: "Laszlo Ersek" <lersek@redhat.com>
To: devel@edk2.groups.io, afish@apple.com
Subject: Re: [edk2-devel] Question about the OVMF and MTRRs?
Date: Tue, 7 Jul 2020 21:08:52 +0200 [thread overview]
Message-ID: <236d9a8e-7c7c-90a5-ca79-849ba6e7f4fb@redhat.com> (raw)
In-Reply-To: <369C9B43-A02C-4AEB-8F02-735E1042ABB2@apple.com>
Hi Andrew,
On 07/03/20 19:22, Andrew Fish via groups.io wrote:
> I noticed for my version of QEMU that MTRR registers are not supported. Is that expected? Or is it something if you get wrong it does not break in QEMU?
>
> Due to no MTRR support the CPU Protocol SetMemoeryAttributes() call is falling [1] and non of the GCD ranges have EFI_MEMORY_UC Attribute.
>
> I’m not sure but I think the no MTRR case should attempt to set the attributes via page tables via:
>
> return AssignMemoryPageAttributes (NULL, BaseAddress, Length, MemoryAttributes, NULL);
>
> Vs
>
> return EFI_UNSUPPORTED;
>
> [1] https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/CpuDxe/CpuDxe.c#L429
sorry, reaching this email only now.
I wouldn't really expect IsMtrrSupported() to return FALSE.
BOOLEAN
EFIAPI
IsMtrrSupported (
VOID
)
{
CPUID_VERSION_INFO_EDX Edx;
MSR_IA32_MTRRCAP_REGISTER MtrrCap;
//
// Check CPUID(1).EDX[12] for MTRR capability
//
AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &Edx.Uint32);
if (Edx.Bits.MTRR == 0) {
return FALSE;
}
//
// Check number of variable MTRRs and fixed MTRRs existence.
// If number of variable MTRRs is zero, or fixed MTRRs do not
// exist, return false.
//
MtrrCap.Uint64 = AsmReadMsr64 (MSR_IA32_MTRRCAP);
if ((MtrrCap.Bits.VCNT == 0) || (MtrrCap.Bits.FIX == 0)) {
return FALSE;
}
return TRUE;
}
In QEMU, the rdmsr is handled in "target/i386/misc_helper.c", function
helper_rdmsr():
case MSR_MTRRcap:
if (env->features[FEAT_1_EDX] & CPUID_MTRR) {
val = MSR_MTRRcap_VCNT | MSR_MTRRcap_FIXRANGE_SUPPORT |
MSR_MTRRcap_WC_SUPPORTED;
} else {
/* XXX: exception? */
val = 0;
}
break;
thus the second "FALSE" branch in IsMtrrSupported() can never be
reached. (Either the first "FALSE" branch is taken, or the "TRUE" branch
is taken.) MSR_MTRRcap_VCNT is 8.
Regarding the first "FALSE" branch, whether that is taken depends on the
QEMU CPU model (or the QEMU command line). Check "target/i386/cpu.c" for
"CPUID_MTRR".
Unfortunately I can't think of an easy way to list the CPU models that
do *not* have CPUID_MTRR. What is your CPU model?
Thanks
Laszlo
prev parent reply other threads:[~2020-07-07 19:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-03 17:22 Question about the OVMF and MTRRs? Andrew Fish
2020-07-07 19:08 ` Laszlo Ersek [this message]
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=236d9a8e-7c7c-90a5-ca79-849ba6e7f4fb@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