From nobody Thu Jan 13 15:54:56 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0B062195B7AA; Thu, 13 Jan 2022 15:54:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JZTXJ6sCgz3m3Q; Thu, 13 Jan 2022 15:54:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642089297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=j5FLlkOgFIUxlePJ4GgWfeuThYMl9fJKPYmEcslXUoo=; b=orYVx9LJJ7QwW7FZnzfgFFzGQjHfVjPUgu434oR97pwncCT1nDNU80HQzs7f25uruJ7nEY 06zES0dm7qzaMR5Ymu+LAn0vPug7C138XJzRASCK+W4QTRKR3P8Iy19CZv8DtxQmV6JKSN bKjZEwBAn4X+MjXGuJPEuhMnzvDUbka8RlnKTOYX+MqGdgKDM2f1eUHp3u57FLkzoxU/mS IJTGCShuWrtSEvs0D60CgeIhvCOFdd+P5sNhyJ8yFitzKR9N5md562+mx7XsMzO57KSCTw +Sqz2p5TcETN+Tq8SpmEtk9adSzaJcjV0rAcXoKayqEzyK0v2L/+hA8Iljhgkg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CB1DC231E5; Thu, 13 Jan 2022 15:54:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20DFsuxa088615; Thu, 13 Jan 2022 15:54:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20DFsuF0088614; Thu, 13 Jan 2022 15:54:56 GMT (envelope-from git) Date: Thu, 13 Jan 2022 15:54:56 GMT Message-Id: <202201131554.20DFsuF0088614@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Roger Pau Monn=C3=A9?= Subject: git: ca46f3289d96 - main - xen: use an hypercall for shutdown and reboot List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ca46f3289d9630a9b203379333b46f3f11363146 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642089297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=j5FLlkOgFIUxlePJ4GgWfeuThYMl9fJKPYmEcslXUoo=; b=uE/w6WsUAinmv7o2wbdGZTL9ESAs7cxKN66T4+wDc4jeG/VC0gd08XYlXudmwewS/sdv1x W5K2DOx+dM8in0WSlhblVUUXQm3B+nPHlKgfnOKiTPKA32JYOZa3zsUgN7eFYZYI2woY53 Jn37HMFUWkLnyrOas+nhfD7djAIGfYtmwc7C2IEo1lt3PPWugMAAM9wrjcyJLXYFRoPYAq 0ygQt/eUxGLmaiM9WNQLtWPcGjgo4DfS4OfPJFskKWTLnbZI5KhgTtSVKrsE//1Kvke3uq NYmTn0ziJ8Cd2qTseZy/JhOvAi2CBoP6DT7tqB7s/6gzn8X60f6vzcge8uKP/g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642089297; a=rsa-sha256; cv=none; b=xpGTrqLzZ0/HTKc/umOE3GIPJoeJoOhP0/H/D4tde7EV+kljF8RoPpnVcO1d6p3m1/5/zm uMKf9FDSxUIfmFKQ9LQtHvtfzcUPDX5SDCt6JgoyF6i8IQJ7uK5jJMIvUtB3z7xHhmxaST Zn84075jCAIvyeCa5ai/mZYksYlsgkt7FjsiOpypRhfznWEO5I0mH+vvqjHELhdBIqBzmb TQ7+HMbz0tslD2zypei19lwbuRlRx8ufCF3kqPA/PR1W1TNH/eJtWRicrsInag2WoOxJTm XceERQgNd67v1SiqqrssYgSV0Dr31aocNuMy1+n2mxC0eI6y9LSjYOrouEYAZA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=ca46f3289d9630a9b203379333b46f3f11363146 commit ca46f3289d9630a9b203379333b46f3f11363146 Author: Roger Pau Monné AuthorDate: 2022-01-13 13:47:18 +0000 Commit: Roger Pau Monné CommitDate: 2022-01-13 15:54:30 +0000 xen: use an hypercall for shutdown and reboot When running as a Xen guest it's easier to use an hypercall in order to do power management operations (power off, power cycle). Do this for all supported guest types (HVM and PVH). Note that for HVM the power operation could also be done using ACPI, but there's no reason to differentiate between PVH and HVM. While there fix the shutdown handler to properly differentiate between power cycle and power off requests. Reported by: Freddy DISSAUX MFC: 1 week Sponsored by: Citrix Systems R&D --- sys/dev/xen/control/control.c | 18 ++++++------------ sys/x86/include/xen/xen-os.h | 7 ------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/sys/dev/xen/control/control.c b/sys/dev/xen/control/control.c index 426682a8f2d9..b42b52a62411 100644 --- a/sys/dev/xen/control/control.c +++ b/sys/dev/xen/control/control.c @@ -347,17 +347,12 @@ xctrl_crash() } static void -xen_pv_shutdown_final(void *arg, int howto) +shutdown_final(void *arg, int howto) { - /* - * Inform the hypervisor that shutdown is complete. - * This is not necessary in HVM domains since Xen - * emulates ACPI in that mode and FreeBSD's ACPI - * support will request this transition. - */ - if (howto & (RB_HALT | RB_POWEROFF)) + /* Inform the hypervisor that shutdown is complete. */ + if (howto & RB_POWEROFF) HYPERVISOR_shutdown(SHUTDOWN_poweroff); - else + else if (howto & RB_POWERCYCLE) HYPERVISOR_shutdown(SHUTDOWN_reboot); } @@ -453,9 +448,8 @@ xctrl_attach(device_t dev) xctrl->xctrl_watch.max_pending = 1; xs_register_watch(&xctrl->xctrl_watch); - if (xen_pv_shutdown_handler()) - EVENTHANDLER_REGISTER(shutdown_final, xen_pv_shutdown_final, NULL, - SHUTDOWN_PRI_LAST); + EVENTHANDLER_REGISTER(shutdown_final, shutdown_final, NULL, + SHUTDOWN_PRI_LAST); return (0); } diff --git a/sys/x86/include/xen/xen-os.h b/sys/x86/include/xen/xen-os.h index 9d0964c6631d..655961da22fd 100644 --- a/sys/x86/include/xen/xen-os.h +++ b/sys/x86/include/xen/xen-os.h @@ -56,13 +56,6 @@ xen_has_percpu_evtchn(void) return (!xen_hvm_domain() || xen_vector_callback_enabled); } -static inline bool -xen_pv_shutdown_handler(void) -{ - - return (xen_pv_domain()); -} - static inline bool xen_pv_disks_disabled(void) {