From owner-svn-src-stable@FreeBSD.ORG Wed Jan 29 21:23:40 2014 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0F5B8C5D; Wed, 29 Jan 2014 21:23:40 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id ED2C4171E; Wed, 29 Jan 2014 21:23:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0TLNdPt055154; Wed, 29 Jan 2014 21:23:39 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0TLNcxg055145; Wed, 29 Jan 2014 21:23:38 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201401292123.s0TLNcxg055145@svn.freebsd.org> From: John Baldwin Date: Wed, 29 Jan 2014 21:23:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r261275 - in stable/10/sys: amd64/amd64 amd64/include amd64/vmm amd64/vmm/amd amd64/vmm/intel x86/acpica X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jan 2014 21:23:40 -0000 Author: jhb Date: Wed Jan 29 21:23:37 2014 New Revision: 261275 URL: http://svnweb.freebsd.org/changeset/base/261275 Log: MFC 259782: Add a resume hook for bhyve that runs a function on all CPUs during resume. For Intel CPUs, invoke vmxon for CPUs that were in VMX mode at the time of suspend. Modified: stable/10/sys/amd64/amd64/machdep.c stable/10/sys/amd64/amd64/mp_machdep.c stable/10/sys/amd64/include/cpu.h stable/10/sys/amd64/include/vmm.h stable/10/sys/amd64/vmm/amd/amdv.c stable/10/sys/amd64/vmm/intel/vmx.c stable/10/sys/amd64/vmm/vmm.c stable/10/sys/x86/acpica/acpi_wakeup.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/amd64/machdep.c ============================================================================== --- stable/10/sys/amd64/amd64/machdep.c Wed Jan 29 20:48:26 2014 (r261274) +++ stable/10/sys/amd64/amd64/machdep.c Wed Jan 29 21:23:37 2014 (r261275) @@ -216,6 +216,8 @@ struct mem_range_softc mem_range_softc; struct mtx dt_lock; /* lock for GDT and LDT */ +void (*vmm_resume_p)(void); + static void cpu_startup(dummy) void *dummy; Modified: stable/10/sys/amd64/amd64/mp_machdep.c ============================================================================== --- stable/10/sys/amd64/amd64/mp_machdep.c Wed Jan 29 20:48:26 2014 (r261274) +++ stable/10/sys/amd64/amd64/mp_machdep.c Wed Jan 29 21:23:37 2014 (r261275) @@ -1483,6 +1483,8 @@ cpususpend_handler(void) if (cpu_ops.cpu_resume) cpu_ops.cpu_resume(); + if (vmm_resume_p) + vmm_resume_p(); /* Resume MCA and local APIC */ mca_resume(); Modified: stable/10/sys/amd64/include/cpu.h ============================================================================== --- stable/10/sys/amd64/include/cpu.h Wed Jan 29 20:48:26 2014 (r261274) +++ stable/10/sys/amd64/include/cpu.h Wed Jan 29 21:23:37 2014 (r261275) @@ -70,6 +70,9 @@ extern struct cpu_ops cpu_ops; extern char btext[]; extern char etext[]; +/* Resume hook for VMM. */ +extern void (*vmm_resume_p)(void); + void cpu_halt(void); void cpu_reset(void); void fork_trampoline(void); Modified: stable/10/sys/amd64/include/vmm.h ============================================================================== --- stable/10/sys/amd64/include/vmm.h Wed Jan 29 20:48:26 2014 (r261274) +++ stable/10/sys/amd64/include/vmm.h Wed Jan 29 21:23:37 2014 (r261275) @@ -49,6 +49,7 @@ enum x2apic_state; typedef int (*vmm_init_func_t)(void); typedef int (*vmm_cleanup_func_t)(void); +typedef void (*vmm_resume_func_t)(void); typedef void * (*vmi_init_func_t)(struct vm *vm, struct pmap *pmap); typedef int (*vmi_run_func_t)(void *vmi, int vcpu, register_t rip, struct pmap *pmap); @@ -72,6 +73,7 @@ typedef void (*vmi_vmspace_free)(struct struct vmm_ops { vmm_init_func_t init; /* module wide initialization */ vmm_cleanup_func_t cleanup; + vmm_resume_func_t resume; vmi_init_func_t vminit; /* vm-specific initialization */ vmi_run_func_t vmrun; Modified: stable/10/sys/amd64/vmm/amd/amdv.c ============================================================================== --- stable/10/sys/amd64/vmm/amd/amdv.c Wed Jan 29 20:48:26 2014 (r261274) +++ stable/10/sys/amd64/vmm/amd/amdv.c Wed Jan 29 21:23:37 2014 (r261275) @@ -53,6 +53,11 @@ amdv_cleanup(void) return (ENXIO); } +static void +amdv_resume(void) +{ +} + static void * amdv_vminit(struct vm *vm, struct pmap *pmap) { @@ -153,6 +158,7 @@ amdv_vmspace_free(struct vmspace *vmspac struct vmm_ops vmm_ops_amd = { amdv_init, amdv_cleanup, + amdv_resume, amdv_vminit, amdv_vmrun, amdv_vmcleanup, Modified: stable/10/sys/amd64/vmm/intel/vmx.c ============================================================================== --- stable/10/sys/amd64/vmm/intel/vmx.c Wed Jan 29 20:48:26 2014 (r261274) +++ stable/10/sys/amd64/vmm/intel/vmx.c Wed Jan 29 21:23:37 2014 (r261275) @@ -526,6 +526,14 @@ vmx_enable(void *arg __unused) vmxon_enabled[curcpu] = 1; } +static void +vmx_restore(void) +{ + + if (vmxon_enabled[curcpu]) + vmxon(vmxon_region[curcpu]); +} + static int vmx_init(void) { @@ -2053,6 +2061,7 @@ vmx_setcap(void *arg, int vcpu, int type struct vmm_ops vmm_ops_intel = { vmx_init, vmx_cleanup, + vmx_restore, vmx_vminit, vmx_run, vmx_vmcleanup, Modified: stable/10/sys/amd64/vmm/vmm.c ============================================================================== --- stable/10/sys/amd64/vmm/vmm.c Wed Jan 29 20:48:26 2014 (r261274) +++ stable/10/sys/amd64/vmm/vmm.c Wed Jan 29 21:23:37 2014 (r261275) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -131,6 +132,7 @@ static int vmm_initialized; static struct vmm_ops *ops; #define VMM_INIT() (ops != NULL ? (*ops->init)() : 0) #define VMM_CLEANUP() (ops != NULL ? (*ops->cleanup)() : 0) +#define VMM_RESUME() (ops != NULL ? (*ops->resume)() : 0) #define VMINIT(vm, pmap) (ops != NULL ? (*ops->vminit)(vm, pmap): NULL) #define VMRUN(vmi, vcpu, rip, pmap) \ @@ -202,6 +204,12 @@ vm_exitinfo(struct vm *vm, int cpuid) return (&vcpu->exitinfo); } +static void +vmm_resume(void) +{ + VMM_RESUME(); +} + static int vmm_init(void) { @@ -222,6 +230,7 @@ vmm_init(void) return (ENXIO); vmm_msr_init(); + vmm_resume_p = vmm_resume; return (VMM_INIT()); } @@ -242,6 +251,7 @@ vmm_handler(module_t mod, int what, void case MOD_UNLOAD: error = vmmdev_cleanup(); if (error == 0) { + vmm_resume_p = NULL; iommu_cleanup(); vmm_ipi_cleanup(); error = VMM_CLEANUP(); Modified: stable/10/sys/x86/acpica/acpi_wakeup.c ============================================================================== --- stable/10/sys/x86/acpica/acpi_wakeup.c Wed Jan 29 20:48:26 2014 (r261274) +++ stable/10/sys/x86/acpica/acpi_wakeup.c Wed Jan 29 21:23:37 2014 (r261275) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -266,6 +267,10 @@ acpi_wakeup_machdep(struct acpi_softc *s restart_cpus(suspcpus); #endif mca_resume(); +#ifdef __amd64__ + if (vmm_resume_p != NULL) + vmm_resume_p(); +#endif intr_resume(/*suspend_cancelled*/false); AcpiSetFirmwareWakingVector(0);