From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0E96021A134BB for ; Wed, 3 May 2017 05:58:59 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 770F4C059733; Wed, 3 May 2017 12:58:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 770F4C059733 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 770F4C059733 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-118.phx2.redhat.com [10.3.116.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4838817F4B; Wed, 3 May 2017 12:58:55 +0000 (UTC) To: Gerd Hoffmann , "Kinney, Michael D" References: <1382eb04-9646-133b-9ce5-8293cb54745f@redhat.com> <1493794647.8581.144.camel@redhat.com> Cc: "Fan, Jeff" , "Yao, Jiewen" , edk2-devel-01 , Paolo Bonzini From: Laszlo Ersek Message-ID: <159c4eae-4e13-7958-59f4-dfab4c1bf16e@redhat.com> Date: Wed, 3 May 2017 14:58:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1493794647.8581.144.camel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 03 May 2017 12:58:58 +0000 (UTC) Subject: Re: SMRAM sizes on large hosts X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 May 2017 12:58:59 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 05/03/17 08:57, Gerd Hoffmann wrote: > On Di, 2017-05-02 at 20:49 +0000, Kinney, Michael D wrote: >> Laszlo, >> >> Is it possible to add more TSEG sizes to the Q35 board? > > qemu implements what physical q35 support. The extended smram register > has two bits for the tseg size, three out of the four values are used > (for 1, 2, 8 MB sizes). "11" is reserved in the specs. We could use > "11" to implement a bigger tseg. Current code sets the tseg size to > zero for "11". Alternatively we could add some qemu-specific register. > > When implementing this in qemu we will have to do it runtime-switchable, > for backward compatibility with older qemu versions. So ideally > firmware would detect somehow whenever qemu supports a bigger tseg or > not and adapt at runtime. If edk2 can't do this we would need two edk2 > builds ... Thanks everyone for the feedback! After reading Mike's and Jiewen's replies, I've come to the same conclusion as Gerd. QEMU should provide a larger SMRAM, and it must be guest-detectable. I propose the following: add a new fw_cfg file which communicates how much memory (how many megabytes) the "11b" value in the tseg size register will configure. For starters (pc-q35-2.10), I recommend 16MB. For future Q35 board versions (pc-q35-2.11 and later), we can bump it to 32MB if necessary. The firmware does not have to *dictate* the size, it just needs to be able to see that "11b" is a valid selection (for "give me largest"), and what that "largest" exactly corresponds to. In the firmware, the TSEG size is handled internally to platform code (i.e., in OvmfPkg); it is selected by the PcdQ35TsegMbytes fixed-at-build PCD. The "OvmfPkg/PlatformPei" and "OvmfPkg/SmmAccess/SmmAccessPei" PEIMs consume it directly. Everything else gets the SMRAM size from the abstractions provided by those PEIMs. These PEIMs can consume fw_cfg. If the fw_cfg file is missing, then the firmware knows it can't select "11b". New firmware on old Q35 machine type versions will not find the fw_cfg file, hence OVMF will not use "11b". Old firmware on new Q35 machine type versions will ignore the fw_cfg file, and stick with the PcdQ35TsegMbytes preference. This will basically demote "PcdQ35TsegMbytes" from "TSEG size selection" to "TSEG size selection unless QEMU dictates it". There is one place in the code where the MCH_ESMRAMC register is read back to see the TSEG size. This is built into both SmmAccessPei and SmmAccess2Dxe. In the entry points of both SmmAccessPei and SmmAccess2Dxe, we can interrogate fw_cfg, and stash the size corresponding to 11b in a common global variable. Then we can rebase the common code to that global variable, in case it reads back 11b. So I think it can be made work. Does it sound good? Thanks! Laszlo