public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Hangaohuai <hangaohuai@huawei.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	Igor Mammedov <imammedo@redhat.com>
Subject: Re: [Help] UEFI boot KVM4T vm hang On TianoCore
Date: Tue, 7 Nov 2017 15:06:22 +0100	[thread overview]
Message-ID: <bcc8ecff-acaa-ee62-f6b6-1b6e2e6bc636@redhat.com> (raw)
In-Reply-To: <643686C90A8F6046B2C3783E2A7A06AD3DDC1320@dggeml506-mbs.china.huawei.com>

On 11/07/17 03:39, Hangaohuai wrote:
> Hi, Laszlo Ersek;
> Thanks for your reply.
> 
> I have trying to shoot this trouble:
> 
> 1. edk get the MtrrValidBitsMask by "AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, &VirPhyAddressSize.Uint32, NULL, NULL, NULL); "(0x80000008)
> 2. Cpuid(0x80000008) is held in kvm struct (&vcpu->arch.cpuid_entries[i])
> 3. (0x80000008) is set by qemu;
> 
> Part1:
> We set the <maxMemory slots='256' unit='KiB'>4294967296</maxMemory>, the "GetFirstNonAddress: Pci64Base=0x44800000000"
> But the MtrrValidBitsMask get 0x3FF FFFF FFFF;
> Does not pass the check.
>   MtrrLibInitializeMtrrMask (&MtrrValidBitsMask, &MtrrValidAddressMask);
>   if (((BaseAddress & ~MtrrValidAddressMask) != 0) || (Length & ~MtrrValidAddressMask) != 0) {
>     return RETURN_UNSUPPORTED;
>   }
> 
> Part2:
> Xhci_hcd will use the address above maxMemory, so we visit the wrong address.
> Checking by starting a <maxMemory slots='256' unit='KiB'>3294967296</maxMemory> memory with USB3.0.
> 
> So , I think edk2 is ok; maxMemory depend on CPU support more the 42bit.

That's right; if you look at /proc/cpuinfo on your KVM host, it will say
something like:

address sizes   : 39 bits physical, 48 bits virtual
                  ^^^^^^^^^^^^^^^^

(the actual number will vary).

With EPT enabled (see "/sys/module/kvm_intel/parameters/ept"), the guest
cannot have a larger guest-phys address space than what's supported by
the host CPU's physical address width.

Thanks,
Laszlo


> 
> 
> ***********************
> Hi,
> 
> sorry about the delayed response.
> 
> CC'ing Igor, and commenting below:
> 
> On 10/31/17 15:29, Hangaohuai wrote:
>> Hi, Laszlo Ersek;
>>
>> I have tested the uefi booting KVM vm with the configuration(xml); but 
>> start hang.
>> Enable the memoryhotplug, with usb3.0 config. The config as Config1 
>> below.
>>
>> Tested branches:
>> UDK2017     eea98eea4ccbb1d640657770bccb5497fddc6064
>> Master       76fd5a660d704538a1b14a58d03a4eef9682b01c
>>
>> Both hang on the snapshot TianoCore in VNC
>>
>> Try to shoot the problem;
>> I find the early version can boot success with the same config.
>> Maybe the patch1 below cause the problem;
>>
>> Try to ignore the patch does, the master/ UDK2017 both can boot 
>> success.
>> But I don't know why. Hope for your help,thanks.
>>
>> Patch1
>> ***********************************************
>> commit 4f5eff8193096eb847639f090a7dfae3cff95fde
>> Author: Laszlo Ersek <lersek@redhat.com>
>> Date:   Fri Mar 4 20:06:26 2016 +0100
>>
>> OvmfPkg: PciHostBridgeLib: install 64-bit PCI host aperture
>>
>> diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c 
>> b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib
>> index 3e02778..1d3d10a 100644
>> --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
>> +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
>> @@ -132,6 +132,13 @@ InitRootBridge (
>>    RootBus->MemAbove4G.Base      = 0;
>>    RootBus->MemAbove4G.Limit     = 0;
>> +  if (PcdGet64 (PcdPciMmio64Size) > 0) {
>> +    RootBus->AllocationAttributes |= EFI_PCI_HOST_BRIDGE_MEM64_DECODE;
>> +    RootBus->MemAbove4G.Base       = PcdGet64 (PcdPciMmio64Base);
>> +    RootBus->MemAbove4G.Limit      = PcdGet64 (PcdPciMmio64Base) +
>> +                                     (PcdGet64 (PcdPciMmio64Size) - 
>> + 1);  }
>> +
>>    RootBus->Bus.Base  = RootBusNumber;
>>    RootBus->Bus.Limit = MaxSubBusNumber;
>>    RootBus->Io.Base   = PcdGet64 (PcdPciIoBase);
>> diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf 
>> b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeL
>> index bbec746..7a964c7 100644
>> --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
>> +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
>> @@ -51,4 +51,6 @@
>>    gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize
>>    gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base
>>    gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size
>> +  gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base
>> +  gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size
>>    gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
>> ***********************************************
>>
>>
>> Config1
>> ***********************************************
>> <maxMemory slots='256' unit='KiB'>4294967296</maxMemory>
>>   <memory unit='KiB'>4294967</memory>
>>   <currentMemory unit='KiB'>4294967</currentMemory>
>> Xxxx
>> <controller type='usb' index='2' model='nec-xhci'>
>>     <address type='pci' domain='0x0000' bus='0x00' slot='0x1c' 
>> function='0x0'/>  </controller>
>> ***********************************************
> 
> The patch that you identified is responsible for exposing the 64-bit MMIO aperture for PCI MMIO BAR allocation purposes.
> 
> Reverting this patch might mask the issue, but I don't expect the actual problem to be in this patch.
> 
> Instead, the base address and the size of the aperture in question is determined in the file
> 
>   OvmfPkg/PlatformPei/MemDetect.c
> 
> in the function
> 
>   GetFirstNonAddress()
> 
> This function takes the memory (DIMM) hotplug range in question, the end of which is presented by QEMU in the fw_cfg file
> 
>   etc/reserved-memory-end
> 
> To my knowledge, this fw_cfg file is an 8-byte integer in LE encoding.
> 
> Quoting the code:
> 
>>   //
>>   // If QEMU presents an E820 map, then get the highest exclusive >=4GB RAM
>>   // address from it. This can express an address >= 4GB+1TB.
>>   //
>>   // Otherwise, get the flat size of the memory above 4GB from the CMOS (which
>>   // can only express a size smaller than 1TB), and add it to 4GB.
>>   //
>>   Status = ScanOrAdd64BitE820Ram (&FirstNonAddress);
>>   if (EFI_ERROR (Status)) {
>>     FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb ();
>>   }
>>
>> ...
>>
>>   //
>>   // The "etc/reserved-memory-end" fw_cfg file, when present, contains an
>>   // absolute, exclusive end address for the memory hotplug area. This area
>>   // starts right at the end of the memory above 4GB. The 64-bit PCI host
>>   // aperture must be placed above it.
>>   //
>>   Status = QemuFwCfgFindFile ("etc/reserved-memory-end", &FwCfgItem,
>>              &FwCfgSize);
>>   if (!EFI_ERROR (Status) && FwCfgSize == sizeof HotPlugMemoryEnd) {
>>     QemuFwCfgSelectItem (FwCfgItem);
>>     QemuFwCfgReadBytes (FwCfgSize, &HotPlugMemoryEnd);
>>
>>     ASSERT (HotPlugMemoryEnd >= FirstNonAddress);
>>     FirstNonAddress = HotPlugMemoryEnd;
>>   }
> 
> Can you check if the ASSERT fires for you?
> 
> For that, please capture the OVMF debug log like this:
> 
> (1) build OVMF with the following flag:
> 
>   --pcd=gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel=0x8040004F
> 
> (2) modify your domain XML as follows:
> 
>   <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
>                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^   <--- don't forget this attribute!
>     <qemu:commandline>
>       <qemu:arg value='-global'/>
>       <qemu:arg value='isa-debugcon.iobase=0x402'/>
>       <qemu:arg value='-debugcon'/>
>       <qemu:arg value='file:/tmp/ovmf.log'/>
>     </qemu:commandline>
>   </domain>
> 
> Then the file "/tmp/ovmf.log" should contain a verbose OVMF log -- please attach it.
> 
> Thanks
> Laszlo
> 



      reply	other threads:[~2017-11-07 14:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-31 14:29 [Help] UEFI boot KVM4T vm hang On TianoCore Hangaohuai
2017-11-06 19:10 ` Laszlo Ersek
2017-11-07  2:39   ` Hangaohuai
2017-11-07 14:06     ` 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=bcc8ecff-acaa-ee62-f6b6-1b6e2e6bc636@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