From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] x86/shadow: convert non-const statics Date: Wed, 28 Jan 2015 15:38:57 +0000 Message-ID: <54C90291.4080606@citrix.com> References: <54C90D6E020000780005A61A@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2437856644271919872==" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YGUhr-0001s2-O4 for xen-devel@lists.xenproject.org; Wed, 28 Jan 2015 15:39:03 +0000 In-Reply-To: <54C90D6E020000780005A61A@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , xen-devel Cc: Tim Deegan List-Id: xen-devel@lists.xenproject.org --===============2437856644271919872== Content-Type: multipart/alternative; boundary="------------020906000205060809050708" --------------020906000205060809050708 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit On 28/01/15 15:25, Jan Beulich wrote: > To make obvious that such statics are safe to use, they should be > const. In some of the cases, they don't even need to be static. > > Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper > > --- a/xen/arch/x86/mm/shadow/common.c > +++ b/xen/arch/x86/mm/shadow/common.c > @@ -2164,7 +2164,7 @@ int sh_remove_write_access(struct vcpu * > NULL /* unused */ > }; > > - static unsigned int callback_mask = > + const unsigned int callback_mask = > 1 << SH_type_l1_32_shadow > | 1 << SH_type_fl1_32_shadow > | 1 << SH_type_l1_pae_shadow > @@ -2414,7 +2414,7 @@ int sh_remove_all_mappings(struct vcpu * > NULL /* unused */ > }; > > - static unsigned int callback_mask = > + const unsigned int callback_mask = > 1 << SH_type_l1_32_shadow > | 1 << SH_type_fl1_32_shadow > | 1 << SH_type_l1_pae_shadow > @@ -2558,7 +2558,7 @@ void sh_remove_shadows(struct vcpu *v, m > }; > > /* Another lookup table, for choosing which mask to use */ > - static unsigned int masks[SH_type_unused] = { > + static const unsigned int masks[SH_type_unused] = { > 0, /* none */ > 1 << SH_type_l2_32_shadow, /* l1_32 */ > 0, /* fl1_32 */ > @@ -2685,7 +2685,7 @@ static int sh_clear_up_pointer(struct vc > > void sh_reset_l3_up_pointers(struct vcpu *v) > { > - static hash_callback_t callbacks[SH_type_unused] = { > + static const hash_callback_t callbacks[SH_type_unused] = { > NULL, /* none */ > NULL, /* l1_32 */ > NULL, /* fl1_32 */ > @@ -2703,7 +2703,7 @@ void sh_reset_l3_up_pointers(struct vcpu > NULL, /* p2m */ > NULL /* unused */ > }; > - static unsigned int callback_mask = 1 << SH_type_l3_64_shadow; > + const unsigned int callback_mask = 1 << SH_type_l3_64_shadow; > > hash_foreach(v, callback_mask, callbacks, _mfn(INVALID_MFN)); > } > > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel --------------020906000205060809050708 Content-Type: text/html; charset="windows-1252" Content-Transfer-Encoding: 7bit
On 28/01/15 15:25, Jan Beulich wrote:
To make obvious that such statics are safe to use, they should be
const. In some of the cases, they don't even need to be static.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>


--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -2164,7 +2164,7 @@ int sh_remove_write_access(struct vcpu *
         NULL  /* unused  */
     };
 
-    static unsigned int callback_mask = 
+    const unsigned int callback_mask =
           1 << SH_type_l1_32_shadow
         | 1 << SH_type_fl1_32_shadow
         | 1 << SH_type_l1_pae_shadow
@@ -2414,7 +2414,7 @@ int sh_remove_all_mappings(struct vcpu *
         NULL  /* unused  */
     };
 
-    static unsigned int callback_mask = 
+    const unsigned int callback_mask =
           1 << SH_type_l1_32_shadow
         | 1 << SH_type_fl1_32_shadow
         | 1 << SH_type_l1_pae_shadow
@@ -2558,7 +2558,7 @@ void sh_remove_shadows(struct vcpu *v, m
     };
 
     /* Another lookup table, for choosing which mask to use */
-    static unsigned int masks[SH_type_unused] = {
+    static const unsigned int masks[SH_type_unused] = {
         0, /* none    */
         1 << SH_type_l2_32_shadow, /* l1_32   */
         0, /* fl1_32  */
@@ -2685,7 +2685,7 @@ static int sh_clear_up_pointer(struct vc
 
 void sh_reset_l3_up_pointers(struct vcpu *v)
 {
-    static hash_callback_t callbacks[SH_type_unused] = {
+    static const hash_callback_t callbacks[SH_type_unused] = {
         NULL, /* none    */
         NULL, /* l1_32   */
         NULL, /* fl1_32  */
@@ -2703,7 +2703,7 @@ void sh_reset_l3_up_pointers(struct vcpu
         NULL, /* p2m     */
         NULL  /* unused  */
     };
-    static unsigned int callback_mask = 1 << SH_type_l3_64_shadow;    
+    const unsigned int callback_mask = 1 << SH_type_l3_64_shadow;
 
     hash_foreach(v, callback_mask, callbacks, _mfn(INVALID_MFN));
 }





_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

--------------020906000205060809050708-- --===============2437856644271919872== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============2437856644271919872==--