From patchwork Wed Jan 18 11:45:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Dennis-Jordan X-Patchwork-Id: 716638 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v3S0w1Fx8z9t0C for ; Thu, 19 Jan 2017 00:06:55 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=philjordan-eu.20150623.gappssmtp.com header.i=@philjordan-eu.20150623.gappssmtp.com header.b="OEem5Nif"; dkim-atps=neutral Received: from localhost ([::1]:41282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cTpww-0002t0-Ge for incoming@patchwork.ozlabs.org; Wed, 18 Jan 2017 08:06:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cToiP-0005Ja-Id for qemu-devel@nongnu.org; Wed, 18 Jan 2017 06:47:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cToiM-000542-FE for qemu-devel@nongnu.org; Wed, 18 Jan 2017 06:47:45 -0500 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:37607) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cToiM-00053M-7h for qemu-devel@nongnu.org; Wed, 18 Jan 2017 06:47:42 -0500 Received: by mail-wm0-x22d.google.com with SMTP id c206so21044646wme.0 for ; Wed, 18 Jan 2017 03:47:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philjordan-eu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=uTcghGe4U6dYPQ2IICzNlObMSk3XPxQjen93zAQAmW0=; b=OEem5NifO44cONDWEKXyQUJ5JNI+beteNkZRuL/Rj0j19AZHzKgGFIKeuzrUITRtA5 t/AuvI8TIaO+7dbUjZtyUhiXBKHYLnVC6bFLF3BLWsooLno/z25p7V7z8OccwKbzwrhP a/k3+H3SXYnvak0i9JvCphkEj76p6b3TIqb36Uc39iWITVvKtdvqMaY11qdRXrA/WCZ2 07JIl5tIkykeCs2XfnZIOlIaO+yI7uyf2rnjyWVzolKGEd4ac52zCL6d87qZN8Dm58v/ vBBUAuahRMjCV/B+q2Yf1D6vMCoPDwxBKbAoIsV7fj52omCeZBPHhvW+hxQXJibfGf7Z tAfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uTcghGe4U6dYPQ2IICzNlObMSk3XPxQjen93zAQAmW0=; b=FReUaRoCUci/eWfcCGk9lOf478o+6NJ2LYLaGzviXRHic6xGgQtuXy25d4LpJWaS15 LUTNKtk6Q7q6jxi+PNSwUtcybXLBBVVxK2doZhU8DTsbfPPjPy1PqPVtkCWygPE2HtVx qrbV9SWdV7rr8G+qy3d/gG7FZddxo8fee3BmS8rU3mMIt2HoyfXLUwNiM6o8UJY56FR5 OV7hg8Mr6TkVDVQwZiP/lyoQUHUyVD5ii2I4d1TkrNbt39XcsOQdDPNf+ip3VSzb/+2v N669NRORo+Shn8+1Vg67u/492o1W2GYYjOAz7XCBES3EewTyS3pZQK7+LBHFRgVsEoO4 JCzg== X-Gm-Message-State: AIkVDXI2+l68oznwDxiff75GcBpe+xhyDPW82zIqIVenyR3nd0cFL2Hpa4NUITLefEkHcA== X-Received: by 10.28.222.11 with SMTP id v11mr19460858wmg.1.1484740059269; Wed, 18 Jan 2017 03:47:39 -0800 (PST) Received: from Phils-MacBook-Pro-57025.local.eu (37-186-10-86.ip.as39912.net. [37.186.10.86]) by smtp.gmail.com with ESMTPSA id y145sm44713437wmc.17.2017.01.18.03.47.36 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 18 Jan 2017 03:47:37 -0800 (PST) From: Phil Dennis-Jordan To: qemu-devel@nongnu.org Date: Wed, 18 Jan 2017 12:45:54 +0100 Message-Id: <1484739954-86833-1-git-send-email-phil@philjordan.eu> X-Mailer: git-send-email 2.3.2 (Apple Git-55) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22d X-Mailman-Approved-At: Wed, 18 Jan 2017 08:05:14 -0500 Subject: [Qemu-devel] [PATCH RFC] acpi: add reset register to fadt X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Phil Dennis-Jordan , Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" About 2 years ago, Reza Jelveh submitted essentially this same patch: https://lists.gnu.org/archive/html/qemu-devel/2015-03/msg05832.html It adds the reset register defined in ACPI 2.0 to the x86 FADT, which fixes rebooting for Darwin/OS X/macOS guests. I'm trying to revive this as part of an effort to get recent versions of OS X/macOS working in Qemu/KVM with OVMF and without the need for out-of-tree patches. I've adapted the original patch so it cleanly applies on current master. The unaddressed issues last time around were: 1. Does this work with a range of Windows versions? I've tested this new version of the patch with KVM from Ubuntu's 4.4.0-51-generic kernel, using the following guests: * Windows XP SP2 and SP3, x86. "pc" (FX440) machine, IDE disk, SeaBIOS. * Windows 7 SP 1, x86. "pc" (FX440) machine, AHCI disk, SeaBIOS. * Windows 10 1607, x86-64, q35 machine, AHCI disk, OVMF from 2017-01-17 EDK2 master. * OS X 10.9 to 10.11, macOS 10.12; patched OVMF [1] In all cases I went through a fresh install, checked basic functionality, and rebooting. I noticed nothing different in any of the Windows VMs, and of course the Darwin-based ones no longer hang when attempting to reboot. 2. The reset register is defined in ACPI 2.0, this still advertises 1.0. I have to admit, I know very little about how ACPI works, so I'm not sure I got this right, but: I subsequently added a line rsdp->revision = 0x02; to build_rsdp() in acpi-build.c, then booted the aforementioned Windows VMs, and the macOS 10.12 one with this change. I noticed no change or ill effect whatsoever. I suspect more might be involved in enabling ACPI 2.0, and it should probably be an option so as to avoid regressions. I don't know what the best approach would be for this, so comments welcome. Should adding the reset register to the FADT also be configurable? Additionally, please suggest any further guest OSes and configurations I should test which seem likely to exhibit regressions with this change. (First post to this list - apologies if I messed up any of the conventions! Thanks, phil) [1] EDK2 fork with OS X/macOS compatibility patches: https://github.com/pmj/edk2/tree/mac-patches --- hw/i386/acpi-build.c | 5 +++++ include/hw/acpi/acpi-defs.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 0c8912f..93781a0 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -296,6 +296,11 @@ static void fadt_setup(AcpiFadtDescriptorRev1 *fadt, AcpiPmInfo *pm) (1 << ACPI_FADT_F_SLP_BUTTON) | (1 << ACPI_FADT_F_RTC_S4)); fadt->flags |= cpu_to_le32(1 << ACPI_FADT_F_USE_PLATFORM_CLOCK); + fadt->flags |= cpu_to_le32(1 << ACPI_FADT_F_RESET_REG_SUP); + fadt->reset_val = 0xf; + fadt->reset_reg.address_space_id = 1; + fadt->reset_reg.register_bit_width = 8; + fadt->reset_reg.address = ICH9_RST_CNT_IOPORT; /* APIC destination mode ("Flat Logical") has an upper limit of 8 CPUs * For more than 8 CPUs, "Clustered Logical" mode has to be used */ diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 4cc3630..5755570 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -140,6 +140,8 @@ struct AcpiFadtDescriptorRev1 uint8_t reserved4a; /* Reserved */ uint8_t reserved4b; /* Reserved */ uint32_t flags; + Acpi20GenericAddress reset_reg; + uint8_t reset_val; } QEMU_PACKED; typedef struct AcpiFadtDescriptorRev1 AcpiFadtDescriptorRev1;