[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] xc_cpuid_x86.c: No need to mask NX twice
On Mon, Sep 8, 2014 at 2:59 PM, Jan Beulich <JBeulich@xxxxxxxx> wrote:
 Hi, Jan Thanks. Yes, and I did some changes as below. Please correct me if I did some improper ones. diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c index 9add109..7d79dc2 100644 --- a/tools/libxc/xc_cpuid_x86.c +++ b/tools/libxc/xc_cpuid_x86.c @@ -80,7 +80,7 @@ static void xc_cpuid_brand_get(char *str) Âstatic void amd_xc_cpuid_policy(  xc_interface *xch, domid_t domid,  const unsigned int *input, unsigned int *regs, - int is_pae, int is_nestedhvm) + int is_64bit, int is_pae, int is_nestedhvm) Â{  switch ( input[0] )  { @@ -95,13 +95,11 @@ static void amd_xc_cpuid_policy(  break;  Â case 0x80000001: { - int is_64bit = hypervisor_is_64bit(xch) && is_pae; -  if ( !is_pae )  clear_bit(X86_FEATURE_PAE, regs[3]);  Â /* Filter all other features according to a whitelist. */ - regs[2] &= ((is_64bit ? bitmaskof(X86_FEATURE_LAHF_LM) : 0) | + regs[2] &= (bitmaskof(X86_FEATURE_LAHF_LM) |  bitmaskof(X86_FEATURE_CMP_LEGACY) |  (is_nestedhvm ? bitmaskof(X86_FEATURE_SVM) : 0) |  bitmaskof(X86_FEATURE_CR8_LEGACY) | @@ -117,7 +115,7 @@ static void amd_xc_cpuid_policy(  bitmaskof(X86_FEATURE_DBEXT));  regs[3] &= (0x0183f3ff | /* features shared with 0x00000001:EDX */  bitmaskof(X86_FEATURE_NX) | - (is_64bit ? bitmaskof(X86_FEATURE_LM) : 0) | + bitmaskof(X86_FEATURE_LM) |  bitmaskof(X86_FEATURE_SYSCALL) |  bitmaskof(X86_FEATURE_MP) |  bitmaskof(X86_FEATURE_MMXEXT) | @@ -169,7 +167,7 @@ static void amd_xc_cpuid_policy( Âstatic void intel_xc_cpuid_policy(  xc_interface *xch, domid_t domid,  const unsigned int *input, unsigned int *regs, - int is_pae, int is_nestedhvm) + int is_64bit, int is_pae, int is_nestedhvm) Â{  switch ( input[0] )  { @@ -195,14 +193,12 @@ static void intel_xc_cpuid_policy(  break;  Â case 0x80000001: { - int is_64bit = hypervisor_is_64bit(xch) && is_pae; -  /* Only a few features are advertised in Intel's 0x80000001. */ - regs[2] &= (is_64bit ? bitmaskof(X86_FEATURE_LAHF_LM) : 0) | - bitmaskof(X86_FEATURE_3DNOWPREFETCH) | - bitmaskof(X86_FEATURE_ABM); + regs[2] &= (bitmaskof(X86_FEATURE_LAHF_LM) | + bitmaskof(X86_FEATURE_3DNOWPREFETCH) | + bitmaskof(X86_FEATURE_ABM);  regs[3] &= (bitmaskof(X86_FEATURE_NX) | - (is_64bit ? bitmaskof(X86_FEATURE_LM) : 0) | + bitmaskof(X86_FEATURE_LM) |  (is_64bit ? bitmaskof(X86_FEATURE_SYSCALL) : 0) |  (is_64bit ? bitmaskof(X86_FEATURE_RDTSCP) : 0));  break; @@ -278,12 +274,14 @@ static void xc_cpuid_hvm_policy(  DECLARE_DOMCTL;  char brand[13];  uint64_t val; - int is_pae, is_nestedhvm; + int is_64bit, is_pae, is_nestedhvm;  uint64_t xfeature_mask;  Â xc_hvm_param_get(xch, domid, HVM_PARAM_PAE_ENABLED, &val);  is_pae = !!val; - + + is_64bit = hypervisor_is_64bit(xch) && is_pae; + Â /* Detecting Xen's atitude towards XSAVE */  memset(&domctl, 0, sizeof(domctl));  domctl.cmd = XEN_DOMCTL_getvcpuextstate; @@ -391,10 +389,18 @@ static void xc_cpuid_hvm_policy(  break;  Â case 0x80000001: - if ( !is_pae ) { + if ( !is_64bit ) { + clear_bit(X86_FEATURE_LAHF_LM, regs[2]); + clear_bit(X86_FEATURE_LM, regs[3]); + clear_bit(X86_FEATURE_NX, regs[3]); + clear_bit(X86_FEATURE_PSE36, regs[3]); + } else if ( !is_pae ) {  clear_bit(X86_FEATURE_NX, regs[3]);  clear_bit(X86_FEATURE_PSE36, regs[3]); + } else { + /* Do nothing for 32-bit guest */  } +  break;  Â case 0x80000007: @@ -430,10 +436,11 @@ static void xc_cpuid_hvm_policy(  Â xc_cpuid_brand_get(brand);  if ( strstr(brand, "AMD") ) - amd_xc_cpuid_policy(xch, domid, input, regs, is_pae, is_nestedhvm); + amd_xc_cpuid_policy(xch, domid, input, regs, + is_64bit, is_pae, is_nestedhvm);  else - intel_xc_cpuid_policy(xch, domid, input, regs, is_pae, is_nestedhvm); - + intel_xc_cpuid_policy(xch, domid, input, regs, + is_64bit, is_pae, is_nestedhvm); Â
I am not so sure for now, but I will check it later as well:) Â
Zhuo _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |