From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web08.3038.1611974207753017407 for ; Fri, 29 Jan 2021 18:36:48 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AB8xqJWV; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611974206; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mA2Y8m1jUsdUiSH4l5w1LGGjUWGIwcIqz1s90VWOpoA=; b=AB8xqJWVLjUSRDJ1NlWf6WzwuREBCh7tJscmBx4rPKW5kas4e3mis+gx+ibiAw5F+/usGw 4psf51rMunWAgaxEek8lslGumRBc8k1yd5Mpn7ItYcVixFO5gAD03J49oeYUr8wqVA2bs6 jCUQNL/CW3gcR6CUu/BY7+uhguxkM2w= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-131-ER7kxShsPh-Y6-c2RZPoKw-1; Fri, 29 Jan 2021 21:36:44 -0500 X-MC-Unique: ER7kxShsPh-Y6-c2RZPoKw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3265F5185; Sat, 30 Jan 2021 02:36:43 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-14.ams2.redhat.com [10.36.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 881EB1346F; Sat, 30 Jan 2021 02:36:41 +0000 (UTC) Subject: Re: [PATCH v6 3/9] OvmfPkg/CpuHotplugSmm: add Qemu Cpu Status helper To: Ankur Arora , devel@edk2.groups.io Cc: imammedo@redhat.com, boris.ostrovsky@oracle.com, Jordan Justen , Ard Biesheuvel , Aaron Young References: <20210129005950.467638-1-ankur.a.arora@oracle.com> <20210129005950.467638-4-ankur.a.arora@oracle.com> From: "Laszlo Ersek" Message-ID: Date: Sat, 30 Jan 2021 03:36:40 +0100 MIME-Version: 1.0 In-Reply-To: <20210129005950.467638-4-ankur.a.arora@oracle.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 01/29/21 01:59, Ankur Arora wrote: > Add QemuCpuhpWriteCpuStatus() which will be used to update the QEMU > CPU status register. On error, it hangs in a similar fashion as > other helper functions. > > Cc: Laszlo Ersek > Cc: Jordan Justen > Cc: Ard Biesheuvel > Cc: Igor Mammedov > Cc: Boris Ostrovsky > Cc: Aaron Young > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3132 > Signed-off-by: Ankur Arora > --- > OvmfPkg/CpuHotplugSmm/QemuCpuhp.h | 6 ++++++ > OvmfPkg/CpuHotplugSmm/QemuCpuhp.c | 22 ++++++++++++++++++++++ > 2 files changed, 28 insertions(+) > > diff --git a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h > index 8adaa0ad91f0..804809846890 100644 > --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h > +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h > @@ -30,6 +30,12 @@ QemuCpuhpReadCpuStatus ( > IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo > ); > > +VOID > +QemuCpuhpWriteCpuStatus ( > + IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo, > + IN UINT8 CpuStatus > + ); > + > UINT32 > QemuCpuhpReadCommandData ( > IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo > diff --git a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c > index f871e50c377b..ed44264de934 100644 > --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c > +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c > @@ -67,6 +67,28 @@ QemuCpuhpReadCpuStatus ( > return CpuStatus; > } > > +VOID > +QemuCpuhpWriteCpuStatus ( > + IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo, > + IN UINT8 CpuStatus > + ) > +{ > + EFI_STATUS Status; > + > + Status = MmCpuIo->Io.Write ( > + MmCpuIo, > + MM_IO_UINT8, > + ICH9_CPU_HOTPLUG_BASE + QEMU_CPUHP_R_CPU_STAT, > + 1, > + &CpuStatus > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, Status)); > + ASSERT (FALSE); > + CpuDeadLoop (); > + } > +} > + > UINT32 > QemuCpuhpReadCommandData ( > IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo > The code is fine, but please move the new function (both declaration and definition) between QemuCpuhpWriteCpuSelector() and QemuCpuhpWriteCommand(). Reason: the pre-patch order of the functions matches the order of the register descriptions in QEMU's "docs/specs/acpi_cpu_hotplug.txt". There, we first have a section called "read access", then another called "write access". And in each section, registers are listed in increasing offset order, within the hotplug register block. Thanks! Laszlo