Re: [kvm-devel] [PATCH 1/4] [HYPERCALL] Add hypercalls functions

2007-08-29 Thread Dor Laor

 +asm ( call hypercall_addr\n

Hi Dor,

This cannot work, because hypercall_addr is currently not defined in
todays
kvm.git:

The definition is inside kvm_pv.c which was in the next patchset, I'll 
join them in the next series. [Although Anthony L. has a different
method that
might catch.


# grep -R hypercall_addr *
drivers/kvm/kvm.h:unsigned char *hypercall_addr);
#

IIRC there was a definition of hypercall_addr in the older paravirt
drivers
from the rt-kernel. It seems it did not make it into this patch set.


I think the origin was the same (Ingo Molnar).

Christian

-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 1/4] [HYPERCALL] Add hypercalls functions

2007-08-29 Thread Dor Laor
 +static inline int
 +__hypercall2(unsigned int nr, unsigned long p1, unsigned long p2)
 +{
 +int ret;
 +asm ( call hypercall_addr\n
[...]
 +return ret;

Hello Dor,

Linux system calls return long. I think hypercalls should behave in a
similar
manner and return long as well, no?

Logical, will be incorporated to the next patch set release.
Thanks, Dor.


Christian


-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 1/4] [HYPERCALL] Add hypercalls functions

2007-08-29 Thread Dor Laor
 The hypercalls can be called with various parameters number.
 Both x86_64 and i386 are supported.

 Signed-off-by: Dor Laor [EMAIL PROTECTED]
 ---
 +static inline int
 +__hypercall6(unsigned int nr, unsigned long p1, unsigned long p2,
 + unsigned long p3, unsigned long p4, unsigned long p5,
 + unsigned long p6)
 +{
 +int ret;
 +asm ( call hypercall_addr\n
 +: =a (ret)
 +: b (nr),
 +  a (p1),
 +  c (p2),
 +  d (p3),
 +  S (p4),
 +  D (p5),
 +  bp (p6)
 +: memory, cc
 +);
 +return ret;
 +}
 +
 +#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;  \
 +})

A couple things are different in my patchset.  I didn't do this
hypercall macro.  I tried it at first but IMHO it was pretty ugly.  It

It will also simplify the call to the hypercall, instead of
hypercall(X,TYPE,...) hypercallX(Type,...)
Will be changed in the next drop.

makes things less readable to me.  The second thing is I only have up
to
4 parameters to a hypercall.  That leaves some GP registers on 32-bit
and Xen seems to be happily using 4 registers so I don't think there's
anything we can't express without the extra 2.


Agreed, actually the x86_64 has only 4 parameters too.
Thanks,
Dor.

-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 1/4] [HYPERCALL] Add hypercalls functions

2007-08-27 Thread Christian Borntraeger
Am Samstag, 25. August 2007 schrieb Dor Laor:
 + asm ( call hypercall_addr\n

Hi Dor,

This cannot work, because hypercall_addr is currently not defined in todays 
kvm.git:

# grep -R hypercall_addr *
drivers/kvm/kvm.h:unsigned char *hypercall_addr);
#

IIRC there was a definition of hypercall_addr in the older paravirt drivers 
from the rt-kernel. It seems it did not make it into this patch set.

Christian

-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 1/4] [HYPERCALL] Add hypercalls functions

2007-08-27 Thread Anthony Liguori
On Fri, 2007-08-24 at 16:57 -0700, Dor Laor wrote:
 The hypercalls can be called with various parameters number.
 Both x86_64 and i386 are supported.
 
 Signed-off-by: Dor Laor [EMAIL PROTECTED]
 ---
 +static inline int
 +__hypercall6(unsigned int nr, unsigned long p1, unsigned long p2,
 +  unsigned long p3, unsigned long p4, unsigned long p5,
 +  unsigned long p6)
 +{
 + int ret;
 + asm ( call hypercall_addr\n
 + : =a (ret)
 + : b (nr),
 +   a (p1),
 +   c (p2),
 +   d (p3),
 +   S (p4),
 +   D (p5),
 +   bp (p6)
 + : memory, cc
 + );
 + return ret;
 +}
 +
 +#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;  \
 +})

A couple things are different in my patchset.  I didn't do this
hypercall macro.  I tried it at first but IMHO it was pretty ugly.  It
makes things less readable to me.  The second thing is I only have up to
4 parameters to a hypercall.  That leaves some GP registers on 32-bit
and Xen seems to be happily using 4 registers so I don't think there's
anything we can't express without the extra 2.

Regards,

Anthony Liguori


-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 1/4] [HYPERCALL] Add hypercalls functions

2007-08-25 Thread Avi Kivity
Dor Laor wrote:
 The hypercalls can be called with various parameters number.
 Both x86_64 and i386 are supported.

 Signed-off-by: Dor Laor [EMAIL PROTECTED]
 ---
  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 000..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 [EMAIL PROTECTED]
 + * Copyright (C) 2007, Qumranet, Inc., Dor Laor [EMAIL PROTECTED]
 + *
 + * 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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel