[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <408dee3f-a466-4746-92d3-adf54d35ec7c@intel.com>
Date: Thu, 26 Sep 2024 08:47:54 -0700
From: Dave Hansen <dave.hansen@...el.com>
To: Kai Huang <kai.huang@...el.com>, kirill.shutemov@...ux.intel.com,
tglx@...utronix.de, bp@...en8.de, peterz@...radead.org, mingo@...hat.com,
hpa@...or.com, dan.j.williams@...el.com, seanjc@...gle.com,
pbonzini@...hat.com
Cc: x86@...nel.org, linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
rick.p.edgecombe@...el.com, isaku.yamahata@...el.com,
adrian.hunter@...el.com, nik.borisov@...e.com
Subject: Re: [PATCH v4 3/8] x86/virt/tdx: Prepare to support reading other
global metadata fields
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.
Powered by blists - more mailing lists