lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230103164359.24347-20-ysionneau@kalray.eu>
Date:   Tue,  3 Jan 2023 17:43:53 +0100
From:   Yann Sionneau <ysionneau@...ray.eu>
To:     unlisted-recipients:; (no To-header on input)
Cc:     Yann Sionneau <ysionneau@...ray.eu>,
        Sebastian Reichel <sre@...nel.org>,
        linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
        Clement Leger <clement.leger@...tlin.com>,
        Julian Vetter <jvetter@...ray.eu>
Subject: [RFC PATCH 19/25] kvx: power: scall poweroff driver

Add a driver to poweroff the Coolidge SoC
when running under Qemu, ISS or when
the debugger (jtag-runner) runs on PL0
to catch the scall.

CC: Sebastian Reichel <sre@...nel.org>
CC: linux-kernel@...r.kernel.org
CC: linux-pm@...r.kernel.org
Co-developed-by: Clement Leger <clement.leger@...tlin.com>
Signed-off-by: Clement Leger <clement.leger@...tlin.com>
Co-developed-by: Julian Vetter <jvetter@...ray.eu>
Signed-off-by: Julian Vetter <jvetter@...ray.eu>
Signed-off-by: Yann Sionneau <ysionneau@...ray.eu>
---
 drivers/power/reset/kvx-scall-poweroff.c | 53 ++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 drivers/power/reset/kvx-scall-poweroff.c

diff --git a/drivers/power/reset/kvx-scall-poweroff.c b/drivers/power/reset/kvx-scall-poweroff.c
new file mode 100644
index 000000000000..586d93fbcaed
--- /dev/null
+++ b/drivers/power/reset/kvx-scall-poweroff.c
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2017 - 2022 Kalray Inc.
+ * Author(s): Clement Leger
+ */
+
+#include <linux/pm.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+
+#define SCALL_NUM_EXIT	"0xfff"
+
+static void kvx_scall_poweroff(void)
+{
+	register int status asm("r0") = 0;
+
+	asm volatile ("scall " SCALL_NUM_EXIT "\n\t;;"
+		      : /* out */
+		      : "r"(status));
+
+	unreachable();
+}
+
+static int kvx_scall_poweroff_probe(struct platform_device *pdev)
+{
+	pm_power_off = kvx_scall_poweroff;
+
+	return 0;
+}
+
+static int kvx_scall_poweroff_remove(struct platform_device *pdev)
+{
+	if (pm_power_off == kvx_scall_poweroff)
+		pm_power_off = NULL;
+
+	return 0;
+}
+
+static const struct of_device_id kvx_scall_poweroff_of_match[] = {
+	{ .compatible = "kalray,kvx-scall-poweroff" },
+	{}
+};
+
+static struct platform_driver kvx_scall_poweroff_driver = {
+	.probe = kvx_scall_poweroff_probe,
+	.remove = kvx_scall_poweroff_remove,
+	.driver = {
+		.name = "kvx-scall-poweroff",
+		.of_match_table = kvx_scall_poweroff_of_match,
+	},
+};
+module_platform_driver(kvx_scall_poweroff_driver);
-- 
2.37.2





Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ