From owner-svn-src-head@FreeBSD.ORG Thu Mar 20 18:15:39 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D9C83C34; Thu, 20 Mar 2014 18:15:38 +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 B658CB86; Thu, 20 Mar 2014 18:15:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2KIFc9S054901; Thu, 20 Mar 2014 18:15:38 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2KIFcMP054896; Thu, 20 Mar 2014 18:15:38 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <201403201815.s2KIFcMP054896@svn.freebsd.org> From: Neel Natu Date: Thu, 20 Mar 2014 18:15:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r263432 - head/usr.sbin/bhyve X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Mar 2014 18:15:39 -0000 Author: neel Date: Thu Mar 20 18:15:37 2014 New Revision: 263432 URL: http://svnweb.freebsd.org/changeset/base/263432 Log: Use 'cpuset_t' to represent the vcpus active in a virtual machine. Modified: head/usr.sbin/bhyve/bhyverun.c head/usr.sbin/bhyve/bhyverun.h head/usr.sbin/bhyve/spinup_ap.c Modified: head/usr.sbin/bhyve/bhyverun.c ============================================================================== --- head/usr.sbin/bhyve/bhyverun.c Thu Mar 20 17:53:56 2014 (r263431) +++ head/usr.sbin/bhyve/bhyverun.c Thu Mar 20 18:15:37 2014 (r263432) @@ -98,7 +98,7 @@ static int acpi; static char *progname; static const int BSP = 0; -static int cpumask; +static cpuset_t cpumask; static void vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip); @@ -199,30 +199,26 @@ fbsdrun_start_thread(void *param) } void -fbsdrun_addcpu(struct vmctx *ctx, int vcpu, uint64_t rip) +fbsdrun_addcpu(struct vmctx *ctx, int fromcpu, int newcpu, uint64_t rip) { int error; - if (cpumask & (1 << vcpu)) { - fprintf(stderr, "addcpu: attempting to add existing cpu %d\n", - vcpu); - exit(1); - } + assert(fromcpu == BSP); - atomic_set_int(&cpumask, 1 << vcpu); + CPU_SET_ATOMIC(newcpu, &cpumask); /* * Set up the vmexit struct to allow execution to start * at the given RIP */ - vmexit[vcpu].rip = rip; - vmexit[vcpu].inst_length = 0; + vmexit[newcpu].rip = rip; + vmexit[newcpu].inst_length = 0; - mt_vmm_info[vcpu].mt_ctx = ctx; - mt_vmm_info[vcpu].mt_vcpu = vcpu; + mt_vmm_info[newcpu].mt_ctx = ctx; + mt_vmm_info[newcpu].mt_vcpu = newcpu; - error = pthread_create(&mt_vmm_info[vcpu].mt_thr, NULL, - fbsdrun_start_thread, &mt_vmm_info[vcpu]); + error = pthread_create(&mt_vmm_info[newcpu].mt_thr, NULL, + fbsdrun_start_thread, &mt_vmm_info[newcpu]); assert(error == 0); } @@ -230,14 +226,14 @@ static int fbsdrun_deletecpu(struct vmctx *ctx, int vcpu) { - if ((cpumask & (1 << vcpu)) == 0) { + if (!CPU_ISSET(vcpu, &cpumask)) { fprintf(stderr, "addcpu: attempting to delete unknown cpu %d\n", vcpu); exit(1); } - atomic_clear_int(&cpumask, 1 << vcpu); - return (cpumask == 0); + CPU_CLR_ATOMIC(vcpu, &cpumask); + return (CPU_EMPTY(&cpumask)); } static int @@ -745,7 +741,7 @@ main(int argc, char *argv[]) /* * Add CPU 0 */ - fbsdrun_addcpu(ctx, BSP, rip); + fbsdrun_addcpu(ctx, BSP, BSP, rip); /* * Head off to the main event dispatch loop Modified: head/usr.sbin/bhyve/bhyverun.h ============================================================================== --- head/usr.sbin/bhyve/bhyverun.h Thu Mar 20 17:53:56 2014 (r263431) +++ head/usr.sbin/bhyve/bhyverun.h Thu Mar 20 18:15:37 2014 (r263432) @@ -43,7 +43,7 @@ extern char *vmname; void *paddr_guest2host(struct vmctx *ctx, uintptr_t addr, size_t len); void fbsdrun_set_capabilities(struct vmctx *ctx, int cpu); -void fbsdrun_addcpu(struct vmctx *ctx, int cpu, uint64_t rip); +void fbsdrun_addcpu(struct vmctx *ctx, int fromcpu, int newcpu, uint64_t rip); int fbsdrun_muxed(void); int fbsdrun_vmexit_on_hlt(void); int fbsdrun_vmexit_on_pause(void); Modified: head/usr.sbin/bhyve/spinup_ap.c ============================================================================== --- head/usr.sbin/bhyve/spinup_ap.c Thu Mar 20 17:53:56 2014 (r263431) +++ head/usr.sbin/bhyve/spinup_ap.c Thu Mar 20 18:15:37 2014 (r263432) @@ -98,7 +98,7 @@ spinup_ap(struct vmctx *ctx, int vcpu, i spinup_ap_realmode(ctx, newcpu, &rip); - fbsdrun_addcpu(ctx, newcpu, rip); + fbsdrun_addcpu(ctx, vcpu, newcpu, rip); return (newcpu); }