On Tue, 2024-07-09 at 11:11 -0700, Sean Christopherson wrote: > On Thu, Jul 04, 2024, Maxim Levitsky wrote: > > On Fri, 2024-05-17 at 10:39 -0700, Sean Christopherson wrote: > > > +/* > > > + * For kernel-defined leafs, mask the boot CPU's pre-populated value. For KVM- > > > + * defined leafs, explicitly set the leaf, as KVM is the one and only authority. > > > + */ > > > +#define kvm_cpu_cap_init(leaf, mask) \ > > > +do { \ > > > + const struct cpuid_reg cpuid = x86_feature_cpuid(leaf * 32); \ > > > + const u32 __maybe_unused kvm_cpu_cap_init_in_progress = leaf; \ > > > > Why not to #define the kvm_cpu_cap_init_in_progress as well instead of a variable? > > Macros can't #define new macros. A macro could be used, but it would require the > caller to #define and #undef the macro, e.g. Oh, I somehow forgot about this, of course this is how C processor works. > #define kvm_cpu_cap_init_in_progress CPUID_1_ECX > kvm_cpu_cap_init(CPUID_1_ECX, ...) > #undef kvm_cpu_cap_init_in_progress > Yes, this is much uglier. > but, stating the obvious, that's ugly and is less robust than automatically > "defining" the in-progress leaf in kvm_cpu_cap_init(). > Best regards, Maxim Levitsky