Skip to contentSkip to conversation

x86/cpu: Add supports for zhaoxin x86 platform

PATCH Superseded Davidwang 2 participants 4 messages May 3, 2018 – May 4, 2018

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Davidwang

author
#0 lore raw

PATCH v3 1/1 x86/cpu: Add supports for zhaoxin x86 platform

From: DavidWang <[email protected]>

Zhaoxin is a x86 IC designer. Its SOC products support both CPU virtualization and I/O virtualization, which are compatible with Intel VMX and VT-d respectively. Zhaoxin has 'Shanghai' CPU vendor ID.

---
 xen/arch/x86/cpu/Makefile          |  1 +
 xen/arch/x86/cpu/common.c          |  1 +
 xen/arch/x86/cpu/intel_cacheinfo.c |  4 +++-
 xen/arch/x86/cpu/shanghai.c        | 30 ++++++++++++++++++++++++++++++
 xen/include/asm-x86/setup.h        |  1 +
 xen/include/asm-x86/x86-vendors.h  |  3 ++-
 6 files changed, 38 insertions(+), 2 deletions(-)
 create mode 100644 xen/arch/x86/cpu/shanghai.c
xen/arch/x86/cpu/Makefile +1 -0
index 74f23ae..34a01ca 100644
@@ -7,4 +7,5 @@ obj-y += common.o
 obj-y += intel.o
 obj-y += intel_cacheinfo.o
 obj-y += mwait-idle.o
+obj-y += shanghai.o
 obj-y += vpmu.o vpmu_amd.o vpmu_intel.o
xen/arch/x86/cpu/common.c +1 -0
index 0a452ae..02863c9 100644
@@ -709,6 +709,7 @@ void __init early_cpu_init(void)
 	intel_cpu_init();
 	amd_init_cpu();
 	centaur_init_cpu();
+	shanghai_init_cpu();
 	early_cpu_detect();
 }
 
xen/arch/x86/cpu/intel_cacheinfo.c +3 -1
index 101e297..5f92254 100644
@@ -176,7 +176,9 @@ unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c)
 	 * Don't use cpuid2 if cpuid4 is supported. For P4, we use cpuid2 for
 	 * trace cache
 	 */
-	if ((num_cache_leaves == 0 || c->x86 == 15) && c->cpuid_level > 1) {
+	if ( (num_cache_leaves == 0 || c->x86 == 15) && c->cpuid_level > 1 &&
+         c->x86_vendor != X86_VENDOR_SHANGHAI )
+	{
 		/* supports eax=2  call */
 		int i, j, n;
 		int regs[4];
xen/arch/x86/cpu/shanghai.c new file +30 -0
new file mode 100644
index 0000000..4f424ed
@@ -0,0 +1,30 @@
+#include <xen/bitops.h>
+#include <xen/init.h>
+#include <asm/processor.h>
+#include "cpu.h"
+
+static void init_shanghai(struct cpuinfo_x86 *c)
+{
+    unsigned int l2 = 0;
+
+    if ( cpu_has(c, X86_FEATURE_ITSC) )
+    {
+        __set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
+        __set_bit(X86_FEATURE_NONSTOP_TSC, c->x86_capability);
+        __set_bit(X86_FEATURE_TSC_RELIABLE, c->x86_capability);
+    }
+
+    l2 = init_intel_cacheinfo(c);
+}
+
+static const struct cpu_dev shanghai_cpu_dev = {
+    .c_vendor   = "  Shang",
+    .c_ident    = {"  Shanghai  "},
+    .c_init     = init_shanghai,
+};
+
+int __init shanghai_init_cpu(void)
+{
+    cpu_devs[X86_VENDOR_SHANGHAI] = &shanghai_cpu_dev;
+    return 0;
+}
xen/include/asm-x86/setup.h +1 -0
index 19232af..2c2d9fd 100644
@@ -23,6 +23,7 @@ int cyrix_init_cpu(void);
 int nsc_init_cpu(void);
 int centaur_init_cpu(void);
 int transmeta_init_cpu(void);
+int shanghai_init_cpu(void);
 
 void set_nr_cpu_ids(unsigned int max_cpus);
 
xen/include/asm-x86/x86-vendors.h +2 -1
index cae5507..c53d0b9 100644
@@ -7,7 +7,8 @@
 #define X86_VENDOR_INTEL 0
 #define X86_VENDOR_AMD 1
 #define X86_VENDOR_CENTAUR 2
-#define X86_VENDOR_NUM 3
+#define X86_VENDOR_SHANGHAI 3
+#define X86_VENDOR_NUM 4
 #define X86_VENDOR_UNKNOWN 0xff
 
 #endif	/* __XEN_X86_VENDORS_H__ */
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 03.05.18 at 06:43, <[email protected]> wrote:

From: DavidWang <[email protected]>

Zhaoxin is a x86 IC designer. Its SOC products support both CPU virtualization and I/O virtualization, which are compatible with Intel VMX and VT-d respectively. Zhaoxin has 'Shanghai' CPU vendor ID.

---

Please have a brief list of changes from the previous version here.

xen/arch/x86/cpu/intel_cacheinfo.c unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c) · line 181

Quoted 10 lines
xen/arch/x86/cpu/intel_cacheinfo.c +3 -1
@@ -176,7 +176,9 @@ unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c)
 	 * Don't use cpuid2 if cpuid4 is supported. For P4, we use cpuid2 for
 	 * trace cache
 	 */
-	if ((num_cache_leaves == 0 || c->x86 == 15) && c->cpuid_level > 1) {
+	if ( (num_cache_leaves == 0 || c->x86 == 15) && c->cpuid_level > 1 &&
+         c->x86_vendor != X86_VENDOR_SHANGHAI )
+	{

There's again a mixup of indentation styles here.

xen/arch/x86/cpu/shanghai.c line 8

Quoted 11 lines
xen/arch/x86/cpu/shanghai.c new file +8 -0
@@ -0,0 +1,30 @@
+#include <xen/bitops.h>
+#include <xen/init.h>
+#include <asm/processor.h>
+#include "cpu.h"
+
+static void init_shanghai(struct cpuinfo_x86 *c)
+{
+    unsigned int l2 = 0;

What use is this local variable, considering ...

xen/arch/x86/cpu/shanghai.c line 18

Quoted 9 lines
xen/arch/x86/cpu/shanghai.c new file +9 -0
+    if ( cpu_has(c, X86_FEATURE_ITSC) )
+    {
+        __set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
+        __set_bit(X86_FEATURE_NONSTOP_TSC, c->x86_capability);
+        __set_bit(X86_FEATURE_TSC_RELIABLE, c->x86_capability);
+    }
+
+    l2 = init_intel_cacheinfo(c);
+}

... this is its only use?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#2 lore raw

________________________________________
发件人: Jan Beulich <[email protected]>
发送时间: 2018年5月3日 23:09
收件人: David Wang
抄送: xen-devel; Fiona Li(BJ-RD)
主题: Re: [PATCH v3] x86/cpu: Add supports for zhaoxin x86 platform

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 03.05.18 at 06:43, <[email protected]> wrote:

From: DavidWang <[email protected]>

Zhaoxin is a x86 IC designer. Its SOC products support both CPU virtualization and I/O virtualization, which are compatible with Intel VMX and VT-d respectively. Zhaoxin has 'Shanghai' CPU vendor ID.

---

Please have a brief list of changes from the previous version here. OK, thank you.

xen/arch/x86/cpu/intel_cacheinfo.c unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c) · line 181

Quoted 10 lines
xen/arch/x86/cpu/intel_cacheinfo.c +3 -1
@@ -176,7 +176,9 @@ unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c)
       * Don't use cpuid2 if cpuid4 is supported. For P4, we use cpuid2 for
       * trace cache
       */
-     if ((num_cache_leaves == 0 || c->x86 == 15) && c->cpuid_level > 1) {
+     if ( (num_cache_leaves == 0 || c->x86 == 15) && c->cpuid_level > 1 &&
+         c->x86_vendor != X86_VENDOR_SHANGHAI )
+     {

There's again a mixup of indentation styles here.

xen/arch/x86/cpu/shanghai.c line 8

Quoted 11 lines
xen/arch/x86/cpu/shanghai.c new file +8 -0
@@ -0,0 +1,30 @@
+#include <xen/bitops.h>
+#include <xen/init.h>
+#include <asm/processor.h>
+#include "cpu.h"
+
+static void init_shanghai(struct cpuinfo_x86 *c)
+{
+    unsigned int l2 = 0;

What use is this local variable, considering ...

xen/arch/x86/cpu/shanghai.c line 18

Quoted 9 lines
xen/arch/x86/cpu/shanghai.c new file +9 -0
+    if ( cpu_has(c, X86_FEATURE_ITSC) )
+    {
+        __set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
+        __set_bit(X86_FEATURE_NONSTOP_TSC, c->x86_capability);
+        __set_bit(X86_FEATURE_TSC_RELIABLE, c->x86_capability);
+    }
+
+    l2 = init_intel_cacheinfo(c);
+}

... this is its only use?
Yes, it Only be used to save the return value. I think it is unnecessary but calls of init_intel_cacheinfo() (in init_intel()) make me confused. Can i delete it in patch v4? David

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 04.05.18 at 04:54, <[email protected]> wrote:

发件人: Jan Beulich <[email protected]>
发送时间: 2018年5月3日 23:09

xen/arch/x86/cpu/shanghai.c line 18

Quoted 9 lines
xen/arch/x86/cpu/shanghai.c new file +9 -0
+    if ( cpu_has(c, X86_FEATURE_ITSC) )
+    {
+        __set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
+        __set_bit(X86_FEATURE_NONSTOP_TSC, c->x86_capability);
+        __set_bit(X86_FEATURE_TSC_RELIABLE, c->x86_capability);
+    }
+
+    l2 = init_intel_cacheinfo(c);
+}

... this is its only use?
Yes, it Only be used to save the return value. I think it is unnecessary but calls of init_intel_cacheinfo() (in init_intel()) make me confused. Can i delete it in patch v4?

If you don't need the value, you should (not just "can") remove the variable.

Also, I think I had mentioned this before: Please adjust your quoting style when replying to mails.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel