xen: add PV/PVH kernel entry point
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v9 1/19 xen: add PV/PVH kernel entry point
Add the PV/PVH entry point and the low level functions for PVH initialization.
--- sys/amd64/amd64/locore.S | 1 + sys/amd64/amd64/xen-locore.S | 83 +++++++++++++++++++++++++++++ sys/amd64/include/asmacros.h | 26 +++++++++ sys/conf/files.amd64 | 2 + sys/i386/xen/xen_machdep.c | 2 + sys/x86/xen/hvm.c | 1 + sys/x86/xen/pv.c | 119 ++++++++++++++++++++++++++++++++++++++++++ sys/xen/xen-os.h | 4 ++ 8 files changed, 238 insertions(+), 0 deletions(-) create mode 100644 sys/amd64/amd64/xen-locore.S create mode 100644 sys/x86/xen/pv.c
sys/amd64/amd64/locore.S +1 -0
@@ -84,5 +84,6 @@ NON_GPROF_ENTRY(btext) .bss ALIGN_DATA /* just to be sure */ + .globl bootstack .space 0x1000 /* space for bootstack - temporary stack */ bootstack:
sys/amd64/amd64/xen-locore.S new file +83 -0
83 lines not on this page · raw message
sys/amd64/include/asmacros.h +26 -0
@@ -201,4 +201,30 @@#endif /* LOCORE */ +#ifdef __STDC__ +#define ELFNOTE(name, type, desctype, descdata...) \ +.pushsection .note.name ; \ + .align 4 ; \ + .long 2f - 1f /* namesz */ ; \ + .long 4f - 3f /* descsz */ ; \ + .long type ; \ +1:.asciz #name ; \ +2:.align 4 ; \ +3:desctype descdata ; \ +4:.align 4 ; \ +.popsection +#else /* !__STDC__, i.e. -traditional */ +#define ELFNOTE(name, type, desctype, descdata) \ +.pushsection .note.name ; \ + .align 4 ; \ + .long 2f - 1f /* namesz */ ; \ + .long 4f - 3f /* descsz */ ; \ + .long type ; \ +1:.asciz "name" ; \ +2:.align 4 ; \ +3:desctype descdata ; \ +4:.align 4 ; \ +.popsection +#endif /* __STDC__ */ +#endif /* !_MACHINE_ASMACROS_H_ */
sys/conf/files.amd64 +2 -0
@@ -119,6 +119,7 @@ amd64/amd64/in_cksum.c optional inet | inet6 amd64/amd64/initcpu.c standard amd64/amd64/io.c optional io amd64/amd64/locore.S standard no-obj +amd64/amd64/xen-locore.S optional xenhvm amd64/amd64/machdep.c standard amd64/amd64/mem.c optional mem amd64/amd64/minidump_machdep.c standard
@@ -566,3 +567,4 @@ x86/x86/nexus.c standard x86/x86/tsc.c standard x86/xen/hvm.c optional xenhvm x86/xen/xen_intr.c optional xen | xenhvm +x86/xen/pv.c optional xenhvm
sys/i386/xen/xen_machdep.c +2 -0
@@ -89,6 +89,7 @@ IDTVEC(div), IDTVEC(dbg), IDTVEC(nmi), IDTVEC(bpt), IDTVEC(ofl),int xendebug_flags;start_info_t *xen_start_info; +start_info_t *HYPERVISOR_start_info;shared_info_t *HYPERVISOR_shared_info;xen_pfn_t *xen_machine_phys = machine_to_phys_mapping;xen_pfn_t *xen_phys_machine;
@@ -927,6 +928,7 @@ initvalues(start_info_t *startinfo)HYPERVISOR_vm_assist (VMASST_CMD_enable, VMASST_TYPE_4gb_segments_notify);#endif xen_start_info = startinfo; + HYPERVISOR_start_info = startinfo; xen_phys_machine = (xen_pfn_t *)startinfo->mfn_list; IdlePTD = (pd_entry_t *)((uint8_t *)startinfo->pt_base +PAGE_SIZE );
sys/x86/xen/hvm.c +1 -0
@@ -159,6 +159,7 @@ DPCPU_DEFINE(xen_intr_handle_t, ipi_handle[nitems(xen_ipis)]);/** Hypercall table accessed via HYPERVISOR_*_op() methods. */ char *hypercall_stubs;shared_info_t *HYPERVISOR_shared_info; +start_info_t *HYPERVISOR_start_info;#ifdef SMP /*---------------------------- XEN PV IPI Handlers ---------------------------*/
sys/x86/xen/pv.c new file +119 -0
119 lines not on this page · raw message
sys/xen/xen-os.h +4 -0
@@ -51,6 +51,10 @@void force_evtchn_callback (void );extern shared_info_t *HYPERVISOR_shared_info; +extern start_info_t *HYPERVISOR_start_info; + +/* XXX: we need to get rid of this and use HYPERVISOR_start_info directly */ +extern struct xenstore_domain_interface *xen_store;enum xen_domain_type {XEN_NATIVE ,/* running on bare hardware */
Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v9 2/19 xen: add macro to detect if running as Dom0
In reply to a message not in the archive--- sys/xen/xen-os.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
sys/xen/xen-os.h +7 -0
@@ -82,6 +82,13 @@ xen_hvm_domain(void)return (xen_domain_type ==XEN_HVM_DOMAIN ); } +static inline int +xen_initial_domain (void ) +{ +return (xen_domain () && HYPERVISOR_start_info && + HYPERVISOR_start_info->flags &SIF_INITDOMAIN ); +} +#ifndef xen_mb#define xen_mb () mb()#endif
Signature · 1 line
1.7.7.5 (Apple Git-26)
PATCH v9 3/19 xen: add and enable Xen console for PVH guests
In reply to a message not in the archiveThis adds and enables the console used on XEN kernels.
--- sys/conf/files | 4 +- sys/dev/xen/console/console.c | 37 +++++++++++++++++++++++++++++------ sys/dev/xen/console/xencons_ring.c | 15 +++++++++---- sys/i386/include/xen/xen-os.h | 1 - sys/i386/xen/xen_machdep.c | 17 ---------------- sys/x86/xen/pv.c | 4 +++ sys/xen/xen-os.h | 4 +++ 7 files changed, 50 insertions(+), 32 deletions(-)
sys/conf/files +2 -2
@@ -2523,8 +2523,8 @@ dev/xe/if_xe_pccard.c optional xe pccard dev/xen/balloon/balloon.c optional xen | xenhvm dev/xen/blkfront/blkfront.c optional xen | xenhvm dev/xen/blkback/blkback.c optional xen | xenhvm -dev/xen/console/console.c optional xen -dev/xen/console/xencons_ring.c optional xen +dev/xen/console/console.c optional xen | xenhvm +dev/xen/console/xencons_ring.c optional xen | xenhvm dev/xen/control/control.c optional xen | xenhvm dev/xen/netback/netback.c optional xen | xenhvm dev/xen/netfront/netfront.c optional xen | xenhvm
sys/dev/xen/console/console.c +30 -7
@@ -69,11 +69,14 @@ struct mtx cn_mtx;static char wbuf[WBUF_SIZE ];static char rbuf[RBUF_SIZE ];static int rc, rp; -static unsigned int cnsl_evt_reg; +unsigned int cnsl_evt_reg;static unsigned int wc, wp;/* write_cons, write_prod */ xen_intr_handle_t xen_intr_handle;device_t xencons_dev; +/* Virtual address of the shared console page */ +char *console_page; +#ifdef KDB static int xc_altbrk;#endif
@@ -110,9 +113,26 @@ static struct ttydevsw xc_ttydevsw = { .tsw_outwakeup = xcoutwakeup, }; +/*----------------------------- Debug function -------------------------------*/ +#define XC_PRINTF_BUFSIZE 1024 +void +xc_printf (const char *fmt, ...) +{ +static char buf[XC_PRINTF_BUFSIZE ]; +__va_list ap; + +va_start (ap, fmt); +vsnprintf (buf,sizeof (buf), fmt, ap); +va_end (ap); +HYPERVISOR_console_write (buf,strlen (buf)); +} +static void xc_cnprobe (struct consdev *cp) { +if (!xen_pv_domain ()) +return ; + cp->cn_pri =CN_REMOTE ;sprintf (cp->cn_name,"%s0" , driver_name); }
@@ -175,7 +195,7 @@ static void xc_cnputc(struct consdev *dev, int c) { -if (xen_start_info->flags &SIF_INITDOMAIN ) + if (xen_initial_domain()) xc_cnputc_dom0(dev, c); elsexc_cnputc_domu (dev ,c );
@@ -206,8 +226,7 @@ xcons_putc(int c)xcons_force_flush ();#endif } -if (cnsl_evt_reg) -__xencons_tx_flush (); +__xencons_tx_flush ();/* inform start path that we're pretty full */ return ((wp - wc) >=WBUF_SIZE -100 ) ? TRUE : FALSE;
@@ -217,6 +236,10 @@ static void xc_identify(driver_t *driver, device_t parent) {device_t child; + +if (!xen_pv_domain ()) +return ; + child =BUS_ADD_CHILD (parent,0 , driver_name,0 );device_set_driver (child, driver);device_set_desc (child,"Xen Console" );
@@ -245,7 +268,7 @@ xc_attach(device_t dev) cnsl_evt_reg =1 ;callout_reset (&xc_callout,XC_POLLTIME , xc_timeout, xccons); -if (xen_start_info->flags &SIF_INITDOMAIN ) { +if (xen_initial_domain ()) { error =xen_intr_bind_virq (dev,VIRQ_CONSOLE ,0 ,NULL , xencons_priv_interrupt,NULL ,INTR_TYPE_TTY , &xen_intr_handle);
@@ -309,7 +332,7 @@ __xencons_tx_flush(void) sz = wp - wc;if (sz > (WBUF_SIZE -WBUF_MASK (wc))) sz =WBUF_SIZE -WBUF_MASK (wc); -if (xen_start_info->flags &SIF_INITDOMAIN ) { +if (xen_initial_domain ()) {HYPERVISOR_console_io (CONSOLEIO_write, sz, &wbuf[WBUF_MASK (wc)]); wc += sz; }else {
@@ -424,7 +447,7 @@ xcons_force_flush(void) {int sz; -if (xen_start_info->flags &SIF_INITDOMAIN ) +if (xen_initial_domain ())return ;/* Spin until console data is flushed through to the domain controller. */
sys/dev/xen/console/xencons_ring.c +10 -5
@@ -32,9 +32,9 @@ __FBSDID("$FreeBSD$");#define console_evtchn console.domU.evtchnxen_intr_handle_t console_handle; -extern char *console_page;extern struct mtx cn_mtx;extern device_t xencons_dev; +extern int cnsl_evt_reg;static inline struct xencons_interface *xencons_interface (void )
@@ -60,6 +60,8 @@ xencons_ring_send(const char *data, unsigned len)struct xencons_interface *intf;XENCONS_RING_IDX cons, prod;int sent; +struct evtchn_send send = { .port = + HYPERVISOR_start_info->console_evtchn }; intf =xencons_interface (); cons = intf->out_cons;
@@ -76,7 +78,10 @@ xencons_ring_send(const char *data, unsigned len)wmb (); intf->out_prod = prod; -xen_intr_signal (console_handle); +if (cnsl_evt_reg) +xen_intr_signal (console_handle); +else +HYPERVISOR_event_channel_op (EVTCHNOP_send, &send);return sent;
@@ -125,11 +130,11 @@ xencons_ring_init(void) {int err; -if (!xen_start_info->console_evtchn) +if (!HYPERVISOR_start_info->console_evtchn)return 0 ; err =xen_intr_bind_local_port (xencons_dev, - xen_start_info->console_evtchn,NULL , xencons_handle_input,NULL , + HYPERVISOR_start_info->console_evtchn,NULL , xencons_handle_input,NULL ,INTR_TYPE_MISC |INTR_MPSAFE , &console_handle);if (err) {return err;
@@ -145,7 +150,7 @@ voidxencons_suspend (void) { -if (!xen_start_info->console_evtchn) +if (!HYPERVISOR_start_info->console_evtchn)return ;xen_intr_unbind (&console_handle);
sys/i386/include/xen/xen-os.h +0 -1
@@ -45,7 +45,6 @@ static inline void rep_nop(void)#define cpu_relax () rep_nop()#ifndef XENHVM -void xc_printf (const char *fmt, ...);#ifdef SMP extern int gdtset;
sys/i386/xen/xen_machdep.c +0 -17
@@ -186,21 +186,6 @@ xen_boothowto(char *envp)return howto; } -#define XC_PRINTF_BUFSIZE 1024 -void -xc_printf (const char *fmt, ...) -{ -__va_list ap; -int retval; -static char buf[XC_PRINTF_BUFSIZE ]; - -va_start (ap, fmt); - retval =vsnprintf (buf,XC_PRINTF_BUFSIZE -1 , fmt, ap); -va_end (ap); - buf[retval] =0 ; - (void )HYPERVISOR_console_write (buf, retval); -} -#define XPQUEUE_SIZE 128
@@ -745,8 +730,6 @@ void initvalues(start_info_t *startinfo);struct xenstore_domain_interface ;extern struct xenstore_domain_interface *xen_store; -char *console_page; -void *bootmem_alloc (unsigned int size) {
sys/x86/xen/pv.c +4 -0
@@ -70,9 +70,12 @@ hammer_time_xen(start_info_t *si, u_int64_t xenstack)int i;if ((si ==NULL ) || (xenstack ==0 )) { +xc_printf ("ERROR: invalid start_info or xen stack, halting\n" );HYPERVISOR_shutdown (SHUTDOWN_crash); } +xc_printf ("FreeBSD PVH running on %s\n" , si->magic); +/* We use 3 pages of xen stack for the boot pagetables */ physfree = xenstack +3 *PAGE_SIZE -KERNBASE ;
@@ -90,6 +93,7 @@ hammer_time_xen(start_info_t *si, u_int64_t xenstack)*/ xen_store = (struct xenstore_domain_interface *) (ptoa (si->store_mfn) +KERNBASE ); + console_page = (char *)(ptoa (si->console.domU.mfn) +KERNBASE ); xen_domain_type =XEN_PV_DOMAIN ; vm_guest =VM_GUEST_XEN ;
sys/xen/xen-os.h +4 -0
@@ -55,6 +55,7 @@ extern start_info_t *HYPERVISOR_start_info;/* XXX: we need to get rid of this and use HYPERVISOR_start_info directly */ extern struct xenstore_domain_interface *xen_store; +extern char *console_page;enum xen_domain_type {XEN_NATIVE ,/* running on bare hardware */
@@ -89,6 +90,9 @@ xen_initial_domain(void) HYPERVISOR_start_info->flags & SIF_INITDOMAIN); } +/* Debug function, prints directly to hypervisor console */ +void xc_printf (const char *, ...); +#ifndef xen_mb#define xen_mb () mb()#endif
Signature · 1 line
1.7.7.5 (Apple Git-26)
Re: [PATCH v9 03/19] xen: add and enable Xen console for PVH guests
Quoted 2 lines · Roger Pau Monne
This adds and enables the console used on XEN kernels.
---
[..]
sys/xen/xen-os.h xen_initial_domain(void) · line 95
Quoted 3 lines
sys/xen/xen-os.h +3
-0+/* Debug function, prints directly to hypervisor console */ +void xc_printf (const char *, ...); +
Can you add __printflike(...)? It will be easier to catch bad format.
Signature · 1 line
Julien Grall
PATCH v9 4/19 amd64: introduce hook for custom preload metadata parsers
In reply to a message not in the archive--- sys/amd64/amd64/machdep.c | 41 ++++++++++++++++------ sys/amd64/include/sysarch.h | 12 ++++++ sys/x86/xen/pv.c | 82 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 11 deletions(-)
sys/amd64/amd64/machdep.c +30 -11
@@ -126,6 +126,7 @@ __FBSDID("$FreeBSD$");#include <machine/reg.h> #include <machine/sigframe.h> #include <machine/specialreg.h> +#include <machine/sysarch.h> #ifdef PERFMON #include <machine/perfmon.h> #endif
@@ -165,6 +166,14 @@ static int set_fpcontext(struct thread *td, const mcontext_t *mcp, char *xfpustate, size_t xfpustate_len);SYSINIT (cpu,SI_SUB_CPU ,SI_ORDER_FIRST , cpu_startup,NULL ); +/* Preload data parse function */ +static caddr_t native_parse_preload_data (u_int64_t ); + +/* Default init_ops implementation. */ +struct init_ops init_ops = { + .parse_preload_data = native_parse_preload_data, +}; +/* * The file "conf/ldscript.amd64" defines the symbol "kernphys". Its value is * the physical address at which the kernel is loaded.
@@ -1683,6 +1692,26 @@ do_next: msgbufp = (struct msgbuf *)PHYS_TO_DMAP (phys_avail[pa_indx]); } +static caddr_t +native_parse_preload_data (u_int64_t modulep) +{ +caddr_t kmdp; + + preload_metadata = (caddr_t)(uintptr_t)(modulep +KERNBASE ); +preload_bootstrap_relocate (KERNBASE ); + kmdp =preload_search_by_type ("elf kernel" ); +if (kmdp ==NULL ) + kmdp =preload_search_by_type ("elf64 kernel" ); + boothowto =MD_FETCH (kmdp,MODINFOMD_HOWTO , int); + kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *) + KERNBASE; +#ifdef DDB + ksym_start =MD_FETCH (kmdp,MODINFOMD_SSYM , uintptr_t); + ksym_end =MD_FETCH (kmdp,MODINFOMD_ESYM , uintptr_t); +#endif + +return (kmdp); +} +u_int64_t hammer_time (u_int64_t modulep,u_int64_t physfree) {
@@ -1707,17 +1736,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)*/ proc_linkup0 (&proc0, &thread0); - preload_metadata = (caddr_t)(uintptr_t)(modulep +KERNBASE ); -preload_bootstrap_relocate (KERNBASE ); - kmdp =preload_search_by_type ("elf kernel" ); -if (kmdp ==NULL ) - kmdp =preload_search_by_type ("elf64 kernel" ); - boothowto =MD_FETCH (kmdp,MODINFOMD_HOWTO , int); - kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *) + KERNBASE; -#ifdef DDB - ksym_start =MD_FETCH (kmdp,MODINFOMD_SSYM , uintptr_t); - ksym_end =MD_FETCH (kmdp,MODINFOMD_ESYM , uintptr_t); -#endif + kmdp = init_ops.parse_preload_data (modulep);/* Init basic tunables, hz etc */ init_param1 ();
sys/amd64/include/sysarch.h +12 -0
@@ -4,3 +4,15 @@/* $FreeBSD$ */ #include <x86/sysarch.h> + +/* +* Struct containing pointers to init functions whose +* implementation is run time selectable. Selection can be made, +* for example, based on detection of a BIOS variant or +* hypervisor environment. +*/ +struct init_ops { +caddr_t (*parse_preload_data)(u_int64_t ); +}; + +extern struct init_ops init_ops;
sys/x86/xen/pv.c +82 -0
100 lines not on this page · raw message
Signature · 1 line
1.7.7.5 (Apple Git-26)
PATCH v9 5/19 xen: rework xen timer so it can be used early in boot process
In reply to a message not in the archiveThis should not introduce any functional change, and makes the functions suitable to be called before we have actually mapped the vcpu_info struct on a per-cpu basis.
--- sys/dev/xen/timer/timer.c | 29 ++++++++++++++++++++--------- 1 files changed, 20 insertions(+), 9 deletions(-)
sys/dev/xen/timer/timer.c +20 -9
@@ -230,22 +230,22 @@ xen_fetch_vcpu_tinfo(struct vcpu_time_info *dst, struct vcpu_time_info *src)/** * \brief Get the current time, in nanoseconds, since the hypervisor booted. * +* \param vcpu vcpu_info structure to fetch the time from. +* * \note This function returns the current CPU's idea of this value, unless * it happens to be less than another CPU's previously determined value. */ static uint64_t -xen_fetch_vcpu_time (void ) +xen_fetch_vcpu_time (struct vcpu_info *vcpu) {struct vcpu_time_info dst;struct vcpu_time_info *src;uint32_t pre_version;uint64_t now;volatile uint64_t last; -struct vcpu_info *vcpu =DPCPU_GET (vcpu_info); src = &vcpu->time; -critical_enter (); do { pre_version = xen_fetch_vcpu_tinfo(&dst, src); barrier();
@@ -266,16 +266,19 @@ xen_fetch_vcpu_time(void) } }while (!atomic_cmpset_64 (&xen_timer_last_time, last, now)); -critical_exit (); -return (now); }static uint32_t xentimer_get_timecount (struct timecounter *tc) { +uint32_t xen_time; -return ((uint32_t )xen_fetch_vcpu_time () &UINT_MAX ); +critical_enter (); + xen_time = (uint32_t )xen_fetch_vcpu_time (DPCPU_GET (vcpu_info)) &UINT_MAX ; +critical_exit (); + +return (xen_time); }/**
@@ -305,7 +308,12 @@ xen_fetch_wallclock(struct timespec *ts)static void xen_fetch_uptime (struct timespec *ts) { -uint64_t uptime =xen_fetch_vcpu_time (); +uint64_t uptime; + +critical_enter (); + uptime =xen_fetch_vcpu_time (DPCPU_GET (vcpu_info)); +critical_exit (); + ts->tv_sec = uptime /NSEC_IN_SEC ; ts->tv_nsec = uptime %NSEC_IN_SEC ; }
@@ -354,7 +362,7 @@ xentimer_intr(void *arg)struct xentimer_softc *sc = (struct xentimer_softc *)arg;struct xentimer_pcpu_data *pcpu =DPCPU_PTR (xentimer_pcpu); - pcpu->last_processed =xen_fetch_vcpu_time (); + pcpu->last_processed =xen_fetch_vcpu_time (DPCPU_GET (vcpu_info));if (pcpu->timer !=0 && sc->et.et_active) sc->et.et_event_cb (&sc->et, sc->et.et_arg);
@@ -415,7 +423,10 @@ xentimer_et_start(struct eventtimer *et,do {if (++i ==60 )panic ("can't schedule timer" ); - next_time =xen_fetch_vcpu_time () + first_in_ns; +critical_enter (); + next_time =xen_fetch_vcpu_time (DPCPU_GET (vcpu_info)) + + first_in_ns; +critical_exit (); error =xentimer_vcpu_start_timer (cpu, next_time); }while (error == -ETIME );
Signature · 1 line
1.7.7.5 (Apple Git-26)
PATCH v9 6/19 xen: implement an early timer for Xen PVH
In reply to a message not in the archiveWhen running as a PVH guest, there's no emulated i8254, so we need to use the Xen PV timer as the early source for DELAY. This change allows for different implementations of the early DELAY function and implements a Xen variant for it.
--- sys/amd64/amd64/machdep.c | 6 ++- sys/amd64/include/clock.h | 5 ++ sys/amd64/include/sysarch.h | 2 + sys/conf/files.amd64 | 1 + sys/conf/files.i386 | 1 + sys/dev/xen/timer/timer.c | 33 +++++++++++++ sys/i386/include/clock.h | 5 ++ sys/x86/isa/clock.c | 53 +-------------------- sys/x86/x86/delay.c | 112 +++++++++++++++++++++++++++++++++++++++++++ sys/x86/xen/pv.c | 3 + 10 files changed, 167 insertions(+), 54 deletions(-) create mode 100644 sys/x86/x86/delay.c
sys/amd64/amd64/machdep.c +4 -2
@@ -172,6 +172,8 @@ static caddr_t native_parse_preload_data(u_int64_t);/* Default init_ops implementation. */ struct init_ops init_ops = { .parse_preload_data = native_parse_preload_data, + .early_delay_init = i8254_init, + .early_delay = i8254_delay, };/*
@@ -1820,10 +1822,10 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)lidt (&r_idt);/* -* Initialize the i8254 before the console so that console +* Initialize the early delay before the console so that console * initialization can use DELAY(). */ -i8254_init (); + init_ops.early_delay_init ();/* * Initialize the console before we print anything out.
sys/amd64/include/clock.h +5 -0
@@ -25,6 +25,11 @@ extern int smp_tsc;#endif void i8254_init (void ); +void i8254_delay (int ); +#ifdef XENHVM +void xen_delay_init (void ); +void xen_delay (int ); +#endif /* * Driver to clock driver interface.
sys/amd64/include/sysarch.h +2 -0
@@ -13,6 +13,8 @@*/ struct init_ops {caddr_t (*parse_preload_data)(u_int64_t ); +void (*early_delay_init)(void ); +void (*early_delay)(int ); };extern struct init_ops init_ops;
sys/conf/files.amd64 +1 -0
@@ -565,6 +565,7 @@ x86/x86/mptable_pci.c optional mptable pci x86/x86/msi.c optional pci x86/x86/nexus.c standard x86/x86/tsc.c standard +x86/x86/delay.c standard x86/xen/hvm.c optional xenhvm x86/xen/xen_intr.c optional xen | xenhvm x86/xen/pv.c optional xenhvm
sys/conf/files.i386 +1 -0
@@ -600,5 +600,6 @@ x86/x86/mptable_pci.c optional apic native pci x86/x86/msi.c optional apic pci x86/x86/nexus.c standard x86/x86/tsc.c standard +x86/x86/delay.c standard x86/xen/hvm.c optional xenhvm x86/xen/xen_intr.c optional xen | xenhvm
sys/dev/xen/timer/timer.c +33 -0
@@ -59,6 +59,9 @@ __FBSDID("$FreeBSD$");#include <machine/_inttypes.h> #include <machine/smp.h> +/* For the declaration of clock_lock */ +#include <isa/rtc.h> +#include "clock_if.h" static devclass_t xentimer_devclass;
@@ -584,6 +587,36 @@ xentimer_suspend(device_t dev)return (0 ); } +/* +* Xen delay early init +*/ +void xen_delay_init (void ) +{ +/* Init the clock lock */ +mtx_init (&clock_lock,"clk" ,NULL ,MTX_SPIN |MTX_NOPROFILE ); +} +/* +* Xen PV DELAY function +* +* When running on PVH mode we don't have an emulated i8524, so +* make use of the Xen time info in order to code a simple DELAY +* function that can be used during early boot. +*/ +void xen_delay (int n) +{ +uint64_t end_ns; +uint64_t current; + + end_ns =xen_fetch_vcpu_time (&HYPERVISOR_shared_info->vcpu_info[0 ]); + end_ns += n *NSEC_IN_USEC ; + +for (;;) { + current =xen_fetch_vcpu_time (&HYPERVISOR_shared_info->vcpu_info[0 ]); +if (current >= end_ns) +break ; + } +} +static device_method_t xentimer_methods[] = {DEVMETHOD (device_identify, xentimer_identify),DEVMETHOD (device_probe, xentimer_probe),
sys/i386/include/clock.h +5 -0
@@ -22,6 +22,11 @@ extern int tsc_is_invariant;extern int tsc_perf_stat;void i8254_init (void ); +void i8254_delay (int ); +#ifdef XENHVM +void xen_delay_init (void ); +void xen_delay (int ); +#endif /* * Driver to clock driver interface.
sys/x86/isa/clock.c +1 -52
71 lines not on this page · raw message
sys/x86/x86/delay.c new file +112 -0
112 lines not on this page · raw message
sys/x86/xen/pv.c +3 -0
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");#include <vm/vm_param.h> #include <machine/sysarch.h> +#include <machine/clock.h> #include <xen/xen-os.h> #include <xen/hypervisor.h>
@@ -65,6 +66,8 @@ static void xen_pv_set_init_ops(void);/* Xen init_ops implementation. */ struct init_ops xen_init_ops = { .parse_preload_data = xen_pv_parse_preload_data, + .early_delay_init = xen_delay_init, + .early_delay = xen_delay, }; static struct
Signature · 1 line
1.7.7.5 (Apple Git-26)
PATCH v9 7/19 xen: implement hook to fetch e820 memory map
In reply to a message not in the archive--- sys/amd64/amd64/machdep.c | 50 ++++++++++++++++++++++++++---------------- sys/amd64/include/pc/bios.h | 2 + sys/amd64/include/sysarch.h | 1 + sys/x86/xen/pv.c | 25 +++++++++++++++++++++ 4 files changed, 59 insertions(+), 19 deletions(-)
sys/amd64/amd64/machdep.c +31 -19
@@ -169,11 +169,15 @@ SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL);/* Preload data parse function */ static caddr_t native_parse_preload_data (u_int64_t ); +/* Native function to fetch and parse the e820 map */ +static void native_parse_memmap (caddr_t ,vm_paddr_t *,int *); +/* Default init_ops implementation. */ struct init_ops init_ops = { .parse_preload_data = native_parse_preload_data, .early_delay_init = i8254_init, .early_delay = i8254_delay, + .parse_memmap = native_parse_memmap, };/*
@@ -1401,21 +1405,12 @@ add_physmap_entry(uint64_t base, uint64_t length, vm_paddr_t *physmap,return (1 ); } -static void -add_smap_entries (struct bios_smap *smapbase,vm_paddr_t *physmap, -int *physmap_idx) +void +bios_add_smap_entries (struct bios_smap *smapbase,u_int32_t smapsize, +vm_paddr_t *physmap,int *physmap_idx) {struct bios_smap *smap, *smapend; -u_int32_t smapsize; -/* -* Memory map from INT 15:E820. -* -* subr_module.c says: -* "Consumer may safely assume that size value precedes data." -* ie: an int32_t immediately precedes smap. -*/ - smapsize = *((u_int32_t *)smapbase -1 ); smapend = (struct bios_smap *)((uintptr_t )smapbase + smapsize);for (smap = smapbase; smap < smapend; smap++) {
@@ -1432,6 +1427,29 @@ add_smap_entries(struct bios_smap *smapbase, vm_paddr_t *physmap, } } +static void +native_parse_memmap (caddr_t kmdp,vm_paddr_t *physmap,int *physmap_idx) +{ +struct bios_smap *smap; +u_int32_t size; + +/* +* Memory map from INT 15:E820. +* +* subr_module.c says: +* "Consumer may safely assume that size value precedes data." +* ie: an int32_t immediately precedes smap. +*/ + + smap = (struct bios_smap *)preload_search_info (kmdp, +MODINFO_METADATA |MODINFOMD_SMAP ); +if (smap ==NULL ) +panic ("No BIOS smap info from loader!" ); + size = *((u_int32_t *)smap -1 ); + +bios_add_smap_entries (smap, size, physmap, physmap_idx); +} +/* * Populate the (physmap) array with base/bound pairs describing the * available physical memory in the system, then test this memory and
@@ -1449,19 +1467,13 @@ getmemsize(caddr_t kmdp, u_int64_t first)vm_paddr_t pa, physmap[PHYSMAP_SIZE ];u_long physmem_start, physmem_tunable, memtest;pt_entry_t *pte; -struct bios_smap *smapbase;quad_t dcons_addr, dcons_size;bzero (physmap,sizeof (physmap)); basemem =0 ; physmap_idx =0 ; - smapbase = (struct bios_smap *)preload_search_info (kmdp, -MODINFO_METADATA |MODINFOMD_SMAP ); -if (smapbase ==NULL ) -panic ("No BIOS smap info from loader!" ); - -add_smap_entries (smapbase, physmap, &physmap_idx); + init_ops.parse_memmap (kmdp, physmap, &physmap_idx);/* * Find the 'base memory' segment for SMP
sys/amd64/include/pc/bios.h +2 -0
@@ -106,6 +106,8 @@ struct bios_oem {int bios_oem_strings (struct bios_oem *oem,u_char *buffer,size_t maxlen);uint32_t bios_sigsearch (uint32_t start,u_char *sig,int siglen,int paralen,int sigofs); +void bios_add_smap_entries (struct bios_smap *smapbase,u_int32_t smapsize, +vm_paddr_t *physmap,int *physmap_idx);#endif #endif /* _MACHINE_PC_BIOS_H_ */
sys/amd64/include/sysarch.h +1 -0
@@ -15,6 +15,7 @@ struct init_ops {caddr_t (*parse_preload_data)(u_int64_t);void (*early_delay_init)(void );void (*early_delay)(int ); +void (*parse_memmap)(caddr_t ,vm_paddr_t *,int *); };extern struct init_ops init_ops;
sys/x86/xen/pv.c +25 -0
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");#include <machine/sysarch.h> #include <machine/clock.h> +#include <machine/pc/bios.h> #include <xen/xen-os.h> #include <xen/hypervisor.h>
@@ -57,8 +58,11 @@ extern u_int64_t hammer_time(u_int64_t, u_int64_t);/* Xen initial function */ extern u_int64_t hammer_time_xen (start_info_t *,u_int64_t ); +#define MAX_E820_ENTRIES 128 +/*--------------------------- Forward Declarations ---------------------------*/ static caddr_t xen_pv_parse_preload_data (u_int64_t ); +static void xen_pv_parse_memmap (caddr_t ,vm_paddr_t *,int *);static void xen_pv_set_init_ops (void );
@@ -68,6 +72,7 @@ struct init_ops xen_init_ops = { .parse_preload_data = xen_pv_parse_preload_data, .early_delay_init = xen_delay_init, .early_delay = xen_delay, + .parse_memmap = xen_pv_parse_memmap, }; static struct
@@ -88,6 +93,8 @@ static struct {NULL, 0} }; +static struct bios_smap xen_smap[MAX_E820_ENTRIES ]; +/*-------------------------------- Xen PV init -------------------------------*/ /* * First function called by the Xen PVH boot sequence.
@@ -201,6 +208,24 @@ xen_pv_parse_preload_data(u_int64_t modulep) }static void +xen_pv_parse_memmap (caddr_t kmdp,vm_paddr_t *physmap,int *physmap_idx) +{ +struct xen_memory_map memmap; +u_int32_t size; +int rc; + +/* Fetch the E820 map from Xen */ + memmap.nr_entries =MAX_E820_ENTRIES ; +set_xen_guest_handle (memmap.buffer, xen_smap); + rc =HYPERVISOR_memory_op (XENMEM_memory_map, &memmap); +if (rc) +panic ("unable to fetch Xen E820 memory map" ); + size = memmap.nr_entries *sizeof (xen_smap[0 ]); + +bios_add_smap_entries (xen_smap, size, physmap, physmap_idx); +} + +static void xen_pv_set_init_ops (void ) {/* Init ops for Xen PV */
Signature · 1 line
1.7.7.5 (Apple Git-26)
PATCH v9 8/19 xen: use the same hypercall mechanism for XEN and XENHVM
In reply to a message not in the archive--- sys/amd64/include/xen/hypercall.h | 7 ------- sys/i386/i386/locore.s | 9 +++++++++ sys/i386/include/xen/hypercall.h | 8 -------- sys/x86/xen/hvm.c | 24 ++++++++++-------------- 4 files changed, 19 insertions(+), 29 deletions(-)
sys/amd64/include/xen/hypercall.h +0 -7
@@ -51,15 +51,8 @@#define CONFIG_XEN_COMPAT 0x030002#define __must_check -#ifdef XEN #define HYPERCALL_STR (name) \ "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)" -#else -#define HYPERCALL_STR (name) \ - "mov $("STR(__HYPERVISOR_##name)" * 32),%%eax; "\ - "add hypercall_stubs(%%rip),%%rax; " \ - "call *%%rax" -#endif #define _hypercall0 (type, name) \ ({ \
sys/i386/i386/locore.s +9 -0
@@ -898,3 +898,12 @@ done_pde: #endif ret + +#ifdef XENHVM +/* Xen Hypercall page */ + .text +.p2align PAGE_SHIFT, 0x90 /* Hypercall_page needs to be PAGE aligned */ + +NON_GPROF_ENTRY(hypercall_page) + .skip 0x1000, 0x90 /* Fill with "nop"s */ +#endif
sys/i386/include/xen/hypercall.h +0 -8
@@ -39,16 +39,8 @@#define ENOXENSYS 38#define CONFIG_XEN_COMPAT 0x030002 - -#if defined(XEN )#define HYPERCALL_STR (name) \ "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)" -#else -#define HYPERCALL_STR (name) \ - "mov hypercall_stubs,%%eax; " \ - "add $("STR(__HYPERVISOR_##name)" * 32),%%eax; " \ - "call *%%eax" -#endif #define _hypercall0 (type, name) \ ({ \
sys/x86/xen/hvm.c +10 -14
@@ -157,7 +157,7 @@ DPCPU_DEFINE(xen_intr_handle_t, ipi_handle[nitems(xen_ipis)]);/*------------------ Hypervisor Access Shared Memory Regions -----------------*/ /** Hypercall table accessed via HYPERVISOR_*_op() methods. */ -char *hypercall_stubs; +extern char *hypercall_page;shared_info_t *HYPERVISOR_shared_info;start_info_t *HYPERVISOR_start_info;
@@ -559,7 +559,7 @@ xen_hvm_cpuid_base(void)* Allocate and fill in the hypcall page. */ static int -xen_hvm_init_hypercall_stubs (void ) +xen_hvm_init_hypercall_stubs (enum xen_hvm_init_type init_type) {uint32_t base, regs[4 ];int i;
@@ -568,7 +568,7 @@ xen_hvm_init_hypercall_stubs(void)if (base ==0 )return (ENXIO ); -if (hypercall_stubs ==NULL ) { +if (init_type ==XEN_HVM_INIT_COLD ) {do_cpuid (base +1 , regs);printf ("XEN: Hypervisor version %d.%d detected.\n" , regs[0 ] >>16 , regs[0 ] &0xffff );
@@ -578,18 +578,9 @@ xen_hvm_init_hypercall_stubs(void)* Find the hypercall pages. */ do_cpuid (base +2 , regs); - -if (hypercall_stubs ==NULL ) { -size_t call_region_size; - - call_region_size = regs[0 ] *PAGE_SIZE ; - hypercall_stubs =malloc (call_region_size,M_XENHVM ,M_NOWAIT ); -if (hypercall_stubs ==NULL ) -panic ("Unable to allocate Xen hypercall region" ); - }for (i =0 ; i < regs[0 ]; i++) -wrmsr (regs[1 ],vtophys (hypercall_stubs + i *PAGE_SIZE ) + i); +wrmsr (regs[1 ],vtophys (&hypercall_page + i *PAGE_SIZE ) + i);return (0 ); }
@@ -692,7 +683,12 @@ xen_hvm_init(enum xen_hvm_init_type init_type)if (init_type ==XEN_HVM_INIT_CANCELLED_SUSPEND )return ; - error =xen_hvm_init_hypercall_stubs (); +if (xen_pv_domain ()) { +/* hypercall page is already set in the PV case */ + error =0 ; + }else { + error =xen_hvm_init_hypercall_stubs (init_type); + }switch (init_type) {case XEN_HVM_INIT_COLD :
Signature · 1 line
1.7.7.5 (Apple Git-26)
PATCH v9 9/19 xen: add a apic_enumerator for PVH
In reply to a message not in the archive--- sys/conf/files.amd64 | 1 + sys/x86/xen/pvcpu_enum.c | 136 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 0 deletions(-) create mode 100644 sys/x86/xen/pvcpu_enum.c
sys/conf/files.amd64 +1 -0
@@ -569,3 +569,4 @@ x86/x86/delay.c standard x86/xen/hvm.c optional xenhvm x86/xen/xen_intr.c optional xen | xenhvm x86/xen/pv.c optional xenhvm +x86/xen/pvcpu_enum.c optional xenhvm
sys/x86/xen/pvcpu_enum.c new file +136 -0
136 lines not on this page · raw message
Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v9 10/19 xen: add hook for AP bootstrap memory reservation
In reply to a message not in the archiveThis hook will only be implemented for bare metal, Xen doesn't require any bootstrap code since APs are started in long mode with paging enabled.
--- sys/amd64/amd64/machdep.c | 6 +++++- sys/amd64/include/sysarch.h | 1 + 2 files changed, 6 insertions(+), 1 deletions(-)
sys/amd64/amd64/machdep.c +5 -1
@@ -178,6 +178,9 @@ struct init_ops init_ops = { .early_delay_init = i8254_init, .early_delay = i8254_delay, .parse_memmap = native_parse_memmap, +#ifdef SMP + .mp_bootaddress = mp_bootaddress, +#endif };/*
@@ -1490,7 +1493,8 @@ getmemsize(caddr_t kmdp, u_int64_t first)#ifdef SMP /* make hole for AP bootstrap code */ - physmap[1 ] =mp_bootaddress (physmap[1 ] /1024 ); +if (init_ops.mp_bootaddress) + physmap[1 ] = init_ops.mp_bootaddress (physmap[1 ] /1024 );#endif /*
sys/amd64/include/sysarch.h +1 -0
@@ -16,6 +16,7 @@ struct init_ops {void (*early_delay_init)(void );void (*early_delay)(int );void (*parse_memmap)(caddr_t ,vm_paddr_t *,int *); +u_int (*mp_bootaddress)(u_int); };extern struct init_ops init_ops;
Signature · 1 line
1.7.7.5 (Apple Git-26)
PATCH v9 11/19 xen: changes to hvm code in order to support PVH guests
In reply to a message not in the archiveOn PVH we don't need to init the shared info page, or disable emulated devices. Also, make sure PV IPIs are set before starting the APs.
--- sys/x86/xen/hvm.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-)
sys/x86/xen/hvm.c +12 -5
@@ -523,7 +523,7 @@ xen_setup_cpus(void) {int i; -if (!xen_hvm_domain () || !xen_vector_callback_enabled) +if (!xen_vector_callback_enabled)return ;#ifdef __amd64__
@@ -712,10 +712,13 @@ xen_hvm_init(enum xen_hvm_init_type init_type) } xen_vector_callback_enabled =0 ; - xen_domain_type =XEN_HVM_DOMAIN ; -xen_hvm_init_shared_info_page ();xen_hvm_set_callback (NULL ); -xen_hvm_disable_emulated_devices (); + +if (!xen_pv_domain ()) { + xen_domain_type =XEN_HVM_DOMAIN ; +xen_hvm_init_shared_info_page (); +xen_hvm_disable_emulated_devices (); + } }void
@@ -746,6 +749,9 @@ xen_set_vcpu_id(void)struct pcpu *pc;int i; +if (!xen_hvm_domain ()) +return ; +/* Set vcpu_id to acpi_id */ CPU_FOREACH (i) { pc =pcpu_find (i);
@@ -789,7 +795,8 @@ xen_hvm_cpu_init(void)SYSINIT (xen_hvm_init,SI_SUB_HYPERVISOR ,SI_ORDER_FIRST , xen_hvm_sysinit,NULL );#ifdef SMP -SYSINIT (xen_setup_cpus,SI_SUB_SMP ,SI_ORDER_FIRST , xen_setup_cpus,NULL ); +/* We need to setup IPIs before APs are started */ +SYSINIT (xen_setup_cpus,SI_SUB_SMP -1 ,SI_ORDER_FIRST , xen_setup_cpus,NULL );#endif SYSINIT (xen_hvm_cpu_init,SI_SUB_INTR ,SI_ORDER_FIRST , xen_hvm_cpu_init,NULL );SYSINIT (xen_set_vcpu_id,SI_SUB_CPU ,SI_ORDER_ANY , xen_set_vcpu_id,NULL );
Signature · 1 line
1.7.7.5 (Apple Git-26)
PATCH v9 12/19 xen: add a hook to perform AP startup
In reply to a message not in the archiveAP startup on PVH follows the PV method, so we need to add a hook in order to diverge from bare metal.
--- sys/amd64/amd64/mp_machdep.c | 14 +++--- sys/amd64/include/cpu.h | 1 + sys/amd64/include/smp.h | 1 + sys/x86/xen/hvm.c | 12 +++++- sys/x86/xen/pv.c | 85 ++++++++++++++++++++++++++++++++++++++++++ sys/xen/pv.h | 32 ++++++++++++++++ 6 files changed, 137 insertions(+), 8 deletions(-) create mode 100644 sys/xen/pv.h
sys/amd64/amd64/mp_machdep.c +7 -7
@@ -90,7 +90,7 @@ extern struct pcpu __pcpu[];/* AP uses this during bootstrap. Do not staticize. */ char *bootSTK; -static int bootAP; +int bootAP;/* Free these after use */ void *bootstacks[MAXCPU ];
@@ -124,7 +124,8 @@ static u_long *ipi_hardclock_counts[MAXCPU];/* Default cpu_ops implementation. */ struct cpu_ops cpu_ops = { - .ipi_vectored = lapic_ipi_vectored + .ipi_vectored = lapic_ipi_vectored, + .start_all_aps = native_start_all_aps, };extern inthand_t IDTVEC (fast_syscall ),IDTVEC (fast_syscall32 );
@@ -138,7 +139,7 @@ extern int pmap_pcid_enabled;static volatile cpuset_t ipi_nmi_pending;/* used to hold the AP's until we are ready to release them */ -static struct mtx ap_boot_mtx; +struct mtx ap_boot_mtx;/* Set to 1 once we're ready to let the APs out of the pen. */ static volatile int aps_ready =0 ;
@@ -165,7 +166,6 @@ static int cpu_cores; /* cores per package */static void assign_cpu_ids (void );static void set_interrupt_apic_ids (void ); -static int start_all_aps (void );static int start_ap (int apic_id);static void release_aps (void *dummy);
@@ -569,7 +569,7 @@ cpu_mp_start(void)assign_cpu_ids ();/* Start each Application Processor */ -start_all_aps (); + cpu_ops.start_all_aps ();set_interrupt_apic_ids (); }
@@ -908,8 +908,8 @@ assign_cpu_ids(void)/* * start each AP in our list */ -static int -start_all_aps (void ) +int +native_start_all_aps (void ) {vm_offset_t va = boot_address +KERNBASE ;u_int64_t *pt4, *pt3, *pt2;
sys/amd64/include/cpu.h +1 -0
@@ -64,6 +64,7 @@ struct cpu_ops {void (*cpu_init)(void );void (*cpu_resume)(void );void (*ipi_vectored)(u_int ,int ); +int (*start_all_aps)(void ); };extern struct cpu_ops cpu_ops;
sys/amd64/include/smp.h +1 -0
@@ -79,6 +79,7 @@ void smp_masked_invlpg_range(cpuset_t mask, struct pmap *pmap, vm_offset_t startva, vm_offset_t endva);void smp_invltlb (struct pmap *pmap);void smp_masked_invltlb (cpuset_t mask,struct pmap *pmap); +int native_start_all_aps (void );#endif /* !LOCORE */ #endif /* SMP */
sys/x86/xen/hvm.c +11 -1
@@ -53,6 +53,9 @@ __FBSDID("$FreeBSD$");#include <xen/hypervisor.h> #include <xen/hvm.h> #include <xen/xen_intr.h> +#ifdef __amd64__ +#include <xen/pv.h> +#endif #include <xen/interface/hvm/params.h> #include <xen/interface/vcpu.h>
@@ -119,7 +122,10 @@ enum xen_domain_type xen_domain_type = XEN_NATIVE;struct cpu_ops xen_hvm_cpu_ops = { .ipi_vectored = lapic_ipi_vectored, .cpu_init = xen_hvm_cpu_init, - .cpu_resume = xen_hvm_cpu_resume + .cpu_resume = xen_hvm_cpu_resume, +#ifdef __amd64__ + .start_all_aps = native_start_all_aps, +#endif }; static MALLOC_DEFINE(M_XENHVM, "xen_hvm", "Xen HVM PV Support");
@@ -698,6 +704,10 @@ xen_hvm_init(enum xen_hvm_init_type init_type)setup_xen_features (); cpu_ops = xen_hvm_cpu_ops; vm_guest =VM_GUEST_XEN ; +#ifdef __amd64__ +if (xen_pv_domain ()) + cpu_ops.start_all_aps = xen_pv_start_all_aps; +#endif break ;case XEN_HVM_INIT_RESUME :if (error !=0 )
sys/x86/xen/pv.c +85 -0
114 lines not on this page · raw message
sys/xen/pv.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright (c) 2013 Roger Pau Monné <[email protected]> +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND +* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +*/ + +#ifndef __XEN_PV_H__ +#define __XEN_PV_H__ + +int xen_pv_start_all_aps (void ); + +#endif /* __XEN_PV_H__ */
Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v9 13/19 xen: introduce flag to disable the local apic
In reply to a message not in the archivePVH guests don't have an emulated lapic.
--- sys/amd64/amd64/mp_machdep.c | 10 ++++++---- sys/amd64/include/apicvar.h | 1 + sys/i386/include/apicvar.h | 1 + sys/i386/xen/xen_machdep.c | 2 ++ sys/x86/x86/local_apic.c | 8 +++++--- sys/x86/xen/pv.c | 3 +++ 6 files changed, 18 insertions(+), 7 deletions(-)
sys/amd64/amd64/mp_machdep.c +6 -4
@@ -707,7 +707,8 @@ init_secondary(void)wrmsr (MSR_SF_MASK ,PSL_NT |PSL_T |PSL_I |PSL_C |PSL_D );/* Disable local APIC just to be sure. */ -lapic_disable (); +if (lapic_valid) +lapic_disable ();/* signal our startup to the BSP. */ mp_naps++;
@@ -733,7 +734,7 @@ init_secondary(void)/* A quick check from sanity claus */ cpuid =PCPU_GET (cpuid); -if (PCPU_GET (apic_id) !=lapic_id ()) { +if (lapic_valid && (PCPU_GET (apic_id) !=lapic_id ())) {printf ("SMP: cpuid = %d\n" , cpuid);printf ("SMP: actual apic_id = %d\n" ,lapic_id ());printf ("SMP: correct apic_id = %d\n" ,PCPU_GET (apic_id));
@@ -749,7 +750,8 @@ init_secondary(void)mtx_lock_spin (&ap_boot_mtx);/* Init local apic for irq's */ -lapic_setup (1 ); +if (lapic_valid) +lapic_setup (1 );/* Set memory range attributes for this CPU to match the BSP */ mem_range_AP_init ();
@@ -764,7 +766,7 @@ init_secondary(void)if (cpu_logical >1 &&PCPU_GET (apic_id) % cpu_logical !=0 )CPU_SET (cpuid, &logical_cpus_mask); -if (bootverbose) +if (lapic_valid && bootverbose)lapic_dump ("AP" );if (smp_cpus == mp_ncpus) {
sys/amd64/include/apicvar.h +1 -0
@@ -169,6 +169,7 @@ inthand_textern vm_paddr_t lapic_paddr;extern int apic_cpuids[]; +extern bool lapic_valid;u_int apic_alloc_vector (u_int apic_id,u_int irq); u_int apic_alloc_vectors(u_int apic_id, u_int *irqs, u_int count,
sys/i386/include/apicvar.h +1 -0
@@ -168,6 +168,7 @@ inthand_textern vm_paddr_t lapic_paddr;extern int apic_cpuids[]; +extern bool lapic_valid;u_int apic_alloc_vector (u_int apic_id,u_int irq); u_int apic_alloc_vectors(u_int apic_id, u_int *irqs, u_int count,
sys/i386/xen/xen_machdep.c +2 -0
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");#include <machine/intr_machdep.h> #include <machine/md_var.h> #include <machine/asmacros.h> +#include <machine/apicvar.h>
@@ -912,6 +913,7 @@ initvalues(start_info_t *startinfo)#endif xen_start_info = startinfo; HYPERVISOR_start_info = startinfo; + lapic_valid = false; xen_phys_machine = (xen_pfn_t *)startinfo->mfn_list; IdlePTD = (pd_entry_t *)((uint8_t *)startinfo->pt_base +PAGE_SIZE );
sys/x86/x86/local_apic.c +5 -3
@@ -156,6 +156,7 @@ extern inthand_t IDTVEC(rsvd);volatile lapic_t *lapic;vm_paddr_t lapic_paddr; +bool lapic_valid = true;static u_long lapic_timer_divisor;static struct eventtimer lapic_et;
@@ -1367,9 +1368,10 @@ apic_setup_io(void *dummy __unused)if (retval !=0 )printf ("%s: Failed to setup I/O APICs: returned %d\n" , best_enum->apic_name, retval); -#ifdef XEN -return ; -#endif + +if (!lapic_valid) +return ; +/* * Finish setting up the local APIC on the BSP once we know how to * properly program the LINT pins.
sys/x86/xen/pv.c +3 -0
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");#include <machine/clock.h> #include <machine/pc/bios.h> #include <machine/smp.h> +#include <machine/apicvar.h> #include <xen/xen-os.h> #include <xen/hypervisor.h>
@@ -315,4 +316,6 @@ xen_pv_set_init_ops(void) {/* Init ops for Xen PV */ init_ops = xen_init_ops; +/* Disable lapic */ + lapic_valid = false; }
Signature · 1 line
1.7.7.5 (Apple Git-26)
PATCH v9 14/19 xen: introduce xenpv bus and a dummy pvcpu device
In reply to a message not in the archiveSince Xen PVH guests doesn't have ACPI, we need to create a dummy bus so top level Xen devices can attach to it (instead of attaching directly to the nexus) and a pvcpu device that will be used to fill the pcpu->pc_device field.
--- sys/conf/files.amd64 | 1 + sys/conf/files.i386 | 1 + sys/x86/xen/xenpv.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+), 0 deletions(-) create mode 100644 sys/x86/xen/xenpv.c
sys/conf/files.amd64 +1 -0
@@ -570,3 +570,4 @@ x86/xen/hvm.c optional xenhvm x86/xen/xen_intr.c optional xen | xenhvm x86/xen/pv.c optional xenhvm x86/xen/pvcpu_enum.c optional xenhvm +x86/xen/xenpv.c optional xenhvm
sys/conf/files.i386 +1 -0
@@ -603,3 +603,4 @@ x86/x86/tsc.c standard x86/x86/delay.c standard x86/xen/hvm.c optional xenhvm x86/xen/xen_intr.c optional xen | xenhvm +x86/xen/xenpv.c optional xen | xenhvm
sys/x86/xen/xenpv.c new file +155 -0
155 lines not on this page · raw message
Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v9 14/19] xen: introduce xenpv bus and a dummy pvcpu device
Quoted 8 lines · Roger Pau Monne
Since Xen PVH guests doesn't have ACPI, we need to create a dummy bus so top level Xen devices can attach to it (instead of attaching directly to the nexus) and a pvcpu device that will be used to fill the
pcpu->pc_devicefield.--- sys/conf/files.amd64 | 1 + sys/conf/files.i386 | 1 + sys/x86/xen/xenpv.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++
I think it makes more sense to have 2 files: one for xenpv bus and one for a dummy pvcpu device. It would allow us to move xenpv bus to common code (sys/xen or sys/dev/xen).
[..]
sys/x86/xen/xenpv.c line 46
Quoted 8 lines
sys/x86/xen/xenpv.c new file +8
-0+ +static int +xenpv_probe (device_t dev) +{ + +device_set_desc (dev,"Xen PV bus" ); +device_quiet (dev); +return (0 );
As I understand, 0 means I can "handle" the current device, in this case if a device is probing, because it doesn't have yet a driver, we will use xenpv and end up with 2 (or even more) xenpv buses.
As we only want to probe xenpv bus once, when the bus was added manually, returning BUS_PROBE_NO_WILDCARD would suit better.
[..]
sys/x86/xen/xenpv.c line 123
Quoted 6 lines
sys/x86/xen/xenpv.c new file +6
-0+static int +xenpvcpu_probe (device_t dev) +{ + +device_set_desc (dev,"Xen PV CPU" ); +return (0 );
Same here: BUS_PROBE_NOWILDCARD.
Signature · 1 line
Julien Grall
Re: [PATCH v9 14/19] xen: introduce xenpv bus and a dummy pvcpu device
Quoted 13 lines · Julien Grall
Quoted 9 lines · Roger Pau Monne
Since Xen PVH guests doesn't have ACPI, we need to create a dummy bus so top level Xen devices can attach to it (instead of attaching directly to the nexus) and a pvcpu device that will be used to fill the
pcpu->pc_devicefield.--- sys/conf/files.amd64 | 1 + sys/conf/files.i386 | 1 + sys/x86/xen/xenpv.c | 155++++++++++++++++++++++++++++++++++++++++++++++++++
Quoted 3 lines
I think it makes more sense to have 2 files: one for xenpv bus and one for a dummy pvcpu device. It would allow us to move xenpv bus to common code (sys/xen or sys/dev/xen).
Ack. I wasn't thinking other arches will probably use the xenpv bus but not the dummy cpu device. Would you agree to leave xenpv bus inside x86/xen for now and move the dummy PV cpu device to dev/xen/pvcpu/?
Quoted 21 lines
[..]
sys/x86/xen/xenpv.c line 46
Quoted 8 lines
sys/x86/xen/xenpv.c new file +8
-0+ +static int +xenpv_probe (device_t dev) +{ + +device_set_desc (dev,"Xen PV bus" ); +device_quiet (dev); +return (0 );As I understand, 0 means I can "handle" the current device, in this case if a device is probing, because it doesn't have yet a driver, we will use xenpv and end up with 2 (or even more) xenpv buses.
As we only want to probe xenpv bus once, when the bus was added manually, returning
BUS_PROBE_NO_WILDCARDwould suit better.[..]
Quoted 8 lines
sys/x86/xen/xenpv.c line 123
Quoted 6 lines
sys/x86/xen/xenpv.c new file +6
-0+static int +xenpvcpu_probe (device_t dev) +{ + +device_set_desc (dev,"Xen PV CPU" ); +return (0 );Same here:
BUS_PROBE_NOWILDCARD.
Ack for both, will change it to BUS_PROBE_NOWILDCARD. While at it, we should also change xenstore probe function to return BUS_PROBE_NOWILDCARD.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v9 14/19] xen: introduce xenpv bus and a dummy pvcpu device
Quoted 14 lines · Roger Pau Monné
Quoted 13 lines · Julien Grall
Quoted 9 lines · Roger Pau Monne
Since Xen PVH guests doesn't have ACPI, we need to create a dummy bus so top level Xen devices can attach to it (instead of attaching directly to the nexus) and a pvcpu device that will be used to fill the
pcpu->pc_devicefield.--- sys/conf/files.amd64 | 1 + sys/conf/files.i386 | 1 + sys/x86/xen/xenpv.c | 155++++++++++++++++++++++++++++++++++++++++++++++++++
Quoted 7 lines
Quoted 3 lines
I think it makes more sense to have 2 files: one for xenpv bus and one for a dummy pvcpu device. It would allow us to move xenpv bus to common code (sys/xen or sys/dev/xen).
Ack. I wasn't thinking other arches will probably use the xenpv bus but not the dummy cpu device. Would you agree to leave xenpv bus inside x86/xen for now and move the dummy PV cpu device to dev/xen/pvcpu/?
As we will attach every xen device to xenpv, it makes more sense to have xenpv bus used on ARM. It will avoid duplication code and keep it nicer.
I'm fine with this solution for now. I will update/move the code when I will send the patch series to support FreeBSD on Xen on ARM.
Quoted 30 lines
Quoted 21 lines
[..]
sys/x86/xen/xenpv.c line 46
Quoted 8 lines
sys/x86/xen/xenpv.c new file +8
-0+ +static int +xenpv_probe (device_t dev) +{ + +device_set_desc (dev,"Xen PV bus" ); +device_quiet (dev); +return (0 );As I understand, 0 means I can "handle" the current device, in this case if a device is probing, because it doesn't have yet a driver, we will use xenpv and end up with 2 (or even more) xenpv buses.
As we only want to probe xenpv bus once, when the bus was added manually, returning
BUS_PROBE_NO_WILDCARDwould suit better.[..]
Quoted 8 lines
sys/x86/xen/xenpv.c line 123
Quoted 6 lines
sys/x86/xen/xenpv.c new file +6
-0+static int +xenpvcpu_probe (device_t dev) +{ + +device_set_desc (dev,"Xen PV CPU" ); +return (0 );Same here:
BUS_PROBE_NOWILDCARD.
Quoted 3 lines
Ack for both, will change it to
BUS_PROBE_NOWILDCARD. While at it, we should also change xenstore probe function to returnBUS_PROBE_NOWILDCARD.
Right, I have a patch for xenstore. Do you want me to send it?
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v9 14/19] xen: introduce xenpv bus and a dummy pvcpu device
Quoted 61 lines · Julien Grall
Quoted 14 lines · Roger Pau Monné
Quoted 13 lines · Julien Grall
Quoted 9 lines · Roger Pau Monne
Since Xen PVH guests doesn't have ACPI, we need to create a dummy bus so top level Xen devices can attach to it (instead of attaching directly to the nexus) and a pvcpu device that will be used to fill the
pcpu->pc_devicefield.--- sys/conf/files.amd64 | 1 + sys/conf/files.i386 | 1 + sys/x86/xen/xenpv.c | 155++++++++++++++++++++++++++++++++++++++++++++++++++
Quoted 7 lines
Quoted 3 lines
I think it makes more sense to have 2 files: one for xenpv bus and one for a dummy pvcpu device. It would allow us to move xenpv bus to common code (sys/xen or sys/dev/xen).
Ack. I wasn't thinking other arches will probably use the xenpv bus but not the dummy cpu device. Would you agree to leave xenpv bus inside x86/xen for now and move the dummy PV cpu device to dev/xen/pvcpu/?
As we will attach every xen device to xenpv, it makes more sense to have xenpv bus used on ARM. It will avoid duplication code and keep it nicer.
I'm fine with this solution for now. I will update/move the code when I will send the patch series to support FreeBSD on Xen on ARM.
Quoted 30 lines
Quoted 29 lines
[..]
sys/x86/xen/xenpv.c line 46
Quoted 8 lines
sys/x86/xen/xenpv.c new file +8
-0+ +static int +xenpv_probe (device_t dev) +{ + +device_set_desc (dev,"Xen PV bus" ); +device_quiet (dev); +return (0 );As I understand, 0 means I can "handle" the current device, in this case if a device is probing, because it doesn't have yet a driver, we will use xenpv and end up with 2 (or even more) xenpv buses.
As we only want to probe xenpv bus once, when the bus was added manually, returning
BUS_PROBE_NO_WILDCARDwould suit better.[..]
sys/x86/xen/xenpv.c line 123
Quoted 6 lines
sys/x86/xen/xenpv.c new file +6
-0+static int +xenpvcpu_probe (device_t dev) +{ + +device_set_desc (dev,"Xen PV CPU" ); +return (0 );Same here:
BUS_PROBE_NOWILDCARD.
Quoted 6 lines
Quoted 4 lines
Ack for both, will change it to
BUS_PROBE_NOWILDCARD. While at it, we should also change xenstore probe function to returnBUS_PROBE_NOWILDCARD.Right, I have a patch for xenstore. Do you want me to send it?
Sure, send it!
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v9 15/19 xen: create a Xen nexus to use in PV/PVH
In reply to a message not in the archiveIntroduce a Xen specific nexus that is going to be in charge for attaching Xen specific devices.
--- sys/conf/files.amd64 | 1 + sys/conf/files.i386 | 1 + sys/dev/xen/console/console.c | 2 +- sys/dev/xen/timer/timer.c | 4 +- sys/dev/xen/xenpci/xenpci.c | 4 ++ sys/x86/xen/xen_nexus.c | 82 +++++++++++++++++++++++++++++++++++++++++ sys/x86/xen/xenpv.c | 1 + sys/xen/xenstore/xenstore.c | 6 +-- 8 files changed, 93 insertions(+), 8 deletions(-) create mode 100644 sys/x86/xen/xen_nexus.c
sys/conf/files.amd64 +1 -0
@@ -571,3 +571,4 @@ x86/xen/xen_intr.c optional xen | xenhvm x86/xen/pv.c optional xenhvm x86/xen/pvcpu_enum.c optional xenhvm x86/xen/xenpv.c optional xenhvm +x86/xen/xen_nexus.c optional xenhvm
sys/conf/files.i386 +1 -0
@@ -604,3 +604,4 @@ x86/x86/delay.c standard x86/xen/hvm.c optional xenhvm x86/xen/xen_intr.c optional xen | xenhvm x86/xen/xenpv.c optional xen | xenhvm +x86/xen/xen_nexus.c optional xen | xenhvm
sys/dev/xen/console/console.c +1 -1
@@ -462,4 +462,4 @@ xcons_force_flush(void) } } -DRIVER_MODULE (xc, nexus, xc_driver, xc_devclass,0 ,0 ); +DRIVER_MODULE (xc, xenpv, xc_driver, xc_devclass,0 ,0 );
sys/dev/xen/timer/timer.c +2 -2
@@ -636,5 +636,5 @@ static driver_t xentimer_driver = { sizeof(struct xentimer_softc), }; -DRIVER_MODULE (xentimer, nexus, xentimer_driver, xentimer_devclass,0 ,0 ); -MODULE_DEPEND (xentimer, nexus,1 ,1 ,1 ); +DRIVER_MODULE (xentimer, xenpv, xentimer_driver, xentimer_devclass,0 ,0 ); +MODULE_DEPEND (xentimer, xenpv,1 ,1 ,1 );
sys/dev/xen/xenpci/xenpci.c +4 -0
@@ -270,6 +270,10 @@ xenpci_attach(device_t dev) goto errexit; } +/* Add the xenpv device so top level Xen devices can attach */ +if (BUS_ADD_CHILD (dev,0 ,"xenpv" ,0 ) ==NULL ) +panic ("xenpci: unable to add xenpv device" ); +return (bus_generic_attach (dev)); errexit:
sys/x86/xen/xen_nexus.c new file +82 -0
82 lines not on this page · raw message
sys/x86/xen/xenpv.c +1 -0
@@ -90,6 +90,7 @@ static driver_t xenpv_driver = {static devclass_t xenpv_devclass;DRIVER_MODULE (xenpv, nexus, xenpv_driver, xenpv_devclass,0 ,0 ); +DRIVER_MODULE (xenpv, xenpci, xenpv_driver, xenpv_devclass,0 ,0 );/* * Dummy Xen cpu device
sys/xen/xenstore/xenstore.c +1 -5
@@ -1261,11 +1261,7 @@ static device_method_t xenstore_methods[] = {DEFINE_CLASS_0 (xenstore, xenstore_driver, xenstore_methods,0 );static devclass_t xenstore_devclass; -#ifdef XENHVM -DRIVER_MODULE (xenstore, xenpci, xenstore_driver, xenstore_devclass,0 ,0 ); -#else -DRIVER_MODULE (xenstore, nexus, xenstore_driver, xenstore_devclass,0 ,0 ); -#endif +DRIVER_MODULE (xenstore, xenpv, xenstore_driver, xenstore_devclass,0 ,0 );/*------------------------------- Sysctl Data --------------------------------*/ /* XXX Shouldn't the node be somewhere else? */
Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v9 16/19 xen: add shutdown hook for PVH
In reply to a message not in the archiveAdd the PV shutdown hook to PVH.
--- sys/dev/xen/control/control.c | 37 ++++++++++++++++++------------------- 1 files changed, 18 insertions(+), 19 deletions(-)
sys/dev/xen/control/control.c +18 -19
@@ -316,21 +316,6 @@ xctrl_suspend() EVENTHANDLER_INVOKE(power_resume); } -static void -xen_pv_shutdown_final (void *arg,int howto) -{ -/* -* Inform the hypervisor that shutdown is complete. -* This is not necessary in HVM domains since Xen -* emulates ACPI in that mode and FreeBSD's ACPI -* support will request this transition. -*/ -if (howto & (RB_HALT |RB_POWEROFF )) -HYPERVISOR_shutdown (SHUTDOWN_poweroff); -else -HYPERVISOR_shutdown (SHUTDOWN_reboot); -} -#else /* HVM mode suspension. */
@@ -440,6 +425,21 @@ xctrl_crash()panic ("Xen directed crash" ); } +static void +xen_pv_shutdown_final (void *arg,int howto) +{ +/* +* Inform the hypervisor that shutdown is complete. +* This is not necessary in HVM domains since Xen +* emulates ACPI in that mode and FreeBSD's ACPI +* support will request this transition. +*/ +if (howto & (RB_HALT |RB_POWEROFF )) +HYPERVISOR_shutdown (SHUTDOWN_poweroff); +else +HYPERVISOR_shutdown (SHUTDOWN_reboot); +} +/*------------------------------ Event Reception -----------------------------*/ static void xctrl_on_watch_event (struct xs_watch *watch,const char **vec,unsigned int len)
@@ -522,10 +522,9 @@ xctrl_attach(device_t dev) xctrl->xctrl_watch.callback_data = (uintptr_t )xctrl;xs_register_watch (&xctrl->xctrl_watch); -#ifndef XENHVM -EVENTHANDLER_REGISTER (shutdown_final, xen_pv_shutdown_final,NULL , -SHUTDOWN_PRI_LAST ); -#endif +if (xen_pv_domain ()) +EVENTHANDLER_REGISTER (shutdown_final, xen_pv_shutdown_final,NULL , +SHUTDOWN_PRI_LAST );return (0 ); }
Signature · 1 line
1.7.7.5 (Apple Git-26)
PATCH v9 17/19 xen: xenstore changes to support PVH
In reply to a message not in the archive--- sys/xen/xenstore/xenstore.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
sys/xen/xenstore/xenstore.c +9 -9
@@ -229,13 +229,11 @@ struct xs_softc {*/ struct sx xenwatch_mutex; -#ifdef XENHVM /** * The HVM guest pseudo-physical frame number. This is Xen's mapping * of the true machine frame number into our "physical address space". */ unsigned long gpfn; -#endif /** * The event channel for communicating with the
@@ -1147,13 +1145,15 @@ xs_attach(device_t dev)/* Initialize the interface to xenstore. */ struct proc *p; -#ifdef XENHVM - xs.evtchn =hvm_get_parameter (HVM_PARAM_STORE_EVTCHN ); - xs.gpfn =hvm_get_parameter (HVM_PARAM_STORE_PFN ); - xen_store =pmap_mapdev (xs.gpfn *PAGE_SIZE ,PAGE_SIZE ); -#else - xs.evtchn = xen_start_info->store_evtchn; -#endif +if (xen_hvm_domain ()) { + xs.evtchn =hvm_get_parameter (HVM_PARAM_STORE_EVTCHN ); + xs.gpfn =hvm_get_parameter (HVM_PARAM_STORE_PFN ); + xen_store =pmap_mapdev (xs.gpfn *PAGE_SIZE ,PAGE_SIZE ); + }else if (xen_pv_domain ()) { + xs.evtchn = HYPERVISOR_start_info->store_evtchn; + }else { +panic ("Unknown domain type, cannot initialize xenstore\n" ); + }TAILQ_INIT (&xs.reply_list);TAILQ_INIT (&xs.watch_events);
Signature · 1 line
1.7.7.5 (Apple Git-26)
PATCH v9 18/19 xen: changes to gnttab for PVH
In reply to a message not in the archive--- sys/xen/gnttab.c | 26 +++++++++++++++++++++----- 1 files changed, 21 insertions(+), 5 deletions(-)
sys/xen/gnttab.c +21 -5
@@ -25,6 +25,7 @@ __FBSDID("$FreeBSD$");#include <sys/lock.h> #include <sys/malloc.h> #include <sys/mman.h> +#include <sys/limits.h> #include <xen/xen-os.h> #include <xen/hypervisor.h>
@@ -607,6 +608,7 @@ gnttab_resume(void) {int error;unsigned int max_nr_gframes, nr_gframes; +void *alloc_mem; nr_gframes = nr_grant_frames; max_nr_gframes =max_nr_grant_frames ();
@@ -614,11 +616,25 @@ gnttab_resume(void)return (ENOSYS );if (!resume_frames) { - error =xenpci_alloc_space (PAGE_SIZE * max_nr_gframes, - &resume_frames); -if (error) { -printf ("error mapping gnttab share frames\n" ); -return (error); +if (xen_pv_domain ()) { +/* +* This is a waste of physical memory, +* we should use ballooned pages instead, +* but it will do for now. +*/ + alloc_mem =contigmalloc (max_nr_gframes *PAGE_SIZE , +M_DEVBUF ,M_NOWAIT ,0 , +ULONG_MAX ,PAGE_SIZE ,0 ); +KASSERT ((alloc_mem !=NULL ), + ("unable to alloc memory for gnttab" )); + resume_frames =vtophys (alloc_mem); + }else { + error =xenpci_alloc_space (PAGE_SIZE * max_nr_gframes, + &resume_frames); +if (error) { +printf ("error mapping gnttab share frames\n" ); +return (error); + } } }
Signature · 1 line
1.7.7.5 (Apple Git-26)
PATCH v9 19/19 isa: allow ISA bus to attach to xenpv device
In reply to a message not in the archive--- sys/x86/isa/isa.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
sys/x86/isa/isa.c +3 -0
@@ -241,3 +241,6 @@ isa_release_resource(device_t bus, device_t child, int type, int rid,* On this platform, isa can also attach to the legacy bus. */ DRIVER_MODULE (isa, legacy, isa_driver, isa_devclass,0 ,0 ); +#ifdef XENHVM +DRIVER_MODULE (isa, xenpv, isa_driver, isa_devclass,0 ,0 ); +#endif
Signature · 1 line
1.7.7.5 (Apple Git-26)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v9 19/19] isa: allow ISA bus to attach to xenpv device
Quoted 9 lines · Roger Pau Monne
--- sys/x86/isa/isa.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)sys/x86/isa/isa.c +0
-0
sys/x86/isa/isa.c isa_release_resource(device_t bus, device_t child, int type, int rid, · line 246
Quoted 6 lines
sys/x86/isa/isa.c +3
-0@@ -241,3 +241,6 @@ isa_release_resource(device_t bus, device_t child, int type, int rid,* On this platform, isa can also attach to the legacy bus. */ DRIVER_MODULE (isa, legacy, isa_driver, isa_devclass,0 ,0 ); +#ifdef XENHVM +DRIVER_MODULE (isa, xenpv, isa_driver, isa_devclass,0 ,0 ); +#endif
read all 19 patches. I'm glad you split them up.. makes it understandable.. even by me :-)
no real negative comments except a question as to whether there is any noticable performance impact on real hardware?
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v9 19/19] isa: allow ISA bus to attach to xenpv device
Quoted 5 lines · Julian Elischer
Quoted 4 lines · Roger Pau Monne
--- sys/x86/isa/isa.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
Quoted 16 lines
sys/x86/isa/isa.c isa_release_resource(device_t bus, device_t child,
Quoted 12 lines
sys/x86/isa/isa.c +3
-0@@ -241,3 +241,6 @@ isa_release_resource(device_t bus, device_t child,int type, int rid, * On this platform, isa can also attach to the legacy bus. */ DRIVER_MODULE (isa, legacy, isa_driver, isa_devclass,0 ,0 ); +#ifdef XENHVM +DRIVER_MODULE (isa, xenpv, isa_driver, isa_devclass,0 ,0 ); +#endif read all 19 patches. I'm glad you split them up.. makes it understandable.. even by me :-)
no real negative comments except a question as to whether there is any noticable performance impact on real hardware?
Thanks for taking a look. I haven't seen any performance impact when running a PVH capable kernel (a kernel with this patch series applied) on real hardware. I'm not adding hooks to any hot paths, most of the code added in this series is only used during boot time.
Roger.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v9 04/19] amd64: introduce hook for custom preload metadata parsers
Quoted 19 lines · Roger Pau Monne
--- sys/amd64/amd64/machdep.c | 41 ++++++++++++++++------ sys/amd64/include/sysarch.h | 12 ++++++ sys/x86/xen/pv.c | 82 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 11 deletions(-)sys/amd64/amd64/machdep.c +1
-0@@ -126,6 +126,7 @@ __FBSDID("$FreeBSD$");#include <machine/reg.h> #include <machine/sigframe.h> #include <machine/specialreg.h> +#include <machine/sysarch.h> #ifdef PERFMON #include <machine/perfmon.h> #endif
sys/amd64/amd64/machdep.c static int set_fpcontext(struct thread *td, const mcontext_t *mcp, · line 174
Quoted 9 lines
sys/amd64/amd64/machdep.c +6
-0@@ -165,6 +166,14 @@ static int set_fpcontext(struct thread *td, const mcontext_t *mcp, char *xfpustate, size_t xfpustate_len);SYSINIT (cpu,SI_SUB_CPU ,SI_ORDER_FIRST , cpu_startup,NULL ); +/* Preload data parse function */ +static caddr_t native_parse_preload_data (u_int64_t ); + +/* Default init_ops implementation. */ +struct init_ops init_ops = { + .parse_preload_data = native_parse_preload_data,
Extra space there.
Quoted 6 lines
sys/amd64/amd64/machdep.c +2
-0+}; +/* * The file "conf/ldscript.amd64" defines the symbol "kernphys". Its value is * the physical address at which the kernel is loaded.
sys/amd64/amd64/machdep.c do_next: · line 1700
Quoted 9 lines
sys/amd64/amd64/machdep.c +6
-0@@ -1683,6 +1692,26 @@ do_next: msgbufp = (struct msgbuf *)PHYS_TO_DMAP (phys_avail[pa_indx]); } +static caddr_t +native_parse_preload_data (u_int64_t modulep) +{ +caddr_t kmdp; + + preload_metadata = (caddr_t)(uintptr_t)(modulep +KERNBASE );
Two casts? Could it be done via one?
Quoted 18 lines
sys/amd64/amd64/machdep.c +14
-0+preload_bootstrap_relocate (KERNBASE ); + kmdp =preload_search_by_type ("elf kernel" ); +if (kmdp ==NULL ) + kmdp =preload_search_by_type ("elf64 kernel" ); + boothowto =MD_FETCH (kmdp,MODINFOMD_HOWTO , int); + kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *) + KERNBASE; +#ifdef DDB + ksym_start =MD_FETCH (kmdp,MODINFOMD_SSYM , uintptr_t); + ksym_end =MD_FETCH (kmdp,MODINFOMD_ESYM , uintptr_t); +#endif + +return (kmdp); +} +u_int64_t hammer_time (u_int64_t modulep,u_int64_t physfree) {
sys/amd64/amd64/machdep.c hammer_time(u_int64_t modulep, u_int64_t physfree) · line 1710
Quoted 4 lines
sys/amd64/amd64/machdep.c +0
-1@@ -1707,17 +1736,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)*/ proc_linkup0 (&proc0, &thread0); - preload_metadata = (caddr_t)(uintptr_t)(modulep +KERNBASE );
Oh, you just moved the code - right, lets not modify it in this patch.
Quoted 97 lines
sys/amd64/amd64/machdep.c +1
-10-preload_bootstrap_relocate (KERNBASE ); - kmdp =preload_search_by_type ("elf kernel" ); -if (kmdp ==NULL ) - kmdp =preload_search_by_type ("elf64 kernel" ); - boothowto =MD_FETCH (kmdp,MODINFOMD_HOWTO , int); - kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *) + KERNBASE; -#ifdef DDB - ksym_start =MD_FETCH (kmdp,MODINFOMD_SSYM , uintptr_t); - ksym_end =MD_FETCH (kmdp,MODINFOMD_ESYM , uintptr_t); -#endif + kmdp = init_ops.parse_preload_data (modulep);/* Init basic tunables, hz etc */ init_param1 ();sys/amd64/include/sysarch.h +12
-0@@ -4,3 +4,15 @@/* $FreeBSD$ */ #include <x86/sysarch.h> + +/* +* Struct containing pointers to init functions whose +* implementation is run time selectable. Selection can be made, +* for example, based on detection of a BIOS variant or +* hypervisor environment. +*/ +struct init_ops { +caddr_t (*parse_preload_data)(u_int64_t ); +}; + +extern struct init_ops init_ops;sys/x86/xen/pv.c +38
-0@@ -46,6 +46,8 @@ __FBSDID("$FreeBSD$");#include <vm/vm_pager.h> #include <vm/vm_param.h> +#include <machine/sysarch.h> +#include <xen/xen-os.h> #include <xen/hypervisor.h> @@ -54,6 +56,36 @@ extern u_int64_t hammer_time(u_int64_t, u_int64_t);/* Xen initial function */ extern u_int64_t hammer_time_xen (start_info_t *,u_int64_t ); +/*--------------------------- Forward Declarations ---------------------------*/ +static caddr_t xen_pv_parse_preload_data (u_int64_t ); + +static void xen_pv_set_init_ops (void ); + +/*-------------------------------- Global Data -------------------------------*/ +/* Xen init_ops implementation. */ +struct init_ops xen_init_ops = { + .parse_preload_data = xen_pv_parse_preload_data, +}; + +static struct +{ +const char *ev; +int mask; +} howto_names[] = { + {"boot_askname" ,RB_ASKNAME }, + {"boot_single" ,RB_SINGLE }, + {"boot_nosync" ,RB_NOSYNC }, + {"boot_halt" ,RB_ASKNAME }, + {"boot_serial" ,RB_SERIAL }, + {"boot_cdrom" ,RB_CDROM }, + {"boot_gdb" ,RB_GDB }, + {"boot_gdb_pause" ,RB_RESERVED1 }, + {"boot_verbose" ,RB_VERBOSE }, + {"boot_multicons" ,RB_MULTIPLE }, + {NULL ,0 } +}; + +/*-------------------------------- Xen PV init -------------------------------*/ /* * First function called by the Xen PVH boot sequence. * @@ -118,6 +150,56 @@ hammer_time_xen(start_info_t *si, u_int64_t xenstack) }load_cr3 (((u_int64_t)&PT4 [0 ]) -KERNBASE ); +/* Set the hooks for early functions that diverge from bare metal */ +xen_pv_set_init_ops (); +/* Now we can jump into the native init function */ return (hammer_time (0 , physfree)); } + +/*-------------------------------- PV specific -------------------------------*/ +/*
sys/x86/xen/pv.c hammer_time_xen(start_info_t *si, u_int64_t xenstack) · line 171
Quoted 10 lines
sys/x86/xen/pv.c +10
-0+* Functions to convert the "extra" parameters passed by Xen +* into FreeBSD boot options (from the i386 Xen port). +*/ +static char * +xen_setbootenv (char *cmd_line) +{ +char *cmd_line_next; + +/* Skip leading spaces */ +for (; *cmd_line ==' ' ; cmd_line++);
Spaces?
Quoted 4 lines
sys/x86/xen/pv.c +4
-0+ +for (cmd_line_next = cmd_line;strsep (&cmd_line_next,"," ) !=NULL ;); +return (cmd_line); +}
sys/x86/xen/pv.c hammer_time_xen(start_info_t *si, u_int64_t xenstack) · line 185
Quoted 10 lines
sys/x86/xen/pv.c +10
-0+ +static int +xen_boothowto (char *envp) +{ +int i, howto =0 ; + +/* get equivalents from the environment */ +for (i =0 ; howto_names[i].ev !=NULL ; i++) +if (getenv (howto_names[i].ev) !=NULL ) + howto |= howto_names[i].mask;
You don't believe in '{}' do you ? :-)
Quoted 28 lines
sys/x86/xen/pv.c +20
-0+return (howto); +} + +static caddr_t +xen_pv_parse_preload_data (u_int64_t modulep) +{ +/* Parse the extra boot information given by Xen */ +if (HYPERVISOR_start_info->cmd_line) + kern_envp =xen_setbootenv (HYPERVISOR_start_info->cmd_line); + boothowto |=xen_boothowto (kern_envp); + +return (NULL ); +} + +static void +xen_pv_set_init_ops (void ) +{ +/* Init ops for Xen PV */ + init_ops = xen_init_ops; +}Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v9 04/19] amd64: introduce hook for custom preload metadata parsers
Quoted 23 lines · Konrad Rzeszutek Wilk
Quoted 22 lines · Roger Pau Monne
--- sys/amd64/amd64/machdep.c | 41 ++++++++++++++++------ sys/amd64/include/sysarch.h | 12 ++++++ sys/x86/xen/pv.c | 82 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 11 deletions(-)sys/amd64/amd64/machdep.c +1
-0@@ -126,6 +126,7 @@ __FBSDID("$FreeBSD$");#include <machine/reg.h> #include <machine/sigframe.h> #include <machine/specialreg.h> +#include <machine/sysarch.h> #ifdef PERFMON #include <machine/perfmon.h> #endif @@ -165,6 +166,14 @@ static int set_fpcontext(struct thread *td, const mcontext_t *mcp, char *xfpustate, size_t xfpustate_len);SYSINIT (cpu,SI_SUB_CPU ,SI_ORDER_FIRST , cpu_startup,NULL );
Quoted 8 lines
sys/amd64/amd64/machdep.c static int set_fpcontext(struct thread *td, const mcontext_t *mcp, · line 174
Quoted 6 lines
sys/amd64/amd64/machdep.c +6
-0+/* Preload data parse function */ +static caddr_t native_parse_preload_data (u_int64_t ); + +/* Default init_ops implementation. */ +struct init_ops init_ops = { + .parse_preload_data = native_parse_preload_data,Extra space there.
It's for alignment, looks strange now because there's only one hook.
Quoted 39 lines
Quoted 6 lines
sys/amd64/amd64/machdep.c +2
-0+}; +/* * The file "conf/ldscript.amd64" defines the symbol "kernphys". Its value is * the physical address at which the kernel is loaded. sys/amd64/amd64/machdep.c do_next: · line 1700
Quoted 9 lines
sys/amd64/amd64/machdep.c +6
-0@@ -1683,6 +1692,26 @@ do_next: msgbufp = (struct msgbuf *)PHYS_TO_DMAP (phys_avail[pa_indx]); } +static caddr_t +native_parse_preload_data (u_int64_t modulep) +{ +caddr_t kmdp; + + preload_metadata = (caddr_t)(uintptr_t)(modulep +KERNBASE );Two casts? Could it be done via one?
Quoted 21 lines
sys/amd64/amd64/machdep.c +14
-0+preload_bootstrap_relocate (KERNBASE ); + kmdp =preload_search_by_type ("elf kernel" ); +if (kmdp ==NULL ) + kmdp =preload_search_by_type ("elf64 kernel" ); + boothowto =MD_FETCH (kmdp,MODINFOMD_HOWTO , int); + kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *) + KERNBASE; +#ifdef DDB + ksym_start =MD_FETCH (kmdp,MODINFOMD_SSYM , uintptr_t); + ksym_end =MD_FETCH (kmdp,MODINFOMD_ESYM , uintptr_t); +#endif + +return (kmdp); +} +u_int64_t hammer_time (u_int64_t modulep,u_int64_t physfree) {@@ -1707,17 +1736,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)*/ proc_linkup0 (&proc0, &thread0);
Quoted 3 lines
sys/amd64/amd64/machdep.c hammer_time(u_int64_t modulep, u_int64_t physfree) · line 1710
Quoted 1 line
sys/amd64/amd64/machdep.c +0
-1- preload_metadata = (caddr_t)(uintptr_t)(modulep +KERNBASE );Oh, you just moved the code - right, lets not modify it in this patch.
Yes, it's just code movement.
Quoted 111 lines
Quoted 98 lines
sys/amd64/amd64/machdep.c +1
-10-preload_bootstrap_relocate (KERNBASE ); - kmdp =preload_search_by_type ("elf kernel" ); -if (kmdp ==NULL ) - kmdp =preload_search_by_type ("elf64 kernel" ); - boothowto =MD_FETCH (kmdp,MODINFOMD_HOWTO , int); - kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *) + KERNBASE; -#ifdef DDB - ksym_start =MD_FETCH (kmdp,MODINFOMD_SSYM , uintptr_t); - ksym_end =MD_FETCH (kmdp,MODINFOMD_ESYM , uintptr_t); -#endif + kmdp = init_ops.parse_preload_data (modulep);/* Init basic tunables, hz etc */ init_param1 ();sys/amd64/include/sysarch.h +12
-0@@ -4,3 +4,15 @@/* $FreeBSD$ */ #include <x86/sysarch.h> + +/* +* Struct containing pointers to init functions whose +* implementation is run time selectable. Selection can be made, +* for example, based on detection of a BIOS variant or +* hypervisor environment. +*/ +struct init_ops { +caddr_t (*parse_preload_data)(u_int64_t ); +}; + +extern struct init_ops init_ops;sys/x86/xen/pv.c +38
-0@@ -46,6 +46,8 @@ __FBSDID("$FreeBSD$");#include <vm/vm_pager.h> #include <vm/vm_param.h> +#include <machine/sysarch.h> +#include <xen/xen-os.h> #include <xen/hypervisor.h> @@ -54,6 +56,36 @@ extern u_int64_t hammer_time(u_int64_t, u_int64_t);/* Xen initial function */ extern u_int64_t hammer_time_xen (start_info_t *,u_int64_t ); +/*--------------------------- Forward Declarations ---------------------------*/ +static caddr_t xen_pv_parse_preload_data (u_int64_t ); + +static void xen_pv_set_init_ops (void ); + +/*-------------------------------- Global Data -------------------------------*/ +/* Xen init_ops implementation. */ +struct init_ops xen_init_ops = { + .parse_preload_data = xen_pv_parse_preload_data, +}; + +static struct +{ +const char *ev; +int mask; +} howto_names[] = { + {"boot_askname" ,RB_ASKNAME }, + {"boot_single" ,RB_SINGLE }, + {"boot_nosync" ,RB_NOSYNC }, + {"boot_halt" ,RB_ASKNAME }, + {"boot_serial" ,RB_SERIAL }, + {"boot_cdrom" ,RB_CDROM }, + {"boot_gdb" ,RB_GDB }, + {"boot_gdb_pause" ,RB_RESERVED1 }, + {"boot_verbose" ,RB_VERBOSE }, + {"boot_multicons" ,RB_MULTIPLE }, + {NULL ,0 } +}; + +/*-------------------------------- Xen PV init -------------------------------*/ /* * First function called by the Xen PVH boot sequence. * @@ -118,6 +150,56 @@ hammer_time_xen(start_info_t *si, u_int64_t xenstack) }load_cr3 (((u_int64_t)&PT4 [0 ]) -KERNBASE ); +/* Set the hooks for early functions that diverge from bare metal */ +xen_pv_set_init_ops (); +/* Now we can jump into the native init function */ return (hammer_time (0 , physfree)); } + +/*-------------------------------- PV specific -------------------------------*/ +/* sys/x86/xen/pv.c hammer_time_xen(start_info_t *si, u_int64_t xenstack) · line 171
Quoted 10 lines
sys/x86/xen/pv.c +10
-0+* Functions to convert the "extra" parameters passed by Xen +* into FreeBSD boot options (from the i386 Xen port). +*/ +static char * +xen_setbootenv (char *cmd_line) +{ +char *cmd_line_next; + +/* Skip leading spaces */ +for (; *cmd_line ==' ' ; cmd_line++);Spaces?
Quoted 16 lines
Quoted 4 lines
sys/x86/xen/pv.c +4
-0+ +for (cmd_line_next = cmd_line;strsep (&cmd_line_next,"," ) !=NULL ;); +return (cmd_line); +}sys/x86/xen/pv.c hammer_time_xen(start_info_t *si, u_int64_t xenstack) · line 185
Quoted 10 lines
sys/x86/xen/pv.c +10
-0+ +static int +xen_boothowto (char *envp) +{ +int i, howto =0 ; + +/* get equivalents from the environment */ +for (i =0 ; howto_names[i].ev !=NULL ; i++) +if (getenv (howto_names[i].ev) !=NULL ) + howto |= howto_names[i].mask;You don't believe in '{}' do you ? :-)
All this code has also been taken from the FreeBSD Xen i386 PV port, but maybe some refactoring wouldn't be bad :).
Quoted 28 lines
Quoted 28 lines
sys/x86/xen/pv.c +20
-0+return (howto); +} + +static caddr_t +xen_pv_parse_preload_data (u_int64_t modulep) +{ +/* Parse the extra boot information given by Xen */ +if (HYPERVISOR_start_info->cmd_line) + kern_envp =xen_setbootenv (HYPERVISOR_start_info->cmd_line); + boothowto |=xen_boothowto (kern_envp); + +return (NULL ); +} + +static void +xen_pv_set_init_ops (void ) +{ +/* Init ops for Xen PV */ + init_ops = xen_init_ops; +}Signature · 7 lines
1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v9 15/19] xen: create a Xen nexus to use in PV/PVH
Quoted 2 lines · Roger Pau Monne
Introduce a Xen specific nexus that is going to be in charge for attaching Xen specific devices.
Now that we have a xenpv bus, do we really need a specific nexus for Xen? We should be able to use the identify callback of xenpv to create the bus.
The other part of this patch can be merged in the patch #14 "Introduce xenpv bus and a dummy pvcpu device".
Signature · 1 line
Julien Grall
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v9 15/19] xen: create a Xen nexus to use in PV/PVH
Quoted 11 lines · Julien Grall
Quoted 2 lines · Roger Pau Monne
Introduce a Xen specific nexus that is going to be in charge for attaching Xen specific devices.
Now that we have a xenpv bus, do we really need a specific nexus for Xen? We should be able to use the identify callback of xenpv to create the bus.
The other part of this patch can be merged in the patch #14 "Introduce xenpv bus and a dummy pvcpu device".
On x86 at least we need the Xen specific nexus, or we will fall back to use the legacy nexus which is not what we really want.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v9 15/19] xen: create a Xen nexus to use in PV/PVH
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Julien Grall
Quoted 2 lines · Roger Pau Monne
Introduce a Xen specific nexus that is going to be in charge for attaching Xen specific devices.
Quoted 9 lines
Quoted 5 lines
Now that we have a xenpv bus, do we really need a specific nexus for Xen? We should be able to use the identify callback of xenpv to create the bus.
The other part of this patch can be merged in the patch #14 "Introduce xenpv bus and a dummy pvcpu device".
On x86 at least we need the Xen specific nexus, or we will fall back to use the legacy nexus which is not what we really want.
Oh right, in any case can we use the identify callback of xenpv to add the bus?
With this solution xenpv can add itself no matter FreeBSD use the generic nexus or the nexus Xen, of course with a check if we are running on Xen :).
For instance, on ARM side I don't plan to have a specific Xen nexus.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v9 15/19] xen: create a Xen nexus to use in PV/PVH
Quoted 18 lines · Julien Grall
Quoted 15 lines · Roger Pau Monné
Quoted 13 lines · Julien Grall
Quoted 2 lines · Roger Pau Monne
Introduce a Xen specific nexus that is going to be in charge for attaching Xen specific devices.
Now that we have a xenpv bus, do we really need a specific nexus for Xen?
We should be able to use the identify callback of xenpv to create the bus.The other part of this patch can be merged in the patch #14 "Introduce xenpv bus and a dummy pvcpu device".
Quoted 6 lines
Quoted 3 lines
On x86 at least we need the Xen specific nexus, or we will fall back to use the legacy nexus which is not what we really want.
Oh right, in any case can we use the identify callback of xenpv to add the bus?
AFAICT this kind of bus devices don't have a identify routine, and they are usually added manually from the specific nexus, see acpi or legacy. Could you add the device on ARM when you detect that you are running as a Xen guest, or in the generic ARM nexus if Xen is detected?
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v9 15/19] xen: create a Xen nexus to use in PV/PVH
Quoted 23 lines · Roger Pau Monné
Quoted 22 lines · Julien Grall
Quoted 18 lines · Roger Pau Monné
Quoted 6 lines · Julien Grall
Quoted 2 lines · Roger Pau Monne
Introduce a Xen specific nexus that is going to be in charge for attaching Xen specific devices.
Quoted 7 lines
Now that we have a xenpv bus, do we really need a specific nexus for Xen?
We should be able to use the identify callback of xenpv to create the bus.The other part of this patch can be merged in the patch #14 "Introduce xenpv bus and a dummy pvcpu device".
On x86 at least we need the Xen specific nexus, or we will fall back to use the legacy nexus which is not what we really want.
Quoted 7 lines
Quoted 2 lines
Oh right, in any case can we use the identify callback of xenpv to add the bus?
AFAICT this kind of bus devices don't have a identify routine, and they are usually added manually from the specific nexus, see acpi or legacy. Could you add the device on ARM when you detect that you are running as a Xen guest, or in the generic ARM nexus if Xen is detected?
Is there any reason to not add identify callback? If it's possible, I would like to avoid as much as possible #ifdef XENHVM in ARM code.
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v9 15/19] xen: create a Xen nexus to use in PV/PVH
Quoted 27 lines · Julien Grall
Quoted 26 lines · Roger Pau Monné
Quoted 24 lines · Julien Grall
Quoted 12 lines · Roger Pau Monné
Quoted 11 lines · Julien Grall
Quoted 2 lines · Roger Pau Monne
Introduce a Xen specific nexus that is going to be in charge for attaching Xen specific devices.
Now that we have a xenpv bus, do we really need a specific nexus for Xen?
We should be able to use the identify callback of xenpv to create the bus.Quoted 6 lines
Quoted 2 lines
The other part of this patch can be merged in the patch #14 "Introduce xenpv bus and a dummy pvcpu device".
On x86 at least we need the Xen specific nexus, or we will fall back to use the legacy nexus which is not what we really want.
Oh right, in any case can we use the identify callback of xenpv to add the bus?
Quoted 7 lines
Quoted 4 lines
AFAICT this kind of bus devices don't have a identify routine, and they are usually added manually from the specific nexus, see acpi or legacy. Could you add the device on ARM when you detect that you are running as a Xen guest, or in the generic ARM nexus if Xen is detected?
Is there any reason to not add identify callback? If it's possible, I would like to avoid as much as possible #ifdef XENHVM in ARM code.
Maybe the x86 world is really different from the ARM world in how nexus works, but I rather prefer to have a #ifdef XENHVM and a BUS_ADD_CHILD that attaches the xenpv bus in the generic ARM nexus rather than having something that completely diverges from what buses usually do in FreeBSD. It's going to be much more difficult to track in case of bugs, and it's not what people expects, but that's just my opinion. I can certainly add the identify routine if there's an agreement that it's the best way to deal with it.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v9 15/19] xen: create a Xen nexus to use in PV/PVH
Quoted 37 lines · Roger Pau Monné
Quoted 19 lines · Julien Grall
Quoted 18 lines · Roger Pau Monné
Quoted 17 lines · Julien Grall
Quoted 15 lines · Roger Pau Monné
Quoted 11 lines · Julien Grall
Quoted 2 lines · Roger Pau Monne
Introduce a Xen specific nexus that is going to be in charge for attaching Xen specific devices.
Now that we have a xenpv bus, do we really need a specific nexus for Xen?
We should be able to use the identify callback of xenpv to create the bus.The other part of this patch can be merged in the patch #14 "Introduce xenpv bus and a dummy pvcpu device".
On x86 at least we need the Xen specific nexus, or we will fall back to use the legacy nexus which is not what we really want.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Oh right, in any case can we use the identify callback of xenpv to add the bus?
AFAICT this kind of bus devices don't have a identify routine, and they are usually added manually from the specific nexus, see acpi or legacy. Could you add the device on ARM when you detect that you are running as a Xen guest, or in the generic ARM nexus if Xen is detected?
Is there any reason to not add identify callback? If it's possible, I would like to avoid as much as possible #ifdef XENHVM in ARM code.
Maybe the x86 world is really different from the ARM world in how nexus works, but I rather prefer to have a #ifdef XENHVM and a
BUS_ADD_CHILDthat attaches the xenpv bus in the generic ARM nexus rather than having something that completely diverges from what buses usually do in FreeBSD. It's going to be much more difficult to track in case of bugs, and it's not what people expects, but that's just my opinion. I can certainly add the identify routine if there's an agreement that it's the best way to deal with it.
Quoted 6 lines
Roger.
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[email protected]"
Attaching sub-devices to nexus using device_identify() is the usual way to do this kind of thing. Note that if you do this, your device_probe() routine should return BUS_PROBE_NOWILDCARD to deal with platforms (ARM, MIPS, PowerPC, sparc64) with real autoconfigured devices hanging directly from nexus.
-Nathan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel