Re: [kvm-devel] [RFC/PATCH 14/15] guest: detect when running on kvm

2008-03-22 Thread Heiko Carstens
On Fri, Mar 21, 2008 at 03:33:29PM +0100, Carsten Otte wrote:
> Am Freitag, den 21.03.2008, 15:06 +0100 schrieb Heiko Carstens:
> > Just introduce something like MACHINE_FLAG_KVM. The rest can be converted
> > later. Unless you're bored and feel like fiddling around with assembly code 
> > :)
> I've done that patch this morning already, see below. I agree with HCH
> that we should do that, but after the kvm merge. I don't want kvm-s390
> conflict with Martin's patches. This is just a beautification, and can
> safely wait a release cycle.

That's nice for a start. But you didn't convert the assembly files to use
the new defines. So there is still no connection between setting a bit
in asm code and the new defines.
That's the reason why I said something about fiddling around with asm code.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC/PATCH 14/15] guest: detect when running on kvm

2008-03-21 Thread Carsten Otte
Am Freitag, den 21.03.2008, 15:06 +0100 schrieb Heiko Carstens:
> Just introduce something like MACHINE_FLAG_KVM. The rest can be converted
> later. Unless you're bored and feel like fiddling around with assembly code :)
I've done that patch this morning already, see below. I agree with HCH
that we should do that, but after the kvm merge. I don't want kvm-s390
conflict with Martin's patches. This is just a beautification, and can
safely wait a release cycle.
---
 arch/s390/kernel/early.c |6 +++---
 include/asm-s390/setup.h |   32 ++--
 2 files changed, 25 insertions(+), 13 deletions(-)

Index: linux-host/arch/s390/kernel/early.c
===
--- linux-host.orig/arch/s390/kernel/early.c
+++ linux-host/arch/s390/kernel/early.c
@@ -138,15 +138,15 @@ static noinline __init void detect_machi
 
/* Running under z/VM ? */
if (cpuinfo->cpu_id.version == 0xff)
-   machine_flags |= 1;
+   machine_flags |= MACHINE_FLAG_VM;
 
/* Running on a P/390 ? */
if (cpuinfo->cpu_id.machine == 0x7490)
-   machine_flags |= 4;
+   machine_flags |= MACHINE_FLAG_P390;
 
/* Running under KVM ? */
if (cpuinfo->cpu_id.version == 0xfe)
-   machine_flags |= 64;
+   machine_flags |= MACHINE_FLAG_KVM;
 }
 
 #ifdef CONFIG_64BIT
Index: linux-host/include/asm-s390/setup.h
===
--- linux-host.orig/include/asm-s390/setup.h
+++ linux-host/include/asm-s390/setup.h
@@ -59,23 +59,35 @@ extern unsigned int s390_noexec;
  */
 extern unsigned long machine_flags;
 
-#define MACHINE_IS_VM  (machine_flags & 1)
-#define MACHINE_IS_P390(machine_flags & 4)
-#define MACHINE_HAS_MVPG   (machine_flags & 16)
-#define MACHINE_IS_KVM (machine_flags & 64)
-#define MACHINE_HAS_IDTE   (machine_flags & 128)
-#define MACHINE_HAS_DIAG9C (machine_flags & 256)
+#define MACHINE_FLAG_VM1
+#define MACHINE_FLAG_IEEE  2
+#define MACHINE_FLAG_P390  4
+#define MACHINE_FLAG_CSP   8
+#define MACHINE_FLAG_MVPG  16
+#define MACHINE_FLAG_DIAG4432
+#define MACHINE_FLAG_KVM   64
+#define MACHINE_FLAG_IDTE  128
+#define MACHINE_FLAG_DIAG9C256
+#define MACHINE_FLAG_MVCOS 512
+
+
+#define MACHINE_IS_VM  (machine_flags & MACHINE_FLAG_VM)
+#define MACHINE_IS_KVM (machine_flags & MACHINE_FLAG_KVM)
+#define MACHINE_IS_P390(machine_flags & MACHINE_FLAG_P390)
+#define MACHINE_HAS_MVPG   (machine_flags & MACHINE_FLAG_MVPG)
+#define MACHINE_HAS_IDTE   (machine_flags & MACHINE_FLAG_IDTE)
+#define MACHINE_HAS_DIAG9C (machine_flags & MACHINE_FLAG_DIAG9C)
 
 #ifndef __s390x__
-#define MACHINE_HAS_IEEE   (machine_flags & 2)
-#define MACHINE_HAS_CSP(machine_flags & 8)
+#define MACHINE_HAS_IEEE   (machine_flags & MACHINE_FLAG_IEEE)
+#define MACHINE_HAS_CSP(machine_flags & MACHINE_FLAG_CSP)
 #define MACHINE_HAS_DIAG44 (1)
 #define MACHINE_HAS_MVCOS  (0)
 #else /* __s390x__ */
 #define MACHINE_HAS_IEEE   (1)
 #define MACHINE_HAS_CSP(1)
-#define MACHINE_HAS_DIAG44 (machine_flags & 32)
-#define MACHINE_HAS_MVCOS  (machine_flags & 512)
+#define MACHINE_HAS_DIAG44 (machine_flags & MACHINE_FLAG_DIAG44)
+#define MACHINE_HAS_MVCOS  (machine_flags & MACHINE_FLAG_MVCOS)
 #endif /* __s390x__ */
 
 #define MACHINE_HAS_SCLP   (!MACHINE_IS_P390)



-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC/PATCH 14/15] guest: detect when running on kvm

2008-03-21 Thread Heiko Carstens
On Fri, Mar 21, 2008 at 12:12:04PM +0100, Carsten Otte wrote:
> [EMAIL PROTECTED] wrote:
>> Since when do we have symbolic names for the bits?
>> It was always on my todo list to do a cleanup and replace the numbers
>> we use everywhere with names. Especially since we have clashes from time
>> to time... but that didn't hurt enough yet, obviously.
>> But now that you volunteered to take care of this... :)
> Right. We only have defines for (machine_flags & bit). Looks to me like 
> the bits really should have a name on them. I've created a patch that 
> does this, but I want to talk it over with Martin before sending that one 
> out.

Just introduce something like MACHINE_FLAG_KVM. The rest can be converted
later. Unless you're bored and feel like fiddling around with assembly code :)

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC/PATCH 14/15] guest: detect when running on kvm

2008-03-21 Thread Carsten Otte
[EMAIL PROTECTED] wrote:
> Since when do we have symbolic names for the bits?
> It was always on my todo list to do a cleanup and replace the numbers
> we use everywhere with names. Especially since we have clashes from time
> to time... but that didn't hurt enough yet, obviously.
> But now that you volunteered to take care of this... :)
Right. We only have defines for (machine_flags & bit). Looks to me 
like the bits really should have a name on them. I've created a patch 
that does this, but I want to talk it over with Martin before sending 
that one out.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC/PATCH 14/15] guest: detect when running on kvm

2008-03-20 Thread Heiko Carstens
On Thu, Mar 20, 2008 at 09:59:32PM +0100, Carsten Otte wrote:
> Christoph Hellwig wrote:
> > On Thu, Mar 20, 2008 at 09:37:19PM +0100, Carsten Otte wrote:
> >> Christoph Hellwig wrote:
> >>> On Thu, Mar 20, 2008 at 05:25:26PM +0100, Carsten Otte wrote:
>  @@ -143,6 +143,10 @@ static noinline __init void detect_machi
>   /* Running on a P/390 ? */
>   if (cpuinfo->cpu_id.machine == 0x7490)
>   machine_flags |= 4;
>  +
>  +/* Running under KVM ? */
>  +if (cpuinfo->cpu_id.version == 0xfe)
>  +machine_flags |= 64;
> >>> Shouldn't these have symbolic names?
> >> You mean symbolics for machine_flags? Or symbolics for cpu ids?
> > 
> > Either.
> [...]
> The machine flags do have symbolic names, defined in 
> include/asm-s390/setup.h. And yea, they should be used here. Will 
> change that.

Since when do we have symbolic names for the bits?
It was always on my todo list to do a cleanup and replace the numbers
we use everywhere with names. Especially since we have clashes from time
to time... but that didn't hurt enough yet, obviously.
But now that you volunteered to take care of this... :)

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC/PATCH 14/15] guest: detect when running on kvm

2008-03-20 Thread Carsten Otte
Christoph Hellwig wrote:
> On Thu, Mar 20, 2008 at 09:37:19PM +0100, Carsten Otte wrote:
>> Christoph Hellwig wrote:
>>> On Thu, Mar 20, 2008 at 05:25:26PM +0100, Carsten Otte wrote:
 @@ -143,6 +143,10 @@ static noinline __init void detect_machi
/* Running on a P/390 ? */
if (cpuinfo->cpu_id.machine == 0x7490)
machine_flags |= 4;
 +
 +  /* Running under KVM ? */
 +  if (cpuinfo->cpu_id.version == 0xfe)
 +  machine_flags |= 64;
>>> Shouldn't these have symbolic names?
>> You mean symbolics for machine_flags? Or symbolics for cpu ids?
> 
> Either.
Hmmh. For cpu id's did'nt make sense probably until now that kvm also 
uses them. Before, this was the only one place that uses them.

With kvm and 0xfe, this one is sort of temporary one. We intend to 
rework this code to use "store system information", which would give 
us way more information about the machine and it's hypervisor 
topology. Up until my todo list gets to that point, I think we'll have 
to cope with a temporary number. We'll aim for making that change 
before 2.6.26 gets released.

The machine flags do have symbolic names, defined in 
include/asm-s390/setup.h. And yea, they should be used here. Will 
change that.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC/PATCH 14/15] guest: detect when running on kvm

2008-03-20 Thread Christoph Hellwig
On Thu, Mar 20, 2008 at 09:37:19PM +0100, Carsten Otte wrote:
> Christoph Hellwig wrote:
>> On Thu, Mar 20, 2008 at 05:25:26PM +0100, Carsten Otte wrote:
>>> @@ -143,6 +143,10 @@ static noinline __init void detect_machi
>>> /* Running on a P/390 ? */
>>> if (cpuinfo->cpu_id.machine == 0x7490)
>>> machine_flags |= 4;
>>> +
>>> +   /* Running under KVM ? */
>>> +   if (cpuinfo->cpu_id.version == 0xfe)
>>> +   machine_flags |= 64;
>>
>> Shouldn't these have symbolic names?
> You mean symbolics for machine_flags? Or symbolics for cpu ids?

Either.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC/PATCH 14/15] guest: detect when running on kvm

2008-03-20 Thread Carsten Otte
Christoph Hellwig wrote:
> On Thu, Mar 20, 2008 at 05:25:26PM +0100, Carsten Otte wrote:
>> @@ -143,6 +143,10 @@ static noinline __init void detect_machi
>>  /* Running on a P/390 ? */
>>  if (cpuinfo->cpu_id.machine == 0x7490)
>>  machine_flags |= 4;
>> +
>> +/* Running under KVM ? */
>> +if (cpuinfo->cpu_id.version == 0xfe)
>> +machine_flags |= 64;
> 
> Shouldn't these have symbolic names?
You mean symbolics for machine_flags? Or symbolics for cpu ids?

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC/PATCH 14/15] guest: detect when running on kvm

2008-03-20 Thread Christoph Hellwig
On Thu, Mar 20, 2008 at 05:25:26PM +0100, Carsten Otte wrote:
> @@ -143,6 +143,10 @@ static noinline __init void detect_machi
>   /* Running on a P/390 ? */
>   if (cpuinfo->cpu_id.machine == 0x7490)
>   machine_flags |= 4;
> +
> + /* Running under KVM ? */
> + if (cpuinfo->cpu_id.version == 0xfe)
> + machine_flags |= 64;

Shouldn't these have symbolic names?


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC/PATCH 14/15] guest: detect when running on kvm

2008-03-20 Thread Carsten Otte
Randy Dunlap wrote:
>> Index: kvm/arch/s390/kernel/early.c
>> ===
>> --- kvm.orig/arch/s390/kernel/early.c
>> +++ kvm/arch/s390/kernel/early.c
>> @@ -143,6 +143,10 @@ static noinline __init void detect_machi
>>  /* Running on a P/390 ? */
>>  if (cpuinfo->cpu_id.machine == 0x7490)
>>  machine_flags |= 4;
>> +
>> +/* Running under KVM ? */
>> +if (cpuinfo->cpu_id.version == 0xfe)
> 
> Hi,
> 
> Where are these magic numbers documented?  (0x7490, 0xfe, etc.)
> 
> 
>> +machine_flags |= 64;
>>  }
>>  
>>  #ifdef CONFIG_64BIT
The cpuid (and most other things about s390 arch) are documented in 
the principles of operation:
http://publibz.boulder.ibm.com/epubs/pdf/a2278324.pdf
http://publibz.boulder.ibm.com/epubs/pdf/dz9zs001.pdf

(see chapter "control instructions" - store cpu id)

The 0xfe however is convention, the kvm arch code sets this value 
where it implements that instruction. See "privileged instructions" patch.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC/PATCH 14/15] guest: detect when running on kvm

2008-03-20 Thread Randy Dunlap
On Thu, 20 Mar 2008 17:25:26 +0100 Carsten Otte wrote:

> From: Christian Borntraeger <[EMAIL PROTECTED]>
> From: Carsten Otte <[EMAIL PROTECTED]>
> 
> This patch adds functionality to detect if the kernel runs under the KVM
> hypervisor. A macro MACHINE_IS_KVM is exported for device drivers. This
> allows drivers to skip device detection if the systems runs non-virtualized.
> We also define a preferred console to avoid having the ttyS0, which is a line
> mode only console.
> 
> Signed-off-by: Christian Borntraeger <[EMAIL PROTECTED]>
> Acked-by: Martin Schwidefsky <[EMAIL PROTECTED]>
> Signed-off-by: Carsten Otte <[EMAIL PROTECTED]>
> ---
>  arch/s390/Kconfig|7 +++
>  arch/s390/kernel/early.c |4 
>  arch/s390/kernel/setup.c |   10 +++---
>  include/asm-s390/setup.h |1 +
>  4 files changed, 19 insertions(+), 3 deletions(-)
> 
> Index: kvm/arch/s390/kernel/early.c
> ===
> --- kvm.orig/arch/s390/kernel/early.c
> +++ kvm/arch/s390/kernel/early.c
> @@ -143,6 +143,10 @@ static noinline __init void detect_machi
>   /* Running on a P/390 ? */
>   if (cpuinfo->cpu_id.machine == 0x7490)
>   machine_flags |= 4;
> +
> + /* Running under KVM ? */
> + if (cpuinfo->cpu_id.version == 0xfe)

Hi,

Where are these magic numbers documented?  (0x7490, 0xfe, etc.)


> + machine_flags |= 64;
>  }
>  
>  #ifdef CONFIG_64BIT

---
~Randy

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel