Re: [PATCH v2 2/2] x86/cpu/intel: Clean-up TME code

From: Ingo Molnar
Date: Thu Sep 28 2023 - 16:56:06 EST



* Compostella, Jeremy <jeremy.compostella@xxxxxxxxx> wrote:

> -/* Values for mktme_status (SW only construct) */
> -#define MKTME_ENABLED 0
> -#define MKTME_DISABLED 1
> -#define MKTME_UNINITIALIZED 2
> -static int mktme_status = MKTME_UNINITIALIZED;
> -
> static void detect_tme(struct cpuinfo_x86 *c)
> {
> u64 tme_activate, tme_policy, tme_crypto_algs;
> int keyid_bits = 0, nr_keyids = 0;
> static u64 tme_activate_cpu0 = 0;
> + static enum {
> + MKTME_ENABLED,
> + MKTME_DISABLED,
> + MKTME_UNINITIALIZED
> + } mktme_status = MKTME_UNINITIALIZED;

Please don't move the new enum inside the function, even if
that's the only place it's used.

We almost always keep constant definitions outside function scope.

We also try to avoid static variables inside functions.

Thanks,

Ingo