Skip to content

Commit 56e0d88

Browse files
superm1herbertx
authored andcommitted
crypto: ccp - Move security attributes to their own file
To prepare for other code that will manipulate security attributes move the handling code out of sp-pci.c. No intended functional changes. Signed-off-by: Mario Limonciello <[email protected]> Acked-by: Tom Lendacky <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 8609dd2 commit 56e0d88

File tree

6 files changed

+95
-56
lines changed

6 files changed

+95
-56
lines changed

MAINTAINERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,12 @@ F: include/uapi/linux/psp-dbc.h
991991
F: tools/crypto/ccp/*.c
992992
F: tools/crypto/ccp/*.py
993993

994+
AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - HSTI SUPPORT
995+
M: Mario Limonciello <[email protected]>
996+
997+
S: Supported
998+
F: drivers/crypto/ccp/hsti.*
999+
9941000
AMD DISPLAY CORE
9951001
M: Harry Wentland <[email protected]>
9961002
M: Leo Li <[email protected]>

drivers/crypto/ccp/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ ccp-$(CONFIG_CRYPTO_DEV_SP_PSP) += psp-dev.o \
1212
sev-dev.o \
1313
tee-dev.o \
1414
platform-access.o \
15-
dbc.o
15+
dbc.o \
16+
hsti.o
1617

1718
obj-$(CONFIG_CRYPTO_DEV_CCP_CRYPTO) += ccp-crypto.o
1819
ccp-crypto-objs := ccp-crypto-main.o \

drivers/crypto/ccp/hsti.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* AMD Secure Processor device driver, security attributes
4+
*
5+
* Copyright (C) 2023-2024 Advanced Micro Devices, Inc.
6+
*
7+
* Author: Mario Limonciello <[email protected]>
8+
*/
9+
10+
#include <linux/device.h>
11+
12+
#include "psp-dev.h"
13+
#include "hsti.h"
14+
15+
#define security_attribute_show(name) \
16+
static ssize_t name##_show(struct device *d, struct device_attribute *attr, \
17+
char *buf) \
18+
{ \
19+
struct sp_device *sp = dev_get_drvdata(d); \
20+
struct psp_device *psp = sp->psp_data; \
21+
return sysfs_emit(buf, "%d\n", psp->capability.name); \
22+
}
23+
24+
security_attribute_show(fused_part)
25+
static DEVICE_ATTR_RO(fused_part);
26+
security_attribute_show(debug_lock_on)
27+
static DEVICE_ATTR_RO(debug_lock_on);
28+
security_attribute_show(tsme_status)
29+
static DEVICE_ATTR_RO(tsme_status);
30+
security_attribute_show(anti_rollback_status)
31+
static DEVICE_ATTR_RO(anti_rollback_status);
32+
security_attribute_show(rpmc_production_enabled)
33+
static DEVICE_ATTR_RO(rpmc_production_enabled);
34+
security_attribute_show(rpmc_spirom_available)
35+
static DEVICE_ATTR_RO(rpmc_spirom_available);
36+
security_attribute_show(hsp_tpm_available)
37+
static DEVICE_ATTR_RO(hsp_tpm_available);
38+
security_attribute_show(rom_armor_enforced)
39+
static DEVICE_ATTR_RO(rom_armor_enforced);
40+
41+
static struct attribute *psp_security_attrs[] = {
42+
&dev_attr_fused_part.attr,
43+
&dev_attr_debug_lock_on.attr,
44+
&dev_attr_tsme_status.attr,
45+
&dev_attr_anti_rollback_status.attr,
46+
&dev_attr_rpmc_production_enabled.attr,
47+
&dev_attr_rpmc_spirom_available.attr,
48+
&dev_attr_hsp_tpm_available.attr,
49+
&dev_attr_rom_armor_enforced.attr,
50+
NULL
51+
};
52+
53+
static umode_t psp_security_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
54+
{
55+
struct device *dev = kobj_to_dev(kobj);
56+
struct sp_device *sp = dev_get_drvdata(dev);
57+
struct psp_device *psp = sp->psp_data;
58+
59+
if (psp && psp->capability.security_reporting)
60+
return 0444;
61+
62+
return 0;
63+
}
64+
65+
struct attribute_group psp_security_attr_group = {
66+
.attrs = psp_security_attrs,
67+
.is_visible = psp_security_is_visible,
68+
};

drivers/crypto/ccp/hsti.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* AMD Secure Processor device driver, security attributes
4+
*
5+
* Copyright (C) 2023-2024 Advanced Micro Devices, Inc.
6+
*
7+
* Author: Mario Limonciello <[email protected]>
8+
*/
9+
10+
#ifndef __HSTI_H
11+
#define __HSTI_H
12+
13+
extern struct attribute_group psp_security_attr_group;
14+
15+
#endif /* __HSTI_H */

drivers/crypto/ccp/psp-dev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "tee-dev.h"
2020
#include "platform-access.h"
2121
#include "dbc.h"
22+
#include "hsti.h"
2223

2324
struct psp_device *psp_master;
2425

drivers/crypto/ccp/sp-pci.c

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "ccp-dev.h"
2626
#include "psp-dev.h"
27+
#include "hsti.h"
2728

2829
/* used for version string AA.BB.CC.DD */
2930
#define AA GENMASK(31, 24)
@@ -39,61 +40,6 @@ struct sp_pci {
3940
};
4041
static struct sp_device *sp_dev_master;
4142

42-
#define security_attribute_show(name) \
43-
static ssize_t name##_show(struct device *d, struct device_attribute *attr, \
44-
char *buf) \
45-
{ \
46-
struct sp_device *sp = dev_get_drvdata(d); \
47-
struct psp_device *psp = sp->psp_data; \
48-
return sysfs_emit(buf, "%d\n", psp->capability.name); \
49-
}
50-
51-
security_attribute_show(fused_part)
52-
static DEVICE_ATTR_RO(fused_part);
53-
security_attribute_show(debug_lock_on)
54-
static DEVICE_ATTR_RO(debug_lock_on);
55-
security_attribute_show(tsme_status)
56-
static DEVICE_ATTR_RO(tsme_status);
57-
security_attribute_show(anti_rollback_status)
58-
static DEVICE_ATTR_RO(anti_rollback_status);
59-
security_attribute_show(rpmc_production_enabled)
60-
static DEVICE_ATTR_RO(rpmc_production_enabled);
61-
security_attribute_show(rpmc_spirom_available)
62-
static DEVICE_ATTR_RO(rpmc_spirom_available);
63-
security_attribute_show(hsp_tpm_available)
64-
static DEVICE_ATTR_RO(hsp_tpm_available);
65-
security_attribute_show(rom_armor_enforced)
66-
static DEVICE_ATTR_RO(rom_armor_enforced);
67-
68-
static struct attribute *psp_security_attrs[] = {
69-
&dev_attr_fused_part.attr,
70-
&dev_attr_debug_lock_on.attr,
71-
&dev_attr_tsme_status.attr,
72-
&dev_attr_anti_rollback_status.attr,
73-
&dev_attr_rpmc_production_enabled.attr,
74-
&dev_attr_rpmc_spirom_available.attr,
75-
&dev_attr_hsp_tpm_available.attr,
76-
&dev_attr_rom_armor_enforced.attr,
77-
NULL
78-
};
79-
80-
static umode_t psp_security_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
81-
{
82-
struct device *dev = kobj_to_dev(kobj);
83-
struct sp_device *sp = dev_get_drvdata(dev);
84-
struct psp_device *psp = sp->psp_data;
85-
86-
if (psp && psp->capability.security_reporting)
87-
return 0444;
88-
89-
return 0;
90-
}
91-
92-
static struct attribute_group psp_security_attr_group = {
93-
.attrs = psp_security_attrs,
94-
.is_visible = psp_security_is_visible,
95-
};
96-
9743
#define version_attribute_show(name, _offset) \
9844
static ssize_t name##_show(struct device *d, struct device_attribute *attr, \
9945
char *buf) \
@@ -150,7 +96,9 @@ static struct attribute_group psp_firmware_attr_group = {
15096
};
15197

15298
static const struct attribute_group *psp_groups[] = {
99+
#ifdef CONFIG_CRYPTO_DEV_SP_PSP
153100
&psp_security_attr_group,
101+
#endif
154102
&psp_firmware_attr_group,
155103
NULL,
156104
};

0 commit comments

Comments
 (0)