0001 #ifndef _ASM_X86_INTEL_PCONFIG_H
0002 #define _ASM_X86_INTEL_PCONFIG_H
0003
0004 #include <asm/asm.h>
0005 #include <asm/processor.h>
0006
0007 enum pconfig_target {
0008 INVALID_TARGET = 0,
0009 MKTME_TARGET = 1,
0010 PCONFIG_TARGET_NR
0011 };
0012
0013 int pconfig_target_supported(enum pconfig_target target);
0014
0015 enum pconfig_leaf {
0016 MKTME_KEY_PROGRAM = 0,
0017 PCONFIG_LEAF_INVALID,
0018 };
0019
0020 #define PCONFIG ".byte 0x0f, 0x01, 0xc5"
0021
0022
0023
0024
0025 #define MKTME_KEYID_SET_KEY_DIRECT 0
0026 #define MKTME_KEYID_SET_KEY_RANDOM 1
0027 #define MKTME_KEYID_CLEAR_KEY 2
0028 #define MKTME_KEYID_NO_ENCRYPT 3
0029
0030
0031 #define MKTME_AES_XTS_128 (1 << 8)
0032
0033
0034 #define MKTME_PROG_SUCCESS 0
0035 #define MKTME_INVALID_PROG_CMD 1
0036 #define MKTME_ENTROPY_ERROR 2
0037 #define MKTME_INVALID_KEYID 3
0038 #define MKTME_INVALID_ENC_ALG 4
0039 #define MKTME_DEVICE_BUSY 5
0040
0041
0042 struct mktme_key_program {
0043 u16 keyid;
0044 u32 keyid_ctrl;
0045 u8 __rsvd[58];
0046 u8 key_field_1[64];
0047 u8 key_field_2[64];
0048 } __packed __aligned(256);
0049
0050 static inline int mktme_key_program(struct mktme_key_program *key_program)
0051 {
0052 unsigned long rax = MKTME_KEY_PROGRAM;
0053
0054 if (!pconfig_target_supported(MKTME_TARGET))
0055 return -ENXIO;
0056
0057 asm volatile(PCONFIG
0058 : "=a" (rax), "=b" (key_program)
0059 : "0" (rax), "1" (key_program)
0060 : "memory", "cc");
0061
0062 return rax;
0063 }
0064
0065 #endif