From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Mon, 07 Oct 2019 02:44:42 -0700 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C6B18C049E1A; Mon, 7 Oct 2019 09:44:41 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-11.rdu2.redhat.com [10.10.120.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13DCD19C7F; Mon, 7 Oct 2019 09:44:35 +0000 (UTC) Subject: Re: [edk2-devel] [Qemu-devel] [PATCH 1/2] q35: implement 128K SMRAM at default SMBASE address To: Igor Mammedov Cc: "Chen, Yingwen" , Brijesh Singh , devel@edk2.groups.io, "phillip.goerl@oracle.com" , "qemu-devel@nongnu.org" , "alex.williamson@redhat.com" , "Yao, Jiewen" , "Nakajima, Jun" , "Kinney, Michael D" , "pbonzini@redhat.com" , "boris.ostrovsky@oracle.com" , "rfc@edk2.groups.io" , "joao.m.martins@oracle.com" References: <20190917130708.10281-1-imammedo@redhat.com> <20190917130708.10281-2-imammedo@redhat.com> <561f4440-7c06-10d7-80ce-bbfa810fec59@redhat.com> <20190920102855.3fe2b689@redhat.com> <20190924131936.7dec5e6c@redhat.com> <20190930143659.6de53f70@redhat.com> <74D8A39837DF1E4DA445A8C0B3885C503F7DFDB3@shsmsx102.ccr.corp.intel.com> <8f179aae-8ff4-2b2b-4024-1fd1156a3225@redhat.com> <20191004133052.20373155@redhat.com> From: "Laszlo Ersek" Message-ID: Date: Mon, 7 Oct 2019 11:44:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20191004133052.20373155@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 07 Oct 2019 09:44:41 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 10/04/19 13:31, Igor Mammedov wrote: > On Tue, 1 Oct 2019 20:03:20 +0200 > "Laszlo Ersek" wrote: >> (1) What values to use. > SeaBIOS writes 0x00 into command port, but it seems that's taken by > EFI_SMM_COMMUNICATION_PROTOCOL. So we can use the next unused value > (lets say 0x4). We probably don't have to use status port or > EFI_SMM_COMMUNICATION_PROTOCOL, since the value of written into 0xB2 > is sufficient to distinguish hotplug event. Thanks. Can you please write a QEMU patch for the ACPI generator such that hotplugging a VCPU writes value 4 to IO port 0xB2? That will allow me to experiment with OVMF. (I can experiment with some other parts in edk2 even before that.) >> (2) How the parameters are passed. >> >> >> (2a) For the new CPU, the SMI remains pending, until it gets an >> INIT-SIPI-SIPI from one of the previously plugged CPUs (most likely, the >> BSP). At that point, the new CPU will execute the "initial SMI handler >> for hotplugged CPUs", at the default SMBASE. >> >> That's a routine we'll have to write in assembly, from zero. In this >> routine, we can read back IO ports 0xB2 and 0xB3. And QEMU will be happy >> to provide the values last written (see apm_ioport_readb() in >> "hw/isa/apm.c"). So we can receive the values in this routine. Alright. > > Potentially we can can avoid writing custom SMI handler, > what do you think about following workflow: > > on system boot after initial CPUs relocation, firmware set NOP SMI handler > at default SMBASE. > Then as reaction to GPE triggered SMI (on cpu hotplug), after SMI rendezvous, > a host cpu reads IO port 0xB2 and does hotplugged CPUs enumeration. > > a) assuming we allow hotplug only in case of negotiated SMI broadcast > host CPU shoots down all in-flight INIT/SIPI/SIPI for hotpugged CPUs > to avoid race within relocation handler. How is that "shootdown" possible? > After that host CPU in loop > > b) it prepares/initializes necessary CPU structures for a hotplugged > CPU if necessary and replaces NOP SMI handler with the relocation > SMI handler that is used during system boot. > > c) a host CPU sends NOP INIT/SIPI/SIPI to the hotplugged CPU > > d) the woken up hotplugged CPU, jumps to default SMBASE and > executes hotplug relocation handler. > > e) after the hotplugged CPU is relocated and if there are more > hotplugged CPUs, a host CPU repeats b-d steps for the next > hotplugged CPU. > > f) after all CPUs are relocated, restore NOP SMI handler at default > SMBASE. > Thanks Laszlo