Re: [PATCH v4 3/8] x86/virt/tdx: Prepare to support reading other global metadata fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/24/24 04:28, Kai Huang wrote:
> +#define build_sysmd_read(_size)							\
> +static int __read_sys_metadata_field##_size(u64 field_id, u##_size *val)	\
> +{										\
> +	u64 tmp;								\
> +	int ret;								\
> +										\
> +	ret = tdh_sys_rd(field_id, &tmp);					\
> +	if (ret)								\
> +		return ret;							\
> +										\
> +	*val = tmp;								\
> +										\
> +	return 0;								\
>  }

Why?  What's so important about having the compiler do the copy?


#define read_sys_metadata_field(id, val) 	\
	__read_sys_metadata_field(id, val, sizeof (*(val)))

static int __read_sys_metadata_field(u64 field_id, void *ptr, int size)
{
	...
	memcpy(ptr, &tmp, size);

	return 0;
}

There's one simple #define there so that users don't have to do the
sizeof and can't screw it up.




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux