[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v13 4/5] i386: Verify and enable topoext feature
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [PATCH v13 4/5] i386: Verify and enable topoext feature if supported |
Date: |
Mon, 11 Jun 2018 17:51:59 -0300 |
User-agent: |
Mutt/1.9.2 (2017-12-15) |
On Fri, Jun 08, 2018 at 06:56:20PM -0400, Babu Moger wrote:
> If the CPU model supports topoext feature, enabled the
> feature automatically if it can be supported.
>
> Signed-off-by: Babu Moger <address@hidden>
> ---
> target/i386/cpu.c | 40 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index 4dd9a82..88bc73d 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -4763,6 +4763,33 @@ static int x86_cpu_filter_features(X86CPU *cpu)
> #define IS_AMD_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_AMD_1 && \
> (env)->cpuid_vendor2 == CPUID_VENDOR_AMD_2 && \
> (env)->cpuid_vendor3 == CPUID_VENDOR_AMD_3)
> +/*
> + * Check if we can support this topology
> + * Fail if number of cores are beyond the supported config
> + * or nr_threads is more than 2
> + */
> +static int topology_supports_topoext(int nr_cores, int nr_threads,
> + Error **errp)
> +{
> + if (nr_cores > (MAX_CORES_IN_NODE * MAX_NODES_PER_SOCKET)) {
> + error_setg(errp, "TOPOEXT unsupported with %d cores per socket",
> + nr_cores);
> + error_append_hint(errp, "TOPOEXT supports only up to %d cores per"
> + " socket\n",
> + (MAX_CORES_IN_NODE * MAX_NODES_PER_SOCKET));
> + return false;
> + }
> +
> + if (nr_threads > 2) {
> + error_setg(errp, "TOPOEXT unsupported with %d threads per core",
> + nr_threads);
> + error_append_hint(errp, "TOPOEXT supports only up to 2 threads"
> + " per core\n");
> + return false;
> + }
> + return true;
> +}
> +
> static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
> {
> CPUState *cs = CPU(dev);
> @@ -4953,6 +4980,19 @@ static void x86_cpu_realizefn(DeviceState *dev, Error
> **errp)
>
> qemu_init_vcpu(cs);
>
> + if (cpu->auto_topoext &&
> + !(env->user_features[FEAT_8000_0001_ECX] & CPUID_EXT3_TOPOEXT)) {
> + if (cs->nr_cores <= (MAX_CORES_IN_NODE * MAX_NODES_PER_SOCKET) &&
> + (cs->nr_threads <= 2)) {
This duplicates the logic from topology_supports_topoext(). Why
not just call
topology_supports_topoext(cs->nr_cores, cs->nr_threads, NULL)
here?
> + env->features[FEAT_8000_0001_ECX] |= CPUID_EXT3_TOPOEXT;
> + }
> + }
> +
> + if ((env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_TOPOEXT) &&
> + !topology_supports_topoext(cs->nr_cores, cs->nr_threads, errp)) {
> + return;
> + }
> +
> /* Only Intel CPUs support hyperthreading. Even though QEMU fixes this
> * issue by adjusting CPUID_0000_0001_EBX and CPUID_8000_0008_ECX
> * based on inputs (sockets,cores,threads), it is still better to gives
> --
> 1.8.3.1
>
--
Eduardo
- Re: [Qemu-devel] [PATCH v13 2/5] i386: Introduce auto_topoext bit to manage topoext, (continued)
[Qemu-devel] [PATCH v13 1/5] i386: Add support for CPUID_8000_001E for AMD, Babu Moger, 2018/06/08
[Qemu-devel] [PATCH v13 3/5] i386: Enable TOPOEXT feature on AMD EPYC CPU, Babu Moger, 2018/06/08
[Qemu-devel] [PATCH v13 4/5] i386: Verify and enable topoext feature if supported, Babu Moger, 2018/06/08
- Re: [Qemu-devel] [PATCH v13 4/5] i386: Verify and enable topoext feature if supported,
Eduardo Habkost <=
[Qemu-devel] [PATCH v13 5/5] i386: Remove generic SMT thread check, Babu Moger, 2018/06/08