# HG changeset patch # User dietmar.hahn@xxxxxxxxxxxxxxxxxxx # Node ID e1fdf6f961a4f65313425978b6209dea31c05e9b # Parent 8a6a6d4afcb31c24ee87a5d30bebec41e8d38126 Added a new hypercall __HYPERVISOR_opt_feature, which let dom0/domU switch on/off special optimization features in the hypervisor. Signed-off-by: Dietmar Hahn diff -r 8a6a6d4afcb3 -r e1fdf6f961a4 xen/arch/ia64/xen/domain.c --- a/xen/arch/ia64/xen/domain.c Fri Jun 22 11:48:49 2007 -0600 +++ b/xen/arch/ia64/xen/domain.c Thu Jun 28 14:38:37 2007 +0200 @@ -1497,3 +1497,30 @@ static void __init parse_dom0_mem(char * dom0_size = parse_size_and_unit(s, NULL); } custom_param("dom0_mem", parse_dom0_mem); + +/* Switch a optimisation feature on/off. */ +int domain_opt_feature(struct xen_ia64_opt_feature* f) +{ + struct arch_domain* d = &(current->domain->arch); + long rc = 0; + switch (f->cmd) { + case IA64_OPT_FEATURE_IDENTITY_MAPPING: + if (f->on) { + d->opt_feature.mask |= f->cmd; + d->opt_feature.ident_map.pgprot = f->pgprot; + d->opt_feature.ident_map.key = f->key; + } + else { + d->opt_feature.mask &= ~(f->cmd); + d->opt_feature.ident_map.pgprot = 0; + d->opt_feature.ident_map.key = 0; + } + break; + default: + printk("%s: unknown opt_feature: %ld\n", __func__, f->cmd); + rc = -ENOSYS; + break; + } + return rc; +} + diff -r 8a6a6d4afcb3 -r e1fdf6f961a4 xen/arch/ia64/xen/hypercall.c --- a/xen/arch/ia64/xen/hypercall.c Fri Jun 22 11:48:49 2007 -0600 +++ b/xen/arch/ia64/xen/hypercall.c Thu Jun 28 14:38:37 2007 +0200 @@ -224,6 +224,15 @@ ia64_hypercall(struct pt_regs *regs) regs->r10 = fpswa_ret.err1; regs->r11 = fpswa_ret.err2; break; + case __HYPERVISOR_opt_feature: { + XEN_GUEST_HANDLE(void) arg; + struct xen_ia64_opt_feature optf; + set_xen_guest_handle(arg, (void*)(vcpu_get_gr(v,33))); + if (copy_from_guest(&optf, arg, 1) == 0) + regs->r8 = domain_opt_feature(&optf); + else regs->r8 = -EFAULT; + break; + } default: printk("unknown ia64 fw hypercall %lx\n", regs->r2); regs->r8 = do_ni_hypercall(); diff -r 8a6a6d4afcb3 -r e1fdf6f961a4 xen/arch/ia64/xen/vcpu.c --- a/xen/arch/ia64/xen/vcpu.c Fri Jun 22 11:48:49 2007 -0600 +++ b/xen/arch/ia64/xen/vcpu.c Thu Jun 28 14:38:37 2007 +0200 @@ -1709,11 +1709,13 @@ IA64FAULT vcpu_translate(VCPU * vcpu, u6 vcpu_thash(vcpu, address, iha); if (!(rr & RR_VE_MASK) || !(pta & IA64_PTA_VE)) { REGS *regs = vcpu_regs(vcpu); + struct arch_domain* ad = &(vcpu->domain->arch); // NOTE: This is specific code for linux kernel // We assume region 7 is identity mapped - if (region == 7 && ia64_psr(regs)->cpl == 2) { + if (region == 7 && ia64_psr(regs)->cpl == 2 && + ad->opt_feature.mask & IA64_OPT_FEATURE_IDENTITY_MAPPING) { pte.val = address & _PAGE_PPN_MASK; - pte.val = pte.val | pgprot_val(PAGE_KERNEL); + pte.val = pte.val | ad->opt_feature.ident_map.pgprot; goto out; } return is_data ? IA64_ALT_DATA_TLB_VECTOR : diff -r 8a6a6d4afcb3 -r e1fdf6f961a4 xen/include/asm-ia64/domain.h --- a/xen/include/asm-ia64/domain.h Fri Jun 22 11:48:49 2007 -0600 +++ b/xen/include/asm-ia64/domain.h Thu Jun 28 14:38:37 2007 +0200 @@ -66,6 +66,20 @@ struct xen_sal_data { int efi_virt_mode; /* phys : 0 , virt : 1 */ }; +/* Optimization feature in the hypervisor, see + * __HYPERVISOR_opt_feature in arch-ia64.h + */ +struct opt_feature { + unsigned long mask; + struct identity_mapping { /* IA64_OPT_FEATURE_IDENTITY_MAPPING */ + unsigned long pgprot; /* The page protection bit mask of the pte.*/ + unsigned long key; /* A protection key. */ + } ident_map; +}; + +/* Switch a optimisation feature on/off. */ +extern int domain_opt_feature(struct xen_ia64_opt_feature*); + struct arch_domain { struct mm_struct mm; @@ -129,6 +143,8 @@ struct arch_domain { struct last_vcpu last_vcpu[NR_CPUS]; + struct opt_feature opt_feature; + #ifdef CONFIG_XEN_IA64_TLB_TRACK struct tlb_track* tlb_track; #endif diff -r 8a6a6d4afcb3 -r e1fdf6f961a4 xen/include/public/arch-ia64.h --- a/xen/include/public/arch-ia64.h Fri Jun 22 11:48:49 2007 -0600 +++ b/xen/include/public/arch-ia64.h Thu Jun 28 14:38:37 2007 +0200 @@ -622,6 +622,39 @@ struct xen_ia64_boot_param { #define XENCOMM_INLINE_ADDR(addr) \ ((unsigned long)(addr) & ~XENCOMM_INLINE_MASK) +#ifndef __ASSEMBLY__ + +/* Optimization features. + * The hypervisor may do some special optimizations for guests. This hypercall + * can be used to switch on/of these special optimizations. + */ +#define __HYPERVISOR_opt_feature 0x700UL + +#define IA64_OPT_FEATURE_OFF 0x0 +#define IA64_OPT_FEATURE_ON 0x1 + +/* If this feature is switched on, the hypervisor does inserting the + * tlb entries without calling the guests traphandler. + * This is usable in guests using region 7 for identity mapping like + * the linux kernel does. + */ +#define IA64_OPT_FEATURE_IDENTITY_MAPPING 0x1UL + +struct xen_ia64_opt_feature { + unsigned long cmd; /* Which feature */ + unsigned char on; /* Feature on/off */ + union { + struct { + /* The page protection bit mask of the pte. + * This will be or'ed with the pte. */ + unsigned long pgprot; + unsigned long key; /* A protection key for itir. */ + }; + }; +}; + +#endif /* __ASSEMBLY__ */ + /* xen perfmon */ #ifdef XEN #ifndef __ASSEMBLY__