Xen CPUID

CPUID Overridden for Xen Hypervisor

cpuid boot options definition

  • Xen hypervisor command line parameters are defined in:

    xen-unstable/xen/arch/x86/cpu/intel.c:integer_param("cpuid_mask_ecx", opt_cpuid_mask_ecx);
    xen-unstable/xen/arch/x86/cpu/intel.c:integer_param("cpuid_mask_edx", opt_cpuid_mask_edx);
    xen-unstable/xen/arch/x86/cpu/amd.c:string_param("cpuid_mask_cpu", opt_famrev);
    xen-unstable/xen/arch/x86/cpu/amd.c:integer_param("cpuid_mask_ecx", opt_cpuid_mask_ecx);
    xen-unstable/xen/arch/x86/cpu/amd.c:integer_param("cpuid_mask_edx", opt_cpuid_mask_edx);
    xen-unstable/xen/arch/x86/cpu/amd.c:integer_param("cpuid_mask_ext_ecx", opt_cpuid_mask_ext_ecx);
    xen-unstable/xen/arch/x86/cpu/amd.c:integer_param("cpuid_mask_ext_edx", opt_cpuid_mask_ext_edx);

Intel cpu

  • For example, E8400 (Intel Core 2 Duo Processor series):

    ecx = 0x0008E3FD
    edx = 0xBFEBFBFF

    when executing CPUID.EAX = 1 normally. If you want to rev down to E8400, you can set these values in these Xen boot parameters:

    cpuid_mask_ecx=0x0008E3FD cpuid_mask_edx=0xBFEBFBFF

AMD cpu

  • There are some pre-canned values for overriding the CPUID features and extended features masks:

    fam_0f_rev_c
    fam_0f_rev_d
    fam_0f_rev_e
    fam_0f_rev_f
    fam_0f_rev_g
    fam_10_rev_b
    fam_10_rev_c
    fam_11_rev_b
  • The details of each cpu family is defined by:

    } else if (!strcmp(opt_famrev, "fam_0f_rev_c")) {
            feat_ecx = AMD_FEATURES_K8_REV_C_ECX;
            feat_edx = AMD_FEATURES_K8_REV_C_EDX;
            extfeat_ecx = AMD_EXTFEATURES_K8_REV_C_ECX;
            extfeat_edx = AMD_EXTFEATURES_K8_REV_C_EDX;
    } else if (!strcmp(opt_famrev, "fam_0f_rev_d")) {
            feat_ecx = AMD_FEATURES_K8_REV_D_ECX;
            feat_edx = AMD_FEATURES_K8_REV_D_EDX;
            extfeat_ecx = AMD_EXTFEATURES_K8_REV_D_ECX;
            extfeat_edx = AMD_EXTFEATURES_K8_REV_D_EDX;
    } else if (!strcmp(opt_famrev, "fam_0f_rev_e")) {
            feat_ecx = AMD_FEATURES_K8_REV_E_ECX;
            feat_edx = AMD_FEATURES_K8_REV_E_EDX;
            extfeat_ecx = AMD_EXTFEATURES_K8_REV_E_ECX;
            extfeat_edx = AMD_EXTFEATURES_K8_REV_E_EDX;
    } else if (!strcmp(opt_famrev, "fam_0f_rev_f")) {
            feat_ecx = AMD_FEATURES_K8_REV_F_ECX;
            feat_edx = AMD_FEATURES_K8_REV_F_EDX;
            extfeat_ecx = AMD_EXTFEATURES_K8_REV_F_ECX;
            extfeat_edx = AMD_EXTFEATURES_K8_REV_F_EDX;
    } else if (!strcmp(opt_famrev, "fam_0f_rev_g")) {
            feat_ecx = AMD_FEATURES_K8_REV_G_ECX;
            feat_edx = AMD_FEATURES_K8_REV_G_EDX;
            extfeat_ecx = AMD_EXTFEATURES_K8_REV_G_ECX;
            extfeat_edx = AMD_EXTFEATURES_K8_REV_G_EDX;
    } else if (!strcmp(opt_famrev, "fam_10_rev_b")) {
            feat_ecx = AMD_FEATURES_FAM10h_REV_B_ECX;
            feat_edx = AMD_FEATURES_FAM10h_REV_B_EDX;
            extfeat_ecx = AMD_EXTFEATURES_FAM10h_REV_B_ECX;
            extfeat_edx = AMD_EXTFEATURES_FAM10h_REV_B_EDX;
    } else if (!strcmp(opt_famrev, "fam_10_rev_c")) {
            feat_ecx = AMD_FEATURES_FAM10h_REV_C_ECX;
            feat_edx = AMD_FEATURES_FAM10h_REV_C_EDX;
            extfeat_ecx = AMD_EXTFEATURES_FAM10h_REV_C_ECX;
            extfeat_edx = AMD_EXTFEATURES_FAM10h_REV_C_EDX;
    } else if (!strcmp(opt_famrev, "fam_11_rev_b")) {
            feat_ecx = AMD_FEATURES_FAM11h_REV_B_ECX;
            feat_edx = AMD_FEATURES_FAM11h_REV_B_EDX;
            extfeat_ecx = AMD_EXTFEATURES_FAM11h_REV_B_ECX;
            extfeat_edx = AMD_EXTFEATURES_FAM11h_REV_B_EDX;
  • The detail of each value is defined in xen-unstable/xen/arch/x86/cpu/amd.h.

  • You can pass these hypervisor boot parameters in grub.conf. Each pair is equal to each other:

    cpuid_mask_cpu=fam_0f_rev_c
    cpuid_mask_ecx=0x0 cpuid_mask_edx=0x78BFBFF cpuid_mask_ext_ecx=0x0 cpuid_mask_ext_edx=0x0
    
    cpuid_mask_cpu=fam_0f_rev_d
    cpuid_mask_ecx=0x0 cpuid_mask_edx=0x78BFBFF cpuid_mask_ext_ecx=0x1 cpuid_mask_ext_edx=0x1
    
    cpuid_mask_cpu=fam_0f_rev_e
    cpuid_mask_ecx=0x1 cpuid_mask_edx=0x178BFBFF cpuid_mask_ext_ecx=0x3 cpuid_mask_ext_edx=0x3
    
    cpuid_mask_cpu=fam_0f_rev_f
    cpuid_mask_ecx=0x2001 cpuid_mask_edx=0x178BFBFF cpuid_mask_ext_ecx=0x1F cpuid_mask_ext_edx=0x1F
    
    cpuid_mask_cpu=fam_0f_rev_g
    cpuid_mask_ecx=0x2001 cpuid_mask_edx=0x178BFBFF cpuid_mask_ext_ecx=0x11F cpuid_mask_ext_edx=0x11F
    
    cpuid_mask_cpu=fam_10_rev_b
    cpuid_mask_ecx=0x802009 cpuid_mask_edx=0x178BFBFF cpuid_mask_ext_ecx=0x6FF cpuid_mask_ext_edx=0x6FF
    
    cpuid_mask_cpu=fam_10_rev_c
    cpuid_mask_ecx=0x802009 cpuid_mask_edx=0x178BFBFF cpuid_mask_ext_ecx=0x36FF cpuid_mask_ext_edx=0x36FF
    
    cpuid_mask_cpu=fam_11_rev_b
    cpuid_mask_ecx=0x2001 cpuid_mask_edx=0x178BFBFF cpuid_mask_ext_ecx=0x111F cpuid_mask_ext_edx=0x111F

CPUID Overridden for Xen Guests

  • xen-unstable/tools/examples/xmexample.hvm:

    #-----------------------------------------------------------------------------
    #   Configure guest CPUID responses:
    #
    #cpuid=[ '1:ecx=xxxxxxxxxxx00xxxxxxxxxxxxxxxxxxx,
    #           eax=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ]
    # - Unset the SSE4 features (CPUID.1[ECX][20-19])
    # - Default behaviour for all other bits in ECX And EAX registers.
    #
    # Each successive character represent a lesser-significant bit:
    #  '1' -> force the corresponding bit to 1
    #  '0' -> force to 0
    #  'x' -> Get a safe value (pass through and mask with the default policy)
    #  'k' -> pass through the host bit value
    #  's' -> as 'k' but preserve across save/restore and migration
    #
    #   Expose to the guest multi-core cpu instead of multiple processors
    # Example for intel, expose a 8-core processor :
    #cpuid=['1:edx=xxx1xxxxxxxxxxxxxxxxxxxxxxxxxxxx,
    #          ebx=xxxxxxxx00010000xxxxxxxxxxxxxxxx',
    #     '4,0:eax=001111xxxxxxxxxxxxxxxxxxxxxxxxxx']
    #  - CPUID.1[EDX][HT] : Enable HT
    #  - CPUID.1[EBX] : Number of vcpus * 2
    #  - CPUID.4,0[EAX] : Number of vcpus * 2 - 1
    #vcpus=8
    #
    # Example for amd, expose a 5-core processor :
    # cpuid = ['1:ebx=xxxxxxxx00001010xxxxxxxxxxxxxxxx,
    #             edx=xxx1xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    # '0x80000001:ecx=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1x',
    # '0x80000008:ecx=xxxxxxxxxxxxxxxxxxxxxxxxxx001001']
    #   - CPUID.1[EBX] : Threads per Core * Cores per Socket (2 * #vcpus)
    #   - CPUID.1[EDX][HT] : Enable HT
    #   - CPUID.0x80000001[CmpLegacy] : Use legacy method
    #   - CPUID.0x80000008[ECX] : #vcpus * 2 - 1
    #vcpus=5
    #
    #  Downgrade the cpuid to make a better compatibility for migration :
    # Look like a generic 686 :
    # cpuid = [ '0:eax=0x3,ebx=0x0,ecx=0x0,edx=0x0',
    #           '1:eax=0x06b1,
    #              ecx=xxxxxxxxxx0000xx00xxx0000000xx0,
    #              edx=xx00000xxxxxxx0xxxxxxxxx0xxxxxx',
    #           '4:eax=0x3,ebx=0x0,ecx=0x0,edx=0x0',
    #  '0x80000000:eax=0x3,ebx=0x0,ecx=0x0,edx=0x0']
    #  with the highest leaf
    #  - CPUID.0[EAX] : Set the highest leaf
    #  - CPUID.1[EAX] : 686
    #  - CPUID.1[ECX] : Mask some features
    #  - CPUID.1[EDX] : Mask some features
    #  - CPUID.4 : Reply like the highest leaf, in our case CPUID.3
    #  - CPUID.0x80000000 : No extension we are on a Pentium III, reply like the
    #  highest leaf (CPUID.3).
    #
    #   Configure host CPUID consistency checks, which must be satisfied for this
    #   VM to be allowed to run on this host's processor type:
    #cpuid_check=[ '1:ecx=xxxxxxxxxxxxxxxxxxxxxxxxxx1xxxxx' ]
    # - Host must have VMX feature flag set
    #
    # The format is similar to the above for 'cpuid':
    #  '1' -> the bit must be '1'
    #  '0' -> the bit must be '0'
    #  'x' -> we don't care (do not check)
    #  's' -> the bit must be the same as on the host that started this VM

None: XenCPUID (last edited 2009-10-13 03:27:59 by ZhigangWang)