WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-merge

Re: [Xen-merge] [patch] SMP alternatives for i386

To: Gerd Knorr <kraxel@xxxxxxx>
Subject: Re: [Xen-merge] [patch] SMP alternatives for i386
From: Zachary Amsden <zach@xxxxxxxxxx>
Date: Tue, 13 Dec 2005 07:36:07 -0800
Cc: linux kernel mailing list <linux-kernel@xxxxxxxxxxxxxxx>, Xen merge mainline list <xen-merge@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Tue, 13 Dec 2005 15:38:08 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <439EE742.5040909@xxxxxxx>
List-help: <mailto:xen-merge-request@lists.xensource.com?subject=help>
List-id: xen-merge <xen-merge.lists.xensource.com>
List-post: <mailto:xen-merge@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-merge>, <mailto:xen-merge-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-merge>, <mailto:xen-merge-request@lists.xensource.com?subject=unsubscribe>
References: <439EE742.5040909@xxxxxxx>
Sender: xen-merge-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040803
Gerd Knorr wrote:

+#ifdef CONFIG_SMP
+#define alternative_smp(smpinstr, upinstr, args...)    \
+       asm volatile ("661:\n\t" smpinstr "\n662:\n"                     \
+                     ".section .smp_altinstructions,\"a\"\n"          \
+                     "  .align 4\n"                                 \
+                     "  .long 661b\n"            /* label */          \
+                     "  .long 663f\n"                  /* new instruction */   
      \
+                     "  .byte 0x68\n"            /* X86_FEATURE_UP */    \
+                     "  .byte 662b-661b\n"       /* sourcelen */      \
+                     "  .byte 664f-663f\n"       /* replacementlen */ \
+                     ".previous\n"                                           \
+                     ".section .smp_altinstr_replacement,\"awx\"\n"            
    \
+                     "663:\n\t" upinstr "\n"     /* replacement */    \
+                     "664:\n\t.fill 662b-661b,1,0x42\n" /* space for original 
*/ \
+                     ".previous" : args)
+
+#define LOCK_PREFIX \
+               ".section .smp_locks,\"a\"\n"       \
+               "  .align 4\n"                        \
+               "  .long 661f\n" /* address */        \
+               ".previous\n"                 \
+               "661:\n\tlock; "
+
+#else /* ! CONFIG_SMP */
+#define alternative_smp(smpinstr, upinstr, args...) \
+       asm volatile (upinstr : args)
+#define LOCK_PREFIX ""
+#endif
+
+#endif /* _I386_ALTERNATIVE_H */


Overall technically, I like this patch. Philosophically, I agree with it as well - but might I strongly suggest that you avoid the .section .previous directives and use the nestable .pushsection, .popsection instead? We are almost to the complexity point with fault handling and alternatives that we will need nested section overrides.

Zach

_______________________________________________
Xen-merge mailing list
Xen-merge@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-merge