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-ia64-devel

[Xen-ia64-devel] pv_ops: imntrinsic pv_ops

To: <xen-ia64-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-ia64-devel] pv_ops: imntrinsic pv_ops
From: "Dong, Eddie" <eddie.dong@xxxxxxxxx>
Date: Wed, 2 Apr 2008 13:51:28 +0800
Delivery-date: Tue, 01 Apr 2008 22:54:00 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AciUhZgAwsXu3nHQSoapSx4V2T8xzw==
Thread-topic: pv_ops: imntrinsic pv_ops
Current definition of intrinsic APIs seems to be too expansive, this one

give alternative way to do simply and reduce some changes.
If this applies, further simplification can be applied.
Thx, eddie



    Simplify intrinsic API handling.

Signed-off-by: Yaozu (Eddie) Dong <eddie.dong@xxxxxxxxx>

diff --git a/arch/ia64/kernel/paravirt.c b/arch/ia64/kernel/paravirt.c
index 4b01c44..6ce4f60 100644
--- a/arch/ia64/kernel/paravirt.c
+++ b/arch/ia64/kernel/paravirt.c
@@ -3,6 +3,7 @@
  *
  * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>
  *                    VA Linux Systems Japan K.K.
+ *     Yaozu (Eddie) Dong <eddie.dong@xxxxxxxxx>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -53,29 +54,18 @@ struct pv_init_ops pv_init_ops;
 
 /* ia64_native_xxx are macros so that we have to make them real
functions */
 
-static void
-ia64_native_fc_func(unsigned long addr)
-{
-       ia64_native_fc(addr);
-}
-
-static unsigned long
-ia64_native_thash_func(unsigned long addr)
-{
-       return ia64_native_thash(addr);
+#define NATIVE_INTRINSIC_API1(type, name, para1)               \
+static type native_ ## name(unsigned long para1) {     \
+       return name(para1);                                     \
 }
 
-static unsigned long
-ia64_native_get_cpuid_func(int index)
-{
-       return ia64_native_get_cpuid(index);
-}
-
-static unsigned long
-ia64_native_get_pmd_func(int index)
-{
-       return ia64_native_get_pmd(index);
-}
+#undef CONFIG_PARAVIRT
+NATIVE_INTRINSIC_API1(void, ia64_fc, addr)
+NATIVE_INTRINSIC_API1(unsigned long, ia64_thash, addr)
+NATIVE_INTRINSIC_API1(unsigned long, ia64_get_cpuid, addr)
+NATIVE_INTRINSIC_API1(unsigned long, ia64_get_pmd, index)
+NATIVE_INTRINSIC_API1(void, ia64_intrin_local_irq_restore, flags)
+#define CONFIG_PARAVIRT
 
 static unsigned long
 ia64_native_get_eflag_func(void)
@@ -217,17 +207,11 @@ ia64_native_get_psr_i_func(void)
        return ia64_native_get_psr_i();
 }
 
-static void
-ia64_native_intrin_local_irq_restore_func(unsigned long flags)
-{
-       ia64_native_intrin_local_irq_restore(flags);
-}
-
 struct pv_cpu_ops pv_cpu_ops = {
-       .fc             = ia64_native_fc_func,
-       .thash          = ia64_native_thash_func,
-       .get_cpuid      = ia64_native_get_cpuid_func,
-       .get_pmd        = ia64_native_get_pmd_func,
+       .fc             = native_ia64_fc,
+       .thash          = native_ia64_thash,
+       .get_cpuid      = native_ia64_get_cpuid,
+       .get_pmd        = native_ia64_get_pmd,
        .get_eflag      = ia64_native_get_eflag_func,
        .set_eflag      = ia64_native_set_eflag_func,
        .get_psr        = ia64_native_get_psr_func,
@@ -252,7 +236,7 @@ struct pv_cpu_ops pv_cpu_ops = {
        .rsm_i          = ia64_native_rsm_i_func,
        .get_psr_i      = ia64_native_get_psr_i_func,
        .intrin_local_irq_restore
-                       = ia64_native_intrin_local_irq_restore_func,
+                       = native_ia64_intrin_local_irq_restore,
 };
 
 
/***********************************************************************
*******
@@ -335,3 +319,5 @@ ia64_native_do_steal_accounting(unsigned long
*new_itm)
 struct pv_time_ops pv_time_ops = {
        .do_steal_accounting = ia64_native_do_steal_accounting,
 };
+
+
diff --git a/include/asm-ia64/gcc_intrin.h
b/include/asm-ia64/gcc_intrin.h
index b9fa3f4..fda12e7 100644
--- a/include/asm-ia64/gcc_intrin.h
+++ b/include/asm-ia64/gcc_intrin.h
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 2002,2003 Jun Nakajima <jun.nakajima@xxxxxxxxx>
  * Copyright (C) 2002,2003 Suresh Siddha <suresh.b.siddha@xxxxxxxxx>
+ * Copyright (C) 2008 Yaozu (Eddie) Dong <eddie.dong@xxxxxxxxx>
  */
 
 #include <linux/compiler.h>
@@ -28,6 +29,13 @@ extern void ia64_bad_param_for_getreg (void);
 register unsigned long ia64_r13 asm ("r13") __used;
 #endif
 
+#ifdef CONFIG_PARAVIRT
+#define INTRINSIC_INS1(name, para1, ins)       \
+       pv_cpu_ops.name(para1)
+#else
+#define INTRINSIC_INS1(name, para1, ins)       ins     
+#endif
+
 #define ia64_native_setreg(regnum, val)
\
 ({
\
        switch (regnum) {
\
@@ -381,8 +389,8 @@ register unsigned long ia64_r13 asm ("r13") __used;
 
 #define ia64_invala() asm volatile ("invala" ::: "memory")
 
-#define ia64_native_thash(addr)
\
-({
\
+#define ia64_thash(addr)
\
+       INTRINSIC_INS1(thash, addr,{
\
        __u64 ia64_intri_res;
\
        asm volatile ("thash %0=%1" : "=r"(ia64_intri_res) : "r"
(addr));        \
        ia64_intri_res;
\
@@ -437,8 +445,8 @@ register unsigned long ia64_r13 asm ("r13") __used;
 #define ia64_native_set_rr(index, val)
\
        asm volatile ("mov rr[%0]=%1" :: "r"(index), "r"(val) :
"memory");
 
-#define ia64_native_get_cpuid(index)
\
-({
\
+#define ia64_get_cpuid(index)
\
+       INTRINSIC_INS1(get_cpuid, index, {
\
        __u64 ia64_intri_res;
\
        asm volatile ("mov %0=cpuid[%r1]" : "=r"(ia64_intri_res) :
"rO"(index));   \
        ia64_intri_res;
\
@@ -473,8 +481,8 @@ register unsigned long ia64_r13 asm ("r13") __used;
 })
 
 
-#define ia64_native_get_pmd(index)
\
-({
\
+#define ia64_get_pmd(index)
\
+       INTRINSIC_INS1(get_pmd, index, {
\
        __u64 ia64_intri_res;
\
        asm volatile ("mov %0=pmd[%1]" : "=r"(ia64_intri_res) :
"r"(index));    \
        ia64_intri_res;
\
@@ -487,7 +495,8 @@ register unsigned long ia64_r13 asm ("r13") __used;
        ia64_intri_res;
\
 })
 
-#define ia64_native_fc(addr)   asm volatile ("fc %0" :: "r"(addr) :
"memory")
+#define ia64_fc(addr)  INTRINSIC_INS1(fc, addr,
\
+       asm volatile ("fc %0" :: "r"(addr) : "memory"))
 
 
 #define ia64_sync_i()  asm volatile (";; sync.i" ::: "memory")
@@ -596,13 +605,13 @@ do {
\
         }
\
 })
 
-#define ia64_native_intrin_local_irq_restore(x)
\
-do {                                                           \
+#define ia64_intrin_local_irq_restore(x)                       \
+       INTRINSIC_INS1(intrin_local_irq_restore, x, do {        \
        asm volatile (";;   cmp.ne p6,p7=%0,r0;;"               \
                      "(p6) ssm psr.i;"                         \
                      "(p7) rsm psr.i;;"                        \
                      "(p6) srlz.d"                             \
                      :: "r"((x)) : "p6", "p7", "memory");      \
-} while (0)
+} while (0))
 
 #endif /* _ASM_IA64_GCC_INTRIN_H */
diff --git a/include/asm-ia64/intel_intrin.h
b/include/asm-ia64/intel_intrin.h
index a7411dc..6781a56 100644
--- a/include/asm-ia64/intel_intrin.h
+++ b/include/asm-ia64/intel_intrin.h
@@ -9,6 +9,13 @@
  *
  */
 #include <ia64intrin.h>
+#ifdef CONFIG_PARAVIRT
+#define INTRINSIC_INS1(name, para1, ins)       \
+       pv_cpu_ops.name(para1)
+#else
+#define INTRINSIC_INS1(name, para1, ins)       ins     
+#endif
+
 
 #define ia64_barrier()         __memory_barrier()
 
@@ -42,7 +49,7 @@
 #define ia64_native_ssm                __ssm
 #define ia64_rum               __rum
 #define ia64_native_rsm                __rsm
-#define ia64_native_fc                 __fc
+#define ia64_fc(addr)          INTRINSIC_INS1(fc, addr, __fc)
 
 #define ia64_ldfs              __ldfs
 #define ia64_ldfd              __ldfd
@@ -91,12 +98,14 @@
 #define ia64_native_set_rr(index, val) \
                __setIndReg(_IA64_REG_INDR_RR, index, val)
 
-#define ia64_native_get_cpuid(index)
__getIndReg(_IA64_REG_INDR_CPUID, index)
+#define ia64_get_cpuid(index)  INTRINSIC_INS1(get_cpuid, index,
\
+       __getIndReg(_IA64_REG_INDR_CPUID, index))
 #define __ia64_get_dbr(index)  __getIndReg(_IA64_REG_INDR_DBR, index)
 #define ia64_native_get_ibr(index)     __getIndReg(_IA64_REG_INDR_IBR,
index)
 #define ia64_native_get_pkr(index)     __getIndReg(_IA64_REG_INDR_PKR,
index)
 #define ia64_native_get_pmc(index)     __getIndReg(_IA64_REG_INDR_PMC,
index)
-#define ia64_native_get_pmd(index)     __getIndReg(_IA64_REG_INDR_PMD,
index)
+#define ia64_get_pmd(index)    INTRINSIC_INS1(get_pmd, index,
\
+       __getIndReg(_IA64_REG_INDR_PMD, index)
 #define ia64_native_get_rr(index)      __getIndReg(_IA64_REG_INDR_RR,
index)
 
 #define ia64_srlz_d            __dsrlz
@@ -119,7 +128,7 @@
 #define ia64_ld8_acq           __ld8_acq
 
 #define ia64_sync_i            __synci
-#define ia64_native_thash              __thash
+#define ia64_thash(adr)                INTRINSIC_INS1(thash,
addr,__thash)
 #define ia64_native_ttag               __ttag
 #define ia64_native_itcd               __itcd
 #define ia64_native_itci               __itci
@@ -146,14 +155,14 @@
 #define ia64_lfetch_fault_excl __lfetch_fault_excl
 
 #define ia64_native_intrin_local_irq_restore(x)                \
-do {                                                   \
+       INTRINSIC_INS1(intrin_local_irq_restore, x, do {        \
        if ((x) != 0) {                                 \
                ia64_native_ssm(IA64_PSR_I);                    \
                ia64_srlz_d();                          \
        } else {                                        \
                ia64_native_rsm(IA64_PSR_I);                    \
        }                                               \
-} while (0)
+} while (0))
 
 #define __builtin_trap()       __break(0);
 
diff --git a/include/asm-ia64/paravirt_privop.h
b/include/asm-ia64/paravirt_privop.h
index 6e8354e..5a41672 100644
--- a/include/asm-ia64/paravirt_privop.h
+++ b/include/asm-ia64/paravirt_privop.h
@@ -75,30 +75,6 @@ extern struct pv_cpu_ops pv_cpu_ops;
 /* Note that "ttag" and "cover" are also privilege-sensitive; "ttag"
  * is not currently used (though it may be in a long-format VHPT
system!) */
 
-static inline void
-paravirt_fc(unsigned long addr)
-{
-       return pv_cpu_ops.fc(addr);
-}
-#define paravirt_fc(addr)      paravirt_fc((unsigned long)addr)
-
-static inline unsigned long
-paravirt_thash(unsigned long addr)
-{
-       return pv_cpu_ops.thash(addr);
-}
-
-static inline unsigned long
-paravirt_get_cpuid(int index)
-{
-       return pv_cpu_ops.get_cpuid(index);
-}
-
-static inline unsigned long
-paravirt_get_pmd(int index)
-{
-       return pv_cpu_ops.get_pmd(index);
-}
 
 static inline unsigned long
 paravirt_get_eflag(void)
@@ -230,12 +206,6 @@ paravirt_get_psr_i(void)
        return pv_cpu_ops.get_psr_i();
 }
 
-static inline void
-paravirt_intrin_local_irq_restore(unsigned long flags)
-{
-       pv_cpu_ops.intrin_local_irq_restore(flags);
-}
-
 /* regnum for ia64_native_getreg/setreg() must be constnat. ("i"
constraint)
  * static inline function doesn't satisfy it. */
 #define paravirt_getreg(regnum)
\
@@ -304,10 +274,6 @@ paravirt_intrin_local_irq_restore(unsigned long
flags)
                        ia64_native_rsm(mask);  \
        } while (0)
 
-#define ia64_fc(addr)                  paravirt_fc(addr)
-#define ia64_thash(addr)               paravirt_thash(addr)
-#define ia64_get_cpuid(i)              paravirt_get_cpuid(i)
-#define ia64_get_pmd(i)                        paravirt_get_pmd(i)
 #define ia64_ptcga(addr, size)         paravirt_ptcga((addr), (size))
 #define ia64_set_rr(index, val)                paravirt_set_rr((index),
(val))
 #define ia64_get_rr(index)             paravirt_get_rr(index)
@@ -319,8 +285,6 @@ paravirt_intrin_local_irq_restore(unsigned long
flags)
 #define ia64_ssm(mask)                 paravirt_ssm(mask)
 #define ia64_rsm(mask)                 paravirt_rsm(mask)
 #define ia64_get_psr_i()               paravirt_get_psr_i()
-#define ia64_intrin_local_irq_restore(x)       \
-       paravirt_intrin_local_irq_restore(x)
 
 /* the remainder of these are not performance-sensitive so its
  * OK to not paravirtualize and just take a privop trap and emulate */
diff --git a/include/asm-ia64/privop.h b/include/asm-ia64/privop.h
index c45c377..67fcd2f 100644
--- a/include/asm-ia64/privop.h
+++ b/include/asm-ia64/privop.h
@@ -21,7 +21,6 @@
 #define ia64_getreg                    ia64_native_getreg
 #define ia64_setreg                    ia64_native_setreg
 #define ia64_hint                      ia64_native_hint
-#define ia64_thash                     ia64_native_thash
 #define ia64_itci                      ia64_native_itci
 #define ia64_itcd                      ia64_native_itcd
 #define ia64_itri                      ia64_native_itri
@@ -32,13 +31,10 @@
 #define ia64_set_pmc                   ia64_native_set_pmc
 #define ia64_set_pmd                   ia64_native_set_pmd
 #define ia64_set_rr                    ia64_native_set_rr
-#define ia64_get_cpuid                 ia64_native_get_cpuid
 #define ia64_get_ibr                   ia64_native_get_ibr
 #define ia64_get_pkr                   ia64_native_get_pkr
 #define ia64_get_pmc                   ia64_native_get_pmc
-#define ia64_get_pmd                   ia64_native_get_pmd
 #define ia64_get_rr                    ia64_native_get_rr
-#define ia64_fc                                ia64_native_fc
 #define ia64_ssm                       ia64_native_ssm
 #define ia64_rsm                       ia64_native_rsm
 #define ia64_ptce                      ia64_native_ptce
@@ -47,7 +43,6 @@
 #define ia64_ptri                      ia64_native_ptri
 #define ia64_ptrd                      ia64_native_ptrd
 #define ia64_get_psr_i                 ia64_native_get_psr_i
-#define ia64_intrin_local_irq_restore
ia64_native_intrin_local_irq_restore
 #define ia64_set_rr0_to_rr4            ia64_native_set_rr0_to_rr4
 #endif /* !__ASSEMBLY */
 

Attachment: entry_pvops3.patch
Description: entry_pvops3.patch

_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel
<Prev in Thread] Current Thread [Next in Thread>