From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH v3 1/4] x86: move cached CR4 value to struct cpu_info Date: Thu, 17 Mar 2016 02:02:12 -0600 Message-ID: <56EA729402000078000DD92B@prv-mh.provo.novell.com> References: <56D97AC102000078000D9537@prv-mh.provo.novell.com> <56E14FF502000078000DB232@prv-mh.provo.novell.com> <56E9A0DB02000078000DD54C@prv-mh.provo.novell.com> <56EA6FDF02000078000DD8FB@prv-mh.provo.novell.com> <56EA6FDF02000078000DD8FB@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part24139594.2__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agSss-0004AR-GB for xen-devel@lists.xenproject.org; Thu, 17 Mar 2016 08:02:18 +0000 In-Reply-To: <56EA6FDF02000078000DD8FB@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: xen-devel Cc: Andrew Cooper , Keir Fraser , Feng Wu List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part24139594.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline This not only eases using the cached value in assembly code, but also improves the generated code resulting from such reads in C. Signed-off-by: Jan Beulich --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -64,7 +64,6 @@ #include =20 DEFINE_PER_CPU(struct vcpu *, curr_vcpu); -DEFINE_PER_CPU(unsigned long, cr4); =20 static void default_idle(void); void (*pm_idle) (void) __read_mostly =3D default_idle; --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -645,7 +645,7 @@ void __init noreturn __start_xen(unsigne parse_video_info(); =20 rdmsrl(MSR_EFER, this_cpu(efer)); - asm volatile ( "mov %%cr4,%0" : "=3Dr" (this_cpu(cr4)) ); + asm volatile ( "mov %%cr4,%0" : "=3Dr" (get_cpu_info()->cr4) ); =20 /* We initialise the serial devices very early so we can get = debugging. */ ns16550.io_base =3D 0x3f8; --- a/xen/include/asm-x86/current.h +++ b/xen/include/asm-x86/current.h @@ -41,8 +41,8 @@ struct cpu_info { unsigned int processor_id; struct vcpu *current_vcpu; unsigned long per_cpu_offset; + unsigned long cr4; /* get_stack_bottom() must be 16-byte aligned */ - unsigned long __pad_for_stack_bottom; }; =20 static inline struct cpu_info *get_cpu_info(void) --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -328,8 +328,6 @@ static inline unsigned long read_cr2(voi return cr2; } =20 -DECLARE_PER_CPU(unsigned long, cr4); - static inline void raw_write_cr4(unsigned long val) { asm volatile ( "mov %0,%%cr4" : : "r" (val) ); @@ -337,12 +335,12 @@ static inline void raw_write_cr4(unsigne =20 static inline unsigned long read_cr4(void) { - return this_cpu(cr4); + return get_cpu_info()->cr4; } =20 static inline void write_cr4(unsigned long val) { - this_cpu(cr4) =3D val; + get_cpu_info()->cr4 =3D val; raw_write_cr4(val); } =20 --=__Part24139594.2__= Content-Type: text/plain; name="x86-CR4-cpu_info.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-CR4-cpu_info.patch" x86: move cached CR4 value to struct cpu_info=0A=0AThis not only eases = using the cached value in assembly code, but also=0Aimproves the generated = code resulting from such reads in C.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/arch/x86/domain.c=0A+++ b/xen/arch/x86/d= omain.c=0A@@ -64,7 +64,6 @@=0A #include =0A =0A DEFINE_PER_CPU(s= truct vcpu *, curr_vcpu);=0A-DEFINE_PER_CPU(unsigned long, cr4);=0A =0A = static void default_idle(void);=0A void (*pm_idle) (void) __read_mostly = =3D default_idle;=0A--- a/xen/arch/x86/setup.c=0A+++ b/xen/arch/x86/setup.c= =0A@@ -645,7 +645,7 @@ void __init noreturn __start_xen(unsigne=0A = parse_video_info();=0A =0A rdmsrl(MSR_EFER, this_cpu(efer));=0A- = asm volatile ( "mov %%cr4,%0" : "=3Dr" (this_cpu(cr4)) );=0A+ asm = volatile ( "mov %%cr4,%0" : "=3Dr" (get_cpu_info()->cr4) );=0A =0A /* = We initialise the serial devices very early so we can get debugging. */=0A = ns16550.io_base =3D 0x3f8;=0A--- a/xen/include/asm-x86/current.h=0A+++ = b/xen/include/asm-x86/current.h=0A@@ -41,8 +41,8 @@ struct cpu_info {=0A = unsigned int processor_id;=0A struct vcpu *current_vcpu;=0A = unsigned long per_cpu_offset;=0A+ unsigned long cr4;=0A /* = get_stack_bottom() must be 16-byte aligned */=0A- unsigned long = __pad_for_stack_bottom;=0A };=0A =0A static inline struct cpu_info = *get_cpu_info(void)=0A--- a/xen/include/asm-x86/processor.h=0A+++ = b/xen/include/asm-x86/processor.h=0A@@ -328,8 +328,6 @@ static inline = unsigned long read_cr2(voi=0A return cr2;=0A }=0A =0A-DECLARE_PER_CPU(u= nsigned long, cr4);=0A-=0A static inline void raw_write_cr4(unsigned long = val)=0A {=0A asm volatile ( "mov %0,%%cr4" : : "r" (val) );=0A@@ = -337,12 +335,12 @@ static inline void raw_write_cr4(unsigne=0A =0A static = inline unsigned long read_cr4(void)=0A {=0A- return this_cpu(cr4);=0A+ = return get_cpu_info()->cr4;=0A }=0A =0A static inline void write_cr4(unsi= gned long val)=0A {=0A- this_cpu(cr4) =3D val;=0A+ get_cpu_info()->cr= 4 =3D val;=0A raw_write_cr4(val);=0A }=0A =0A --=__Part24139594.2__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwOi8vbGlzdHMueGVuLm9y Zy94ZW4tZGV2ZWwK --=__Part24139594.2__=--