[Top] [All Lists]

Re: [PATCH v2 09/13] MIPS: Add functions for hypervisor call

To: Andreas Herrmann <>, Ralf Baechle <>, "Pinski, Andrew" <>
Subject: Re: [PATCH v2 09/13] MIPS: Add functions for hypervisor call
From: David Daney <>
Date: Tue, 3 Jun 2014 09:40:01 -0700
Authentication-results: spf=none (sender IP is );
Cc: <>, David Daney <>, "James Hogan" <>, <>, David Daney <>
In-reply-to: <20140603150337.GA28045@alberich>
List-archive: <>
List-help: <>
List-id: linux-mips <>
List-owner: <>
List-post: <>
List-software: Ecartis version 1.0.0
List-subscribe: <>
List-unsubscribe: <>
Original-recipient: rfc822;
References: <> <> <> <20140603150337.GA28045@alberich>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
In cases like this, I always wonder WWPD (What Would Pinski Do)...

Let's get him to opine.

Andrew, the patch in question is:

David Daney

On 06/03/2014 08:03 AM, Andreas Herrmann wrote:
On Tue, Jun 03, 2014 at 10:30:31AM +0200, Ralf Baechle wrote:
On Wed, May 28, 2014 at 11:52:12PM +0200, Andreas Herrmann wrote:

+ * Hypercalls for KVM.
+ *
+ * Hypercall number is passed in v0.
+ * Return value will be placed in v0.
+ * Up to 3 arguments are passed in a0, a1, and a2.
+ */
+static inline unsigned long kvm_hypercall0(unsigned long num)
+       register unsigned long n asm("v0");
+       register unsigned long r asm("v0");

Btw, is it safe to put two variables in the same register?

I think it's safe.

If we would have a matching constraint letter (say "v" for register v0) the
asm should translate to

         __asm__ __volatile__(
                 : "=v" (n) : "v" (r) : "memory"

which isn't unusual on other archs. (Or maybe I am just biased from
x86 ... or missed something else.)

The syscall wrappers that used to be in <asm/unistd.h> were occasionally
hitting problems which eventually forced me to stop forcing variables
into particular registers instead using a MOVE instruction to shove
each variable into the right place.

Of course they were being used from non-PIC and PIC code, kernel and userland
so GCC had a much better chance to do evil than in the hypercall wrapper
case - but it made me paranoid ...


<Prev in Thread] Current Thread [Next in Thread>