Linux Audio

Check our new training course

Loading...
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * Copyright (C) 2019 IBM Corporation
 4 * Author: Nayna Jain
 5 */
 6#include <linux/types.h>
 7#include <linux/of.h>
 8#include <linux/string_choices.h>
 9#include <asm/secure_boot.h>
10
11static struct device_node *get_ppc_fw_sb_node(void)
12{
13	static const struct of_device_id ids[] = {
14		{ .compatible = "ibm,secureboot", },
15		{ .compatible = "ibm,secureboot-v1", },
16		{ .compatible = "ibm,secureboot-v2", },
17		{},
18	};
19
20	return of_find_matching_node(NULL, ids);
21}
22
23bool is_ppc_secureboot_enabled(void)
24{
25	struct device_node *node;
26	bool enabled = false;
27	u32 secureboot;
28
29	node = get_ppc_fw_sb_node();
30	enabled = of_property_read_bool(node, "os-secureboot-enforcing");
31	of_node_put(node);
32
33	if (enabled)
34		goto out;
35
36	node = of_find_node_by_path("/");
37	if (!of_property_read_u32(node, "ibm,secure-boot", &secureboot))
38		enabled = (secureboot > 1);
39	of_node_put(node);
40
41out:
42	pr_info("Secure boot mode %s\n", str_enabled_disabled(enabled));
43
44	return enabled;
45}
46
47bool is_ppc_trustedboot_enabled(void)
48{
49	struct device_node *node;
50	bool enabled = false;
51	u32 trustedboot;
52
53	node = get_ppc_fw_sb_node();
54	enabled = of_property_read_bool(node, "trusted-enabled");
55	of_node_put(node);
56
57	if (enabled)
58		goto out;
59
60	node = of_find_node_by_path("/");
61	if (!of_property_read_u32(node, "ibm,trusted-boot", &trustedboot))
62		enabled = (trustedboot > 0);
63	of_node_put(node);
64
65out:
66	pr_info("Trusted boot mode %s\n", str_enabled_disabled(enabled));
67
68	return enabled;
69}
v5.9
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * Copyright (C) 2019 IBM Corporation
 4 * Author: Nayna Jain
 5 */
 6#include <linux/types.h>
 7#include <linux/of.h>
 
 8#include <asm/secure_boot.h>
 9
10static struct device_node *get_ppc_fw_sb_node(void)
11{
12	static const struct of_device_id ids[] = {
13		{ .compatible = "ibm,secureboot", },
14		{ .compatible = "ibm,secureboot-v1", },
15		{ .compatible = "ibm,secureboot-v2", },
16		{},
17	};
18
19	return of_find_matching_node(NULL, ids);
20}
21
22bool is_ppc_secureboot_enabled(void)
23{
24	struct device_node *node;
25	bool enabled = false;
26	u32 secureboot;
27
28	node = get_ppc_fw_sb_node();
29	enabled = of_property_read_bool(node, "os-secureboot-enforcing");
30	of_node_put(node);
31
32	if (enabled)
33		goto out;
34
35	if (!of_property_read_u32(of_root, "ibm,secure-boot", &secureboot))
 
36		enabled = (secureboot > 1);
 
37
38out:
39	pr_info("Secure boot mode %s\n", enabled ? "enabled" : "disabled");
40
41	return enabled;
42}
43
44bool is_ppc_trustedboot_enabled(void)
45{
46	struct device_node *node;
47	bool enabled = false;
48	u32 trustedboot;
49
50	node = get_ppc_fw_sb_node();
51	enabled = of_property_read_bool(node, "trusted-enabled");
52	of_node_put(node);
53
54	if (enabled)
55		goto out;
56
57	if (!of_property_read_u32(of_root, "ibm,trusted-boot", &trustedboot))
 
58		enabled = (trustedboot > 0);
 
59
60out:
61	pr_info("Trusted boot mode %s\n", enabled ? "enabled" : "disabled");
62
63	return enabled;
64}