Hi,
attached to this mail are 2 patches:
- opt_feature_xen.patch
implements the new hypercall __HYPERVISOR_opt_feature in the hypervisor.
- opt_feature_linux.patch
implements the usage of the hypercall.
The xen - patch has real effects in vcpu_translate() on inserting identity
mappings in the vhpt/tlb. I'am not sure about some performance impacts.
But without such a patch correct future protection key handling is impossible.
Please send comments or commit!
Thanks.
Dietmar
# HG changeset patch
# User [EMAIL PROTECTED]
# Node ID 87ff9310ce082454ae91d4939b888180d7b5b04b
# Parent 3df04f34c4aa7679bf30a7fe6b46d8ccc0a004da
Added the usage of the new hypervisor call HYPERVISOR_opt_feature().
Signed-off-by: Dietmar Hahn <[EMAIL PROTECTED]>
diff -r 3df04f34c4aa -r 87ff9310ce08 arch/ia64/xen/xcom_hcall.c
--- a/arch/ia64/xen/xcom_hcall.c Mon Jun 18 13:59:27 2007 -0600
+++ b/arch/ia64/xen/xcom_hcall.c Thu Jun 28 14:30:52 2007 +0200
@@ -397,6 +397,13 @@ xencomm_hypercall_vcpu_op(int cmd, int c
xencomm_create_inline(arg));
}
+long
+xencomm_hypercall_opt_feature(unsigned long cmd, void *arg)
+{
+ return xencomm_arch_hypercall_opt_feature(cmd,
+ xencomm_create_inline(arg));
+}
+
int
xencomm_hypercall_fpswa_revision(unsigned int *revision)
{
diff -r 3df04f34c4aa -r 87ff9310ce08 drivers/xen/core/features.c
--- a/drivers/xen/core/features.c Mon Jun 18 13:59:27 2007 -0600
+++ b/drivers/xen/core/features.c Thu Jun 28 14:30:52 2007 +0200
@@ -8,12 +8,14 @@
#include <linux/types.h>
#include <linux/cache.h>
#include <linux/module.h>
+#include <asm/pgtable.h>
#include <asm/hypervisor.h>
#include <xen/features.h>
#ifdef HAVE_XEN_PLATFORM_COMPAT_H
#include <xen/platform-compat.h>
#endif
+
u8 xen_features[XENFEAT_NR_SUBMAPS * 32] __read_mostly;
/* Not a GPL symbol: used in ubiquitous macros, so too restrictive. */
@@ -31,4 +33,11 @@ void setup_xen_features(void)
for (j=0; j<32; j++)
xen_features[i*32+j] = !!(fi.submap & 1<<j);
}
+
+ struct xen_ia64_opt_feature optf;
+ optf.cmd = IA64_OPT_FEATURE_IDENTITY_MAPPING;
+ optf.on = IA64_OPT_FEATURE_ON;
+ optf.pgprot = pgprot_val(PAGE_KERNEL);
+ optf.key = 0; /* No key on linux. */
+ HYPERVISOR_opt_feature(IA64_OPT_FEATURE_IDENTITY_MAPPING,&optf);
}
diff -r 3df04f34c4aa -r 87ff9310ce08 include/asm-ia64/hypercall.h
--- a/include/asm-ia64/hypercall.h Mon Jun 18 13:59:27 2007 -0600
+++ b/include/asm-ia64/hypercall.h Thu Jun 28 14:30:52 2007 +0200
@@ -227,6 +227,12 @@ xencomm_arch_hypercall_xenoprof_op(int o
xencomm_arch_hypercall_xenoprof_op(int op, struct xencomm_handle *arg)
{
return _hypercall2(int, xenoprof_op, op, arg);
+}
+
+static inline long
+xencomm_arch_hypercall_opt_feature(unsigned long op, struct xencomm_handle *arg)
+{
+ return _hypercall2(long, opt_feature, op, arg);
}
extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
@@ -430,6 +436,7 @@ HYPERVISOR_add_io_space(unsigned long ph
#define HYPERVISOR_suspend xencomm_hypercall_suspend
#define HYPERVISOR_vcpu_op xencomm_hypercall_vcpu_op
+#define HYPERVISOR_opt_feature xencomm_hypercall_opt_feature
/* to compile gnttab_copy_grant_page() in drivers/xen/core/gnttab.c */
#define HYPERVISOR_mmu_update(req, count, success_count, domid) ({BUG();0;})
diff -r 3df04f34c4aa -r 87ff9310ce08 include/asm-ia64/xen/xcom_hcall.h
--- a/include/asm-ia64/xen/xcom_hcall.h Mon Jun 18 13:59:27 2007 -0600
+++ b/include/asm-ia64/xen/xcom_hcall.h Thu Jun 28 14:30:52 2007 +0200
@@ -53,6 +53,8 @@ extern int xencomm_hypercall_perfmon_op(
extern long xencomm_hypercall_vcpu_op(int cmd, int cpu, void *arg);
+extern long xencomm_hypercall_opt_feature(unsigned long, void *arg);
+
/* Using mini xencomm. */
extern int xencomm_mini_hypercall_console_io(int cmd, int count, char *str);
diff -r 3df04f34c4aa -r 87ff9310ce08 include/xen/interface/arch-ia64.h
--- a/include/xen/interface/arch-ia64.h Mon Jun 18 13:59:27 2007 -0600
+++ b/include/xen/interface/arch-ia64.h Thu Jun 28 14:30:52 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__
# HG changeset patch
# User [EMAIL PROTECTED]
# 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 <[EMAIL PROTECTED]>
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__
_______________________________________________
Xen-ia64-devel mailing list
[email protected]
http://lists.xensource.com/xen-ia64-devel