All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: Ian Pratt <m+Ian.Pratt@cl.cam.ac.uk>,
	Mike Wray <mike.wray@hp.com>,
	Xen Mailing List <xen-devel@lists.xensource.com>,
	Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Subject: Re: dom0 bootstrap for xenstore
Date: Thu, 16 Jun 2005 18:11:44 +1000	[thread overview]
Message-ID: <1118909504.10407.4.camel@localhost.localdomain> (raw)
In-Reply-To: <ea6e31bae1f900c7b076535f372290a3@cl.cam.ac.uk>

On Thu, 2005-06-16 at 06:17 +0100, Keir Fraser wrote:
> > I suggested that we simply mmap /dev/kmem for the xenstored to access
> > the domain0 page for the moment.  That doesn't work: we'll do something
> > else.
> 
> Just use xc_map_foreign_range(), as you would for mapping any other 
> domain's xenstore page.

So here's my patch against latest bk, including test program but we have
an issue.  On unmap, I hit the BUG_ON() on mm/rmap.c:482.  Is this some
issue with using xc_map_foreign_range() on non-foreign pages?

Rusty.
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal xen/linux-2.6.11-xen-sparse/drivers/xen/privcmd/privcmd.c xen-dom0-store/linux-2.6.11-xen-sparse/drivers/xen/privcmd/privcmd.c
--- xen/linux-2.6.11-xen-sparse/drivers/xen/privcmd/privcmd.c	2005-06-16 18:03:10.000000000 +1000
+++ xen-dom0-store/linux-2.6.11-xen-sparse/drivers/xen/privcmd/privcmd.c	2005-06-16 15:12:49.000000000 +1000
@@ -196,6 +196,34 @@ static int privcmd_ioctl(struct inode *i
     }
     break;
 
+    case IOCTL_PRIVCMD_INITDOMAIN_STORE:
+    {
+        extern int do_xenbus_probe(void*);
+
+        if (xen_start_info.store_evtchn != 0) {
+	    ret = -EINVAL;
+	    break;
+	}
+
+	/* Allocate page. */
+	xen_start_info.store_page = get_zeroed_page(GFP_KERNEL);
+	if (!xen_start_info.store_page) {
+	    ret = -ENOMEM;
+	    break;
+	}
+
+	/* Initial connect. Setup channel and page. */
+	xen_start_info.store_evtchn = data;
+	ret = pfn_to_mfn(virt_to_phys((void *)xen_start_info.store_page)
+			 >> PAGE_SHIFT);
+
+	strcpy((char *)xen_start_info.store_page, "HELLO THERE!");
+
+	/* We'll return then this will wait for daemon to answer */
+	//kthread_run(do_xenbus_probe, NULL, "xenbus_probe");
+    }
+    break;
+
     default:
         ret = -EINVAL;
         break;
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal xen/linux-2.6.11-xen-sparse/include/asm-xen/linux-public/privcmd.h xen-dom0-store/linux-2.6.11-xen-sparse/include/asm-xen/linux-public/privcmd.h
--- xen/linux-2.6.11-xen-sparse/include/asm-xen/linux-public/privcmd.h	2005-06-16 18:03:13.000000000 +1000
+++ xen-dom0-store/linux-2.6.11-xen-sparse/include/asm-xen/linux-public/privcmd.h	2005-06-16 13:47:48.000000000 +1000
@@ -84,5 +84,7 @@ typedef struct privcmd_blkmsg
     _IOC(_IOC_NONE, 'P', 3, sizeof(privcmd_mmapbatch_t))
 #define IOCTL_PRIVCMD_GET_MACH2PHYS_START_MFN \
     _IOC(_IOC_READ, 'P', 4, sizeof(unsigned long))
+#define IOCTL_PRIVCMD_INITDOMAIN_STORE \
+    _IOC(_IOC_READ, 'P', 5, 0)
 
 #endif /* __PRIVCMD_H__ */
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal xen/tools/xenstore/Makefile xen-dom0-store/tools/xenstore/Makefile
--- xen/tools/xenstore/Makefile	2005-06-16 18:03:27.000000000 +1000
+++ xen-dom0-store/tools/xenstore/Makefile	2005-06-16 14:46:51.000000000 +1000
@@ -82,18 +82,22 @@ stresstest: xs_stress xenstored_test
 	rm -rf $(TESTDIR)/store
 	export $(TESTENV); PID=`./xenstored_test --output-pid`; ./xs_stress 10000; ret=$$?; kill $$PID; exit $$ret
 
+xs_dom0_test: xs_dom0_test.o utils.o
+	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lxc -o $@
+
 TAGS:
 	etags `find . -name '*.[ch]'`
 
 tarball: clean
 	cd .. && tar -c -j -v -h -f xenstore.tar.bz2 xenstore/
 
-install: xenstored libxenstore.a
+install: xenstored libxenstore.a xs_dom0_test
 	$(INSTALL_DIR) -p $(DESTDIR)/var/run/xenstored
 	$(INSTALL_DIR) -p $(DESTDIR)/var/lib/xenstored
 	$(INSTALL_DIR) -p $(DESTDIR)/usr/sbin
 	$(INSTALL_DIR) -p $(DESTDIR)/usr/include
 	$(INSTALL_PROG) xenstored $(DESTDIR)/usr/sbin
+	$(INSTALL_PROG) xs_dom0_test $(DESTDIR)/usr/sbin
 	$(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
 	$(INSTALL_DATA) libxenstore.a $(DESTDIR)/usr/$(LIBDIR)
 	$(INSTALL_DATA) xs.h $(DESTDIR)/usr/include
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal xen/tools/xenstore/xs_dom0_test.c xen-dom0-store/tools/xenstore/xs_dom0_test.c
--- xen/tools/xenstore/xs_dom0_test.c	1970-01-01 10:00:00.000000000 +1000
+++ xen-dom0-store/tools/xenstore/xs_dom0_test.c	2005-06-16 16:51:00.000000000 +1000
@@ -0,0 +1,43 @@
+/* Test introduction of domain 0 */
+#include <linux/ioctl.h>
+#include <sys/ioctl.h>
+#include "xs.h"
+#include "utils.h"
+#include <xc.h>
+#include <xen/linux/privcmd.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+int main()
+{
+	int h, local = 0, kernel = 0;
+	long err;
+	void *page;
+
+	h = xc_interface_open();
+	if (h < 0)
+		barf_perror("Failed to open xc");
+
+	if (xc_evtchn_bind_interdomain(h, DOMID_SELF, 0, &local, &kernel) != 0)
+		barf_perror("Failed to bind interdomain");
+
+	printf("Got ports %i & %i\n", local, kernel);
+
+	err = ioctl(h, IOCTL_PRIVCMD_INITDOMAIN_STORE, kernel);
+	if (err < 0)
+		barf_perror("Failed to initialize store");
+	printf("Got mfn %li\n", err);
+
+	page = xc_map_foreign_range(h, 0, getpagesize(), PROT_READ|PROT_WRITE,
+				    err);
+	if (!page)
+		barf_perror("Failed to map page %li", err);
+	printf("Mapped page at %p\n", page);
+	printf("Page says %s\n", (char *)page);
+	munmap(page, getpagesize());
+	printf("unmapped\n");
+	
+	return 0;
+}
+	

-- 
A bad analogy is like a leaky screwdriver -- Richard Braakman

       reply	other threads:[~2005-06-16  8:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <A95E2296287EAD4EB592B5DEEFCE0E9D282251@liverpoolst.ad.cl.cam.ac.uk>
     [not found] ` <1118891075.15491.14.camel@localhost.localdomain>
     [not found]   ` <ea6e31bae1f900c7b076535f372290a3@cl.cam.ac.uk>
2005-06-16  8:11     ` Rusty Russell [this message]
2005-06-16 13:55       ` dom0 bootstrap for xenstore Keir Fraser
2005-06-16 14:03         ` Keir Fraser
2005-06-16 15:54         ` Mike Wray
2005-06-16 19:40           ` Keir Fraser
2005-06-17  3:50         ` Rusty Russell
2005-06-17  7:31         ` Rusty Russell
2005-06-17 13:00           ` Mike Wray
2005-06-20  4:49             ` Rusty Russell
2005-06-20 15:39               ` Mike Wray

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1118909504.10407.4.camel@localhost.localdomain \
    --to=rusty@rustcorp.com.au \
    --cc=Christian.Limpach@cl.cam.ac.uk \
    --cc=Keir.Fraser@cl.cam.ac.uk \
    --cc=m+Ian.Pratt@cl.cam.ac.uk \
    --cc=mike.wray@hp.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.