Index: sys/dev/xen/console/xen_console.c =================================================================== --- sys/dev/xen/console/xen_console.c +++ sys/dev/xen/console/xen_console.c @@ -55,6 +55,7 @@ #include #include #include +#include #include "opt_ddb.h" #include "opt_printf.h" @@ -272,6 +273,14 @@ static void xencons_early_init_ring(struct xencons_priv *cons) { + /* + * The ring is initialized later for the HVM console as the + * pmap code is not yet fully initialized + * TODO: See if we can map the ring in another way earlier. + */ + if (!xen_hvm_domain()) + return; + cons->intf = pmap_mapdev_attr(ptoa(xen_get_console_mfn()), PAGE_SIZE, VM_MEMATTR_XEN); cons->evtchn = xen_get_console_evtchn(); @@ -282,9 +291,23 @@ { struct xencons_priv *cons; int err; + xen_pfn_t pfn; cons = tty_softc(tp); + /* + * The information are already retrieved in + * xencons_early_init_ring for PV guest + */ + if (xen_hvm_domain()) { + cons->evtchn = hvm_get_parameter(HVM_PARAM_CONSOLE_EVTCHN); + pfn = hvm_get_parameter(HVM_PARAM_CONSOLE_PFN); + if (!pfn) + return (ENODEV); + cons->intf = pmap_mapdev_attr(pfn << PAGE_SHIFT, PAGE_SIZE, + VM_MEMATTR_XEN); + } + if (cons->evtchn == 0) return (ENODEV); @@ -327,6 +350,10 @@ xencons_lock_assert(cons); + /* The console page may have not yet been initialized for HVM domain */ + if (__predict_false(!intf)) + return -1; + wcons = intf->out_cons; wprod = intf->out_prod; @@ -359,6 +386,10 @@ xencons_lock_assert(cons); + /* The console page may have not yet been initialized for HVM domain */ + if (__predict_false(!intf)) + return 0; + rcons = intf->in_cons; rprod = intf->in_prod; rmb();