[PATCH v3 2/4] target/i386: Add a _MAX sentinel to X86ASIdx enum

Gustavo Romero posted 4 patches 1 month, 2 weeks ago
Maintainers: Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>, David Hildenbrand <david@kernel.org>, Peter Maydell <peter.maydell@linaro.org>, Marcelo Tosatti <mtosatti@redhat.com>
There is a newer version of this series
[PATCH v3 2/4] target/i386: Add a _MAX sentinel to X86ASIdx enum
Posted by Gustavo Romero 1 month, 2 weeks ago
Add a sentinel to the X86ASIdx enum so it can be used when the total
number of address spaces is required.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
---
 target/i386/cpu.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index cee1f692a1..ba0c4fa548 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -2600,6 +2600,8 @@ void cpu_sync_avx_hflag(CPUX86State *env);
 typedef enum X86ASIdx {
     X86ASIdx_MEM = 0,
     X86ASIdx_SMM = 1,
+    X86ASIdx_MAX = X86ASIdx_SMM
+#define X86ASIdx_COUNT (X86ASIdx_MAX + 1)
 } X86ASIdx;
 
 #ifndef CONFIG_USER_ONLY
-- 
2.34.1
Re: [PATCH v3 2/4] target/i386: Add a _MAX sentinel to X86ASIdx enum
Posted by Richard Henderson 1 month ago
On 12/24/25 09:26, Gustavo Romero wrote:
> Add a sentinel to the X86ASIdx enum so it can be used when the total
> number of address spaces is required.
> 
> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
> ---
>   target/i386/cpu.h | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index cee1f692a1..ba0c4fa548 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -2600,6 +2600,8 @@ void cpu_sync_avx_hflag(CPUX86State *env);
>   typedef enum X86ASIdx {
>       X86ASIdx_MEM = 0,
>       X86ASIdx_SMM = 1,
> +    X86ASIdx_MAX = X86ASIdx_SMM
> +#define X86ASIdx_COUNT (X86ASIdx_MAX + 1)
>   } X86ASIdx;
>   
>   #ifndef CONFIG_USER_ONLY

But... it's _COUNT that matters, and that doesn't seem to get a mention.
I don't see the point in adding _MAX.


r~