# HG changeset patch # User dietmar.hahn@xxxxxxxxxxxxxxxxxxx # Node ID e990fa5f7828e3795c1a20122cf79ef27478d7df # Parent 1b51e7262318a23f14b7ca10e559f2777987c31a Added a new hypercall interface to support special dom0/domU optimization's in the hypervisor. Signed-off-by: Dietmar Hahn diff -r 1b51e7262318 -r e990fa5f7828 xen/arch/ia64/xen/domain.c --- a/xen/arch/ia64/xen/domain.c Mon Jun 25 11:59:12 2007 +0200 +++ b/xen/arch/ia64/xen/domain.c Wed Jun 27 13:33:08 2007 +0200 @@ -1497,3 +1497,29 @@ 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 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; + } + else { + d->opt_feature.mask &= ~(f->cmd); + d->opt_feature.ident_map.pgprot = 0; + } + break; + default: + printk("%s: unknown opt_feature: %ld\n", __func__, f->cmd); + rc = -ENOSYS; + break; + } + return rc; +} + + diff -r 1b51e7262318 -r e990fa5f7828 xen/arch/ia64/xen/hypercall.c --- a/xen/arch/ia64/xen/hypercall.c Mon Jun 25 11:59:12 2007 +0200 +++ b/xen/arch/ia64/xen/hypercall.c Wed Jun 27 13:33:08 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 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 1b51e7262318 -r e990fa5f7828 xen/arch/ia64/xen/vcpu.c --- a/xen/arch/ia64/xen/vcpu.c Mon Jun 25 11:59:12 2007 +0200 +++ b/xen/arch/ia64/xen/vcpu.c Wed Jun 27 13:33:08 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 1b51e7262318 -r e990fa5f7828 xen/include/asm-ia64/domain.h --- a/xen/include/asm-ia64/domain.h Mon Jun 25 11:59:12 2007 +0200 +++ b/xen/include/asm-ia64/domain.h Wed Jun 27 13:33:08 2007 +0200 @@ -65,6 +65,19 @@ struct xen_sal_data { /* There are these for EFI_SET_VIRTUAL_ADDRESS_MAP emulation. */ int efi_virt_mode; /* phys : 0 , virt : 1 */ }; + +/* Optimization feature in the hypervisor, see + * FW_HYPERCALL_OPT_FEATURE in arch-ia64.h + */ +struct opt_feature { + unsigned long mask; + struct identity_mapping { /* IA64_OPT_FEATURE_IDENTITY_MAPPING */ + unsigned long pgprot; + /* Maybe a protection key later. */ + } ident_map; +}; +/* Switch a optimisation feature on/off. */ +extern int domain_opt_feature(struct ia64_opt_feature*); struct arch_domain { struct mm_struct mm; @@ -129,6 +142,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 1b51e7262318 -r e990fa5f7828 xen/include/public/arch-ia64.h --- a/xen/include/public/arch-ia64.h Mon Jun 25 11:59:12 2007 +0200 +++ b/xen/include/public/arch-ia64.h Wed Jun 27 13:33:08 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 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; + /* Maybe later a protection key! */ + }; + }; +}; + +#endif /* __ASSEMBLY__ */ + /* xen perfmon */ #ifdef XEN #ifndef __ASSEMBLY__