Re: [PATCH v4 22/26] KVM: SVM: Use BIT() and GENMASK() for definitions in svm.h

From: Sean Christopherson

Date: Thu Feb 05 2026 - 20:37:29 EST


On Thu, Jan 15, 2026, Yosry Ahmed wrote:
> Use BIT() and GENMASK() (and *_ULL() variants) to define the bitmasks in
> svm.h.

Oh, hey, just what I was talking about. But why is this buried as patch 22/26?
AFAICT, it's got nothing to do with the rest of the series.

> Opportunistically switch the definitions of AVIC_ENABLE_{SHIFT/MASK}
> and X2APIC_MODE_{SHIFT/MASK}, as well as SVM_EVTINJ_VALID and
> SVM_EVTINJ_VALID_ERR, such that the bitmasks are defined in the correct
> order.
>
> No functional change intended.
>
> Signed-off-by: Yosry Ahmed <yosry.ahmed@xxxxxxxxx>
> ---
> arch/x86/include/asm/svm.h | 78 +++++++++++++++++++-------------------
> 1 file changed, 39 insertions(+), 39 deletions(-)
>
> diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h
> index 770c7aed5fa5..0bc26b2b3fd7 100644
> --- a/arch/x86/include/asm/svm.h
> +++ b/arch/x86/include/asm/svm.h
> @@ -189,39 +189,39 @@ struct __attribute__ ((__packed__)) vmcb_control_area {
> #define V_TPR_MASK 0x0f
>
> #define V_IRQ_SHIFT 8
> -#define V_IRQ_MASK (1 << V_IRQ_SHIFT)
> +#define V_IRQ_MASK BIT(V_IRQ_SHIFT)

I vote (and if anyone disagrees, their vote doesn't count) to purge the _SHIFT
and _MASK crud. There is zero reason to define the shifts.

And then when we rename, I would like to try and find better names, e.g. maybe
things like V_GIF and V_ENABLE_GIF_VIRTUALIZATION?

Anyways, that's partly why I asked why this patch is here. If we're changing
things, then I'd like to do some cleanup. But this series is already a chonker,
so I'd much prefer to do any cleanup in a separate series.