Re: [edk2-devel] CPU hotplug using SMM with QEMU+OVMF
Igor Mammedov <imammedo@...>
On Tue, 27 Aug 2019 22:11:15 +0200
Laszlo Ersek <lersek@...> wrote: On 08/27/19 18:23, Igor Mammedov wrote:from SDM vol 3:On Mon, 26 Aug 2019 17:30:43 +0200The TSEG base calculation is not trivial in this environment. The 32-bit " 34.5.1 Initial SMM Execution Environment After saving the current context of the processor, the processor initializes its core registers to the values shown in Table 34-4. Upon entering SMM, the PE and PG flags in control register CR0 are cleared, which places the processor in an environment similar to real-address mode. The differences between the SMM execution environment and the real-address mode execution environment are as follows: • The addressable address space ranges from 0 to FFFFFFFFH (4 GBytes). • The normal 64-KByte segment limit for real-address mode is increased to 4 GBytes. • The default operand and address sizes are set to 16 bits, which restricts the addressable SMRAM address space to the 1-MByte real-address mode limit for native real-address-mode code. However, operand-size and address-size override prefixes can be used to access the address space beyond ^^^^^^^^ the 1-MByte. " we could map at 30000 not 64K required for save area but 128K and use 2nd half as secure RAM for stack and intermediate data. Firmware could put there pre-calculated pointer to TSEG after it's configured and locked down, this way relocation handler won't have to figure out TSEG address on its own. It also could execute INIT reset, which leaves initialized SMM untouched2: calculate its new SMBASE offset based on its APIC IDI agree about that implication, yes. *If* we send an INIT/SIPI/SIPI to but otherwise CPU would be inactive. Let me prepare a QEMU branch with something usable for you.8b could be trivial hlt loop and we most likely could skip 08a and signaling host CPU stepsI think we'll need a separate QEMU tree for this. I'm quite in the dark To avoid inventing mgmt API for configuring SMRAM at 30000, I'm suggesting to steal/alias top or bottom 128K of TSEG window to 30000. This way OVMF would be able to set SMI relocation handler modifying TSEG and pass TSEG base/other data to it as well. Would it work for you or should we try more elaborate approach? in case of broadcast SMI (btw does OVMF use broadcast SMIs?) several CPUs could end upIf the default SMBASE area is corrupted due to concurrent access, couldWe can serialize it (for normal hotplug flow) from ACPI handlerCan the SMI monarch use the LocalI agree this would be a huge help. with the same SMBASE within SMRAM 1: default one: in case the 2nd CPU enters SMM after the 1st CPU saved new SMBASE but before it's called RSM 2: duplicated SMBASE: where the 2nd CPU saves its new SMBASE before the 1st calls RSM while the 2nd could be counteracted with using locks, I don't see how 1st one could be avoided. May be host CPU can send 2nd SMI so just relocated CPU could send an ACK from relocated SMBASE/with new SMI handler?
|
|