CVS commit: [jym-xensuspend] src/sys/arch/x86/x86
Module Name:src Committed By: jym Date: Sat Sep 17 10:59:58 UTC 2011 Modified Files: src/sys/arch/x86/x86 [jym-xensuspend]: pmap.c Log Message: Fix comment, as noted by cherry@. To generate a diff of this commit: cvs rdiff -u -r1.77.2.12 -r1.77.2.13 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.77.2.12 src/sys/arch/x86/x86/pmap.c:1.77.2.13 --- src/sys/arch/x86/x86/pmap.c:1.77.2.12 Sat Aug 27 15:37:30 2011 +++ src/sys/arch/x86/x86/pmap.c Sat Sep 17 10:59:58 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.77.2.12 2011/08/27 15:37:30 jym Exp $ */ +/* $NetBSD: pmap.c,v 1.77.2.13 2011/09/17 10:59:58 jym Exp $ */ /*- * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. @@ -171,7 +171,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.77.2.12 2011/08/27 15:37:30 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.77.2.13 2011/09/17 10:59:58 jym Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -4434,10 +4434,10 @@ * handle them correctly during save/restore, leading to incorrect page * tracking and pinning during restore. * For save/restore to succeed, two functions are introduced: - * - pmap_map_shadow_entries(), used by resume code to set the last entry - * of PDIR_SLOT_PTE so that it points to the correct L2 shadow page - * - pmap_unmap_shadow_entries(), used by suspend code to clear all - * PDIR_SLOT_PTE entries pointing to L2 shadow entries + * - pmap_map_recursive_entries(), used by resume code to set the recursive + * mapping entries to their correct value + * - pmap_unmap_recursive_entries(), used by suspend code to clear all + * PDIR_SLOT_PTE entries */ void pmap_map_recursive_entries(void)
CVS commit: [jym-xensuspend] src/sys/arch/xen/xen
Module Name:src Committed By: jym Date: Sun Aug 28 22:34:26 UTC 2011 Modified Files: src/sys/arch/xen/xen [jym-xensuspend]: clock.c evtchn.c Log Message: Put some assertions to check values of the VIRQ <> event channels mappings. Fix the VIRQ_TIMER per-cpu translations, so that save/restore does not choke on event channel being "-1" anymore (ends badly 99,9% of the time when used as an index...) Some KNF and white space fixes. To generate a diff of this commit: cvs rdiff -u -r1.49.2.6 -r1.49.2.7 src/sys/arch/xen/xen/clock.c cvs rdiff -u -r1.42.2.8 -r1.42.2.9 src/sys/arch/xen/xen/evtchn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/clock.c diff -u src/sys/arch/xen/xen/clock.c:1.49.2.6 src/sys/arch/xen/xen/clock.c:1.49.2.7 --- src/sys/arch/xen/xen/clock.c:1.49.2.6 Sat Aug 27 15:37:32 2011 +++ src/sys/arch/xen/xen/clock.c Sun Aug 28 22:34:25 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.49.2.6 2011/08/27 15:37:32 jym Exp $ */ +/* $NetBSD: clock.c,v 1.49.2.7 2011/08/28 22:34:25 jym Exp $ */ /* * @@ -29,7 +29,7 @@ #include "opt_xen.h" #include -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.49.2.6 2011/08/27 15:37:32 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.49.2.7 2011/08/28 22:34:25 jym Exp $"); #include #include @@ -433,11 +433,13 @@ } void -xen_suspendclocks(void) { - +xen_suspendclocks(void) +{ int evtch; evtch = unbind_virq_from_evtch(VIRQ_TIMER); + KASSERT(evtch != -1); + hypervisor_mask_event(evtch); event_remove_handler(evtch, (int (*)(void *))xen_timer_handler, NULL); @@ -445,11 +447,13 @@ } void -xen_resumeclocks(void) { - +xen_resumeclocks(void) +{ int evtch; - + evtch = bind_virq_to_evtch(VIRQ_TIMER); + KASSERT(evtch != -1); + event_set_handler(evtch, (int (*)(void *))xen_timer_handler, NULL, IPL_CLOCK, "clock"); hypervisor_enable_event(evtch); Index: src/sys/arch/xen/xen/evtchn.c diff -u src/sys/arch/xen/xen/evtchn.c:1.42.2.8 src/sys/arch/xen/xen/evtchn.c:1.42.2.9 --- src/sys/arch/xen/xen/evtchn.c:1.42.2.8 Sat Aug 27 15:37:32 2011 +++ src/sys/arch/xen/xen/evtchn.c Sun Aug 28 22:34:26 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: evtchn.c,v 1.42.2.8 2011/08/27 15:37:32 jym Exp $ */ +/* $NetBSD: evtchn.c,v 1.42.2.9 2011/08/28 22:34:26 jym Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.42.2.8 2011/08/27 15:37:32 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.42.2.9 2011/08/28 22:34:26 jym Exp $"); #include "opt_xen.h" #include "isa.h" @@ -197,7 +197,7 @@ } bool -events_suspend (void) +events_suspend(void) { int evtch; @@ -205,6 +205,9 @@ /* VIRQ_DEBUG is the last interrupt to remove */ evtch = unbind_virq_from_evtch(VIRQ_DEBUG); + + KASSERT(evtch != -1); + hypervisor_mask_event(evtch); /* Remove the non-NULL value set in events_init() */ evtsource[evtch] = NULL; @@ -277,7 +280,7 @@ evtch >> LONG_SHIFT, evtch & LONG_MASK); - if (evtsource[evtch]->ev_cpu != ci) { + if (evtsource[evtch]->ev_cpu != ci) { /* facilitate spllower() on remote cpu */ struct cpu_info *rci = evtsource[evtch]->ev_cpu; if (xen_send_ipi(rci, XEN_IPI_KICK) != 0) { @@ -285,7 +288,7 @@ } } - /* leave masked */ + /* leave masked */ return 0; } ci->ci_ilevel = evtsource[evtch]->ev_maxlevel; @@ -381,7 +384,7 @@ evtch_bindcount[evtchn]++; mutex_spin_exit(&evtchn_lock); - + return evtchn; } @@ -393,9 +396,9 @@ mutex_spin_enter(&evtchn_lock); - /* - * XXX: The only per-cpu VIRQ we currently use is VIRQ_TIMER. - * Please re-visit this implementation when others are used. + /* + * XXX: The only per-cpu VIRQ we currently use is VIRQ_TIMER. + * Please re-visit this implementation when others are used. * Note: VIRQ_DEBUG is special-cased, and not used or bound on APs. * XXX: event->virq/ipi can be unified in a linked-list * implementation. @@ -407,12 +410,14 @@ return -1; } + /* Get event channel from VIRQ */ if (virq == VIRQ_TIMER) { evtchn = virq_timer_to_evtch[ci->ci_cpuid]; - } - else { + } else { evtchn = virq_to_evtch[virq]; } + + /* Allocate a channel if there is none already allocated */ if (evtchn == -1) { op.cmd = EVTCHNOP_bind_virq; op.u.bind_virq.virq = virq; @@ -420,14 +425,20 @@ if (HYPERVISOR_event_channel_op(&op) != 0) panic("Failed to bind virtual IRQ %d\n", virq); evtchn = op.u.bind_virq.port; + } + /* Set event channel */ + if (virq == VIRQ_TIMER) { + virq_timer_to_evtch[ci->ci_cpuid] = evtchn; + } else { virq_to_evtch[virq] = evtchn; } + /* Increase ref counter */ evtch_bindcount[evtchn]++; mutex_spin_exit(&evtchn_lock); - + return evtchn; } @@ -498,7 +509,7 @@ evtch_bindcount[evtchn]++; mutex_spin_exit(&evtchn_lock); - + return evtchn; } @@ -658,13 +669,13
CVS commit: [jym-xensuspend] src/sys/arch/xen
Module Name:src Committed By: jym Date: Sat Aug 27 15:56:48 UTC 2011 Modified Files: src/sys/arch/xen/include [jym-xensuspend]: shutdown_xenbus.h xen.h src/sys/arch/xen/x86 [jym-xensuspend]: hypervisor_machdep.c src/sys/arch/xen/xen [jym-xensuspend]: shutdown_xenbus.c xen_machdep.c Log Message: Rename the functions for suspend to reflect that Xen does not hijack the ACPI "sleepstate" sysctl(7) node anymore. Add a boolean value to mark that the save/suspend operation has been notified by dom0, so as to avoid possible errors where admin would like to schedule the domain for sleep without dom0 being prepared for that. Fail with EAGAIN in this case. Sprinkle some KNF. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.3.34.1 src/sys/arch/xen/include/shutdown_xenbus.h cvs rdiff -u -r1.30.8.7 -r1.30.8.8 src/sys/arch/xen/include/xen.h cvs rdiff -u -r1.11.8.9 -r1.11.8.10 src/sys/arch/xen/x86/hypervisor_machdep.c cvs rdiff -u -r1.5.8.3 -r1.5.8.4 src/sys/arch/xen/xen/shutdown_xenbus.c cvs rdiff -u -r1.4.12.9 -r1.4.12.10 src/sys/arch/xen/xen/xen_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/include/shutdown_xenbus.h diff -u src/sys/arch/xen/include/shutdown_xenbus.h:1.3 src/sys/arch/xen/include/shutdown_xenbus.h:1.3.34.1 --- src/sys/arch/xen/include/shutdown_xenbus.h:1.3 Wed Oct 17 19:58:29 2007 +++ src/sys/arch/xen/include/shutdown_xenbus.h Sat Aug 27 15:56:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: shutdown_xenbus.h,v 1.3 2007/10/17 19:58:29 garbled Exp $ */ +/* $NetBSD: shutdown_xenbus.h,v 1.3.34.1 2011/08/27 15:56:48 jym Exp $ */ /*- * Copyright (c)2006 YAMAMOTO Takashi, @@ -29,6 +29,9 @@ #ifndef _XEN_SHUTDOWN_XENBUS_H_ #define _XEN_SHUTDOWN_XENBUS_H_ +/* Whether dom0 ordered a suspend (true) or not (false) */ +bool xen_suspend_allow; + void shutdown_xenbus_setup(void); #endif /* _XEN_SHUTDOWN_XENBUS_H_ */ Index: src/sys/arch/xen/include/xen.h diff -u src/sys/arch/xen/include/xen.h:1.30.8.7 src/sys/arch/xen/include/xen.h:1.30.8.8 --- src/sys/arch/xen/include/xen.h:1.30.8.7 Sat Aug 27 15:48:35 2011 +++ src/sys/arch/xen/include/xen.h Sat Aug 27 15:56:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xen.h,v 1.30.8.7 2011/08/27 15:48:35 jym Exp $ */ +/* $NetBSD: xen.h,v 1.30.8.8 2011/08/27 15:56:48 jym Exp $ */ /* * @@ -73,7 +73,7 @@ void idle_block(void); /* xen_machdep.c */ -void sysctl_xen_sleepstate_setup(void); +void sysctl_xen_suspend_setup(void); #if defined(XENDEBUG) || 1 /* XXX */ #include Index: src/sys/arch/xen/x86/hypervisor_machdep.c diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.9 src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.10 --- src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.9 Sat Aug 27 15:44:09 2011 +++ src/sys/arch/xen/x86/hypervisor_machdep.c Sat Aug 27 15:56:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor_machdep.c,v 1.11.8.9 2011/08/27 15:44:09 jym Exp $ */ +/* $NetBSD: hypervisor_machdep.c,v 1.11.8.10 2011/08/27 15:56:48 jym Exp $ */ /* * @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.11.8.9 2011/08/27 15:44:09 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.11.8.10 2011/08/27 15:56:48 jym Exp $"); #include #include @@ -383,7 +383,7 @@ /* dom0 does not require the arch-dependent P2M translation table */ if (!xendomain_is_dom0()) { build_p2m_frame_list_list(); - sysctl_xen_sleepstate_setup(); + sysctl_xen_suspend_setup(); } } Index: src/sys/arch/xen/xen/shutdown_xenbus.c diff -u src/sys/arch/xen/xen/shutdown_xenbus.c:1.5.8.3 src/sys/arch/xen/xen/shutdown_xenbus.c:1.5.8.4 --- src/sys/arch/xen/xen/shutdown_xenbus.c:1.5.8.3 Sun Nov 1 21:43:28 2009 +++ src/sys/arch/xen/xen/shutdown_xenbus.c Sat Aug 27 15:56:48 2011 @@ -1,4 +1,4 @@ -/* $Id: shutdown_xenbus.c,v 1.5.8.3 2009/11/01 21:43:28 jym Exp $ */ +/* $Id: shutdown_xenbus.c,v 1.5.8.4 2011/08/27 15:56:48 jym Exp $ */ /*- * Copyright (c)2006 YAMAMOTO Takashi, @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: shutdown_xenbus.c,v 1.5.8.3 2009/11/01 21:43:28 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: shutdown_xenbus.c,v 1.5.8.4 2011/08/27 15:56:48 jym Exp $"); #include #include @@ -130,6 +130,7 @@ } else if (strcmp(reqstr, "reboot") == 0) { sysmon_pswitch_event(&xenbus_reset, PSWITCH_EVENT_PRESSED); } else if (strcmp(reqstr, "suspend") == 0) { + xen_suspend_allow = true; sysmon_pswitch_event(&xenbus_sleep, PSWITCH_EVENT_PRESSED); } else { printf("ignore shutdown request: %s\n", reqstr); @@ -145,6 +146,7 @@ void shutdown_xenbus_setup(void) { + xen_suspend_allow = false; if (sysmon_pswitch_register(&xenbus_power) != 0 || sysmon_pswitch_register(&xenbus_reset) != 0 || Index: src/sys/arch/xen/xen/xen_machdep.c diff -u src/sys/arch/xen/xen/xen_machdep.c:1.4.12.9 src/sys/arch/xen/xen/xen_machdep.c:1.4.12.10 --- src/sys/arch
CVS commit: [jym-xensuspend] src/sys/arch/xen/include
Module Name:src Committed By: jym Date: Sat Aug 27 15:48:36 UTC 2011 Modified Files: src/sys/arch/xen/include [jym-xensuspend]: xen.h Log Message: (HEAD fix) _BSD_VA_LIST_ => va_list To generate a diff of this commit: cvs rdiff -u -r1.30.8.6 -r1.30.8.7 src/sys/arch/xen/include/xen.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/include/xen.h diff -u src/sys/arch/xen/include/xen.h:1.30.8.6 src/sys/arch/xen/include/xen.h:1.30.8.7 --- src/sys/arch/xen/include/xen.h:1.30.8.6 Sat Aug 27 15:44:09 2011 +++ src/sys/arch/xen/include/xen.h Sat Aug 27 15:48:35 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xen.h,v 1.30.8.6 2011/08/27 15:44:09 jym Exp $ */ +/* $NetBSD: xen.h,v 1.30.8.7 2011/08/27 15:48:35 jym Exp $ */ /* * @@ -79,7 +79,7 @@ #include void printk(const char *, ...); -void vprintk(const char *, _BSD_VA_LIST_); +void vprintk(const char *, va_list); #endif #endif
CVS commit: [jym-xensuspend] src/sys/arch/xen
Module Name:src Committed By: jym Date: Sat Aug 27 15:44:09 UTC 2011 Modified Files: src/sys/arch/xen/include [jym-xensuspend]: xen.h src/sys/arch/xen/x86 [jym-xensuspend]: hypervisor_machdep.c Log Message: Further sync with HEAD. To generate a diff of this commit: cvs rdiff -u -r1.30.8.5 -r1.30.8.6 src/sys/arch/xen/include/xen.h cvs rdiff -u -r1.11.8.8 -r1.11.8.9 src/sys/arch/xen/x86/hypervisor_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/include/xen.h diff -u src/sys/arch/xen/include/xen.h:1.30.8.5 src/sys/arch/xen/include/xen.h:1.30.8.6 --- src/sys/arch/xen/include/xen.h:1.30.8.5 Mon May 2 22:49:58 2011 +++ src/sys/arch/xen/include/xen.h Sat Aug 27 15:44:09 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xen.h,v 1.30.8.5 2011/05/02 22:49:58 jym Exp $ */ +/* $NetBSD: xen.h,v 1.30.8.6 2011/08/27 15:44:09 jym Exp $ */ /* * @@ -76,6 +76,8 @@ void sysctl_xen_sleepstate_setup(void); #if defined(XENDEBUG) || 1 /* XXX */ +#include + void printk(const char *, ...); void vprintk(const char *, _BSD_VA_LIST_); #endif Index: src/sys/arch/xen/x86/hypervisor_machdep.c diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.8 src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.9 --- src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.8 Sat May 7 17:39:47 2011 +++ src/sys/arch/xen/x86/hypervisor_machdep.c Sat Aug 27 15:44:09 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor_machdep.c,v 1.11.8.8 2011/05/07 17:39:47 jym Exp $ */ +/* $NetBSD: hypervisor_machdep.c,v 1.11.8.9 2011/08/27 15:44:09 jym Exp $ */ /* * @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.11.8.8 2011/05/07 17:39:47 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.11.8.9 2011/08/27 15:44:09 jym Exp $"); #include #include @@ -86,13 +86,79 @@ // #define PORT_DEBUG 4 // #define EARLY_DEBUG_EVENT +/* callback function type */ +typedef void (*iterate_func_t)(struct cpu_info *, unsigned int, + unsigned int, unsigned int, void *); + +static inline void +evt_iterate_bits(struct cpu_info *ci, volatile unsigned long *pendingl1, + volatile unsigned long *pendingl2, + volatile unsigned long *mask, + iterate_func_t iterate_pending, void *iterate_args) +{ + + KASSERT(pendingl1 != NULL); + KASSERT(pendingl2 != NULL); + + unsigned long l1, l2; + unsigned int l1i, l2i, port; + + l1 = xen_atomic_xchg(pendingl1, 0); + while ((l1i = xen_ffs(l1)) != 0) { + l1i--; + l1 &= ~(1UL << l1i); + + l2 = pendingl2[l1i] & (mask != NULL ? ~mask[l1i] : -1UL); + + if (mask != NULL) xen_atomic_setbits_l(&mask[l1i], l2); + xen_atomic_clearbits_l(&pendingl2[l1i], l2); + + while ((l2i = xen_ffs(l2)) != 0) { + l2i--; + l2 &= ~(1UL << l2i); + + port = (l1i << LONG_SHIFT) + l2i; + + iterate_pending(ci, port, l1i, l2i, iterate_args); + } + } +} + +/* + * Set per-cpu "pending" information for outstanding events that + * cannot be processed now. + */ + +static inline void +evt_set_pending(struct cpu_info *ci, unsigned int port, unsigned int l1i, + unsigned int l2i, void *args) +{ + + KASSERT(args != NULL); + KASSERT(ci != NULL); + + int *ret = args; + + if (evtsource[port]) { + hypervisor_set_ipending(ci, evtsource[port]->ev_imask, + l1i, l2i); + evtsource[port]->ev_evcnt.ev_count++; + if (*ret == 0 && ci->ci_ilevel < + evtsource[port]->ev_maxlevel) + *ret = 1; + } +#ifdef DOM0OPS + else { + /* set pending event */ + xenevt_setipending(l1i, l2i); + } +#endif +} + int stipending(void); int stipending(void) { - unsigned long l1; - unsigned long l2; - unsigned int l1i, l2i, port; volatile shared_info_t *s = HYPERVISOR_shared_info; struct cpu_info *ci; volatile struct vcpu_info *vci; @@ -120,45 +186,16 @@ * we're only called after STIC, so we know that we'll have to * STI at the end */ + while (vci->evtchn_upcall_pending) { cli(); + vci->evtchn_upcall_pending = 0; - /* NB. No need for a barrier here -- XCHG is a barrier - * on x86. */ - l1 = xen_atomic_xchg(&vci->evtchn_pending_sel, 0); - while ((l1i = xen_ffs(l1)) != 0) { - l1i--; - l1 &= ~(1UL << l1i); - - l2 = s->evtchn_pending[l1i] & ~s->evtchn_mask[l1i]; - /* - * mask and clear event. More efficient than calling - * hypervisor_mask/clear_event for each event. - */ - xen_atomic_setbits_l(&s->evtchn_mask[l1i], l2); - xen_atomic_clearbits_l(&s->evtchn_pending[l1i], l2); - while ((l2i = xen_ffs(l2)) != 0) { -l2i--; -l2 &= ~(1UL << l2i); - -port = (l1i << LONG_SHIFT) + l2i; -if (evtsource[port]) { - hypervisor_set_ipending( - evtsource[port]->ev_imask, - l1i, l2i); - evtsource[port]->ev_evcnt.ev_count++; - if (ret == 0 && ci->ci_ilevel < - evtsource[port]->ev_maxlevel) - ret = 1; -} -#ifdef DOM0OPS -else { - /* set pending event */ - xenevt_setipending(l1i,
CVS commit: [jym-xensuspend] src/sys/arch/xen/xen
Module Name:src Committed By: jym Date: Wed Aug 24 21:37:05 UTC 2011 Modified Files: src/sys/arch/xen/xen [jym-xensuspend]: xen_machdep.c Log Message: Now that Xen sysctl(7) moved under machdep, create a machdep.xen.suspend node to command suspension. To generate a diff of this commit: cvs rdiff -u -r1.4.12.8 -r1.4.12.9 src/sys/arch/xen/xen/xen_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/xen_machdep.c diff -u src/sys/arch/xen/xen/xen_machdep.c:1.4.12.8 src/sys/arch/xen/xen/xen_machdep.c:1.4.12.9 --- src/sys/arch/xen/xen/xen_machdep.c:1.4.12.8 Thu May 26 22:32:39 2011 +++ src/sys/arch/xen/xen/xen_machdep.c Wed Aug 24 21:37:05 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_machdep.c,v 1.4.12.8 2011/05/26 22:32:39 jym Exp $ */ +/* $NetBSD: xen_machdep.c,v 1.4.12.9 2011/08/24 21:37:05 jym Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -53,7 +53,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.4.12.8 2011/05/26 22:32:39 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.4.12.9 2011/08/24 21:37:05 jym Exp $"); #include "opt_xen.h" @@ -218,29 +218,39 @@ } /* - * this function sets up the machdep.sleep_state sysctl equivalent - * for guest domains with no ACPI support - * This sysctl mimics the ACPI one, except it should be used only for - * Xen's save/restore functionalities of guest domains + * this function sets up the machdep.xen.suspend sysctl(7) that + * controls domain suspend/save. */ void -sysctl_xen_sleepstate_setup(void) { - - int ret; +sysctl_xen_sleepstate_setup(void) +{ + const struct sysctlnode *node = NULL; /* - * dom0 implements sleep_state support through ACPI - * it should not call this function to register - * machdep.sleep_state sysctl + * dom0 implements sleep support through ACPI. It should not call this + * this function to register a suspend interface. */ KASSERT(!(xendomain_is_dom0())); - ret = sysctl_createv(NULL, 0, NULL, NULL, CTLFLAG_READWRITE, - CTLTYPE_INT, "sleep_state", NULL, sysctl_xen_sleepstate, 0, - NULL, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); - - if (ret) - aprint_error("sysctl_createv failed: %d\n", ret); + sysctl_createv(clog, 0, NULL, &node, + CTLFLAG_PERMANENT, + CTLTYPE_NODE, "machdep", NULL, + NULL, 0, NULL, 0, + CTL_MACHDEP, CTL_EOL); + + sysctl_createv(clog, 0, &node, &node, + CTLFLAG_PERMANENT, + CTLTYPE_NODE, "xen", + SYSCTL_DESCR("Xen top level node"), + NULL, 0, NULL, 0, + CTL_CREATE, CTL_EOL); + + sysctl_createv(clog, 0, &node, &node, + CTLFLAG_PERMANENT | CTLFLAG_READWRITE, + CTLTYPE_INT, "suspend", + SYSCTL_DESCR("Suspend/save control of current Xen domain"), + NULL, sysctl_xen_sleepstate, 0, NULL, 0, + CTL_CREATE, CTL_EOL); } static int
CVS commit: [jym-xensuspend] src/sys/arch/xen
Module Name:src Committed By: jym Date: Mon Jul 25 00:18:28 UTC 2011 Modified Files: src/sys/arch/xen/xen [jym-xensuspend]: evtchn.c if_xennet_xenbus.c xbd_xenbus.c src/sys/arch/xen/xenbus [jym-xensuspend]: xenbus_comms.c Log Message: Pull-up to my branch some of the improvements I committed to HEAD, but forgot to reflect here. Improvements in the attachement routines: in case of error, don't forget to free() the allocated rings. Should not happen anyway, more a matter of staying clean. To generate a diff of this commit: cvs rdiff -u -r1.42.2.6 -r1.42.2.7 src/sys/arch/xen/xen/evtchn.c cvs rdiff -u -r1.33.2.11 -r1.33.2.12 src/sys/arch/xen/xen/if_xennet_xenbus.c cvs rdiff -u -r1.38.2.10 -r1.38.2.11 src/sys/arch/xen/xen/xbd_xenbus.c cvs rdiff -u -r1.12.2.3 -r1.12.2.4 src/sys/arch/xen/xenbus/xenbus_comms.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/evtchn.c diff -u src/sys/arch/xen/xen/evtchn.c:1.42.2.6 src/sys/arch/xen/xen/evtchn.c:1.42.2.7 --- src/sys/arch/xen/xen/evtchn.c:1.42.2.6 Mon Jan 10 00:37:39 2011 +++ src/sys/arch/xen/xen/evtchn.c Mon Jul 25 00:18:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: evtchn.c,v 1.42.2.6 2011/01/10 00:37:39 jym Exp $ */ +/* $NetBSD: evtchn.c,v 1.42.2.7 2011/07/25 00:18:28 jym Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.42.2.6 2011/01/10 00:37:39 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.42.2.7 2011/07/25 00:18:28 jym Exp $"); #include "opt_xen.h" #include "isa.h" @@ -447,10 +447,8 @@ printf("pirq_establish: can't malloc handler info\n"); return NULL; } - if (event_set_handler(evtch, pirq_interrupt, ih, level, evname) != 0) { - free(ih, M_DEVBUF); - return NULL; - } + + event_set_handler(evtch, pirq_interrupt, ih, level, evname); ih->pirq = pirq; ih->evtch = evtch; ih->func = func; Index: src/sys/arch/xen/xen/if_xennet_xenbus.c diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.11 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.12 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.11 Thu May 26 22:30:31 2011 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Mon Jul 25 00:18:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.33.2.11 2011/05/26 22:30:31 jym Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1.33.2.12 2011/07/25 00:18:28 jym Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -85,7 +85,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.33.2.11 2011/05/26 22:30:31 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.33.2.12 2011/07/25 00:18:28 jym Exp $"); #include "opt_xen.h" #include "opt_nfs_boot.h" @@ -385,7 +385,13 @@ sc->sc_rx_ring.sring = rx_ring; /* resume shared structures and tell backend that we are ready */ - xennet_xenbus_resume(self, PMF_Q_NONE); + if (xennet_xenbus_resume(self, PMF_Q_NONE) == false) { + uvm_km_free(kernel_map, (vaddr_t)tx_ring, PAGE_SIZE, + UVM_KMF_WIRED); + uvm_km_free(kernel_map, (vaddr_t)rx_ring, PAGE_SIZE, + UVM_KMF_WIRED); + return; + } #if NRND > 0 rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dev), @@ -493,20 +499,23 @@ (void)pmap_extract_ma(pmap_kernel(), (vaddr_t)tx_ring, &ma); error = xenbus_grant_ring(sc->sc_xbusd, ma, &sc->sc_tx_ring_gntref); if (error) - return false; + goto abort_resume; (void)pmap_extract_ma(pmap_kernel(), (vaddr_t)rx_ring, &ma); error = xenbus_grant_ring(sc->sc_xbusd, ma, &sc->sc_rx_ring_gntref); if (error) - return false; + goto abort_resume; error = xenbus_alloc_evtchn(sc->sc_xbusd, &sc->sc_evtchn); if (error) - return false; + goto abort_resume; aprint_verbose_dev(dev, "using event channel %d\n", sc->sc_evtchn); event_set_handler(sc->sc_evtchn, &xennet_handler, sc, IPL_NET, device_xname(dev)); - return true; + +abort_resume: + xenbus_dev_fatal(sc->sc_xbusd, error, "resuming device"); + return false; } static int Index: src/sys/arch/xen/xen/xbd_xenbus.c diff -u src/sys/arch/xen/xen/xbd_xenbus.c:1.38.2.10 src/sys/arch/xen/xen/xbd_xenbus.c:1.38.2.11 --- src/sys/arch/xen/xen/xbd_xenbus.c:1.38.2.10 Thu May 26 22:30:31 2011 +++ src/sys/arch/xen/xen/xbd_xenbus.c Mon Jul 25 00:18:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xbd_xenbus.c,v 1.38.2.10 2011/05/26 22:30:31 jym Exp $ */ +/* $NetBSD: xbd_xenbus.c,v 1.38.2.11 2011/07/25 00:18:28 jym Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -25,8 +25,32 @@ * */ +/* + * The file contains the xbd frontend code required for block-level + * communications (similar to hard disks) between two Xen domains. + * + * We are not supposed to receive solicitations spontaneously from backend. The + * protocol is therefore fairly simple and uses only one ring to communicate + * with backend: frontend posts requests to the ring then wait
CVS commit: [jym-xensuspend] src/sys/arch/xen/xen
Module Name:src Committed By: jym Date: Thu May 26 22:32:39 UTC 2011 Modified Files: src/sys/arch/xen/xen [jym-xensuspend]: xen_machdep.c Log Message: balloon is now supported, update comment. To generate a diff of this commit: cvs rdiff -u -r1.4.12.7 -r1.4.12.8 src/sys/arch/xen/xen/xen_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/xen_machdep.c diff -u src/sys/arch/xen/xen/xen_machdep.c:1.4.12.7 src/sys/arch/xen/xen/xen_machdep.c:1.4.12.8 --- src/sys/arch/xen/xen/xen_machdep.c:1.4.12.7 Mon Jan 10 00:37:39 2011 +++ src/sys/arch/xen/xen/xen_machdep.c Thu May 26 22:32:39 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_machdep.c,v 1.4.12.7 2011/01/10 00:37:39 jym Exp $ */ +/* $NetBSD: xen_machdep.c,v 1.4.12.8 2011/05/26 22:32:39 jym Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -53,7 +53,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.4.12.7 2011/01/10 00:37:39 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_machdep.c,v 1.4.12.8 2011/05/26 22:32:39 jym Exp $"); #include "opt_xen.h" @@ -321,8 +321,8 @@ if (xen_start_info.nr_pages != physmem) { /* - * XXX JYM for now, we crash - fix it with balloon when - * supported + * XXX JYM for now, we crash - fix it with memory + * hotplug when supported */ DPRINTK(("xen_start_info.nr_pages != physmem")); HYPERVISOR_crash();
CVS commit: [jym-xensuspend] src/sys/arch/xen/xen
Module Name:src Committed By: jym Date: Thu May 26 22:30:32 UTC 2011 Modified Files: src/sys/arch/xen/xen [jym-xensuspend]: if_xennet_xenbus.c xbd_xenbus.c Log Message: Split allocation and initialization of ring I/O for xbd(4) and xennet(4): - allocation belongs to _attach() - init to _resume(), so that it can be used by suspend/resume code too. To generate a diff of this commit: cvs rdiff -u -r1.33.2.10 -r1.33.2.11 src/sys/arch/xen/xen/if_xennet_xenbus.c cvs rdiff -u -r1.38.2.9 -r1.38.2.10 src/sys/arch/xen/xen/xbd_xenbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/if_xennet_xenbus.c diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.10 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.11 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.10 Sat May 7 17:42:09 2011 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Thu May 26 22:30:31 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.33.2.10 2011/05/07 17:42:09 jym Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1.33.2.11 2011/05/26 22:30:31 jym Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -85,7 +85,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.33.2.10 2011/05/07 17:42:09 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.33.2.11 2011/05/26 22:30:31 jym Exp $"); #include "opt_xen.h" #include "opt_nfs_boot.h" @@ -375,9 +375,9 @@ /* alloc shared rings */ tx_ring = (void *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0, - UVM_KMF_WIRED | UVM_KMF_ZERO); + UVM_KMF_WIRED); rx_ring = (void *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0, - UVM_KMF_WIRED | UVM_KMF_ZERO); + UVM_KMF_WIRED); if (tx_ring == NULL || rx_ring == NULL) panic("%s: can't alloc rings", device_xname(self)); @@ -481,8 +481,12 @@ tx_ring = sc->sc_tx_ring.sring; rx_ring = sc->sc_rx_ring.sring; + /* Initialize rings */ + memset(tx_ring, 0, PAGE_SIZE); SHARED_RING_INIT(tx_ring); FRONT_RING_INIT(&sc->sc_tx_ring, tx_ring, PAGE_SIZE); + + memset(rx_ring, 0, PAGE_SIZE); SHARED_RING_INIT(rx_ring); FRONT_RING_INIT(&sc->sc_rx_ring, rx_ring, PAGE_SIZE); Index: src/sys/arch/xen/xen/xbd_xenbus.c diff -u src/sys/arch/xen/xen/xbd_xenbus.c:1.38.2.9 src/sys/arch/xen/xen/xbd_xenbus.c:1.38.2.10 --- src/sys/arch/xen/xen/xbd_xenbus.c:1.38.2.9 Mon May 2 22:49:59 2011 +++ src/sys/arch/xen/xen/xbd_xenbus.c Thu May 26 22:30:31 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xbd_xenbus.c,v 1.38.2.9 2011/05/02 22:49:59 jym Exp $ */ +/* $NetBSD: xbd_xenbus.c,v 1.38.2.10 2011/05/26 22:30:31 jym Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.38.2.9 2011/05/02 22:49:59 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.38.2.10 2011/05/26 22:30:31 jym Exp $"); #include "opt_xen.h" #include "rnd.h" @@ -268,8 +268,7 @@ sc->sc_backend_status = BLKIF_STATE_DISCONNECTED; sc->sc_shutdown = BLKIF_SHUTDOWN_REMOTE; - ring = (void *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0, - UVM_KMF_ZERO | UVM_KMF_WIRED); + ring = (void *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_WIRED); if (ring == NULL) panic("%s: can't alloc ring", device_xname(self)); sc->sc_ring.sring = ring; @@ -372,8 +371,8 @@ s = splbio(); /* wait for requests to complete, then suspend device */ while (sc->sc_backend_status == BLKIF_STATE_CONNECTED && - sc->sc_dksc.sc_dkdev.dk_stats->io_busy > 0) - tsleep(xbd_xenbus_suspend, PRIBIO, "xbdsuspend", hz/2); + sc->sc_dksc.sc_dkdev.dk_stats->io_busy > 0) + tsleep(xbd_xenbus_suspend, PRIBIO, "xbdsuspend", hz/2); hypervisor_mask_event(sc->sc_evtchn); sc->sc_backend_status = BLKIF_STATE_SUSPENDED; @@ -407,8 +406,10 @@ xengnt_revoke_access(sc->sc_ring_gntref); } sc->sc_ring_gntref = GRANT_INVALID_REF; - ring = sc->sc_ring.sring; + /* Initialize ring */ + ring = sc->sc_ring.sring; + memset(ring, 0, PAGE_SIZE); SHARED_RING_INIT(ring); FRONT_RING_INIT(&sc->sc_ring, ring, PAGE_SIZE); @@ -698,9 +699,11 @@ done: xen_rmb(); sc->sc_ring.rsp_cons = i; + RING_FINAL_CHECK_FOR_RESPONSES(&sc->sc_ring, more_to_do); if (more_to_do) goto again; + dk_iodone(sc->sc_di, &sc->sc_dksc); if (sc->sc_xbdreq_wait) wakeup(&sc->sc_xbdreq_wait);
CVS commit: [jym-xensuspend] src/sys/arch
Module Name:src Committed By: jym Date: Thu May 26 22:26:52 UTC 2011 Modified Files: src/sys/arch/x86/include [jym-xensuspend]: pmap.h src/sys/arch/xen/xen [jym-xensuspend]: xbdback_xenbus.c xengnt.c Log Message: Pull-up some modifications from -current to my branch. To generate a diff of this commit: cvs rdiff -u -r1.21.2.9 -r1.21.2.10 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.24.2.4 -r1.24.2.5 src/sys/arch/xen/xen/xbdback_xenbus.c cvs rdiff -u -r1.13.2.5 -r1.13.2.6 src/sys/arch/xen/xen/xengnt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/include/pmap.h diff -u src/sys/arch/x86/include/pmap.h:1.21.2.9 src/sys/arch/x86/include/pmap.h:1.21.2.10 --- src/sys/arch/x86/include/pmap.h:1.21.2.9 Mon May 2 22:49:57 2011 +++ src/sys/arch/x86/include/pmap.h Thu May 26 22:26:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.21.2.9 2011/05/02 22:49:57 jym Exp $ */ +/* $NetBSD: pmap.h,v 1.21.2.10 2011/05/26 22:26:52 jym Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -378,13 +378,11 @@ void pmap_unmap_recursive_entries(void); #endif /* PAE */ +#include + #define XPTE_MASK L1_FRAME -/* XPTE_SHIFT = L1_SHIFT - log2(sizeof(pt_entry_t)) */ -#if defined(__x86_64__) || defined(PAE) -#define XPTE_SHIFT 9 -#else -#define XPTE_SHIFT 10 -#endif +/* Selects the index of a PTE in (A)PTE_BASE */ +#define XPTE_SHIFT (L1_SHIFT - ilog2(sizeof(pt_entry_t))) /* PTE access inline fuctions */ Index: src/sys/arch/xen/xen/xbdback_xenbus.c diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.24.2.4 src/sys/arch/xen/xen/xbdback_xenbus.c:1.24.2.5 --- src/sys/arch/xen/xen/xbdback_xenbus.c:1.24.2.4 Mon May 2 22:49:59 2011 +++ src/sys/arch/xen/xen/xbdback_xenbus.c Thu May 26 22:26:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback_xenbus.c,v 1.24.2.4 2011/05/02 22:49:59 jym Exp $ */ +/* $NetBSD: xbdback_xenbus.c,v 1.24.2.5 2011/05/26 22:26:52 jym Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.24.2.4 2011/05/02 22:49:59 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.24.2.5 2011/05/26 22:26:52 jym Exp $"); #include #include @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -143,7 +144,7 @@ grant_handle_t xbdi_ring_handle; /* to unmap the ring */ vaddr_t xbdi_ring_va; /* to unmap the ring */ /* disconnection must be postponed until all I/O is done */ - volatile unsigned xbdi_refcnt; + int xbdi_refcnt; /* * State for I/O processing/coalescing follows; this has to * live here instead of on the stack because of the @@ -167,13 +168,10 @@ uint xbdi_pendingreqs; /* number of I/O in fly */ }; /* Manipulation of the above reference count. */ -/* xxx...@panix.com: not MP-safe, and move the i386 asm elsewhere. */ -#define xbdi_get(xbdip) (++(xbdip)->xbdi_refcnt) +#define xbdi_get(xbdip) atomic_inc_uint(&(xbdip)->xbdi_refcnt) #define xbdi_put(xbdip) \ do { \ - __asm volatile("decl %0" \ - : "=m"((xbdip)->xbdi_refcnt) : "m"((xbdip)->xbdi_refcnt)); \ - if (0 == (xbdip)->xbdi_refcnt)\ + if (atomic_dec_uint_nv(&(xbdip)->xbdi_refcnt) == 0) \ xbdback_finish_disconnect(xbdip); \ } while (/* CONSTCOND */ 0) @@ -875,7 +873,6 @@ blkif_request_t *req = &xbdi->xbdi_xen_req; blkif_x86_32_request_t *req32; blkif_x86_64_request_t *req64; - int i; (void)obj; if (xbdi->xbdi_ring.ring_n.req_cons != xbdi->xbdi_req_prod) { @@ -893,8 +890,6 @@ req->handle = req32->handle; req->id = req32->id; req->sector_number = req32->sector_number; - for (i = 0; i < req->nr_segments; i++) -req->seg[i] = req32->seg[i]; break; case XBDIP_64: @@ -905,8 +900,6 @@ req->handle = req64->handle; req->id = req64->id; req->sector_number = req64->sector_number; - for (i = 0; i < req->nr_segments; i++) -req->seg[i] = req64->seg[i]; break; } XENPRINTF(("xbdback op %d req_cons 0x%x req_prod 0x%x " @@ -1021,17 +1014,24 @@ static void * xbdback_co_io(struct xbdback_instance *xbdi, void *obj) { - int error; + int i, error; + blkif_request_t *req; + blkif_x86_32_request_t *req32; + blkif_x86_64_request_t *req64; (void)obj; - if (xbdi->xbdi_xen_req.nr_segments < 1 || - xbdi->xbdi_xen_req.nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST ) { + + /* some sanity checks */ + req = &xbdi->xbdi_xen_req; + if (req->nr_segments < 1 || + req->nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST) { printf("xbdback_io domain %d: %d segments\n", xbdi->xbdi_domid, xbdi->xbdi_xen_req.nr_segments); error = EINVAL; goto end; } - if (xbdi->xbdi_xen_req.operation == BL
CVS commit: [jym-xensuspend] src/sys/arch/x86/x86
Module Name:src Committed By: jym Date: Sat May 7 17:52:26 UTC 2011 Modified Files: src/sys/arch/x86/x86 [jym-xensuspend]: pmap.c Log Message: Fix the (recurring) problem with APDPs and Xen: unmap all of them at suspend, and let MD parts remap them when they are needed. The issue is not PAE specific, this can be triggered with i386 and amd64. Xen evaluates mappings in a lazy fashion, and it can incorrectly detects recursive ones when they are pointing to inactive pmaps. Move a comment that explains the L2 shadow page unmapping code closer to the associated function, it makes more sense. Now, you can save/suspend all kind of NetBSD domUs, with xbd(4) and xennet(4) devices. Remaining bugs are in xbd(4) and xennet(4) resuming, where the mappings have to be updated before issuing more I/Os. More Linux code reading I guess... Stay tuned. XXX (note to myself): move away from the machdep.sleep_state sysctl. To generate a diff of this commit: cvs rdiff -u -r1.77.2.10 -r1.77.2.11 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.77.2.10 src/sys/arch/x86/x86/pmap.c:1.77.2.11 --- src/sys/arch/x86/x86/pmap.c:1.77.2.10 Mon May 2 22:49:57 2011 +++ src/sys/arch/x86/x86/pmap.c Sat May 7 17:52:26 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.77.2.10 2011/05/02 22:49:57 jym Exp $ */ +/* $NetBSD: pmap.c,v 1.77.2.11 2011/05/07 17:52:26 jym Exp $ */ /* * Copyright (c) 2007 Manuel Bouyer. @@ -142,7 +142,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.77.2.10 2011/05/02 22:49:57 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.77.2.11 2011/05/07 17:52:26 jym Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -729,24 +729,6 @@ (kernel && (pmap->pm_kernel_cpus & ci->ci_cpumask) != 0)); } -/* - * Flush the content of APDP_PDE - */ -static inline -void pmap_unmap_apdp_pde(void) { - - int i; - - for (i = 0; i < PDP_SIZE; i++) { - pmap_pte_set(&APDP_PDE[i], 0); -#ifdef PAE - /* clear current pmap shadow entries too */ - pmap_pte_set(&APDP_PDE_SHADOW[i], 0); -#endif - } - -} - #ifdef XEN /* * Flush all APDP entries found in pmaps @@ -762,16 +744,7 @@ s = splvm(); -#ifdef PAE - /* - * For PAE, there are two places where alternative recursive mappings - * could be found: in the L2 shadow pages, and the "real" L2 kernel - * page (pmap_kl2pd), which is unique and static. - * We first clear the APDP for the current pmap. As L2 kernel page is - * unique, we only need to do it once for all pmaps. - */ - pmap_unmap_apdp_pde(); -#endif + pmap_unmap_apdp(); mutex_enter(&pmaps_lock); /* @@ -898,7 +871,15 @@ for (i = 0; i < PDP_SIZE; i++) { pmap_pte_set(APDP_PDE+i, 0); #if defined (XEN) && defined (PAE) - /* clear shadow entries too */ + /* + * For PAE, there are two places where alternative recursive + * mappings could be found with Xen: + * - in the L2 shadow pages + * - the "real" L2 kernel page (pmap_kl2pd), which is unique + * and static. + * We first clear the APDP for the current pmap. As L2 kernel + * page is unique, we only need to do it once for all pmaps. + */ pmap_pte_set(APDP_PDE_SHADOW+i, 0); #endif }
CVS commit: [jym-xensuspend] src/sys/arch/xen/xen
Module Name:src Committed By: jym Date: Sat May 7 17:42:09 UTC 2011 Modified Files: src/sys/arch/xen/xen [jym-xensuspend]: if_xennet_xenbus.c Log Message: When it successfully resume a device, return true instead of 0 aka false. To generate a diff of this commit: cvs rdiff -u -r1.33.2.9 -r1.33.2.10 src/sys/arch/xen/xen/if_xennet_xenbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/if_xennet_xenbus.c diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.9 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.10 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.9 Mon May 2 22:49:59 2011 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Sat May 7 17:42:09 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.33.2.9 2011/05/02 22:49:59 jym Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1.33.2.10 2011/05/07 17:42:09 jym Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -85,7 +85,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.33.2.9 2011/05/02 22:49:59 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.33.2.10 2011/05/07 17:42:09 jym Exp $"); #include "opt_xen.h" #include "opt_nfs_boot.h" @@ -392,9 +392,8 @@ RND_TYPE_NET, 0); #endif - if (!pmf_device_register(self, - xennet_xenbus_suspend, - xennet_xenbus_resume)) + if (!pmf_device_register(self, xennet_xenbus_suspend, + xennet_xenbus_resume)) aprint_error_dev(self, "couldn't establish power handler\n"); else pmf_class_network_register(self, ifp); @@ -460,7 +459,7 @@ static bool xennet_xenbus_resume(device_t dev, const pmf_qual_t *qual) { - struct xennet_xenbus_softc *sc = p; + struct xennet_xenbus_softc *sc = device_private(dev); int error; netif_tx_sring_t *tx_ring; netif_rx_sring_t *rx_ring; @@ -503,7 +502,7 @@ event_set_handler(sc->sc_evtchn, &xennet_handler, sc, IPL_NET, device_xname(dev)); - return 0; + return true; } static int
CVS commit: [jym-xensuspend] src/sys/arch/xen
Module Name:src Committed By: jym Date: Sat May 7 17:39:47 UTC 2011 Modified Files: src/sys/arch/xen/x86 [jym-xensuspend]: hypervisor_machdep.c src/sys/arch/xen/xen [jym-xensuspend]: hypervisor.c xencons.c src/sys/arch/xen/xenbus [jym-xensuspend]: xenbus_probe.c Log Message: KNF. To generate a diff of this commit: cvs rdiff -u -r1.11.8.7 -r1.11.8.8 src/sys/arch/xen/x86/hypervisor_machdep.c cvs rdiff -u -r1.43.2.6 -r1.43.2.7 src/sys/arch/xen/xen/hypervisor.c cvs rdiff -u -r1.31.2.8 -r1.31.2.9 src/sys/arch/xen/xen/xencons.c cvs rdiff -u -r1.27.2.7 -r1.27.2.8 src/sys/arch/xen/xenbus/xenbus_probe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/x86/hypervisor_machdep.c diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.7 src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.8 --- src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.7 Mon May 2 22:49:58 2011 +++ src/sys/arch/xen/x86/hypervisor_machdep.c Sat May 7 17:39:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor_machdep.c,v 1.11.8.7 2011/05/02 22:49:58 jym Exp $ */ +/* $NetBSD: hypervisor_machdep.c,v 1.11.8.8 2011/05/07 17:39:47 jym Exp $ */ /* * @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.11.8.7 2011/05/02 22:49:58 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.11.8.8 2011/05/07 17:39:47 jym Exp $"); #include #include @@ -360,7 +360,7 @@ hypervisor_machdep_attach(void) { /* dom0 does not require the arch-dependent P2M translation table */ - if ( !xendomain_is_dom0() ) { + if (!xendomain_is_dom0()) { build_p2m_frame_list_list(); sysctl_xen_sleepstate_setup(); } @@ -370,7 +370,7 @@ hypervisor_machdep_resume(void) { /* dom0 does not require the arch-dependent P2M translation table */ - if ( !(xen_start_info.flags & SIF_INITDOMAIN) ) + if (!xendomain_is_dom0()) update_p2m_frame_list_list(); } Index: src/sys/arch/xen/xen/hypervisor.c diff -u src/sys/arch/xen/xen/hypervisor.c:1.43.2.6 src/sys/arch/xen/xen/hypervisor.c:1.43.2.7 --- src/sys/arch/xen/xen/hypervisor.c:1.43.2.6 Mon May 2 22:49:59 2011 +++ src/sys/arch/xen/xen/hypervisor.c Sat May 7 17:39:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.c,v 1.43.2.6 2011/05/02 22:49:59 jym Exp $ */ +/* $NetBSD: hypervisor.c,v 1.43.2.7 2011/05/07 17:39:47 jym Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -53,7 +53,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.43.2.6 2011/05/02 22:49:59 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.43.2.7 2011/05/07 17:39:47 jym Exp $"); #include #include @@ -304,8 +304,8 @@ } static bool -hypervisor_suspend(device_t dev, const pmf_qual_t *qual) { - +hypervisor_suspend(device_t dev, const pmf_qual_t *qual) +{ events_suspend(); xengnt_suspend(); @@ -313,8 +313,8 @@ } static bool -hypervisor_resume(device_t dev, const pmf_qual_t *qual) { - +hypervisor_resume(device_t dev, const pmf_qual_t *qual) +{ hypervisor_machdep_resume(); xengnt_resume(); Index: src/sys/arch/xen/xen/xencons.c diff -u src/sys/arch/xen/xen/xencons.c:1.31.2.8 src/sys/arch/xen/xen/xencons.c:1.31.2.9 --- src/sys/arch/xen/xen/xencons.c:1.31.2.8 Mon May 2 22:49:59 2011 +++ src/sys/arch/xen/xen/xencons.c Sat May 7 17:39:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xencons.c,v 1.31.2.8 2011/05/02 22:49:59 jym Exp $ */ +/* $NetBSD: xencons.c,v 1.31.2.9 2011/05/07 17:39:47 jym Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -53,7 +53,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.31.2.8 2011/05/02 22:49:59 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.31.2.9 2011/05/07 17:39:47 jym Exp $"); #include "opt_xen.h" @@ -217,7 +217,6 @@ aprint_verbose_dev(dev, "removed event channel %d\n", evtch); } - return true; } Index: src/sys/arch/xen/xenbus/xenbus_probe.c diff -u src/sys/arch/xen/xenbus/xenbus_probe.c:1.27.2.7 src/sys/arch/xen/xenbus/xenbus_probe.c:1.27.2.8 --- src/sys/arch/xen/xenbus/xenbus_probe.c:1.27.2.7 Mon May 2 22:49:59 2011 +++ src/sys/arch/xen/xenbus/xenbus_probe.c Sat May 7 17:39:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xenbus_probe.c,v 1.27.2.7 2011/05/02 22:49:59 jym Exp $ */ +/* $NetBSD: xenbus_probe.c,v 1.27.2.8 2011/05/07 17:39:47 jym Exp $ */ /** * Talks to Xen Store to figure out what devices we have. * @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.27.2.7 2011/05/02 22:49:59 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.27.2.8 2011/05/07 17:39:47 jym Exp $"); #if 0 #define DPRINTK(fmt, args...) \ @@ -122,8 +122,8 @@ } static bool -xenbus_suspend(device_t dev, const pmf_qual_t *qual) { - +xenbus_suspend(device_t dev, const pmf_qual_t *qual) +{ xs_suspend(); xb_suspend_comms(dev); @@ -131,8 +131,8 @@ } sta
CVS commit: [jym-xensuspend] src/sys/arch/xen/xen
Module Name:src Committed By: jym Date: Sat May 7 17:38:35 UTC 2011 Modified Files: src/sys/arch/xen/xen [jym-xensuspend]: balloon.c Log Message: Implement pmf(9) suspend/resume routines for balloon(4). Trivial, heh. To generate a diff of this commit: cvs rdiff -u -r1.5.6.4 -r1.5.6.5 src/sys/arch/xen/xen/balloon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/balloon.c diff -u src/sys/arch/xen/xen/balloon.c:1.5.6.4 src/sys/arch/xen/xen/balloon.c:1.5.6.5 --- src/sys/arch/xen/xen/balloon.c:1.5.6.4 Mon May 2 22:49:59 2011 +++ src/sys/arch/xen/xen/balloon.c Sat May 7 17:38:35 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: balloon.c,v 1.5.6.4 2011/05/02 22:49:59 jym Exp $ */ +/* $NetBSD: balloon.c,v 1.5.6.5 2011/05/07 17:38:35 jym Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ #define BALLOONDEBUG 0 #include -__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.5.6.4 2011/05/02 22:49:59 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.5.6.5 2011/05/07 17:38:35 jym Exp $"); #include #include @@ -246,6 +246,9 @@ goto error; } + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + return; error:
CVS commit: [jym-xensuspend] src/sys/arch/xen
Module Name:src Committed By: jym Date: Wed Mar 30 23:15:06 UTC 2011 Modified Files: src/sys/arch/xen/include/amd64 [jym-xensuspend]: hypercalls.h src/sys/arch/xen/include/i386 [jym-xensuspend]: hypercalls.h src/sys/arch/xen/x86 [jym-xensuspend]: hypervisor_machdep.c x86_xpmap.c src/sys/arch/xen/xen [jym-xensuspend]: if_xennet_xenbus.c xbd_xenbus.c src/sys/arch/xen/xenbus [jym-xensuspend]: xenbus_probe.c Log Message: Sync with my commits in HEAD. To generate a diff of this commit: cvs rdiff -u -r1.5.4.3 -r1.5.4.4 src/sys/arch/xen/include/amd64/hypercalls.h cvs rdiff -u -r1.8.4.3 -r1.8.4.4 src/sys/arch/xen/include/i386/hypercalls.h cvs rdiff -u -r1.11.8.5 -r1.11.8.6 src/sys/arch/xen/x86/hypervisor_machdep.c cvs rdiff -u -r1.12.4.12 -r1.12.4.13 src/sys/arch/xen/x86/x86_xpmap.c cvs rdiff -u -r1.33.2.7 -r1.33.2.8 src/sys/arch/xen/xen/if_xennet_xenbus.c cvs rdiff -u -r1.38.2.7 -r1.38.2.8 src/sys/arch/xen/xen/xbd_xenbus.c cvs rdiff -u -r1.27.2.5 -r1.27.2.6 src/sys/arch/xen/xenbus/xenbus_probe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/include/amd64/hypercalls.h diff -u src/sys/arch/xen/include/amd64/hypercalls.h:1.5.4.3 src/sys/arch/xen/include/amd64/hypercalls.h:1.5.4.4 --- src/sys/arch/xen/include/amd64/hypercalls.h:1.5.4.3 Sun Nov 1 21:43:28 2009 +++ src/sys/arch/xen/include/amd64/hypercalls.h Wed Mar 30 23:15:05 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: hypercalls.h,v 1.5.4.3 2009/11/01 21:43:28 jym Exp $ */ +/* $NetBSD: hypercalls.h,v 1.5.4.4 2011/03/30 23:15:05 jym Exp $ */ /** * hypercall.h * Index: src/sys/arch/xen/include/i386/hypercalls.h diff -u src/sys/arch/xen/include/i386/hypercalls.h:1.8.4.3 src/sys/arch/xen/include/i386/hypercalls.h:1.8.4.4 --- src/sys/arch/xen/include/i386/hypercalls.h:1.8.4.3 Sun Nov 1 21:43:28 2009 +++ src/sys/arch/xen/include/i386/hypercalls.h Wed Mar 30 23:15:05 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: hypercalls.h,v 1.8.4.3 2009/11/01 21:43:28 jym Exp $ */ +/* $NetBSD: hypercalls.h,v 1.8.4.4 2011/03/30 23:15:05 jym Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. Index: src/sys/arch/xen/x86/hypervisor_machdep.c diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.5 src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.6 --- src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.5 Tue Mar 29 20:43:01 2011 +++ src/sys/arch/xen/x86/hypervisor_machdep.c Wed Mar 30 23:15:05 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor_machdep.c,v 1.11.8.5 2011/03/29 20:43:01 jym Exp $ */ +/* $NetBSD: hypervisor_machdep.c,v 1.11.8.6 2011/03/30 23:15:05 jym Exp $ */ /* * @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.11.8.5 2011/03/29 20:43:01 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.11.8.6 2011/03/30 23:15:05 jym Exp $"); #include #include @@ -394,11 +394,11 @@ * A L1 page contains the list of MFN we are looking for */ max_pfn = xen_start_info.nr_pages; -fpp = PAGE_SIZE / sizeof(vaddr_t); +fpp = PAGE_SIZE / sizeof(xen_pfn_t); /* we only need one L3 page */ l3_p2m_page = (vaddr_t *)uvm_km_alloc(kernel_map, PAGE_SIZE, -PAGE_SIZE, UVM_KMF_WIRED | UVM_KMF_NOWAIT); + PAGE_SIZE, UVM_KMF_WIRED | UVM_KMF_NOWAIT); if (l3_p2m_page == NULL) panic("could not allocate memory for l3_p2m_page"); @@ -430,7 +430,7 @@ unsigned long max_pfn; max_pfn = xen_start_info.nr_pages; -fpp = PAGE_SIZE / sizeof(vaddr_t); +fpp = PAGE_SIZE / sizeof(xen_pfn_t); for (i = 0; i < l2_p2m_page_size; i++) { /* Index: src/sys/arch/xen/x86/x86_xpmap.c diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.12.4.12 src/sys/arch/xen/x86/x86_xpmap.c:1.12.4.13 --- src/sys/arch/xen/x86/x86_xpmap.c:1.12.4.12 Tue Mar 29 20:43:01 2011 +++ src/sys/arch/xen/x86/x86_xpmap.c Wed Mar 30 23:15:05 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: x86_xpmap.c,v 1.12.4.12 2011/03/29 20:43:01 jym Exp $ */ +/* $NetBSD: x86_xpmap.c,v 1.12.4.13 2011/03/30 23:15:05 jym Exp $ */ /* * Copyright (c) 2006 Mathieu Ropert @@ -69,7 +69,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.12.4.12 2011/03/29 20:43:01 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.12.4.13 2011/03/30 23:15:05 jym Exp $"); #include "opt_xen.h" #include "opt_ddb.h" Index: src/sys/arch/xen/xen/if_xennet_xenbus.c diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.7 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.8 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.33.2.7 Mon Mar 28 23:04:56 2011 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Wed Mar 30 23:15:06 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.33.2.7 2011/03/28 23:04:56 jym Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1
CVS commit: [jym-xensuspend] src/sys/arch
Module Name:src Committed By: jym Date: Fri Jul 24 11:30:29 UTC 2009 Modified Files: src/sys/arch/x86/include [jym-xensuspend]: pmap.h src/sys/arch/x86/x86 [jym-xensuspend]: pmap.c src/sys/arch/xen/include [jym-xensuspend]: xenpmap.h src/sys/arch/xen/x86 [jym-xensuspend]: x86_xpmap.c src/sys/arch/xen/xen [jym-xensuspend]: xen_machdep.c xencons.c Log Message: - rework the page pinning API, so that now a function is provided for each level of indirection encountered during virtual memory translations. Update pmap accordingly. Pinning looks cleaner that way, and it offers the possibility to pin lower level pages if necessary (NetBSD does not do it currently). - some fixes and comments to explain how page validation/invalidation take place during save/restore/migrate under Xen. L2 shadow entries from PAE are now handled, so basically, suspend/resume works with PAE. - fixes an issue reported by Christoph (cegger@) for xencons suspend/resume in dom0. TODO: - PAE save/restore is currently limited to single-user only, multi-user support requires modifications in PAE pmap that should be discussed first. See the comments about the L2 shadow pages cached in pmap_pdp_cache in this commit. - grant table bug is still there; do not use the kernels of this branch to test suspend/resume, unless you want to experience bad crashes in dom0, and push the big red button. Now there is light at the end of the tunnel :) Note: XEN2 kernels will neither build nor work with this branch. To generate a diff of this commit: cvs rdiff -u -r1.21.2.3 -r1.21.2.4 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.77.2.4 -r1.77.2.5 src/sys/arch/x86/x86/pmap.c cvs rdiff -u -r1.21.8.2 -r1.21.8.3 src/sys/arch/xen/include/xenpmap.h cvs rdiff -u -r1.12.4.4 -r1.12.4.5 src/sys/arch/xen/x86/x86_xpmap.c cvs rdiff -u -r1.4.12.3 -r1.4.12.4 src/sys/arch/xen/xen/xen_machdep.c cvs rdiff -u -r1.31.2.3 -r1.31.2.4 src/sys/arch/xen/xen/xencons.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/include/pmap.h diff -u src/sys/arch/x86/include/pmap.h:1.21.2.3 src/sys/arch/x86/include/pmap.h:1.21.2.4 --- src/sys/arch/x86/include/pmap.h:1.21.2.3 Thu Jul 23 23:31:36 2009 +++ src/sys/arch/x86/include/pmap.h Fri Jul 24 11:30:28 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.21.2.3 2009/07/23 23:31:36 jym Exp $ */ +/* $NetBSD: pmap.h,v 1.21.2.4 2009/07/24 11:30:28 jym Exp $ */ /* * @@ -354,6 +354,34 @@ #ifdef XEN +#ifdef PAE +/* + * Under PAE, Xen handles our recursive mappings to the L2 shadow pages + * erroneously during a restore (the last entry of the PDIR_SLOT_PTE). + * This pages are found in two places: + * - the used ones are found in the pmaps list + * - the unused ones (but still valid from a Xen's point of view) are cached + * inside the pmap_pdp_cache pool. + * This list is not protected by locks, as it is expected to be accessed only + * during pmap_create()/pmap_destroy(), and save/restore code, which + * cannot run concurrently. +struct l2_pdirpte { + SLIST_ENTRY(l2_pinned) l2_pdirpte_list; + paddr_t slot_pte; + paddr_t slot_pte_content; +}; + */ + +/* + * Head of the list of all pages pinned as L2 and containing valid entry + * in PDIR_SLOT_PTE +SLIST_HEAD(l2_pdirpte_head, l2_pdirpte); + */ + +void pmap_map_shadow_entries(void); +void pmap_unmap_shadow_entries(void); +#endif /* PAE */ + #define XPTE_MASK L1_FRAME /* XPTE_SHIFT = L1_SHIFT - log2(sizeof(pt_entry_t)) */ #if defined(__x86_64__) || defined(PAE) Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.77.2.4 src/sys/arch/x86/x86/pmap.c:1.77.2.5 --- src/sys/arch/x86/x86/pmap.c:1.77.2.4 Thu Jul 23 23:31:37 2009 +++ src/sys/arch/x86/x86/pmap.c Fri Jul 24 11:30:28 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.77.2.4 2009/07/23 23:31:37 jym Exp $ */ +/* $NetBSD: pmap.c,v 1.77.2.5 2009/07/24 11:30:28 jym Exp $ */ /* * Copyright (c) 2007 Manuel Bouyer. @@ -154,7 +154,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.77.2.4 2009/07/23 23:31:37 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.77.2.5 2009/07/24 11:30:28 jym Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -557,6 +557,12 @@ .pa_free = pmap_pdp_free, .pa_pagesz = PAGE_SIZE * PDP_SIZE, }; + +#ifdef XEN +/* pool for allocation of the structures tracking L2 pinned shadow pages */ +//static struct pool_cache l2_pdirpte_cache; +#endif /* XEN */ + #endif /* PAE */ void *vmmap; /* XXX: used by mem.c... it should really uvm_map_reserve it */ @@ -752,13 +758,14 @@ for (i = 0; i < PDP_SIZE; i++) { pmap_pte_set(&APDP_PDE[i], 0); #ifdef PAE - /* clear shadow entry too */ + /* clear current pmap shadow entries too */ pmap_pte_set(&APDP_PDE_SHADOW[i], 0); #endif } } +#ifdef XEN3 /* * Flush all APDP entries found in pmaps * Required during Xen save/restore operations, as it does
CVS commit: [jym-xensuspend] src/sys/arch/xen/xen
Module Name:src Committed By: cegger Date: Thu Jun 18 11:14:14 UTC 2009 Modified Files: src/sys/arch/xen/xen [jym-xensuspend]: xen_acpi_machdep.c Log Message: implement ACPI S3 support for Dom0. ok jym@ To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.4.24.1 src/sys/arch/xen/xen/xen_acpi_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/xen_acpi_machdep.c diff -u src/sys/arch/xen/xen/xen_acpi_machdep.c:1.4 src/sys/arch/xen/xen/xen_acpi_machdep.c:1.4.24.1 --- src/sys/arch/xen/xen/xen_acpi_machdep.c:1.4 Sun Feb 17 14:03:16 2008 +++ src/sys/arch/xen/xen/xen_acpi_machdep.c Thu Jun 18 11:14:14 2009 @@ -1,18 +1,122 @@ -/* $NetBSD: xen_acpi_machdep.c,v 1.4 2008/02/17 14:03:16 bouyer Exp $ */ +/* $NetBSD: xen_acpi_machdep.c,v 1.4.24.1 2009/06/18 11:14:14 cegger Exp $ */ #include "acpi.h" #include -__KERNEL_RCSID(0, "$NetBSD: xen_acpi_machdep.c,v 1.4 2008/02/17 14:03:16 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_acpi_machdep.c,v 1.4.24.1 2009/06/18 11:14:14 cegger Exp $"); #include #include #define ACPI_MACHDEP_PRIVATE #include +#include + +static int +xen_dom0_sleepenter(int sleep_state, int pm1a_control, int pm1b_control) +{ + struct xen_platform_op op = { + .cmd = XENPF_enter_acpi_sleep, + .interface_version = XENPF_INTERFACE_VERSION, + .u = { + .enter_acpi_sleep = { +.pm1a_cnt_val = pm1a_control, +.pm1b_cnt_val = pm1b_control, +.sleep_state = sleep_state, + }, + }, + }; + + return HYPERVISOR_platform_op(&op); +} + +static ACPI_STATUS +acpi_md_get_pm1controls(uint32_t *pm1a_control, uint32_t *pm1b_control) +{ + ACPI_STATUS status = 0; + uint32_t pm1a, pm1b; + struct acpi_bit_register_info *sleep_type_reg_info; + struct acpi_bit_register_info *sleep_enable_reg_info; + + *pm1a_control = *pm1b_control = 0; + + sleep_type_reg_info = + AcpiHwGetBitRegisterInfo(ACPI_BITREG_SLEEP_TYPE_A); + sleep_enable_reg_info = + AcpiHwGetBitRegisterInfo(ACPI_BITREG_SLEEP_ENABLE); + + status = AcpiHwRegisterRead(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_CONTROL, &pm1a); + if (ACPI_FAILURE(status)) + return status; + + /* Clear SLP_EN and SLP_TYP fields */ + pm1a &= ~(sleep_type_reg_info->AccessBitMask | + sleep_enable_reg_info->AccessBitMask); + pm1b = pm1a; + + /* Insert SLP_TYP bits */ + pm1a |= (AcpiGbl_SleepTypeA << sleep_type_reg_info->BitPosition); + pm1b |= (AcpiGbl_SleepTypeB << sleep_type_reg_info->BitPosition); + + /* Split the writes of SLP_TYP and SLP_EN to workaround + * poorly implemented hardware + */ + + /* Write #1: fill in SLP_TYP data */ + status = AcpiHwRegisterWrite(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1A_CONTROL, + pm1a); + if (ACPI_FAILURE(status)) + return status; + + status = AcpiHwRegisterWrite(ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1B_CONTROL, + pm1b); + if (ACPI_FAILURE(status)) + return status; + + /* Insert SLP_ENABLE bit */ + + pm1a |= sleep_enable_reg_info->AccessBitMask; + pm1b |= sleep_enable_reg_info->AccessBitMask; + + ACPI_FLUSH_CPU_CACHE(); + + *pm1a_control = pm1a; + *pm1b_control = pm1b; + + return status; +} int acpi_md_sleep(int state) { - printf("acpi: sleep not implemented\n"); - return (-1); + int error; + ACPI_STATUS status; + uint32_t pm1a_control, pm1b_control; + uint32_t xen_version, xen_vermajor, xen_verminor; + + xen_version = HYPERVISOR_xen_version(XENVER_version, NULL); + xen_vermajor = (xen_version & 0x) >> 16; + xen_verminor = (xen_version & 0x); + + /* Xen version check. We require Xen 3.x */ + KASSERT(xen_vermajor >= 3); + + /* Xen 3.2 and older have no s3 support. */ + if (xen_verminor < 3) { + printf("xenacpi: Xen 3.2 and older have no S3 support.\n"); + return -1; + } + + status = acpi_md_get_pm1controls(&pm1a_control, &pm1b_control); + if (ACPI_FAILURE(status)) { + printf("xenacpi: can't enter sleep mode. acpi error %i\n", + status); + return -1; + } + + error = xen_dom0_sleepenter(state, pm1a_control, pm1b_control); + + return error; }
CVS commit: [jym-xensuspend] src/sys/arch/xen/x86
Module Name:src Committed By: cegger Date: Thu Jun 18 11:12:07 UTC 2009 Modified Files: src/sys/arch/xen/x86 [jym-xensuspend]: cpu.c Log Message: register physical CPUs with pmf. No suspend/resume handlers needed since the hypervisor itself handles them. ok @jym To generate a diff of this commit: cvs rdiff -u -r1.31.2.1 -r1.31.2.2 src/sys/arch/xen/x86/cpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/x86/cpu.c diff -u src/sys/arch/xen/x86/cpu.c:1.31.2.1 src/sys/arch/xen/x86/cpu.c:1.31.2.2 --- src/sys/arch/xen/x86/cpu.c:1.31.2.1 Mon Feb 9 00:03:55 2009 +++ src/sys/arch/xen/x86/cpu.c Thu Jun 18 11:12:07 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.31.2.1 2009/02/09 00:03:55 jym Exp $ */ +/* $NetBSD: cpu.c,v 1.31.2.2 2009/06/18 11:12:07 cegger Exp $ */ /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp */ /*- @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.31.2.1 2009/02/09 00:03:55 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.31.2.2 2009/06/18 11:12:07 cegger Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -275,6 +275,10 @@ default: panic("unknown processor type??\n"); } + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + return; #else cpu_attach_common(parent, self, aux);
CVS commit: [jym-xensuspend] src/sys/arch/xen/x86
Module Name:src Committed By: jym Date: Sat Jun 6 22:30:41 UTC 2009 Modified Files: src/sys/arch/xen/x86 [jym-xensuspend]: intr.c Log Message: As requested by cegger@, apply the following patch to jym-xensuspend branch: Interrupt handling in Xen 3.5 changed. There's no longer a hardcoded upper limit. So *our* upper limit of 200 may be different from machine to machine now. So just retry if the hypercall failed. To generate a diff of this commit: cvs rdiff -u -r1.21.8.1 -r1.21.8.2 src/sys/arch/xen/x86/intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/x86/intr.c diff -u src/sys/arch/xen/x86/intr.c:1.21.8.1 src/sys/arch/xen/x86/intr.c:1.21.8.2 --- src/sys/arch/xen/x86/intr.c:1.21.8.1 Wed May 13 17:18:50 2009 +++ src/sys/arch/xen/x86/intr.c Sat Jun 6 22:30:41 2009 @@ -103,7 +103,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.21.8.1 2009/05/13 17:18:50 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.21.8.2 2009/06/06 22:30:41 jym Exp $"); #include "opt_multiprocessor.h" #include "opt_xen.h" @@ -257,6 +257,9 @@ * of the next device if this one used this IRQ. The easiest is * to allocate IRQs top-down, starting with a high number. * 250 and 230 have been tried, but got rejected by Xen. + * + * Xen 3.5 also rejects 200. Try out all values until Xen accepts + * or none is available. */ static int xen_next_irq = 200; struct ioapic_softc *ioapic = ioapic_find(APIC_IRQ_APIC(*pirq)); @@ -271,11 +274,16 @@ irq = APIC_IRQ_LEGACY_IRQ(*pirq); if (irq <= 0 || irq > 15) irq = xen_next_irq--; +retry: /* allocate vector and route interrupt */ op.cmd = PHYSDEVOP_ASSIGN_VECTOR; op.u.irq_op.irq = irq; - if (HYPERVISOR_physdev_op(&op) < 0) -panic("PHYSDEVOP_ASSIGN_VECTOR irq %d", irq); + if (HYPERVISOR_physdev_op(&op) < 0) { +irq = xen_next_irq--; +if (xen_next_irq == 15) + panic("PHYSDEVOP_ASSIGN_VECTOR irq %d", irq); +goto retry; + } irq2vect[irq] = op.u.irq_op.vector; vect2irq[op.u.irq_op.vector] = irq; pic->pic_addroute(pic, &phycpu_info_primary, pin,
CVS commit: [jym-xensuspend] src/sys/arch
Module Name:src Committed By: jym Date: Sun May 31 20:15:37 UTC 2009 Modified Files: src/sys/arch/x86/include [jym-xensuspend]: pmap.h src/sys/arch/x86/x86 [jym-xensuspend]: pmap.c src/sys/arch/xen/include [jym-xensuspend]: xenbus.h src/sys/arch/xen/include/amd64 [jym-xensuspend]: hypercalls.h src/sys/arch/xen/include/i386 [jym-xensuspend]: hypercalls.h src/sys/arch/xen/x86 [jym-xensuspend]: x86_xpmap.c xen_bus_dma.c src/sys/arch/xen/xen [jym-xensuspend]: evtchn.c if_xennet_xenbus.c xbd_xenbus.c xen_machdep.c xencons.c xennetback_xenbus.c src/sys/arch/xen/xenbus [jym-xensuspend]: xenbus_probe.c Log Message: Modifications for the Xen suspend/migrate/resume branch: - introduce xenbus_device_{suspend,resume}() functions. These are routines used to suspend/resume MI parts of the Xenbus device interfaces, like updating frontend/backend devices' paths found in XenStore. - introduce HYPERVISOR_sysctl(), an hypercall used only by Xentools to obtain information from hypervisor (listing VMs, printing console, etc.). I use it to query xenconsole from ddb(), as a last resort in case of a panic() in dom0 (xm being not available). Currently unused in the branch; could be, if requested. - disable the rwlock(9) used to protect code that could use transient MFNs. It could trigger nasty context switches in place it should not to. - fix some bugs in the xennet/xbd suspend/resume pmf(9) handlers. - following XenSource's design, talk_to_otherend() is now called watch_otherend(), and free_otherend_details() is used by Xenbus device suspend/resume routines. - some slight modifications in pmap regarding APDP. Introduce an inline function (pmap_unmap_apdp_pde()) that clears APDP entry for the current pmap. - similarly, implement pmap_unmap_all_apdp_pdes() that iterates through all pmaps and tears down APDP, as Xen does not handle them properly. TODO/XXX: - pmap_unmap_apdp_pde() does not handle APDP shadow entry of PAE. It will, once I figure out how PAE uses it. - revisit the pmap locking issue regarding transient MFNs. As NetBSD does not use kernel preemption and MP for Xen, this could be skipped momentarily. See http://mail-index.netbsd.org/port-xen/2009/04/27/msg004903.html for details. - fix a bug regarding grant tables which could technically DoS a dom0 if ridiculously high consumer/producer indexes are passed down in the ring during a resume. All in all, once the grant table index issue and APDP PAE are fixed, next step is to torture test this branch. Tested under i386 PAE and non-PAE, Xen3 dom0 and domU. amd64 is only compile tested. To generate a diff of this commit: cvs rdiff -u -r1.21.2.1 -r1.21.2.2 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.77.2.2 -r1.77.2.3 src/sys/arch/x86/x86/pmap.c cvs rdiff -u -r1.11 -r1.11.6.1 src/sys/arch/xen/include/xenbus.h cvs rdiff -u -r1.5 -r1.5.4.1 src/sys/arch/xen/include/amd64/hypercalls.h cvs rdiff -u -r1.8 -r1.8.4.1 src/sys/arch/xen/include/i386/hypercalls.h cvs rdiff -u -r1.12.4.2 -r1.12.4.3 src/sys/arch/xen/x86/x86_xpmap.c cvs rdiff -u -r1.14.2.1 -r1.14.2.2 src/sys/arch/xen/x86/xen_bus_dma.c cvs rdiff -u -r1.42.2.2 -r1.42.2.3 src/sys/arch/xen/xen/evtchn.c cvs rdiff -u -r1.33.2.2 -r1.33.2.3 src/sys/arch/xen/xen/if_xennet_xenbus.c cvs rdiff -u -r1.38.2.2 -r1.38.2.3 src/sys/arch/xen/xen/xbd_xenbus.c cvs rdiff -u -r1.4.12.2 -r1.4.12.3 src/sys/arch/xen/xen/xen_machdep.c cvs rdiff -u -r1.31.2.1 -r1.31.2.2 src/sys/arch/xen/xen/xencons.c cvs rdiff -u -r1.27.2.2 -r1.27.2.3 src/sys/arch/xen/xen/xennetback_xenbus.c cvs rdiff -u -r1.27.2.1 -r1.27.2.2 src/sys/arch/xen/xenbus/xenbus_probe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/include/pmap.h diff -u src/sys/arch/x86/include/pmap.h:1.21.2.1 src/sys/arch/x86/include/pmap.h:1.21.2.2 --- src/sys/arch/x86/include/pmap.h:1.21.2.1 Wed May 13 17:18:44 2009 +++ src/sys/arch/x86/include/pmap.h Sun May 31 20:15:36 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.21.2.1 2009/05/13 17:18:44 jym Exp $ */ +/* $NetBSD: pmap.h,v 1.21.2.2 2009/05/31 20:15:36 jym Exp $ */ /* * @@ -400,6 +400,7 @@ int pmap_enter_ma(struct pmap *, vaddr_t, paddr_t, paddr_t, vm_prot_t, u_int, int); bool pmap_extract_ma(pmap_t, vaddr_t, paddr_t *); +void pmap_unmap_all_apdp_pdes(void); paddr_t vtomach(vaddr_t); #define vtomfn(va) (vtomach(va) >> PAGE_SHIFT) Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.77.2.2 src/sys/arch/x86/x86/pmap.c:1.77.2.3 --- src/sys/arch/x86/x86/pmap.c:1.77.2.2 Wed May 13 17:18:45 2009 +++ src/sys/arch/x86/x86/pmap.c Sun May 31 20:15:36 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.77.2.2 2009/05/13 17:18:45 jym Exp $ */ +/* $NetBSD: pmap.c,v 1.77.2.3 2009/05/31 20:15:36 jym Exp $ */ /* * Copyright (c) 2007 Manuel Bouyer. @@ -154,7 +154,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pma
CVS commit: [jym-xensuspend] src/sys/arch
Module Name:src Committed By: jym Date: Sun May 31 14:32:35 UTC 2009 Modified Files: src/sys/arch/amd64/amd64 [jym-xensuspend]: bios32.c src/sys/arch/amd64/conf [jym-xensuspend]: GENERIC src/sys/arch/amd64/include [jym-xensuspend]: elf_machdep.h src/sys/arch/i386 [jym-xensuspend]: Makefile src/sys/arch/i386/i386 [jym-xensuspend]: bios32.c gdt.c src/sys/arch/i386/include [jym-xensuspend]: elf_machdep.h segments.h src/sys/arch/i386/pci [jym-xensuspend]: glxsb.c src/sys/arch/x86/include [jym-xensuspend]: cacheinfo.h specialreg.h src/sys/arch/x86/x86 [jym-xensuspend]: cpu_topology.c ioapic.c sys_machdep.c src/sys/arch/xen [jym-xensuspend]: Makefile Log Message: Sync with HEAD. To generate a diff of this commit: cvs rdiff -u -r1.14.2.1 -r1.14.2.2 src/sys/arch/amd64/amd64/bios32.c cvs rdiff -u -r1.237.2.1 -r1.237.2.2 src/sys/arch/amd64/conf/GENERIC cvs rdiff -u -r1.2 -r1.2.8.1 src/sys/arch/amd64/include/elf_machdep.h cvs rdiff -u -r1.36 -r1.36.4.1 src/sys/arch/i386/Makefile cvs rdiff -u -r1.22.14.1 -r1.22.14.2 src/sys/arch/i386/i386/bios32.c cvs rdiff -u -r1.45.14.1 -r1.45.14.2 src/sys/arch/i386/i386/gdt.c cvs rdiff -u -r1.9 -r1.9.138.1 src/sys/arch/i386/include/elf_machdep.h cvs rdiff -u -r1.50.8.1 -r1.50.8.2 src/sys/arch/i386/include/segments.h cvs rdiff -u -r1.6.14.1 -r1.6.14.2 src/sys/arch/i386/pci/glxsb.c cvs rdiff -u -r1.9.12.1 -r1.9.12.2 src/sys/arch/x86/include/cacheinfo.h cvs rdiff -u -r1.31.8.1 -r1.31.8.2 src/sys/arch/x86/include/specialreg.h cvs rdiff -u -r1.1.4.2 -r1.1.4.3 src/sys/arch/x86/x86/cpu_topology.c cvs rdiff -u -r1.38.10.1 -r1.38.10.2 src/sys/arch/x86/x86/ioapic.c cvs rdiff -u -r1.16.4.1 -r1.16.4.2 src/sys/arch/x86/x86/sys_machdep.c cvs rdiff -u -r1.5 -r1.5.8.1 src/sys/arch/xen/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/bios32.c diff -u src/sys/arch/amd64/amd64/bios32.c:1.14.2.1 src/sys/arch/amd64/amd64/bios32.c:1.14.2.2 --- src/sys/arch/amd64/amd64/bios32.c:1.14.2.1 Wed May 13 17:16:08 2009 +++ src/sys/arch/amd64/amd64/bios32.c Sun May 31 14:32:32 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: bios32.c,v 1.14.2.1 2009/05/13 17:16:08 jym Exp $ */ +/* $NetBSD: bios32.c,v 1.14.2.2 2009/05/31 14:32:32 jym Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1.14.2.1 2009/05/13 17:16:08 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1.14.2.2 2009/05/31 14:32:32 jym Exp $"); #include #include @@ -306,7 +306,7 @@ if (i == indx) { if (va + len < end) { ret = dest; - memcpy( ret, va, len); + memcpy(ret, va, len); ret[len - 1] = '\0'; } } Index: src/sys/arch/amd64/conf/GENERIC diff -u src/sys/arch/amd64/conf/GENERIC:1.237.2.1 src/sys/arch/amd64/conf/GENERIC:1.237.2.2 --- src/sys/arch/amd64/conf/GENERIC:1.237.2.1 Wed May 13 17:16:08 2009 +++ src/sys/arch/amd64/conf/GENERIC Sun May 31 14:32:33 2009 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.237.2.1 2009/05/13 17:16:08 jym Exp $ +# $NetBSD: GENERIC,v 1.237.2.2 2009/05/31 14:32:33 jym Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.237.2.1 $" +#ident "GENERIC-$Revision: 1.237.2.2 $" maxusers 64 # estimated number of users @@ -783,9 +783,13 @@ umodem* at uhub? port ? configuration ? ucom* at umodem? +# Huawei E220 3G/HSDPA modem +uhmodem* at uhub? port ? configuration ? interface ? +ucom* at uhmodem? portno ? + # USB Mass Storage umass* at uhub? port ? configuration ? interface ? -#wd* at umass? +wd* at umass? # USB audio uaudio* at uhub? port ? configuration ? Index: src/sys/arch/amd64/include/elf_machdep.h diff -u src/sys/arch/amd64/include/elf_machdep.h:1.2 src/sys/arch/amd64/include/elf_machdep.h:1.2.8.1 --- src/sys/arch/amd64/include/elf_machdep.h:1.2 Sun Oct 26 00:08:15 2008 +++ src/sys/arch/amd64/include/elf_machdep.h Sun May 31 14:32:33 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: elf_machdep.h,v 1.2 2008/10/26 00:08:15 mrg Exp $ */ +/* $NetBSD: elf_machdep.h,v 1.2.8.1 2009/05/31 14:32:33 jym Exp $ */ #ifdef __x86_64__ @@ -36,6 +36,16 @@ #define R_X86_64_8 14 #define R_X86_64_PC8 15 +/* TLS relocations */ +#define R_X86_64_DTPMOD64 16 +#define R_X86_64_DTPOFF64 17 +#define R_X86_64_TPOFF64 18 +#define R_X86_64_TLSGD 19 +#define R_X86_64_TLSLD 20 +#define R_X86_64_DTPOFF32 21 +#define R_X86_64_GOTTPOFF 22 +#define R_X86_64_TPOFF32 23 + #define R_TYPE(name) __CONCAT(R_X86_64_,name) #else /* __x86_64__ */ Index: src/sys/arch/i386/Makefile diff -u src/sys/arch/i386/Makefile:1.36 src/sys/arch/i386/Makefile:1.36.4.1 --- src/sys/arch/i386/Makefile:1.36 Thu Nov 6 00:41:52 2008 +++ src/sys/arch/i386/Makefile Sun May 31 14:32:33 2009 @@ -1,4 +1,4 @@ -# $NetBSD: Makef
CVS commit: [jym-xensuspend] src/sys/arch/xen/x86
Module Name:src Committed By: jym Date: Fri May 29 17:30:51 UTC 2009 Modified Files: src/sys/arch/xen/x86 [jym-xensuspend]: hypervisor_machdep.c Log Message: - use uvm_km_alloc() instead of kmem_alloc() to enforce alignement when allocating p2m_frame pages (xentools can only deal with page-aligned addresses) - *sigh* do not use paddr_t for p2m_frame_list_list with PAE, xentools expect 32 bits addresses even with 64 bits PTE... To generate a diff of this commit: cvs rdiff -u -r1.11.8.1 -r1.11.8.2 src/sys/arch/xen/x86/hypervisor_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/x86/hypervisor_machdep.c diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.1 src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.2 --- src/sys/arch/xen/x86/hypervisor_machdep.c:1.11.8.1 Mon Feb 9 00:03:55 2009 +++ src/sys/arch/xen/x86/hypervisor_machdep.c Fri May 29 17:30:51 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor_machdep.c,v 1.11.8.1 2009/02/09 00:03:55 jym Exp $ */ +/* $NetBSD: hypervisor_machdep.c,v 1.11.8.2 2009/05/29 17:30:51 jym Exp $ */ /* * @@ -59,11 +59,10 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.11.8.1 2009/02/09 00:03:55 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.11.8.2 2009/05/29 17:30:51 jym Exp $"); #include #include -#include #include @@ -424,10 +423,11 @@ * A L1 page contains the list of MFN we are looking for */ max_pfn = xen_start_info.nr_pages; -fpp = PAGE_SIZE / sizeof(paddr_t); +fpp = PAGE_SIZE / sizeof(unsigned long); /* we only need one L3 page */ -l3_p2m_page = kmem_alloc(PAGE_SIZE, KM_NOSLEEP); +l3_p2m_page = (vaddr_t *)uvm_km_alloc(kernel_map, PAGE_SIZE, + PAGE_SIZE, UVM_KMF_WIRED | UVM_KMF_NOWAIT); if (l3_p2m_page == NULL) panic("could not allocate memory for l3_p2m_page"); @@ -437,7 +437,9 @@ */ l2_p2m_page_size = howmany(max_pfn, fpp); -l2_p2m_page = kmem_alloc(l2_p2m_page_size * PAGE_SIZE, KM_NOSLEEP); +l2_p2m_page = (vaddr_t *)uvm_km_alloc(kernel_map, + l2_p2m_page_size * PAGE_SIZE, + PAGE_SIZE, UVM_KMF_WIRED | UVM_KMF_NOWAIT); if (l2_p2m_page == NULL) panic("could not allocate memory for l2_p2m_page"); @@ -457,7 +459,7 @@ unsigned long max_pfn; max_pfn = xen_start_info.nr_pages; -fpp = PAGE_SIZE / sizeof(paddr_t); +fpp = PAGE_SIZE / sizeof(unsigned long); for (i = 0; i < l2_p2m_page_size; i++) { /* @@ -481,7 +483,7 @@ HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list = vtomfn((vaddr_t)l3_p2m_page); -HYPERVISOR_shared_info->arch.max_pfn = max_pfn; +HYPERVISOR_shared_info->arch.max_pfn = max_pfn; } #endif /* XEN3 */