qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Laszlo Ersek <lersek@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>
Subject: [PULL v2 07/17] acpi: cpuhp: spec: add typical usecases
Date: Wed, 22 Jan 2020 01:50:08 -0500	[thread overview]
Message-ID: <20200122064907.512501-8-mst@redhat.com> (raw)
In-Reply-To: <20200122064907.512501-1-mst@redhat.com>

From: Igor Mammedov <imammedo@redhat.com>

Document work-flows for
  * enabling/detecting modern CPU hotplug interface
  * finding a CPU with pending 'insert/remove' event
  * enumerating present and possible CPUs

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <1575896942-331151-9-git-send-email-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
 docs/specs/acpi_cpu_hotplug.txt | 51 +++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 3 deletions(-)

diff --git a/docs/specs/acpi_cpu_hotplug.txt b/docs/specs/acpi_cpu_hotplug.txt
index 9879f9ef7e..cb99cf3c8e 100644
--- a/docs/specs/acpi_cpu_hotplug.txt
+++ b/docs/specs/acpi_cpu_hotplug.txt
@@ -15,14 +15,14 @@ CPU present bitmap for:
   PIIX-PM  (IO port 0xaf00-0xaf1f, 1-byte access)
   One bit per CPU. Bit position reflects corresponding CPU APIC ID. Read-only.
   The first DWORD in bitmap is used in write mode to switch from legacy
-  to new CPU hotplug interface, write 0 into it to do switch.
+  to modern CPU hotplug interface, write 0 into it to do switch.
 ---------------------------------------------------------------
 QEMU sets corresponding CPU bit on hot-add event and issues SCI
 with GPE.2 event set. CPU present map is read by ACPI BIOS GPE.2 handler
 to notify OS about CPU hot-add events. CPU hot-remove isn't supported.
 
 =====================================
-ACPI CPU hotplug interface registers:
+Modern ACPI CPU hotplug interface registers:
 -------------------------------------
 Register block base address:
     ICH9-LPC IO port 0x0cd8
@@ -67,6 +67,7 @@ write access:
     [0x0-0x3] CPU selector: (DWORD access)
               selects active CPU device. All following accesses to other
               registers will read/store data from/to selected CPU.
+              Valid values: [0 .. max_cpus)
     [0x4] CPU device control fields: (1 byte access)
         bits:
             0: reserved, OSPM must clear it before writing to register.
@@ -98,4 +99,48 @@ write access:
               2: stores value into OST status register, triggers
                  ACPI_DEVICE_OST QMP event from QEMU to external applications
                  with current values of OST event and status registers.
-            other values: reserved
+              other values: reserved
+
+Typical usecases:
+    - (x86) Detecting and enabling modern CPU hotplug interface.
+      QEMU starts with legacy CPU hotplug interface enabled. Detecting and
+      switching to modern interface is based on the 2 legacy CPU hotplug features:
+        1. Writes into CPU bitmap are ignored.
+        2. CPU bitmap always has bit#0 set, corresponding to boot CPU.
+
+      Use following steps to detect and enable modern CPU hotplug interface:
+        1. Store 0x0 to the 'CPU selector' register,
+           attempting to switch to modern mode
+        2. Store 0x0 to the 'CPU selector' register,
+           to ensure valid selector value
+        3. Store 0x0 to the 'Command field' register,
+        4. Read the 'Command data 2' register.
+           If read value is 0x0, the modern interface is enabled.
+           Otherwise legacy or no CPU hotplug interface available
+
+    - Get a cpu with pending event
+      1. Store 0x0 to the 'CPU selector' register.
+      2. Store 0x0 to the 'Command field' register.
+      3. Read the 'CPU device status fields' register.
+      4. If both bit#1 and bit#2 are clear in the value read, there is no CPU
+         with a pending event and selected CPU remains unchanged.
+      5. Otherwise, read the 'Command data' register. The value read is the
+         selector of the CPU with the pending event (which is already
+         selected).
+
+    - Enumerate CPUs present/non present CPUs
+      01. Set the present CPU count to 0.
+      02. Set the iterator to 0.
+      03. Store 0x0 to the 'CPU selector' register, to ensure that it's in
+          a valid state and that access to other registers won't be ignored.
+      04. Store 0x0 to the 'Command field' register to make 'Command data'
+          register return 'CPU selector' value of selected CPU
+      05. Read the 'CPU device status fields' register.
+      06. If bit#0 is set, increment the present CPU count.
+      07. Increment the iterator.
+      08. Store the iterator to the 'CPU selector' register.
+      09. Read the 'Command data' register.
+      10. If the value read is not zero, goto 05.
+      11. Otherwise store 0x0 to the 'CPU selector' register, to put it
+          into a valid state and exit.
+          The iterator at this point equals "max_cpus".
-- 
MST



  parent reply	other threads:[~2020-01-22  6:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-22  6:49 [PULL v2 00/17] virtio, pc: fixes, features Michael S. Tsirkin
2020-01-22  6:49 ` [PULL v2 01/17] q35: implement 128K SMRAM at default SMBASE address Michael S. Tsirkin
2020-01-22  6:49 ` [PULL v2 02/17] tests: q35: MCH: add default SMBASE SMRAM lock test Michael S. Tsirkin
2020-01-22  6:49 ` [PULL v2 03/17] acpi: cpuhp: spec: clarify 'CPU selector' register usage and endianness Michael S. Tsirkin
2020-01-22  6:50 ` [PULL v2 04/17] acpi: cpuhp: spec: fix 'Command data' description Michael S. Tsirkin
2020-01-22  6:50 ` [PULL v2 05/17] acpi: cpuhp: spec: clarify store into 'Command data' when 'Command field' == 0 Michael S. Tsirkin
2020-01-22  6:50 ` [PULL v2 06/17] acpi: cpuhp: introduce 'Command data 2' field Michael S. Tsirkin
2020-01-22  6:50 ` Michael S. Tsirkin [this message]
2020-01-22  6:50 ` [PULL v2 08/17] acpi: cpuhp: add CPHP_GET_CPU_ID_CMD command Michael S. Tsirkin
2020-01-22  6:50 ` [PULL v2 09/17] bios-tables-test: document expected file update Michael S. Tsirkin
2020-01-22  6:50 ` [PULL v2 10/17] virtio-9p-device: fix memleak in virtio_9p_device_unrealize Michael S. Tsirkin
2020-01-22  6:50 ` [PULL v2 11/17] virtio-9p-device: convert to new virtio_delete_queue Michael S. Tsirkin
2020-01-22  6:50 ` [PULL v2 12/17] virtio-scsi: delete vqs in unrealize to avoid memleaks Michael S. Tsirkin
2020-01-22  6:50 ` [PULL v2 13/17] virtio-scsi: convert to new virtio_delete_queue Michael S. Tsirkin
2020-01-22  6:50 ` [PULL v2 14/17] vhost-vsock: delete vqs in vhost_vsock_unrealize to avoid memleaks Michael S. Tsirkin
2020-01-22  6:50 ` [PULL v2 15/17] vhost: Add names to section rounded warning Michael S. Tsirkin
2020-01-22  6:50 ` [PULL v2 16/17] vhost: Only align sections for vhost-user Michael S. Tsirkin
2020-01-22  6:50 ` [PULL v2 17/17] i386:acpi: Remove _HID from the SMBus ACPI entry Michael S. Tsirkin
2020-01-22  7:10 ` [PULL v2 00/17] virtio, pc: fixes, features no-reply
2020-01-22  8:07   ` Michael S. Tsirkin
2020-01-23 14:30 ` Peter Maydell

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-all 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=20200122064907.512501-8-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=lersek@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).