From owner-svn-src-all@FreeBSD.ORG Sat Dec 27 18:13:50 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A68DB106564A for ; Sat, 27 Dec 2008 18:13:50 +0000 (UTC) (envelope-from antoine.brodin.freebsd@gmail.com) Received: from mail-bw0-f19.google.com (mail-bw0-f19.google.com [209.85.218.19]) by mx1.freebsd.org (Postfix) with ESMTP id 0442F8FC08 for ; Sat, 27 Dec 2008 18:13:49 +0000 (UTC) (envelope-from antoine.brodin.freebsd@gmail.com) Received: by bwz12 with SMTP id 12so11363934bwz.19 for ; Sat, 27 Dec 2008 10:13:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=b+4lsq6iZeMHZBoCa/Z70Bg9DkRz1ojiDJ/CYzIb6PI=; b=CkeOmkSMgxGHfYhV7CaFdnzPHNHURmjMRgFqhCfI2a2pESwothjRVXJ1f/d8ABbCQd LztQWsAFb94OEJLTSLnt0fII/BhmbTZPYZTu1NO61AO2XKSRFORGmWutpNP2FSZogN/y NHkJ3+w3I0LEXjNhfmFbcTrzTZE80+UYMQ7ys= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=dNq2sAdmIVlvItDdM34jsCGnzDn+RKtsC7a4GGUq8GjJieBw8d+cxMLjVX+9GbukOm s/eAInKEZLAmOVqVzoI0QMK+1qE80dKu7fgqISeOM3Z5SYZPBiggsw3Q9RI803mR13uq d0nkLJUCFAAy4WjNWe1YgV+Sox0FW3sf17mDQ= Received: by 10.181.137.13 with SMTP id p13mr4458129bkn.173.1230399745555; Sat, 27 Dec 2008 09:42:25 -0800 (PST) Received: by 10.181.9.17 with HTTP; Sat, 27 Dec 2008 09:42:25 -0800 (PST) Message-ID: Date: Sat, 27 Dec 2008 18:42:25 +0100 From: "Antoine Brodin" Sender: antoine.brodin.freebsd@gmail.com To: "Ivan Voras" In-Reply-To: <200812171957.mBHJvCO2013765@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200812171957.mBHJvCO2013765@svn.freebsd.org> X-Google-Sender-Auth: 4a9c7a3168978fbf Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r186252 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Dec 2008 18:13:50 -0000 On Wed, Dec 17, 2008 at 8:57 PM, Ivan Voras wrote: > Author: ivoras > Date: Wed Dec 17 19:57:12 2008 > New Revision: 186252 > URL: http://svn.freebsd.org/changeset/base/186252 > > Log: > Introduce a sysctl kern.vm_guest that reflects what the kernel knows about > it running under a virtual environment. This also introduces a globally > accessible variable vm_guest that can be used where appropriate in the > kernel to inspect this environment. > > To make it easier for the long run, an enum VM_GUEST is also introduced, > which could possibly be factored out in a header somewhere (but the > question is where - vm/vm_param.h? sys/param.h?) so it eventually becomes > a part of the standard KPI. In any case, it's a start. > > The purpose of all this isn't to absolutely detect that the OS is running > under a virtual environment (cf. "redpill") but to allow the parts of the > kernel and the userland that care about this particular aspect and can do > something useful depending on it to have a standardised interface. Reducing > kern.hz is one example but there are other things that could be done like > avoiding context switches, not using CPU instructions that are known to be > slow in emulation, possibly different strategies in VM (memory) allocation, > CPU scheduling, etc. > > It isn't clear if the JAILS/VIMAGE functionality should also be exposed > by this particular mechanism (probably not since they're not "full" > virtual hardware environments). Sometime in the future another sysctl and > a variable could be introduced to reflect if the kernel supports any kind > of virtual hosting (e.g. VMWare VMI, Xen dom0). > > Reviewed by: silence from src-commiters@, virtualization@, kmacy@ > Approved by: gnn (mentor) > Security: Obscurity doesn't help. > > Modified: > head/sys/kern/subr_param.c > > Modified: head/sys/kern/subr_param.c [snip] > +enum VM_GUEST { VM_GUEST_NO, VM_GUEST_VM, VM_GUEST_XEN }; > + [snip] > - hz = detect_virtual() ? HZ_VM : HZ; > + hz = vm_guest > VM_GUEST_NO ? HZ_VM : HZ; [snip] Hi Ivan, Could you change VM_GUEST_NO / VM_GUEST_VM / VM_GUEST_XEN to a #define or explicitly initialize them? The magnitude comparison between vm_guest and VM_GUEST_NO looks like gratuitous obfuscation. Cheers, Antoine