Re: [PATCH 4/4] driver: provide sysfs interfaces to access SMXparameter

From: Matthew Garrett
Date: Wed May 08 2013 - 01:25:16 EST


On Tue, 2013-05-07 at 22:55 +0800, Qiaowei Ren wrote:
> These interfaces are located in /sys/devices/platform/intel_txt/parameter/,
> showing specific parameter information for SMX features supported by
> the processor.

Explain what SMX is here.

> +Contact: "Qiaowei Ren" <qiaowei.ren@xxxxxxxxx>
> +Description: The parameter/ directory exposes specific parameter
> + information for SMX features supported by the processor.

Also here.

> +What: /sys/devices/platform/intel_txt/parameter/acm_max_size
> +Date: May 2013
> +KernelVersion: 3.9
> +Contact: "Qiaowei Ren" <qiaowei.ren@xxxxxxxxx>
> +Description: The "acm_max_size" property will show max size of
> + authenticated code execution area.

What would userspace use this for?

> +What: /sys/devices/platform/intel_txt/parameter/acm_mem_types
> +Date: May 2013
> +KernelVersion: 3.9
> +Contact: "Qiaowei Ren" <qiaowei.ren@xxxxxxxxx>
> +Description: The "acm_max_types" property will show external memory
> + types supported during AC mode.

Or this? And what's AC mode?

> +static void __getsec_parameters(uint32_t index, int *param_type,
> + uint32_t *peax, uint32_t *pebx,
> + uint32_t *pecx)
> +{
> + uint32_t eax = 0, ebx = 0, ecx = 0;

These are all going to be overwritten by the getsec operation? Do they
really need to be initialised?

> + __asm__ __volatile__ (IA32_GETSEC_OPCODE "\n"
> + : "=a"(eax), "=b"(ebx), "=c"(ecx)
> + : "a"(IA32_GETSEC_PARAMETERS), "b"(index));
> +
> + *param_type = eax & 0x1f;
> + *peax = eax;
> + *pebx = ebx;
> + *pecx = ecx;

Should there be a check for failure here? Is it possible for this
operation to fail?

> + write_cr4(read_cr4() | CR4_SMXE);

Whoo. This needs at least a giant comment and probably some locking, but
if this is supposed to be set during runtime then it should be done in
core architecture code rather than just in this driver.

> + sscanf(buf, "%d", &index);

What if this fails?

> +EXPORT_SYMBOL_GPL(sysfs_create_parameter);
> +
> +MODULE_LICENSE("GPL");

Not needed.

> +#define IA32_GETSEC_OPCODE ".byte 0x0f,0x37"

Nnf. Does the assembler really not know about this instruction?

--
Matthew Garrett | mjg59@xxxxxxxxxxxxx
¢éì®&Þ~º&¶¬–+-±éÝ¥Šw®žË±Êâmébžìdz¹Þ)í…æèw*jg¬±¨¶‰šŽŠÝj/êäz¹ÞŠà2ŠÞ¨è­Ú&¢)ß«a¶Úþø®G«éh®æj:+v‰¨Šwè†Ù>Wš±êÞiÛaxPjØm¶Ÿÿà -»+ƒùdš_