From: "Jan Beulich" Subject: Re: [PATCH] xc_cpuid_x86.c: No need to mask NX twice Date: Mon, 08 Sep 2014 07:59:51 +0100 Message-ID: <540D70070200007800031D44@mail.emea.novell.com> References: <1409911893-18037-1-git-send-email-alfred.z.song@gmail.com> <5409AD6E0200007800031618@mail.emea.novell.com> <5409E07D020000780003182B@mail.emea.novell.com> <5409FC650200007800031931@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: z Cc: Ian Campbell , Stefano Stabellini , jinsong.liu@alibaba-inc.com, ian.jackson@eu.citrix.com, Zhuo Song , boyu.mt@alibaba-inc.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 05.09.14 at 18:35, wrote: > Got it. Thanks, Jan. > If so, I think we could remove the condition for masking NX in both vendor > specific functions, since the architectural logic has help cover it and the > judgement is unnecessary. For example: > > diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c > index 61af3e6..6bd89b0 100644 > --- a/tools/libxc/xc_cpuid_x86.c > +++ b/tools/libxc/xc_cpuid_x86.c > @@ -116,7 +116,7 @@ static void amd_xc_cpuid_policy( > bitmaskof(X86_FEATURE_TBM) | > bitmaskof(X86_FEATURE_DBEXT)); > regs[3] &= (0x0183f3ff | /* features shared with 0x00000001:EDX */ > - (is_pae ? bitmaskof(X86_FEATURE_NX) : 0) | > + bitmaskof(X86_FEATURE_NX) | > (is_64bit ? bitmaskof(X86_FEATURE_LM) : 0) | > bitmaskof(X86_FEATURE_SYSCALL) | > bitmaskof(X86_FEATURE_MP) | > @@ -201,7 +201,7 @@ static void intel_xc_cpuid_policy( > regs[2] &= (is_64bit ? bitmaskof(X86_FEATURE_LAHF_LM) : 0) | > bitmaskof(X86_FEATURE_3DNOWPREFETCH) | > bitmaskof(X86_FEATURE_ABM); > - regs[3] &= ((is_pae ? bitmaskof(X86_FEATURE_NX) : 0) | > + regs[3] &= (bitmaskof(X86_FEATURE_NX) | > (is_64bit ? bitmaskof(X86_FEATURE_LM) : 0) | > (is_64bit ? bitmaskof(X86_FEATURE_SYSCALL) : 0) | > (is_64bit ? bitmaskof(X86_FEATURE_RDTSCP) : 0)); Right, and I think you could go further and move at least the LM check into vendor-independent code too. Looking at the context above I also wonder whether tying RDTSCP to 64-bit guests is really correct in (at least) the Intel case. Jan