# HG changeset patch
# User Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
# Node ID 17aa29a18b080bd96286b29e7b5918701a330eff
# Parent e30fba67c38de4e6a769f0b57bb8613d79a23f16
[powerpc] Use new method to detect NULL xencomm handle
old method wasted cycles and could give false positive.
Signed-off-by: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
---
arch/powerpc/platforms/xen/hcall.c | 5 +---
drivers/xen/core/xencomm.c | 45 +++++++++++++++++++------------------
2 files changed, 26 insertions(+), 24 deletions(-)
diff -r e30fba67c38d -r 17aa29a18b08 arch/powerpc/platforms/xen/hcall.c
--- a/arch/powerpc/platforms/xen/hcall.c Wed Jul 26 15:00:06 2006 -0400
+++ b/arch/powerpc/platforms/xen/hcall.c Thu Jul 27 18:57:20 2006 -0400
@@ -93,9 +93,8 @@ int HYPERVISOR_xen_version(int cmd, void
argsize = sizeof(xen_platform_parameters_t);
break;
case XENVER_pagesize:
- argsize = sizeof(void *);
- break;
-
+ argsize = (arg == NULL) ? 0 : sizeof(void *);
+ break;
default:
printk("%s: unknown version cmd %d\n", __func__, cmd);
return -ENOSYS;
diff -r e30fba67c38d -r 17aa29a18b08 drivers/xen/core/xencomm.c
--- a/drivers/xen/core/xencomm.c Wed Jul 26 15:00:06 2006 -0400
+++ b/drivers/xen/core/xencomm.c Thu Jul 27 18:57:20 2006 -0400
@@ -59,33 +59,36 @@ static int __xencomm_init(struct xencomm
unsigned long recorded = 0;
int i = 0;
+ BUG_ON((buffer == NULL) && (bytes > 0));
+
/* record the physical pages used */
- if (buffer) {
- while ((recorded < bytes) && (i < desc->nr_addrs)) {
- unsigned long vaddr = (unsigned long)buffer + recorded;
- unsigned long paddr;
- int offset;
- int chunksz;
+ if (buffer == NULL)
+ desc->nr_addrs = 0;
- offset = vaddr % PAGE_SIZE; /* handle partial pages */
- chunksz = min(PAGE_SIZE - offset, bytes - recorded);
+ while ((recorded < bytes) && (i < desc->nr_addrs)) {
+ unsigned long vaddr = (unsigned long)buffer + recorded;
+ unsigned long paddr;
+ int offset;
+ int chunksz;
- paddr = to_phys(vaddr);
- if (paddr == ~0UL) {
- printk("%s: couldn't translate vaddr %lx\n",
- __func__, vaddr);
- return -EINVAL;
- }
+ offset = vaddr % PAGE_SIZE; /* handle partial pages */
+ chunksz = min(PAGE_SIZE - offset, bytes - recorded);
- desc->address[i++] = paddr;
- recorded += chunksz;
+ paddr = to_phys(vaddr);
+ if (paddr == ~0UL) {
+ printk("%s: couldn't translate vaddr %lx\n",
+ __func__, vaddr);
+ return -EINVAL;
}
- if (recorded < bytes) {
- printk("%s: could only translate %ld of %ld bytes\n",
- __func__, recorded, bytes);
- return -ENOSPC;
- }
+ desc->address[i++] = paddr;
+ recorded += chunksz;
+ }
+
+ if (recorded < bytes) {
+ printk("%s: could only translate %ld of %ld bytes\n",
+ __func__, recorded, bytes);
+ return -ENOSPC;
}
/* mark remaining addresses invalid (just for safety) */
_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel
|