lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a7552693-e0df-4225-9cbf-a5f482900626@suse.com>
Date: Tue, 18 Jun 2024 14:42:19 +0300
From: Nikolay Borisov <nik.borisov@...e.com>
To: Kai Huang <kai.huang@...el.com>, linux-kernel@...r.kernel.org
Cc: x86@...nel.org, dave.hansen@...el.com, dan.j.williams@...el.com,
 kirill.shutemov@...ux.intel.com, rick.p.edgecombe@...el.com,
 peterz@...radead.org, tglx@...utronix.de, bp@...en8.de, mingo@...hat.com,
 hpa@...or.com, seanjc@...gle.com, pbonzini@...hat.com, kvm@...r.kernel.org,
 isaku.yamahata@...el.com, binbin.wu@...ux.intel.com
Subject: Re: [PATCH 3/9] x86/virt/tdx: Support global metadata read for all
 element sizes

<snip>

>   
> -static int read_sys_metadata_field16(u64 field_id,
> -				     int offset,
> -				     void *stbuf)
> +/*
> + * Read one global metadata field and store the data to a location of a
> + * given buffer specified by the offset and size (in bytes).
> + */
> +static int stbuf_read_sysmd_field(u64 field_id, void *stbuf, int offset,

read_system_metadat_field or read_sys_metadata_field or simply
read_metadata_field

> +				  int bytes)
s/bytes/size
>   {
> -	u16 *st_member = stbuf + offset;
> +	void *st_member = stbuf + offset;

Again, this could be renamed to just 'member', what value does the 'st' 
prefix bring?

>   	u64 tmp;
>   	int ret;
>   
> -	if (WARN_ON_ONCE(MD_FIELD_ID_ELE_SIZE_CODE(field_id) !=
> -			MD_FIELD_ID_ELE_SIZE_16BIT))
> +	if (WARN_ON_ONCE(MD_FIELD_BYTES(field_id) != bytes))
>   		return -EINVAL;
>   
>   	ret = read_sys_metadata_field(field_id, &tmp);
>   	if (ret)
>   		return ret;
>   
> -	*st_member = tmp;
> +	memcpy(st_member, &tmp, bytes);
>   
>   	return 0;
>   }
> @@ -294,11 +296,13 @@ static int read_sys_metadata_field16(u64 field_id,
>   struct field_mapping {
>   	u64 field_id;
>   	int offset;
> +	int size;
>   };
>   
> -#define TD_SYSINFO_MAP(_field_id, _struct, _member)	\
> -	{ .field_id = MD_FIELD_ID_##_field_id,		\
> -	  .offset   = offsetof(_struct, _member) }
> +#define TD_SYSINFO_MAP(_field_id, _struct, _member)		\
> +	{ .field_id = MD_FIELD_ID_##_field_id,			\
> +	  .offset   = offsetof(_struct, _member),		\
> +	  .size	    = sizeof(typeof(((_struct *)0)->_member)) }
>   
>   #define TD_SYSINFO_MAP_TDMR_INFO(_field_id, _member)	\
>   	TD_SYSINFO_MAP(_field_id, struct tdx_tdmr_sysinfo, _member)
> @@ -319,9 +323,8 @@ static int get_tdx_tdmr_sysinfo(struct tdx_tdmr_sysinfo *tdmr_sysinfo)
>   
>   	/* Populate 'tdmr_sysinfo' fields using the mapping structure above: */
>   	for (i = 0; i < ARRAY_SIZE(fields); i++) {
> -		ret = read_sys_metadata_field16(fields[i].field_id,
> -						fields[i].offset,
> -						tdmr_sysinfo);
> +		ret = stbuf_read_sysmd_field(fields[i].field_id, tdmr_sysinfo,
> +				fields[i].offset, fields[i].size);
>   		if (ret)
>   			return ret;
>   	}
> diff --git a/arch/x86/virt/vmx/tdx/tdx.h b/arch/x86/virt/vmx/tdx/tdx.h
> index b701f69485d3..812943516946 100644
> --- a/arch/x86/virt/vmx/tdx/tdx.h
> +++ b/arch/x86/virt/vmx/tdx/tdx.h
> @@ -53,7 +53,8 @@
>   #define MD_FIELD_ID_ELE_SIZE_CODE(_field_id)	\
>   		(((_field_id) & GENMASK_ULL(33, 32)) >> 32)
>   
> -#define MD_FIELD_ID_ELE_SIZE_16BIT	1
> +#define MD_FIELD_BYTES(_field_id)	\

Just name it MD_FIELD_SIZE, even the MD_FIELD_ID member is called 
ELEMENT_SIZE_CODE, rather than ELEMENT_BYTES_CODE or some such.

> +		(1 << MD_FIELD_ID_ELE_SIZE_CODE(_field_id))
>   
>   struct tdmr_reserved_area {
>   	u64 offset;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ