public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>
Cc: "Fan, Jeff" <jeff.fan@intel.com>,
	"Yao, Jiewen" <jiewen.yao@intel.com>,
	edk2-devel-01 <edk2-devel@lists.01.org>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: SMRAM sizes on large hosts
Date: Wed, 3 May 2017 14:58:54 +0200	[thread overview]
Message-ID: <159c4eae-4e13-7958-59f4-dfab4c1bf16e@redhat.com> (raw)
In-Reply-To: <1493794647.8581.144.camel@redhat.com>

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


  parent reply	other threads:[~2017-05-03 12:58 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-02 18:16 SMRAM sizes on large hosts Laszlo Ersek
2017-05-02 20:49 ` Kinney, Michael D
2017-05-03  1:20   ` Yao, Jiewen
2017-05-03  6:57   ` Gerd Hoffmann
2017-05-03 12:56     ` Paolo Bonzini
2017-05-03 13:14       ` Laszlo Ersek
2017-05-03 13:26         ` Paolo Bonzini
2017-05-03 13:35           ` Laszlo Ersek
2017-05-03 13:55             ` Paolo Bonzini
2017-05-03 22:34               ` Laszlo Ersek
2017-05-03 12:58     ` Laszlo Ersek [this message]
2017-05-03 13:44       ` Gerd Hoffmann
2017-05-03 22:33         ` Laszlo Ersek
2017-05-03 23:36           ` Laszlo Ersek
2017-05-04  6:18             ` Gerd Hoffmann
2017-05-04 14:52             ` Gerd Hoffmann
2017-05-04 15:21               ` Laszlo Ersek
2017-05-04  8:23           ` Igor Mammedov
2017-05-04 11:34             ` Laszlo Ersek
2017-05-04 14:00               ` Igor Mammedov
2017-05-04 14:41                 ` Gerd Hoffmann
2017-05-04 14:50                   ` Igor Mammedov
2017-05-04 15:19                     ` Laszlo Ersek

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=159c4eae-4e13-7958-59f4-dfab4c1bf16e@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