TXT driver
cover TXT driver
This module is expected to be a better tool to access below resources
- TXT config space
- TXT heap
- Tboot log mem
- SMX parameter
Intel TXT (Trusted Execution Technology) will provide higher assurance of system configuration and initial state as well as data reset protection. It also helps solve real end user concerns about having confidence that their hardware is running the VMM or kernel that it was configured with, especially since they may be responsible for providing such assurances to VMs and services running on it.
See <http://www.intel.com/technology/security/> for more information about Intel(R) TXT.
Intel TXT configuration registers are a subset of chipset registers. These chipset registers that interact with SMX are accessed from two regions of memory, which represent the public and private configuration spaces, by system software using memory read/write protocols.
Intel TXT Heap memory is a region of physically contiguous memory which is set aside by BIOS for the use of Intel TXT hardware and software.
With this module, it will be easier to access TXT/tboot related information/logs.
Qiaowei Ren (5):
driver: add TXT driver in kernel
driver: provide sysfs interfaces to access TXT config space
driver: provide sysfs interfaces to access TXT log
driver: provide sysfs interfaces to access SMX parameter
driver: provide sysfs interfaces to access TXT heap
drivers/char/Kconfig | 2 + drivers/char/Makefile | 1 + drivers/char/txt/Kconfig | 18 + drivers/char/txt/Makefile | 5 + drivers/char/txt/txt-config.c | 1041 ++++++++++++++++++++++++ drivers/char/txt/txt-config.h | 138 ++++ drivers/char/txt/txt-heap.c | 1616 ++++++++++++++++++++++++++++++++++++++ drivers/char/txt/txt-heap.h | 338 ++++++++ drivers/char/txt/txt-log.c | 140 ++++ drivers/char/txt/txt-log.h | 27 + drivers/char/txt/txt-parameter.c | 261 ++++++ drivers/char/txt/txt-parameter.h | 40 + drivers/char/txt/txt-sysfs.c | 68 ++ 13 files changed, 3695 insertions(+) create mode 100644 drivers/char/txt/Kconfig create mode 100644 drivers/char/txt/Makefile create mode 100644 drivers/char/txt/txt-config.c create mode 100644 drivers/char/txt/txt-config.h create mode 100644 drivers/char/txt/txt-heap.c create mode 100644 drivers/char/txt/txt-heap.h create mode 100644 drivers/char/txt/txt-log.c create mode 100644 drivers/char/txt/txt-log.h create mode 100644 drivers/char/txt/txt-parameter.c create mode 100644 drivers/char/txt/txt-parameter.h create mode 100644 drivers/char/txt/txt-sysfs.c
Signature · 1 line
1.7.9.5
PATCH 1/5 driver: add TXT driver in kernel
TXT driver is expected to be a better tool to access below resources:
TXT config space, TXT heap, TXT log and SMX parameter.
--- drivers/char/Kconfig | 2 ++ drivers/char/Makefile | 1 + drivers/char/txt/Kconfig | 18 ++++++++++++++++++ drivers/char/txt/Makefile | 5 +++++ drivers/char/txt/txt-sysfs.c | 41 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 drivers/char/txt/Kconfig create mode 100644 drivers/char/txt/Makefile create mode 100644 drivers/char/txt/txt-sysfs.c
drivers/char/Kconfig +2 -0
@@ -565,6 +565,8 @@ config UV_MMTIMER source "drivers/char/tpm/Kconfig" +source "drivers/char/txt/Kconfig" + config TELCLOCK tristate "Telecom clock driver for ATCA SBC" depends on X86
drivers/char/Makefile +1 -0
@@ -55,6 +55,7 @@ obj-$(CONFIG_PCMCIA) += pcmcia/ obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o obj-$(CONFIG_TCG_TPM) += tpm/ +obj-$(CONFIG_TXT) += txt/ obj-$(CONFIG_PS3_FLASH) += ps3flash.o
drivers/char/txt/Kconfig new file +18 -0
@@ -0,0 +1,18 @@ +# +# intel TXT driver configuration +# + +config INTEL_TXT_DRIVER + tristate "INTEL TXT sysfs driver" + default m + depends on INTEL_TXT + select SECURITYFS + ---help--- + TXT Driver is expected to be a better tool to access below resources: + - TXT config space + - TXT heap + - Tboot log mem + - SMX parameter + + To compile this driver as a module, choose M here; the module will be + called txt.
drivers/char/txt/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for the intel TXT drivers. +# +obj-$(CONFIG_TXT) += txt.o +txt-y := txt-sysfs.o
drivers/char/txt/txt-sysfs.c new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Greg Kroah-Hartman
maintainerRe: [PATCH 1/5] driver: add TXT driver in kernel
Quoted 2 lines · Qiaowei Ren
TXT driver is expected to be a better tool to access below resources:
TXT config space, TXT heap, TXT log and SMX parameter.
You are adding new sysfs files, so that means you need to add Documentation/ABI files as well. Please respin this series with those added so we have a hint as to how this driver is interacting with userspace.
Quoted 45 lines
Signed-off-by Qiaowei Ren <[email protected]>Signed-off-by Xiaoyan Zhang <[email protected]>Signed-off-by Gang Wei <[email protected]>--- drivers/char/Kconfig | 2 ++ drivers/char/Makefile | 1 + drivers/char/txt/Kconfig | 18 ++++++++++++++++++ drivers/char/txt/Makefile | 5 +++++ drivers/char/txt/txt-sysfs.c | 41 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 drivers/char/txt/Kconfig create mode 100644 drivers/char/txt/Makefile create mode 100644 drivers/char/txt/txt-sysfs.cdrivers/char/Kconfig +2
-0@@ -565,6 +565,8 @@ config UV_MMTIMER source "drivers/char/tpm/Kconfig" +source "drivers/char/txt/Kconfig" + config TELCLOCK tristate "Telecom clock driver for ATCA SBC" depends on X86drivers/char/Makefile +1
-0@@ -55,6 +55,7 @@ obj-$(CONFIG_PCMCIA) += pcmcia/ obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o obj-$(CONFIG_TCG_TPM) += tpm/ +obj-$(CONFIG_TXT) += txt/ obj-$(CONFIG_PS3_FLASH) += ps3flash.odrivers/char/txt/Kconfig new file +0
-0
drivers/char/txt/Kconfig line 6
Quoted 6 lines
drivers/char/txt/Kconfig new file +6
-0@@ -0,0 +1,18 @@ +# +# intel TXT driver configuration +# + +config INTEL_TXT_DRIVER + tristate "INTEL TXT sysfs driver"
Why isn't this a drivers/platform/x86/ driver?
drivers/char/txt/Kconfig line 9
Quoted 3 lines
drivers/char/txt/Kconfig new file +3
-0+ default m + depends on INTEL_TXT + select SECURITYFS
Or even better yet, a drivers/security/ driver?
Quoted 35 lines
drivers/char/txt/Kconfig new file +9
-0+ ---help--- + TXT Driver is expected to be a better tool to access below resources: + - TXT config space + - TXT heap + - Tboot log mem + - SMX parameter + + To compile this driver as a module, choose M here; the module will be + called txt.drivers/char/txt/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# +# Makefile for the intel TXT drivers. +# +obj-$(CONFIG_TXT) += txt.o +txt-y := txt-sysfs.odrivers/char/txt/txt-sysfs.c new file +9
-0@@ -0,0 +1,41 @@ +/* +* txt-sysfs.c +* +* This module is expected to be a better tool to access below resources +* - TXT config space +* - TXT heap +* - Tboot log mem +* - SMX parameter +*
drivers/char/txt/txt-sysfs.c line 19
Quoted 10 lines
drivers/char/txt/txt-sysfs.c new file +10
-0+* Data is currently found below +* /sys/devices/platform/txt/... +*/ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/sysfs.h> + +#define DEV_NAME "txt"
That's a _very_ generic name.
drivers/char/txt/txt-sysfs.c line 20
Quoted 1 line
drivers/char/txt/txt-sysfs.c new file +1
-0+struct platform_device *pdev;
That's a _very_ generic global variable you just created. Don't.
drivers/char/txt/txt-sysfs.c line 28
Quoted 7 lines
drivers/char/txt/txt-sysfs.c new file +7
-0+static int __init txt_sysfs_init (void ) +{ + pdev =platform_device_register_simple (DEV_NAME ,-1 ,NULL ,0 ); +if (IS_ERR (pdev)) +return PTR_ERR (pdev); + +pr_info ("Loading TXT module successfully\n" );
We don't care that your driver was loaded, don't be noisy.
drivers/char/txt/txt-sysfs.c line 35
Quoted 7 lines
drivers/char/txt/txt-sysfs.c new file +7
-0+return 0 ; +} + +static void __exit txt_sysfs_exit(void) +{ +platform_device_unregister (pdev); +pr_info ("Unloading TXT module successfully\n" );
Same thing here.
Also, isn't there a module_platform_driver() macro you can use intead?
thanks,
greg k-h
PATCH 2/5 driver: provide sysfs interfaces to access TXT config space
In reply to Qiaowei RenThese interfaces are located in /sys/devices/platform/txt/config, and including totally 37 files, providing access to Intel TXT configuration registers.
--- drivers/char/txt/Makefile | 2 +- drivers/char/txt/txt-config.c | 1041 +++++++++++++++++++++++++++++++++++++++++ drivers/char/txt/txt-config.h | 138 ++++++ drivers/char/txt/txt-sysfs.c | 12 + 4 files changed, 1192 insertions(+), 1 deletion(-) create mode 100644 drivers/char/txt/txt-config.c create mode 100644 drivers/char/txt/txt-config.h
drivers/char/txt/Makefile +1 -1
@@ -2,4 +2,4 @@ # Makefile for the intel TXT drivers. # obj-$(CONFIG_TXT) += txt.o -txt-y := txt-sysfs.o +txt-y := txt-sysfs.o txt-config.o
drivers/char/txt/txt-config.c new file +1041 -0
1,041 lines not on this page · raw message
drivers/char/txt/txt-config.h new file +138 -0
138 lines not on this page · raw message
drivers/char/txt/txt-sysfs.c +12 -0
@@ -16,17 +16,29 @@#include <linux/platform_device.h> #include <linux/sysfs.h> +#include "txt-config.h" +#define DEV_NAME "txt"struct platform_device *pdev;static int __init txt_sysfs_init (void ) { +int retval; + pdev =platform_device_register_simple (DEV_NAME ,-1 ,NULL ,0 );if (IS_ERR (pdev))return PTR_ERR (pdev); + retval =sysfs_create_config (&pdev->dev.kobj); +if (retval) + goto err; +pr_info ("Loading TXT module successfully\n" );return 0 ; + +err: +platform_device_unregister (pdev); +return retval; } static void __exit txt_sysfs_exit(void)
Signature · 1 line
1.7.9.5
PATCH 3/5 driver: provide sysfs interfaces to access TXT log
In reply to Qiaowei RenThese interfaces are located in /sys/devices/platform/txt/log/.
--- drivers/char/txt/Makefile | 2 +- drivers/char/txt/txt-log.c | 140 ++++++++++++++++++++++++++++++++++++++++++ drivers/char/txt/txt-log.h | 27 ++++++++ drivers/char/txt/txt-sysfs.c | 5 ++ 4 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 drivers/char/txt/txt-log.c create mode 100644 drivers/char/txt/txt-log.h
drivers/char/txt/Makefile +1 -1
@@ -2,4 +2,4 @@ # Makefile for the intel TXT drivers. # obj-$(CONFIG_TXT) += txt.o -txt-y := txt-sysfs.o txt-config.o +txt-y := txt-sysfs.o txt-config.o txt-log.o
drivers/char/txt/txt-log.c new file +140 -0
140 lines not on this page · raw message
drivers/char/txt/txt-log.h new file +27 -0
@@ -0,0 +1,27 @@ +#ifndef __LOG_H__ +#define __LOG_H__ + +struct uuid { +uint32_t data1; +uint16_t data2; +uint16_t data3; +uint16_t data4; +uint8_t data5[6 ]; +} __packed; + +struct tboot_log { +struct uuid uuid; +uint32_t max_size; +uint32_t curr_pos; +char buf[]; +}; + +#define TBOOT_LOG_UUID {0xc0192526, 0x6b30, 0x4db4, 0x844c, \ + {0xa3, 0xe9, 0x53, 0xb8, 0x81, 0x74} } +#define TBOOT_SERIAL_LOG_ADDR 0x60000 +#define TBOOT_SERIAL_LOG_SIZE 0x08000 + +extern ssize_t sysfs_create_log (struct kobject *parent); + +#endif /* __LOG_H__ */ +
drivers/char/txt/txt-sysfs.c +5 -0
@@ -17,6 +17,7 @@#include <linux/sysfs.h> #include "txt-config.h" +#include "txt-log.h" #define DEV_NAME "txt"struct platform_device *pdev;
@@ -33,6 +34,10 @@ static int __init txt_sysfs_init(void)if (retval) goto err; + retval =sysfs_create_log (&pdev->dev.kobj); +if (retval) + goto err; +pr_info ("Loading TXT module successfully\n" );return 0 ;
Signature · 1 line
1.7.9.5
Greg Kroah-Hartman
maintainerRe: [PATCH 3/5] driver: provide sysfs interfaces to access TXT log
Quoted 5 lines · Qiaowei Ren
drivers/char/txt/txt-log.c new file +5
-0+ssize_t sysfs_create_log (struct kobject *parent) +{ +struct kobject *log_kobj; +int retval; +
drivers/char/txt/txt-log.c line 137
Quoted 10 lines
drivers/char/txt/txt-log.c new file +10
-0+ log_kobj =kobject_create_and_add ("log" , parent); +if (!log_kobj) +return -ENOMEM ; + + retval =sysfs_create_group (log_kobj, &log_attr_grp); +if (retval) +kobject_put (log_kobj); +return retval; +} +EXPORT_SYMBOL_GPL (sysfs_create_log);
Seriously? That's what you are calling this function?
{sigh}
Please, go get this patch series reviewed by other, experienced, Intel developers, before you send it out again. There's loads of things wrong with this series, and they can help you out much easier, and nicer, than I'm going to be here.
Oh, and NEVER use "raw" kobjects, by doing that, you know you are doing something wrong in a driver.
greg k-h
PATCH 4/5 driver: provide sysfs interfaces to access SMX parameter
In reply to Qiaowei RenThese interfaces are located in /sys/devices/platform/txt/parameter/, showing specific parameter information for SMX features supported by the processor.
--- drivers/char/txt/Makefile | 2 +- drivers/char/txt/txt-parameter.c | 261 ++++++++++++++++++++++++++++++++++++++ drivers/char/txt/txt-parameter.h | 40 ++++++ drivers/char/txt/txt-sysfs.c | 5 + 4 files changed, 307 insertions(+), 1 deletion(-) create mode 100644 drivers/char/txt/txt-parameter.c create mode 100644 drivers/char/txt/txt-parameter.h
drivers/char/txt/Makefile +1 -1
@@ -2,4 +2,4 @@ # Makefile for the intel TXT drivers. # obj-$(CONFIG_TXT) += txt.o -txt-y := txt-sysfs.o txt-config.o txt-log.o +txt-y := txt-sysfs.o txt-config.o txt-log.o txt-parameter.o
drivers/char/txt/txt-parameter.c new file +261 -0
261 lines not on this page · raw message
drivers/char/txt/txt-parameter.h new file +40 -0
@@ -0,0 +1,40 @@ +#ifndef __PARAMETER_H__ +#define __PARAMETER_H__ + +#define CR4_SMXE 0x00004000 +#define MAX_SUPPORTED_ACM_VERSIONS 16 + +#define DEF_ACM_MAX_SIZE 0x8000 +#define DEF_ACM_VER_MASK 0xffffffff +#define DEF_ACM_VER_SUPPORTED 0x00 +#define DEF_ACM_MEM_TYPES 0x0100 +#define DEF_SENTER_CTRLS 0x00 + +#define IA32_GETSEC_OPCODE ".byte 0x0f,0x37" +#define IA32_GETSEC_PARAMETERS 6 + +#define off_n_versions 1 +#define off_acm_max_size 2 +#define off_acm_mem_types 3 +#define off_senter_controls 4 +#define off_proc_based_scrtm 5 +#define off_preserve_mce 6 +#define off_acm_version 7 + +typedef struct getsec_parameters { +struct { +uint32_t mask; +uint32_t version; + } acm_versions[MAX_SUPPORTED_ACM_VERSIONS ]; +int n_versions; +uint32_t acm_max_size; +uint32_t acm_mem_types; +uint32_t senter_controls; +bool proc_based_scrtm; +bool preserve_mce; +}getsec_parameters_t ; + +extern ssize_t sysfs_create_parameter (struct kobject *parent); + +#endif /* __PARAMETER_H__ */ +
drivers/char/txt/txt-sysfs.c +5 -0
@@ -18,6 +18,7 @@#include "txt-config.h" #include "txt-log.h" +#include "txt-parameter.h" #define DEV_NAME "txt"struct platform_device *pdev;
@@ -38,6 +39,10 @@ static int __init txt_sysfs_init(void)if (retval) goto err; + retval =sysfs_create_parameter (&pdev->dev.kobj); +if (retval) + goto err; +pr_info ("Loading TXT module successfully\n" );return 0 ;
Signature · 1 line
1.7.9.5
PATCH 5/5 driver: provide sysfs interfaces to access TXT heap
In reply to Qiaowei RenThese interfaces are located in /sys/devices/platform/txt/heap/. There are one file binary_heap displaying the whole heap information in binary, and four subfolders displaying detailed heap information.
--- drivers/char/txt/Makefile | 2 +- drivers/char/txt/txt-heap.c | 1616 ++++++++++++++++++++++++++++++++++++++++++ drivers/char/txt/txt-heap.h | 338 +++++++++ drivers/char/txt/txt-sysfs.c | 5 + 4 files changed, 1960 insertions(+), 1 deletion(-) create mode 100644 drivers/char/txt/txt-heap.c create mode 100644 drivers/char/txt/txt-heap.h
drivers/char/txt/Makefile +1 -1
@@ -2,4 +2,4 @@ # Makefile for the intel TXT drivers. # obj-$(CONFIG_TXT) += txt.o -txt-y := txt-sysfs.o txt-config.o txt-log.o txt-parameter.o +txt-y := txt-sysfs.o txt-config.o txt-log.o txt-parameter.o txt-heap.o
drivers/char/txt/txt-heap.c new file +1616 -0
1,616 lines not on this page · raw message
drivers/char/txt/txt-heap.h new file +338 -0
338 lines not on this page · raw message
drivers/char/txt/txt-sysfs.c +5 -0
@@ -19,6 +19,7 @@#include "txt-config.h" #include "txt-log.h" #include "txt-parameter.h" +#include "txt-heap.h" #define DEV_NAME "txt"struct platform_device *pdev;
@@ -43,6 +44,10 @@ static int __init txt_sysfs_init(void)if (retval) goto err; + retval =sysfs_create_heap (&pdev->dev.kobj); +if (retval) + goto err; +pr_info ("Loading TXT module successfully\n" );return 0 ;
Signature · 1 line
1.7.9.5