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 Tue, 2024-10-01 at 08:19 -0700, Dave Hansen wrote:
> On 10/1/24 03:44, Huang, Kai wrote:
> > Please let me know if you have any concern?  Otherwise I will go with
> > this route.
> I still see some long unwieldy #defines in the mail thread.  That's my
> biggest worry.

I suppose you mean the read_sys_metadata_field() macro?

We can split that into two smaller macros by moving BUILD_BUG_ON() out:

/* Don't use this directly, use read_sys_metadata_read() instead. */
#define __read_sys_metadata_field(_field_id, _valptr)   \
({                                                      \
        u64 ___tmp;                                     \
        int ___ret;                                     \
                                                        \
        ___ret = tdh_sys_rd(_field_id, &___tmp);        \
        *_valptr = ___tmp;                              \
                                                        \
        ___ret;                                         \
})

/* @_valptr must be pointer of u8/u16/u32/u64. */
#define read_sys_metadata_field(_field_id, _valptr)     \
({                                                      \
        BUILD_BUG_ON(MD_FIELD_ELE_SIZE(_field_id) !=    \
                        sizeof(*_valptr));              \
        __read_sys_metadata_field(_field_id, _valptr);  \
})

Does this look good to you?




[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