tools/libxc: Add Hygon Dhyana support
authorPu Wen <puwen@hygon.cn>
Thu, 4 Apr 2019 13:48:13 +0000 (21:48 +0800)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 6 Jun 2019 14:28:21 +0000 (15:28 +0100)
Add Hygon Dhyana support to caculate the cpuid policies for creating PV
or HVM guest by using the code path of AMD.

Signed-off-by: Pu Wen <puwen@hygon.cn>
Acked-by: Wei Liu <wei.liu2@citrix.com>
[Rebase over 0cd074144cb "x86/cpu: Renumber X86_VENDOR_* to form a bitmap"]
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/libxc/xc_cpuid_x86.c

index 71e1ee7544636924217c03d472b4653c83445c1e..b82933608289f8cdbb54d8585a6e41274819866a 100644 (file)
@@ -556,7 +556,7 @@ static void xc_cpuid_hvm_policy(const struct cpuid_domain_info *info,
         break;
     }
 
-    if ( info->vendor == X86_VENDOR_AMD )
+    if ( info->vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON) )
         amd_xc_cpuid_policy(info, input, regs);
     else
         intel_xc_cpuid_policy(info, input, regs);
@@ -618,7 +618,7 @@ static void xc_cpuid_pv_policy(const struct cpuid_domain_info *info,
 
     case 0x80000000:
     {
-        unsigned int max = info->vendor == X86_VENDOR_AMD
+        unsigned int max = (info->vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON))
             ? DEF_MAX_AMDEXT : DEF_MAX_INTELEXT;
 
         if ( regs[0] > max )
@@ -724,7 +724,7 @@ static void sanitise_featureset(struct cpuid_domain_info *info)
         if ( !info->pv64 )
         {
             clear_bit(X86_FEATURE_LM, info->featureset);
-            if ( info->vendor != X86_VENDOR_AMD )
+            if ( !(info->vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
                 clear_bit(X86_FEATURE_SYSCALL, info->featureset);
         }
 
@@ -775,7 +775,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid,
     input[0] = 0x80000000;
     cpuid(input, regs);
 
-    if ( info.vendor == X86_VENDOR_AMD )
+    if ( info.vendor == X86_VENDOR_AMD || info.vendor == X86_VENDOR_HYGON )
         ext_max = (regs[0] <= DEF_MAX_AMDEXT) ? regs[0] : DEF_MAX_AMDEXT;
     else
         ext_max = (regs[0] <= DEF_MAX_INTELEXT) ? regs[0] : DEF_MAX_INTELEXT;