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 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

