From owner-p4-projects@FreeBSD.ORG Mon May 1 19:22:36 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7ADC616A447; Mon, 1 May 2006 19:22:36 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EB6B116A426 for ; Mon, 1 May 2006 19:22:35 +0000 (UTC) (envelope-from tkuik@freefall.freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6662243D77 for ; Mon, 1 May 2006 19:22:26 +0000 (GMT) (envelope-from tkuik@freefall.freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k41JMQJ8080989 for ; Mon, 1 May 2006 19:22:26 GMT (envelope-from tkuik@freefall.freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k41JMP6D080972 for perforce@freebsd.org; Mon, 1 May 2006 19:22:25 GMT (envelope-from tkuik@freefall.freebsd.org) Date: Mon, 1 May 2006 19:22:25 GMT Message-Id: <200605011922.k41JMP6D080972@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to tkuik@freefall using -f From: tkuik To: Perforce Change Reviews Cc: Subject: PERFORCE change 96502 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 May 2006 19:22:37 -0000 http://perforce.freebsd.org/chv.cgi?CH=96502 Change 96502 by tkuik@tkuik_freebsd on 2006/05/01 19:22:23 Moved xen-public files up to 3.0.2-2 versions Added support for driver domains along with bug fixes necessary for them to work. This includes the netback & pcifront drivers. Affected files ... .. //depot/projects/xen3/src/sys/conf/Makefile.i386-xen#3 edit .. //depot/projects/xen3/src/sys/conf/files.i386-xen#5 edit .. //depot/projects/xen3/src/sys/conf/options.i386-xen#4 edit .. //depot/projects/xen3/src/sys/dev/pci/pci.c#3 edit .. //depot/projects/xen3/src/sys/dev/xen/blkfront/blkfront.c#5 edit .. //depot/projects/xen3/src/sys/dev/xen/console/xencons_ring.c#3 edit .. //depot/projects/xen3/src/sys/dev/xen/netback/netback.c#1 add .. //depot/projects/xen3/src/sys/dev/xen/netfront/netfront.c#7 edit .. //depot/projects/xen3/src/sys/dev/xen/pcifront/pcifront.c#1 add .. //depot/projects/xen3/src/sys/dev/xen/xenbus/xenbus_comms.c#3 edit .. //depot/projects/xen3/src/sys/dev/xen/xenbus/xenbus_comms.h#2 edit .. //depot/projects/xen3/src/sys/dev/xen/xenbus/xenbus_probe.c#4 edit .. //depot/projects/xen3/src/sys/i386-xen/i386-xen/clock.c#11 edit .. //depot/projects/xen3/src/sys/i386-xen/i386-xen/evtchn.c#4 edit .. //depot/projects/xen3/src/sys/i386-xen/i386-xen/io_apic.c#2 edit .. //depot/projects/xen3/src/sys/i386-xen/i386-xen/machdep.c#12 edit .. //depot/projects/xen3/src/sys/i386-xen/i386-xen/pmap.c#5 edit .. //depot/projects/xen3/src/sys/i386-xen/include/bus_dma.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/hypercall.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/hypervisor-ifs.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/hypervisor.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/pmap.h#4 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/acm.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/acm_ops.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/arch-ia64.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/arch-x86_32.h#3 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/arch-x86_64.h#3 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/dom0_ops.h#3 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/event_channel.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/features.h#1 add .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/grant_table.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/hvm/hvm_info_table.h#1 add .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/hvm/ioreq.h#1 add .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/hvm/vmx_assist.h#1 add .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/io/blkif.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/io/console.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/io/ioreq.h#2 delete .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/io/netif.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/io/pciif.h#1 add .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/io/ring.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/io/tpmif.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/io/xenbus.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/io/xs_wire.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/memory.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/nmi.h#1 add .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/physdev.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/sched.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/sched_ctl.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/trace.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/vcpu.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/version.h#3 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/vmx_assist.h#2 delete .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/xen-compat.h#1 add .. //depot/projects/xen3/src/sys/i386-xen/include/xen-public/xen.h#3 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xen_intr.h#2 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xenbus.h#3 edit .. //depot/projects/xen3/src/sys/i386/i386/busdma_machdep.c#3 edit .. //depot/projects/xen3/src/sys/i386/i386/vm_machdep.c#4 edit .. //depot/projects/xen3/src/sys/i386/include/bus_dma.h#2 edit .. //depot/projects/xen3/src/sys/kern/kern_shutdown.c#6 edit .. //depot/projects/xen3/src/sys/kern/kern_tc.c#3 edit .. //depot/projects/xen3/src/sys/net/if_bridge.c#3 edit .. //depot/projects/xen3/src/sys/net/if_bridgevar.h#3 edit .. //depot/projects/xen3/src/sys/netinet/in_rmx.c#2 edit Differences ... ==== //depot/projects/xen3/src/sys/conf/Makefile.i386-xen#3 (text+ko) ==== @@ -29,6 +29,7 @@ .endif .endif .include "$S/conf/kern.pre.mk" +INCLUDES+= -I$S/i386-xen/include/xen-public -I$S/i386-xen/include/xen-public/io MKMODULESENV+= MACHINE=i386-xen ==== //depot/projects/xen3/src/sys/conf/files.i386-xen#5 (text+ko) ==== @@ -456,3 +456,5 @@ dev/xen/blkfront/blkfront.c standard dev/xen/netfront/netfront.c standard dev/xen/balloon/balloon.c standard +dev/xen/netback/netback.c optional xen_netdev_backend +dev/xen/pcifront/pcifront.c optional xen_pcidev_frontend ==== //depot/projects/xen3/src/sys/conf/options.i386-xen#4 (text+ko) ==== @@ -36,6 +36,11 @@ # support xen hypervisor. XEN opt_global.h +# support network backend driver +XEN_NETDEV_BACKEND opt_global.h +XEN_NETBACK_DEBUG opt_global.h +XEN_NETBACK_DEBUG_LOTS opt_global.h + # support physical device access XEN_PHYSDEV_ACCESS opt_global.h @@ -43,6 +48,9 @@ # stay consistent with mainline for now XEN_PRIVILEGED_GUEST opt_global.h +# support pci device access via front end driver +XEN_PCIDEV_FRONTEND opt_global.h +XEN_PCIDEV_FE_DEBUG opt_global.h # Physical address extensions and support for >4G ram. As above. PAE opt_global.h ==== //depot/projects/xen3/src/sys/dev/pci/pci.c#3 (text+ko) ==== @@ -1112,22 +1112,14 @@ device_t pcib = device_get_parent(dev); struct pci_devinfo *dinfo; int maxslots; - int s, f, pcifunchigh; - uint8_t hdrtype; + int s, f; KASSERT(dinfo_size >= sizeof(struct pci_devinfo), ("dinfo_size too small")); maxslots = PCIB_MAXSLOTS(pcib); for (s = 0; s <= maxslots; s++) { - pcifunchigh = 0; - f = 0; DELAY(1); - hdrtype = REG(PCIR_HDRTYPE, 1); - if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) - continue; - if (hdrtype & PCIM_MFDEV) - pcifunchigh = PCI_FUNCMAX; - for (f = 0; f <= pcifunchigh; f++) { + for (f = 0; f <= PCI_FUNCMAX; f++) { dinfo = pci_read_device(pcib, busno, s, f, dinfo_size); if (dinfo != NULL) { pci_add_child(dev, dinfo); ==== //depot/projects/xen3/src/sys/dev/xen/blkfront/blkfront.c#5 (text+ko) ==== @@ -383,7 +383,7 @@ goto fail; err = bind_evtchn_to_irqhandler(info->evtchn, "xbd", (driver_intr_t *)blkif_int, - info, INTR_TYPE_BIO | INTR_MPSAFE); + info, INTR_TYPE_BIO | INTR_MPSAFE, NULL); if (err <= 0) { xenbus_dev_fatal(dev, err, "bind_evtchn_to_irqhandler failed"); ==== //depot/projects/xen3/src/sys/dev/xen/console/xencons_ring.c#3 (text+ko) ==== @@ -102,7 +102,7 @@ err = bind_evtchn_to_irqhandler(xen_start_info->console_evtchn, "xencons", handle_input, NULL, - INTR_TYPE_MISC | INTR_MPSAFE); + INTR_TYPE_MISC | INTR_MPSAFE, NULL); if (err) { XENPRINTF("XEN console request irq failed %i\n", err); return err; ==== //depot/projects/xen3/src/sys/dev/xen/netfront/netfront.c#7 (text+ko) ==== @@ -490,7 +490,7 @@ network_connect(ifp); info->irq = bind_evtchn_to_irqhandler( - info->evtchn, "xn", xn_intr, info, INTR_TYPE_NET | INTR_MPSAFE); + info->evtchn, "xn", xn_intr, info, INTR_TYPE_NET | INTR_MPSAFE, NULL); show_device(info); ==== //depot/projects/xen3/src/sys/dev/xen/xenbus/xenbus_comms.c#3 (text+ko) ==== @@ -195,7 +195,7 @@ unbind_from_irqhandler(xenbus_irq, &xb_waitq); err = bind_evtchn_to_irqhandler( - xen_start_info->store_evtchn, "xenbus", wake_waiting, NULL, INTR_TYPE_NET); + xen_start_info->store_evtchn, "xenbus", wake_waiting, NULL, INTR_TYPE_NET, NULL); if (err <= 0) { printk("XENBUS request irq failed %i\n", err); return err; ==== //depot/projects/xen3/src/sys/dev/xen/xenbus/xenbus_comms.h#2 (text+ko) ==== @@ -68,7 +68,7 @@ * */ #define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) ==== //depot/projects/xen3/src/sys/dev/xen/xenbus/xenbus_probe.c#4 (text+ko) ==== @@ -92,6 +92,7 @@ #define streq(a, b) (strcmp((a), (b)) == 0) static char *kasprintf(const char *fmt, ...); +static int watch_otherend(struct xenbus_device *dev); /* If something in array of ids matches this device, return it. */ @@ -174,7 +175,7 @@ xendev->nodename); kfree(xendev->otherend); xendev->otherend = NULL; - return ENOENT; + return ENOENT; } return 0; @@ -183,15 +184,77 @@ static int read_backend_details(struct xenbus_device *xendev) { + if (!strncmp(xendev->nodename, "backend", 7)) + return -ENOENT; return read_otherend_details(xendev, "backend-id", "backend"); } static int read_frontend_details(struct xenbus_device *xendev) { + if (strncmp(xendev->nodename, "backend", 7)) + return -ENOENT; return read_otherend_details(xendev, "frontend-id", "frontend"); } +static int watch_otherend_backend(struct xenbus_device *dev) +{ + struct xenbus_transaction *xbt; + + /* We need to add the hotplug-status because we don't */ + /* have a hotplug script to do this. If we ever do, */ + /* this can be removed -- WORK */ + xbt = xenbus_transaction_start(); + xenbus_printf(xbt, dev->nodename, "hotplug-status","%s","connected"); + xenbus_transaction_end(xbt, 0); + + return watch_otherend(dev); +} + +static int watch_otherend_frontend(struct xenbus_device *dev) +{ + return watch_otherend(dev); +} + +/* We need to remove the backend device node from the xenbus */ +/* because we don't have a hotplug script to do this. If we */ +/* ever do, this can be removed -- WORK */ +static int +xenbus_cleanup_backend_device(struct xenbus_device *dev) +{ + char *node, **dir; + unsigned int dir_n; + int i; + + i = strlen(dev->nodename); + if (!i) + return 0; + + node = malloc(i+1, M_DEVBUF, M_WAITOK); + if (!node) + return ENOMEM; + strcpy(node, dev->nodename); +again: + DPRINTK("removing %s\n", node); + if (!xenbus_rm(NULL, node, "")) { + while (i > 7) { + if (node[i] == '/') { + node[i] = '\0'; + dir = xenbus_directory(NULL, node, "", &dir_n); + if (!IS_ERR(dir)) { + kfree(dir); + if (dir_n == 0) + goto again; + } + break; + } + i--; + } + } + free(node, M_DEVBUF); + return 0; +} + static void free_otherend_details(struct xenbus_device *dev) { kfree(dev->otherend); @@ -424,14 +487,14 @@ printk(KERN_WARNING "xenbus_probe: talk_to_otherend on %s failed.\n", dev->nodename); - return err; + return err; } err = drv->probe(dev, id); if (err) goto fail; - - err = watch_otherend(dev); + + err = drv->watch_otherend(dev); if (err) { printk(KERN_WARNING "xenbus_probe: watch_otherend on %s failed.\n", @@ -445,11 +508,16 @@ xenbus_switch_state(dev, NULL, XenbusStateClosed); return ENODEV; } -#if 0 -static int -xenbus_dev_remove(device_t _dev) + +static void xenbus_dev_free(struct xenbus_device *xendev) +{ + LIST_REMOVE(xendev, list); + kfree(xendev); +} + +int +xenbus_remove_device(struct xenbus_device *dev) { - struct xenbus_device *dev = to_xenbus_device(_dev); struct xenbus_driver *drv = dev->driver; DPRINTK(""); @@ -461,9 +529,23 @@ drv->remove(dev); xenbus_switch_state(dev, NULL, XenbusStateClosed); + + if (drv->cleanup_device) + return drv->cleanup_device(dev); + + xenbus_dev_free(dev); + return 0; } + +#if 0 +static int +xenbus_dev_remove(device_t _dev) +{ + return xenbus_remove_device(to_xenbus_device(_dev)); +} #endif + static int xenbus_register_driver_common(struct xenbus_driver *drv, struct xen_bus_type *bus) { @@ -488,17 +570,19 @@ LIST_INSERT_HEAD(&xendrv_list, drv, list); up(&xenwatch_mutex); LIST_FOREACH(xdev, bus->bus, list) { - if (streq(drv->name, xdev->devicetype)) { + if (match_device(drv->ids, xdev)) { xdev->driver = drv; xenbus_dev_probe(xdev); - } } + } return 0; } int xenbus_register_frontend(struct xenbus_driver *drv) { drv->read_otherend_details = read_backend_details; + drv->watch_otherend = watch_otherend_frontend; + drv->cleanup_device = NULL; return xenbus_register_driver_common(drv, &xenbus_frontend); } @@ -507,6 +591,8 @@ int xenbus_register_backend(struct xenbus_driver *drv) { drv->read_otherend_details = read_frontend_details; + drv->watch_otherend = watch_otherend_backend; + drv->cleanup_device = xenbus_cleanup_backend_device; return xenbus_register_driver_common(drv, &xenbus_backend); } @@ -562,7 +648,6 @@ #endif static void xenbus_cleanup_devices(const char *path, struct xendev_list_head * bus) { - panic("unimplemented"); #if 0 struct xb_find_info info = { .nodename = path }; @@ -578,12 +663,6 @@ } #if 0 -static void xenbus_dev_free(struct xenbus_device *xendev) -{ - kfree(xendev); -} - - void xenbus_dev_release(device_t dev) { /* @@ -645,25 +724,25 @@ char *tmpstring; XenbusState state = xenbus_read_driver_state(nodename); - + if (state != XenbusStateInitialising) { /* Device is not new, so ignore it. This can happen if a device is going away after switching to Closed. */ return 0; } - + stringlen = strlen(nodename) + 1 + strlen(type) + 1; xendev = kmalloc(sizeof(*xendev) + stringlen, GFP_KERNEL); if (!xendev) return ENOMEM; memset(xendev, 0, sizeof(*xendev)); - + /* Copy the strings into the extra space. */ - + tmpstring = (char *)(xendev + 1); strcpy(tmpstring, nodename); xendev->nodename = tmpstring; - + tmpstring += strlen(tmpstring) + 1; strcpy(tmpstring, type); xendev->devicetype = tmpstring; @@ -673,30 +752,30 @@ */ LIST_INSERT_HEAD(bus->bus, xendev, list); LIST_FOREACH(xdrv, &xendrv_list, list) { - if (streq(xdrv->name, xendev->devicetype)) + if (match_device(xdrv->ids, xendev)) { xendev->driver = xdrv; + if (!xenbus_dev_probe(xendev)) + break; + } } - if (xendev->driver != NULL) - xenbus_dev_probe(xendev); - #if 0 xendev->dev.parent = &bus->dev; xendev->dev.bus = &bus->bus; xendev->dev.release = xenbus_dev_release; - + err = bus->get_bus_id(xendev->dev.bus_id, xendev->nodename); CHECK_FAIL; - + /* Register with generic device framework. */ err = device_register(&xendev->dev); CHECK_FAIL; - + device_create_file(&xendev->dev, &dev_attr_nodename); device_create_file(&xendev->dev, &dev_attr_devtype); #endif return 0; - + #undef CHECK_FAIL #if 0 fail: @@ -806,7 +885,7 @@ break; } kfree(dir); - + return err; } @@ -913,7 +992,7 @@ xdev = device_get_softc(dev); drv = xdev->driver; - + if (device_get_driver(dev) == NULL) return 0; @@ -922,7 +1001,7 @@ #if 0 /* bus_id ? */ if (err) - printk(KERN_WARNING "xenbus: suspend %s failed: %i\n", + printk(KERN_WARNING "xenbus: suspend %s failed: %i\n", dev->bus_id, err); #endif return 0; @@ -947,8 +1026,8 @@ #if 0 if (err) { printk(KERN_WARNING - "xenbus: resume (talk_to_otherend) %s failed: %i\n", - dev->bus_id, err); + "xenbus: resume (talk_to_otherend) %s failed: %i\n", + dev->bus_id, err); return err; } #endif @@ -993,9 +1072,9 @@ xenbus_add_child(device_t bus, int order, const char *name, int unit) { device_t child; - + child = device_add_child_ordered(bus, order, name, unit); - + return(child); } #endif @@ -1080,7 +1159,7 @@ */ dom0 = (xen_start_info->store_evtchn == 0); - + #ifdef DOM0 if (dom0) { @@ -1101,7 +1180,7 @@ xen_start_info->store_mfn = pfn_to_mfn(virt_to_phys((void *)page) >> PAGE_SHIFT); - + /* Next allocate a local port which xenstored can bind to */ op.cmd = EVTCHNOP_alloc_unbound; op.u.alloc_unbound.dom = DOMID_SELF; @@ -1137,16 +1216,16 @@ panic("xenbus: could not attach"); #endif BUG_ON((xenstored_ready <= 0)); - - + + /* Enumerate devices in xenstore. */ xenbus_probe_devices(&xenbus_frontend); xenbus_probe_devices(&xenbus_backend); - + /* Watch for changes. */ register_xenbus_watch(&fe_watch); register_xenbus_watch(&be_watch); - + /* Notify others that xenstore is up */ EVENTHANDLER_INVOKE(xenstore_event); } @@ -1204,6 +1283,10 @@ #endif + + + + /* * Local variables: * c-file-style: "bsd" ==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/clock.c#11 (text+ko) ==== @@ -314,31 +314,29 @@ int64_t delta_cpu, delta; int cpu = smp_processor_id(); struct shadow_time_info *shadow = &per_cpu(shadow_time, cpu); - long lticks = 0; do { __get_time_values_from_xen(); delta = delta_cpu = shadow->system_timestamp + get_nsec_offset(shadow); - delta -= processed_system_time; delta_cpu -= per_cpu(processed_system_time, cpu); } while (!time_values_up_to_date(cpu)); - if (unlikely(delta < (int64_t)-1000000) || unlikely(delta_cpu < 0)) { + if (unlikely(delta < (int64_t)0) || unlikely(delta_cpu < (int64_t)0)) { printf("Timer ISR: Time went backwards: %lld\n", delta); return; } /* Process elapsed ticks since last call. */ if (delta >= NS_PER_TICK) { - lticks = (delta / NS_PER_TICK); - processed_system_time += lticks*NS_PER_TICK; - per_cpu(processed_system_time, cpu) += lticks*NS_PER_TICK; + processed_system_time += (delta / NS_PER_TICK) * NS_PER_TICK; + per_cpu(processed_system_time, cpu) += (delta_cpu / NS_PER_TICK) * NS_PER_TICK; } hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); + /* * Take synchronised time from Xen once a minute if we're not * synchronised ourselves, and we haven't chosen to keep an independent @@ -357,10 +355,13 @@ static uint32_t getit(void) { + struct shadow_time_info *shadow; + shadow = &per_cpu(shadow_time, smp_processor_id()); __get_time_values_from_xen(); - return per_cpu(shadow_time, smp_processor_id()).system_timestamp; + return shadow->system_timestamp + get_nsec_offset(shadow); } + /* * Wait "n" microseconds. * Relies on timer 1 counting down from (timer_freq / hz) @@ -512,7 +513,9 @@ } set_cyc2ns_scale(cpu_khz/1000); - timer_freq = tsc_freq = xen_timecounter.tc_frequency = cpu_khz * 1000; + tsc_freq = cpu_khz * 1000; + + timer_freq = xen_timecounter.tc_frequency = 1000000000LL; tc_init(&xen_timecounter); @@ -831,9 +834,8 @@ int irq; int cpu = smp_processor_id(); - per_cpu(processed_system_time, cpu) = processed_system_time; - + irq = bind_virq_to_irq(VIRQ_TIMER); PCPU_SET(time_irq, irq); PANIC_IF(intr_add_handler("clk", irq, (driver_intr_t *)clkintr, @@ -859,13 +861,23 @@ static uint32_t xen_get_timecount(struct timecounter *tc) { + uint64_t clk; struct shadow_time_info *shadow; shadow = &per_cpu(shadow_time, smp_processor_id()); __get_time_values_from_xen(); - return (uint32_t)(processed_system_time + shadow->system_timestamp + get_nsec_offset(shadow)); + clk = shadow->system_timestamp + get_nsec_offset(shadow); + + return (uint32_t)((clk / NS_PER_TICK) * NS_PER_TICK); + +} +/* Return system time offset by ticks */ +uint64_t +get_system_time(int ticks) +{ + return processed_system_time + (ticks * NS_PER_TICK); } /* @@ -908,7 +920,6 @@ { __get_time_values_from_xen(); - processed_system_time = per_cpu(processed_system_time, smp_processor_id()); PANIC_IF(HYPERVISOR_set_timer_op(processed_system_time + NS_PER_TICK) != 0); HYPERVISOR_sched_op(SCHEDOP_block, 0); } ==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/evtchn.c#4 (text+ko) ==== @@ -348,14 +348,15 @@ const char *devname, driver_intr_t handler, void *arg, - unsigned long irqflags) + unsigned long irqflags, + void **cookiep) { unsigned int irq; int retval; irq = bind_evtchn_to_irq(evtchn); intr_register_source(&xp->xp_pins[irq].xp_intsrc); - retval = intr_add_handler(devname, irq, handler, arg, irqflags, NULL); + retval = intr_add_handler(devname, irq, handler, arg, irqflags, cookiep); if (retval != 0) { unbind_from_irq(irq); return retval; @@ -407,9 +408,8 @@ void unbind_from_irqhandler(unsigned int irq, void *dev_id) { -#ifdef notyet - intr_remove_handler(dev_id); /* XXX */ -#endif + if (dev_id) + intr_remove_handler(dev_id); /* XXX */ unbind_from_irq(irq); } @@ -915,6 +915,8 @@ tpin = &pin[pirq_to_irq(i)]; tpin->xp_intsrc.is_pic = xp->xp_pirq_pic; tpin->xp_vector = pirq_to_irq(i); + + intr_register_source(&tpin->xp_intsrc); } } ==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/io_apic.c#2 (text+ko) ==== @@ -14,8 +14,8 @@ int ret; op.cmd = PHYSDEVOP_APIC_READ; - op.u.apic_op.apic = io->io_apic_id; - op.u.apic_op.offset = reg; + op.u.apic_op.apic_physbase = (unsigned long)io->io_addr; + op.u.apic_op.reg = reg; ret = HYPERVISOR_physdev_op(&op); if (ret) return ret; @@ -28,8 +28,8 @@ physdev_op_t op; op.cmd = PHYSDEVOP_APIC_WRITE; - op.u.apic_op.apic = io->io_apic_id; - op.u.apic_op.offset = reg; + op.u.apic_op.apic_physbase = (unsigned long)io->io_addr; + op.u.apic_op.reg = reg; op.u.apic_op.value = value; HYPERVISOR_physdev_op(&op); } ==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/machdep.c#12 (text+ko) ==== @@ -1114,7 +1114,7 @@ for (;;) __asm__ ("hlt"); #else - HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_poweroff); + HYPERVISOR_shutdown(SHUTDOWN_poweroff); #endif } ==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/pmap.c#5 (text+ko) ==== @@ -895,6 +895,35 @@ } /* + * Routine: pmap_extract_ma + * Function: + * Like pmap_extract, but returns machine address + */ +vm_paddr_t +pmap_extract_ma(pmap_t pmap, vm_offset_t va) +{ + vm_paddr_t rtval; + pt_entry_t *pte; + pd_entry_t pde; + + rtval = 0; + PMAP_LOCK(pmap); + pde = pmap->pm_pdir[va >> PDRSHIFT]; + if (pde != 0) { + if ((pde & PG_PS) != 0) { + rtval = (pde & ~PDRMASK) | (va & PDRMASK); + PMAP_UNLOCK(pmap); + return rtval; + } + pte = pmap_pte(pmap, va); + rtval = (*pte & PG_FRAME) | (va & PAGE_MASK); + pmap_pte_release(pte); + } + PMAP_UNLOCK(pmap); + return (rtval); +} + +/* * Routine: pmap_extract_and_hold * Function: * Atomically extract and hold the physical page @@ -3205,7 +3234,7 @@ panic("pmap_mapdev: Couldn't alloc kernel virtual memory"); for (tmpva = va; size > 0; ) { - pmap_kenter(tmpva, pa); + pmap_kenter_ma(tmpva, pa); size -= PAGE_SIZE; tmpva += PAGE_SIZE; pa += PAGE_SIZE; ==== //depot/projects/xen3/src/sys/i386-xen/include/bus_dma.h#2 (text+ko) ==== @@ -1,1 +1,7 @@ #include + +#undef _BUS_VIRT_TO_BUS +#define _BUS_VIRT_TO_BUS(pm, va) pmap_extract_ma(pm, va) + +#undef _BUS_VIRT_TO_BUS_KERN +#define _BUS_VIRT_TO_BUS_KERN(va) pmap_kextract_ma(va) ==== //depot/projects/xen3/src/sys/i386-xen/include/hypercall.h#2 (text+ko) ==== @@ -162,7 +162,7 @@ static inline int HYPERVISOR_sched_op( - int cmd, unsigned long arg) + int cmd, void *arg) { return _hypercall2(int, sched_op, cmd, arg); } @@ -296,8 +296,11 @@ HYPERVISOR_suspend( unsigned long srec) { + struct sched_shutdown sched_shutdown = { + .reason = SHUTDOWN_suspend + }; return _hypercall3(int, sched_op, SCHEDOP_shutdown, - SHUTDOWN_suspend, srec); + &sched_shutdown, srec); } #endif /* __HYPERCALL_H__ */ ==== //depot/projects/xen3/src/sys/i386-xen/include/hypervisor-ifs.h#2 (text+ko) ==== @@ -18,6 +18,7 @@ #endif } pte_t; +#define __XEN_INTERFACE_VERSION__ 0x00030101 #define CONFIG_XEN_BLKDEV_GRANT #include #include ==== //depot/projects/xen3/src/sys/i386-xen/include/hypervisor.h#2 (text+ko) ==== @@ -25,6 +25,8 @@ extern start_info_t *xen_start_info; extern shared_info_t *HYPERVISOR_shared_info; +extern uint64_t get_system_time(int ticks); + static inline int HYPERVISOR_console_write(char *str, int count) { @@ -33,13 +35,37 @@ static inline void HYPERVISOR_crash(void) __dead2; +static inline int +HYPERVISOR_shutdown(unsigned int reason) +{ + struct sched_shutdown sched_shutdown = { + .reason = reason + }; + + return HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown); +} + static inline void HYPERVISOR_crash(void) { - _hypercall2(void, sched_op, SCHEDOP_shutdown, SHUTDOWN_crash); + HYPERVISOR_shutdown(SHUTDOWN_crash); /* NEVER REACHED */ for (;;) ; /* eliminate noreturn error */ } +/* Transfer control to hypervisor until an event is detected on one */ +/* of the specified ports or the specified number of ticks elapse */ +static inline int +HYPERVISOR_poll( + evtchn_port_t *ports, unsigned int nr_ports, int ticks) +{ + struct sched_poll sched_poll = { + .ports = ports, + .nr_ports = nr_ports, + .timeout = get_system_time(ticks) + }; + + return HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll); +} #endif /* __HYPERVISOR_H__ */ ==== //depot/projects/xen3/src/sys/i386-xen/include/pmap.h#4 (text+ko) ==== @@ -429,6 +429,8 @@ void pmap_invalidate_range(pmap_t, vm_offset_t, vm_offset_t); void pmap_invalidate_all(pmap_t); +vm_paddr_t pmap_extract_ma(pmap_t pmap, vm_offset_t va); + void pmap_kenter_ma(vm_offset_t va, vm_paddr_t pa); void pmap_map_readonly(pmap_t pmap, vm_offset_t va, int len); void pmap_map_readwrite(pmap_t pmap, vm_offset_t va, int len); ==== //depot/projects/xen3/src/sys/i386-xen/include/xen-public/acm.h#2 (text+ko) ==== @@ -1,25 +1,8 @@ -/**************************************************************** - * acm.h - * - * Copyright (C) 2005 IBM Corporation +/* + * acm.h: Xen access control module interface defintions * - * Author: * Reiner Sailer - * - * Contributors: - * Stefan Berger - * added network byte order support for binary policies - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, version 2 of the - * License. - * - * sHype general access control module header file. - * here are all definitions that are shared between - * xen-core, guest-kernels, and applications. - * - * todo: move from static policy choice to compile option. + * Copyright (c) 2005, International Business Machines Corporation. */ #ifndef _XEN_PUBLIC_ACM_H @@ -169,7 +152,7 @@ uint32_t ec_eval_count; uint32_t gt_eval_count; uint32_t ec_denied_count; - uint32_t gt_denied_count; + uint32_t gt_denied_count; uint32_t ec_cachehit_count; uint32_t gt_cachehit_count; }; ==== //depot/projects/xen3/src/sys/i386-xen/include/xen-public/acm_ops.h#2 (text+ko) ==== @@ -1,19 +1,8 @@ -/****************************************************************************** - * acm_ops.h - * - * Copyright (C) 2005 IBM Corporation +/* + * acm_ops.h: Xen access control module hypervisor commands * - * Author: * Reiner Sailer - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, version 2 of the - * License. - * - * Process acm policy command requests from guest OS. - * access checked by policy; not restricted to DOM0 - * + * Copyright (c) 2005, International Business Machines Corporation. >>> TRUNCATED FOR MAIL (1000 lines) <<<