From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 1/4] [HYPERCALL] Add hypercalls functions Date: Sat, 25 Aug 2007 11:08:47 +0300 Message-ID: <46CFE38F.6000503@qumranet.com> References: <64F9B87B6B770947A9F8391472E032160D59004C@ehost011-8.exch011.intermedia.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Dor Laor Return-path: In-Reply-To: <64F9B87B6B770947A9F8391472E032160D59004C-yEcIvxbTEBqsx+V+t5oei8rau4O3wl8o3fe8/T/H7NteoWH0uzbU5w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org Dor Laor wrote: > The hypercalls can be called with various parameters number. > Both x86_64 and i386 are supported. > > Signed-off-by: Dor Laor > --- > include/asm-i386/hypercall.h | 142 > ++++++++++++++++++++++++++++++++++++++++ > include/asm-x86_64/hypercall.h | 105 +++++++++++++++++++++++++++++ > 2 files changed, 247 insertions(+), 0 deletions(-) > create mode 100644 include/asm-i386/hypercall.h > create mode 100644 include/asm-x86_64/hypercall.h > > diff --git a/include/asm-i386/hypercall.h b/include/asm-i386/hypercall.h > new file mode 100644 > index 0000000..40fd31e > --- /dev/null > +++ b/include/asm-i386/hypercall.h > @@ -0,0 +1,142 @@ > + > +#define CONFIG_PARAVIRT 1 > ?? > +#ifdef CONFIG_PARAVIRT > + > +/* > + * Hypercalls, according to the calling convention > + * documented in include/linux/kvm_para.h > + * > + * Copyright (C) 2007, Red Hat, Inc., Ingo Molnar > + * Copyright (C) 2007, Qumranet, Inc., Dor Laor > + * > + * This work is licensed under the terms of the GNU GPL, version 2. > See > + * the COPYING file in the top-level directory. > + */ > + > +static inline int __hypercall0(unsigned int nr) > These should be called __kvm_hypercallX() (and the file renamed as well). Linux guests support multiple hypevisors with different calling conventions. > +{ > + int ret; > + asm (" call hypercall_addr\n" > I think "asm volatile" can allow you to avoid the volatile... > + > +#define hypercall(nr_params, args...) \ > +({ \ > + /* __ret is volatile to make sure call to this \ > + * function isn't optimized away by gcc. Just \ > + * having the __hypercallN() functions mention \ > + * memory is clobbered isn't enough \ > + */ \ > + volatile int __ret; \ > + \ > + __ret = __hypercall##nr_params(args); \ > + \ > + __ret; \ > +}) > ...here. In fact the statement expression can go away. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/