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.web10.6215.1587113718896052944 for ; Fri, 17 Apr 2020 01:55:19 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YS1T6kbV; 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=1587113718; 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=ailUuUCvs4FxDmOjr67SSj9kTmK2ddoS1uAx4A6idCc=; b=YS1T6kbVEW9ZZCQxTw7p6QHWJ2y68OcvboRmmEaVOhlBBc4Li3i4u9sLqMvb02Fglg5jA0 aY2D3AzvDe5XxFwuUwkTGxa7sx7LLRQItsODWWVPtwTVu5HsdsIY9ZdJ/J5uOvHC7Dk3FH fcfTvJN/StIsQHyaAUpZAcdZmo2e9zs= 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-128-dkkH6CxGPcOhckT9hJQsaQ-1; Fri, 17 Apr 2020 04:55:14 -0400 X-MC-Unique: dkkH6CxGPcOhckT9hJQsaQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 545B3801E5D; Fri, 17 Apr 2020 08:55:13 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-253.ams2.redhat.com [10.36.113.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47F495C545; Fri, 17 Apr 2020 08:55:11 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 02/13] OvmfPkg: support powering off bhyve guests To: devel@edk2.groups.io, rebecca@bsdio.com Cc: Jordan Justen , Ard Biesheuvel References: From: "Laszlo Ersek" Message-ID: <11866fb0-09fb-b6a8-11e8-b3528eb433b9@redhat.com> Date: Fri, 17 Apr 2020 10:55:11 +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: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 04/16/20 01:09, Rebecca Cran wrote: > Update ResetSystemLib to support powering off bhyve guests instead of > having them enter the CpuDeadLoop. > > On bhyve, the Power Management 1 Control Register is located at 0x404; > a write with SLP_TYP set to 5 will power off the guest. > > Signed-off-by: Rebecca Cran > --- > OvmfPkg/Include/IndustryStandard/Bhyve.h | 4 ++++ > OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c | 6 ++++++ > 2 files changed, 10 insertions(+) > > diff --git a/OvmfPkg/Include/IndustryStandard/Bhyve.h b/OvmfPkg/Include/IndustryStandard/Bhyve.h > index 950f87048b..ceabc54d59 100644 > --- a/OvmfPkg/Include/IndustryStandard/Bhyve.h > +++ b/OvmfPkg/Include/IndustryStandard/Bhyve.h > @@ -18,4 +18,8 @@ > > #define BHYVE_ACPI_TIMER_IO_ADDR 0x408 > > +#define BHYVE_PMBASE_VALUE 0x400 > + > +#define BHYVE_PCI_DEVICE_ID 0x1275 // NetApp vendor ID > + > #endif // __BHYVE_H__ > diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c > index 2f2e1293a3..8d9b9dfcf5 100644 > --- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c > +++ b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c > @@ -28,6 +28,12 @@ AcpiPmControl ( > AcpiPmBaseAddress = 0; > HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID); > switch (HostBridgeDevId) { > + case BHYVE_PCI_DEVICE_ID: > + AcpiPmBaseAddress = BHYVE_PMBASE_VALUE; > + // Bhyve needs a value of 5 to enter S5 (power off) > + if (SuspendType == 0) > + SuspendType = 5; > + break; > case INTEL_82441_DEVICE_ID: > AcpiPmBaseAddress = PIIX4_PMBA_VALUE; > break; > In this patch, we should follow the pattern seen in patch#1 -- new, bhyve-specific library instance. However, this library has hugely bit-rotted, and it needs some serious scrubbing before we can do that. Let me look into a patch series for that. I'll continue to review of this series after that. I hope that works for you. Thanks Laszlo