* Question about the OVMF and MTRRs?
@ 2020-07-03 17:22 Andrew Fish
2020-07-07 19:08 ` [edk2-devel] " Laszlo Ersek
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Fish @ 2020-07-03 17:22 UTC (permalink / raw)
To: edk2-devel-groups-io
[-- Attachment #1: Type: text/plain, Size: 635 bytes --]
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
Thanks,
Andrew Fish
[-- Attachment #2: Type: text/html, Size: 3444 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [edk2-devel] Question about the OVMF and MTRRs?
2020-07-03 17:22 Question about the OVMF and MTRRs? Andrew Fish
@ 2020-07-07 19:08 ` Laszlo Ersek
0 siblings, 0 replies; 2+ messages in thread
From: Laszlo Ersek @ 2020-07-07 19:08 UTC (permalink / raw)
To: devel, afish
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-07 19:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-03 17:22 Question about the OVMF and MTRRs? Andrew Fish
2020-07-07 19:08 ` [edk2-devel] " Laszlo Ersek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox