···11+ Recipe for getting/building/running Xen/ia64 with pv_ops22+ --------------------------------------------------------33+44+This recipe describes how to get xen-ia64 source and build it,55+and run domU with pv_ops.66+77+============88+Requirements99+============1010+1111+ - python1212+ - mercurial1313+ it (aka "hg") is an open-source source code1414+ management software. See the below.1515+ http://www.selenic.com/mercurial/wiki/1616+ - git1717+ - bridge-utils1818+1919+=================================2020+Getting and Building Xen and Dom02121+=================================2222+2323+ My environment is;2424+ Machine : Tiger42525+ Domain0 OS : RHEL52626+ DomainU OS : RHEL52727+2828+ 1. Download source2929+ # hg clone http://xenbits.xensource.com/ext/ia64/xen-unstable.hg3030+ # cd xen-unstable.hg3131+ # hg clone http://xenbits.xensource.com/ext/ia64/linux-2.6.18-xen.hg3232+3333+ 2. # make world3434+3535+ 3. # make install-tools3636+3737+ 4. copy kernels and xen3838+ # cp xen/xen.gz /boot/efi/efi/redhat/3939+ # cp build-linux-2.6.18-xen_ia64/vmlinux.gz \4040+ /boot/efi/efi/redhat/vmlinuz-2.6.18.8-xen4141+4242+ 5. make initrd for Dom0/DomU4343+ # make -C linux-2.6.18-xen.hg ARCH=ia64 modules_install \4444+ O=$(/bin/pwd)/build-linux-2.6.18-xen_ia644545+ # mkinitrd -f /boot/efi/efi/redhat/initrd-2.6.18.8-xen.img \4646+ 2.6.18.8-xen --builtin mptspi --builtin mptbase \4747+ --builtin mptscsih --builtin uhci-hcd --builtin ohci-hcd \4848+ --builtin ehci-hcd4949+5050+================================5151+Making a disk image for guest OS5252+================================5353+5454+ 1. make file5555+ # dd if=/dev/zero of=/root/rhel5.img bs=1M seek=4096 count=05656+ # mke2fs -F -j /root/rhel5.img5757+ # mount -o loop /root/rhel5.img /mnt5858+ # cp -ax /{dev,var,etc,usr,bin,sbin,lib} /mnt5959+ # mkdir /mnt/{root,proc,sys,home,tmp}6060+6161+ Note: You may miss some device files. If so, please create them6262+ with mknod. Or you can use tar instead of cp.6363+6464+ 2. modify DomU's fstab6565+ # vi /mnt/etc/fstab6666+ /dev/xvda1 / ext3 defaults 1 16767+ none /dev/pts devpts gid=5,mode=620 0 06868+ none /dev/shm tmpfs defaults 0 06969+ none /proc proc defaults 0 07070+ none /sys sysfs defaults 0 07171+7272+ 3. modify inittab7373+ set runlevel to 3 to avoid X trying to start7474+ # vi /mnt/etc/inittab7575+ id:3:initdefault:7676+ Start a getty on the hvc0 console7777+ X0:2345:respawn:/sbin/mingetty hvc07878+ tty1-6 mingetty can be commented out7979+8080+ 4. add hvc0 into /etc/securetty8181+ # vi /mnt/etc/securetty (add hvc0)8282+8383+ 5. umount8484+ # umount /mnt8585+8686+FYI, virt-manager can also make a disk image for guest OS.8787+It's GUI tools and easy to make it.8888+8989+==================9090+Boot Xen & Domain09191+==================9292+9393+ 1. replace elilo9494+ elilo of RHEL5 can boot Xen and Dom0.9595+ If you use old elilo (e.g RHEL4), please download from the below9696+ http://elilo.sourceforge.net/cgi-bin/blosxom9797+ and copy into /boot/efi/efi/redhat/9898+ # cp elilo-3.6-ia64.efi /boot/efi/efi/redhat/elilo.efi9999+100100+ 2. modify elilo.conf (like the below)101101+ # vi /boot/efi/efi/redhat/elilo.conf102102+ prompt103103+ timeout=20104104+ default=xen105105+ relocatable106106+107107+ image=vmlinuz-2.6.18.8-xen108108+ label=xen109109+ vmm=xen.gz110110+ initrd=initrd-2.6.18.8-xen.img111111+ read-only112112+ append=" -- rhgb root=/dev/sda2"113113+114114+The append options before "--" are for xen hypervisor,115115+the options after "--" are for dom0.116116+117117+FYI, your machine may need console options like118118+"com1=19200,8n1 console=vga,com1". For example,119119+append="com1=19200,8n1 console=vga,com1 -- rhgb console=tty0 \120120+console=ttyS0 root=/dev/sda2"121121+122122+=====================================123123+Getting and Building domU with pv_ops124124+=====================================125125+126126+ 1. get pv_ops tree127127+ # git clone http://people.valinux.co.jp/~yamahata/xen-ia64/linux-2.6-xen-ia64.git/128128+129129+ 2. git branch (if necessary)130130+ # cd linux-2.6-xen-ia64/131131+ # git checkout -b your_branch origin/xen-ia64-domu-minimal-2008may19132132+ (Note: The current branch is xen-ia64-domu-minimal-2008may19.133133+ But you would find the new branch. You can see with134134+ "git branch -r" to get the branch lists.135135+ http://people.valinux.co.jp/~yamahata/xen-ia64/for_eagl/linux-2.6-ia64-pv-ops.git/136136+ is also available. The tree is based on137137+ git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6 test)138138+139139+140140+ 3. copy .config for pv_ops of domU141141+ # cp arch/ia64/configs/xen_domu_wip_defconfig .config142142+143143+ 4. make kernel with pv_ops144144+ # make oldconfig145145+ # make146146+147147+ 5. install the kernel and initrd148148+ # cp vmlinux.gz /boot/efi/efi/redhat/vmlinuz-2.6-pv_ops-xenU149149+ # make modules_install150150+ # mkinitrd -f /boot/efi/efi/redhat/initrd-2.6-pv_ops-xenU.img \151151+ 2.6.26-rc3xen-ia64-08941-g1b12161 --builtin mptspi \152152+ --builtin mptbase --builtin mptscsih --builtin uhci-hcd \153153+ --builtin ohci-hcd --builtin ehci-hcd154154+155155+========================156156+Boot DomainU with pv_ops157157+========================158158+159159+ 1. make config of DomU160160+ # vi /etc/xen/rhel5161161+ kernel = "/boot/efi/efi/redhat/vmlinuz-2.6-pv_ops-xenU"162162+ ramdisk = "/boot/efi/efi/redhat/initrd-2.6-pv_ops-xenU.img"163163+ vcpus = 1164164+ memory = 512165165+ name = "rhel5"166166+ disk = [ 'file:/root/rhel5.img,xvda1,w' ]167167+ root = "/dev/xvda1 ro"168168+ extra= "rhgb console=hvc0"169169+170170+ 2. After boot xen and dom0, start xend171171+ # /etc/init.d/xend start172172+ ( In the debugging case, # XEND_DEBUG=1 xend trace_start )173173+174174+ 3. start domU175175+ # xm create -c rhel5176176+177177+=========178178+Reference179179+=========180180+- Wiki of Xen/IA64 upstream merge181181+ http://wiki.xensource.com/xenwiki/XenIA64/UpstreamMerge182182+183183+Written by Akio Takebe <takebe_akio@jp.fujitsu.com> on 28 May 2008
+32
arch/ia64/Kconfig
···109109 bool110110 default y111111112112+menuconfig PARAVIRT_GUEST113113+ bool "Paravirtualized guest support"114114+ help115115+ Say Y here to get to see options related to running Linux under116116+ various hypervisors. This option alone does not add any kernel code.117117+118118+ If you say N, all options in this submenu will be skipped and disabled.119119+120120+if PARAVIRT_GUEST121121+122122+config PARAVIRT123123+ bool "Enable paravirtualization code"124124+ depends on PARAVIRT_GUEST125125+ default y126126+ bool127127+ default y128128+ help129129+ This changes the kernel so it can modify itself when it is run130130+ under a hypervisor, potentially improving performance significantly131131+ over full virtualization. However, when run without a hypervisor132132+ the kernel is theoretically slower and slightly larger.133133+134134+135135+source "arch/ia64/xen/Kconfig"136136+137137+endif138138+112139choice113140 prompt "System type"114141 default IA64_GENERIC···157130 SGI-SN2 For SGI Altix systems158131 SGI-UV For SGI UV systems159132 Ski-simulator For the HP simulator <http://www.hpl.hp.com/research/linux/ski/>133133+ Xen-domU For xen domU system160134161135 If you don't know what to do, choose "generic".162136···207179config IA64_HP_SIM208180 bool "Ski-simulator"209181 select SWIOTLB182182+183183+config IA64_XEN_GUEST184184+ bool "Xen guest"185185+ depends on XEN210186211187endchoice212188
···2020 */2121#define __IA64_BREAK_SYSCALL 0x10000022222323+/*2424+ * Xen specific break numbers:2525+ */2626+#define __IA64_XEN_HYPERCALL 0x10002727+/* [__IA64_XEN_HYPERPRIVOP_START, __IA64_XEN_HYPERPRIVOP_MAX] is used2828+ for xen hyperprivops */2929+#define __IA64_XEN_HYPERPRIVOP_START 0x13030+#define __IA64_XEN_HYPERPRIVOP_MAX 0x1a3131+2332#endif /* _ASM_IA64_BREAK_H */
+2
arch/ia64/include/asm/machvec.h
···128128# include <asm/machvec_sn2.h>129129# elif defined (CONFIG_IA64_SGI_UV)130130# include <asm/machvec_uv.h>131131+# elif defined (CONFIG_IA64_XEN_GUEST)132132+# include <asm/machvec_xen.h>131133# elif defined (CONFIG_IA64_GENERIC)132134133135# ifdef MACHVEC_PLATFORM_HEADER
+22
arch/ia64/include/asm/machvec_xen.h
···11+#ifndef _ASM_IA64_MACHVEC_XEN_h22+#define _ASM_IA64_MACHVEC_XEN_h33+44+extern ia64_mv_setup_t dig_setup;55+extern ia64_mv_cpu_init_t xen_cpu_init;66+extern ia64_mv_irq_init_t xen_irq_init;77+extern ia64_mv_send_ipi_t xen_platform_send_ipi;88+99+/*1010+ * This stuff has dual use!1111+ *1212+ * For a generic kernel, the macros are used to initialize the1313+ * platform's machvec structure. When compiling a non-generic kernel,1414+ * the macros are used directly.1515+ */1616+#define platform_name "xen"1717+#define platform_setup dig_setup1818+#define platform_cpu_init xen_cpu_init1919+#define platform_irq_init xen_irq_init2020+#define platform_send_ipi xen_platform_send_ipi2121+2222+#endif /* _ASM_IA64_MACHVEC_XEN_h */
+2-1
arch/ia64/include/asm/meminit.h
···1818 * - crash dumping code reserved region1919 * - Kernel memory map built from EFI memory map2020 * - ELF core header2121+ * - xen start info if CONFIG_XEN2122 *2223 * More could be added if necessary2324 */2424-#define IA64_MAX_RSVD_REGIONS 82525+#define IA64_MAX_RSVD_REGIONS 925262627struct rsvd_region {2728 unsigned long start; /* virtual address of beginning of element */
···11+#ifndef _ASM_NATIVE_PVCHK_INST_H22+#define _ASM_NATIVE_PVCHK_INST_H33+44+/******************************************************************************55+ * arch/ia64/include/asm/native/pvchk_inst.h66+ * Checker for paravirtualizations of privileged operations.77+ *88+ * Copyright (C) 2005 Hewlett-Packard Co99+ * Dan Magenheimer <dan.magenheimer@hp.com>1010+ *1111+ * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>1212+ * VA Linux Systems Japan K.K.1313+ *1414+ * This program is free software; you can redistribute it and/or modify1515+ * it under the terms of the GNU General Public License as published by1616+ * the Free Software Foundation; either version 2 of the License, or1717+ * (at your option) any later version.1818+ *1919+ * This program is distributed in the hope that it will be useful,2020+ * but WITHOUT ANY WARRANTY; without even the implied warranty of2121+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2222+ * GNU General Public License for more details.2323+ *2424+ * You should have received a copy of the GNU General Public License2525+ * along with this program; if not, write to the Free Software2626+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2727+ *2828+ */2929+3030+/**********************************************3131+ * Instructions paravirtualized for correctness3232+ **********************************************/3333+3434+/* "fc" and "thash" are privilege-sensitive instructions, meaning they3535+ * may have different semantics depending on whether they are executed3636+ * at PL0 vs PL!=0. When paravirtualized, these instructions mustn't3737+ * be allowed to execute directly, lest incorrect semantics result.3838+ */3939+4040+#define fc .error "fc should not be used directly."4141+#define thash .error "thash should not be used directly."4242+4343+/* Note that "ttag" and "cover" are also privilege-sensitive; "ttag"4444+ * is not currently used (though it may be in a long-format VHPT system!)4545+ * and the semantics of cover only change if psr.ic is off which is very4646+ * rare (and currently non-existent outside of assembly code4747+ */4848+#define ttag .error "ttag should not be used directly."4949+#define cover .error "cover should not be used directly."5050+5151+/* There are also privilege-sensitive registers. These registers are5252+ * readable at any privilege level but only writable at PL0.5353+ */5454+#define cpuid .error "cpuid should not be used directly."5555+#define pmd .error "pmd should not be used directly."5656+5757+/*5858+ * mov ar.eflag =5959+ * mov = ar.eflag6060+ */6161+6262+/**********************************************6363+ * Instructions paravirtualized for performance6464+ **********************************************/6565+/*6666+ * Those instructions include '.' which can't be handled by cpp.6767+ * or can't be handled by cpp easily.6868+ * They are handled by sed instead of cpp.6969+ */7070+7171+/* for .S7272+ * itc.i7373+ * itc.d7474+ *7575+ * bsw.07676+ * bsw.17777+ *7878+ * ssm psr.ic | PSR_DEFAULT_BITS7979+ * ssm psr.ic8080+ * rsm psr.ic8181+ * ssm psr.i8282+ * rsm psr.i8383+ * rsm psr.i | psr.ic8484+ * rsm psr.dt8585+ * ssm psr.dt8686+ *8787+ * mov = cr.ifa8888+ * mov = cr.itir8989+ * mov = cr.isr9090+ * mov = cr.iha9191+ * mov = cr.ipsr9292+ * mov = cr.iim9393+ * mov = cr.iip9494+ * mov = cr.ivr9595+ * mov = psr9696+ *9797+ * mov cr.ifa =9898+ * mov cr.itir =9999+ * mov cr.iha =100100+ * mov cr.ipsr =101101+ * mov cr.ifs =102102+ * mov cr.iip =103103+ * mov cr.kr =104104+ */105105+106106+/* for intrinsics107107+ * ssm psr.i108108+ * rsm psr.i109109+ * mov = psr110110+ * mov = ivr111111+ * mov = tpr112112+ * mov cr.itm =113113+ * mov eoi =114114+ * mov rr[] =115115+ * mov = rr[]116116+ * mov = kr117117+ * mov kr =118118+ * ptc.ga119119+ */120120+121121+/*************************************************************122122+ * define paravirtualized instrcution macros as nop to ingore.123123+ * and check whether arguments are appropriate.124124+ *************************************************************/125125+126126+/* check whether reg is a regular register */127127+.macro is_rreg_in reg128128+ .ifc "\reg", "r0"129129+ nop 0130130+ .exitm131131+ .endif132132+ ;;133133+ mov \reg = r0134134+ ;;135135+.endm136136+#define IS_RREG_IN(reg) is_rreg_in reg ;137137+138138+#define IS_RREG_OUT(reg) \139139+ ;; \140140+ mov reg = r0 \141141+ ;;142142+143143+#define IS_RREG_CLOB(reg) IS_RREG_OUT(reg)144144+145145+/* check whether pred is a predicate register */146146+#define IS_PRED_IN(pred) \147147+ ;; \148148+ (pred) nop 0 \149149+ ;;150150+151151+#define IS_PRED_OUT(pred) \152152+ ;; \153153+ cmp.eq pred, p0 = r0, r0 \154154+ ;;155155+156156+#define IS_PRED_CLOB(pred) IS_PRED_OUT(pred)157157+158158+159159+#define DO_SAVE_MIN(__COVER, SAVE_IFS, EXTRA, WORKAROUND) \160160+ nop 0161161+#define MOV_FROM_IFA(reg) \162162+ IS_RREG_OUT(reg)163163+#define MOV_FROM_ITIR(reg) \164164+ IS_RREG_OUT(reg)165165+#define MOV_FROM_ISR(reg) \166166+ IS_RREG_OUT(reg)167167+#define MOV_FROM_IHA(reg) \168168+ IS_RREG_OUT(reg)169169+#define MOV_FROM_IPSR(pred, reg) \170170+ IS_PRED_IN(pred) \171171+ IS_RREG_OUT(reg)172172+#define MOV_FROM_IIM(reg) \173173+ IS_RREG_OUT(reg)174174+#define MOV_FROM_IIP(reg) \175175+ IS_RREG_OUT(reg)176176+#define MOV_FROM_IVR(reg, clob) \177177+ IS_RREG_OUT(reg) \178178+ IS_RREG_CLOB(clob)179179+#define MOV_FROM_PSR(pred, reg, clob) \180180+ IS_PRED_IN(pred) \181181+ IS_RREG_OUT(reg) \182182+ IS_RREG_CLOB(clob)183183+#define MOV_TO_IFA(reg, clob) \184184+ IS_RREG_IN(reg) \185185+ IS_RREG_CLOB(clob)186186+#define MOV_TO_ITIR(pred, reg, clob) \187187+ IS_PRED_IN(pred) \188188+ IS_RREG_IN(reg) \189189+ IS_RREG_CLOB(clob)190190+#define MOV_TO_IHA(pred, reg, clob) \191191+ IS_PRED_IN(pred) \192192+ IS_RREG_IN(reg) \193193+ IS_RREG_CLOB(clob)194194+#define MOV_TO_IPSR(pred, reg, clob) \195195+ IS_PRED_IN(pred) \196196+ IS_RREG_IN(reg) \197197+ IS_RREG_CLOB(clob)198198+#define MOV_TO_IFS(pred, reg, clob) \199199+ IS_PRED_IN(pred) \200200+ IS_RREG_IN(reg) \201201+ IS_RREG_CLOB(clob)202202+#define MOV_TO_IIP(reg, clob) \203203+ IS_RREG_IN(reg) \204204+ IS_RREG_CLOB(clob)205205+#define MOV_TO_KR(kr, reg, clob0, clob1) \206206+ IS_RREG_IN(reg) \207207+ IS_RREG_CLOB(clob0) \208208+ IS_RREG_CLOB(clob1)209209+#define ITC_I(pred, reg, clob) \210210+ IS_PRED_IN(pred) \211211+ IS_RREG_IN(reg) \212212+ IS_RREG_CLOB(clob)213213+#define ITC_D(pred, reg, clob) \214214+ IS_PRED_IN(pred) \215215+ IS_RREG_IN(reg) \216216+ IS_RREG_CLOB(clob)217217+#define ITC_I_AND_D(pred_i, pred_d, reg, clob) \218218+ IS_PRED_IN(pred_i) \219219+ IS_PRED_IN(pred_d) \220220+ IS_RREG_IN(reg) \221221+ IS_RREG_CLOB(clob)222222+#define THASH(pred, reg0, reg1, clob) \223223+ IS_PRED_IN(pred) \224224+ IS_RREG_OUT(reg0) \225225+ IS_RREG_IN(reg1) \226226+ IS_RREG_CLOB(clob)227227+#define SSM_PSR_IC_AND_DEFAULT_BITS_AND_SRLZ_I(clob0, clob1) \228228+ IS_RREG_CLOB(clob0) \229229+ IS_RREG_CLOB(clob1)230230+#define SSM_PSR_IC_AND_SRLZ_D(clob0, clob1) \231231+ IS_RREG_CLOB(clob0) \232232+ IS_RREG_CLOB(clob1)233233+#define RSM_PSR_IC(clob) \234234+ IS_RREG_CLOB(clob)235235+#define SSM_PSR_I(pred, pred_clob, clob) \236236+ IS_PRED_IN(pred) \237237+ IS_PRED_CLOB(pred_clob) \238238+ IS_RREG_CLOB(clob)239239+#define RSM_PSR_I(pred, clob0, clob1) \240240+ IS_PRED_IN(pred) \241241+ IS_RREG_CLOB(clob0) \242242+ IS_RREG_CLOB(clob1)243243+#define RSM_PSR_I_IC(clob0, clob1, clob2) \244244+ IS_RREG_CLOB(clob0) \245245+ IS_RREG_CLOB(clob1) \246246+ IS_RREG_CLOB(clob2)247247+#define RSM_PSR_DT \248248+ nop 0249249+#define SSM_PSR_DT_AND_SRLZ_I \250250+ nop 0251251+#define BSW_0(clob0, clob1, clob2) \252252+ IS_RREG_CLOB(clob0) \253253+ IS_RREG_CLOB(clob1) \254254+ IS_RREG_CLOB(clob2)255255+#define BSW_1(clob0, clob1) \256256+ IS_RREG_CLOB(clob0) \257257+ IS_RREG_CLOB(clob1)258258+#define COVER \259259+ nop 0260260+#define RFI \261261+ br.ret.sptk.many rp /* defining nop causes dependency error */262262+263263+#endif /* _ASM_NATIVE_PVCHK_INST_H */
+2-2
arch/ia64/include/asm/paravirt.h
···117117struct pv_iosapic_ops {118118 void (*pcat_compat_init)(void);119119120120- struct irq_chip *(*get_irq_chip)(unsigned long trigger);120120+ struct irq_chip *(*__get_irq_chip)(unsigned long trigger);121121122122 unsigned int (*__read)(char __iomem *iosapic, unsigned int reg);123123 void (*__write)(char __iomem *iosapic, unsigned int reg, u32 val);···135135static inline struct irq_chip*136136iosapic_get_irq_chip(unsigned long trigger)137137{138138- return pv_iosapic_ops.get_irq_chip(trigger);138138+ return pv_iosapic_ops.__get_irq_chip(trigger);139139}140140141141static inline unsigned int
+48
arch/ia64/include/asm/pvclock-abi.h
···11+/*22+ * same structure to x86's33+ * Hopefully asm-x86/pvclock-abi.h would be moved to somewhere more generic.44+ * For now, define same duplicated definitions.55+ */66+77+#ifndef _ASM_IA64__PVCLOCK_ABI_H88+#define _ASM_IA64__PVCLOCK_ABI_H99+#ifndef __ASSEMBLY__1010+1111+/*1212+ * These structs MUST NOT be changed.1313+ * They are the ABI between hypervisor and guest OS.1414+ * Both Xen and KVM are using this.1515+ *1616+ * pvclock_vcpu_time_info holds the system time and the tsc timestamp1717+ * of the last update. So the guest can use the tsc delta to get a1818+ * more precise system time. There is one per virtual cpu.1919+ *2020+ * pvclock_wall_clock references the point in time when the system2121+ * time was zero (usually boot time), thus the guest calculates the2222+ * current wall clock by adding the system time.2323+ *2424+ * Protocol for the "version" fields is: hypervisor raises it (making2525+ * it uneven) before it starts updating the fields and raises it again2626+ * (making it even) when it is done. Thus the guest can make sure the2727+ * time values it got are consistent by checking the version before2828+ * and after reading them.2929+ */3030+3131+struct pvclock_vcpu_time_info {3232+ u32 version;3333+ u32 pad0;3434+ u64 tsc_timestamp;3535+ u64 system_time;3636+ u32 tsc_to_system_mul;3737+ s8 tsc_shift;3838+ u8 pad[3];3939+} __attribute__((__packed__)); /* 32 bytes */4040+4141+struct pvclock_wall_clock {4242+ u32 version;4343+ u32 sec;4444+ u32 nsec;4545+} __attribute__((__packed__));4646+4747+#endif /* __ASSEMBLY__ */4848+#endif /* _ASM_IA64__PVCLOCK_ABI_H */
+51
arch/ia64/include/asm/sync_bitops.h
···11+#ifndef _ASM_IA64_SYNC_BITOPS_H22+#define _ASM_IA64_SYNC_BITOPS_H33+44+/*55+ * Copyright (C) 2008 Isaku Yamahata <yamahata at valinux co jp>66+ *77+ * Based on synch_bitops.h which Dan Magenhaimer wrote.88+ *99+ * bit operations which provide guaranteed strong synchronisation1010+ * when communicating with Xen or other guest OSes running on other CPUs.1111+ */1212+1313+static inline void sync_set_bit(int nr, volatile void *addr)1414+{1515+ set_bit(nr, addr);1616+}1717+1818+static inline void sync_clear_bit(int nr, volatile void *addr)1919+{2020+ clear_bit(nr, addr);2121+}2222+2323+static inline void sync_change_bit(int nr, volatile void *addr)2424+{2525+ change_bit(nr, addr);2626+}2727+2828+static inline int sync_test_and_set_bit(int nr, volatile void *addr)2929+{3030+ return test_and_set_bit(nr, addr);3131+}3232+3333+static inline int sync_test_and_clear_bit(int nr, volatile void *addr)3434+{3535+ return test_and_clear_bit(nr, addr);3636+}3737+3838+static inline int sync_test_and_change_bit(int nr, volatile void *addr)3939+{4040+ return test_and_change_bit(nr, addr);4141+}4242+4343+static inline int sync_test_bit(int nr, const volatile void *addr)4444+{4545+ return test_bit(nr, addr);4646+}4747+4848+#define sync_cmpxchg(ptr, old, new) \4949+ ((__typeof__(*(ptr)))cmpxchg_acq((ptr), (old), (new)))5050+5151+#endif /* _ASM_IA64_SYNC_BITOPS_H */
···11+/******************************************************************************22+ * arch/ia64/include/asm/xen/events.h33+ *44+ * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>55+ * VA Linux Systems Japan K.K.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License as published by99+ * the Free Software Foundation; either version 2 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This program is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515+ * GNU General Public License for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2020+ *2121+ */2222+#ifndef _ASM_IA64_XEN_EVENTS_H2323+#define _ASM_IA64_XEN_EVENTS_H2424+2525+enum ipi_vector {2626+ XEN_RESCHEDULE_VECTOR,2727+ XEN_IPI_VECTOR,2828+ XEN_CMCP_VECTOR,2929+ XEN_CPEP_VECTOR,3030+3131+ XEN_NR_IPIS,3232+};3333+3434+static inline int xen_irqs_disabled(struct pt_regs *regs)3535+{3636+ return !(ia64_psr(regs)->i);3737+}3838+3939+static inline void xen_do_IRQ(int irq, struct pt_regs *regs)4040+{4141+ struct pt_regs *old_regs;4242+ old_regs = set_irq_regs(regs);4343+ irq_enter();4444+ __do_IRQ(irq);4545+ irq_exit();4646+ set_irq_regs(old_regs);4747+}4848+#define irq_ctx_init(cpu) do { } while (0)4949+5050+#endif /* _ASM_IA64_XEN_EVENTS_H */
+29
arch/ia64/include/asm/xen/grant_table.h
···11+/******************************************************************************22+ * arch/ia64/include/asm/xen/grant_table.h33+ *44+ * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>55+ * VA Linux Systems Japan K.K.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License as published by99+ * the Free Software Foundation; either version 2 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This program is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515+ * GNU General Public License for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2020+ *2121+ */2222+2323+#ifndef _ASM_IA64_XEN_GRANT_TABLE_H2424+#define _ASM_IA64_XEN_GRANT_TABLE_H2525+2626+struct vm_struct *xen_alloc_vm_area(unsigned long size);2727+void xen_free_vm_area(struct vm_struct *area);2828+2929+#endif /* _ASM_IA64_XEN_GRANT_TABLE_H */
+265
arch/ia64/include/asm/xen/hypercall.h
···11+/******************************************************************************22+ * hypercall.h33+ *44+ * Linux-specific hypervisor handling.55+ *66+ * Copyright (c) 2002-2004, K A Fraser77+ *88+ * This program is free software; you can redistribute it and/or99+ * modify it under the terms of the GNU General Public License version 21010+ * as published by the Free Software Foundation; or, when distributed1111+ * separately from the Linux kernel or incorporated into other1212+ * software packages, subject to the following license:1313+ *1414+ * Permission is hereby granted, free of charge, to any person obtaining a copy1515+ * of this source file (the "Software"), to deal in the Software without1616+ * restriction, including without limitation the rights to use, copy, modify,1717+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,1818+ * and to permit persons to whom the Software is furnished to do so, subject to1919+ * the following conditions:2020+ *2121+ * The above copyright notice and this permission notice shall be included in2222+ * all copies or substantial portions of the Software.2323+ *2424+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR2525+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,2626+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE2727+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER2828+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING2929+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS3030+ * IN THE SOFTWARE.3131+ */3232+3333+#ifndef _ASM_IA64_XEN_HYPERCALL_H3434+#define _ASM_IA64_XEN_HYPERCALL_H3535+3636+#include <xen/interface/xen.h>3737+#include <xen/interface/physdev.h>3838+#include <xen/interface/sched.h>3939+#include <asm/xen/xcom_hcall.h>4040+struct xencomm_handle;4141+extern unsigned long __hypercall(unsigned long a1, unsigned long a2,4242+ unsigned long a3, unsigned long a4,4343+ unsigned long a5, unsigned long cmd);4444+4545+/*4646+ * Assembler stubs for hyper-calls.4747+ */4848+4949+#define _hypercall0(type, name) \5050+({ \5151+ long __res; \5252+ __res = __hypercall(0, 0, 0, 0, 0, __HYPERVISOR_##name);\5353+ (type)__res; \5454+})5555+5656+#define _hypercall1(type, name, a1) \5757+({ \5858+ long __res; \5959+ __res = __hypercall((unsigned long)a1, \6060+ 0, 0, 0, 0, __HYPERVISOR_##name); \6161+ (type)__res; \6262+})6363+6464+#define _hypercall2(type, name, a1, a2) \6565+({ \6666+ long __res; \6767+ __res = __hypercall((unsigned long)a1, \6868+ (unsigned long)a2, \6969+ 0, 0, 0, __HYPERVISOR_##name); \7070+ (type)__res; \7171+})7272+7373+#define _hypercall3(type, name, a1, a2, a3) \7474+({ \7575+ long __res; \7676+ __res = __hypercall((unsigned long)a1, \7777+ (unsigned long)a2, \7878+ (unsigned long)a3, \7979+ 0, 0, __HYPERVISOR_##name); \8080+ (type)__res; \8181+})8282+8383+#define _hypercall4(type, name, a1, a2, a3, a4) \8484+({ \8585+ long __res; \8686+ __res = __hypercall((unsigned long)a1, \8787+ (unsigned long)a2, \8888+ (unsigned long)a3, \8989+ (unsigned long)a4, \9090+ 0, __HYPERVISOR_##name); \9191+ (type)__res; \9292+})9393+9494+#define _hypercall5(type, name, a1, a2, a3, a4, a5) \9595+({ \9696+ long __res; \9797+ __res = __hypercall((unsigned long)a1, \9898+ (unsigned long)a2, \9999+ (unsigned long)a3, \100100+ (unsigned long)a4, \101101+ (unsigned long)a5, \102102+ __HYPERVISOR_##name); \103103+ (type)__res; \104104+})105105+106106+107107+static inline int108108+xencomm_arch_hypercall_sched_op(int cmd, struct xencomm_handle *arg)109109+{110110+ return _hypercall2(int, sched_op_new, cmd, arg);111111+}112112+113113+static inline long114114+HYPERVISOR_set_timer_op(u64 timeout)115115+{116116+ unsigned long timeout_hi = (unsigned long)(timeout >> 32);117117+ unsigned long timeout_lo = (unsigned long)timeout;118118+ return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi);119119+}120120+121121+static inline int122122+xencomm_arch_hypercall_multicall(struct xencomm_handle *call_list,123123+ int nr_calls)124124+{125125+ return _hypercall2(int, multicall, call_list, nr_calls);126126+}127127+128128+static inline int129129+xencomm_arch_hypercall_memory_op(unsigned int cmd, struct xencomm_handle *arg)130130+{131131+ return _hypercall2(int, memory_op, cmd, arg);132132+}133133+134134+static inline int135135+xencomm_arch_hypercall_event_channel_op(int cmd, struct xencomm_handle *arg)136136+{137137+ return _hypercall2(int, event_channel_op, cmd, arg);138138+}139139+140140+static inline int141141+xencomm_arch_hypercall_xen_version(int cmd, struct xencomm_handle *arg)142142+{143143+ return _hypercall2(int, xen_version, cmd, arg);144144+}145145+146146+static inline int147147+xencomm_arch_hypercall_console_io(int cmd, int count,148148+ struct xencomm_handle *str)149149+{150150+ return _hypercall3(int, console_io, cmd, count, str);151151+}152152+153153+static inline int154154+xencomm_arch_hypercall_physdev_op(int cmd, struct xencomm_handle *arg)155155+{156156+ return _hypercall2(int, physdev_op, cmd, arg);157157+}158158+159159+static inline int160160+xencomm_arch_hypercall_grant_table_op(unsigned int cmd,161161+ struct xencomm_handle *uop,162162+ unsigned int count)163163+{164164+ return _hypercall3(int, grant_table_op, cmd, uop, count);165165+}166166+167167+int HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count);168168+169169+extern int xencomm_arch_hypercall_suspend(struct xencomm_handle *arg);170170+171171+static inline int172172+xencomm_arch_hypercall_callback_op(int cmd, struct xencomm_handle *arg)173173+{174174+ return _hypercall2(int, callback_op, cmd, arg);175175+}176176+177177+static inline long178178+xencomm_arch_hypercall_vcpu_op(int cmd, int cpu, void *arg)179179+{180180+ return _hypercall3(long, vcpu_op, cmd, cpu, arg);181181+}182182+183183+static inline int184184+HYPERVISOR_physdev_op(int cmd, void *arg)185185+{186186+ switch (cmd) {187187+ case PHYSDEVOP_eoi:188188+ return _hypercall1(int, ia64_fast_eoi,189189+ ((struct physdev_eoi *)arg)->irq);190190+ default:191191+ return xencomm_hypercall_physdev_op(cmd, arg);192192+ }193193+}194194+195195+static inline long196196+xencomm_arch_hypercall_opt_feature(struct xencomm_handle *arg)197197+{198198+ return _hypercall1(long, opt_feature, arg);199199+}200200+201201+/* for balloon driver */202202+#define HYPERVISOR_update_va_mapping(va, new_val, flags) (0)203203+204204+/* Use xencomm to do hypercalls. */205205+#define HYPERVISOR_sched_op xencomm_hypercall_sched_op206206+#define HYPERVISOR_event_channel_op xencomm_hypercall_event_channel_op207207+#define HYPERVISOR_callback_op xencomm_hypercall_callback_op208208+#define HYPERVISOR_multicall xencomm_hypercall_multicall209209+#define HYPERVISOR_xen_version xencomm_hypercall_xen_version210210+#define HYPERVISOR_console_io xencomm_hypercall_console_io211211+#define HYPERVISOR_memory_op xencomm_hypercall_memory_op212212+#define HYPERVISOR_suspend xencomm_hypercall_suspend213213+#define HYPERVISOR_vcpu_op xencomm_hypercall_vcpu_op214214+#define HYPERVISOR_opt_feature xencomm_hypercall_opt_feature215215+216216+/* to compile gnttab_copy_grant_page() in drivers/xen/core/gnttab.c */217217+#define HYPERVISOR_mmu_update(req, count, success_count, domid) ({ BUG(); 0; })218218+219219+static inline int220220+HYPERVISOR_shutdown(221221+ unsigned int reason)222222+{223223+ struct sched_shutdown sched_shutdown = {224224+ .reason = reason225225+ };226226+227227+ int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);228228+229229+ return rc;230230+}231231+232232+/* for netfront.c, netback.c */233233+#define MULTI_UVMFLAGS_INDEX 0 /* XXX any value */234234+235235+static inline void236236+MULTI_update_va_mapping(237237+ struct multicall_entry *mcl, unsigned long va,238238+ pte_t new_val, unsigned long flags)239239+{240240+ mcl->op = __HYPERVISOR_update_va_mapping;241241+ mcl->result = 0;242242+}243243+244244+static inline void245245+MULTI_grant_table_op(struct multicall_entry *mcl, unsigned int cmd,246246+ void *uop, unsigned int count)247247+{248248+ mcl->op = __HYPERVISOR_grant_table_op;249249+ mcl->args[0] = cmd;250250+ mcl->args[1] = (unsigned long)uop;251251+ mcl->args[2] = count;252252+}253253+254254+static inline void255255+MULTI_mmu_update(struct multicall_entry *mcl, struct mmu_update *req,256256+ int count, int *success_count, domid_t domid)257257+{258258+ mcl->op = __HYPERVISOR_mmu_update;259259+ mcl->args[0] = (unsigned long)req;260260+ mcl->args[1] = count;261261+ mcl->args[2] = (unsigned long)success_count;262262+ mcl->args[3] = domid;263263+}264264+265265+#endif /* _ASM_IA64_XEN_HYPERCALL_H */
+89
arch/ia64/include/asm/xen/hypervisor.h
···11+/******************************************************************************22+ * hypervisor.h33+ *44+ * Linux-specific hypervisor handling.55+ *66+ * Copyright (c) 2002-2004, K A Fraser77+ *88+ * This program is free software; you can redistribute it and/or99+ * modify it under the terms of the GNU General Public License version 21010+ * as published by the Free Software Foundation; or, when distributed1111+ * separately from the Linux kernel or incorporated into other1212+ * software packages, subject to the following license:1313+ *1414+ * Permission is hereby granted, free of charge, to any person obtaining a copy1515+ * of this source file (the "Software"), to deal in the Software without1616+ * restriction, including without limitation the rights to use, copy, modify,1717+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,1818+ * and to permit persons to whom the Software is furnished to do so, subject to1919+ * the following conditions:2020+ *2121+ * The above copyright notice and this permission notice shall be included in2222+ * all copies or substantial portions of the Software.2323+ *2424+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR2525+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,2626+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE2727+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER2828+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING2929+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS3030+ * IN THE SOFTWARE.3131+ */3232+3333+#ifndef _ASM_IA64_XEN_HYPERVISOR_H3434+#define _ASM_IA64_XEN_HYPERVISOR_H3535+3636+#ifdef CONFIG_XEN3737+3838+#include <linux/init.h>3939+#include <xen/interface/xen.h>4040+#include <xen/interface/version.h> /* to compile feature.c */4141+#include <xen/features.h> /* to comiple xen-netfront.c */4242+#include <asm/xen/hypercall.h>4343+4444+/* xen_domain_type is set before executing any C code by early_xen_setup */4545+enum xen_domain_type {4646+ XEN_NATIVE,4747+ XEN_PV_DOMAIN,4848+ XEN_HVM_DOMAIN,4949+};5050+5151+extern enum xen_domain_type xen_domain_type;5252+5353+#define xen_domain() (xen_domain_type != XEN_NATIVE)5454+#define xen_pv_domain() (xen_domain_type == XEN_PV_DOMAIN)5555+#define xen_initial_domain() (xen_pv_domain() && \5656+ (xen_start_info->flags & SIF_INITDOMAIN))5757+#define xen_hvm_domain() (xen_domain_type == XEN_HVM_DOMAIN)5858+5959+/* deprecated. remove this */6060+#define is_running_on_xen() (xen_domain_type == XEN_PV_DOMAIN)6161+6262+extern struct shared_info *HYPERVISOR_shared_info;6363+extern struct start_info *xen_start_info;6464+6565+void __init xen_setup_vcpu_info_placement(void);6666+void force_evtchn_callback(void);6767+6868+/* for drivers/xen/balloon/balloon.c */6969+#ifdef CONFIG_XEN_SCRUB_PAGES7070+#define scrub_pages(_p, _n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)7171+#else7272+#define scrub_pages(_p, _n) ((void)0)7373+#endif7474+7575+/* For setup_arch() in arch/ia64/kernel/setup.c */7676+void xen_ia64_enable_opt_feature(void);7777+7878+#else /* CONFIG_XEN */7979+8080+#define xen_domain() (0)8181+#define xen_pv_domain() (0)8282+#define xen_initial_domain() (0)8383+#define xen_hvm_domain() (0)8484+#define is_running_on_xen() (0) /* deprecated. remove this */8585+#endif8686+8787+#define is_initial_xendomain() (0) /* deprecated. remove this */8888+8989+#endif /* _ASM_IA64_XEN_HYPERVISOR_H */
···11+/******************************************************************************22+ * arch-ia64/hypervisor-if.h33+ *44+ * Guest OS interface to IA64 Xen.55+ *66+ * Permission is hereby granted, free of charge, to any person obtaining a copy77+ * of this software and associated documentation files (the "Software"), to88+ * deal in the Software without restriction, including without limitation the99+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or1010+ * sell copies of the Software, and to permit persons to whom the Software is1111+ * furnished to do so, subject to the following conditions:1212+ *1313+ * The above copyright notice and this permission notice shall be included in1414+ * all copies or substantial portions of the Software.1515+ *1616+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR1717+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,1818+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE1919+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER2020+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING2121+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER2222+ * DEALINGS IN THE SOFTWARE.2323+ *2424+ * Copyright by those who contributed. (in alphabetical order)2525+ *2626+ * Anthony Xu <anthony.xu@intel.com>2727+ * Eddie Dong <eddie.dong@intel.com>2828+ * Fred Yang <fred.yang@intel.com>2929+ * Kevin Tian <kevin.tian@intel.com>3030+ * Alex Williamson <alex.williamson@hp.com>3131+ * Chris Wright <chrisw@sous-sol.org>3232+ * Christian Limpach <Christian.Limpach@cl.cam.ac.uk>3333+ * Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>3434+ * Hollis Blanchard <hollisb@us.ibm.com>3535+ * Isaku Yamahata <yamahata@valinux.co.jp>3636+ * Jan Beulich <jbeulich@novell.com>3737+ * John Levon <john.levon@sun.com>3838+ * Kazuhiro Suzuki <kaz@jp.fujitsu.com>3939+ * Keir Fraser <keir.fraser@citrix.com>4040+ * Kouya Shimura <kouya@jp.fujitsu.com>4141+ * Masaki Kanno <kanno.masaki@jp.fujitsu.com>4242+ * Matt Chapman <matthewc@hp.com>4343+ * Matthew Chapman <matthewc@hp.com>4444+ * Samuel Thibault <samuel.thibault@eu.citrix.com>4545+ * Tomonari Horikoshi <t.horikoshi@jp.fujitsu.com>4646+ * Tristan Gingold <tgingold@free.fr>4747+ * Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>4848+ * Yutaka Ezaki <yutaka.ezaki@jp.fujitsu.com>4949+ * Zhang Xin <xing.z.zhang@intel.com>5050+ * Zhang xiantao <xiantao.zhang@intel.com>5151+ * dan.magenheimer@hp.com5252+ * ian.pratt@cl.cam.ac.uk5353+ * michael.fetterman@cl.cam.ac.uk5454+ */5555+5656+#ifndef _ASM_IA64_XEN_INTERFACE_H5757+#define _ASM_IA64_XEN_INTERFACE_H5858+5959+#define __DEFINE_GUEST_HANDLE(name, type) \6060+ typedef struct { type *p; } __guest_handle_ ## name6161+6262+#define DEFINE_GUEST_HANDLE_STRUCT(name) \6363+ __DEFINE_GUEST_HANDLE(name, struct name)6464+#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)6565+#define GUEST_HANDLE(name) __guest_handle_ ## name6666+#define GUEST_HANDLE_64(name) GUEST_HANDLE(name)6767+#define set_xen_guest_handle(hnd, val) do { (hnd).p = val; } while (0)6868+6969+#ifndef __ASSEMBLY__7070+/* Guest handles for primitive C types. */7171+__DEFINE_GUEST_HANDLE(uchar, unsigned char);7272+__DEFINE_GUEST_HANDLE(uint, unsigned int);7373+__DEFINE_GUEST_HANDLE(ulong, unsigned long);7474+__DEFINE_GUEST_HANDLE(u64, unsigned long);7575+DEFINE_GUEST_HANDLE(char);7676+DEFINE_GUEST_HANDLE(int);7777+DEFINE_GUEST_HANDLE(long);7878+DEFINE_GUEST_HANDLE(void);7979+8080+typedef unsigned long xen_pfn_t;8181+DEFINE_GUEST_HANDLE(xen_pfn_t);8282+#define PRI_xen_pfn "lx"8383+#endif8484+8585+/* Arch specific VIRQs definition */8686+#define VIRQ_ITC VIRQ_ARCH_0 /* V. Virtual itc timer */8787+#define VIRQ_MCA_CMC VIRQ_ARCH_1 /* MCA cmc interrupt */8888+#define VIRQ_MCA_CPE VIRQ_ARCH_2 /* MCA cpe interrupt */8989+9090+/* Maximum number of virtual CPUs in multi-processor guests. */9191+/* keep sizeof(struct shared_page) <= PAGE_SIZE.9292+ * this is checked in arch/ia64/xen/hypervisor.c. */9393+#define MAX_VIRT_CPUS 649494+9595+#ifndef __ASSEMBLY__9696+9797+#define INVALID_MFN (~0UL)9898+9999+union vac {100100+ unsigned long value;101101+ struct {102102+ int a_int:1;103103+ int a_from_int_cr:1;104104+ int a_to_int_cr:1;105105+ int a_from_psr:1;106106+ int a_from_cpuid:1;107107+ int a_cover:1;108108+ int a_bsw:1;109109+ long reserved:57;110110+ };111111+};112112+113113+union vdc {114114+ unsigned long value;115115+ struct {116116+ int d_vmsw:1;117117+ int d_extint:1;118118+ int d_ibr_dbr:1;119119+ int d_pmc:1;120120+ int d_to_pmd:1;121121+ int d_itm:1;122122+ long reserved:58;123123+ };124124+};125125+126126+struct mapped_regs {127127+ union vac vac;128128+ union vdc vdc;129129+ unsigned long virt_env_vaddr;130130+ unsigned long reserved1[29];131131+ unsigned long vhpi;132132+ unsigned long reserved2[95];133133+ union {134134+ unsigned long vgr[16];135135+ unsigned long bank1_regs[16]; /* bank1 regs (r16-r31)136136+ when bank0 active */137137+ };138138+ union {139139+ unsigned long vbgr[16];140140+ unsigned long bank0_regs[16]; /* bank0 regs (r16-r31)141141+ when bank1 active */142142+ };143143+ unsigned long vnat;144144+ unsigned long vbnat;145145+ unsigned long vcpuid[5];146146+ unsigned long reserved3[11];147147+ unsigned long vpsr;148148+ unsigned long vpr;149149+ unsigned long reserved4[76];150150+ union {151151+ unsigned long vcr[128];152152+ struct {153153+ unsigned long dcr; /* CR0 */154154+ unsigned long itm;155155+ unsigned long iva;156156+ unsigned long rsv1[5];157157+ unsigned long pta; /* CR8 */158158+ unsigned long rsv2[7];159159+ unsigned long ipsr; /* CR16 */160160+ unsigned long isr;161161+ unsigned long rsv3;162162+ unsigned long iip;163163+ unsigned long ifa;164164+ unsigned long itir;165165+ unsigned long iipa;166166+ unsigned long ifs;167167+ unsigned long iim; /* CR24 */168168+ unsigned long iha;169169+ unsigned long rsv4[38];170170+ unsigned long lid; /* CR64 */171171+ unsigned long ivr;172172+ unsigned long tpr;173173+ unsigned long eoi;174174+ unsigned long irr[4];175175+ unsigned long itv; /* CR72 */176176+ unsigned long pmv;177177+ unsigned long cmcv;178178+ unsigned long rsv5[5];179179+ unsigned long lrr0; /* CR80 */180180+ unsigned long lrr1;181181+ unsigned long rsv6[46];182182+ };183183+ };184184+ union {185185+ unsigned long reserved5[128];186186+ struct {187187+ unsigned long precover_ifs;188188+ unsigned long unat; /* not sure if this is needed189189+ until NaT arch is done */190190+ int interrupt_collection_enabled; /* virtual psr.ic */191191+192192+ /* virtual interrupt deliverable flag is193193+ * evtchn_upcall_mask in shared info area now.194194+ * interrupt_mask_addr is the address195195+ * of evtchn_upcall_mask for current vcpu196196+ */197197+ unsigned char *interrupt_mask_addr;198198+ int pending_interruption;199199+ unsigned char vpsr_pp;200200+ unsigned char vpsr_dfh;201201+ unsigned char hpsr_dfh;202202+ unsigned char hpsr_mfh;203203+ unsigned long reserved5_1[4];204204+ int metaphysical_mode; /* 1 = use metaphys mapping205205+ 0 = use virtual */206206+ int banknum; /* 0 or 1, which virtual207207+ register bank is active */208208+ unsigned long rrs[8]; /* region registers */209209+ unsigned long krs[8]; /* kernel registers */210210+ unsigned long tmp[16]; /* temp registers211211+ (e.g. for hyperprivops) */212212+ };213213+ };214214+};215215+216216+struct arch_vcpu_info {217217+ /* nothing */218218+};219219+220220+/*221221+ * This structure is used for magic page in domain pseudo physical address222222+ * space and the result of XENMEM_machine_memory_map.223223+ * As the XENMEM_machine_memory_map result,224224+ * xen_memory_map::nr_entries indicates the size in bytes225225+ * including struct xen_ia64_memmap_info. Not the number of entries.226226+ */227227+struct xen_ia64_memmap_info {228228+ uint64_t efi_memmap_size; /* size of EFI memory map */229229+ uint64_t efi_memdesc_size; /* size of an EFI memory map230230+ * descriptor */231231+ uint32_t efi_memdesc_version; /* memory descriptor version */232232+ void *memdesc[0]; /* array of efi_memory_desc_t */233233+};234234+235235+struct arch_shared_info {236236+ /* PFN of the start_info page. */237237+ unsigned long start_info_pfn;238238+239239+ /* Interrupt vector for event channel. */240240+ int evtchn_vector;241241+242242+ /* PFN of memmap_info page */243243+ unsigned int memmap_info_num_pages; /* currently only = 1 case is244244+ supported. */245245+ unsigned long memmap_info_pfn;246246+247247+ uint64_t pad[31];248248+};249249+250250+struct xen_callback {251251+ unsigned long ip;252252+};253253+typedef struct xen_callback xen_callback_t;254254+255255+#endif /* !__ASSEMBLY__ */256256+257257+/* Size of the shared_info area (this is not related to page size). */258258+#define XSI_SHIFT 14259259+#define XSI_SIZE (1 << XSI_SHIFT)260260+/* Log size of mapped_regs area (64 KB - only 4KB is used). */261261+#define XMAPPEDREGS_SHIFT 12262262+#define XMAPPEDREGS_SIZE (1 << XMAPPEDREGS_SHIFT)263263+/* Offset of XASI (Xen arch shared info) wrt XSI_BASE. */264264+#define XMAPPEDREGS_OFS XSI_SIZE265265+266266+/* Hyperprivops. */267267+#define HYPERPRIVOP_START 0x1268268+#define HYPERPRIVOP_RFI (HYPERPRIVOP_START + 0x0)269269+#define HYPERPRIVOP_RSM_DT (HYPERPRIVOP_START + 0x1)270270+#define HYPERPRIVOP_SSM_DT (HYPERPRIVOP_START + 0x2)271271+#define HYPERPRIVOP_COVER (HYPERPRIVOP_START + 0x3)272272+#define HYPERPRIVOP_ITC_D (HYPERPRIVOP_START + 0x4)273273+#define HYPERPRIVOP_ITC_I (HYPERPRIVOP_START + 0x5)274274+#define HYPERPRIVOP_SSM_I (HYPERPRIVOP_START + 0x6)275275+#define HYPERPRIVOP_GET_IVR (HYPERPRIVOP_START + 0x7)276276+#define HYPERPRIVOP_GET_TPR (HYPERPRIVOP_START + 0x8)277277+#define HYPERPRIVOP_SET_TPR (HYPERPRIVOP_START + 0x9)278278+#define HYPERPRIVOP_EOI (HYPERPRIVOP_START + 0xa)279279+#define HYPERPRIVOP_SET_ITM (HYPERPRIVOP_START + 0xb)280280+#define HYPERPRIVOP_THASH (HYPERPRIVOP_START + 0xc)281281+#define HYPERPRIVOP_PTC_GA (HYPERPRIVOP_START + 0xd)282282+#define HYPERPRIVOP_ITR_D (HYPERPRIVOP_START + 0xe)283283+#define HYPERPRIVOP_GET_RR (HYPERPRIVOP_START + 0xf)284284+#define HYPERPRIVOP_SET_RR (HYPERPRIVOP_START + 0x10)285285+#define HYPERPRIVOP_SET_KR (HYPERPRIVOP_START + 0x11)286286+#define HYPERPRIVOP_FC (HYPERPRIVOP_START + 0x12)287287+#define HYPERPRIVOP_GET_CPUID (HYPERPRIVOP_START + 0x13)288288+#define HYPERPRIVOP_GET_PMD (HYPERPRIVOP_START + 0x14)289289+#define HYPERPRIVOP_GET_EFLAG (HYPERPRIVOP_START + 0x15)290290+#define HYPERPRIVOP_SET_EFLAG (HYPERPRIVOP_START + 0x16)291291+#define HYPERPRIVOP_RSM_BE (HYPERPRIVOP_START + 0x17)292292+#define HYPERPRIVOP_GET_PSR (HYPERPRIVOP_START + 0x18)293293+#define HYPERPRIVOP_SET_RR0_TO_RR4 (HYPERPRIVOP_START + 0x19)294294+#define HYPERPRIVOP_MAX (0x1a)295295+296296+/* Fast and light hypercalls. */297297+#define __HYPERVISOR_ia64_fast_eoi __HYPERVISOR_arch_1298298+299299+/* Xencomm macros. */300300+#define XENCOMM_INLINE_MASK 0xf800000000000000UL301301+#define XENCOMM_INLINE_FLAG 0x8000000000000000UL302302+303303+#ifndef __ASSEMBLY__304304+305305+/*306306+ * Optimization features.307307+ * The hypervisor may do some special optimizations for guests. This hypercall308308+ * can be used to switch on/of these special optimizations.309309+ */310310+#define __HYPERVISOR_opt_feature 0x700UL311311+312312+#define XEN_IA64_OPTF_OFF 0x0313313+#define XEN_IA64_OPTF_ON 0x1314314+315315+/*316316+ * If this feature is switched on, the hypervisor inserts the317317+ * tlb entries without calling the guests traphandler.318318+ * This is useful in guests using region 7 for identity mapping319319+ * like the linux kernel does.320320+ */321321+#define XEN_IA64_OPTF_IDENT_MAP_REG7 1322322+323323+/* Identity mapping of region 4 addresses in HVM. */324324+#define XEN_IA64_OPTF_IDENT_MAP_REG4 2325325+326326+/* Identity mapping of region 5 addresses in HVM. */327327+#define XEN_IA64_OPTF_IDENT_MAP_REG5 3328328+329329+#define XEN_IA64_OPTF_IDENT_MAP_NOT_SET (0)330330+331331+struct xen_ia64_opt_feature {332332+ unsigned long cmd; /* Which feature */333333+ unsigned char on; /* Switch feature on/off */334334+ union {335335+ struct {336336+ /* The page protection bit mask of the pte.337337+ * This will be or'ed with the pte. */338338+ unsigned long pgprot;339339+ unsigned long key; /* A protection key for itir.*/340340+ };341341+ };342342+};343343+344344+#endif /* __ASSEMBLY__ */345345+346346+#endif /* _ASM_IA64_XEN_INTERFACE_H */
+44
arch/ia64/include/asm/xen/irq.h
···11+/******************************************************************************22+ * arch/ia64/include/asm/xen/irq.h33+ *44+ * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>55+ * VA Linux Systems Japan K.K.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License as published by99+ * the Free Software Foundation; either version 2 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This program is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515+ * GNU General Public License for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2020+ *2121+ */2222+2323+#ifndef _ASM_IA64_XEN_IRQ_H2424+#define _ASM_IA64_XEN_IRQ_H2525+2626+/*2727+ * The flat IRQ space is divided into two regions:2828+ * 1. A one-to-one mapping of real physical IRQs. This space is only used2929+ * if we have physical device-access privilege. This region is at the3030+ * start of the IRQ space so that existing device drivers do not need3131+ * to be modified to translate physical IRQ numbers into our IRQ space.3232+ * 3. A dynamic mapping of inter-domain and Xen-sourced virtual IRQs. These3333+ * are bound using the provided bind/unbind functions.3434+ */3535+3636+#define XEN_PIRQ_BASE 03737+#define XEN_NR_PIRQS 2563838+3939+#define XEN_DYNIRQ_BASE (XEN_PIRQ_BASE + XEN_NR_PIRQS)4040+#define XEN_NR_DYNIRQS (NR_CPUS * 8)4141+4242+#define XEN_NR_IRQS (XEN_NR_PIRQS + XEN_NR_DYNIRQS)4343+4444+#endif /* _ASM_IA64_XEN_IRQ_H */
+134
arch/ia64/include/asm/xen/minstate.h
···11+/*22+ * DO_SAVE_MIN switches to the kernel stacks (if necessary) and saves33+ * the minimum state necessary that allows us to turn psr.ic back44+ * on.55+ *66+ * Assumed state upon entry:77+ * psr.ic: off88+ * r31: contains saved predicates (pr)99+ *1010+ * Upon exit, the state is as follows:1111+ * psr.ic: off1212+ * r2 = points to &pt_regs.r161313+ * r8 = contents of ar.ccv1414+ * r9 = contents of ar.csd1515+ * r10 = contents of ar.ssd1616+ * r11 = FPSR_DEFAULT1717+ * r12 = kernel sp (kernel virtual address)1818+ * r13 = points to current task_struct (kernel virtual address)1919+ * p15 = TRUE if psr.i is set in cr.ipsr2020+ * predicate registers (other than p2, p3, and p15), b6, r3, r14, r15:2121+ * preserved2222+ * CONFIG_XEN note: p6/p7 are not preserved2323+ *2424+ * Note that psr.ic is NOT turned on by this macro. This is so that2525+ * we can pass interruption state as arguments to a handler.2626+ */2727+#define XEN_DO_SAVE_MIN(__COVER,SAVE_IFS,EXTRA,WORKAROUND) \2828+ mov r16=IA64_KR(CURRENT); /* M */ \2929+ mov r27=ar.rsc; /* M */ \3030+ mov r20=r1; /* A */ \3131+ mov r25=ar.unat; /* M */ \3232+ MOV_FROM_IPSR(p0,r29); /* M */ \3333+ MOV_FROM_IIP(r28); /* M */ \3434+ mov r21=ar.fpsr; /* M */ \3535+ mov r26=ar.pfs; /* I */ \3636+ __COVER; /* B;; (or nothing) */ \3737+ adds r16=IA64_TASK_THREAD_ON_USTACK_OFFSET,r16; \3838+ ;; \3939+ ld1 r17=[r16]; /* load current->thread.on_ustack flag */ \4040+ st1 [r16]=r0; /* clear current->thread.on_ustack flag */ \4141+ adds r1=-IA64_TASK_THREAD_ON_USTACK_OFFSET,r16 \4242+ /* switch from user to kernel RBS: */ \4343+ ;; \4444+ invala; /* M */ \4545+ /* SAVE_IFS;*/ /* see xen special handling below */ \4646+ cmp.eq pKStk,pUStk=r0,r17; /* are we in kernel mode already? */ \4747+ ;; \4848+(pUStk) mov ar.rsc=0; /* set enforced lazy mode, pl 0, little-endian, loadrs=0 */ \4949+ ;; \5050+(pUStk) mov.m r24=ar.rnat; \5151+(pUStk) addl r22=IA64_RBS_OFFSET,r1; /* compute base of RBS */ \5252+(pKStk) mov r1=sp; /* get sp */ \5353+ ;; \5454+(pUStk) lfetch.fault.excl.nt1 [r22]; \5555+(pUStk) addl r1=IA64_STK_OFFSET-IA64_PT_REGS_SIZE,r1; /* compute base of memory stack */ \5656+(pUStk) mov r23=ar.bspstore; /* save ar.bspstore */ \5757+ ;; \5858+(pUStk) mov ar.bspstore=r22; /* switch to kernel RBS */ \5959+(pKStk) addl r1=-IA64_PT_REGS_SIZE,r1; /* if in kernel mode, use sp (r12) */ \6060+ ;; \6161+(pUStk) mov r18=ar.bsp; \6262+(pUStk) mov ar.rsc=0x3; /* set eager mode, pl 0, little-endian, loadrs=0 */ \6363+ adds r17=2*L1_CACHE_BYTES,r1; /* really: biggest cache-line size */ \6464+ adds r16=PT(CR_IPSR),r1; \6565+ ;; \6666+ lfetch.fault.excl.nt1 [r17],L1_CACHE_BYTES; \6767+ st8 [r16]=r29; /* save cr.ipsr */ \6868+ ;; \6969+ lfetch.fault.excl.nt1 [r17]; \7070+ tbit.nz p15,p0=r29,IA64_PSR_I_BIT; \7171+ mov r29=b0 \7272+ ;; \7373+ WORKAROUND; \7474+ adds r16=PT(R8),r1; /* initialize first base pointer */ \7575+ adds r17=PT(R9),r1; /* initialize second base pointer */ \7676+(pKStk) mov r18=r0; /* make sure r18 isn't NaT */ \7777+ ;; \7878+.mem.offset 0,0; st8.spill [r16]=r8,16; \7979+.mem.offset 8,0; st8.spill [r17]=r9,16; \8080+ ;; \8181+.mem.offset 0,0; st8.spill [r16]=r10,24; \8282+ movl r8=XSI_PRECOVER_IFS; \8383+.mem.offset 8,0; st8.spill [r17]=r11,24; \8484+ ;; \8585+ /* xen special handling for possibly lazy cover */ \8686+ /* SAVE_MIN case in dispatch_ia32_handler: mov r30=r0 */ \8787+ ld8 r30=[r8]; \8888+(pUStk) sub r18=r18,r22; /* r18=RSE.ndirty*8 */ \8989+ st8 [r16]=r28,16; /* save cr.iip */ \9090+ ;; \9191+ st8 [r17]=r30,16; /* save cr.ifs */ \9292+ mov r8=ar.ccv; \9393+ mov r9=ar.csd; \9494+ mov r10=ar.ssd; \9595+ movl r11=FPSR_DEFAULT; /* L-unit */ \9696+ ;; \9797+ st8 [r16]=r25,16; /* save ar.unat */ \9898+ st8 [r17]=r26,16; /* save ar.pfs */ \9999+ shl r18=r18,16; /* compute ar.rsc to be used for "loadrs" */ \100100+ ;; \101101+ st8 [r16]=r27,16; /* save ar.rsc */ \102102+(pUStk) st8 [r17]=r24,16; /* save ar.rnat */ \103103+(pKStk) adds r17=16,r17; /* skip over ar_rnat field */ \104104+ ;; /* avoid RAW on r16 & r17 */ \105105+(pUStk) st8 [r16]=r23,16; /* save ar.bspstore */ \106106+ st8 [r17]=r31,16; /* save predicates */ \107107+(pKStk) adds r16=16,r16; /* skip over ar_bspstore field */ \108108+ ;; \109109+ st8 [r16]=r29,16; /* save b0 */ \110110+ st8 [r17]=r18,16; /* save ar.rsc value for "loadrs" */ \111111+ cmp.eq pNonSys,pSys=r0,r0 /* initialize pSys=0, pNonSys=1 */ \112112+ ;; \113113+.mem.offset 0,0; st8.spill [r16]=r20,16; /* save original r1 */ \114114+.mem.offset 8,0; st8.spill [r17]=r12,16; \115115+ adds r12=-16,r1; /* switch to kernel memory stack (with 16 bytes of scratch) */ \116116+ ;; \117117+.mem.offset 0,0; st8.spill [r16]=r13,16; \118118+.mem.offset 8,0; st8.spill [r17]=r21,16; /* save ar.fpsr */ \119119+ mov r13=IA64_KR(CURRENT); /* establish `current' */ \120120+ ;; \121121+.mem.offset 0,0; st8.spill [r16]=r15,16; \122122+.mem.offset 8,0; st8.spill [r17]=r14,16; \123123+ ;; \124124+.mem.offset 0,0; st8.spill [r16]=r2,16; \125125+.mem.offset 8,0; st8.spill [r17]=r3,16; \126126+ ACCOUNT_GET_STAMP \127127+ adds r2=IA64_PT_REGS_R16_OFFSET,r1; \128128+ ;; \129129+ EXTRA; \130130+ movl r1=__gp; /* establish kernel global pointer */ \131131+ ;; \132132+ ACCOUNT_SYS_ENTER \133133+ BSW_1(r3,r14); /* switch back to bank 1 (must be last in insn group) */ \134134+ ;;
+65
arch/ia64/include/asm/xen/page.h
···11+/******************************************************************************22+ * arch/ia64/include/asm/xen/page.h33+ *44+ * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>55+ * VA Linux Systems Japan K.K.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License as published by99+ * the Free Software Foundation; either version 2 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This program is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515+ * GNU General Public License for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2020+ *2121+ */2222+2323+#ifndef _ASM_IA64_XEN_PAGE_H2424+#define _ASM_IA64_XEN_PAGE_H2525+2626+#define INVALID_P2M_ENTRY (~0UL)2727+2828+static inline unsigned long mfn_to_pfn(unsigned long mfn)2929+{3030+ return mfn;3131+}3232+3333+static inline unsigned long pfn_to_mfn(unsigned long pfn)3434+{3535+ return pfn;3636+}3737+3838+#define phys_to_machine_mapping_valid(_x) (1)3939+4040+static inline void *mfn_to_virt(unsigned long mfn)4141+{4242+ return __va(mfn << PAGE_SHIFT);4343+}4444+4545+static inline unsigned long virt_to_mfn(void *virt)4646+{4747+ return __pa(virt) >> PAGE_SHIFT;4848+}4949+5050+/* for tpmfront.c */5151+static inline unsigned long virt_to_machine(void *virt)5252+{5353+ return __pa(virt);5454+}5555+5656+static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)5757+{5858+ /* nothing */5959+}6060+6161+#define pte_mfn(_x) pte_pfn(_x)6262+#define mfn_pte(_x, _y) __pte_ma(0) /* unmodified use */6363+#define __pte_ma(_x) ((pte_t) {(_x)}) /* unmodified use */6464+6565+#endif /* _ASM_IA64_XEN_PAGE_H */
+129
arch/ia64/include/asm/xen/privop.h
···11+#ifndef _ASM_IA64_XEN_PRIVOP_H22+#define _ASM_IA64_XEN_PRIVOP_H33+44+/*55+ * Copyright (C) 2005 Hewlett-Packard Co66+ * Dan Magenheimer <dan.magenheimer@hp.com>77+ *88+ * Paravirtualizations of privileged operations for Xen/ia6499+ *1010+ *1111+ * inline privop and paravirt_alt support1212+ * Copyright (c) 2007 Isaku Yamahata <yamahata at valinux co jp>1313+ * VA Linux Systems Japan K.K.1414+ *1515+ */1616+1717+#ifndef __ASSEMBLY__1818+#include <linux/types.h> /* arch-ia64.h requires uint64_t */1919+#endif2020+#include <asm/xen/interface.h>2121+2222+/* At 1 MB, before per-cpu space but still addressable using addl instead2323+ of movl. */2424+#define XSI_BASE 0xfffffffffff000002525+2626+/* Address of mapped regs. */2727+#define XMAPPEDREGS_BASE (XSI_BASE + XSI_SIZE)2828+2929+#ifdef __ASSEMBLY__3030+#define XEN_HYPER_RFI break HYPERPRIVOP_RFI3131+#define XEN_HYPER_RSM_PSR_DT break HYPERPRIVOP_RSM_DT3232+#define XEN_HYPER_SSM_PSR_DT break HYPERPRIVOP_SSM_DT3333+#define XEN_HYPER_COVER break HYPERPRIVOP_COVER3434+#define XEN_HYPER_ITC_D break HYPERPRIVOP_ITC_D3535+#define XEN_HYPER_ITC_I break HYPERPRIVOP_ITC_I3636+#define XEN_HYPER_SSM_I break HYPERPRIVOP_SSM_I3737+#define XEN_HYPER_GET_IVR break HYPERPRIVOP_GET_IVR3838+#define XEN_HYPER_THASH break HYPERPRIVOP_THASH3939+#define XEN_HYPER_ITR_D break HYPERPRIVOP_ITR_D4040+#define XEN_HYPER_SET_KR break HYPERPRIVOP_SET_KR4141+#define XEN_HYPER_GET_PSR break HYPERPRIVOP_GET_PSR4242+#define XEN_HYPER_SET_RR0_TO_RR4 break HYPERPRIVOP_SET_RR0_TO_RR44343+4444+#define XSI_IFS (XSI_BASE + XSI_IFS_OFS)4545+#define XSI_PRECOVER_IFS (XSI_BASE + XSI_PRECOVER_IFS_OFS)4646+#define XSI_IFA (XSI_BASE + XSI_IFA_OFS)4747+#define XSI_ISR (XSI_BASE + XSI_ISR_OFS)4848+#define XSI_IIM (XSI_BASE + XSI_IIM_OFS)4949+#define XSI_ITIR (XSI_BASE + XSI_ITIR_OFS)5050+#define XSI_PSR_I_ADDR (XSI_BASE + XSI_PSR_I_ADDR_OFS)5151+#define XSI_PSR_IC (XSI_BASE + XSI_PSR_IC_OFS)5252+#define XSI_IPSR (XSI_BASE + XSI_IPSR_OFS)5353+#define XSI_IIP (XSI_BASE + XSI_IIP_OFS)5454+#define XSI_B1NAT (XSI_BASE + XSI_B1NATS_OFS)5555+#define XSI_BANK1_R16 (XSI_BASE + XSI_BANK1_R16_OFS)5656+#define XSI_BANKNUM (XSI_BASE + XSI_BANKNUM_OFS)5757+#define XSI_IHA (XSI_BASE + XSI_IHA_OFS)5858+#endif5959+6060+#ifndef __ASSEMBLY__6161+6262+/************************************************/6363+/* Instructions paravirtualized for correctness */6464+/************************************************/6565+6666+/* "fc" and "thash" are privilege-sensitive instructions, meaning they6767+ * may have different semantics depending on whether they are executed6868+ * at PL0 vs PL!=0. When paravirtualized, these instructions mustn't6969+ * be allowed to execute directly, lest incorrect semantics result. */7070+extern void xen_fc(unsigned long addr);7171+extern unsigned long xen_thash(unsigned long addr);7272+7373+/* Note that "ttag" and "cover" are also privilege-sensitive; "ttag"7474+ * is not currently used (though it may be in a long-format VHPT system!)7575+ * and the semantics of cover only change if psr.ic is off which is very7676+ * rare (and currently non-existent outside of assembly code */7777+7878+/* There are also privilege-sensitive registers. These registers are7979+ * readable at any privilege level but only writable at PL0. */8080+extern unsigned long xen_get_cpuid(int index);8181+extern unsigned long xen_get_pmd(int index);8282+8383+extern unsigned long xen_get_eflag(void); /* see xen_ia64_getreg */8484+extern void xen_set_eflag(unsigned long); /* see xen_ia64_setreg */8585+8686+/************************************************/8787+/* Instructions paravirtualized for performance */8888+/************************************************/8989+9090+/* Xen uses memory-mapped virtual privileged registers for access to many9191+ * performance-sensitive privileged registers. Some, like the processor9292+ * status register (psr), are broken up into multiple memory locations.9393+ * Others, like "pend", are abstractions based on privileged registers.9494+ * "Pend" is guaranteed to be set if reading cr.ivr would return a9595+ * (non-spurious) interrupt. */9696+#define XEN_MAPPEDREGS ((struct mapped_regs *)XMAPPEDREGS_BASE)9797+9898+#define XSI_PSR_I \9999+ (*XEN_MAPPEDREGS->interrupt_mask_addr)100100+#define xen_get_virtual_psr_i() \101101+ (!XSI_PSR_I)102102+#define xen_set_virtual_psr_i(_val) \103103+ ({ XSI_PSR_I = (uint8_t)(_val) ? 0 : 1; })104104+#define xen_set_virtual_psr_ic(_val) \105105+ ({ XEN_MAPPEDREGS->interrupt_collection_enabled = _val ? 1 : 0; })106106+#define xen_get_virtual_pend() \107107+ (*(((uint8_t *)XEN_MAPPEDREGS->interrupt_mask_addr) - 1))108108+109109+/* Although all privileged operations can be left to trap and will110110+ * be properly handled by Xen, some are frequent enough that we use111111+ * hyperprivops for performance. */112112+extern unsigned long xen_get_psr(void);113113+extern unsigned long xen_get_ivr(void);114114+extern unsigned long xen_get_tpr(void);115115+extern void xen_hyper_ssm_i(void);116116+extern void xen_set_itm(unsigned long);117117+extern void xen_set_tpr(unsigned long);118118+extern void xen_eoi(unsigned long);119119+extern unsigned long xen_get_rr(unsigned long index);120120+extern void xen_set_rr(unsigned long index, unsigned long val);121121+extern void xen_set_rr0_to_rr4(unsigned long val0, unsigned long val1,122122+ unsigned long val2, unsigned long val3,123123+ unsigned long val4);124124+extern void xen_set_kr(unsigned long index, unsigned long val);125125+extern void xen_ptcga(unsigned long addr, unsigned long size);126126+127127+#endif /* !__ASSEMBLY__ */128128+129129+#endif /* _ASM_IA64_XEN_PRIVOP_H */
+51
arch/ia64/include/asm/xen/xcom_hcall.h
···11+/*22+ * Copyright (C) 2006 Tristan Gingold <tristan.gingold@bull.net>, Bull SAS33+ *44+ * This program is free software; you can redistribute it and/or modify55+ * it under the terms of the GNU General Public License as published by66+ * the Free Software Foundation; either version 2 of the License, or77+ * (at your option) any later version.88+ *99+ * This program is distributed in the hope that it will be useful,1010+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1111+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1212+ * GNU General Public License for more details.1313+ *1414+ * You should have received a copy of the GNU General Public License1515+ * along with this program; if not, write to the Free Software1616+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA1717+ */1818+1919+#ifndef _ASM_IA64_XEN_XCOM_HCALL_H2020+#define _ASM_IA64_XEN_XCOM_HCALL_H2121+2222+/* These function creates inline or mini descriptor for the parameters and2323+ calls the corresponding xencomm_arch_hypercall_X.2424+ Architectures should defines HYPERVISOR_xxx as xencomm_hypercall_xxx unless2525+ they want to use their own wrapper. */2626+extern int xencomm_hypercall_console_io(int cmd, int count, char *str);2727+2828+extern int xencomm_hypercall_event_channel_op(int cmd, void *op);2929+3030+extern int xencomm_hypercall_xen_version(int cmd, void *arg);3131+3232+extern int xencomm_hypercall_physdev_op(int cmd, void *op);3333+3434+extern int xencomm_hypercall_grant_table_op(unsigned int cmd, void *op,3535+ unsigned int count);3636+3737+extern int xencomm_hypercall_sched_op(int cmd, void *arg);3838+3939+extern int xencomm_hypercall_multicall(void *call_list, int nr_calls);4040+4141+extern int xencomm_hypercall_callback_op(int cmd, void *arg);4242+4343+extern int xencomm_hypercall_memory_op(unsigned int cmd, void *arg);4444+4545+extern int xencomm_hypercall_suspend(unsigned long srec);4646+4747+extern long xencomm_hypercall_vcpu_op(int cmd, int cpu, void *arg);4848+4949+extern long xencomm_hypercall_opt_feature(void *arg);5050+5151+#endif /* _ASM_IA64_XEN_XCOM_HCALL_H */
+42
arch/ia64/include/asm/xen/xencomm.h
···11+/*22+ * Copyright (C) 2006 Hollis Blanchard <hollisb@us.ibm.com>, IBM Corporation33+ *44+ * This program is free software; you can redistribute it and/or modify55+ * it under the terms of the GNU General Public License as published by66+ * the Free Software Foundation; either version 2 of the License, or77+ * (at your option) any later version.88+ *99+ * This program is distributed in the hope that it will be useful,1010+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1111+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1212+ * GNU General Public License for more details.1313+ *1414+ * You should have received a copy of the GNU General Public License1515+ * along with this program; if not, write to the Free Software1616+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA1717+ */1818+1919+#ifndef _ASM_IA64_XEN_XENCOMM_H2020+#define _ASM_IA64_XEN_XENCOMM_H2121+2222+#include <xen/xencomm.h>2323+#include <asm/pgtable.h>2424+2525+/* Must be called before any hypercall. */2626+extern void xencomm_initialize(void);2727+extern int xencomm_is_initialized(void);2828+2929+/* Check if virtual contiguity means physical contiguity3030+ * where the passed address is a pointer value in virtual address.3131+ * On ia64, identity mapping area in region 7 or the piece of region 53232+ * that is mapped by itr[IA64_TR_KERNEL]/dtr[IA64_TR_KERNEL]3333+ */3434+static inline int xencomm_is_phys_contiguous(unsigned long addr)3535+{3636+ return (PAGE_OFFSET <= addr &&3737+ addr < (PAGE_OFFSET + (1UL << IA64_MAX_PHYS_BITS))) ||3838+ (KERNEL_START <= addr &&3939+ addr < KERNEL_START + KERNEL_TR_PAGE_SIZE);4040+}4141+4242+#endif /* _ASM_IA64_XEN_XENCOMM_H */
···242242/* We don't actually take CPU down, just spin without interrupts. */243243static inline void play_dead(void)244244{245245- extern void ia64_cpu_local_tick (void);246245 unsigned int this_cpu = smp_processor_id();247246248247 /* Ack it */
+32
arch/ia64/scripts/pvcheck.sed
···11+#22+# Checker for paravirtualizations of privileged operations.33+#44+s/ssm.*psr\.ic.*/.warning \"ssm psr.ic should not be used directly\"/g55+s/rsm.*psr\.ic.*/.warning \"rsm psr.ic should not be used directly\"/g66+s/ssm.*psr\.i.*/.warning \"ssm psr.i should not be used directly\"/g77+s/rsm.*psr\.i.*/.warning \"rsm psr.i should not be used directly\"/g88+s/ssm.*psr\.dt.*/.warning \"ssm psr.dt should not be used directly\"/g99+s/rsm.*psr\.dt.*/.warning \"rsm psr.dt should not be used directly\"/g1010+s/mov.*=.*cr\.ifa/.warning \"cr.ifa should not used directly\"/g1111+s/mov.*=.*cr\.itir/.warning \"cr.itir should not used directly\"/g1212+s/mov.*=.*cr\.isr/.warning \"cr.isr should not used directly\"/g1313+s/mov.*=.*cr\.iha/.warning \"cr.iha should not used directly\"/g1414+s/mov.*=.*cr\.ipsr/.warning \"cr.ipsr should not used directly\"/g1515+s/mov.*=.*cr\.iim/.warning \"cr.iim should not used directly\"/g1616+s/mov.*=.*cr\.iip/.warning \"cr.iip should not used directly\"/g1717+s/mov.*=.*cr\.ivr/.warning \"cr.ivr should not used directly\"/g1818+s/mov.*=[^\.]*psr/.warning \"psr should not used directly\"/g # avoid ar.fpsr1919+s/mov.*=.*ar\.eflags/.warning \"ar.eflags should not used directly\"/g2020+s/mov.*cr\.ifa.*=.*/.warning \"cr.ifa should not used directly\"/g2121+s/mov.*cr\.itir.*=.*/.warning \"cr.itir should not used directly\"/g2222+s/mov.*cr\.iha.*=.*/.warning \"cr.iha should not used directly\"/g2323+s/mov.*cr\.ipsr.*=.*/.warning \"cr.ipsr should not used directly\"/g2424+s/mov.*cr\.ifs.*=.*/.warning \"cr.ifs should not used directly\"/g2525+s/mov.*cr\.iip.*=.*/.warning \"cr.iip should not used directly\"/g2626+s/mov.*cr\.kr.*=.*/.warning \"cr.kr should not used directly\"/g2727+s/mov.*ar\.eflags.*=.*/.warning \"ar.eflags should not used directly\"/g2828+s/itc\.i.*/.warning \"itc.i should not be used directly.\"/g2929+s/itc\.d.*/.warning \"itc.d should not be used directly.\"/g3030+s/bsw\.0/.warning \"bsw.0 should not be used directly.\"/g3131+s/bsw\.1/.warning \"bsw.1 should not be used directly.\"/g3232+s/ptc\.ga.*/.warning \"ptc.ga should not be used directly.\"/g
+26
arch/ia64/xen/Kconfig
···11+#22+# This Kconfig describes xen/ia64 options33+#44+55+config XEN66+ bool "Xen hypervisor support"77+ default y88+ depends on PARAVIRT && MCKINLEY && IA64_PAGE_SIZE_16KB && EXPERIMENTAL99+ select XEN_XENCOMM1010+ select NO_IDLE_HZ1111+1212+ # those are required to save/restore.1313+ select ARCH_SUSPEND_POSSIBLE1414+ select SUSPEND1515+ select PM_SLEEP1616+ help1717+ Enable Xen hypervisor support. Resulting kernel runs1818+ both as a guest OS on Xen and natively on hardware.1919+2020+config XEN_XENCOMM2121+ depends on XEN2222+ bool2323+2424+config NO_IDLE_HZ2525+ depends on XEN2626+ bool
···11+/******************************************************************************22+ * arch/ia64/xen/grant-table.c33+ *44+ * Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp>55+ * VA Linux Systems Japan K.K.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License as published by99+ * the Free Software Foundation; either version 2 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This program is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515+ * GNU General Public License for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2020+ *2121+ */2222+2323+#include <linux/module.h>2424+#include <linux/vmalloc.h>2525+#include <linux/mm.h>2626+2727+#include <xen/interface/xen.h>2828+#include <xen/interface/memory.h>2929+#include <xen/grant_table.h>3030+3131+#include <asm/xen/hypervisor.h>3232+3333+struct vm_struct *xen_alloc_vm_area(unsigned long size)3434+{3535+ int order;3636+ unsigned long virt;3737+ unsigned long nr_pages;3838+ struct vm_struct *area;3939+4040+ order = get_order(size);4141+ virt = __get_free_pages(GFP_KERNEL, order);4242+ if (virt == 0)4343+ goto err0;4444+ nr_pages = 1 << order;4545+ scrub_pages(virt, nr_pages);4646+4747+ area = kmalloc(sizeof(*area), GFP_KERNEL);4848+ if (area == NULL)4949+ goto err1;5050+5151+ area->flags = VM_IOREMAP;5252+ area->addr = (void *)virt;5353+ area->size = size;5454+ area->pages = NULL;5555+ area->nr_pages = nr_pages;5656+ area->phys_addr = 0; /* xenbus_map_ring_valloc uses this field! */5757+5858+ return area;5959+6060+err1:6161+ free_pages(virt, order);6262+err0:6363+ return NULL;6464+}6565+EXPORT_SYMBOL_GPL(xen_alloc_vm_area);6666+6767+void xen_free_vm_area(struct vm_struct *area)6868+{6969+ unsigned int order = get_order(area->size);7070+ unsigned long i;7171+ unsigned long phys_addr = __pa(area->addr);7272+7373+ /* This area is used for foreign page mappping.7474+ * So underlying machine page may not be assigned. */7575+ for (i = 0; i < (1 << order); i++) {7676+ unsigned long ret;7777+ unsigned long gpfn = (phys_addr >> PAGE_SHIFT) + i;7878+ struct xen_memory_reservation reservation = {7979+ .nr_extents = 1,8080+ .address_bits = 0,8181+ .extent_order = 0,8282+ .domid = DOMID_SELF8383+ };8484+ set_xen_guest_handle(reservation.extent_start, &gpfn);8585+ ret = HYPERVISOR_memory_op(XENMEM_populate_physmap,8686+ &reservation);8787+ BUG_ON(ret != 1);8888+ }8989+ free_pages((unsigned long)area->addr, order);9090+ kfree(area);9191+}9292+EXPORT_SYMBOL_GPL(xen_free_vm_area);9393+9494+9595+/****************************************************************************9696+ * grant table hack9797+ * cmd: GNTTABOP_xxx9898+ */9999+100100+int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes,101101+ unsigned long max_nr_gframes,102102+ struct grant_entry **__shared)103103+{104104+ *__shared = __va(frames[0] << PAGE_SHIFT);105105+ return 0;106106+}107107+108108+void arch_gnttab_unmap_shared(struct grant_entry *shared,109109+ unsigned long nr_gframes)110110+{111111+ /* nothing */112112+}113113+114114+static void115115+gnttab_map_grant_ref_pre(struct gnttab_map_grant_ref *uop)116116+{117117+ uint32_t flags;118118+119119+ flags = uop->flags;120120+121121+ if (flags & GNTMAP_host_map) {122122+ if (flags & GNTMAP_application_map) {123123+ printk(KERN_DEBUG124124+ "GNTMAP_application_map is not supported yet: "125125+ "flags 0x%x\n", flags);126126+ BUG();127127+ }128128+ if (flags & GNTMAP_contains_pte) {129129+ printk(KERN_DEBUG130130+ "GNTMAP_contains_pte is not supported yet: "131131+ "flags 0x%x\n", flags);132132+ BUG();133133+ }134134+ } else if (flags & GNTMAP_device_map) {135135+ printk("GNTMAP_device_map is not supported yet 0x%x\n", flags);136136+ BUG(); /* not yet. actually this flag is not used. */137137+ } else {138138+ BUG();139139+ }140140+}141141+142142+int143143+HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count)144144+{145145+ if (cmd == GNTTABOP_map_grant_ref) {146146+ unsigned int i;147147+ for (i = 0; i < count; i++) {148148+ gnttab_map_grant_ref_pre(149149+ (struct gnttab_map_grant_ref *)uop + i);150150+ }151151+ }152152+ return xencomm_hypercall_grant_table_op(cmd, uop, count);153153+}154154+155155+EXPORT_SYMBOL(HYPERVISOR_grant_table_op);
···11+/******************************************************************************22+ * arch/ia64/xen/hypervisor.c33+ *44+ * Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp>55+ * VA Linux Systems Japan K.K.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License as published by99+ * the Free Software Foundation; either version 2 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This program is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515+ * GNU General Public License for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2020+ *2121+ */2222+2323+#include <linux/efi.h>2424+#include <asm/xen/hypervisor.h>2525+#include <asm/xen/privop.h>2626+2727+#include "irq_xen.h"2828+2929+struct shared_info *HYPERVISOR_shared_info __read_mostly =3030+ (struct shared_info *)XSI_BASE;3131+EXPORT_SYMBOL(HYPERVISOR_shared_info);3232+3333+DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);3434+3535+struct start_info *xen_start_info;3636+EXPORT_SYMBOL(xen_start_info);3737+3838+EXPORT_SYMBOL(xen_domain_type);3939+4040+EXPORT_SYMBOL(__hypercall);4141+4242+/* Stolen from arch/x86/xen/enlighten.c */4343+/*4444+ * Flag to determine whether vcpu info placement is available on all4545+ * VCPUs. We assume it is to start with, and then set it to zero on4646+ * the first failure. This is because it can succeed on some VCPUs4747+ * and not others, since it can involve hypervisor memory allocation,4848+ * or because the guest failed to guarantee all the appropriate4949+ * constraints on all VCPUs (ie buffer can't cross a page boundary).5050+ *5151+ * Note that any particular CPU may be using a placed vcpu structure,5252+ * but we can only optimise if the all are.5353+ *5454+ * 0: not available, 1: available5555+ */5656+5757+static void __init xen_vcpu_setup(int cpu)5858+{5959+ /*6060+ * WARNING:6161+ * before changing MAX_VIRT_CPUS,6262+ * check that shared_info fits on a page6363+ */6464+ BUILD_BUG_ON(sizeof(struct shared_info) > PAGE_SIZE);6565+ per_cpu(xen_vcpu, cpu) = &HYPERVISOR_shared_info->vcpu_info[cpu];6666+}6767+6868+void __init xen_setup_vcpu_info_placement(void)6969+{7070+ int cpu;7171+7272+ for_each_possible_cpu(cpu)7373+ xen_vcpu_setup(cpu);7474+}7575+7676+void __cpuinit7777+xen_cpu_init(void)7878+{7979+ xen_smp_intr_init();8080+}8181+8282+/**************************************************************************8383+ * opt feature8484+ */8585+void8686+xen_ia64_enable_opt_feature(void)8787+{8888+ /* Enable region 7 identity map optimizations in Xen */8989+ struct xen_ia64_opt_feature optf;9090+9191+ optf.cmd = XEN_IA64_OPTF_IDENT_MAP_REG7;9292+ optf.on = XEN_IA64_OPTF_ON;9393+ optf.pgprot = pgprot_val(PAGE_KERNEL);9494+ optf.key = 0; /* No key on linux. */9595+ HYPERVISOR_opt_feature(&optf);9696+}
+435
arch/ia64/xen/irq_xen.c
···11+/******************************************************************************22+ * arch/ia64/xen/irq_xen.c33+ *44+ * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>55+ * VA Linux Systems Japan K.K.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License as published by99+ * the Free Software Foundation; either version 2 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This program is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515+ * GNU General Public License for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2020+ *2121+ */2222+2323+#include <linux/cpu.h>2424+2525+#include <xen/interface/xen.h>2626+#include <xen/interface/callback.h>2727+#include <xen/events.h>2828+2929+#include <asm/xen/privop.h>3030+3131+#include "irq_xen.h"3232+3333+/***************************************************************************3434+ * pv_irq_ops3535+ * irq operations3636+ */3737+3838+static int3939+xen_assign_irq_vector(int irq)4040+{4141+ struct physdev_irq irq_op;4242+4343+ irq_op.irq = irq;4444+ if (HYPERVISOR_physdev_op(PHYSDEVOP_alloc_irq_vector, &irq_op))4545+ return -ENOSPC;4646+4747+ return irq_op.vector;4848+}4949+5050+static void5151+xen_free_irq_vector(int vector)5252+{5353+ struct physdev_irq irq_op;5454+5555+ if (vector < IA64_FIRST_DEVICE_VECTOR ||5656+ vector > IA64_LAST_DEVICE_VECTOR)5757+ return;5858+5959+ irq_op.vector = vector;6060+ if (HYPERVISOR_physdev_op(PHYSDEVOP_free_irq_vector, &irq_op))6161+ printk(KERN_WARNING "%s: xen_free_irq_vecotr fail vector=%d\n",6262+ __func__, vector);6363+}6464+6565+6666+static DEFINE_PER_CPU(int, timer_irq) = -1;6767+static DEFINE_PER_CPU(int, ipi_irq) = -1;6868+static DEFINE_PER_CPU(int, resched_irq) = -1;6969+static DEFINE_PER_CPU(int, cmc_irq) = -1;7070+static DEFINE_PER_CPU(int, cmcp_irq) = -1;7171+static DEFINE_PER_CPU(int, cpep_irq) = -1;7272+#define NAME_SIZE 157373+static DEFINE_PER_CPU(char[NAME_SIZE], timer_name);7474+static DEFINE_PER_CPU(char[NAME_SIZE], ipi_name);7575+static DEFINE_PER_CPU(char[NAME_SIZE], resched_name);7676+static DEFINE_PER_CPU(char[NAME_SIZE], cmc_name);7777+static DEFINE_PER_CPU(char[NAME_SIZE], cmcp_name);7878+static DEFINE_PER_CPU(char[NAME_SIZE], cpep_name);7979+#undef NAME_SIZE8080+8181+struct saved_irq {8282+ unsigned int irq;8383+ struct irqaction *action;8484+};8585+/* 16 should be far optimistic value, since only several percpu irqs8686+ * are registered early.8787+ */8888+#define MAX_LATE_IRQ 168989+static struct saved_irq saved_percpu_irqs[MAX_LATE_IRQ];9090+static unsigned short late_irq_cnt;9191+static unsigned short saved_irq_cnt;9292+static int xen_slab_ready;9393+9494+#ifdef CONFIG_SMP9595+/* Dummy stub. Though we may check XEN_RESCHEDULE_VECTOR before __do_IRQ,9696+ * it ends up to issue several memory accesses upon percpu data and9797+ * thus adds unnecessary traffic to other paths.9898+ */9999+static irqreturn_t100100+xen_dummy_handler(int irq, void *dev_id)101101+{102102+103103+ return IRQ_HANDLED;104104+}105105+106106+static struct irqaction xen_ipi_irqaction = {107107+ .handler = handle_IPI,108108+ .flags = IRQF_DISABLED,109109+ .name = "IPI"110110+};111111+112112+static struct irqaction xen_resched_irqaction = {113113+ .handler = xen_dummy_handler,114114+ .flags = IRQF_DISABLED,115115+ .name = "resched"116116+};117117+118118+static struct irqaction xen_tlb_irqaction = {119119+ .handler = xen_dummy_handler,120120+ .flags = IRQF_DISABLED,121121+ .name = "tlb_flush"122122+};123123+#endif124124+125125+/*126126+ * This is xen version percpu irq registration, which needs bind127127+ * to xen specific evtchn sub-system. One trick here is that xen128128+ * evtchn binding interface depends on kmalloc because related129129+ * port needs to be freed at device/cpu down. So we cache the130130+ * registration on BSP before slab is ready and then deal them131131+ * at later point. For rest instances happening after slab ready,132132+ * we hook them to xen evtchn immediately.133133+ *134134+ * FIXME: MCA is not supported by far, and thus "nomca" boot param is135135+ * required.136136+ */137137+static void138138+__xen_register_percpu_irq(unsigned int cpu, unsigned int vec,139139+ struct irqaction *action, int save)140140+{141141+ irq_desc_t *desc;142142+ int irq = 0;143143+144144+ if (xen_slab_ready) {145145+ switch (vec) {146146+ case IA64_TIMER_VECTOR:147147+ snprintf(per_cpu(timer_name, cpu),148148+ sizeof(per_cpu(timer_name, cpu)),149149+ "%s%d", action->name, cpu);150150+ irq = bind_virq_to_irqhandler(VIRQ_ITC, cpu,151151+ action->handler, action->flags,152152+ per_cpu(timer_name, cpu), action->dev_id);153153+ per_cpu(timer_irq, cpu) = irq;154154+ break;155155+ case IA64_IPI_RESCHEDULE:156156+ snprintf(per_cpu(resched_name, cpu),157157+ sizeof(per_cpu(resched_name, cpu)),158158+ "%s%d", action->name, cpu);159159+ irq = bind_ipi_to_irqhandler(XEN_RESCHEDULE_VECTOR, cpu,160160+ action->handler, action->flags,161161+ per_cpu(resched_name, cpu), action->dev_id);162162+ per_cpu(resched_irq, cpu) = irq;163163+ break;164164+ case IA64_IPI_VECTOR:165165+ snprintf(per_cpu(ipi_name, cpu),166166+ sizeof(per_cpu(ipi_name, cpu)),167167+ "%s%d", action->name, cpu);168168+ irq = bind_ipi_to_irqhandler(XEN_IPI_VECTOR, cpu,169169+ action->handler, action->flags,170170+ per_cpu(ipi_name, cpu), action->dev_id);171171+ per_cpu(ipi_irq, cpu) = irq;172172+ break;173173+ case IA64_CMC_VECTOR:174174+ snprintf(per_cpu(cmc_name, cpu),175175+ sizeof(per_cpu(cmc_name, cpu)),176176+ "%s%d", action->name, cpu);177177+ irq = bind_virq_to_irqhandler(VIRQ_MCA_CMC, cpu,178178+ action->handler,179179+ action->flags,180180+ per_cpu(cmc_name, cpu),181181+ action->dev_id);182182+ per_cpu(cmc_irq, cpu) = irq;183183+ break;184184+ case IA64_CMCP_VECTOR:185185+ snprintf(per_cpu(cmcp_name, cpu),186186+ sizeof(per_cpu(cmcp_name, cpu)),187187+ "%s%d", action->name, cpu);188188+ irq = bind_ipi_to_irqhandler(XEN_CMCP_VECTOR, cpu,189189+ action->handler,190190+ action->flags,191191+ per_cpu(cmcp_name, cpu),192192+ action->dev_id);193193+ per_cpu(cmcp_irq, cpu) = irq;194194+ break;195195+ case IA64_CPEP_VECTOR:196196+ snprintf(per_cpu(cpep_name, cpu),197197+ sizeof(per_cpu(cpep_name, cpu)),198198+ "%s%d", action->name, cpu);199199+ irq = bind_ipi_to_irqhandler(XEN_CPEP_VECTOR, cpu,200200+ action->handler,201201+ action->flags,202202+ per_cpu(cpep_name, cpu),203203+ action->dev_id);204204+ per_cpu(cpep_irq, cpu) = irq;205205+ break;206206+ case IA64_CPE_VECTOR:207207+ case IA64_MCA_RENDEZ_VECTOR:208208+ case IA64_PERFMON_VECTOR:209209+ case IA64_MCA_WAKEUP_VECTOR:210210+ case IA64_SPURIOUS_INT_VECTOR:211211+ /* No need to complain, these aren't supported. */212212+ break;213213+ default:214214+ printk(KERN_WARNING "Percpu irq %d is unsupported "215215+ "by xen!\n", vec);216216+ break;217217+ }218218+ BUG_ON(irq < 0);219219+220220+ if (irq > 0) {221221+ /*222222+ * Mark percpu. Without this, migrate_irqs() will223223+ * mark the interrupt for migrations and trigger it224224+ * on cpu hotplug.225225+ */226226+ desc = irq_desc + irq;227227+ desc->status |= IRQ_PER_CPU;228228+ }229229+ }230230+231231+ /* For BSP, we cache registered percpu irqs, and then re-walk232232+ * them when initializing APs233233+ */234234+ if (!cpu && save) {235235+ BUG_ON(saved_irq_cnt == MAX_LATE_IRQ);236236+ saved_percpu_irqs[saved_irq_cnt].irq = vec;237237+ saved_percpu_irqs[saved_irq_cnt].action = action;238238+ saved_irq_cnt++;239239+ if (!xen_slab_ready)240240+ late_irq_cnt++;241241+ }242242+}243243+244244+static void245245+xen_register_percpu_irq(ia64_vector vec, struct irqaction *action)246246+{247247+ __xen_register_percpu_irq(smp_processor_id(), vec, action, 1);248248+}249249+250250+static void251251+xen_bind_early_percpu_irq(void)252252+{253253+ int i;254254+255255+ xen_slab_ready = 1;256256+ /* There's no race when accessing this cached array, since only257257+ * BSP will face with such step shortly258258+ */259259+ for (i = 0; i < late_irq_cnt; i++)260260+ __xen_register_percpu_irq(smp_processor_id(),261261+ saved_percpu_irqs[i].irq,262262+ saved_percpu_irqs[i].action, 0);263263+}264264+265265+/* FIXME: There's no obvious point to check whether slab is ready. So266266+ * a hack is used here by utilizing a late time hook.267267+ */268268+269269+#ifdef CONFIG_HOTPLUG_CPU270270+static int __devinit271271+unbind_evtchn_callback(struct notifier_block *nfb,272272+ unsigned long action, void *hcpu)273273+{274274+ unsigned int cpu = (unsigned long)hcpu;275275+276276+ if (action == CPU_DEAD) {277277+ /* Unregister evtchn. */278278+ if (per_cpu(cpep_irq, cpu) >= 0) {279279+ unbind_from_irqhandler(per_cpu(cpep_irq, cpu), NULL);280280+ per_cpu(cpep_irq, cpu) = -1;281281+ }282282+ if (per_cpu(cmcp_irq, cpu) >= 0) {283283+ unbind_from_irqhandler(per_cpu(cmcp_irq, cpu), NULL);284284+ per_cpu(cmcp_irq, cpu) = -1;285285+ }286286+ if (per_cpu(cmc_irq, cpu) >= 0) {287287+ unbind_from_irqhandler(per_cpu(cmc_irq, cpu), NULL);288288+ per_cpu(cmc_irq, cpu) = -1;289289+ }290290+ if (per_cpu(ipi_irq, cpu) >= 0) {291291+ unbind_from_irqhandler(per_cpu(ipi_irq, cpu), NULL);292292+ per_cpu(ipi_irq, cpu) = -1;293293+ }294294+ if (per_cpu(resched_irq, cpu) >= 0) {295295+ unbind_from_irqhandler(per_cpu(resched_irq, cpu),296296+ NULL);297297+ per_cpu(resched_irq, cpu) = -1;298298+ }299299+ if (per_cpu(timer_irq, cpu) >= 0) {300300+ unbind_from_irqhandler(per_cpu(timer_irq, cpu), NULL);301301+ per_cpu(timer_irq, cpu) = -1;302302+ }303303+ }304304+ return NOTIFY_OK;305305+}306306+307307+static struct notifier_block unbind_evtchn_notifier = {308308+ .notifier_call = unbind_evtchn_callback,309309+ .priority = 0310310+};311311+#endif312312+313313+void xen_smp_intr_init_early(unsigned int cpu)314314+{315315+#ifdef CONFIG_SMP316316+ unsigned int i;317317+318318+ for (i = 0; i < saved_irq_cnt; i++)319319+ __xen_register_percpu_irq(cpu, saved_percpu_irqs[i].irq,320320+ saved_percpu_irqs[i].action, 0);321321+#endif322322+}323323+324324+void xen_smp_intr_init(void)325325+{326326+#ifdef CONFIG_SMP327327+ unsigned int cpu = smp_processor_id();328328+ struct callback_register event = {329329+ .type = CALLBACKTYPE_event,330330+ .address = { .ip = (unsigned long)&xen_event_callback },331331+ };332332+333333+ if (cpu == 0) {334334+ /* Initialization was already done for boot cpu. */335335+#ifdef CONFIG_HOTPLUG_CPU336336+ /* Register the notifier only once. */337337+ register_cpu_notifier(&unbind_evtchn_notifier);338338+#endif339339+ return;340340+ }341341+342342+ /* This should be piggyback when setup vcpu guest context */343343+ BUG_ON(HYPERVISOR_callback_op(CALLBACKOP_register, &event));344344+#endif /* CONFIG_SMP */345345+}346346+347347+void __init348348+xen_irq_init(void)349349+{350350+ struct callback_register event = {351351+ .type = CALLBACKTYPE_event,352352+ .address = { .ip = (unsigned long)&xen_event_callback },353353+ };354354+355355+ xen_init_IRQ();356356+ BUG_ON(HYPERVISOR_callback_op(CALLBACKOP_register, &event));357357+ late_time_init = xen_bind_early_percpu_irq;358358+}359359+360360+void361361+xen_platform_send_ipi(int cpu, int vector, int delivery_mode, int redirect)362362+{363363+#ifdef CONFIG_SMP364364+ /* TODO: we need to call vcpu_up here */365365+ if (unlikely(vector == ap_wakeup_vector)) {366366+ /* XXX367367+ * This should be in __cpu_up(cpu) in ia64 smpboot.c368368+ * like x86. But don't want to modify it,369369+ * keep it untouched.370370+ */371371+ xen_smp_intr_init_early(cpu);372372+373373+ xen_send_ipi(cpu, vector);374374+ /* vcpu_prepare_and_up(cpu); */375375+ return;376376+ }377377+#endif378378+379379+ switch (vector) {380380+ case IA64_IPI_VECTOR:381381+ xen_send_IPI_one(cpu, XEN_IPI_VECTOR);382382+ break;383383+ case IA64_IPI_RESCHEDULE:384384+ xen_send_IPI_one(cpu, XEN_RESCHEDULE_VECTOR);385385+ break;386386+ case IA64_CMCP_VECTOR:387387+ xen_send_IPI_one(cpu, XEN_CMCP_VECTOR);388388+ break;389389+ case IA64_CPEP_VECTOR:390390+ xen_send_IPI_one(cpu, XEN_CPEP_VECTOR);391391+ break;392392+ case IA64_TIMER_VECTOR: {393393+ /* this is used only once by check_sal_cache_flush()394394+ at boot time */395395+ static int used = 0;396396+ if (!used) {397397+ xen_send_ipi(cpu, IA64_TIMER_VECTOR);398398+ used = 1;399399+ break;400400+ }401401+ /* fallthrough */402402+ }403403+ default:404404+ printk(KERN_WARNING "Unsupported IPI type 0x%x\n",405405+ vector);406406+ notify_remote_via_irq(0); /* defaults to 0 irq */407407+ break;408408+ }409409+}410410+411411+static void __init412412+xen_register_ipi(void)413413+{414414+#ifdef CONFIG_SMP415415+ register_percpu_irq(IA64_IPI_VECTOR, &xen_ipi_irqaction);416416+ register_percpu_irq(IA64_IPI_RESCHEDULE, &xen_resched_irqaction);417417+ register_percpu_irq(IA64_IPI_LOCAL_TLB_FLUSH, &xen_tlb_irqaction);418418+#endif419419+}420420+421421+static void422422+xen_resend_irq(unsigned int vector)423423+{424424+ (void)resend_irq_on_evtchn(vector);425425+}426426+427427+const struct pv_irq_ops xen_irq_ops __initdata = {428428+ .register_ipi = xen_register_ipi,429429+430430+ .assign_irq_vector = xen_assign_irq_vector,431431+ .free_irq_vector = xen_free_irq_vector,432432+ .register_percpu_irq = xen_register_percpu_irq,433433+434434+ .resend_irq = xen_resend_irq,435435+};
+34
arch/ia64/xen/irq_xen.h
···11+/******************************************************************************22+ * arch/ia64/xen/irq_xen.h33+ *44+ * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>55+ * VA Linux Systems Japan K.K.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License as published by99+ * the Free Software Foundation; either version 2 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This program is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515+ * GNU General Public License for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2020+ *2121+ */2222+2323+#ifndef IRQ_XEN_H2424+#define IRQ_XEN_H2525+2626+extern void (*late_time_init)(void);2727+extern char xen_event_callback;2828+void __init xen_init_IRQ(void);2929+3030+extern const struct pv_irq_ops xen_irq_ops __initdata;3131+extern void xen_smp_intr_init(void);3232+extern void xen_send_ipi(int cpu, int vec);3333+3434+#endif /* IRQ_XEN_H */
···11+/******************************************************************************22+ * arch/ia64/xen/suspend.c33+ *44+ * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>55+ * VA Linux Systems Japan K.K.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License as published by99+ * the Free Software Foundation; either version 2 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This program is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515+ * GNU General Public License for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2020+ *2121+ * suspend/resume2222+ */2323+2424+#include <xen/xen-ops.h>2525+#include <asm/xen/hypervisor.h>2626+#include "time.h"2727+2828+void2929+xen_mm_pin_all(void)3030+{3131+ /* nothing */3232+}3333+3434+void3535+xen_mm_unpin_all(void)3636+{3737+ /* nothing */3838+}3939+4040+void xen_pre_device_suspend(void)4141+{4242+ /* nothing */4343+}4444+4545+void4646+xen_pre_suspend()4747+{4848+ /* nothing */4949+}5050+5151+void5252+xen_post_suspend(int suspend_cancelled)5353+{5454+ if (suspend_cancelled)5555+ return;5656+5757+ xen_ia64_enable_opt_feature();5858+ /* add more if necessary */5959+}6060+6161+void xen_arch_resume(void)6262+{6363+ xen_timer_resume_on_aps();6464+}
+213
arch/ia64/xen/time.c
···11+/******************************************************************************22+ * arch/ia64/xen/time.c33+ *44+ * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>55+ * VA Linux Systems Japan K.K.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License as published by99+ * the Free Software Foundation; either version 2 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This program is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515+ * GNU General Public License for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2020+ *2121+ */2222+2323+#include <linux/delay.h>2424+#include <linux/kernel_stat.h>2525+#include <linux/posix-timers.h>2626+#include <linux/irq.h>2727+#include <linux/clocksource.h>2828+2929+#include <asm/timex.h>3030+3131+#include <asm/xen/hypervisor.h>3232+3333+#include <xen/interface/vcpu.h>3434+3535+#include "../kernel/fsyscall_gtod_data.h"3636+3737+DEFINE_PER_CPU(struct vcpu_runstate_info, runstate);3838+DEFINE_PER_CPU(unsigned long, processed_stolen_time);3939+DEFINE_PER_CPU(unsigned long, processed_blocked_time);4040+4141+/* taken from i386/kernel/time-xen.c */4242+static void xen_init_missing_ticks_accounting(int cpu)4343+{4444+ struct vcpu_register_runstate_memory_area area;4545+ struct vcpu_runstate_info *runstate = &per_cpu(runstate, cpu);4646+ int rc;4747+4848+ memset(runstate, 0, sizeof(*runstate));4949+5050+ area.addr.v = runstate;5151+ rc = HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area, cpu,5252+ &area);5353+ WARN_ON(rc && rc != -ENOSYS);5454+5555+ per_cpu(processed_blocked_time, cpu) = runstate->time[RUNSTATE_blocked];5656+ per_cpu(processed_stolen_time, cpu) = runstate->time[RUNSTATE_runnable]5757+ + runstate->time[RUNSTATE_offline];5858+}5959+6060+/*6161+ * Runstate accounting6262+ */6363+/* stolen from arch/x86/xen/time.c */6464+static void get_runstate_snapshot(struct vcpu_runstate_info *res)6565+{6666+ u64 state_time;6767+ struct vcpu_runstate_info *state;6868+6969+ BUG_ON(preemptible());7070+7171+ state = &__get_cpu_var(runstate);7272+7373+ /*7474+ * The runstate info is always updated by the hypervisor on7575+ * the current CPU, so there's no need to use anything7676+ * stronger than a compiler barrier when fetching it.7777+ */7878+ do {7979+ state_time = state->state_entry_time;8080+ rmb();8181+ *res = *state;8282+ rmb();8383+ } while (state->state_entry_time != state_time);8484+}8585+8686+#define NS_PER_TICK (1000000000LL/HZ)8787+8888+static unsigned long8989+consider_steal_time(unsigned long new_itm)9090+{9191+ unsigned long stolen, blocked;9292+ unsigned long delta_itm = 0, stolentick = 0;9393+ int cpu = smp_processor_id();9494+ struct vcpu_runstate_info runstate;9595+ struct task_struct *p = current;9696+9797+ get_runstate_snapshot(&runstate);9898+9999+ /*100100+ * Check for vcpu migration effect101101+ * In this case, itc value is reversed.102102+ * This causes huge stolen value.103103+ * This function just checks and reject this effect.104104+ */105105+ if (!time_after_eq(runstate.time[RUNSTATE_blocked],106106+ per_cpu(processed_blocked_time, cpu)))107107+ blocked = 0;108108+109109+ if (!time_after_eq(runstate.time[RUNSTATE_runnable] +110110+ runstate.time[RUNSTATE_offline],111111+ per_cpu(processed_stolen_time, cpu)))112112+ stolen = 0;113113+114114+ if (!time_after(delta_itm + new_itm, ia64_get_itc()))115115+ stolentick = ia64_get_itc() - new_itm;116116+117117+ do_div(stolentick, NS_PER_TICK);118118+ stolentick++;119119+120120+ do_div(stolen, NS_PER_TICK);121121+122122+ if (stolen > stolentick)123123+ stolen = stolentick;124124+125125+ stolentick -= stolen;126126+ do_div(blocked, NS_PER_TICK);127127+128128+ if (blocked > stolentick)129129+ blocked = stolentick;130130+131131+ if (stolen > 0 || blocked > 0) {132132+ account_steal_time(NULL, jiffies_to_cputime(stolen));133133+ account_steal_time(idle_task(cpu), jiffies_to_cputime(blocked));134134+ run_local_timers();135135+136136+ if (rcu_pending(cpu))137137+ rcu_check_callbacks(cpu, user_mode(get_irq_regs()));138138+139139+ scheduler_tick();140140+ run_posix_cpu_timers(p);141141+ delta_itm += local_cpu_data->itm_delta * (stolen + blocked);142142+143143+ if (cpu == time_keeper_id) {144144+ write_seqlock(&xtime_lock);145145+ do_timer(stolen + blocked);146146+ local_cpu_data->itm_next = delta_itm + new_itm;147147+ write_sequnlock(&xtime_lock);148148+ } else {149149+ local_cpu_data->itm_next = delta_itm + new_itm;150150+ }151151+ per_cpu(processed_stolen_time, cpu) += NS_PER_TICK * stolen;152152+ per_cpu(processed_blocked_time, cpu) += NS_PER_TICK * blocked;153153+ }154154+ return delta_itm;155155+}156156+157157+static int xen_do_steal_accounting(unsigned long *new_itm)158158+{159159+ unsigned long delta_itm;160160+ delta_itm = consider_steal_time(*new_itm);161161+ *new_itm += delta_itm;162162+ if (time_after(*new_itm, ia64_get_itc()) && delta_itm)163163+ return 1;164164+165165+ return 0;166166+}167167+168168+static void xen_itc_jitter_data_reset(void)169169+{170170+ u64 lcycle, ret;171171+172172+ do {173173+ lcycle = itc_jitter_data.itc_lastcycle;174174+ ret = cmpxchg(&itc_jitter_data.itc_lastcycle, lcycle, 0);175175+ } while (unlikely(ret != lcycle));176176+}177177+178178+struct pv_time_ops xen_time_ops __initdata = {179179+ .init_missing_ticks_accounting = xen_init_missing_ticks_accounting,180180+ .do_steal_accounting = xen_do_steal_accounting,181181+ .clocksource_resume = xen_itc_jitter_data_reset,182182+};183183+184184+/* Called after suspend, to resume time. */185185+static void xen_local_tick_resume(void)186186+{187187+ /* Just trigger a tick. */188188+ ia64_cpu_local_tick();189189+ touch_softlockup_watchdog();190190+}191191+192192+void193193+xen_timer_resume(void)194194+{195195+ unsigned int cpu;196196+197197+ xen_local_tick_resume();198198+199199+ for_each_online_cpu(cpu)200200+ xen_init_missing_ticks_accounting(cpu);201201+}202202+203203+static void ia64_cpu_local_tick_fn(void *unused)204204+{205205+ xen_local_tick_resume();206206+ xen_init_missing_ticks_accounting(smp_processor_id());207207+}208208+209209+void210210+xen_timer_resume_on_aps(void)211211+{212212+ smp_call_function(&ia64_cpu_local_tick_fn, NULL, 1);213213+}
+24
arch/ia64/xen/time.h
···11+/******************************************************************************22+ * arch/ia64/xen/time.h33+ *44+ * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>55+ * VA Linux Systems Japan K.K.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License as published by99+ * the Free Software Foundation; either version 2 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This program is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515+ * GNU General Public License for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2020+ *2121+ */2222+2323+extern struct pv_time_ops xen_time_ops __initdata;2424+void xen_timer_resume_on_aps(void);
+441
arch/ia64/xen/xcom_hcall.c
···11+/*22+ * This program is free software; you can redistribute it and/or modify33+ * it under the terms of the GNU General Public License as published by44+ * the Free Software Foundation; either version 2 of the License, or55+ * (at your option) any later version.66+ *77+ * This program is distributed in the hope that it will be useful,88+ * but WITHOUT ANY WARRANTY; without even the implied warranty of99+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1010+ * GNU General Public License for more details.1111+ *1212+ * You should have received a copy of the GNU General Public License1313+ * along with this program; if not, write to the Free Software1414+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.1515+ *1616+ * Tristan Gingold <tristan.gingold@bull.net>1717+ *1818+ * Copyright (c) 20071919+ * Isaku Yamahata <yamahata at valinux co jp>2020+ * VA Linux Systems Japan K.K.2121+ * consolidate mini and inline version.2222+ */2323+2424+#include <linux/module.h>2525+#include <xen/interface/xen.h>2626+#include <xen/interface/memory.h>2727+#include <xen/interface/grant_table.h>2828+#include <xen/interface/callback.h>2929+#include <xen/interface/vcpu.h>3030+#include <asm/xen/hypervisor.h>3131+#include <asm/xen/xencomm.h>3232+3333+/* Xencomm notes:3434+ * This file defines hypercalls to be used by xencomm. The hypercalls simply3535+ * create inlines or mini descriptors for pointers and then call the raw arch3636+ * hypercall xencomm_arch_hypercall_XXX3737+ *3838+ * If the arch wants to directly use these hypercalls, simply define macros3939+ * in asm/xen/hypercall.h, eg:4040+ * #define HYPERVISOR_sched_op xencomm_hypercall_sched_op4141+ *4242+ * The arch may also define HYPERVISOR_xxx as a function and do more operations4343+ * before/after doing the hypercall.4444+ *4545+ * Note: because only inline or mini descriptors are created these functions4646+ * must only be called with in kernel memory parameters.4747+ */4848+4949+int5050+xencomm_hypercall_console_io(int cmd, int count, char *str)5151+{5252+ /* xen early printk uses console io hypercall before5353+ * xencomm initialization. In that case, we just ignore it.5454+ */5555+ if (!xencomm_is_initialized())5656+ return 0;5757+5858+ return xencomm_arch_hypercall_console_io5959+ (cmd, count, xencomm_map_no_alloc(str, count));6060+}6161+EXPORT_SYMBOL_GPL(xencomm_hypercall_console_io);6262+6363+int6464+xencomm_hypercall_event_channel_op(int cmd, void *op)6565+{6666+ struct xencomm_handle *desc;6767+ desc = xencomm_map_no_alloc(op, sizeof(struct evtchn_op));6868+ if (desc == NULL)6969+ return -EINVAL;7070+7171+ return xencomm_arch_hypercall_event_channel_op(cmd, desc);7272+}7373+EXPORT_SYMBOL_GPL(xencomm_hypercall_event_channel_op);7474+7575+int7676+xencomm_hypercall_xen_version(int cmd, void *arg)7777+{7878+ struct xencomm_handle *desc;7979+ unsigned int argsize;8080+8181+ switch (cmd) {8282+ case XENVER_version:8383+ /* do not actually pass an argument */8484+ return xencomm_arch_hypercall_xen_version(cmd, 0);8585+ case XENVER_extraversion:8686+ argsize = sizeof(struct xen_extraversion);8787+ break;8888+ case XENVER_compile_info:8989+ argsize = sizeof(struct xen_compile_info);9090+ break;9191+ case XENVER_capabilities:9292+ argsize = sizeof(struct xen_capabilities_info);9393+ break;9494+ case XENVER_changeset:9595+ argsize = sizeof(struct xen_changeset_info);9696+ break;9797+ case XENVER_platform_parameters:9898+ argsize = sizeof(struct xen_platform_parameters);9999+ break;100100+ case XENVER_get_features:101101+ argsize = (arg == NULL) ? 0 : sizeof(struct xen_feature_info);102102+ break;103103+104104+ default:105105+ printk(KERN_DEBUG106106+ "%s: unknown version op %d\n", __func__, cmd);107107+ return -ENOSYS;108108+ }109109+110110+ desc = xencomm_map_no_alloc(arg, argsize);111111+ if (desc == NULL)112112+ return -EINVAL;113113+114114+ return xencomm_arch_hypercall_xen_version(cmd, desc);115115+}116116+EXPORT_SYMBOL_GPL(xencomm_hypercall_xen_version);117117+118118+int119119+xencomm_hypercall_physdev_op(int cmd, void *op)120120+{121121+ unsigned int argsize;122122+123123+ switch (cmd) {124124+ case PHYSDEVOP_apic_read:125125+ case PHYSDEVOP_apic_write:126126+ argsize = sizeof(struct physdev_apic);127127+ break;128128+ case PHYSDEVOP_alloc_irq_vector:129129+ case PHYSDEVOP_free_irq_vector:130130+ argsize = sizeof(struct physdev_irq);131131+ break;132132+ case PHYSDEVOP_irq_status_query:133133+ argsize = sizeof(struct physdev_irq_status_query);134134+ break;135135+136136+ default:137137+ printk(KERN_DEBUG138138+ "%s: unknown physdev op %d\n", __func__, cmd);139139+ return -ENOSYS;140140+ }141141+142142+ return xencomm_arch_hypercall_physdev_op143143+ (cmd, xencomm_map_no_alloc(op, argsize));144144+}145145+146146+static int147147+xencommize_grant_table_op(struct xencomm_mini **xc_area,148148+ unsigned int cmd, void *op, unsigned int count,149149+ struct xencomm_handle **desc)150150+{151151+ struct xencomm_handle *desc1;152152+ unsigned int argsize;153153+154154+ switch (cmd) {155155+ case GNTTABOP_map_grant_ref:156156+ argsize = sizeof(struct gnttab_map_grant_ref);157157+ break;158158+ case GNTTABOP_unmap_grant_ref:159159+ argsize = sizeof(struct gnttab_unmap_grant_ref);160160+ break;161161+ case GNTTABOP_setup_table:162162+ {163163+ struct gnttab_setup_table *setup = op;164164+165165+ argsize = sizeof(*setup);166166+167167+ if (count != 1)168168+ return -EINVAL;169169+ desc1 = __xencomm_map_no_alloc170170+ (xen_guest_handle(setup->frame_list),171171+ setup->nr_frames *172172+ sizeof(*xen_guest_handle(setup->frame_list)),173173+ *xc_area);174174+ if (desc1 == NULL)175175+ return -EINVAL;176176+ (*xc_area)++;177177+ set_xen_guest_handle(setup->frame_list, (void *)desc1);178178+ break;179179+ }180180+ case GNTTABOP_dump_table:181181+ argsize = sizeof(struct gnttab_dump_table);182182+ break;183183+ case GNTTABOP_transfer:184184+ argsize = sizeof(struct gnttab_transfer);185185+ break;186186+ case GNTTABOP_copy:187187+ argsize = sizeof(struct gnttab_copy);188188+ break;189189+ case GNTTABOP_query_size:190190+ argsize = sizeof(struct gnttab_query_size);191191+ break;192192+ default:193193+ printk(KERN_DEBUG "%s: unknown hypercall grant table op %d\n",194194+ __func__, cmd);195195+ BUG();196196+ }197197+198198+ *desc = __xencomm_map_no_alloc(op, count * argsize, *xc_area);199199+ if (*desc == NULL)200200+ return -EINVAL;201201+ (*xc_area)++;202202+203203+ return 0;204204+}205205+206206+int207207+xencomm_hypercall_grant_table_op(unsigned int cmd, void *op,208208+ unsigned int count)209209+{210210+ int rc;211211+ struct xencomm_handle *desc;212212+ XENCOMM_MINI_ALIGNED(xc_area, 2);213213+214214+ rc = xencommize_grant_table_op(&xc_area, cmd, op, count, &desc);215215+ if (rc)216216+ return rc;217217+218218+ return xencomm_arch_hypercall_grant_table_op(cmd, desc, count);219219+}220220+EXPORT_SYMBOL_GPL(xencomm_hypercall_grant_table_op);221221+222222+int223223+xencomm_hypercall_sched_op(int cmd, void *arg)224224+{225225+ struct xencomm_handle *desc;226226+ unsigned int argsize;227227+228228+ switch (cmd) {229229+ case SCHEDOP_yield:230230+ case SCHEDOP_block:231231+ argsize = 0;232232+ break;233233+ case SCHEDOP_shutdown:234234+ argsize = sizeof(struct sched_shutdown);235235+ break;236236+ case SCHEDOP_poll:237237+ {238238+ struct sched_poll *poll = arg;239239+ struct xencomm_handle *ports;240240+241241+ argsize = sizeof(struct sched_poll);242242+ ports = xencomm_map_no_alloc(xen_guest_handle(poll->ports),243243+ sizeof(*xen_guest_handle(poll->ports)));244244+245245+ set_xen_guest_handle(poll->ports, (void *)ports);246246+ break;247247+ }248248+ default:249249+ printk(KERN_DEBUG "%s: unknown sched op %d\n", __func__, cmd);250250+ return -ENOSYS;251251+ }252252+253253+ desc = xencomm_map_no_alloc(arg, argsize);254254+ if (desc == NULL)255255+ return -EINVAL;256256+257257+ return xencomm_arch_hypercall_sched_op(cmd, desc);258258+}259259+EXPORT_SYMBOL_GPL(xencomm_hypercall_sched_op);260260+261261+int262262+xencomm_hypercall_multicall(void *call_list, int nr_calls)263263+{264264+ int rc;265265+ int i;266266+ struct multicall_entry *mce;267267+ struct xencomm_handle *desc;268268+ XENCOMM_MINI_ALIGNED(xc_area, nr_calls * 2);269269+270270+ for (i = 0; i < nr_calls; i++) {271271+ mce = (struct multicall_entry *)call_list + i;272272+273273+ switch (mce->op) {274274+ case __HYPERVISOR_update_va_mapping:275275+ case __HYPERVISOR_mmu_update:276276+ /* No-op on ia64. */277277+ break;278278+ case __HYPERVISOR_grant_table_op:279279+ rc = xencommize_grant_table_op280280+ (&xc_area,281281+ mce->args[0], (void *)mce->args[1],282282+ mce->args[2], &desc);283283+ if (rc)284284+ return rc;285285+ mce->args[1] = (unsigned long)desc;286286+ break;287287+ case __HYPERVISOR_memory_op:288288+ default:289289+ printk(KERN_DEBUG290290+ "%s: unhandled multicall op entry op %lu\n",291291+ __func__, mce->op);292292+ return -ENOSYS;293293+ }294294+ }295295+296296+ desc = xencomm_map_no_alloc(call_list,297297+ nr_calls * sizeof(struct multicall_entry));298298+ if (desc == NULL)299299+ return -EINVAL;300300+301301+ return xencomm_arch_hypercall_multicall(desc, nr_calls);302302+}303303+EXPORT_SYMBOL_GPL(xencomm_hypercall_multicall);304304+305305+int306306+xencomm_hypercall_callback_op(int cmd, void *arg)307307+{308308+ unsigned int argsize;309309+ switch (cmd) {310310+ case CALLBACKOP_register:311311+ argsize = sizeof(struct callback_register);312312+ break;313313+ case CALLBACKOP_unregister:314314+ argsize = sizeof(struct callback_unregister);315315+ break;316316+ default:317317+ printk(KERN_DEBUG318318+ "%s: unknown callback op %d\n", __func__, cmd);319319+ return -ENOSYS;320320+ }321321+322322+ return xencomm_arch_hypercall_callback_op323323+ (cmd, xencomm_map_no_alloc(arg, argsize));324324+}325325+326326+static int327327+xencommize_memory_reservation(struct xencomm_mini *xc_area,328328+ struct xen_memory_reservation *mop)329329+{330330+ struct xencomm_handle *desc;331331+332332+ desc = __xencomm_map_no_alloc(xen_guest_handle(mop->extent_start),333333+ mop->nr_extents *334334+ sizeof(*xen_guest_handle(mop->extent_start)),335335+ xc_area);336336+ if (desc == NULL)337337+ return -EINVAL;338338+339339+ set_xen_guest_handle(mop->extent_start, (void *)desc);340340+ return 0;341341+}342342+343343+int344344+xencomm_hypercall_memory_op(unsigned int cmd, void *arg)345345+{346346+ GUEST_HANDLE(xen_pfn_t) extent_start_va[2] = { {NULL}, {NULL} };347347+ struct xen_memory_reservation *xmr = NULL;348348+ int rc;349349+ struct xencomm_handle *desc;350350+ unsigned int argsize;351351+ XENCOMM_MINI_ALIGNED(xc_area, 2);352352+353353+ switch (cmd) {354354+ case XENMEM_increase_reservation:355355+ case XENMEM_decrease_reservation:356356+ case XENMEM_populate_physmap:357357+ xmr = (struct xen_memory_reservation *)arg;358358+ set_xen_guest_handle(extent_start_va[0],359359+ xen_guest_handle(xmr->extent_start));360360+361361+ argsize = sizeof(*xmr);362362+ rc = xencommize_memory_reservation(xc_area, xmr);363363+ if (rc)364364+ return rc;365365+ xc_area++;366366+ break;367367+368368+ case XENMEM_maximum_ram_page:369369+ argsize = 0;370370+ break;371371+372372+ case XENMEM_add_to_physmap:373373+ argsize = sizeof(struct xen_add_to_physmap);374374+ break;375375+376376+ default:377377+ printk(KERN_DEBUG "%s: unknown memory op %d\n", __func__, cmd);378378+ return -ENOSYS;379379+ }380380+381381+ desc = xencomm_map_no_alloc(arg, argsize);382382+ if (desc == NULL)383383+ return -EINVAL;384384+385385+ rc = xencomm_arch_hypercall_memory_op(cmd, desc);386386+387387+ switch (cmd) {388388+ case XENMEM_increase_reservation:389389+ case XENMEM_decrease_reservation:390390+ case XENMEM_populate_physmap:391391+ set_xen_guest_handle(xmr->extent_start,392392+ xen_guest_handle(extent_start_va[0]));393393+ break;394394+ }395395+396396+ return rc;397397+}398398+EXPORT_SYMBOL_GPL(xencomm_hypercall_memory_op);399399+400400+int401401+xencomm_hypercall_suspend(unsigned long srec)402402+{403403+ struct sched_shutdown arg;404404+405405+ arg.reason = SHUTDOWN_suspend;406406+407407+ return xencomm_arch_hypercall_sched_op(408408+ SCHEDOP_shutdown, xencomm_map_no_alloc(&arg, sizeof(arg)));409409+}410410+411411+long412412+xencomm_hypercall_vcpu_op(int cmd, int cpu, void *arg)413413+{414414+ unsigned int argsize;415415+ switch (cmd) {416416+ case VCPUOP_register_runstate_memory_area: {417417+ struct vcpu_register_runstate_memory_area *area =418418+ (struct vcpu_register_runstate_memory_area *)arg;419419+ argsize = sizeof(*arg);420420+ set_xen_guest_handle(area->addr.h,421421+ (void *)xencomm_map_no_alloc(area->addr.v,422422+ sizeof(area->addr.v)));423423+ break;424424+ }425425+426426+ default:427427+ printk(KERN_DEBUG "%s: unknown vcpu op %d\n", __func__, cmd);428428+ return -ENOSYS;429429+ }430430+431431+ return xencomm_arch_hypercall_vcpu_op(cmd, cpu,432432+ xencomm_map_no_alloc(arg, argsize));433433+}434434+435435+long436436+xencomm_hypercall_opt_feature(void *arg)437437+{438438+ return xencomm_arch_hypercall_opt_feature(439439+ xencomm_map_no_alloc(arg,440440+ sizeof(struct xen_ia64_opt_feature)));441441+}
+364
arch/ia64/xen/xen_pv_ops.c
···11+/******************************************************************************22+ * arch/ia64/xen/xen_pv_ops.c33+ *44+ * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>55+ * VA Linux Systems Japan K.K.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License as published by99+ * the Free Software Foundation; either version 2 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This program is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515+ * GNU General Public License for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2020+ *2121+ */2222+2323+#include <linux/console.h>2424+#include <linux/irq.h>2525+#include <linux/kernel.h>2626+#include <linux/pm.h>2727+2828+#include <asm/xen/hypervisor.h>2929+#include <asm/xen/xencomm.h>3030+#include <asm/xen/privop.h>3131+3232+#include "irq_xen.h"3333+#include "time.h"3434+3535+/***************************************************************************3636+ * general info3737+ */3838+static struct pv_info xen_info __initdata = {3939+ .kernel_rpl = 2, /* or 1: determin at runtime */4040+ .paravirt_enabled = 1,4141+ .name = "Xen/ia64",4242+};4343+4444+#define IA64_RSC_PL_SHIFT 24545+#define IA64_RSC_PL_BIT_SIZE 24646+#define IA64_RSC_PL_MASK \4747+ (((1UL << IA64_RSC_PL_BIT_SIZE) - 1) << IA64_RSC_PL_SHIFT)4848+4949+static void __init5050+xen_info_init(void)5151+{5252+ /* Xenified Linux/ia64 may run on pl = 1 or 2.5353+ * determin at run time. */5454+ unsigned long rsc = ia64_getreg(_IA64_REG_AR_RSC);5555+ unsigned int rpl = (rsc & IA64_RSC_PL_MASK) >> IA64_RSC_PL_SHIFT;5656+ xen_info.kernel_rpl = rpl;5757+}5858+5959+/***************************************************************************6060+ * pv_init_ops6161+ * initialization hooks.6262+ */6363+6464+static void6565+xen_panic_hypercall(struct unw_frame_info *info, void *arg)6666+{6767+ current->thread.ksp = (__u64)info->sw - 16;6868+ HYPERVISOR_shutdown(SHUTDOWN_crash);6969+ /* we're never actually going to get here... */7070+}7171+7272+static int7373+xen_panic_event(struct notifier_block *this, unsigned long event, void *ptr)7474+{7575+ unw_init_running(xen_panic_hypercall, NULL);7676+ /* we're never actually going to get here... */7777+ return NOTIFY_DONE;7878+}7979+8080+static struct notifier_block xen_panic_block = {8181+ xen_panic_event, NULL, 0 /* try to go last */8282+};8383+8484+static void xen_pm_power_off(void)8585+{8686+ local_irq_disable();8787+ HYPERVISOR_shutdown(SHUTDOWN_poweroff);8888+}8989+9090+static void __init9191+xen_banner(void)9292+{9393+ printk(KERN_INFO9494+ "Running on Xen! pl = %d start_info_pfn=0x%lx nr_pages=%ld "9595+ "flags=0x%x\n",9696+ xen_info.kernel_rpl,9797+ HYPERVISOR_shared_info->arch.start_info_pfn,9898+ xen_start_info->nr_pages, xen_start_info->flags);9999+}100100+101101+static int __init102102+xen_reserve_memory(struct rsvd_region *region)103103+{104104+ region->start = (unsigned long)__va(105105+ (HYPERVISOR_shared_info->arch.start_info_pfn << PAGE_SHIFT));106106+ region->end = region->start + PAGE_SIZE;107107+ return 1;108108+}109109+110110+static void __init111111+xen_arch_setup_early(void)112112+{113113+ struct shared_info *s;114114+ BUG_ON(!xen_pv_domain());115115+116116+ s = HYPERVISOR_shared_info;117117+ xen_start_info = __va(s->arch.start_info_pfn << PAGE_SHIFT);118118+119119+ /* Must be done before any hypercall. */120120+ xencomm_initialize();121121+122122+ xen_setup_features();123123+ /* Register a call for panic conditions. */124124+ atomic_notifier_chain_register(&panic_notifier_list,125125+ &xen_panic_block);126126+ pm_power_off = xen_pm_power_off;127127+128128+ xen_ia64_enable_opt_feature();129129+}130130+131131+static void __init132132+xen_arch_setup_console(char **cmdline_p)133133+{134134+ add_preferred_console("xenboot", 0, NULL);135135+ add_preferred_console("tty", 0, NULL);136136+ /* use hvc_xen */137137+ add_preferred_console("hvc", 0, NULL);138138+139139+#if !defined(CONFIG_VT) || !defined(CONFIG_DUMMY_CONSOLE)140140+ conswitchp = NULL;141141+#endif142142+}143143+144144+static int __init145145+xen_arch_setup_nomca(void)146146+{147147+ return 1;148148+}149149+150150+static void __init151151+xen_post_smp_prepare_boot_cpu(void)152152+{153153+ xen_setup_vcpu_info_placement();154154+}155155+156156+static const struct pv_init_ops xen_init_ops __initdata = {157157+ .banner = xen_banner,158158+159159+ .reserve_memory = xen_reserve_memory,160160+161161+ .arch_setup_early = xen_arch_setup_early,162162+ .arch_setup_console = xen_arch_setup_console,163163+ .arch_setup_nomca = xen_arch_setup_nomca,164164+165165+ .post_smp_prepare_boot_cpu = xen_post_smp_prepare_boot_cpu,166166+};167167+168168+/***************************************************************************169169+ * pv_cpu_ops170170+ * intrinsics hooks.171171+ */172172+173173+static void xen_setreg(int regnum, unsigned long val)174174+{175175+ switch (regnum) {176176+ case _IA64_REG_AR_KR0 ... _IA64_REG_AR_KR7:177177+ xen_set_kr(regnum - _IA64_REG_AR_KR0, val);178178+ break;179179+#ifdef CONFIG_IA32_SUPPORT180180+ case _IA64_REG_AR_EFLAG:181181+ xen_set_eflag(val);182182+ break;183183+#endif184184+ case _IA64_REG_CR_TPR:185185+ xen_set_tpr(val);186186+ break;187187+ case _IA64_REG_CR_ITM:188188+ xen_set_itm(val);189189+ break;190190+ case _IA64_REG_CR_EOI:191191+ xen_eoi(val);192192+ break;193193+ default:194194+ ia64_native_setreg_func(regnum, val);195195+ break;196196+ }197197+}198198+199199+static unsigned long xen_getreg(int regnum)200200+{201201+ unsigned long res;202202+203203+ switch (regnum) {204204+ case _IA64_REG_PSR:205205+ res = xen_get_psr();206206+ break;207207+#ifdef CONFIG_IA32_SUPPORT208208+ case _IA64_REG_AR_EFLAG:209209+ res = xen_get_eflag();210210+ break;211211+#endif212212+ case _IA64_REG_CR_IVR:213213+ res = xen_get_ivr();214214+ break;215215+ case _IA64_REG_CR_TPR:216216+ res = xen_get_tpr();217217+ break;218218+ default:219219+ res = ia64_native_getreg_func(regnum);220220+ break;221221+ }222222+ return res;223223+}224224+225225+/* turning on interrupts is a bit more complicated.. write to the226226+ * memory-mapped virtual psr.i bit first (to avoid race condition),227227+ * then if any interrupts were pending, we have to execute a hyperprivop228228+ * to ensure the pending interrupt gets delivered; else we're done! */229229+static void230230+xen_ssm_i(void)231231+{232232+ int old = xen_get_virtual_psr_i();233233+ xen_set_virtual_psr_i(1);234234+ barrier();235235+ if (!old && xen_get_virtual_pend())236236+ xen_hyper_ssm_i();237237+}238238+239239+/* turning off interrupts can be paravirtualized simply by writing240240+ * to a memory-mapped virtual psr.i bit (implemented as a 16-bit bool) */241241+static void242242+xen_rsm_i(void)243243+{244244+ xen_set_virtual_psr_i(0);245245+ barrier();246246+}247247+248248+static unsigned long249249+xen_get_psr_i(void)250250+{251251+ return xen_get_virtual_psr_i() ? IA64_PSR_I : 0;252252+}253253+254254+static void255255+xen_intrin_local_irq_restore(unsigned long mask)256256+{257257+ if (mask & IA64_PSR_I)258258+ xen_ssm_i();259259+ else260260+ xen_rsm_i();261261+}262262+263263+static const struct pv_cpu_ops xen_cpu_ops __initdata = {264264+ .fc = xen_fc,265265+ .thash = xen_thash,266266+ .get_cpuid = xen_get_cpuid,267267+ .get_pmd = xen_get_pmd,268268+ .getreg = xen_getreg,269269+ .setreg = xen_setreg,270270+ .ptcga = xen_ptcga,271271+ .get_rr = xen_get_rr,272272+ .set_rr = xen_set_rr,273273+ .set_rr0_to_rr4 = xen_set_rr0_to_rr4,274274+ .ssm_i = xen_ssm_i,275275+ .rsm_i = xen_rsm_i,276276+ .get_psr_i = xen_get_psr_i,277277+ .intrin_local_irq_restore278278+ = xen_intrin_local_irq_restore,279279+};280280+281281+/******************************************************************************282282+ * replacement of hand written assembly codes.283283+ */284284+285285+extern char xen_switch_to;286286+extern char xen_leave_syscall;287287+extern char xen_work_processed_syscall;288288+extern char xen_leave_kernel;289289+290290+const struct pv_cpu_asm_switch xen_cpu_asm_switch = {291291+ .switch_to = (unsigned long)&xen_switch_to,292292+ .leave_syscall = (unsigned long)&xen_leave_syscall,293293+ .work_processed_syscall = (unsigned long)&xen_work_processed_syscall,294294+ .leave_kernel = (unsigned long)&xen_leave_kernel,295295+};296296+297297+/***************************************************************************298298+ * pv_iosapic_ops299299+ * iosapic read/write hooks.300300+ */301301+static void302302+xen_pcat_compat_init(void)303303+{304304+ /* nothing */305305+}306306+307307+static struct irq_chip*308308+xen_iosapic_get_irq_chip(unsigned long trigger)309309+{310310+ return NULL;311311+}312312+313313+static unsigned int314314+xen_iosapic_read(char __iomem *iosapic, unsigned int reg)315315+{316316+ struct physdev_apic apic_op;317317+ int ret;318318+319319+ apic_op.apic_physbase = (unsigned long)iosapic -320320+ __IA64_UNCACHED_OFFSET;321321+ apic_op.reg = reg;322322+ ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic_op);323323+ if (ret)324324+ return ret;325325+ return apic_op.value;326326+}327327+328328+static void329329+xen_iosapic_write(char __iomem *iosapic, unsigned int reg, u32 val)330330+{331331+ struct physdev_apic apic_op;332332+333333+ apic_op.apic_physbase = (unsigned long)iosapic -334334+ __IA64_UNCACHED_OFFSET;335335+ apic_op.reg = reg;336336+ apic_op.value = val;337337+ HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op);338338+}339339+340340+static const struct pv_iosapic_ops xen_iosapic_ops __initdata = {341341+ .pcat_compat_init = xen_pcat_compat_init,342342+ .__get_irq_chip = xen_iosapic_get_irq_chip,343343+344344+ .__read = xen_iosapic_read,345345+ .__write = xen_iosapic_write,346346+};347347+348348+/***************************************************************************349349+ * pv_ops initialization350350+ */351351+352352+void __init353353+xen_setup_pv_ops(void)354354+{355355+ xen_info_init();356356+ pv_info = xen_info;357357+ pv_init_ops = xen_init_ops;358358+ pv_cpu_ops = xen_cpu_ops;359359+ pv_iosapic_ops = xen_iosapic_ops;360360+ pv_irq_ops = xen_irq_ops;361361+ pv_time_ops = xen_time_ops;362362+363363+ paravirt_cpu_asm_init(&xen_cpu_asm_switch);364364+}
+105
arch/ia64/xen/xencomm.c
···11+/*22+ * Copyright (C) 2006 Hollis Blanchard <hollisb@us.ibm.com>, IBM Corporation33+ *44+ * This program is free software; you can redistribute it and/or modify55+ * it under the terms of the GNU General Public License as published by66+ * the Free Software Foundation; either version 2 of the License, or77+ * (at your option) any later version.88+ *99+ * This program is distributed in the hope that it will be useful,1010+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1111+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1212+ * GNU General Public License for more details.1313+ *1414+ * You should have received a copy of the GNU General Public License1515+ * along with this program; if not, write to the Free Software1616+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA1717+ */1818+1919+#include <linux/mm.h>2020+2121+static unsigned long kernel_virtual_offset;2222+static int is_xencomm_initialized;2323+2424+/* for xen early printk. It uses console io hypercall which uses xencomm.2525+ * However early printk may use it before xencomm initialization.2626+ */2727+int2828+xencomm_is_initialized(void)2929+{3030+ return is_xencomm_initialized;3131+}3232+3333+void3434+xencomm_initialize(void)3535+{3636+ kernel_virtual_offset = KERNEL_START - ia64_tpa(KERNEL_START);3737+ is_xencomm_initialized = 1;3838+}3939+4040+/* Translate virtual address to physical address. */4141+unsigned long4242+xencomm_vtop(unsigned long vaddr)4343+{4444+ struct page *page;4545+ struct vm_area_struct *vma;4646+4747+ if (vaddr == 0)4848+ return 0UL;4949+5050+ if (REGION_NUMBER(vaddr) == 5) {5151+ pgd_t *pgd;5252+ pud_t *pud;5353+ pmd_t *pmd;5454+ pte_t *ptep;5555+5656+ /* On ia64, TASK_SIZE refers to current. It is not initialized5757+ during boot.5858+ Furthermore the kernel is relocatable and __pa() doesn't5959+ work on addresses. */6060+ if (vaddr >= KERNEL_START6161+ && vaddr < (KERNEL_START + KERNEL_TR_PAGE_SIZE))6262+ return vaddr - kernel_virtual_offset;6363+6464+ /* In kernel area -- virtually mapped. */6565+ pgd = pgd_offset_k(vaddr);6666+ if (pgd_none(*pgd) || pgd_bad(*pgd))6767+ return ~0UL;6868+6969+ pud = pud_offset(pgd, vaddr);7070+ if (pud_none(*pud) || pud_bad(*pud))7171+ return ~0UL;7272+7373+ pmd = pmd_offset(pud, vaddr);7474+ if (pmd_none(*pmd) || pmd_bad(*pmd))7575+ return ~0UL;7676+7777+ ptep = pte_offset_kernel(pmd, vaddr);7878+ if (!ptep)7979+ return ~0UL;8080+8181+ return (pte_val(*ptep) & _PFN_MASK) | (vaddr & ~PAGE_MASK);8282+ }8383+8484+ if (vaddr > TASK_SIZE) {8585+ /* percpu variables */8686+ if (REGION_NUMBER(vaddr) == 7 &&8787+ REGION_OFFSET(vaddr) >= (1ULL << IA64_MAX_PHYS_BITS))8888+ ia64_tpa(vaddr);8989+9090+ /* kernel address */9191+ return __pa(vaddr);9292+ }9393+9494+ /* XXX double-check (lack of) locking */9595+ vma = find_extend_vma(current->mm, vaddr);9696+ if (!vma)9797+ return ~0UL;9898+9999+ /* We assume the page is modified. */100100+ page = follow_page(vma, vaddr, FOLL_WRITE | FOLL_TOUCH);101101+ if (!page)102102+ return ~0UL;103103+104104+ return (page_to_pfn(page) << PAGE_SHIFT) | (vaddr & ~PAGE_MASK);105105+}
+52
arch/ia64/xen/xenivt.S
···11+/*22+ * arch/ia64/xen/ivt.S33+ *44+ * Copyright (C) 2005 Hewlett-Packard Co55+ * Dan Magenheimer <dan.magenheimer@hp.com>66+ *77+ * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp>88+ * VA Linux Systems Japan K.K.99+ * pv_ops.1010+ */1111+1212+#include <asm/asmmacro.h>1313+#include <asm/kregs.h>1414+#include <asm/pgtable.h>1515+1616+#include "../kernel/minstate.h"1717+1818+ .section .text,"ax"1919+GLOBAL_ENTRY(xen_event_callback)2020+ mov r31=pr // prepare to save predicates2121+ ;;2222+ SAVE_MIN_WITH_COVER // uses r31; defines r2 and r32323+ ;;2424+ movl r3=XSI_PSR_IC2525+ mov r14=12626+ ;;2727+ st4 [r3]=r142828+ ;;2929+ adds r3=8,r2 // set up second base pointer for SAVE_REST3030+ srlz.i // ensure everybody knows psr.ic is back on3131+ ;;3232+ SAVE_REST3333+ ;;3434+1:3535+ alloc r14=ar.pfs,0,0,1,0 // must be first in an insn group3636+ add out0=16,sp // pass pointer to pt_regs as first arg3737+ ;;3838+ br.call.sptk.many b0=xen_evtchn_do_upcall3939+ ;;4040+ movl r20=XSI_PSR_I_ADDR4141+ ;;4242+ ld8 r20=[r20]4343+ ;;4444+ adds r20=-1,r20 // vcpu_info->evtchn_upcall_pending4545+ ;;4646+ ld1 r20=[r20]4747+ ;;4848+ cmp.ne p6,p0=r20,r0 // if there are pending events,4949+ (p6) br.spnt.few 1b // call evtchn_do_upcall again.5050+ br.sptk.many xen_leave_kernel // we know ia64_leave_kernel is5151+ // paravirtualized as xen_leave_kernel5252+END(xen_event_callback)
+83
arch/ia64/xen/xensetup.S
···11+/*22+ * Support routines for Xen33+ *44+ * Copyright (C) 2005 Dan Magenheimer <dan.magenheimer@hp.com>55+ */66+77+#include <asm/processor.h>88+#include <asm/asmmacro.h>99+#include <asm/pgtable.h>1010+#include <asm/system.h>1111+#include <asm/paravirt.h>1212+#include <asm/xen/privop.h>1313+#include <linux/elfnote.h>1414+#include <linux/init.h>1515+#include <xen/interface/elfnote.h>1616+1717+ .section .data.read_mostly1818+ .align 81919+ .global xen_domain_type2020+xen_domain_type:2121+ data4 XEN_NATIVE_ASM2222+ .previous2323+2424+ __INIT2525+ENTRY(startup_xen)2626+ // Calculate load offset.2727+ // The constant, LOAD_OFFSET, can't be used because the boot2828+ // loader doesn't always load to the LMA specified by the vmlinux.lds.2929+ mov r9=ip // must be the first instruction to make sure3030+ // that r9 = the physical address of startup_xen.3131+ // Usually r9 = startup_xen - LOAD_OFFSET3232+ movl r8=startup_xen3333+ ;;3434+ sub r9=r9,r8 // Usually r9 = -LOAD_OFFSET.3535+3636+ mov r10=PARAVIRT_HYPERVISOR_TYPE_XEN3737+ movl r11=_start3838+ ;;3939+ add r11=r11,r94040+ movl r8=hypervisor_type4141+ ;;4242+ add r8=r8,r94343+ mov b0=r114444+ ;;4545+ st8 [r8]=r104646+ br.cond.sptk.many b04747+ ;;4848+END(startup_xen)4949+5050+ ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux")5151+ ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6")5252+ ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0")5353+ ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, data8.ua startup_xen - LOAD_OFFSET)5454+5555+#define isBP p3 // are we the Bootstrap Processor?5656+5757+ .text5858+5959+GLOBAL_ENTRY(xen_setup_hook)6060+ mov r8=XEN_PV_DOMAIN_ASM6161+(isBP) movl r9=xen_domain_type;;6262+(isBP) st4 [r9]=r86363+ movl r10=xen_ivt;;6464+6565+ mov cr.iva=r106666+6767+ /* Set xsi base. */6868+#define FW_HYPERCALL_SET_SHARED_INFO_VA 0x6006969+(isBP) mov r2=FW_HYPERCALL_SET_SHARED_INFO_VA7070+(isBP) movl r28=XSI_BASE;;7171+(isBP) break 0x1000;;7272+7373+ /* setup pv_ops */7474+(isBP) mov r4=rp7575+ ;;7676+(isBP) br.call.sptk.many rp=xen_setup_pv_ops7777+ ;;7878+(isBP) mov rp=r47979+ ;;8080+8181+ br.ret.sptk.many rp8282+ ;;8383+END(xen_setup_hook)