From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web11.5105.1588707839352789044 for ; Tue, 05 May 2020 12:44:00 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RckxLjW7; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588707838; 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=mEkiO06Upeq/zuwYBNJh0t3e/MVVe1SA9GIS1jyLdb8=; b=RckxLjW7ngeqnLt1cdp1K7+n6umkGCJWzP/EYD3hG79R04ks87AzkgTE3/1H58BljxChL6 9Q6ys++bJnwhi353LgRTuMojmvOs1Yb2Tt+Nt0QEpDdM60itaeUoS5e3hPLdeZtkwU0QN8 R1HyK4QYz2R4GkZOSf0CDpycwAKG7jY= 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-190-EUT9Y5_RMa-K_hr9wiFHXg-1; Tue, 05 May 2020 15:43:46 -0400 X-MC-Unique: EUT9Y5_RMa-K_hr9wiFHXg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79C0664AD8; Tue, 5 May 2020 19:43:45 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-134.ams2.redhat.com [10.36.114.134]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42252707B5; Tue, 5 May 2020 19:43:43 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 1/1] OvmfPkg: Add BaseResetSystemLibBhyve.inf To: devel@edk2.groups.io, rebecca@bsdio.com Cc: Jordan Justen , Ard Biesheuvel References: <20200504021853.76658-1-rebecca@bsdio.com> From: "Laszlo Ersek" Message-ID: <8fd1f0c6-d1ce-784d-aaeb-fe31f980b612@redhat.com> Date: Tue, 5 May 2020 21:43:43 +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: <20200504021853.76658-1-rebecca@bsdio.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 05/04/20 04:18, Rebecca Cran wrote: > Introduce BaseResetSystemLibBhyve.inf, to support powering off > bhyve guests. > > Signed-off-by: Rebecca Cran > Cc: Jordan Justen > Cc: Laszlo Ersek > Cc: Ard Biesheuvel > --- > Laszlo: I couldn't find your email specifying specific changes to > make, It's archived here: http://mid.mail-archive.com/f1dacfcb-fd50-6e58-965b-656181d3d6d2@redhat.com https://edk2.groups.io/g/devel/message/58076 (1) The ".inf" should be stripped from the subject line. > so I hope I've caught all of them. > > OvmfPkg/Include/IndustryStandard/Bhyve.h | 2 + > .../ResetSystemLib/BaseResetShutdownBhyve.c | 34 ++++++++++++++++ > .../BaseResetSystemLibBhyve.inf | 40 +++++++++++++++++++ > 3 files changed, 76 insertions(+) > create mode 100644 OvmfPkg/Library/ResetSystemLib/BaseResetShutdownBhyve.c > create mode 100644 OvmfPkg/Library/ResetSystemLib/BaseResetSystemLibBhyve.inf > > diff --git a/OvmfPkg/Include/IndustryStandard/Bhyve.h b/OvmfPkg/Include/IndustryStandard/Bhyve.h > index 02ce5587ee0f..ab8f2b0729b4 100644 > --- a/OvmfPkg/Include/IndustryStandard/Bhyve.h > +++ b/OvmfPkg/Include/IndustryStandard/Bhyve.h > @@ -13,4 +13,6 @@ > > #define BHYVE_ACPI_TIMER_IO_ADDR 0x408 > > +#define BHYVE_PM_REG 0x404 > + > #endif // __BHYVE_H__ > diff --git a/OvmfPkg/Library/ResetSystemLib/BaseResetShutdownBhyve.c b/OvmfPkg/Library/ResetSystemLib/BaseResetShutdownBhyve.c > new file mode 100644 > index 000000000000..156e5ad0d797 > --- /dev/null > +++ b/OvmfPkg/Library/ResetSystemLib/BaseResetShutdownBhyve.c > @@ -0,0 +1,34 @@ > +/** @file > + Base Reset System Library Shutdown API implementation for bhyve. > + > + Copyright (C) 2020, Rebecca Cran > + Copyright (C) 2020, Red Hat, Inc. > + Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#include // BIT13 > + > +#include // CpuDeadLoop() > +#include // IoOr16() > +#include // ResetShutdown() > +#include // BHYVE_PM_REG (2) Even though does include now, from commit 91dee771fc0d ("OvmfPkg: Add bhyve support into AcpiTimerLib", 2020-04-30), there's still no reason for this library instance to prefer the more general to . > + > +/** > + Calling this function causes the system to enter a power state equivalent > + to the ACPI G2/S5 or G3 states. > + > + System shutdown should not return, if it returns, it means the system does > + not support shut down reset. > +**/ > +VOID > +EFIAPI > +ResetShutdown ( > + VOID > + ) > +{ > + IoBitFieldWrite16 (BHYVE_PM_REG, 10, 13, 5); > + IoOr16 (BHYVE_PM_REG, BIT13); > + CpuDeadLoop (); > +} > diff --git a/OvmfPkg/Library/ResetSystemLib/BaseResetSystemLibBhyve.inf b/OvmfPkg/Library/ResetSystemLib/BaseResetSystemLibBhyve.inf > new file mode 100644 > index 000000000000..33e4e2689e57 > --- /dev/null > +++ b/OvmfPkg/Library/ResetSystemLib/BaseResetSystemLibBhyve.inf > @@ -0,0 +1,40 @@ > +## @file > +# Base library instance for ResetSystem library class for bhyve > +# > +# Copyright (C) 2020, Rebecca Cran > +# Copyright (C) 2020, Red Hat, Inc. > +# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION = 1.29 > + BASE_NAME = BaseResetSystemLibBhyve > + FILE_GUID = 5c71b08f-0ade-4607-8b9d-946c2757fee8 > + MODULE_TYPE = DXE_DRIVER (3) Should be BASE. I've fixed up the above three warts for you: [lersek@redhat.com: MODULE_TYPE: replace DXE_DRIVER with BASE] [lersek@redhat.com: replace with ] [lersek@redhat.com: strip ".inf" from subject line] With those: Reviewed-by: Laszlo Ersek (I also build-tested the library after my fixups.) github.com pull request: https://github.com/tianocore/edk2/pull/580 Commit: f159102a130fac9b416418eb9b6fa35b63426ca5 Thanks, Laszlo > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = ResetSystemLib > + > +# > +# The following information is for reference only and not required by the build > +# tools. > +# > +# VALID_ARCHITECTURES = IA32 X64 > +# > + > +[Sources] > + BaseResetShutdownBhyve.c > + ResetSystemLib.c > + > +[Packages] > + MdeModulePkg/MdeModulePkg.dec > + MdePkg/MdePkg.dec > + OvmfPkg/OvmfPkg.dec > + > +[LibraryClasses] > + BaseLib > + IoLib > + TimerLib > + >