From nobody Sat May 18 19:12:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563446462; cv=none; d=zoho.com; s=zohoarc; b=dmczk6yKm3L5eRAjbIdbG6wdinY7vHg4a6oysKYQc6mijdvWfBIjvcCmwYaVaUL4HQqkP+hQvrmCo/IjAPqJ6fzaS59LuAOrDz8figyboWUkw4azlJ2pIy+PX34v6ksoklWsHriNyxWL2yPrS0/oGWJFDKl/7wDGCeK5jrsf3EU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563446462; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=jAa9CTlGAyUwS8ryUtwx8J55K0uQzdwgZLDcXfJufxg=; b=MLPaR4wrKpelbedl8zUnDnQ2GQKAqKAVIb1Z3XkcjSt+q28h7Xg6WmvDNLUQDe8QELW18APo1dC8xwAUT7nVT4LaZ5HcoHOSrNKXoG6XZReuEMyke0fMbN5YwohI9qmxcePMMgT0UtcGewPlMpJnLS/2CGd/JkL9Ah9e5kh5xw0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563446462030246.15682772215018; Thu, 18 Jul 2019 03:41:02 -0700 (PDT) Received: from localhost ([::1]:36184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1ho3qO-0005YO-MV for importer@patchew.org; Thu, 18 Jul 2019 06:41:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34842) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1ho3pm-0003FB-9a for qemu-devel@nongnu.org; Thu, 18 Jul 2019 06:40:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ho3pk-0000aJ-5d for qemu-devel@nongnu.org; Thu, 18 Jul 2019 06:40:22 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:39766) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ho3pi-0000Wz-25; Thu, 18 Jul 2019 06:40:18 -0400 Received: by mail-pg1-x542.google.com with SMTP id u17so12708893pgi.6; Thu, 18 Jul 2019 03:40:17 -0700 (PDT) Received: from bobo.local0.net (61-68-63-89.tpgi.com.au. [61.68.63.89]) by smtp.gmail.com with ESMTPSA id y10sm28243415pfm.66.2019.07.18.03.40.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 18 Jul 2019 03:40:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jAa9CTlGAyUwS8ryUtwx8J55K0uQzdwgZLDcXfJufxg=; b=noL8vNZYn/ERx59hFdgCKcxPJc1qS0Pz6X/tZrXmrHPy/VUuvcyDJdmRRbH5GCy2Ca HiMlYelUU+nAORnUiL1DyTf0LJ9hNQidmfconZTUJHwBeneWGvrFmh2F65WT/tJAqlgz eReJgn3V1/qY4SomSKhDJlDF8BfL1t2NQ9i99UIYB9jcAub+J7Ts4v88a1Rhqb0CgKAW YU0oEF2LovJY82BtCMjirm15BMeHAll/EBqpOIsh0sDqxydvOF8Kx9JmUPdg3jhtJepv Rh0ZkOXm6st+h2Bb8aLHqCPfTKfA6g99oUlnSmlmtUo4DiNKxdVPvfMqiN4d0Yb7el0C tTjw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=jAa9CTlGAyUwS8ryUtwx8J55K0uQzdwgZLDcXfJufxg=; b=Ukj6TqD4xapwzo6pnsOhnK9ZQJNp6M7i/qF5u+5gYvaSSIolvSDW3ckbdYTIZxHvRY SedsiGDR2tyvQGgTzvghYDfa2O2Jn9yrJLEqNooNhRUoyRKV8m4OJVv1xmciSW2UeM/M Y8zI4lFIwxng6hSIXuiMC/SJsQSg0LGaUjylgVTjAX/roG9chBL1VV4ocYjaiN2UMDZZ wuqIvuxmEk8uXMsdQB9cqeg41psJdSo9JMPexW0tc9pW02jOrhahW5CJbH2Up/BrKtaB uDkBMAZllgOeXlYsSjzw2SfzEMKf4Gykv6WznTMJjhwYnBC0XDVYZqCw3qkfEsZPycdj R2Hw== X-Gm-Message-State: APjAAAWlprV+QMKmui1d/ug9R3yQvxS9k8fLE4vHwx8oQEzKtfAzyjQ1 IQnasBh3hyP4YIwSH3peBWSuzxPz X-Google-Smtp-Source: APXvYqzIR4+E8UWfUBP/biRfH1y72qHD91FvMnORSc1JAQxhS3lDmFKn5LB6e3ww+XvmX0SOQFLHnw== X-Received: by 2002:a17:90a:d3d4:: with SMTP id d20mr51365858pjw.28.1563446417042; Thu, 18 Jul 2019 03:40:17 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Date: Thu, 18 Jul 2019 20:39:49 +1000 Message-Id: <20190718103951.10027-2-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190718103951.10027-1-npiggin@gmail.com> References: <20190718103951.10027-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH 1/3] qmp: don't emit the RESET event on wakeup X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Nicholas Piggin , Luiz Capitulino , Christian Borntraeger , Gerd Hoffmann , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Commit 1405819637f53 ("qmp: don't emit the RESET event on wakeup from S3") changed system wakeup to avoid calling qapi_event_send_reset. Commit 76ed4b18debfe ("s390/ipl: fix ipl with -no-reboot") appears to have inadvertently broken that logic. Signed-off-by: Nicholas Piggin Acked-by: Christian Borntraeger Acked-by: Cornelia Huck --- I'm not quite sure if this patch is correct and haven't tested it, I found it by inspection. If this patch is incorrect, I will have to adjust patch 2. vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vl.c b/vl.c index 5089fce6c5..ef3c7ab8b8 100644 --- a/vl.c +++ b/vl.c @@ -1550,7 +1550,7 @@ void qemu_system_reset(ShutdownCause reason) } else { qemu_devices_reset(); } - if (reason !=3D SHUTDOWN_CAUSE_SUBSYSTEM_RESET) { + if (reason && reason !=3D SHUTDOWN_CAUSE_SUBSYSTEM_RESET) { qapi_event_send_reset(shutdown_caused_by_guest(reason), reason); } cpu_synchronize_all_post_reset(); --=20 2.20.1 From nobody Sat May 18 19:12:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563446450; cv=none; d=zoho.com; s=zohoarc; b=YkncWAHn4mwS2h60LsjoarWi/noXFvVSk16xw1nkMD7boHOzy5xJHj9t7mjPrXTfBIvdosgxohdFW0NP+CZumSJRBh8OalkkyBVtENHRTqtblqie0kyWartPEk5Bc0elvTeVYcN4BbTbS5UJgN4ppfYvokRLga3xhH9D8wkL/iA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563446450; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=jeDfu5EycFvl9XFUWjClydY4i9PbIdp0Dl2n2igY378=; b=XvItAmbXsheSeivhXclTAvpE/h2lkwtkUHLXYyHk65gw+k1pjlX+x4qgfQI+OG+d2q9dEBkV+jAUc4k7aUNTrD7EpO4s1VVeFMxg9jVHgUT9DPwDy+tY7xXzudQqEBrZIzkjL4n7phno56wK0gLQxt5B7jmqAExmm9jQiXCv3gw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563446450419987.7975290122413; Thu, 18 Jul 2019 03:40:50 -0700 (PDT) Received: from localhost ([::1]:36182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1ho3qD-0004kE-36 for importer@patchew.org; Thu, 18 Jul 2019 06:40:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34875) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1ho3pr-0003eq-Uj for qemu-devel@nongnu.org; Thu, 18 Jul 2019 06:40:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ho3pq-0000gf-Ro for qemu-devel@nongnu.org; Thu, 18 Jul 2019 06:40:27 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:33753) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ho3po-0000dO-A1; Thu, 18 Jul 2019 06:40:24 -0400 Received: by mail-pf1-x42d.google.com with SMTP id g2so12443849pfq.0; Thu, 18 Jul 2019 03:40:24 -0700 (PDT) Received: from bobo.local0.net (61-68-63-89.tpgi.com.au. [61.68.63.89]) by smtp.gmail.com with ESMTPSA id y10sm28243415pfm.66.2019.07.18.03.40.17 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 18 Jul 2019 03:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jeDfu5EycFvl9XFUWjClydY4i9PbIdp0Dl2n2igY378=; b=du2EdGeBkny+IfgWNzwqYqHutMf9z9h/WVcIjUyH/Mp5Jfz0L68EkTg86Us7OcSlRY +VpfdyTK7tagjno46JRE7+xxNQ6O8NcQeJDs1mDiDFGuixAzqlNq+ttlDaQkmg/uJOfD 1tbTSsXPowJkoexkZCpnGOEvTPf9GOe6uOVxZUVU2wMUBS17SDocB7vbqtQioWAUhK4Z QXCZ7wzMnHZg3mHnRFQkLONMOoO/VSFPKsXW2vwUooAk/R48LJY+8zK8KXc+FYjhmKeV HjU7jE97aB8vYbMFfflPLL7kcarvrE63jH0n0Y37PUEIo1Z0UZ/C4YE4sDR+P9RMOO70 yFNg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=jeDfu5EycFvl9XFUWjClydY4i9PbIdp0Dl2n2igY378=; b=sv+gmoA98uDcdK5kopPddBFn7M4JFQe85gx5GtrGXvrWxOnZVg7BCPA2g4L+vPVJLe p/0GDumgfPhhjG5doY8b3XVc4MeRBhJzDOzL1eDCQEtHq21KOz2nBfiZhQiGBRwcRewr Z6HFbAWR2n4miE39bIOWCwWcVubGnZ9I+rV2zW/oHIfBi7XbKkaXPBptP9keQw6lpWQV H9tWk2uqiitrJQGMfapQBINatzKzZvGk5A2FPuxXuEwrp57qN6eXPT4615TsPz3SpQA9 6012Yk+otOq3K1r41jbIcdt7lxPoXcSaJjQe4hISLhLiN1a+AmCAc/iQVd4rGr10Tfzr ky8g== X-Gm-Message-State: APjAAAUEkujgPSCzb+P6dRPlqrcZxnAbYqbgWocR+carVAsBUkkJByC1 KPjdDu81U7RVhj95jFTEqFimighY X-Google-Smtp-Source: APXvYqwUtt17A6CS7/mLYliXRZawQAJ8FObcwBEz14TJr7/wbkmsQhHg1IETvyNszfUtMR6I/spdYw== X-Received: by 2002:a63:9e43:: with SMTP id r3mr21865071pgo.148.1563446423094; Thu, 18 Jul 2019 03:40:23 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Date: Thu, 18 Jul 2019 20:39:50 +1000 Message-Id: <20190718103951.10027-3-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190718103951.10027-1-npiggin@gmail.com> References: <20190718103951.10027-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::42d Subject: [Qemu-devel] [PATCH 2/3] machine: Add wakeup method to MachineClass X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Nicholas Piggin , Luiz Capitulino , Christian Borntraeger , Gerd Hoffmann , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Waking from suspend is not logically a machine reset on all machines, particularly in the paravirtualized case rather than hardware emulated. The ppc spapr machine for example just invokes hypervisor to suspend, and expects that call to return with the machine in the same state (modulo some possible migration and reconfiguration details). Implement a machine ->wakeup method and use that if it exists. Signed-off-by: Nicholas Piggin --- include/hw/boards.h | 1 + vl.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index a71d1a53a5..915ac3352b 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -180,6 +180,7 @@ struct MachineClass { =20 void (*init)(MachineState *state); void (*reset)(MachineState *state); + void (*wakeup)(MachineState *state); void (*hot_add_cpu)(MachineState *state, const int64_t id, Error **err= p); int (*kvm_type)(MachineState *machine, const char *arg); void (*smp_parse)(MachineState *ms, QemuOpts *opts); diff --git a/vl.c b/vl.c index ef3c7ab8b8..b9e9943458 100644 --- a/vl.c +++ b/vl.c @@ -1556,6 +1556,33 @@ void qemu_system_reset(ShutdownCause reason) cpu_synchronize_all_post_reset(); } =20 +/* + * Wake the VM after suspend. + */ +static void qemu_system_wakeup(void) +{ + MachineClass *mc; + + mc =3D current_machine ? MACHINE_GET_CLASS(current_machine) : NULL; + + if (mc && mc->wakeup) { + mc->wakeup(current_machine); + } else { + /* + * Fall back to old reset wakeup method. Platforms supporting + * wakeup should be converted over to use ->wakeup and this + * fallback code removed. + */ + cpu_synchronize_all_states(); + if (mc && mc->reset) { + mc->reset(current_machine); + } else { + qemu_devices_reset(); + } + cpu_synchronize_all_post_reset(); + } +} + void qemu_system_guest_panicked(GuestPanicInformation *info) { qemu_log_mask(LOG_GUEST_ERROR, "Guest crashed"); @@ -1764,7 +1791,7 @@ static bool main_loop_should_exit(void) } if (qemu_wakeup_requested()) { pause_all_vcpus(); - qemu_system_reset(SHUTDOWN_CAUSE_NONE); + qemu_system_wakeup(); notifier_list_notify(&wakeup_notifiers, &wakeup_reason); wakeup_reason =3D QEMU_WAKEUP_REASON_NONE; resume_all_vcpus(); --=20 2.20.1 From nobody Sat May 18 19:12:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563446495; cv=none; d=zoho.com; s=zohoarc; b=ZirpOD3BNK1Sla34r87q+Q4bqdqiDL6+EhmV0HfRCHDw6gicYmFC8AzMF7UbVkjy96UvoOGAkBKEi4XfVYvzHZ9N4O8qNKEzLjIq3h61kUOcIigvszJ8hne8lCZdrsl+K4l0JuIn2SS8bFjJdY6FY4JU8ZblPy1vPN24y3uApyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563446495; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=lteyBjEv79ancuyu48+6RkOCiXixXc/t0skBD9V32vQ=; b=Z0409sowZFBj21+3mWJN+iEDFfpIroyehNGtiU0zlXukbDX1r6tZvQNUtXrxtaz+W1Qxfkc2RXUQfw5booZpbNa0KsoeLTv6Vs3e5Lg1x9rMP6adltnC/d2gUsuQD5IEkGOfFfo1MlPnYz7LpfH2C5jHHIIhKFhUgBzIqYb2cgM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156344649597376.33974013531395; Thu, 18 Jul 2019 03:41:35 -0700 (PDT) Received: from localhost ([::1]:36206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1ho3qw-0007ia-Qz for importer@patchew.org; Thu, 18 Jul 2019 06:41:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34910) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1ho3py-00043z-7V for qemu-devel@nongnu.org; Thu, 18 Jul 2019 06:40:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ho3pw-0000sh-Qt for qemu-devel@nongnu.org; Thu, 18 Jul 2019 06:40:34 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:34865) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ho3pu-0000mU-41; Thu, 18 Jul 2019 06:40:30 -0400 Received: by mail-pf1-x443.google.com with SMTP id u14so12448020pfn.2; Thu, 18 Jul 2019 03:40:30 -0700 (PDT) Received: from bobo.local0.net (61-68-63-89.tpgi.com.au. [61.68.63.89]) by smtp.gmail.com with ESMTPSA id y10sm28243415pfm.66.2019.07.18.03.40.23 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 18 Jul 2019 03:40:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lteyBjEv79ancuyu48+6RkOCiXixXc/t0skBD9V32vQ=; b=nnSMfJtfbz3GZR6j8f14cbn6GCnbfFXOalYlIrtLUOooKg4J9NRyQ4RkUexObVi3Om u13CAM8Y5tHXEVVthXSk38zcgCVW43+AeREk2Z55AYZlIDLaQM35LElOAQSjMo1qvjJp SDsrPAUvjZPb1XCgYdYtzq8OyeOmnb84KH61zuBfit6FVwKBJ1rTUlK7pTxGb6pObLmQ NlLbq4KONCQ0sqa5hwmx4nobJsrOqwCWvUZ5FCgH1Hj++4cdVphAAfhvjosy09oipk4h bBGwlo6+8TsttppnRU0hYI8lvC+V2RZTknFQxmokPSL5xirMJ9us3W5zJm3/KMskSFPb AOiQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=lteyBjEv79ancuyu48+6RkOCiXixXc/t0skBD9V32vQ=; b=D4c03Xb0jJze3oPqNsknH/RevB8nHQQL2t6nzVRevAJe1+qWEVRA1t70eNj7DKS45m tm7x5ZXQl+WpzdPwx40/XHCAdahR4c7Eee5laywY9hvjeVgyyvrH3TNY3Iwvwdb/tiKg aXae9oj8nY/XWom3dfQ4rrQIOLSvFUKRjHU3160HdBcrKmun05xwiGIJ6RPBSjz7FpqW yU7NnaFt3hliq9zMKhTr+vn22tkKunp4MX02AbfR6rWlsL623Xlx/yWz1JrCiJPZWJBH ppG323GCvuEUcG/QeRkUgDIzqCemb/3sYmtL2o3ZSc0Ll6zRQ6yO4oB9Lxbd59oiAf9L euPA== X-Gm-Message-State: APjAAAXWI2EHgolpHCBdFdUJD2e28i/JacGbhkrXVz/fEkYy7i9KoETB YG+4CJxmrctlAFr4NNWxrc1bdRuq X-Google-Smtp-Source: APXvYqwsvM882HpPaC8IJLzlJuWwOuOQI3DlFNuwZW+dJykqstq1ueq/aLUA/i5Xr58MQwG37Me+EA== X-Received: by 2002:a63:c106:: with SMTP id w6mr47324592pgf.422.1563446428755; Thu, 18 Jul 2019 03:40:28 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Date: Thu, 18 Jul 2019 20:39:51 +1000 Message-Id: <20190718103951.10027-4-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190718103951.10027-1-npiggin@gmail.com> References: <20190718103951.10027-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH 3/3] spapr: Implement ibm,suspend-me X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Nicholas Piggin , Luiz Capitulino , Christian Borntraeger , Gerd Hoffmann , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This has been useful to modify and test the Linux pseries suspend code but it requires modification to the guest to call it (due to being gated by other unimplemented features). It is not otherwise used by Linux yet, but work is slowly progressing there. This allows a (lightly modified) guest kernel to suspend with `echo mem > /sys/power/state` and be resumed with system_wakeup monitor command. Signed-off-by: Nicholas Piggin --- hw/ppc/spapr.c | 11 +++++++++++ hw/ppc/spapr_rtas.c | 32 ++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 3 ++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 00f7735a31..c7725d3586 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1701,6 +1701,14 @@ static int spapr_reset_drcs(Object *child, void *opa= que) return 0; } =20 +static void spapr_machine_wakeup(MachineState *machine) +{ + /* + * Nothing needs to be done to resume a suspended guest because + * suspending does not change the machine state. + */ +} + static void spapr_machine_reset(MachineState *machine) { SpaprMachineState *spapr =3D SPAPR_MACHINE(machine); @@ -3078,6 +3086,8 @@ static void spapr_machine_init(MachineState *machine) =20 qemu_register_boot_set(spapr_boot_set, spapr); =20 + qemu_register_wakeup_support(); + if (kvm_enabled()) { /* to stop and start vmclock */ qemu_add_vm_change_state_handler(cpu_ppc_clock_vm_state_change, @@ -4373,6 +4383,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) */ mc->init =3D spapr_machine_init; mc->reset =3D spapr_machine_reset; + mc->wakeup =3D spapr_machine_wakeup; mc->block_default_type =3D IF_SCSI; mc->max_cpus =3D 1024; mc->no_parallel =3D 1; diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index a618a2ac0f..87175c1e0a 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -216,6 +216,36 @@ static void rtas_stop_self(PowerPCCPU *cpu, SpaprMachi= neState *spapr, qemu_cpu_kick(cs); } =20 +static void rtas_ibm_suspend_me(PowerPCCPU *cpu, SpaprMachineState *spapr, + uint32_t token, uint32_t nargs, + target_ulong args, + uint32_t nret, target_ulong rets) +{ + CPUState *cs; + + if (nargs !=3D 0 || nret !=3D 1) { + rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); + return; + } + + CPU_FOREACH(cs) { + PowerPCCPU *c =3D POWERPC_CPU(cs); + CPUPPCState *e =3D &c->env; + if (c =3D=3D cpu) { + continue; + } + + /* See h_join */ + if (!cs->halted || (e->msr & (1ULL << MSR_EE))) { + rtas_st(rets, 0, H_MULTI_THREADS_ACTIVE); + return; + } + } + + qemu_system_suspend_request(); + rtas_st(rets, 0, RTAS_OUT_SUCCESS); +} + static inline int sysparm_st(target_ulong addr, target_ulong len, const void *val, uint16_t vallen) { @@ -483,6 +513,8 @@ static void core_rtas_register_types(void) rtas_query_cpu_stopped_state); spapr_rtas_register(RTAS_START_CPU, "start-cpu", rtas_start_cpu); spapr_rtas_register(RTAS_STOP_SELF, "stop-self", rtas_stop_self); + spapr_rtas_register(RTAS_IBM_SUSPEND_ME, "ibm,suspend-me", + rtas_ibm_suspend_me); spapr_rtas_register(RTAS_IBM_GET_SYSTEM_PARAMETER, "ibm,get-system-parameter", rtas_ibm_get_system_parameter); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 5d36eec9d0..6e8e18b077 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -631,8 +631,9 @@ target_ulong spapr_hypercall(PowerPCCPU *cpu, target_ul= ong opcode, #define RTAS_IBM_CREATE_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x27) #define RTAS_IBM_REMOVE_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x28) #define RTAS_IBM_RESET_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x29) +#define RTAS_IBM_SUSPEND_ME (RTAS_TOKEN_BASE + 0x2A) =20 -#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2A) +#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2B) =20 /* RTAS ibm,get-system-parameter token values */ #define RTAS_SYSPARM_SPLPAR_CHARACTERISTICS 20 --=20 2.20.1