From patchwork Thu Mar 17 08:02:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 8607721 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E63A49F3D1 for ; Thu, 17 Mar 2016 08:04:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 123B1202F0 for ; Thu, 17 Mar 2016 08:04:45 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD875202EC for ; Thu, 17 Mar 2016 08:04:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agSst-0004AZ-EC; Thu, 17 Mar 2016 08:02:19 +0000 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 Received: from [193.109.254.147] by server-7.bemta-14.messagelabs.com id C9/CC-04065-9846AE65; Thu, 17 Mar 2016 08:02:17 +0000 X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1458201734!30926930!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 62301 invoked from network); 17 Mar 2016 08:02:15 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-4.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 17 Mar 2016 08:02:15 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Thu, 17 Mar 2016 02:02:13 -0600 Message-Id: <56EA729402000078000DD92B@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Thu, 17 Mar 2016 02:02:12 -0600 From: "Jan Beulich" To: "xen-devel" 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> In-Reply-To: <56EA6FDF02000078000DD8FB@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Andrew Cooper , Keir Fraser , Feng Wu Subject: [Xen-devel] [PATCH v3 1/4] x86: move cached CR4 value to struct cpu_info X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 x86: move cached CR4 value to struct cpu_info 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 DEFINE_PER_CPU(struct vcpu *, curr_vcpu); -DEFINE_PER_CPU(unsigned long, cr4); static void default_idle(void); void (*pm_idle) (void) __read_mostly = 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(); rdmsrl(MSR_EFER, this_cpu(efer)); - asm volatile ( "mov %%cr4,%0" : "=r" (this_cpu(cr4)) ); + asm volatile ( "mov %%cr4,%0" : "=r" (get_cpu_info()->cr4) ); /* We initialise the serial devices very early so we can get debugging. */ ns16550.io_base = 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; }; 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; } -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 static inline unsigned long read_cr4(void) { - return this_cpu(cr4); + return get_cpu_info()->cr4; } static inline void write_cr4(unsigned long val) { - this_cpu(cr4) = val; + get_cpu_info()->cr4 = val; raw_write_cr4(val); } Reviewed-by: Andrew Cooper --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -64,7 +64,6 @@ #include DEFINE_PER_CPU(struct vcpu *, curr_vcpu); -DEFINE_PER_CPU(unsigned long, cr4); static void default_idle(void); void (*pm_idle) (void) __read_mostly = 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(); rdmsrl(MSR_EFER, this_cpu(efer)); - asm volatile ( "mov %%cr4,%0" : "=r" (this_cpu(cr4)) ); + asm volatile ( "mov %%cr4,%0" : "=r" (get_cpu_info()->cr4) ); /* We initialise the serial devices very early so we can get debugging. */ ns16550.io_base = 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; }; 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; } -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 static inline unsigned long read_cr4(void) { - return this_cpu(cr4); + return get_cpu_info()->cr4; } static inline void write_cr4(unsigned long val) { - this_cpu(cr4) = val; + get_cpu_info()->cr4 = val; raw_write_cr4(val); }