xen-devel
[Xen-devel] Re: [RFC PATCH 08/35] Add Xen-specific memory management def
To: |
Chris Wright <chrisw@xxxxxxxxxxxx> |
Subject: |
[Xen-devel] Re: [RFC PATCH 08/35] Add Xen-specific memory management definitions |
From: |
Pete Zaitcev <zaitcev@xxxxxxxxxx> |
Date: |
Sun, 14 May 2006 23:44:18 -0700 |
Cc: |
xen-devel@xxxxxxxxxxxxxxxxxxx, ian.pratt@xxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, virtualization@xxxxxxxxxxxxxx, zaitcev@xxxxxxxxxx, Christian.Limpach@xxxxxxxxxxxx |
Delivery-date: |
Sun, 14 May 2006 23:44:52 -0700 |
Envelope-to: |
www-data@xxxxxxxxxxxxxxxxxx |
In-reply-to: |
<20060509085151.047254000@xxxxxxxxxxxx> |
List-help: |
<mailto:xen-devel-request@lists.xensource.com?subject=help> |
List-id: |
Xen developer discussion <xen-devel.lists.xensource.com> |
List-post: |
<mailto:xen-devel@lists.xensource.com> |
List-subscribe: |
<http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe> |
List-unsubscribe: |
<http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe> |
Organization: |
Red Hat, Inc. |
References: |
<20060509084945.373541000@xxxxxxxxxxxx> <20060509085151.047254000@xxxxxxxxxxxx> |
Sender: |
xen-devel-bounces@xxxxxxxxxxxxxxxxxxx |
On Tue, 09 May 2006 00:00:08 -0700, Chris Wright <chrisw@xxxxxxxxxxxx> wrote:
I'm a little concerned with the code below being entirely too smart:
> +static inline unsigned long mfn_to_pfn(unsigned long mfn)
> +{
> +#ifndef CONFIG_XEN_SHADOW_MODE
> + unsigned long pfn;
> +
> + if (xen_feature(XENFEAT_auto_translated_physmap))
> + return mfn;
> +
> + /*
> + * The array access can fail (e.g., device space beyond end of RAM).
> + * In such cases it doesn't matter what we return (we return garbage),
> + * but we must handle the fault without crashing!
> + */
> + asm (
> + "1: movl %1,%0\n"
> + "2:\n"
> + ".section __ex_table,\"a\"\n"
> + " .align 4\n"
> + " .long 1b,2b\n"
> + ".previous"
> + : "=r" (pfn) : "m" (machine_to_phys_mapping[mfn]) );
> +
> + return pfn;
> +#else
> + return mfn;
> +#endif
> +}
I found that if someone tries to use this too early, hypervisor terminates
the domain with a message like this:
(XEN) DOM0: (file=mm.c, line=486) Non-privileged attempt to map I/O space
000fec00
Why can't we use something like this, only a proper number of machine
pages:
diff -urp -X dontdiff
linux-2.6.15-1.2054_FC5/include/asm-x86_64/mach-xen/asm/page.h
linux-2.6.15-1.2054_FC5.z3/include/asm-x86_64/mach-xen/asm/page.h
--- linux-2.6.15-1.2054_FC5/include/asm-x86_64/mach-xen/asm/page.h
2006-03-17 17:52:38.000000000 -0800
+++ linux-2.6.15-1.2054_FC5.z3/include/asm-x86_64/mach-xen/asm/page.h
2006-05-11 20:36:16.000000000 -0700
@@ -101,26 +101,11 @@ static inline int phys_to_machine_mappin
static inline unsigned long mfn_to_pfn(unsigned long mfn)
{
- unsigned long pfn;
-
if (xen_feature(XENFEAT_auto_translated_physmap))
return mfn;
-
- /*
- * The array access can fail (e.g., device space beyond end of RAM).
- * In such cases it doesn't matter what we return (we return garbage),
- * but we must handle the fault without crashing!
- */
- asm (
- "1: movq %1,%0\n"
- "2:\n"
- ".section __ex_table,\"a\"\n"
- " .align 8\n"
- " .quad 1b,2b\n"
- ".previous"
- : "=r" (pfn) : "m" (machine_to_phys_mapping[mfn]) );
-
- return pfn;
+ if (mfn >= 1048576) /* 4GB _machine_ RAM. XXX How to find out? */
+ return ~0;
+ return machine_to_phys_mapping[mfn];
}
/*
I'm sure you considered this, but decided to be tricky. Why?
No way to find the safe number of machine pages in a guest?
-- Pete
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
|
|