diff mbox series

[v14,4/6] cpus: Add new function topology_supports_topoext

Message ID 1528939107-17193-5-git-send-email-babu.moger@amd.com
State New
Headers show
Series i386: Enable TOPOEXT to support hyperthreading on AMD CPU | expand

Commit Message

Moger, Babu June 14, 2018, 1:18 a.m. UTC
Add new function topology_supports_topoext to verify
if we can support topoext feature. Will be used to enable/disable
topoext feature.

Signed-off-by: Babu Moger <babu.moger@amd.com>
---
 accel/tcg/user-exec-stub.c |  5 +++++
 cpus.c                     | 13 +++++++++++++
 include/qom/cpu.h          |  9 +++++++++
 3 files changed, 27 insertions(+)

Comments

Eduardo Habkost June 14, 2018, 6:42 p.m. UTC | #1
On Wed, Jun 13, 2018 at 09:18:25PM -0400, Babu Moger wrote:
> Add new function topology_supports_topoext to verify
> if we can support topoext feature. Will be used to enable/disable
> topoext feature.
> 
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> ---
>  accel/tcg/user-exec-stub.c |  5 +++++
>  cpus.c                     | 13 +++++++++++++
>  include/qom/cpu.h          |  9 +++++++++
>  3 files changed, 27 insertions(+)
> 

x86-specific code doesn't belong to arch-independent code.  Why
not keep it in target/i386/cpu.c like before?
diff mbox series

Patch

diff --git a/accel/tcg/user-exec-stub.c b/accel/tcg/user-exec-stub.c
index dbcf1ad..715818a 100644
--- a/accel/tcg/user-exec-stub.c
+++ b/accel/tcg/user-exec-stub.c
@@ -11,6 +11,11 @@  void qemu_init_vcpu(CPUState *cpu)
 {
 }
 
+int topology_supports_topoext(int max_cores, int max_threads)
+{
+    return true;
+}
+
 /* User mode emulation does not support record/replay yet.  */
 
 bool replay_exception(void)
diff --git a/cpus.c b/cpus.c
index d1f1629..17f6f4c 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1979,6 +1979,19 @@  static void qemu_dummy_start_vcpu(CPUState *cpu)
                        QEMU_THREAD_JOINABLE);
 }
 
+/*
+ * Check if we can support topoext feature with this topology
+ * Fail if number of cores are beyond the supported cores
+ * or number of threads are more than supported threads
+ */
+int topology_supports_topoext(int max_cores, int max_threads)
+{
+    if ((smp_cores > max_cores) || (smp_threads > max_threads)) {
+        return false;
+    }
+    return true;
+}
+
 void qemu_init_vcpu(CPUState *cpu)
 {
     cpu->nr_cores = smp_cores;
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 9d3afc6..4ac4d49 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -1004,6 +1004,15 @@  void end_exclusive(void);
  */
 void qemu_init_vcpu(CPUState *cpu);
 
+/**
+ * topology_supports_topoext:
+ * @max_cores: Max cores topoext feature can support
+ * @max_threads: Max threads topoext feature can support
+ *
+ * Return true if topology can be supported else return false
+ */
+int topology_supports_topoext(int max_cores, int max_threads);
+
 #define SSTEP_ENABLE  0x1  /* Enable simulated HW single stepping */
 #define SSTEP_NOIRQ   0x2  /* Do not use IRQ while single stepping */
 #define SSTEP_NOTIMER 0x4  /* Do not Timers while single stepping */