Re: [kvm-unit-tests PATCH 08/18] run_tests: pass test name to run script

2015-11-10 Thread Paolo Bonzini


On 06/11/2015 01:24, Andrew Jones wrote:
> With this $TEST_DIR/run can output test specific error messages.
> 
> Signed-off-by: Andrew Jones 
> ---
>  run_tests.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/run_tests.sh b/run_tests.sh
> index ebb7e9fe6fdfc..80b87823c3358 100755
> --- a/run_tests.sh
> +++ b/run_tests.sh
> @@ -46,7 +46,7 @@ function run()
>  fi
>  done
>  
> -cmdline="./$TEST_DIR-run $kernel -smp $smp $opts"
> +cmdline="TESTNAME=$testname ./$TEST_DIR-run $kernel -smp $smp $opts"
>  if [ $verbose != 0 ]; then
>  echo $cmdline
>  fi
> 

Applied, thanks.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[kvm-unit-tests PATCH 08/18] run_tests: pass test name to run script

2015-11-05 Thread Andrew Jones
With this $TEST_DIR/run can output test specific error messages.

Signed-off-by: Andrew Jones 
---
 run_tests.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/run_tests.sh b/run_tests.sh
index ebb7e9fe6fdfc..80b87823c3358 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -46,7 +46,7 @@ function run()
 fi
 done
 
-cmdline="./$TEST_DIR-run $kernel -smp $smp $opts"
+cmdline="TESTNAME=$testname ./$TEST_DIR-run $kernel -smp $smp $opts"
 if [ $verbose != 0 ]; then
 echo $cmdline
 fi
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[kvm-unit-tests PATCH 05/11] run_tests: pass test name to run script

2015-09-10 Thread Andrew Jones
With this $TEST_DIR/run can output test specific error messages.

Signed-off-by: Andrew Jones 
---
 run_tests.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/run_tests.sh b/run_tests.sh
index ebb7e9fe6fdfc..80b87823c3358 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -46,7 +46,7 @@ function run()
 fi
 done
 
-cmdline="./$TEST_DIR-run $kernel -smp $smp $opts"
+cmdline="TESTNAME=$testname ./$TEST_DIR-run $kernel -smp $smp $opts"
 if [ $verbose != 0 ]; then
 echo $cmdline
 fi
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[kvm-unit-tests PATCH 2/3] run_tests: pass test name to run script

2015-08-04 Thread Andrew Jones
With this $TEST_DIR/run can output test specific error messages.

Signed-off-by: Andrew Jones 
---
 run_tests.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/run_tests.sh b/run_tests.sh
index ebb7e9fe6fdfc..80b87823c3358 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -46,7 +46,7 @@ function run()
 fi
 done
 
-cmdline="./$TEST_DIR-run $kernel -smp $smp $opts"
+cmdline="TESTNAME=$testname ./$TEST_DIR-run $kernel -smp $smp $opts"
 if [ $verbose != 0 ]; then
 echo $cmdline
 fi
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[kvm-unit-tests PATCH 2/3] run_tests: pass test name to run script

2015-08-03 Thread Andrew Jones
With this $TEST_DIR/run can output test specific error messages.

Signed-off-by: Andrew Jones 
---
 run_tests.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/run_tests.sh b/run_tests.sh
index ebb7e9fe6fdfc..80b87823c3358 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -46,7 +46,7 @@ function run()
 fi
 done
 
-cmdline="./$TEST_DIR-run $kernel -smp $smp $opts"
+cmdline="TESTNAME=$testname ./$TEST_DIR-run $kernel -smp $smp $opts"
 if [ $verbose != 0 ]; then
 echo $cmdline
 fi
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 02/17] Add accelerator id and model name to CPUState

2015-04-13 Thread Michael Mueller
The patch defines ids per accelerator and adds the accel_id and
the model_name to the CPUState. The accel_id is initialized by
common code, the model name needs to be initialized by target
specific code.

Signed-off-by: Michael Mueller 
---
 include/qom/cpu.h |  5 +
 qapi-schema.json  |  9 +
 qom/cpu.c | 14 ++
 3 files changed, 28 insertions(+)

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 9dafb48..4ffc050 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -236,6 +236,8 @@ struct kvm_run;
  * @mem_io_pc: Host Program Counter at which the memory was accessed.
  * @mem_io_vaddr: Target virtual address at which the memory was accessed.
  * @kvm_fd: vCPU file descriptor for KVM.
+ * @accel_id: accelerator id of this CPU.
+ * @model_name: model name of this CPU
  *
  * State of one CPU core or thread.
  */
@@ -313,6 +315,9 @@ struct CPUState {
(absolute value) offset as small as possible.  This reduces code
size, especially for hosts without large memory offsets.  */
 volatile sig_atomic_t tcg_exit_req;
+
+AccelId accel_id;
+char *model_name;
 };
 
 QTAILQ_HEAD(CPUTailQ, CPUState);
diff --git a/qapi-schema.json b/qapi-schema.json
index ac9594d..540e520 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2515,6 +2515,15 @@
 ##
 { 'command': 'query-machines', 'returns': ['MachineInfo'] }
 
+# @AccelId
+#
+# Defines accelerator ids
+#
+# Since: 2.4
+##
+{ 'enum': 'AccelId',
+  'data': ['qtest', 'tcg', 'kvm', 'xen'] }
+
 ##
 # @CpuDefinitionInfo:
 #
diff --git a/qom/cpu.c b/qom/cpu.c
index 108bfa2..457afc7 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -67,6 +67,20 @@ CPUState *cpu_generic_init(const char *typename, const char 
*cpu_model)
 goto out;
 }
 
+if (tcg_enabled()) {
+cpu->accel_id = ACCEL_ID_TCG;
+} else if (kvm_enabled()) {
+cpu->accel_id = ACCEL_ID_KVM;
+}
+#ifdef CONFIG_XEN
+else if (xen_enabled()) {
+cpu->accel_id = ACCEL_ID_XEN;
+}
+#endif
+else {
+cpu->accel_id = ACCEL_ID_QTEST;
+}
+
 object_property_set_bool(OBJECT(cpu), true, "realized", &err);
 
 out:
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 14/17] target-s390x: Initialize S390 CPU model name in CPUState

2015-04-13 Thread Michael Mueller
The cpu model name now gets initialized during CPU instance
initialization.

Signed-off-by: Michael Mueller 
---
 target-s390x/cpu.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 65dee3e..771acbd 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -207,6 +207,7 @@ static void s390_cpu_initfn(Object *obj)
 struct tm tm;
 #endif
 
+cs->model_name = strdup_cpu_name(S390_CPU_GET_CLASS(cs));
 cs->env_ptr = env;
 cpu_exec_init(env);
 #if !defined(CONFIG_USER_ONLY)
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 03/17] Extend QMP command query-cpus to return accelerator id and model name

2015-04-13 Thread Michael Mueller
The QMP command query-cpus now additionally displays a model name and
the backing accelerator. Both are omitted if the model name is not
initialized.

  request:
{ "execute" : "query-cpus" }

  answer:
{ { "current": true,
"CPU": 0,
"model": "2827-ga2",
"halted": false,
"accel": "kvm",
"thread_id": 31917
  }, ... }

Signed-off-by: Michael Mueller 
---
 cpus.c   | 4 
 qapi-schema.json | 7 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/cpus.c b/cpus.c
index e6dcae3..00f33b9 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1436,6 +1436,10 @@ CpuInfoList *qmp_query_cpus(Error **errp)
 info->value->current = (cpu == first_cpu);
 info->value->halted = cpu->halted;
 info->value->thread_id = cpu->thread_id;
+info->value->model = g_strdup(cpu->model_name);
+info->value->accel = cpu->accel_id;
+info->value->has_model = info->value->has_accel =
+info->value->model != NULL;
 #if defined(TARGET_I386)
 info->value->has_pc = true;
 info->value->pc = env->eip + env->segs[R_CS].base;
diff --git a/qapi-schema.json b/qapi-schema.json
index 540e520..215a7bc 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -616,6 +616,10 @@
 #
 # @thread_id: ID of the underlying host thread
 #
+# @accel: #optional accelerator id (since 2.4)
+#
+# @model: #optional cpu model name (since 2.4)
+#
 # Since: 0.14.0
 #
 # Notes: @halted is a transient state that changes frequently.  By the time the
@@ -623,7 +627,8 @@
 ##
 { 'type': 'CpuInfo',
   'data': {'CPU': 'int', 'current': 'bool', 'halted': 'bool', '*pc': 'int',
-   '*nip': 'int', '*npc': 'int', '*PC': 'int', 'thread_id': 'int'} }
+   '*nip': 'int', '*npc': 'int', '*PC': 'int', 'thread_id': 'int',
+   '*accel': 'AccelId', '*model': 'str'} }
 
 ##
 # @query-cpus:
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 04/17] Extend HMP command info cpus to display accelerator id and model name

2015-04-13 Thread Michael Mueller
The HMP command info cpus now displays the CPU model name and the
backing accelerator if part of the CPUState.

(qemu) info cpus
* CPU #0: (halted) model=2827-ga2 accel=kvm thread_id=1679

Signed-off-by: Michael Mueller 
---
 hmp.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/hmp.c b/hmp.c
index f31ae27..70238332 100644
--- a/hmp.c
+++ b/hmp.c
@@ -290,6 +290,13 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict)
 monitor_printf(mon, " (halted)");
 }
 
+if (cpu->value->has_model) {
+monitor_printf(mon, " model=%s", cpu->value->model);
+}
+if (cpu->value->has_accel) {
+monitor_printf(mon, " accel=%s", 
AccelId_lookup[cpu->value->accel]);
+}
+
 monitor_printf(mon, " thread_id=%" PRId64 "\n", cpu->value->thread_id);
 }
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[GIT PULL 3/7] s390/kernel: Update /proc/sysinfo file with Extended Name and UUID

2015-02-09 Thread Christian Borntraeger
From: Ekaterina Tumanova 

A new architecture extends STSI 3.2.2 with UUID and long names. KVM
will provide the first implementation. This patch adds the additional
data  fields (Extended Name and UUID) from the 4KB block returned by
the STSI 3.2.2 command and reflect this information in the
/proc/sysinfo file accordingly.

Signed-off-by: Ekaterina Tumanova 
Reviewed-by: David Hildenbrand 
Reviewed-by: Cornelia Huck 
Acked-by: Heiko Carstens 
Signed-off-by: Christian Borntraeger 
---
 arch/s390/include/asm/sysinfo.h | 10 +++---
 arch/s390/kernel/sysinfo.c  | 29 +
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/arch/s390/include/asm/sysinfo.h b/arch/s390/include/asm/sysinfo.h
index f92428e..9f8f2b5 100644
--- a/arch/s390/include/asm/sysinfo.h
+++ b/arch/s390/include/asm/sysinfo.h
@@ -15,6 +15,7 @@
 #define __ASM_S390_SYSINFO_H
 
 #include 
+#include 
 
 struct sysinfo_1_1_1 {
unsigned char p:1;
@@ -112,10 +113,13 @@ struct sysinfo_3_2_2 {
char name[8];
unsigned int caf;
char cpi[16];
-   char reserved_1[24];
-
+   char reserved_1[3];
+   char ext_name_encoding;
+   unsigned int reserved_2;
+   uuid_be uuid;
} vm[8];
-   char reserved_544[3552];
+   char reserved_3[1504];
+   char ext_names[8][256];
 };
 
 extern int topology_max_mnest;
diff --git a/arch/s390/kernel/sysinfo.c b/arch/s390/kernel/sysinfo.c
index 811f542..cebab77 100644
--- a/arch/s390/kernel/sysinfo.c
+++ b/arch/s390/kernel/sysinfo.c
@@ -196,6 +196,33 @@ static void stsi_2_2_2(struct seq_file *m, struct 
sysinfo_2_2_2 *info)
seq_printf(m, "LPAR CPUs Shared: %d\n", info->cpus_shared);
 }
 
+static void print_ext_name(struct seq_file *m, int lvl,
+  struct sysinfo_3_2_2 *info)
+{
+   if (info->vm[lvl].ext_name_encoding == 0)
+   return;
+   if (info->ext_names[lvl][0] == 0)
+   return;
+   switch (info->vm[lvl].ext_name_encoding) {
+   case 1: /* EBCDIC */
+   EBCASC(info->ext_names[lvl], sizeof(info->ext_names[lvl]));
+   break;
+   case 2: /* UTF-8 */
+   break;
+   default:
+   return;
+   }
+   seq_printf(m, "VM%02d Extended Name:   %-.256s\n", lvl,
+  info->ext_names[lvl]);
+}
+
+static void print_uuid(struct seq_file *m, int i, struct sysinfo_3_2_2 *info)
+{
+   if (!memcmp(&info->vm[i].uuid, &NULL_UUID_BE, sizeof(uuid_be)))
+   return;
+   seq_printf(m, "VM%02d UUID:%pUb\n", i, &info->vm[i].uuid);
+}
+
 static void stsi_3_2_2(struct seq_file *m, struct sysinfo_3_2_2 *info)
 {
int i;
@@ -213,6 +240,8 @@ static void stsi_3_2_2(struct seq_file *m, struct 
sysinfo_3_2_2 *info)
seq_printf(m, "VM%02d CPUs Configured: %d\n", i, 
info->vm[i].cpus_configured);
seq_printf(m, "VM%02d CPUs Standby:%d\n", i, 
info->vm[i].cpus_standby);
seq_printf(m, "VM%02d CPUs Reserved:   %d\n", i, 
info->vm[i].cpus_reserved);
+   print_ext_name(m, i, info);
+   print_uuid(m, i, info);
}
 }
 
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/7] s390/kernel: Update /proc/sysinfo file with Extended Name and UUID

2015-02-05 Thread Paolo Bonzini


On 04/02/2015 20:32, Christian Borntraeger wrote:
> 
> A new architecture extends STSI 3.2.2 with UUID and long names. KVM will
> provide the first implementation. This patch adds the additional data 
> fields (Extended Name and UUID) from the 4KB block returned by the STSI 
> 3.2.2 command and reflect this information in the /proc/sysinfo file
> accordingly. 

Great.

> This is is non-KVM code, but developed by the KVM team. The patch is 
> acked by Heiko Carstens to go over the KVM tree.

The last two lines are not even necessary (the explanation of "why" is
in the first paragraph, the explanation of "how" is in the
Signed-off-bys and Acked-by).

Paolo

> Signed-off-by: Ekaterina Tumanova 
> Reviewed-by: David Hildenbrand 
> Reviewed-by: Cornelia Huck 
> Acked-by: Heiko Carstens 
> Signed-off-by: Christian Borntraeger 
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/7] s390/kernel: Update /proc/sysinfo file with Extended Name and UUID

2015-02-04 Thread Christian Borntraeger
Am 04.02.2015 um 14:03 schrieb Paolo Bonzini:
> 
> 
> On 04/02/2015 14:01, Christian Borntraeger wrote:
>> Am 04.02.2015 um 13:57 schrieb Paolo Bonzini:
>>>
>>>
>>> On 04/02/2015 10:44, Christian Borntraeger wrote:
>>>> From: Ekaterina Tumanova 
>>>>
>>>> Read the additional data fields (Extended Name and UUID) from the
>>>> 1KB block returned by the STSI command and reflect this information in
>>>> the /proc/sysinfo file accordingly
>>>>
>>>> Signed-off-by: Ekaterina Tumanova 
>>>> Reviewed-by: David Hildenbrand 
>>>> Reviewed-by: Cornelia Huck 
>>>> Acked-by: Heiko Carstens 
>>>> Signed-off-by: Christian Borntraeger 
>>>
>>> Why should this go in via KVM? :)
>>
>> Because we are being the first that will implement the architecture (
>> the other side so to speak). 
>> Heiko gave his ack so this shoudl be fine. If you prefer I can certainly push
>> that via Martin/Heiko.
> 
> No problem.  Perhaps edit the commit message?

Something like

A new architecture extends STSI 3.2.2 with UUID and long names. KVM will
provide the first implementation. This patch adds the additional data 
fields (Extended Name and UUID) from the 4KB block returned by the STSI 
3.2.2 command and reflect this information in the /proc/sysinfo file
accordingly. 
This is is non-KVM code, but developed by the KVM team. The patch is 
acked by Heiko Carstens to go over the KVM tree.

Signed-off-by: Ekaterina Tumanova 
Reviewed-by: David Hildenbrand 
Reviewed-by: Cornelia Huck 
Acked-by: Heiko Carstens 
Signed-off-by: Christian Borntraeger 

?

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/7] s390/kernel: Update /proc/sysinfo file with Extended Name and UUID

2015-02-04 Thread Paolo Bonzini


On 04/02/2015 14:01, Christian Borntraeger wrote:
> Am 04.02.2015 um 13:57 schrieb Paolo Bonzini:
>>
>>
>> On 04/02/2015 10:44, Christian Borntraeger wrote:
>>> From: Ekaterina Tumanova 
>>>
>>> Read the additional data fields (Extended Name and UUID) from the
>>> 1KB block returned by the STSI command and reflect this information in
>>> the /proc/sysinfo file accordingly
>>>
>>> Signed-off-by: Ekaterina Tumanova 
>>> Reviewed-by: David Hildenbrand 
>>> Reviewed-by: Cornelia Huck 
>>> Acked-by: Heiko Carstens 
>>> Signed-off-by: Christian Borntraeger 
>>
>> Why should this go in via KVM? :)
> 
> Because we are being the first that will implement the architecture (
> the other side so to speak). 
> Heiko gave his ack so this shoudl be fine. If you prefer I can certainly push
> that via Martin/Heiko.

No problem.  Perhaps edit the commit message?

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/7] s390/kernel: Update /proc/sysinfo file with Extended Name and UUID

2015-02-04 Thread Christian Borntraeger
Am 04.02.2015 um 13:57 schrieb Paolo Bonzini:
> 
> 
> On 04/02/2015 10:44, Christian Borntraeger wrote:
>> From: Ekaterina Tumanova 
>>
>> Read the additional data fields (Extended Name and UUID) from the
>> 1KB block returned by the STSI command and reflect this information in
>> the /proc/sysinfo file accordingly
>>
>> Signed-off-by: Ekaterina Tumanova 
>> Reviewed-by: David Hildenbrand 
>> Reviewed-by: Cornelia Huck 
>> Acked-by: Heiko Carstens 
>> Signed-off-by: Christian Borntraeger 
> 
> Why should this go in via KVM? :)

Because we are being the first that will implement the architecture (
the other side so to speak). 
Heiko gave his ack so this shoudl be fine. If you prefer I can certainly push
that via Martin/Heiko.


Christian

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/7] s390/kernel: Update /proc/sysinfo file with Extended Name and UUID

2015-02-04 Thread Paolo Bonzini


On 04/02/2015 10:44, Christian Borntraeger wrote:
> From: Ekaterina Tumanova 
> 
> Read the additional data fields (Extended Name and UUID) from the
> 1KB block returned by the STSI command and reflect this information in
> the /proc/sysinfo file accordingly
> 
> Signed-off-by: Ekaterina Tumanova 
> Reviewed-by: David Hildenbrand 
> Reviewed-by: Cornelia Huck 
> Acked-by: Heiko Carstens 
> Signed-off-by: Christian Borntraeger 

Why should this go in via KVM? :)

Paolo

> ---
>  arch/s390/include/asm/sysinfo.h | 10 +++---
>  arch/s390/kernel/sysinfo.c  | 29 +
>  2 files changed, 36 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/s390/include/asm/sysinfo.h b/arch/s390/include/asm/sysinfo.h
> index f92428e..9f8f2b5 100644
> --- a/arch/s390/include/asm/sysinfo.h
> +++ b/arch/s390/include/asm/sysinfo.h
> @@ -15,6 +15,7 @@
>  #define __ASM_S390_SYSINFO_H
>  
>  #include 
> +#include 
>  
>  struct sysinfo_1_1_1 {
>   unsigned char p:1;
> @@ -112,10 +113,13 @@ struct sysinfo_3_2_2 {
>   char name[8];
>   unsigned int caf;
>   char cpi[16];
> - char reserved_1[24];
> -
> + char reserved_1[3];
> + char ext_name_encoding;
> + unsigned int reserved_2;
> + uuid_be uuid;
>   } vm[8];
> - char reserved_544[3552];
> + char reserved_3[1504];
> + char ext_names[8][256];
>  };
>  
>  extern int topology_max_mnest;
> diff --git a/arch/s390/kernel/sysinfo.c b/arch/s390/kernel/sysinfo.c
> index 811f542..cebab77 100644
> --- a/arch/s390/kernel/sysinfo.c
> +++ b/arch/s390/kernel/sysinfo.c
> @@ -196,6 +196,33 @@ static void stsi_2_2_2(struct seq_file *m, struct 
> sysinfo_2_2_2 *info)
>   seq_printf(m, "LPAR CPUs Shared: %d\n", info->cpus_shared);
>  }
>  
> +static void print_ext_name(struct seq_file *m, int lvl,
> +struct sysinfo_3_2_2 *info)
> +{
> + if (info->vm[lvl].ext_name_encoding == 0)
> + return;
> + if (info->ext_names[lvl][0] == 0)
> + return;
> + switch (info->vm[lvl].ext_name_encoding) {
> + case 1: /* EBCDIC */
> + EBCASC(info->ext_names[lvl], sizeof(info->ext_names[lvl]));
> + break;
> + case 2: /* UTF-8 */
> + break;
> + default:
> + return;
> + }
> + seq_printf(m, "VM%02d Extended Name:   %-.256s\n", lvl,
> +info->ext_names[lvl]);
> +}
> +
> +static void print_uuid(struct seq_file *m, int i, struct sysinfo_3_2_2 *info)
> +{
> + if (!memcmp(&info->vm[i].uuid, &NULL_UUID_BE, sizeof(uuid_be)))
> + return;
> + seq_printf(m, "VM%02d UUID:%pUb\n", i, &info->vm[i].uuid);
> +}
> +
>  static void stsi_3_2_2(struct seq_file *m, struct sysinfo_3_2_2 *info)
>  {
>   int i;
> @@ -213,6 +240,8 @@ static void stsi_3_2_2(struct seq_file *m, struct 
> sysinfo_3_2_2 *info)
>   seq_printf(m, "VM%02d CPUs Configured: %d\n", i, 
> info->vm[i].cpus_configured);
>   seq_printf(m, "VM%02d CPUs Standby:%d\n", i, 
> info->vm[i].cpus_standby);
>   seq_printf(m, "VM%02d CPUs Reserved:   %d\n", i, 
> info->vm[i].cpus_reserved);
> + print_ext_name(m, i, info);
> + print_uuid(m, i, info);
>   }
>  }
>  
> 
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/7] s390/kernel: Update /proc/sysinfo file with Extended Name and UUID

2015-02-04 Thread Christian Borntraeger
From: Ekaterina Tumanova 

Read the additional data fields (Extended Name and UUID) from the
1KB block returned by the STSI command and reflect this information in
the /proc/sysinfo file accordingly

Signed-off-by: Ekaterina Tumanova 
Reviewed-by: David Hildenbrand 
Reviewed-by: Cornelia Huck 
Acked-by: Heiko Carstens 
Signed-off-by: Christian Borntraeger 
---
 arch/s390/include/asm/sysinfo.h | 10 +++---
 arch/s390/kernel/sysinfo.c  | 29 +
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/arch/s390/include/asm/sysinfo.h b/arch/s390/include/asm/sysinfo.h
index f92428e..9f8f2b5 100644
--- a/arch/s390/include/asm/sysinfo.h
+++ b/arch/s390/include/asm/sysinfo.h
@@ -15,6 +15,7 @@
 #define __ASM_S390_SYSINFO_H
 
 #include 
+#include 
 
 struct sysinfo_1_1_1 {
unsigned char p:1;
@@ -112,10 +113,13 @@ struct sysinfo_3_2_2 {
char name[8];
unsigned int caf;
char cpi[16];
-   char reserved_1[24];
-
+   char reserved_1[3];
+   char ext_name_encoding;
+   unsigned int reserved_2;
+   uuid_be uuid;
} vm[8];
-   char reserved_544[3552];
+   char reserved_3[1504];
+   char ext_names[8][256];
 };
 
 extern int topology_max_mnest;
diff --git a/arch/s390/kernel/sysinfo.c b/arch/s390/kernel/sysinfo.c
index 811f542..cebab77 100644
--- a/arch/s390/kernel/sysinfo.c
+++ b/arch/s390/kernel/sysinfo.c
@@ -196,6 +196,33 @@ static void stsi_2_2_2(struct seq_file *m, struct 
sysinfo_2_2_2 *info)
seq_printf(m, "LPAR CPUs Shared: %d\n", info->cpus_shared);
 }
 
+static void print_ext_name(struct seq_file *m, int lvl,
+  struct sysinfo_3_2_2 *info)
+{
+   if (info->vm[lvl].ext_name_encoding == 0)
+   return;
+   if (info->ext_names[lvl][0] == 0)
+   return;
+   switch (info->vm[lvl].ext_name_encoding) {
+   case 1: /* EBCDIC */
+   EBCASC(info->ext_names[lvl], sizeof(info->ext_names[lvl]));
+   break;
+   case 2: /* UTF-8 */
+   break;
+   default:
+   return;
+   }
+   seq_printf(m, "VM%02d Extended Name:   %-.256s\n", lvl,
+  info->ext_names[lvl]);
+}
+
+static void print_uuid(struct seq_file *m, int i, struct sysinfo_3_2_2 *info)
+{
+   if (!memcmp(&info->vm[i].uuid, &NULL_UUID_BE, sizeof(uuid_be)))
+   return;
+   seq_printf(m, "VM%02d UUID:%pUb\n", i, &info->vm[i].uuid);
+}
+
 static void stsi_3_2_2(struct seq_file *m, struct sysinfo_3_2_2 *info)
 {
int i;
@@ -213,6 +240,8 @@ static void stsi_3_2_2(struct seq_file *m, struct 
sysinfo_3_2_2 *info)
seq_printf(m, "VM%02d CPUs Configured: %d\n", i, 
info->vm[i].cpus_configured);
seq_printf(m, "VM%02d CPUs Standby:%d\n", i, 
info->vm[i].cpus_standby);
seq_printf(m, "VM%02d CPUs Reserved:   %d\n", i, 
info->vm[i].cpus_reserved);
+   print_ext_name(m, i, info);
+   print_uuid(m, i, info);
}
 }
 
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PULL 09/24] KVM: PPC: Book3S HV: Add register name when loading toc

2014-09-24 Thread Alexander Graf
From: Michael Neuling 

Add 'r' to register name r2 in kvmppc_hv_enter.

Also update comment at the top of kvmppc_hv_enter to indicate that R2/TOC is
non-volatile.

Signed-off-by: Michael Neuling 
Signed-off-by: Paul Mackerras 
Signed-off-by: Alexander Graf 
---
 arch/powerpc/kvm/book3s_hv_rmhandlers.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S 
b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index f0c4db7..edb2ccd 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -355,6 +355,7 @@ kvmppc_hv_entry:
 * MSR = ~IR|DR
 * R13 = PACA
 * R1 = host R1
+* R2 = TOC
 * all other volatile GPRS = free
 */
mflrr0
@@ -503,7 +504,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 toc_tlbie_lock:
.tc native_tlbie_lock[TC],native_tlbie_lock
.previous
-   ld  r3,toc_tlbie_lock@toc(2)
+   ld  r3,toc_tlbie_lock@toc(r2)
 #ifdef __BIG_ENDIAN__
lwz r8,PACA_LOCK_TOKEN(r13)
 #else
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] KVM: PPC: Book3S HV: Add register name when loading toc

2014-08-27 Thread Alexander Graf


On 19.08.14 06:59, Michael Neuling wrote:
> Add 'r' to register name r2 in kvmppc_hv_enter.
> 
> Also update comment at the top of kvmppc_hv_enter to indicate that R2/TOC is
> non-volatile.
> 
> Signed-off-by: Michael Neuling 
> Signed-off-by: Paul Mackerras 

Thanks, applied to kvm-ppc-queue.


Alex
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/2] target-i386: Add "tsc_adjust" CPU feature name

2014-08-25 Thread Eduardo Habkost
tsc_adjust migration support is already implemented (commit
f28558d3d37ad3bc4e35e8ac93f7bf81a0d5622c), so we can add it to the list
of known feature names.

Signed-off-by: Eduardo Habkost 
---
 target-i386/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index c86cf5c..ea0fd9c 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -257,7 +257,7 @@ static const char *svm_feature_name[] = {
 };
 
 static const char *cpuid_7_0_ebx_feature_name[] = {
-"fsgsbase", NULL, NULL, "bmi1", "hle", "avx2", NULL, "smep",
+"fsgsbase", "tsc_adjust", NULL, "bmi1", "hle", "avx2", NULL, "smep",
 "bmi2", "erms", "invpcid", "rtm", NULL, NULL, "mpx", NULL,
 NULL, NULL, "rdseed", "adx", "smap", NULL, NULL, NULL,
 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/2] target-i386: Add "mpx" CPU feature name

2014-08-25 Thread Eduardo Habkost
Migration support for MPX is already implemented (commit
79e9ebebbf2a00c46fcedb6dc7dd5e12bbd30216), so we can add it to the list
of known feature names.

Signed-off-by: Eduardo Habkost 
---
 target-i386/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 217500c..c86cf5c 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -258,7 +258,7 @@ static const char *svm_feature_name[] = {
 
 static const char *cpuid_7_0_ebx_feature_name[] = {
 "fsgsbase", NULL, NULL, "bmi1", "hle", "avx2", NULL, "smep",
-"bmi2", "erms", "invpcid", "rtm", NULL, NULL, NULL, NULL,
+"bmi2", "erms", "invpcid", "rtm", NULL, NULL, "mpx", NULL,
 NULL, NULL, "rdseed", "adx", "smap", NULL, NULL, NULL,
 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 };
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] KVM: PPC: Book3S HV: Add register name when loading toc

2014-08-18 Thread Michael Neuling
Add 'r' to register name r2 in kvmppc_hv_enter.

Also update comment at the top of kvmppc_hv_enter to indicate that R2/TOC is
non-volatile.

Signed-off-by: Michael Neuling 
Signed-off-by: Paul Mackerras 
---
 arch/powerpc/kvm/book3s_hv_rmhandlers.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S 
b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index c4bd2d7..1e8c480 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -355,6 +355,7 @@ kvmppc_hv_entry:
 * MSR = ~IR|DR
 * R13 = PACA
 * R1 = host R1
+* R2 = TOC
 * all other volatile GPRS = free
 */
mflrr0
@@ -503,7 +504,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 toc_tlbie_lock:
.tc native_tlbie_lock[TC],native_tlbie_lock
.previous
-   ld  r3,toc_tlbie_lock@toc(2)
+   ld  r3,toc_tlbie_lock@toc(r2)
 #ifdef __BIG_ENDIAN__
lwz r8,PACA_LOCK_TOKEN(r13)
 #else
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] target-i386: Add tsc_adjust CPU feature name

2014-08-06 Thread Eduardo Habkost
tsc_adjust migration support was implemented almost 2 years ago, by
commit f28558d3d37ad3bc4e35e8ac93f7bf81a0d5622c, so QEMU can safely
recognize the feature name.

Signed-off-by: Eduardo Habkost 
---
This needs to be applied after:
 [PATCH] target-i386: Add MPX CPU feature name
which I just sent. Sorry for not making it a series, I have noticed tsc_adjust
was in the same section after I had already sent the MPX patch.
---
 target-i386/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 749f9cb..535a0d7 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -257,7 +257,7 @@ static const char *svm_feature_name[] = {
 };
 
 static const char *cpuid_7_0_ebx_feature_name[] = {
-"fsgsbase", NULL, NULL, "bmi1", "hle", "avx2", NULL, "smep",
+"fsgsbase", "tsc_adjust", NULL, "bmi1", "hle", "avx2", NULL, "smep",
 "bmi2", "erms", "invpcid", "rtm", NULL, NULL, "mpx", NULL,
 NULL, NULL, "rdseed", "adx", "smap", NULL, NULL, NULL,
 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] target-i386: Add MPX CPU feature name

2014-08-06 Thread Eduardo Habkost
Migration support for MPX is already implemented, so we can add it to
the list of known feature names.

Signed-off-by: Eduardo Habkost 
---
 target-i386/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 6d008ab..749f9cb 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -258,7 +258,7 @@ static const char *svm_feature_name[] = {
 
 static const char *cpuid_7_0_ebx_feature_name[] = {
 "fsgsbase", NULL, NULL, "bmi1", "hle", "avx2", NULL, "smep",
-"bmi2", "erms", "invpcid", "rtm", NULL, NULL, NULL, NULL,
+"bmi2", "erms", "invpcid", "rtm", NULL, NULL, "mpx", NULL,
 NULL, NULL, "rdseed", "adx", "smap", NULL, NULL, NULL,
 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 };
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH for-2.1] target-i386: Add "kvmclock-stable-bit" feature bit name

2014-07-05 Thread Paolo Bonzini

Il 04/07/2014 21:44, Eduardo Habkost ha scritto:

KVM_FEATURE_CLOCKSOURCE_STABLE_BIT is enabled by default and supported
by KVM. But not having a name defined makes QEMU treat it as an unknown
and unmigratable feature flag (as any unknown feature may possibly
require state to be migrated), and disable it by default on "-cpu host".

As a side-effect, the new name also makes the flag configurable,
allowing the user to disable it (which may be useful for testing or for
compatibility with old kernels).

Signed-off-by: Eduardo Habkost 
---
 target-i386/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 45c662d..6d008ab 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -241,7 +241,7 @@ static const char *kvm_feature_name[] = {
 NULL, NULL, NULL, NULL,
 NULL, NULL, NULL, NULL,
 NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
+"kvmclock-stable-bit", NULL, NULL, NULL,
 NULL, NULL, NULL, NULL,
 };




Applied to uq/master, thanks.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH for-2.1] target-i386: Add "kvmclock-stable-bit" feature bit name

2014-07-04 Thread Eduardo Habkost
KVM_FEATURE_CLOCKSOURCE_STABLE_BIT is enabled by default and supported
by KVM. But not having a name defined makes QEMU treat it as an unknown
and unmigratable feature flag (as any unknown feature may possibly
require state to be migrated), and disable it by default on "-cpu host".

As a side-effect, the new name also makes the flag configurable,
allowing the user to disable it (which may be useful for testing or for
compatibility with old kernels).

Signed-off-by: Eduardo Habkost 
---
 target-i386/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 45c662d..6d008ab 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -241,7 +241,7 @@ static const char *kvm_feature_name[] = {
 NULL, NULL, NULL, NULL,
 NULL, NULL, NULL, NULL,
 NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL,
+"kvmclock-stable-bit", NULL, NULL, NULL,
 NULL, NULL, NULL, NULL,
 };
 
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] perf tools: parse tracepooints with '-' in system name

2014-04-28 Thread Christian Borntraeger
On 25/04/14 17:34, Alexander Yarygin wrote:
> Trace events potentially can have a '-' in their trace system name,
> e.g. kvm on s390 defines kvm-s390:* tracepoints.
> tools/perf could not parse them, because there was no rule for this:
> $ sudo ./perf top -e "kvm-s390:*"
> invalid or unsupported event: 'kvm-s390:*'
> 
> This patch adds an extra rule to event_legacy_tracepoint which handles
> those cases. Without the patch, perf will not accept such tracepoints in
> the -e option.
> 
> Signed-off-by: Alexander Yarygin 
Tested-by: Christian Borntraeger 
Acked-by: Christian Borntraeger 

Jiri, please review and handle via your tree if ok.

I gave the other two patches also a quick test on my s390 box. Seems to work 
fine.



> ---
>  tools/perf/util/parse-events.y |   12 
>  1 file changed, 12 insertions(+)
> 
> diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
> index 4eb67ec..ac9db9f 100644
> --- a/tools/perf/util/parse-events.y
> +++ b/tools/perf/util/parse-events.y
> @@ -299,6 +299,18 @@ PE_PREFIX_MEM PE_VALUE sep_dc
>  }
> 
>  event_legacy_tracepoint:
> +PE_NAME '-' PE_NAME ':' PE_NAME
> +{
> + struct parse_events_evlist *data = _data;
> + struct list_head *list;
> + char sys_name[128];
> + snprintf(&sys_name, 128, "%s-%s", $1, $3);
> +
> + ALLOC_LIST(list);
> + ABORT_ON(parse_events_add_tracepoint(list, &data->idx, &sys_name, $5));
> + $$ = list;
> +}
> +|
>  PE_NAME ':' PE_NAME
>  {
>   struct parse_events_evlist *data = _data;
> 

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/3] Fix usage of trace events with '-' in trace system name.

2014-04-25 Thread Alexander Yarygin
This path series allows perf tool to work with trace events,
which have '-' in trace system name (i.e. kvm-s390:*).

v2 changes:
- added s390 specific test to perf/tests/parse-events.c
- use array with a constant length in the parse rule
- rephrased description of patch 1/3

Patch 2/3 makes possible to add arch specific tests
to perf/tests/parse-events.c.

Alexander Yarygin (3):
  perf tools: parse tracepooints with '-' in system name
  perf-test: add numeric identifier to evlist_test
  perf-test: Add a test of kvm-390: trace event

 tools/perf/tests/parse-events.c |  142 ++-
 tools/perf/util/parse-events.y  |   12 
 2 files changed, 109 insertions(+), 45 deletions(-)

--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] perf tools: parse tracepooints with '-' in system name

2014-04-25 Thread Alexander Yarygin
Trace events potentially can have a '-' in their trace system name,
e.g. kvm on s390 defines kvm-s390:* tracepoints.
tools/perf could not parse them, because there was no rule for this:
$ sudo ./perf top -e "kvm-s390:*"
invalid or unsupported event: 'kvm-s390:*'

This patch adds an extra rule to event_legacy_tracepoint which handles
those cases. Without the patch, perf will not accept such tracepoints in
the -e option.

Signed-off-by: Alexander Yarygin 
---
 tools/perf/util/parse-events.y |   12 
 1 file changed, 12 insertions(+)

diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 4eb67ec..ac9db9f 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -299,6 +299,18 @@ PE_PREFIX_MEM PE_VALUE sep_dc
 }
 
 event_legacy_tracepoint:
+PE_NAME '-' PE_NAME ':' PE_NAME
+{
+   struct parse_events_evlist *data = _data;
+   struct list_head *list;
+   char sys_name[128];
+   snprintf(&sys_name, 128, "%s-%s", $1, $3);
+
+   ALLOC_LIST(list);
+   ABORT_ON(parse_events_add_tracepoint(list, &data->idx, &sys_name, $5));
+   $$ = list;
+}
+|
 PE_NAME ':' PE_NAME
 {
struct parse_events_evlist *data = _data;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-04-23 Thread Christian Borntraeger
On 23/04/14 13:45, Jiri Olsa wrote:
> On Mon, Apr 21, 2014 at 07:43:50PM +0400, Alexander Yarygin wrote:
[...]
>> And a bit of offtopic :)
>> Apparently, s390 doesn't have syscalls:*, so some of the tests
>> don't work properly (or maybe I missed something? I set 
>> CONFIG_FTRACE_SYSCALLS
>> to 'y' in my config: still no syscalls:*).

Strange, on my system I have syscall trace points on s390.
Maybe some additional dependency of CONFIG_FTRACE_SYSCALLS that is not catched
via Kconfig?

>>
>> What do you think about this idea:
>>
>> --- a/tools/perf/tests/parse-events.c
>> +++ b/tools/perf/tests/parse-events.c
>> @@ -1177,13 +1177,21 @@ struct evlist_test {
>>  int (*check)(struct perf_evlist *evlist);
>>  };
>>
>> +#if !defined(__s390x__)
>> +#define TP_SYS_NAME "syscalls"
>> +#define TP_EVENT_NAME "sys_enter_open"
>> +#else
>> +#define TP_SYS_NAME "sched"
>> +#define TP_EVENT_NAME "sched_wakeup"
>> +#endif
>> +
>>  static struct evlist_test test__events[] = {
>>  [0] = {
>> -.name  = "syscalls:sys_enter_open",
>> +.name  = TP_SYS_NAME ":" TP_EVENT_NAME,
>>  .check = test__checkevent_tracepoint,
>>  },
>>
>> ... and so on?
> 
> that looks fine.. also we could use just generic tracepoints
> like the 'sched' ones

I think generic tracepoints are preferred over ifdef, but as I said I have 
syscalls.

Christian

Christian




--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-04-23 Thread Jiri Olsa
On Mon, Apr 21, 2014 at 07:43:50PM +0400, Alexander Yarygin wrote:

SNIP

> 
> --- a/tools/perf/tests/parse-events.c
> +++ b/tools/perf/tests/parse-events.c
> @@ -1346,6 +1346,12 @@ static struct evlist_test test__events[] = {
>   .name  = "{cycles,cache-misses,branch-misses}:D",
>   .check = test__pinned_group,
>   },
> +#if defined(__s390x__)
> + [42] = {
> + .name  = "kvm-s390:kvm_s390_create_vm",
> + .check = test__checkevent_tracepoint,
> + },
> +#endif /* and what will be the next number: 42 or 43? */
>  };
> 
>  static struct evlist_test test__events_pmu[] = {
> 
> 
> Because it breaks explicit numbering of test__events[].
> I can suggest to move numeration into evlist_test, i.e.
> 
> --- a/tools/perf/tests/parse-events.c
> +++ b/tools/perf/tests/parse-events.c
> @@ -1174,25 +1174,30 @@ static int test__all_tracepoints(struct perf_evlist 
> *evlist)
>  struct evlist_test {
>   const char *name;
>   __u32 type;
> + int index;
>   int (*check)(struct perf_evlist *evlist);
>  };
>  
>  static struct evlist_test test__events[] = {
> - [0] = {
> + {
>   .name  = "syscalls:sys_enter_open",
>   .check = test__checkevent_tracepoint,
> + .index = 0;
>   },
> ...
> 
> or just to remove it?

right, that numbering is there to ease the search for test,
and is printed for -v option

the 'index' field should be fine, and please print it
out for '-v' option


> 
> How do you think?
> 
> 
> And a bit of offtopic :)
> Apparently, s390 doesn't have syscalls:*, so some of the tests
> don't work properly (or maybe I missed something? I set CONFIG_FTRACE_SYSCALLS
> to 'y' in my config: still no syscalls:*).
> 
> What do you think about this idea:
> 
> --- a/tools/perf/tests/parse-events.c
> +++ b/tools/perf/tests/parse-events.c
> @@ -1177,13 +1177,21 @@ struct evlist_test {
>   int (*check)(struct perf_evlist *evlist);
>  };
> 
> +#if !defined(__s390x__)
> +#define TP_SYS_NAME "syscalls"
> +#define TP_EVENT_NAME "sys_enter_open"
> +#else
> +#define TP_SYS_NAME "sched"
> +#define TP_EVENT_NAME "sched_wakeup"
> +#endif
> +
>  static struct evlist_test test__events[] = {
>   [0] = {
> - .name  = "syscalls:sys_enter_open",
> + .name  = TP_SYS_NAME ":" TP_EVENT_NAME,
>   .check = test__checkevent_tracepoint,
>   },
> 
> ... and so on?

that looks fine.. also we could use just generic tracepoints
like the 'sched' ones

> 
> Also, test_pmu() looks at /sys/bus/event_source/devices/cpu/
> but instead of "cpu/" on s390 there are "cpum_sf/" and "cpum_cf/",
> so pmu tests don't work either..

we could #ifdef the pmu name for s390 and other archs

or make it more fancy and detect it by using pmu.c code,
please check perf_pmu__scan,perf_pmu__find functions

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-04-23 Thread Christian Borntraeger
On 17/04/14 16:40, Jiri Olsa wrote:
> On Mon, Mar 24, 2014 at 09:49:00PM +0100, Christian Borntraeger wrote:
>> From: Alexander Yarygin 
>>
>> Trace events potentially can have a '-' in their trace system name,
>> e.g. kvm on s390 defines kvm-s390:* tracepoints.
>> tools/perf could not parse them, because there was no rule for this:
>> $ sudo ./perf top -e "kvm-s390:*"
>> invalid or unsupported event: 'kvm-s390:*'
>>
>> This patch adds an extra rule to event_legacy_tracepoint which handles
>> those cases. Without the patch, perf will not accept such tracepoints in
>> the -e option.
>>
>> Signed-off-by: Alexander Yarygin 
>> Signed-off-by: Christian Borntraeger 
>> ---
>>  tools/perf/util/parse-events.y | 12 
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
>> index 4eb67ec..dbbb01c 100644
>> --- a/tools/perf/util/parse-events.y
>> +++ b/tools/perf/util/parse-events.y
>> @@ -299,6 +299,18 @@ PE_PREFIX_MEM PE_VALUE sep_dc
>>  }
>>  
>>  event_legacy_tracepoint:
>> +PE_NAME '-' PE_NAME ':' PE_NAME
>> +{
>> +struct parse_events_evlist *data = _data;
>> +struct list_head *list;
>> +char sys_name[strlen($1) + strlen($3) + 2];
> 
> hum, could you limit the size of sys_name array with some
> sane value? those strlens make me nervous :-\

Right. Something like
char sys_name[128];
[...]

snprintf(&sys_name, 128, "%s-%s", $1, $3);

should be enough for all trace event names. And if not, the event should simply 
fail.

Alexander,

can you send an updates patch?

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-04-21 Thread Alexander Yarygin
At Thu, 17 Apr 2014 13:32:21 +0200,
Jiri Olsa wrote:
> 
> On Tue, Mar 25, 2014 at 11:15:29AM +0100, Paolo Bonzini wrote:
> > Il 24/03/2014 21:49, Christian Borntraeger ha scritto:
> > > event_legacy_tracepoint:
> > >+PE_NAME '-' PE_NAME ':' PE_NAME
> > >+{
> > >+  struct parse_events_evlist *data = _data;
> > >+  struct list_head *list;
> > >+  char sys_name[strlen($1) + strlen($3) + 2];
> > >+  sprintf(&sys_name, "%s-%s", $1, $3);
> > >+
> > >+  ALLOC_LIST(list);
> > >+  ABORT_ON(parse_events_add_tracepoint(list, &data->idx, &sys_name, $5));
> > >+  $$ = list;
> > >+}
> > 
> > Why isn't '-' part of PE_NAME?
> 
> hi Paolo ;-)
> 
> because it screws cache events parsing.. we need some code factoring
> in this part
> 
> Acked-by: Jiri Olsa 
> 
> it'd be nice to add test to tests/parse-events.c, probably s390 specific,
> because the parsing code touches the tracepoint format file
> 

Hi,

Hmm, looks like we can't simply add arch-specific test:

--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1346,6 +1346,12 @@ static struct evlist_test test__events[] = {
.name  = "{cycles,cache-misses,branch-misses}:D",
.check = test__pinned_group,
},
+#if defined(__s390x__)
+   [42] = {
+   .name  = "kvm-s390:kvm_s390_create_vm",
+   .check = test__checkevent_tracepoint,
+   },
+#endif /* and what will be the next number: 42 or 43? */
 };

 static struct evlist_test test__events_pmu[] = {


Because it breaks explicit numbering of test__events[].
I can suggest to move numeration into evlist_test, i.e.

--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1174,25 +1174,30 @@ static int test__all_tracepoints(struct perf_evlist 
*evlist)
 struct evlist_test {
const char *name;
__u32 type;
+   int index;
int (*check)(struct perf_evlist *evlist);
 };
 
 static struct evlist_test test__events[] = {
-   [0] = {
+   {
.name  = "syscalls:sys_enter_open",
.check = test__checkevent_tracepoint,
+   .index = 0;
},
...

or just to remove it?

How do you think?


And a bit of offtopic :)
Apparently, s390 doesn't have syscalls:*, so some of the tests
don't work properly (or maybe I missed something? I set CONFIG_FTRACE_SYSCALLS
to 'y' in my config: still no syscalls:*).

What do you think about this idea:

--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1177,13 +1177,21 @@ struct evlist_test {
int (*check)(struct perf_evlist *evlist);
 };

+#if !defined(__s390x__)
+#define TP_SYS_NAME "syscalls"
+#define TP_EVENT_NAME "sys_enter_open"
+#else
+#define TP_SYS_NAME "sched"
+#define TP_EVENT_NAME "sched_wakeup"
+#endif
+
 static struct evlist_test test__events[] = {
[0] = {
-   .name  = "syscalls:sys_enter_open",
+   .name  = TP_SYS_NAME ":" TP_EVENT_NAME,
.check = test__checkevent_tracepoint,
},

... and so on?

Also, test_pmu() looks at /sys/bus/event_source/devices/cpu/
but instead of "cpu/" on s390 there are "cpum_sf/" and "cpum_cf/",
so pmu tests don't work either..


Thanks

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-04-17 Thread Jiri Olsa
On Mon, Mar 24, 2014 at 09:49:00PM +0100, Christian Borntraeger wrote:
> From: Alexander Yarygin 
> 
> Trace events potentially can have a '-' in their trace system name,
> e.g. kvm on s390 defines kvm-s390:* tracepoints.
> tools/perf could not parse them, because there was no rule for this:
> $ sudo ./perf top -e "kvm-s390:*"
> invalid or unsupported event: 'kvm-s390:*'
> 
> This patch adds an extra rule to event_legacy_tracepoint which handles
> those cases. Without the patch, perf will not accept such tracepoints in
> the -e option.
> 
> Signed-off-by: Alexander Yarygin 
> Signed-off-by: Christian Borntraeger 
> ---
>  tools/perf/util/parse-events.y | 12 
>  1 file changed, 12 insertions(+)
> 
> diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
> index 4eb67ec..dbbb01c 100644
> --- a/tools/perf/util/parse-events.y
> +++ b/tools/perf/util/parse-events.y
> @@ -299,6 +299,18 @@ PE_PREFIX_MEM PE_VALUE sep_dc
>  }
>  
>  event_legacy_tracepoint:
> +PE_NAME '-' PE_NAME ':' PE_NAME
> +{
> + struct parse_events_evlist *data = _data;
> + struct list_head *list;
> + char sys_name[strlen($1) + strlen($3) + 2];

hum, could you limit the size of sys_name array with some
sane value? those strlens make me nervous :-\

thanks,
jirka

> + sprintf(&sys_name, "%s-%s", $1, $3);
> +
> + ALLOC_LIST(list);
> + ABORT_ON(parse_events_add_tracepoint(list, &data->idx, &sys_name, $5));
> + $$ = list;
> +}
> +|
>  PE_NAME ':' PE_NAME
>  {
>   struct parse_events_evlist *data = _data;
> -- 
> 1.8.4.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-04-17 Thread Jiri Olsa
On Thu, Apr 17, 2014 at 01:41:56PM +0200, Christian Borntraeger wrote:
> On 17/04/14 13:32, Jiri Olsa wrote:
> > On Tue, Mar 25, 2014 at 11:15:29AM +0100, Paolo Bonzini wrote:
> >> Il 24/03/2014 21:49, Christian Borntraeger ha scritto:
> >>> event_legacy_tracepoint:
> >>> +PE_NAME '-' PE_NAME ':' PE_NAME
> >>> +{
> >>> + struct parse_events_evlist *data = _data;
> >>> + struct list_head *list;
> >>> + char sys_name[strlen($1) + strlen($3) + 2];
> >>> + sprintf(&sys_name, "%s-%s", $1, $3);
> >>> +
> >>> + ALLOC_LIST(list);
> >>> + ABORT_ON(parse_events_add_tracepoint(list, &data->idx, &sys_name, $5));
> >>> + $$ = list;
> >>> +}
> >>
> >> Why isn't '-' part of PE_NAME?
> > 
> > hi Paolo ;-)
> > 
> > because it screws cache events parsing.. we need some code factoring
> > in this part
> > 
> > Acked-by: Jiri Olsa 
> 
> Jiri,
> 
> can you handle this patch + "perf-kvm: fix of 'Min time' counting in report 
> command" in your tree?

yep, I queued both of them

jirka

> 
> > 
> > it'd be nice to add test to tests/parse-events.c, probably s390 specific,
> > because the parsing code touches the tracepoint format file
> 
> Alexander,
> 
> can you have a look to provide a simple test for perf that checks that trace 
> events like kvm-s390 are handled properly?
> 
> Thanks
> 
> Christian
> 
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-04-17 Thread Christian Borntraeger
On 17/04/14 13:32, Jiri Olsa wrote:
> On Tue, Mar 25, 2014 at 11:15:29AM +0100, Paolo Bonzini wrote:
>> Il 24/03/2014 21:49, Christian Borntraeger ha scritto:
>>> event_legacy_tracepoint:
>>> +PE_NAME '-' PE_NAME ':' PE_NAME
>>> +{
>>> +   struct parse_events_evlist *data = _data;
>>> +   struct list_head *list;
>>> +   char sys_name[strlen($1) + strlen($3) + 2];
>>> +   sprintf(&sys_name, "%s-%s", $1, $3);
>>> +
>>> +   ALLOC_LIST(list);
>>> +   ABORT_ON(parse_events_add_tracepoint(list, &data->idx, &sys_name, $5));
>>> +   $$ = list;
>>> +}
>>
>> Why isn't '-' part of PE_NAME?
> 
> hi Paolo ;-)
> 
> because it screws cache events parsing.. we need some code factoring
> in this part
> 
> Acked-by: Jiri Olsa 

Jiri,

can you handle this patch + "perf-kvm: fix of 'Min time' counting in report 
command" in your tree?

> 
> it'd be nice to add test to tests/parse-events.c, probably s390 specific,
> because the parsing code touches the tracepoint format file

Alexander,

can you have a look to provide a simple test for perf that checks that trace 
events like kvm-s390 are handled properly?

Thanks

Christian

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-04-17 Thread Jiri Olsa
On Tue, Mar 25, 2014 at 11:15:29AM +0100, Paolo Bonzini wrote:
> Il 24/03/2014 21:49, Christian Borntraeger ha scritto:
> > event_legacy_tracepoint:
> >+PE_NAME '-' PE_NAME ':' PE_NAME
> >+{
> >+struct parse_events_evlist *data = _data;
> >+struct list_head *list;
> >+char sys_name[strlen($1) + strlen($3) + 2];
> >+sprintf(&sys_name, "%s-%s", $1, $3);
> >+
> >+ALLOC_LIST(list);
> >+ABORT_ON(parse_events_add_tracepoint(list, &data->idx, &sys_name, $5));
> >+$$ = list;
> >+}
> 
> Why isn't '-' part of PE_NAME?

hi Paolo ;-)

because it screws cache events parsing.. we need some code factoring
in this part

Acked-by: Jiri Olsa 

it'd be nice to add test to tests/parse-events.c, probably s390 specific,
because the parsing code touches the tracepoint format file

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL 1/2] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-04-16 Thread Jiri Olsa
On Wed, Apr 16, 2014 at 03:31:15PM +0200, Christian Borntraeger wrote:
> On 16/04/14 15:28, Christian Borntraeger wrote:
> > On 16/04/14 15:00, Jiri Olsa wrote:
> >> On Wed, Apr 09, 2014 at 04:21:58PM +0200, Christian Borntraeger wrote:
> >>> From: Alexander Yarygin 
> >>>
> >>> Trace events potentially can have a '-' in their trace system name,
> >>> e.g. kvm on s390 defines kvm-s390:* tracepoints.
> >>> tools/perf could not parse them, because there was no rule for this:
> >>> $ sudo ./perf top -e "kvm-s390:*"
> >>> invalid or unsupported event: 'kvm-s390:*'
> >>>
> >>> This patch allows '-' to be a part of PE_NAME token, so tracepoints
> >>> with '-' can be parsed by the event_legacy_tracepoint rule.
> >>> Without the patch, perf will not accept such tracepoints in the -e
> >>> option.
> >>>
> >>> Signed-off-by: Alexander Yarygin 
> >>> Signed-off-by: Christian Borntraeger 
> >>> ---
> >>>  tools/perf/util/parse-events.l |2 +-
> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/tools/perf/util/parse-events.l 
> >>> b/tools/perf/util/parse-events.l
> >>> index 3432995..ca20da7 100644
> >>> --- a/tools/perf/util/parse-events.l
> >>> +++ b/tools/perf/util/parse-events.l
> >>> @@ -199,7 +199,7 @@ r{num_raw_hex}{ return 
> >>> raw(yyscanner); }
> >>>  {num_hex}{ return value(yyscanner, 16); }
> >>>  
> >>>  {modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); }
> >>> -{name}   { return str(yyscanner, PE_NAME); }
> >>> +{name_minus} { return str(yyscanner, PE_NAME); }
> >>>  "/"  { BEGIN(config); return '/'; }
> >>>  -{ return '-'; }
> >>>  ,{ BEGIN(event); return ','; }
> >>
> >> this breaks parsing of cache events like:
> >>
> >>   $ perf record -e 'L1-dcache-loads' ls
> >>
> >> also test 10 (same issue):
> >>   $ ./perf test 10
> >>   10: roundtrip evsel->name check: FAILED!
> >>
> >>
> >> it might be little tricky to fix, let me know if you
> >> have any troubles with that, I could look on it
> > 
> > Hmm, so do you prefer tackling this problem directly at  
> > event_legacy_tracepoint, e.g.
> > like in
> > https://lkml.org/lkml/2014/3/24/364
> 
> A totally different approach would be to rename the kvm-s390 trace events to 
> kvm_s390.
> 

hopefully that wouldn't be necessary ;-)

I checked the other approach and it works.. I'll see if I can find
some other way, if not I'll take that patch

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL 1/2] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-04-16 Thread Christian Borntraeger
On 16/04/14 15:28, Christian Borntraeger wrote:
> On 16/04/14 15:00, Jiri Olsa wrote:
>> On Wed, Apr 09, 2014 at 04:21:58PM +0200, Christian Borntraeger wrote:
>>> From: Alexander Yarygin 
>>>
>>> Trace events potentially can have a '-' in their trace system name,
>>> e.g. kvm on s390 defines kvm-s390:* tracepoints.
>>> tools/perf could not parse them, because there was no rule for this:
>>> $ sudo ./perf top -e "kvm-s390:*"
>>> invalid or unsupported event: 'kvm-s390:*'
>>>
>>> This patch allows '-' to be a part of PE_NAME token, so tracepoints
>>> with '-' can be parsed by the event_legacy_tracepoint rule.
>>> Without the patch, perf will not accept such tracepoints in the -e
>>> option.
>>>
>>> Signed-off-by: Alexander Yarygin 
>>> Signed-off-by: Christian Borntraeger 
>>> ---
>>>  tools/perf/util/parse-events.l |2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
>>> index 3432995..ca20da7 100644
>>> --- a/tools/perf/util/parse-events.l
>>> +++ b/tools/perf/util/parse-events.l
>>> @@ -199,7 +199,7 @@ r{num_raw_hex}  { return raw(yyscanner); }
>>>  {num_hex}  { return value(yyscanner, 16); }
>>>  
>>>  {modifier_event}   { return str(yyscanner, PE_MODIFIER_EVENT); }
>>> -{name} { return str(yyscanner, PE_NAME); }
>>> +{name_minus}   { return str(yyscanner, PE_NAME); }
>>>  "/"{ BEGIN(config); return '/'; }
>>>  -  { return '-'; }
>>>  ,  { BEGIN(event); return ','; }
>>
>> this breaks parsing of cache events like:
>>
>>   $ perf record -e 'L1-dcache-loads' ls
>>
>> also test 10 (same issue):
>>   $ ./perf test 10
>>   10: roundtrip evsel->name check: FAILED!
>>
>>
>> it might be little tricky to fix, let me know if you
>> have any troubles with that, I could look on it
> 
> Hmm, so do you prefer tackling this problem directly at  
> event_legacy_tracepoint, e.g.
> like in
> https://lkml.org/lkml/2014/3/24/364

A totally different approach would be to rename the kvm-s390 trace events to 
kvm_s390.


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL 1/2] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-04-16 Thread Christian Borntraeger
On 16/04/14 15:00, Jiri Olsa wrote:
> On Wed, Apr 09, 2014 at 04:21:58PM +0200, Christian Borntraeger wrote:
>> From: Alexander Yarygin 
>>
>> Trace events potentially can have a '-' in their trace system name,
>> e.g. kvm on s390 defines kvm-s390:* tracepoints.
>> tools/perf could not parse them, because there was no rule for this:
>> $ sudo ./perf top -e "kvm-s390:*"
>> invalid or unsupported event: 'kvm-s390:*'
>>
>> This patch allows '-' to be a part of PE_NAME token, so tracepoints
>> with '-' can be parsed by the event_legacy_tracepoint rule.
>> Without the patch, perf will not accept such tracepoints in the -e
>> option.
>>
>> Signed-off-by: Alexander Yarygin 
>> Signed-off-by: Christian Borntraeger 
>> ---
>>  tools/perf/util/parse-events.l |2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
>> index 3432995..ca20da7 100644
>> --- a/tools/perf/util/parse-events.l
>> +++ b/tools/perf/util/parse-events.l
>> @@ -199,7 +199,7 @@ r{num_raw_hex}   { return raw(yyscanner); }
>>  {num_hex}   { return value(yyscanner, 16); }
>>  
>>  {modifier_event}{ return str(yyscanner, PE_MODIFIER_EVENT); }
>> -{name}  { return str(yyscanner, PE_NAME); }
>> +{name_minus}{ return str(yyscanner, PE_NAME); }
>>  "/" { BEGIN(config); return '/'; }
>>  -   { return '-'; }
>>  ,   { BEGIN(event); return ','; }
> 
> this breaks parsing of cache events like:
> 
>   $ perf record -e 'L1-dcache-loads' ls
> 
> also test 10 (same issue):
>   $ ./perf test 10
>   10: roundtrip evsel->name check: FAILED!
> 
> 
> it might be little tricky to fix, let me know if you
> have any troubles with that, I could look on it

Hmm, so do you prefer tackling this problem directly at  
event_legacy_tracepoint, e.g.
like in
https://lkml.org/lkml/2014/3/24/364

Christian


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL 1/2] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-04-16 Thread Jiri Olsa
On Wed, Apr 09, 2014 at 04:21:58PM +0200, Christian Borntraeger wrote:
> From: Alexander Yarygin 
> 
> Trace events potentially can have a '-' in their trace system name,
> e.g. kvm on s390 defines kvm-s390:* tracepoints.
> tools/perf could not parse them, because there was no rule for this:
> $ sudo ./perf top -e "kvm-s390:*"
> invalid or unsupported event: 'kvm-s390:*'
> 
> This patch allows '-' to be a part of PE_NAME token, so tracepoints
> with '-' can be parsed by the event_legacy_tracepoint rule.
> Without the patch, perf will not accept such tracepoints in the -e
> option.
> 
> Signed-off-by: Alexander Yarygin 
> Signed-off-by: Christian Borntraeger 
> ---
>  tools/perf/util/parse-events.l |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
> index 3432995..ca20da7 100644
> --- a/tools/perf/util/parse-events.l
> +++ b/tools/perf/util/parse-events.l
> @@ -199,7 +199,7 @@ r{num_raw_hex}{ return raw(yyscanner); }
>  {num_hex}    { return value(yyscanner, 16); }
>  
>  {modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); }
> -{name}   { return str(yyscanner, PE_NAME); }
> +{name_minus} { return str(yyscanner, PE_NAME); }
>  "/"  { BEGIN(config); return '/'; }
>  -{ return '-'; }
>  ,{ BEGIN(event); return ','; }

this breaks parsing of cache events like:

  $ perf record -e 'L1-dcache-loads' ls

also test 10 (same issue):
  $ ./perf test 10
  10: roundtrip evsel->name check: FAILED!


it might be little tricky to fix, let me know if you
have any troubles with that, I could look on it

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 34/47] s390: fix name of lowcore field at offset 0xa3

2014-04-15 Thread Christian Borntraeger
From: Jens Freimann 

According to the Principles of Operation, at offset 0xA3
in the lowcore we have the "Architectural-Mode identification",
not an "access identification".

Signed-off-by: Jens Freimann 
Acked-by: Heiko Carstens 
Signed-off-by: Christian Borntraeger 
---
 arch/s390/include/asm/lowcore.h | 4 ++--
 arch/s390/kernel/asm-offsets.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/s390/include/asm/lowcore.h b/arch/s390/include/asm/lowcore.h
index bbf8141..edfa89b 100644
--- a/arch/s390/include/asm/lowcore.h
+++ b/arch/s390/include/asm/lowcore.h
@@ -62,7 +62,7 @@ struct _lowcore {
__u8exc_access_id;  /* 0x00a0 */
__u8per_access_id;  /* 0x00a1 */
__u8op_access_id;   /* 0x00a2 */
-   __u8ar_access_id;   /* 0x00a3 */
+   __u8ar_mode_id; /* 0x00a3 */
__u8pad_0x00a4[0x00b8-0x00a4];  /* 0x00a4 */
__u16   subchannel_id;  /* 0x00b8 */
__u16   subchannel_nr;  /* 0x00ba */
@@ -201,7 +201,7 @@ struct _lowcore {
__u8exc_access_id;  /* 0x00a0 */
__u8per_access_id;  /* 0x00a1 */
__u8op_access_id;   /* 0x00a2 */
-   __u8ar_access_id;   /* 0x00a3 */
+   __u8ar_mode_id; /* 0x00a3 */
__u8pad_0x00a4[0x00a8-0x00a4];  /* 0x00a4 */
__u64   trans_exc_code; /* 0x00a8 */
__u64   monitor_code;   /* 0x00b0 */
diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
index e4c99a1..6a6b93a 100644
--- a/arch/s390/kernel/asm-offsets.c
+++ b/arch/s390/kernel/asm-offsets.c
@@ -92,7 +92,7 @@ int main(void)
DEFINE(__LC_PER_CAUSE, offsetof(struct _lowcore, per_perc_atmid));
DEFINE(__LC_PER_ADDRESS, offsetof(struct _lowcore, per_address));
DEFINE(__LC_PER_PAID, offsetof(struct _lowcore, per_access_id));
-   DEFINE(__LC_AR_MODE_ID, offsetof(struct _lowcore, ar_access_id));
+   DEFINE(__LC_AR_MODE_ID, offsetof(struct _lowcore, ar_mode_id));
DEFINE(__LC_SUBCHANNEL_ID, offsetof(struct _lowcore, subchannel_id));
DEFINE(__LC_SUBCHANNEL_NR, offsetof(struct _lowcore, subchannel_nr));
DEFINE(__LC_IO_INT_PARM, offsetof(struct _lowcore, io_int_parm));
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PULL 1/2] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-04-09 Thread Christian Borntraeger
From: Alexander Yarygin 

Trace events potentially can have a '-' in their trace system name,
e.g. kvm on s390 defines kvm-s390:* tracepoints.
tools/perf could not parse them, because there was no rule for this:
$ sudo ./perf top -e "kvm-s390:*"
invalid or unsupported event: 'kvm-s390:*'

This patch allows '-' to be a part of PE_NAME token, so tracepoints
with '-' can be parsed by the event_legacy_tracepoint rule.
Without the patch, perf will not accept such tracepoints in the -e
option.

Signed-off-by: Alexander Yarygin 
Signed-off-by: Christian Borntraeger 
---
 tools/perf/util/parse-events.l |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index 3432995..ca20da7 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -199,7 +199,7 @@ r{num_raw_hex}  { return raw(yyscanner); }
 {num_hex}  { return value(yyscanner, 16); }
 
 {modifier_event}   { return str(yyscanner, PE_MODIFIER_EVENT); }
-{name} { return str(yyscanner, PE_NAME); }
+{name_minus}   { return str(yyscanner, PE_NAME); }
 "/"{ BEGIN(config); return '/'; }
 -  { return '-'; }
 ,  { BEGIN(event); return ','; }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-03-27 Thread Christian Borntraeger
On 27/03/14 09:27, Alexander Yarygin wrote:
> 
> Trace events potentially can have a '-' in their trace system name,
> e.g. kvm on s390 defines kvm-s390:* tracepoints.
> tools/perf could not parse them, because there was no rule for this:
> $ sudo ./perf top -e "kvm-s390:*"
> invalid or unsupported event: 'kvm-s390:*'
> 
> This patch allows to '-' to be a part of PE_NAME token, so tracepoints
> with '-' can be parsed by the event_legacy_tracepoint rule.
> Without the patch, perf will not accept such tracepoints in the -e
> option.
> 
> Signed-off-by: Alexander Yarygin 
> Signed-off-by: Christian Borntraeger 

When doing a V2, you should remove my Signed-off-by. ;-)



But at least we can now add my
Acked-by: Christian Borntraeger 


Ingo, Peter, Paul,

If you agree with this solution, I would like to have this in the next merge 
window - maybe 
cc stable if we consider perf stable relevant.

Christian


> ---
>  tools/perf/util/parse-events.l |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
> index 3432995..ca20da7 100644
> --- a/tools/perf/util/parse-events.l
> +++ b/tools/perf/util/parse-events.l
> @@ -199,7 +199,7 @@ r{num_raw_hex}{ return raw(yyscanner); }
>  {num_hex}{ return value(yyscanner, 16); }
> 
>  {modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); }
> -{name}   { return str(yyscanner, PE_NAME); }
> +{name_minus} { return str(yyscanner, PE_NAME); }
>  "/"  { BEGIN(config); return '/'; }
>  -{ return '-'; }
>  ,{ BEGIN(event); return ','; }
> 

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-03-25 Thread Paolo Bonzini

Il 24/03/2014 21:49, Christian Borntraeger ha scritto:

 event_legacy_tracepoint:
+PE_NAME '-' PE_NAME ':' PE_NAME
+{
+   struct parse_events_evlist *data = _data;
+   struct list_head *list;
+   char sys_name[strlen($1) + strlen($3) + 2];
+   sprintf(&sys_name, "%s-%s", $1, $3);
+
+   ALLOC_LIST(list);
+   ABORT_ON(parse_events_add_tracepoint(list, &data->idx, &sys_name, $5));
+   $$ = list;
+}


Why isn't '-' part of PE_NAME?

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] perf/tool: Fix usage of trace events with '-' in trace system name.

2014-03-24 Thread Christian Borntraeger
From: Alexander Yarygin 

Trace events potentially can have a '-' in their trace system name,
e.g. kvm on s390 defines kvm-s390:* tracepoints.
tools/perf could not parse them, because there was no rule for this:
$ sudo ./perf top -e "kvm-s390:*"
invalid or unsupported event: 'kvm-s390:*'

This patch adds an extra rule to event_legacy_tracepoint which handles
those cases. Without the patch, perf will not accept such tracepoints in
the -e option.

Signed-off-by: Alexander Yarygin 
Signed-off-by: Christian Borntraeger 
---
 tools/perf/util/parse-events.y | 12 
 1 file changed, 12 insertions(+)

diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 4eb67ec..dbbb01c 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -299,6 +299,18 @@ PE_PREFIX_MEM PE_VALUE sep_dc
 }
 
 event_legacy_tracepoint:
+PE_NAME '-' PE_NAME ':' PE_NAME
+{
+   struct parse_events_evlist *data = _data;
+   struct list_head *list;
+   char sys_name[strlen($1) + strlen($3) + 2];
+   sprintf(&sys_name, "%s-%s", $1, $3);
+
+   ALLOC_LIST(list);
+   ABORT_ON(parse_events_add_tracepoint(list, &data->idx, &sys_name, $5));
+   $$ = list;
+}
+|
 PE_NAME ':' PE_NAME
 {
struct parse_events_evlist *data = _data;
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ARM: kvm: rename cpu_reset to avoid name clash

2013-09-24 Thread Christoffer Dall
From: Olof Johansson 

cpu_reset is already #defined in  as processor.reset,
so it expands here and causes problems.

Cc: 
Signed-off-by: Olof Johansson 
Signed-off-by: Christoffer Dall 
---
 arch/arm/kvm/reset.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kvm/reset.c b/arch/arm/kvm/reset.c
index 71e08ba..c02ba4a 100644
--- a/arch/arm/kvm/reset.c
+++ b/arch/arm/kvm/reset.c
@@ -58,14 +58,14 @@ static const struct kvm_irq_level a15_vtimer_irq = {
  */
 int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
 {
-   struct kvm_regs *cpu_reset;
+   struct kvm_regs *reset_regs;
const struct kvm_irq_level *cpu_vtimer_irq;
 
switch (vcpu->arch.target) {
case KVM_ARM_TARGET_CORTEX_A15:
if (vcpu->vcpu_id > a15_max_cpu_idx)
return -EINVAL;
-   cpu_reset = &a15_regs_reset;
+   reset_regs = &a15_regs_reset;
vcpu->arch.midr = read_cpuid_id();
cpu_vtimer_irq = &a15_vtimer_irq;
break;
@@ -74,7 +74,7 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
}
 
/* Reset core registers */
-   memcpy(&vcpu->arch.regs, cpu_reset, sizeof(vcpu->arch.regs));
+   memcpy(&vcpu->arch.regs, reset_regs, sizeof(vcpu->arch.regs));
 
/* Reset CP15 registers */
kvm_reset_coprocs(vcpu);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: kvm: rename cpu_reset to avoid name clash

2013-09-23 Thread Christoffer Dall
On Mon, Sep 23, 2013 at 09:30:42PM +0100, Russell King - ARM Linux wrote:
> On Mon, Sep 23, 2013 at 12:59:44PM -0700, Olof Johansson wrote:
> > Hi Christoffer,
> > 
> > On Mon, Sep 16, 2013 at 8:47 PM, Christoffer Dall
> >  wrote:
> > > On 16 September 2013 19:41, Olof Johansson  wrote:
> > >> Hi,
> > >>
> > >> On Wed, Sep 11, 2013 at 6:50 PM, Christoffer Dall
> > >>  wrote:
> > >>> On Wed, Sep 11, 2013 at 03:39:26PM -0700, Olof Johansson wrote:
> >  On Wed, Sep 11, 2013 at 3:27 PM, Olof Johansson  wrote:
> >  > cpu_reset is already #defined in  as processor.reset,
> >  > so it expands here and causes problems.
> >  >
> >  > Signed-off-by: Olof Johansson 
> > 
> >  I just noticed this is broken on 3.10 too, so if/when applying feel 
> >  free to add:
> > 
> >  Cc:  # 3.10+
> > 
> > >>> Thanks for the fix, applied.
> > >>
> > >> I haven't seen this hit linux-next yet?
> > >>
> > > I was waiting for kvm/next to move to 3.12-rc1 and base the patch for
> > > kvm-arm-next off there, but I pushed this to kvm-arm-next now and it
> > > should land in linux-next as soon as they update.
> > 
> > Another week has passed, and -next and mainline are both still broken.
> > Can we please see a fix in mainline and -next within the next few
> > days?
> 
> I'm getting failing builds too, which will only stop once it hits
> mainline.

Apologies about this, apparently linux-next doesn't pull in my tree despite
e-mail confirmation that it did.  I was away last week for LPC, but I'll
make sure this lands upstream ASAP.

-Christoffer
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: kvm: rename cpu_reset to avoid name clash

2013-09-23 Thread Russell King - ARM Linux
On Mon, Sep 23, 2013 at 12:59:44PM -0700, Olof Johansson wrote:
> Hi Christoffer,
> 
> On Mon, Sep 16, 2013 at 8:47 PM, Christoffer Dall
>  wrote:
> > On 16 September 2013 19:41, Olof Johansson  wrote:
> >> Hi,
> >>
> >> On Wed, Sep 11, 2013 at 6:50 PM, Christoffer Dall
> >>  wrote:
> >>> On Wed, Sep 11, 2013 at 03:39:26PM -0700, Olof Johansson wrote:
>  On Wed, Sep 11, 2013 at 3:27 PM, Olof Johansson  wrote:
>  > cpu_reset is already #defined in  as processor.reset,
>  > so it expands here and causes problems.
>  >
>  > Signed-off-by: Olof Johansson 
> 
>  I just noticed this is broken on 3.10 too, so if/when applying feel free 
>  to add:
> 
>  Cc:  # 3.10+
> 
> >>> Thanks for the fix, applied.
> >>
> >> I haven't seen this hit linux-next yet?
> >>
> > I was waiting for kvm/next to move to 3.12-rc1 and base the patch for
> > kvm-arm-next off there, but I pushed this to kvm-arm-next now and it
> > should land in linux-next as soon as they update.
> 
> Another week has passed, and -next and mainline are both still broken.
> Can we please see a fix in mainline and -next within the next few
> days?

I'm getting failing builds too, which will only stop once it hits
mainline.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: kvm: rename cpu_reset to avoid name clash

2013-09-23 Thread Olof Johansson
Hi Christoffer,

On Mon, Sep 16, 2013 at 8:47 PM, Christoffer Dall
 wrote:
> On 16 September 2013 19:41, Olof Johansson  wrote:
>> Hi,
>>
>> On Wed, Sep 11, 2013 at 6:50 PM, Christoffer Dall
>>  wrote:
>>> On Wed, Sep 11, 2013 at 03:39:26PM -0700, Olof Johansson wrote:
 On Wed, Sep 11, 2013 at 3:27 PM, Olof Johansson  wrote:
 > cpu_reset is already #defined in  as processor.reset,
 > so it expands here and causes problems.
 >
 > Signed-off-by: Olof Johansson 

 I just noticed this is broken on 3.10 too, so if/when applying feel free 
 to add:

 Cc:  # 3.10+

>>> Thanks for the fix, applied.
>>
>> I haven't seen this hit linux-next yet?
>>
> I was waiting for kvm/next to move to 3.12-rc1 and base the patch for
> kvm-arm-next off there, but I pushed this to kvm-arm-next now and it
> should land in linux-next as soon as they update.

Another week has passed, and -next and mainline are both still broken.
Can we please see a fix in mainline and -next within the next few
days?


-Olof
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: kvm: rename cpu_reset to avoid name clash

2013-09-16 Thread Christoffer Dall
On 16 September 2013 19:41, Olof Johansson  wrote:
> Hi,
>
> On Wed, Sep 11, 2013 at 6:50 PM, Christoffer Dall
>  wrote:
>> On Wed, Sep 11, 2013 at 03:39:26PM -0700, Olof Johansson wrote:
>>> On Wed, Sep 11, 2013 at 3:27 PM, Olof Johansson  wrote:
>>> > cpu_reset is already #defined in  as processor.reset,
>>> > so it expands here and causes problems.
>>> >
>>> > Signed-off-by: Olof Johansson 
>>>
>>> I just noticed this is broken on 3.10 too, so if/when applying feel free to 
>>> add:
>>>
>>> Cc:  # 3.10+
>>>
>> Thanks for the fix, applied.
>
> I haven't seen this hit linux-next yet?
>
I was waiting for kvm/next to move to 3.12-rc1 and base the patch for
kvm-arm-next off there, but I pushed this to kvm-arm-next now and it
should land in linux-next as soon as they update.

-Christoffer
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: kvm: rename cpu_reset to avoid name clash

2013-09-16 Thread Olof Johansson
Hi,

On Wed, Sep 11, 2013 at 6:50 PM, Christoffer Dall
 wrote:
> On Wed, Sep 11, 2013 at 03:39:26PM -0700, Olof Johansson wrote:
>> On Wed, Sep 11, 2013 at 3:27 PM, Olof Johansson  wrote:
>> > cpu_reset is already #defined in  as processor.reset,
>> > so it expands here and causes problems.
>> >
>> > Signed-off-by: Olof Johansson 
>>
>> I just noticed this is broken on 3.10 too, so if/when applying feel free to 
>> add:
>>
>> Cc:  # 3.10+
>>
> Thanks for the fix, applied.

I haven't seen this hit linux-next yet?


-Olof
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: kvm: rename cpu_reset to avoid name clash

2013-09-11 Thread Christoffer Dall
On Wed, Sep 11, 2013 at 03:39:26PM -0700, Olof Johansson wrote:
> On Wed, Sep 11, 2013 at 3:27 PM, Olof Johansson  wrote:
> > cpu_reset is already #defined in  as processor.reset,
> > so it expands here and causes problems.
> >
> > Signed-off-by: Olof Johansson 
> 
> I just noticed this is broken on 3.10 too, so if/when applying feel free to 
> add:
> 
> Cc:  # 3.10+
> 
Thanks for the fix, applied.

-Christoffer
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: kvm: rename cpu_reset to avoid name clash

2013-09-11 Thread Olof Johansson
On Wed, Sep 11, 2013 at 3:27 PM, Olof Johansson  wrote:
> cpu_reset is already #defined in  as processor.reset,
> so it expands here and causes problems.
>
> Signed-off-by: Olof Johansson 

I just noticed this is broken on 3.10 too, so if/when applying feel free to add:

Cc:  # 3.10+


-Olof
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ARM: kvm: rename cpu_reset to avoid name clash

2013-09-11 Thread Olof Johansson
cpu_reset is already #defined in  as processor.reset,
so it expands here and causes problems.

Signed-off-by: Olof Johansson 
---
 arch/arm/kvm/reset.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kvm/reset.c b/arch/arm/kvm/reset.c
index 71e08ba..c02ba4a 100644
--- a/arch/arm/kvm/reset.c
+++ b/arch/arm/kvm/reset.c
@@ -58,14 +58,14 @@ static const struct kvm_irq_level a15_vtimer_irq = {
  */
 int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
 {
-   struct kvm_regs *cpu_reset;
+   struct kvm_regs *reset_regs;
const struct kvm_irq_level *cpu_vtimer_irq;
 
switch (vcpu->arch.target) {
case KVM_ARM_TARGET_CORTEX_A15:
if (vcpu->vcpu_id > a15_max_cpu_idx)
return -EINVAL;
-   cpu_reset = &a15_regs_reset;
+   reset_regs = &a15_regs_reset;
vcpu->arch.midr = read_cpuid_id();
cpu_vtimer_irq = &a15_vtimer_irq;
break;
@@ -74,7 +74,7 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
}
 
/* Reset core registers */
-   memcpy(&vcpu->arch.regs, cpu_reset, sizeof(vcpu->arch.regs));
+   memcpy(&vcpu->arch.regs, reset_regs, sizeof(vcpu->arch.regs));
 
/* Reset CP15 registers */
kvm_reset_coprocs(vcpu);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: mod filenames != modnames? (inconsistent name changing)

2013-06-15 Thread Rusty Russell
Linda Walsh  writes:
> Should we have any expectation that a module name and it's filename
> should be equivalent?
>
> I was writing an auto-complete script for modprobe so it wouldn't give
> me the option to double load a module (I'd have to manually type it in if
> I really wanted it).
>
> Trouble is some modules with names w/underscores ('_') change
> register their names with a 'dash'.

But modprobe kvm_intel already works.  Just convert any - to _?

> Would it be too much trouble to ask that the same names be used in
> both places?

Well, you could get kernel developers to rename their files with
underscores.  I've CC'd them.

We use _ because we turn the module names into identifiers; it's also
the most common choice, and having both is just confusing.

> I have about 30 modules loaded now and out of that list,
> 2 are name changes:
>
> acpi_cpufreq  (filename acip-cpufreq.ko)
> kvm_intel (filename kvm-intel.ko)
>
> If I load a bunch more... I find more that change names.
>
> Could the naming in the modules that do this be made consistent?
>
> Not doing so makes automatically tying a mod-name to it's file
> tend toward being non-deterministic.
>
> Many modules use '-' or '_' without being confused.
> It would be helpful if the few confused modules could
> get their identity straight.  Is there a problem with
> making these names consistent?

It shouldn't break anything to rename them, if there's consensus I'm
happy to create a patch.

Cheers,
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 3/6] mips/kvm: Fix name of gpr field in struct kvm_regs.

2013-05-23 Thread David Daney
From: David Daney 

Signed-off-by: David Daney 
Acked-by: Sanjay Lal 
---
 arch/mips/include/uapi/asm/kvm.h | 3 ++-
 arch/mips/kvm/kvm_mips.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/mips/include/uapi/asm/kvm.h b/arch/mips/include/uapi/asm/kvm.h
index 86812fb..d145ead 100644
--- a/arch/mips/include/uapi/asm/kvm.h
+++ b/arch/mips/include/uapi/asm/kvm.h
@@ -26,7 +26,8 @@
  * extended to 64-bits.
  */
 struct kvm_regs {
-   __u64 gprs[32];
+   /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
+   __u64 gpr[32];
__u64 hi;
__u64 lo;
__u64 pc;
diff --git a/arch/mips/kvm/kvm_mips.c b/arch/mips/kvm/kvm_mips.c
index e0dad02..93da750 100644
--- a/arch/mips/kvm/kvm_mips.c
+++ b/arch/mips/kvm/kvm_mips.c
@@ -678,7 +678,7 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, 
struct kvm_regs *regs)
int i;
 
for (i = 0; i < 32; i++)
-   vcpu->arch.gprs[i] = regs->gprs[i];
+   vcpu->arch.gprs[i] = regs->gpr[i];
 
vcpu->arch.hi = regs->hi;
vcpu->arch.lo = regs->lo;
@@ -692,7 +692,7 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, 
struct kvm_regs *regs)
int i;
 
for (i = 0; i < 32; i++)
-   regs->gprs[i] = vcpu->arch.gprs[i];
+   regs->gpr[i] = vcpu->arch.gprs[i];
 
regs->hi = vcpu->arch.hi;
regs->lo = vcpu->arch.lo;
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 3/6] mips/kvm: Fix name of gpr field in struct kvm_regs.

2013-05-22 Thread David Daney
From: David Daney 

Signed-off-by: David Daney 
---
 arch/mips/include/asm/kvm.h | 3 ++-
 arch/mips/kvm/kvm_mips.c| 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/mips/include/asm/kvm.h b/arch/mips/include/asm/kvm.h
index 86812fb..d145ead 100644
--- a/arch/mips/include/asm/kvm.h
+++ b/arch/mips/include/asm/kvm.h
@@ -26,7 +26,8 @@
  * extended to 64-bits.
  */
 struct kvm_regs {
-   __u64 gprs[32];
+   /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
+   __u64 gpr[32];
__u64 hi;
__u64 lo;
__u64 pc;
diff --git a/arch/mips/kvm/kvm_mips.c b/arch/mips/kvm/kvm_mips.c
index e0dad02..93da750 100644
--- a/arch/mips/kvm/kvm_mips.c
+++ b/arch/mips/kvm/kvm_mips.c
@@ -678,7 +678,7 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, 
struct kvm_regs *regs)
int i;
 
for (i = 0; i < 32; i++)
-   vcpu->arch.gprs[i] = regs->gprs[i];
+   vcpu->arch.gprs[i] = regs->gpr[i];
 
vcpu->arch.hi = regs->hi;
vcpu->arch.lo = regs->lo;
@@ -692,7 +692,7 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, 
struct kvm_regs *regs)
int i;
 
for (i = 0; i < 32; i++)
-   regs->gprs[i] = vcpu->arch.gprs[i];
+   regs->gpr[i] = vcpu->arch.gprs[i];
 
regs->hi = vcpu->arch.hi;
regs->lo = vcpu->arch.lo;
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 3/6] mips/kvm: Fix name of gpr field in struct kvm_regs.

2013-05-21 Thread David Daney
From: David Daney 

Signed-off-by: David Daney 
---
 arch/mips/include/asm/kvm.h | 3 ++-
 arch/mips/kvm/kvm_mips.c| 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/mips/include/asm/kvm.h b/arch/mips/include/asm/kvm.h
index 86812fb..d145ead 100644
--- a/arch/mips/include/asm/kvm.h
+++ b/arch/mips/include/asm/kvm.h
@@ -26,7 +26,8 @@
  * extended to 64-bits.
  */
 struct kvm_regs {
-   __u64 gprs[32];
+   /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
+   __u64 gpr[32];
__u64 hi;
__u64 lo;
__u64 pc;
diff --git a/arch/mips/kvm/kvm_mips.c b/arch/mips/kvm/kvm_mips.c
index e0dad02..93da750 100644
--- a/arch/mips/kvm/kvm_mips.c
+++ b/arch/mips/kvm/kvm_mips.c
@@ -678,7 +678,7 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, 
struct kvm_regs *regs)
int i;
 
for (i = 0; i < 32; i++)
-   vcpu->arch.gprs[i] = regs->gprs[i];
+   vcpu->arch.gprs[i] = regs->gpr[i];
 
vcpu->arch.hi = regs->hi;
vcpu->arch.lo = regs->lo;
@@ -692,7 +692,7 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, 
struct kvm_regs *regs)
int i;
 
for (i = 0; i < 32; i++)
-   regs->gprs[i] = vcpu->arch.gprs[i];
+   regs->gpr[i] = vcpu->arch.gprs[i];
 
regs->hi = vcpu->arch.hi;
regs->lo = vcpu->arch.lo;
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/5] mips/kvm: Fix name of gpr field in struct kvm_regs.

2013-05-20 Thread David Daney
From: David Daney 

Signed-off-by: David Daney 
---
 arch/mips/include/asm/kvm.h | 3 ++-
 arch/mips/kvm/kvm_mips.c| 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/mips/include/asm/kvm.h b/arch/mips/include/asm/kvm.h
index 86812fb..d145ead 100644
--- a/arch/mips/include/asm/kvm.h
+++ b/arch/mips/include/asm/kvm.h
@@ -26,7 +26,8 @@
  * extended to 64-bits.
  */
 struct kvm_regs {
-   __u64 gprs[32];
+   /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
+   __u64 gpr[32];
__u64 hi;
__u64 lo;
__u64 pc;
diff --git a/arch/mips/kvm/kvm_mips.c b/arch/mips/kvm/kvm_mips.c
index e0dad02..93da750 100644
--- a/arch/mips/kvm/kvm_mips.c
+++ b/arch/mips/kvm/kvm_mips.c
@@ -678,7 +678,7 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, 
struct kvm_regs *regs)
int i;
 
for (i = 0; i < 32; i++)
-   vcpu->arch.gprs[i] = regs->gprs[i];
+   vcpu->arch.gprs[i] = regs->gpr[i];
 
vcpu->arch.hi = regs->hi;
vcpu->arch.lo = regs->lo;
@@ -692,7 +692,7 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, 
struct kvm_regs *regs)
int i;
 
for (i = 0; i < 32; i++)
-   regs->gprs[i] = vcpu->arch.gprs[i];
+   regs->gpr[i] = vcpu->arch.gprs[i];
 
regs->hi = vcpu->arch.hi;
regs->lo = vcpu->arch.lo;
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 09/11] kvm tools: 8250: add address qualifier to uart name in fdt node

2013-05-01 Thread Will Deacon
From: Marc Zyngier 

Having several uarts with the same name makes the kernel (and dtc)
choke. Add the base address as a qualifier so we get unique names.

Signed-off-by: Marc Zyngier 
Signed-off-by: Will Deacon 
---
 tools/kvm/hw/serial.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/hw/serial.c b/tools/kvm/hw/serial.c
index 523a767..931067f 100644
--- a/tools/kvm/hw/serial.c
+++ b/tools/kvm/hw/serial.c
@@ -374,17 +374,22 @@ static bool serial8250_in(struct ioport *ioport, struct 
kvm *kvm, u16 port, void
 }
 
 #ifdef CONFIG_HAS_LIBFDT
+#define DEVICE_NAME_MAX_LEN 32
 static void serial8250_generate_fdt_node(struct ioport *ioport, void *fdt,
 void (*generate_irq_prop)(void *fdt,
   u8 irq))
 {
+   char dev_name[DEVICE_NAME_MAX_LEN];
struct serial8250_device *dev = ioport->priv;
+   u64 addr = KVM_IOPORT_AREA + dev->iobase;
u64 reg_prop[] = {
-   cpu_to_fdt64(KVM_IOPORT_AREA + dev->iobase),
+   cpu_to_fdt64(addr),
cpu_to_fdt64(8),
};
 
-   _FDT(fdt_begin_node(fdt, "U6_16550A"));
+   snprintf(dev_name, DEVICE_NAME_MAX_LEN, "U6_16550A@%llx", addr);
+
+   _FDT(fdt_begin_node(fdt, dev_name));
_FDT(fdt_property_string(fdt, "compatible", "ns16550a"));
_FDT(fdt_property(fdt, "reg", reg_prop, sizeof(reg_prop)));
generate_irq_prop(fdt, dev->irq);
-- 
1.8.0

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 RESEND 14/22] tap: introduce a helper to get the name of an interface

2013-01-31 Thread Jason Wang
This patch introduces a helper tap_get_ifname() to get the device name of tap
device. This is needed when ifname is unspecified in the command line and qemu
were asked to create tap device by itself. In this situation, the name were
allocated by kernel, so if multiqueue is asked, we need to fetch its name after
creating the first queue.

Only linux has this support since it's the only platform that supports
multiqueue tap.

Signed-off-by: Jason Wang 
Signed-off-by: Michael S. Tsirkin 
---
 include/net/tap.h |1 +
 net/tap-aix.c |5 +
 net/tap-bsd.c |5 +
 net/tap-haiku.c   |5 +
 net/tap-linux.c   |   14 ++
 net/tap-solaris.c |5 +
 net/tap_int.h |1 +
 7 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/include/net/tap.h b/include/net/tap.h
index a994f20..c3eb85a 100644
--- a/include/net/tap.h
+++ b/include/net/tap.h
@@ -37,6 +37,7 @@ void tap_set_offload(NetClientState *nc, int csum, int tso4, 
int tso6, int ecn,
 void tap_set_vnet_hdr_len(NetClientState *nc, int len);
 int tap_enable(NetClientState *nc);
 int tap_disable(NetClientState *nc);
+int tap_get_ifname(NetClientState *nc, char *ifname);
 
 int tap_get_fd(NetClientState *nc);
 
diff --git a/net/tap-aix.c b/net/tap-aix.c
index 66e0574..0e1eac3 100644
--- a/net/tap-aix.c
+++ b/net/tap-aix.c
@@ -69,3 +69,8 @@ int tap_fd_disable(int fd)
 {
 return -1;
 }
+
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index 5ed2d16..4f22109 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -155,3 +155,8 @@ int tap_fd_disable(int fd)
 {
 return -1;
 }
+
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
diff --git a/net/tap-haiku.c b/net/tap-haiku.c
index 0f1b1fe..b3b5fbb 100644
--- a/net/tap-haiku.c
+++ b/net/tap-haiku.c
@@ -69,3 +69,8 @@ int tap_fd_disable(int fd)
 {
 return -1;
 }
+
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
diff --git a/net/tap-linux.c b/net/tap-linux.c
index 42376cc..3b21662 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -260,3 +260,17 @@ int tap_fd_disable(int fd)
 
 return ret;
 }
+
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+struct ifreq ifr;
+
+if (ioctl(fd, TUNGETIFF, &ifr) != 0) {
+error_report("TUNGETIFF ioctl() failed: %s",
+ strerror(errno));
+return -1;
+}
+
+pstrcpy(ifname, sizeof(ifr.ifr_name), ifr.ifr_name);
+return 0;
+}
diff --git a/net/tap-solaris.c b/net/tap-solaris.c
index cc08e9e..214d95e 100644
--- a/net/tap-solaris.c
+++ b/net/tap-solaris.c
@@ -235,3 +235,8 @@ int tap_fd_disable(int fd)
 {
 return -1;
 }
+
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
diff --git a/net/tap_int.h b/net/tap_int.h
index ca1c21b..125f83d 100644
--- a/net/tap_int.h
+++ b/net/tap_int.h
@@ -44,5 +44,6 @@ void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, 
int ecn, int ufo);
 void tap_fd_set_vnet_hdr_len(int fd, int len);
 int tap_fd_enable(int fd);
 int tap_fd_disable(int fd);
+int tap_fd_get_ifname(int fd, char *ifname);
 
 #endif /* QEMU_TAP_H */
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 14/22] tap: introduce a helper to get the name of an interface

2013-01-30 Thread Jason Wang
This patch introduces a helper tap_get_ifname() to get the device name of tap
device. This is needed when ifname is unspecified in the command line and qemu
were asked to create tap device by itself. In this situation, the name were
allocated by kernel, so if multiqueue is asked, we need to fetch its name after
creating the first queue.

Only linux has this support since it's the only platform that supports
multiqueue tap.

Signed-off-by: Jason Wang 
---
 include/net/tap.h |1 +
 net/tap-aix.c |6 ++
 net/tap-bsd.c |4 
 net/tap-haiku.c   |4 
 net/tap-linux.c   |   13 +
 net/tap-solaris.c |4 
 net/tap_int.h |1 +
 7 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/include/net/tap.h b/include/net/tap.h
index a994f20..c3eb85a 100644
--- a/include/net/tap.h
+++ b/include/net/tap.h
@@ -37,6 +37,7 @@ void tap_set_offload(NetClientState *nc, int csum, int tso4, 
int tso6, int ecn,
 void tap_set_vnet_hdr_len(NetClientState *nc, int len);
 int tap_enable(NetClientState *nc);
 int tap_disable(NetClientState *nc);
+int tap_get_ifname(NetClientState *nc, char *ifname);
 
 int tap_get_fd(NetClientState *nc);
 
diff --git a/net/tap-aix.c b/net/tap-aix.c
index 66e0574..e760e9a 100644
--- a/net/tap-aix.c
+++ b/net/tap-aix.c
@@ -69,3 +69,9 @@ int tap_fd_disable(int fd)
 {
 return -1;
 }
+
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
+
diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index cfc7a28..4f22109 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -156,3 +156,7 @@ int tap_fd_disable(int fd)
 return -1;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
diff --git a/net/tap-haiku.c b/net/tap-haiku.c
index 664d40f..b3b5fbb 100644
--- a/net/tap-haiku.c
+++ b/net/tap-haiku.c
@@ -70,3 +70,7 @@ int tap_fd_disable(int fd)
 return -1;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
diff --git a/net/tap-linux.c b/net/tap-linux.c
index bdb0a79..3b21662 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -261,3 +261,16 @@ int tap_fd_disable(int fd)
 return ret;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+struct ifreq ifr;
+
+if (ioctl(fd, TUNGETIFF, &ifr) != 0) {
+error_report("TUNGETIFF ioctl() failed: %s",
+ strerror(errno));
+return -1;
+}
+
+pstrcpy(ifname, sizeof(ifr.ifr_name), ifr.ifr_name);
+return 0;
+}
diff --git a/net/tap-solaris.c b/net/tap-solaris.c
index 12cc392..214d95e 100644
--- a/net/tap-solaris.c
+++ b/net/tap-solaris.c
@@ -236,3 +236,7 @@ int tap_fd_disable(int fd)
 return -1;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
diff --git a/net/tap_int.h b/net/tap_int.h
index ca1c21b..125f83d 100644
--- a/net/tap_int.h
+++ b/net/tap_int.h
@@ -44,5 +44,6 @@ void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, 
int ecn, int ufo);
 void tap_fd_set_vnet_hdr_len(int fd, int len);
 int tap_fd_enable(int fd);
 int tap_fd_disable(int fd);
+int tap_fd_get_ifname(int fd, char *ifname);
 
 #endif /* QEMU_TAP_H */
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 12/20] tap: introduce a helper to get the name of an interface

2013-01-29 Thread Jason Wang
This patch introduces a helper tap_get_ifname() to get the device name of tap
device. This is needed when ifname is unspecified in the command line and qemu
were asked to create tap device by itself. In this situation, the name were
allocated by kernel, so if multiqueue is asked, we need to fetch its name after
creating the first queue.

Only linux has this support since it's the only platform that supports
multiqueue tap.

Signed-off-by: Jason Wang 
---
 include/net/tap.h |1 +
 net/tap-aix.c |6 ++
 net/tap-bsd.c |4 
 net/tap-haiku.c   |4 
 net/tap-linux.c   |   13 +
 net/tap-solaris.c |4 
 net/tap_int.h |1 +
 7 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/include/net/tap.h b/include/net/tap.h
index 0caf8c4..c523ff0 100644
--- a/include/net/tap.h
+++ b/include/net/tap.h
@@ -37,6 +37,7 @@ void tap_set_offload(NetClientState *nc, int csum, int tso4, 
int tso6, int ecn,
 void tap_set_vnet_hdr_len(NetClientState *nc, int len);
 int tap_enable(NetClientState *nc);
 int tap_disable(NetClientState *nc);
+int tap_get_ifname(NetClientState *nc, char *ifname);
 
 int tap_get_fd(NetClientState *nc);
 
diff --git a/net/tap-aix.c b/net/tap-aix.c
index 66e0574..e760e9a 100644
--- a/net/tap-aix.c
+++ b/net/tap-aix.c
@@ -69,3 +69,9 @@ int tap_fd_disable(int fd)
 {
 return -1;
 }
+
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
+
diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index cfc7a28..4f22109 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -156,3 +156,7 @@ int tap_fd_disable(int fd)
 return -1;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
diff --git a/net/tap-haiku.c b/net/tap-haiku.c
index 664d40f..b3b5fbb 100644
--- a/net/tap-haiku.c
+++ b/net/tap-haiku.c
@@ -70,3 +70,7 @@ int tap_fd_disable(int fd)
 return -1;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
diff --git a/net/tap-linux.c b/net/tap-linux.c
index 60ea8d0..6827c2a 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -261,3 +261,16 @@ int tap_fd_disable(int fd)
 return ret;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+struct ifreq ifr;
+
+if (ioctl(fd, TUNGETIFF, &ifr) != 0) {
+error_report("TUNGETIFF ioctl() failed: %s",
+ strerror(errno));
+return -1;
+}
+
+pstrcpy(ifname, sizeof(ifr.ifr_name), ifr.ifr_name);
+return 0;
+}
diff --git a/net/tap-solaris.c b/net/tap-solaris.c
index 12cc392..214d95e 100644
--- a/net/tap-solaris.c
+++ b/net/tap-solaris.c
@@ -236,3 +236,7 @@ int tap_fd_disable(int fd)
 return -1;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
diff --git a/net/tap_int.h b/net/tap_int.h
index ca1c21b..125f83d 100644
--- a/net/tap_int.h
+++ b/net/tap_int.h
@@ -44,5 +44,6 @@ void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, 
int ecn, int ufo);
 void tap_fd_set_vnet_hdr_len(int fd, int len);
 int tap_fd_enable(int fd);
 int tap_fd_disable(int fd);
+int tap_fd_get_ifname(int fd, char *ifname);
 
 #endif /* QEMU_TAP_H */
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 12/20] tap: introduce a helper to get the name of an interface

2013-01-25 Thread Jason Wang
This patch introduces a helper tap_get_ifname() to get the device name of tap
device. This is needed when ifname is unspecified in the command line and qemu
were asked to create tap device by itself. In this situation, the name were
allocated by kernel, so if multiqueue is asked, we need to fetch its name after
creating the first queue.

Only linux has this support since it's the only platform that supports
multiqueue tap.

Signed-off-by: Jason Wang 
---
 include/net/tap.h |1 +
 net/tap-aix.c |6 ++
 net/tap-bsd.c |4 
 net/tap-haiku.c   |4 
 net/tap-linux.c   |   13 +
 net/tap-solaris.c |4 
 net/tap_int.h |1 +
 7 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/include/net/tap.h b/include/net/tap.h
index 0caf8c4..c523ff0 100644
--- a/include/net/tap.h
+++ b/include/net/tap.h
@@ -37,6 +37,7 @@ void tap_set_offload(NetClientState *nc, int csum, int tso4, 
int tso6, int ecn,
 void tap_set_vnet_hdr_len(NetClientState *nc, int len);
 int tap_enable(NetClientState *nc);
 int tap_disable(NetClientState *nc);
+int tap_get_ifname(NetClientState *nc, char *ifname);
 
 int tap_get_fd(NetClientState *nc);
 
diff --git a/net/tap-aix.c b/net/tap-aix.c
index 66e0574..e760e9a 100644
--- a/net/tap-aix.c
+++ b/net/tap-aix.c
@@ -69,3 +69,9 @@ int tap_fd_disable(int fd)
 {
 return -1;
 }
+
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
+
diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index cfc7a28..4f22109 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -156,3 +156,7 @@ int tap_fd_disable(int fd)
 return -1;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
diff --git a/net/tap-haiku.c b/net/tap-haiku.c
index 664d40f..b3b5fbb 100644
--- a/net/tap-haiku.c
+++ b/net/tap-haiku.c
@@ -70,3 +70,7 @@ int tap_fd_disable(int fd)
 return -1;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
diff --git a/net/tap-linux.c b/net/tap-linux.c
index 60ea8d0..6827c2a 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -261,3 +261,16 @@ int tap_fd_disable(int fd)
 return ret;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+struct ifreq ifr;
+
+if (ioctl(fd, TUNGETIFF, &ifr) != 0) {
+error_report("TUNGETIFF ioctl() failed: %s",
+ strerror(errno));
+return -1;
+}
+
+pstrcpy(ifname, sizeof(ifr.ifr_name), ifr.ifr_name);
+return 0;
+}
diff --git a/net/tap-solaris.c b/net/tap-solaris.c
index 12cc392..214d95e 100644
--- a/net/tap-solaris.c
+++ b/net/tap-solaris.c
@@ -236,3 +236,7 @@ int tap_fd_disable(int fd)
 return -1;
 }
 
+int tap_fd_get_ifname(int fd, char *ifname)
+{
+return -1;
+}
diff --git a/net/tap_int.h b/net/tap_int.h
index ca1c21b..125f83d 100644
--- a/net/tap_int.h
+++ b/net/tap_int.h
@@ -44,5 +44,6 @@ void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, 
int ecn, int ufo);
 void tap_fd_set_vnet_hdr_len(int fd, int len);
 int tap_fd_enable(int fd);
 int tap_fd_disable(int fd);
+int tap_fd_get_ifname(int fd, char *ifname);
 
 #endif /* QEMU_TAP_H */
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Qemu-devel] [PATCH qom-cpu 6/7] target-i386/cpu.c: Add feature name array for ext4_features

2013-01-10 Thread Andreas Färber
Am 07.01.2013 19:20, schrieb Eduardo Habkost:
> Feature names were taken from the X86_FEATURE_* constants in the Linux
> kernel code.
> 
> Signed-off-by: Eduardo Habkost 
> ---
> Cc: Gleb Natapov 
> ---
>  target-i386/cpu.c | 17 +
>  1 file changed, 17 insertions(+)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 4b3ee63..a54c464 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -95,6 +95,17 @@ static const char *ext3_feature_name[] = {
>  NULL, NULL, NULL, NULL,
>  };
>  
> +static const char *ext4_feature_name[] = {
> +NULL, NULL, "xstore","xstore-en",
> +NULL, NULL, "xcrypt","xcrypt-en",

Missing spaces, fixed.

Andreas

> +"ace2", "ace2-en", "phe", "phe-en",
> +"pmm", "pmm-en", NULL, NULL,
> +NULL, NULL, NULL, NULL,
> +NULL, NULL, NULL, NULL,
> +NULL, NULL, NULL, NULL,
> +NULL, NULL, NULL, NULL,
> +};
> +
>  static const char *kvm_feature_name[] = {
>  "kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock",
>  "kvm_asyncpf", "kvm_steal_time", "kvm_pv_eoi", NULL,
[snip]

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH qom-cpu 6/7] target-i386/cpu.c: Add feature name array for ext4_features

2013-01-07 Thread Eduardo Habkost
Feature names were taken from the X86_FEATURE_* constants in the Linux
kernel code.

Signed-off-by: Eduardo Habkost 
---
Cc: Gleb Natapov 
---
 target-i386/cpu.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 4b3ee63..a54c464 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -95,6 +95,17 @@ static const char *ext3_feature_name[] = {
 NULL, NULL, NULL, NULL,
 };
 
+static const char *ext4_feature_name[] = {
+NULL, NULL, "xstore","xstore-en",
+NULL, NULL, "xcrypt","xcrypt-en",
+"ace2", "ace2-en", "phe", "phe-en",
+"pmm", "pmm-en", NULL, NULL,
+NULL, NULL, NULL, NULL,
+NULL, NULL, NULL, NULL,
+NULL, NULL, NULL, NULL,
+NULL, NULL, NULL, NULL,
+};
+
 static const char *kvm_feature_name[] = {
 "kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock",
 "kvm_asyncpf", "kvm_steal_time", "kvm_pv_eoi", NULL,
@@ -147,6 +158,10 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
 .feat_names = ext3_feature_name,
 .cpuid_eax = 0x8001, .cpuid_reg = R_ECX,
 },
+[FEAT_C000_0001_EDX] = {
+.feat_names = ext4_feature_name,
+.cpuid_eax = 0xC001, .cpuid_reg = R_EDX,
+},
 [FEAT_KVM] = {
 .feat_names = kvm_feature_name,
 .cpuid_eax = KVM_CPUID_FEATURES, .cpuid_reg = R_EAX,
@@ -1412,6 +1427,7 @@ static int cpu_x86_parse_featurestr(x86_def_t 
*x86_cpu_def, char *features)
 x86_cpu_def->ext_features |= plus_features[FEAT_1_ECX];
 x86_cpu_def->ext2_features |= plus_features[FEAT_8000_0001_EDX];
 x86_cpu_def->ext3_features |= plus_features[FEAT_8000_0001_ECX];
+x86_cpu_def->ext4_features |= plus_features[FEAT_C000_0001_EDX];
 x86_cpu_def->kvm_features |= plus_features[FEAT_KVM];
 x86_cpu_def->svm_features |= plus_features[FEAT_SVM];
 x86_cpu_def->cpuid_7_0_ebx_features |= plus_features[FEAT_7_0_EBX];
@@ -1419,6 +1435,7 @@ static int cpu_x86_parse_featurestr(x86_def_t 
*x86_cpu_def, char *features)
 x86_cpu_def->ext_features &= ~minus_features[FEAT_1_ECX];
 x86_cpu_def->ext2_features &= ~minus_features[FEAT_8000_0001_EDX];
 x86_cpu_def->ext3_features &= ~minus_features[FEAT_8000_0001_ECX];
+x86_cpu_def->ext4_features &= ~minus_features[FEAT_C000_0001_EDX];
 x86_cpu_def->kvm_features &= ~minus_features[FEAT_KVM];
 x86_cpu_def->svm_features &= ~minus_features[FEAT_SVM];
 x86_cpu_def->cpuid_7_0_ebx_features &= ~minus_features[FEAT_7_0_EBX];
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] trace-cmd: fix kvm_mmu_prepare_zap_page even name and kvm_mmu_get_page event output in kvm plugin

2012-12-27 Thread Gleb Natapov
On Wed, Dec 26, 2012 at 09:22:32AM -0500, Steven Rostedt wrote:
> On Wed, 2012-12-26 at 16:13 +0200, Gleb Natapov wrote:
> > On Wed, Dec 26, 2012 at 08:58:30AM -0500, Steven Rostedt wrote:
> > > On Tue, 2012-12-25 at 13:46 +0200, Gleb Natapov wrote:
> > > > kvm_mmu_zap_page even was renamed to kvm_mmu_prepare_zap_page.
> > > > Print out created field for kvm_mmu_get_page event.
> > > 
> > > trace-cmd needs to be backward compatible with older kernels. If older
> > > kernels used kvm_mmu_zap_page, then please add a check for that and have
> > > the plugin cope with either one.
> > > 
> > Something like this?
> > 
> > if (pevent_find_event_by_name(pevent, "kvmmmu", 
> > "kvm_mmu_prepare_zap_page"))
> > pevent_register_event_handler(pevent, -1, "kvmmmu",
> > "kvm_mmu_prepare_zap_page", 
> > kvm_mmu_print_role,
> > NULL);
> > else
> > pevent_register_event_handler(pevent, -1, "kvmmmu",
> > "kvm_mmu_zap_page", kvm_mmu_print_role, 
> > NULL);
> 
> Sure, if it works.
> 
Well, it isn't and if it were it would have prevented tarce-cmd running
on new kernel from reading traces generated on older kernels. I will
register both.

> > 
> > Also when trace-cmd encounters an event it does not recognize it prints
> > mysterious message:
> > 
> > trace-cmd: No such file or directory
> >   bad op token {
> > 
> > Is this a bug?
> > 
> 
> Yes and no ;-)
> 
> I need to get rid of the "perror" part, for errors that don't set errno.
> That's been on my todo list for a long time. Maybe when I come back to
> work next week I'll fix that.
> 
> The 'bad op token {' happens when it tries to parse an event and it
> comes across something that it doesn't recognize. In this case a '{'.
> 
> The kvm events are notorious with having extremely complex "print_fmt"
> fields in their event format files. When no event handler is registered
> for an event, trace-cmd uses the print_fmt to figure out how to print
> it. This was never meant to be too complex of a parser. For example,
> looking at my kvm_mmu_prepare_zap_page, we have:
> 
> print fmt: "%s", ({ const char *ret = p->buffer + p->len; static const char 
> *access_str[] = 
> { "---", "--x", "w--", "w-x", "-u-", "-ux", "wu-", "wux" }; union 
> kvm_mmu_page_role role;
>  role.word = REC->role; trace_seq_printf(p, "sp gfn %llx %u%s q%u%s %s%s" " 
> %snxe root %u
>  %s%c", REC->gfn, role.level, role.cr4_pae ? " pae" : "", role.quadrant, 
> role.direct ? " 
> direct" : "", access_str[role.access], role.invalid ? " invalid" : "", 
> role.nxe ? "" : "!",
>  REC->root_count, REC->unsync ? "unsync" : "sync", 0); ret; })
> 
> trace-cmd has no idea on how to parse "({ const char *ret ..." in fact
> it dies on that first "{" because trace-cmd is not a full C parser.
> 
> This was why the plugins were created in the first place. To handle
> various events that have too complex print_fmts for trace-cmd to
> understand.
> 
> Most events are simple print_fmts and do not need plugins. Like
> sock_rcvqueue_full:
> 
> print fmt: "rmem_alloc=%d truesize=%u sk_rcvbuf=%d", REC->rmem_alloc,
> REC->truesize, REC->sk_rcvbuf
> 
> trace-cmd has no problem parsing events like that.
> 
Got it.

--
Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] trace-cmd: fix kvm_mmu_prepare_zap_page even name and kvm_mmu_get_page event output in kvm plugin

2012-12-26 Thread Steven Rostedt
On Wed, 2012-12-26 at 16:13 +0200, Gleb Natapov wrote:
> On Wed, Dec 26, 2012 at 08:58:30AM -0500, Steven Rostedt wrote:
> > On Tue, 2012-12-25 at 13:46 +0200, Gleb Natapov wrote:
> > > kvm_mmu_zap_page even was renamed to kvm_mmu_prepare_zap_page.
> > > Print out created field for kvm_mmu_get_page event.
> > 
> > trace-cmd needs to be backward compatible with older kernels. If older
> > kernels used kvm_mmu_zap_page, then please add a check for that and have
> > the plugin cope with either one.
> > 
> Something like this?
> 
> if (pevent_find_event_by_name(pevent, "kvmmmu", 
> "kvm_mmu_prepare_zap_page"))
> pevent_register_event_handler(pevent, -1, "kvmmmu",
> "kvm_mmu_prepare_zap_page", 
> kvm_mmu_print_role,
> NULL);
> else
> pevent_register_event_handler(pevent, -1, "kvmmmu",
> "kvm_mmu_zap_page", kvm_mmu_print_role, NULL);

Sure, if it works.

> 
> Also when trace-cmd encounters an event it does not recognize it prints
> mysterious message:
> 
> trace-cmd: No such file or directory
>   bad op token {
> 
> Is this a bug?
> 

Yes and no ;-)

I need to get rid of the "perror" part, for errors that don't set errno.
That's been on my todo list for a long time. Maybe when I come back to
work next week I'll fix that.

The 'bad op token {' happens when it tries to parse an event and it
comes across something that it doesn't recognize. In this case a '{'.

The kvm events are notorious with having extremely complex "print_fmt"
fields in their event format files. When no event handler is registered
for an event, trace-cmd uses the print_fmt to figure out how to print
it. This was never meant to be too complex of a parser. For example,
looking at my kvm_mmu_prepare_zap_page, we have:

print fmt: "%s", ({ const char *ret = p->buffer + p->len; static const char 
*access_str[] = 
{ "---", "--x", "w--", "w-x", "-u-", "-ux", "wu-", "wux" }; union 
kvm_mmu_page_role role;
 role.word = REC->role; trace_seq_printf(p, "sp gfn %llx %u%s q%u%s %s%s" " 
%snxe root %u
 %s%c", REC->gfn, role.level, role.cr4_pae ? " pae" : "", role.quadrant, 
role.direct ? " 
direct" : "", access_str[role.access], role.invalid ? " invalid" : "", role.nxe 
? "" : "!",
 REC->root_count, REC->unsync ? "unsync" : "sync", 0); ret; })

trace-cmd has no idea on how to parse "({ const char *ret ..." in fact
it dies on that first "{" because trace-cmd is not a full C parser.

This was why the plugins were created in the first place. To handle
various events that have too complex print_fmts for trace-cmd to
understand.

Most events are simple print_fmts and do not need plugins. Like
sock_rcvqueue_full:

print fmt: "rmem_alloc=%d truesize=%u sk_rcvbuf=%d", REC->rmem_alloc,
REC->truesize, REC->sk_rcvbuf

trace-cmd has no problem parsing events like that.

-- Steve


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] trace-cmd: fix kvm_mmu_prepare_zap_page even name and kvm_mmu_get_page event output in kvm plugin

2012-12-26 Thread Gleb Natapov
On Wed, Dec 26, 2012 at 08:58:30AM -0500, Steven Rostedt wrote:
> On Tue, 2012-12-25 at 13:46 +0200, Gleb Natapov wrote:
> > kvm_mmu_zap_page even was renamed to kvm_mmu_prepare_zap_page.
> > Print out created field for kvm_mmu_get_page event.
> 
> trace-cmd needs to be backward compatible with older kernels. If older
> kernels used kvm_mmu_zap_page, then please add a check for that and have
> the plugin cope with either one.
> 
Something like this?

if (pevent_find_event_by_name(pevent, "kvmmmu", 
"kvm_mmu_prepare_zap_page"))
pevent_register_event_handler(pevent, -1, "kvmmmu",
"kvm_mmu_prepare_zap_page", kvm_mmu_print_role,
NULL);
else
pevent_register_event_handler(pevent, -1, "kvmmmu",
"kvm_mmu_zap_page", kvm_mmu_print_role, NULL);

Also when trace-cmd encounters an event it does not recognize it prints
mysterious message:

trace-cmd: No such file or directory
  bad op token {

Is this a bug?

> Thanks,
> 
> -- Steve
> 
> > 
> > Signed-off-by: Gleb Natapov 
> > diff --git a/plugin_kvm.c b/plugin_kvm.c
> > index 55812ef..adc5694 100644
> > --- a/plugin_kvm.c
> > +++ b/plugin_kvm.c
> > @@ -382,7 +382,7 @@ static int kvm_mmu_print_role(struct trace_seq *s, 
> > struct pevent_record *record,
> > } else
> > trace_seq_printf(s, "WORD: %08x", role.word);
> >  
> > -   pevent_print_num_field(s, " root %u",  event,
> > +   pevent_print_num_field(s, " root %u ",  event,
> >"root_count", record, 1);
> >  
> > if (pevent_get_field_val(s, event, "unsync", record, &val, 1) < 0)
> > @@ -397,6 +397,11 @@ static int kvm_mmu_get_page_handler(struct trace_seq 
> > *s, struct pevent_record *r
> >  {
> > unsigned long long val;
> >  
> > +   if (pevent_get_field_val(s, event, "created", record, &val, 1) < 0)
> > +   return -1;
> > +
> > +   trace_seq_printf(s, "%s ", val ? "new" : "existing");
> > +
> > if (pevent_get_field_val(s, event, "gfn", record, &val, 1) < 0)
> > return -1;
> >  
> > @@ -430,7 +435,7 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
> > pevent_register_event_handler(pevent, -1, "kvmmmu", 
> > "kvm_mmu_unsync_page",
> >   kvm_mmu_print_role, NULL);
> >  
> > -   pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
> > +   pevent_register_event_handler(pevent, -1, "kvmmmu", 
> > "kvm_mmu_prepare_zap_page",
> >   kvm_mmu_print_role, NULL);
> >  
> > return 0;
> > --
> > Gleb.
> 

--
Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] trace-cmd: fix kvm_mmu_prepare_zap_page even name and kvm_mmu_get_page event output in kvm plugin

2012-12-26 Thread Steven Rostedt
On Tue, 2012-12-25 at 13:46 +0200, Gleb Natapov wrote:
> kvm_mmu_zap_page even was renamed to kvm_mmu_prepare_zap_page.
> Print out created field for kvm_mmu_get_page event.

trace-cmd needs to be backward compatible with older kernels. If older
kernels used kvm_mmu_zap_page, then please add a check for that and have
the plugin cope with either one.

Thanks,

-- Steve

> 
> Signed-off-by: Gleb Natapov 
> diff --git a/plugin_kvm.c b/plugin_kvm.c
> index 55812ef..adc5694 100644
> --- a/plugin_kvm.c
> +++ b/plugin_kvm.c
> @@ -382,7 +382,7 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct 
> pevent_record *record,
>   } else
>   trace_seq_printf(s, "WORD: %08x", role.word);
>  
> - pevent_print_num_field(s, " root %u",  event,
> + pevent_print_num_field(s, " root %u ",  event,
>  "root_count", record, 1);
>  
>   if (pevent_get_field_val(s, event, "unsync", record, &val, 1) < 0)
> @@ -397,6 +397,11 @@ static int kvm_mmu_get_page_handler(struct trace_seq *s, 
> struct pevent_record *r
>  {
>   unsigned long long val;
>  
> + if (pevent_get_field_val(s, event, "created", record, &val, 1) < 0)
> + return -1;
> +
> + trace_seq_printf(s, "%s ", val ? "new" : "existing");
> +
>   if (pevent_get_field_val(s, event, "gfn", record, &val, 1) < 0)
>   return -1;
>  
> @@ -430,7 +435,7 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
>   pevent_register_event_handler(pevent, -1, "kvmmmu", 
> "kvm_mmu_unsync_page",
> kvm_mmu_print_role, NULL);
>  
> - pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
> + pevent_register_event_handler(pevent, -1, "kvmmmu", 
> "kvm_mmu_prepare_zap_page",
> kvm_mmu_print_role, NULL);
>  
>   return 0;
> --
>   Gleb.


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] trace-cmd: fix kvm_mmu_prepare_zap_page even name and kvm_mmu_get_page event output in kvm plugin

2012-12-25 Thread Gleb Natapov
kvm_mmu_zap_page even was renamed to kvm_mmu_prepare_zap_page.
Print out created field for kvm_mmu_get_page event.

Signed-off-by: Gleb Natapov 
diff --git a/plugin_kvm.c b/plugin_kvm.c
index 55812ef..adc5694 100644
--- a/plugin_kvm.c
+++ b/plugin_kvm.c
@@ -382,7 +382,7 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct 
pevent_record *record,
} else
trace_seq_printf(s, "WORD: %08x", role.word);
 
-   pevent_print_num_field(s, " root %u",  event,
+   pevent_print_num_field(s, " root %u ",  event,
   "root_count", record, 1);
 
if (pevent_get_field_val(s, event, "unsync", record, &val, 1) < 0)
@@ -397,6 +397,11 @@ static int kvm_mmu_get_page_handler(struct trace_seq *s, 
struct pevent_record *r
 {
unsigned long long val;
 
+   if (pevent_get_field_val(s, event, "created", record, &val, 1) < 0)
+   return -1;
+
+   trace_seq_printf(s, "%s ", val ? "new" : "existing");
+
if (pevent_get_field_val(s, event, "gfn", record, &val, 1) < 0)
return -1;
 
@@ -430,7 +435,7 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
pevent_register_event_handler(pevent, -1, "kvmmmu", 
"kvm_mmu_unsync_page",
  kvm_mmu_print_role, NULL);
 
-   pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
+   pevent_register_event_handler(pevent, -1, "kvmmmu", 
"kvm_mmu_prepare_zap_page",
  kvm_mmu_print_role, NULL);
 
return 0;
--
Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 04/16] kvm tools: specify compiler by name when overriding make default

2012-11-12 Thread Will Deacon
GNU make defaults "$(CC)" to "cc", which breaks compilation when we try
to execute $(CROSS_COMPILE)-cc.

This patch copies what the top-level kernel Makefile does, by specifying
"gcc" directly when overriding the $CC environment variable.

Signed-off-by: Will Deacon 
---
 tools/kvm/Makefile |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile
index 44a55c2..bb22587 100644
--- a/tools/kvm/Makefile
+++ b/tools/kvm/Makefile
@@ -19,8 +19,8 @@ export E Q KINCL_PATH
 include config/utilities.mak
 include config/feature-tests.mak
 
-CC := $(CROSS_COMPILE)$(CC)
-LD := $(CROSS_COMPILE)$(LD)
+CC := $(CROSS_COMPILE)gcc
+LD := $(CROSS_COMPILE)ld
 
 FIND   := find
 CSCOPE := cscope
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] x86, add hypervisor name to dump_stack() [v4]

2012-11-01 Thread Gleb Natapov
On Tue, Oct 30, 2012 at 04:26:33PM -0400, Prarit Bhargava wrote:
> Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
> bare-metal boots can get difficult very quickly.  While there are ways to
> decipher the output and determine if the output is from a virtual guest,
> the in-kernel hypervisors now have a single registration point
> and set x86_hyper.  We can use this to output additional debug
> information during a panic/oops/stack trace.
> 
> Signed-off-by: Prarit Bhargava 
> Cc: Avi Kivity 
> Cc: Gleb Natapov 
> Cc: Alex Williamson 
> Cc: Marcelo Tostatti 
> Cc: Ingo Molnar 
> Cc: kvm@vger.kernel.org
> Cc: x...@kernel.org
> 
Acked-by: Gleb Natapov 

> [v2]: Modifications suggested by Ingo and added changes for similar output
>   from process.c
> 
> [v3]: Unify common code and move output to end of line
> ---
>  arch/x86/kernel/dumpstack.c |6 +-
>  arch/x86/kernel/process.c   |   14 --
>  2 files changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
> index ae42418b..96d40ed 100644
> --- a/arch/x86/kernel/dumpstack.c
> +++ b/arch/x86/kernel/dumpstack.c
> @@ -188,11 +188,7 @@ void dump_stack(void)
>   unsigned long stack;
>  
>   bp = stack_frame(current, NULL);
> - printk("Pid: %d, comm: %.20s %s %s %.*s\n",
> - current->pid, current->comm, print_tainted(),
> - init_utsname()->release,
> - (int)strcspn(init_utsname()->version, " "),
> - init_utsname()->version);
> + show_regs_common();
>   show_trace(NULL, NULL, &stack, bp);
>  }
>  EXPORT_SYMBOL(dump_stack);
> diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
> index b644e1c..7ea4692 100644
> --- a/arch/x86/kernel/process.c
> +++ b/arch/x86/kernel/process.c
> @@ -28,6 +28,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /*
>   * per-CPU TSS segments. Threads are completely 'soft' on Linux,
> @@ -124,6 +125,13 @@ void exit_thread(void)
>  void show_regs_common(void)
>  {
>   const char *vendor, *product, *board;
> + const char *machine_name = "x86";
> + const char *kernel_type = "native";
> +
> + if (x86_hyper) {
> + machine_name = x86_hyper->name;
> + kernel_type = "guest";
> + }
>  
>   vendor = dmi_get_system_info(DMI_SYS_VENDOR);
>   if (!vendor)
> @@ -135,14 +143,16 @@ void show_regs_common(void)
>   /* Board Name is optional */
>   board = dmi_get_system_info(DMI_BOARD_NAME);
>  
> - printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
> + printk(KERN_DEFAULT
> +"Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s [%s %s kernel]\n",
>  current->pid, current->comm, print_tainted(),
>  init_utsname()->release,
>  (int)strcspn(init_utsname()->version, " "),
>  init_utsname()->version,
>  vendor, product,
>  board ? "/" : "",
> -board ? board : "");
> +board ? board : "",
> +machine_name, kernel_type);
>  }
>  
>  void flush_thread(void)
> -- 
> 1.7.9.3

--
Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/28] target-i386: Add missing kvm cpuid feature name

2012-10-31 Thread Marcelo Tosatti
From: Don Slutz 

Currently "-cpu host,-kvmclock,-kvm_nopiodelay,-kvm_mmu" does not
turn off all bits in CPUID 0x4001 EAX.

The missing ones is KVM_FEATURE_STEAL_TIME.

This adds the name kvm_steal_time.

Signed-off-by: Don Slutz 
Signed-off-by: Marcelo Tosatti 
---
 target-i386/cpu.c |   12 
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 7c726fc..4417d6a 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -88,10 +88,14 @@ static const char *ext3_feature_name[] = {
 };
 
 static const char *kvm_feature_name[] = {
-"kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock", "kvm_asyncpf", NULL, 
"kvm_pv_eoi", NULL,
-NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+"kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock",
+"kvm_asyncpf", "kvm_steal_time", "kvm_pv_eoi", NULL,
+NULL, NULL, NULL, NULL,
+NULL, NULL, NULL, NULL,
+NULL, NULL, NULL, NULL,
+NULL, NULL, NULL, NULL,
+NULL, NULL, NULL, NULL,
+NULL, NULL, NULL, NULL,
 };
 
 static const char *svm_feature_name[] = {
-- 
1.7.6.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] x86, add hypervisor name to dump_stack() [v4]

2012-10-30 Thread Borislav Petkov
On Tue, Oct 30, 2012 at 04:26:33PM -0400, Prarit Bhargava wrote:
> Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
> bare-metal boots can get difficult very quickly.  While there are ways to
> decipher the output and determine if the output is from a virtual guest,
> the in-kernel hypervisors now have a single registration point
> and set x86_hyper.  We can use this to output additional debug
> information during a panic/oops/stack trace.
> 
> Signed-off-by: Prarit Bhargava 
> Cc: Avi Kivity 
> Cc: Gleb Natapov 
> Cc: Alex Williamson 
> Cc: Marcelo Tostatti 
> Cc: Ingo Molnar 
> Cc: kvm@vger.kernel.org
> Cc: x...@kernel.org
> 
> [v2]: Modifications suggested by Ingo and added changes for similar output
>   from process.c
> 
> [v3]: Unify common code and move output to end of line

Looks useful.

Acked-by: Borislav Petkov 

-- 
Regards/Gruss,
Boris.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] x86, add hypervisor name to dump_stack() [v4]

2012-10-30 Thread Prarit Bhargava
Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
bare-metal boots can get difficult very quickly.  While there are ways to
decipher the output and determine if the output is from a virtual guest,
the in-kernel hypervisors now have a single registration point
and set x86_hyper.  We can use this to output additional debug
information during a panic/oops/stack trace.

Signed-off-by: Prarit Bhargava 
Cc: Avi Kivity 
Cc: Gleb Natapov 
Cc: Alex Williamson 
Cc: Marcelo Tostatti 
Cc: Ingo Molnar 
Cc: kvm@vger.kernel.org
Cc: x...@kernel.org

[v2]: Modifications suggested by Ingo and added changes for similar output
  from process.c

[v3]: Unify common code and move output to end of line
---
 arch/x86/kernel/dumpstack.c |6 +-
 arch/x86/kernel/process.c   |   14 --
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index ae42418b..96d40ed 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -188,11 +188,7 @@ void dump_stack(void)
unsigned long stack;
 
bp = stack_frame(current, NULL);
-   printk("Pid: %d, comm: %.20s %s %s %.*s\n",
-   current->pid, current->comm, print_tainted(),
-   init_utsname()->release,
-   (int)strcspn(init_utsname()->version, " "),
-   init_utsname()->version);
+   show_regs_common();
show_trace(NULL, NULL, &stack, bp);
 }
 EXPORT_SYMBOL(dump_stack);
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index b644e1c..7ea4692 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * per-CPU TSS segments. Threads are completely 'soft' on Linux,
@@ -124,6 +125,13 @@ void exit_thread(void)
 void show_regs_common(void)
 {
const char *vendor, *product, *board;
+   const char *machine_name = "x86";
+   const char *kernel_type = "native";
+
+   if (x86_hyper) {
+   machine_name = x86_hyper->name;
+   kernel_type = "guest";
+   }
 
vendor = dmi_get_system_info(DMI_SYS_VENDOR);
    if (!vendor)
@@ -135,14 +143,16 @@ void show_regs_common(void)
/* Board Name is optional */
board = dmi_get_system_info(DMI_BOARD_NAME);
 
-   printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
+   printk(KERN_DEFAULT
+  "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s [%s %s kernel]\n",
   current->pid, current->comm, print_tainted(),
   init_utsname()->release,
   (int)strcspn(init_utsname()->version, " "),
   init_utsname()->version,
   vendor, product,
   board ? "/" : "",
-  board ? board : "");
+  board ? board : "",
+  machine_name, kernel_type);
 }
 
 void flush_thread(void)
-- 
1.7.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] x86, add hypervisor name to dump_stack() [v3]

2012-10-30 Thread Prarit Bhargava


On 10/30/2012 03:14 PM, Prarit Bhargava wrote:
> Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
> bare-metal boots can get difficult very quickly.  While there are ways to
> decipher the output and determine if the output is from a virtual guest,
> the in-kernel hypervisors now have a single registration point
> and set x86_hyper.  We can use this to output additional debug
> information during a panic/oops/stack trace.
> 
> Signed-off-by: Prarit Bhargava 
> Cc: Avi Kivity 
> Cc: Gleb Natapov 
> Cc: Alex Williamson 
> Cc: Marcelo Tostatti 
> Cc: Ingo Molnar 
> Cc: kvm@vger.kernel.org
> Cc: x...@kernel.org
> 
> [v2]: Modifications suggested by Ingo and added changes for similar output
>   from process.c
> 
> [v3]: Unify common code and move output to end of line
> ---
>  arch/x86/kernel/dumpstack.c |6 +-
>  arch/x86/kernel/process.c   |   12 +++-
>  2 files changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
> index ae42418b..96d40ed 100644
> --- a/arch/x86/kernel/dumpstack.c
> +++ b/arch/x86/kernel/dumpstack.c
> @@ -188,11 +188,7 @@ void dump_stack(void)
>   unsigned long stack;
>  
>   bp = stack_frame(current, NULL);
> - printk("Pid: %d, comm: %.20s %s %s %.*s\n",
> - current->pid, current->comm, print_tainted(),
> - init_utsname()->release,
> - (int)strcspn(init_utsname()->version, " "),
> - init_utsname()->version);
> + show_regs_common();
>   show_trace(NULL, NULL, &stack, bp);
>  }
>  EXPORT_SYMBOL(dump_stack);
> diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
> index b644e1c..14bd064 100644
> --- a/arch/x86/kernel/process.c
> +++ b/arch/x86/kernel/process.c
> @@ -28,6 +28,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /*
>   * per-CPU TSS segments. Threads are completely 'soft' on Linux,
> @@ -124,6 +125,13 @@ void exit_thread(void)
>  void show_regs_common(void)
>  {
>   const char *vendor, *product, *board;
> + const char *machine_name = "x86";
> + const char *kernel_type = "native";
> +
> + if (x86_hyper) {
> + machine_name = x86_hyper->name;
> + kernel_type = "guest";
> + }
>  
>   vendor = dmi_get_system_info(DMI_SYS_VENDOR);
>   if (!vendor)
> @@ -135,7 +143,9 @@ void show_regs_common(void)
>   /* Board Name is optional */
>   board = dmi_get_system_info(DMI_BOARD_NAME);
>  
> - printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
> + printk(KERN_DEFAULT
> +"[%s %s kernel] Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
> +machine_name, kernel_type,

Ugh ... self-nak.  I sent the wrong version of this patch.  Sorry Ingo :(

P.

>  current->pid, current->comm, print_tainted(),
>  init_utsname()->release,
>  (int)strcspn(init_utsname()->version, " "),
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] x86, add hypervisor name to dump_stack() [v3]

2012-10-30 Thread Prarit Bhargava
Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
bare-metal boots can get difficult very quickly.  While there are ways to
decipher the output and determine if the output is from a virtual guest,
the in-kernel hypervisors now have a single registration point
and set x86_hyper.  We can use this to output additional debug
information during a panic/oops/stack trace.

Signed-off-by: Prarit Bhargava 
Cc: Avi Kivity 
Cc: Gleb Natapov 
Cc: Alex Williamson 
Cc: Marcelo Tostatti 
Cc: Ingo Molnar 
Cc: kvm@vger.kernel.org
Cc: x...@kernel.org

[v2]: Modifications suggested by Ingo and added changes for similar output
  from process.c

[v3]: Unify common code and move output to end of line
---
 arch/x86/kernel/dumpstack.c |6 +-
 arch/x86/kernel/process.c   |   12 +++-
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index ae42418b..96d40ed 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -188,11 +188,7 @@ void dump_stack(void)
unsigned long stack;
 
bp = stack_frame(current, NULL);
-   printk("Pid: %d, comm: %.20s %s %s %.*s\n",
-   current->pid, current->comm, print_tainted(),
-   init_utsname()->release,
-   (int)strcspn(init_utsname()->version, " "),
-   init_utsname()->version);
+   show_regs_common();
show_trace(NULL, NULL, &stack, bp);
 }
 EXPORT_SYMBOL(dump_stack);
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index b644e1c..14bd064 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * per-CPU TSS segments. Threads are completely 'soft' on Linux,
@@ -124,6 +125,13 @@ void exit_thread(void)
 void show_regs_common(void)
 {
const char *vendor, *product, *board;
+   const char *machine_name = "x86";
+   const char *kernel_type = "native";
+
+   if (x86_hyper) {
+   machine_name = x86_hyper->name;
+   kernel_type = "guest";
+   }
 
vendor = dmi_get_system_info(DMI_SYS_VENDOR);
if (!vendor)
@@ -135,7 +143,9 @@ void show_regs_common(void)
/* Board Name is optional */
board = dmi_get_system_info(DMI_BOARD_NAME);
 
-   printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
+   printk(KERN_DEFAULT
+  "[%s %s kernel] Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
+  machine_name, kernel_type,
   current->pid, current->comm, print_tainted(),
   init_utsname()->release,
   (int)strcspn(init_utsname()->version, " "),
-- 
1.7.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] x86, add hypervisor name to dump_stack() [v2]

2012-10-26 Thread Ingo Molnar

* Prarit Bhargava  wrote:

> Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
> bare-metal boots can get difficult very quickly.  While there are ways to
> decipher the output and determine if the output is from a virtual guest,
> the in-kernel hypervisors now have a single registration point
> and set x86_hyper.  We can use this to output additional debug
> information during a panic/oops/stack trace.
> 
> Signed-off-by: Prarit Bhargava 
> Cc: Avi Kivity 
> Cc: Gleb Natapov 
> Cc: Alex Williamson 
> Cc: Marcelo Tostatti 
> Cc: Ingo Molnar 
> Cc: kvm@vger.kernel.org
> Cc: x...@kernel.org
> 
> [v2]: Modifications suggested by Ingo and added changes for similar output
>   from process.c
> ---
>  arch/x86/kernel/dumpstack.c |   11 ++-
>  arch/x86/kernel/process.c   |   12 +++-
>  2 files changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
> index ae42418b..5dd680f 100644
> --- a/arch/x86/kernel/dumpstack.c
> +++ b/arch/x86/kernel/dumpstack.c
> @@ -16,6 +16,7 @@
>  #include 
>  #include 
>  
> +#include 
>  #include 
>  
>  
> @@ -186,9 +187,17 @@ void dump_stack(void)
>  {
>   unsigned long bp;
>   unsigned long stack;
> + const char *machine_name = "x86";
> + const char *kernel_type = "native";
> +
> + if (x86_hyper) {
> + machine_name = x86_hyper->name;
> + kernel_type = "guest";
> + }
>  
>   bp = stack_frame(current, NULL);
> - printk("Pid: %d, comm: %.20s %s %s %.*s\n",
> + printk("[%s %s kernel] Pid: %d, comm: %.20s %s %s %.*s\n",
> + machine_name, kernel_type,

I'd put the kernel info at the end of the line.

It's all very exciting I know, because we are working on this 
printout right now and all that - but to users and developers 
the PID/comm output plus the backtrace is far more important.

>   current->pid, current->comm, print_tainted(),
>   init_utsname()->release,
>   (int)strcspn(init_utsname()->version, " "),
> diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
> index b644e1c..14bd064 100644
> --- a/arch/x86/kernel/process.c
> +++ b/arch/x86/kernel/process.c
> @@ -28,6 +28,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /*
>   * per-CPU TSS segments. Threads are completely 'soft' on Linux,
> @@ -124,6 +125,13 @@ void exit_thread(void)
>  void show_regs_common(void)
>  {
>   const char *vendor, *product, *board;
> + const char *machine_name = "x86";
> + const char *kernel_type = "native";
> +
> + if (x86_hyper) {
> + machine_name = x86_hyper->name;
> + kernel_type = "guest";
> + }
>  
>   vendor = dmi_get_system_info(DMI_SYS_VENDOR);
>   if (!vendor)
> @@ -135,7 +143,9 @@ void show_regs_common(void)
>   /* Board Name is optional */
>   board = dmi_get_system_info(DMI_BOARD_NAME);
>  
> - printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
> + printk(KERN_DEFAULT
> +"[%s %s kernel] Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
> +machine_name, kernel_type,
>  current->pid, current->comm, print_tainted(),
>  init_utsname()->release,
>  (int)strcspn(init_utsname()->version, " "),

Ha, duplicate code doing almost the same thing!

I suspect you know what my next suggestion would be? :-)

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] x86, add hypervisor name to dump_stack() [v2]

2012-10-26 Thread Prarit Bhargava
Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
bare-metal boots can get difficult very quickly.  While there are ways to
decipher the output and determine if the output is from a virtual guest,
the in-kernel hypervisors now have a single registration point
and set x86_hyper.  We can use this to output additional debug
information during a panic/oops/stack trace.

Signed-off-by: Prarit Bhargava 
Cc: Avi Kivity 
Cc: Gleb Natapov 
Cc: Alex Williamson 
Cc: Marcelo Tostatti 
Cc: Ingo Molnar 
Cc: kvm@vger.kernel.org
Cc: x...@kernel.org

[v2]: Modifications suggested by Ingo and added changes for similar output
  from process.c
---
 arch/x86/kernel/dumpstack.c |   11 ++-
 arch/x86/kernel/process.c   |   12 +++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index ae42418b..5dd680f 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 
@@ -186,9 +187,17 @@ void dump_stack(void)
 {
unsigned long bp;
unsigned long stack;
+   const char *machine_name = "x86";
+   const char *kernel_type = "native";
+
+   if (x86_hyper) {
+   machine_name = x86_hyper->name;
+   kernel_type = "guest";
+   }
 
bp = stack_frame(current, NULL);
-   printk("Pid: %d, comm: %.20s %s %s %.*s\n",
+   printk("[%s %s kernel] Pid: %d, comm: %.20s %s %s %.*s\n",
+   machine_name, kernel_type,
current->pid, current->comm, print_tainted(),
init_utsname()->release,
(int)strcspn(init_utsname()->version, " "),
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index b644e1c..14bd064 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * per-CPU TSS segments. Threads are completely 'soft' on Linux,
@@ -124,6 +125,13 @@ void exit_thread(void)
 void show_regs_common(void)
 {
const char *vendor, *product, *board;
+   const char *machine_name = "x86";
+   const char *kernel_type = "native";
+
+   if (x86_hyper) {
+   machine_name = x86_hyper->name;
+   kernel_type = "guest";
+   }
 
vendor = dmi_get_system_info(DMI_SYS_VENDOR);
if (!vendor)
@@ -135,7 +143,9 @@ void show_regs_common(void)
/* Board Name is optional */
board = dmi_get_system_info(DMI_BOARD_NAME);
 
-   printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
+   printk(KERN_DEFAULT
+  "[%s %s kernel] Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
+  machine_name, kernel_type,
   current->pid, current->comm, print_tainted(),
   init_utsname()->release,
   (int)strcspn(init_utsname()->version, " "),
-- 
1.7.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] kvm tools: name threads

2012-10-24 Thread Sasha Levin
Give threads a meaningful name. This makes debugging much easier, and
everything else much prettier.

Suggested-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 tools/kvm/disk/core.c   | 2 ++
 tools/kvm/include/kvm/kvm.h | 7 +++
 tools/kvm/ioeventfd.c   | 2 ++
 tools/kvm/kvm-ipc.c | 2 ++
 tools/kvm/net/uip/tcp.c | 3 +++
 tools/kvm/net/uip/udp.c | 3 +++
 tools/kvm/ui/sdl.c  | 2 ++
 tools/kvm/ui/vnc.c  | 2 ++
 tools/kvm/util/threadpool.c | 2 ++
 tools/kvm/virtio/blk.c  | 2 ++
 tools/kvm/virtio/net.c  | 4 
 11 files changed, 31 insertions(+)

diff --git a/tools/kvm/disk/core.c b/tools/kvm/disk/core.c
index b313b28..dd59751 100644
--- a/tools/kvm/disk/core.c
+++ b/tools/kvm/disk/core.c
@@ -63,6 +63,8 @@ static void *disk_image__thread(void *param)
int nr, i;
u64 dummy;
 
+   kvm__set_thread_name("disk-image-io");
+
while (read(disk->evt, &dummy, sizeof(dummy)) > 0) {
nr = io_getevents(disk->ctx, 1, ARRAY_SIZE(event), event, 
¬ime);
for (i = 0; i < nr; i++)
diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h
index b460656..1c7fab7 100644
--- a/tools/kvm/include/kvm/kvm.h
+++ b/tools/kvm/include/kvm/kvm.h
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define SIGKVMEXIT (SIGRTMIN + 0)
 #define SIGKVMPAUSE(SIGRTMIN + 1)
@@ -118,4 +119,10 @@ static inline void *guest_flat_to_host(struct kvm *kvm, 
unsigned long offset)
 
 bool kvm__supports_extension(struct kvm *kvm, unsigned int extension);
 
+static inline void kvm__set_thread_name(const char *name)
+{
+   prctl(PR_SET_NAME, name);
+}
+
 #endif /* KVM__KVM_H */
+
diff --git a/tools/kvm/ioeventfd.c b/tools/kvm/ioeventfd.c
index a68d8d0..ff665d4 100644
--- a/tools/kvm/ioeventfd.c
+++ b/tools/kvm/ioeventfd.c
@@ -24,6 +24,8 @@ static void *ioeventfd__thread(void *param)
 {
u64 tmp = 1;
 
+   kvm__set_thread_name("ioeventfd-worker");
+
for (;;) {
int nfds, i;
 
diff --git a/tools/kvm/kvm-ipc.c b/tools/kvm/kvm-ipc.c
index d23edd2..bdcc0d1 100644
--- a/tools/kvm/kvm-ipc.c
+++ b/tools/kvm/kvm-ipc.c
@@ -260,6 +260,8 @@ static void *kvm_ipc__thread(void *param)
struct epoll_event event;
struct kvm *kvm = param;
 
+   kvm__set_thread_name("kvm-ipc");
+
for (;;) {
int nfds;
 
diff --git a/tools/kvm/net/uip/tcp.c b/tools/kvm/net/uip/tcp.c
index 711a716..830aa3f 100644
--- a/tools/kvm/net/uip/tcp.c
+++ b/tools/kvm/net/uip/tcp.c
@@ -1,5 +1,6 @@
 #include "kvm/uip.h"
 
+#include 
 #include 
 #include 
 #include 
@@ -176,6 +177,8 @@ static void *uip_tcp_socket_thread(void *p)
int len, left, ret;
u8 *payload, *pos;
 
+   kvm__set_thread_name("uip-tcp");
+
sk = p;
 
payload = malloc(UIP_MAX_TCP_PAYLOAD);
diff --git a/tools/kvm/net/uip/udp.c b/tools/kvm/net/uip/udp.c
index d4518b2..5b6ec1c 100644
--- a/tools/kvm/net/uip/udp.c
+++ b/tools/kvm/net/uip/udp.c
@@ -1,5 +1,6 @@
 #include "kvm/uip.h"
 
+#include 
 #include 
 #include 
 #include 
@@ -160,6 +161,8 @@ static void *uip_udp_socket_thread(void *p)
int nfds;
int i;
 
+   kvm__set_thread_name("uip-udp");
+
info = p;
 
do {
diff --git a/tools/kvm/ui/sdl.c b/tools/kvm/ui/sdl.c
index 172a12b..9994490 100644
--- a/tools/kvm/ui/sdl.c
+++ b/tools/kvm/ui/sdl.c
@@ -206,6 +206,8 @@ static void *sdl__thread(void *p)
SDL_Event ev;
Uint32 flags;
 
+   kvm__set_thread_name("kvm-sdl-worker");
+
if (SDL_Init(SDL_INIT_VIDEO) != 0)
die("Unable to initialize SDL");
 
diff --git a/tools/kvm/ui/vnc.c b/tools/kvm/ui/vnc.c
index efdc0f4..12e4bd5 100644
--- a/tools/kvm/ui/vnc.c
+++ b/tools/kvm/ui/vnc.c
@@ -185,6 +185,8 @@ static void *vnc__thread(void *p)
char argv[1][1] = {{0}};
int argc = 1;
 
+   kvm__set_thread_name("kvm-vnc-worker");
+
server = rfbGetScreen(&argc, (char **) argv, fb->width, fb->height, 8, 
3, 4);
server->frameBuffer = fb->mem;
server->alwaysShared= TRUE;
diff --git a/tools/kvm/util/threadpool.c b/tools/kvm/util/threadpool.c
index 85ac7e7..a363831 100644
--- a/tools/kvm/util/threadpool.c
+++ b/tools/kvm/util/threadpool.c
@@ -78,6 +78,8 @@ static void *thread_pool__threadfunc(void *param)
 {
pthread_cleanup_push(thread_pool__threadfunc_cleanup, NULL);
 
+   kvm__set_thread_name("threadpool-worker");
+
while (running) {
struct thread_pool__job *curjob = NULL;
 
diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c
index cff38aa..f76342c 100644
--- a/tools/kvm/virtio/blk.c
+++ b/tools/kvm/virtio/blk.c
@@ -179,6 +179,8 @@ static void *virtio_blk_thread(void *dev)
u64 data;
int r;
 
+   kvm__se

Re: [PATCH] x86, add hypervisor name to dump_stack()

2012-10-24 Thread Ingo Molnar

* Prarit Bhargava  wrote:

> > Looks useful, but please don't waste a full new line on it 
> > but embedd it in the already existing status line that 
> > prints details like release and version.
> 
> Ingo, I thought about doing that but since x86_hyper can be 
> NULL (... maybe it should initialized to "Bare-metal" or "No 
> Hypervisor"?) I didn't want to break up the printk line.  I'll 
> look into doing it a different way...

You don't have to break it up - just initialize a name string 
to:

const char *machine_name = "x86";
const char *kernel_type = "native";

if (x86_hyperv) {
machine_name = x86_hyperv->name;
kernel_type = "guest";
}

And print it as:

  "[%s %s kernel]", machine_name, kernel_type

That way we'll get nice:

... [x86 native kernel]
... [KVM guest kernel]
... [Xen guest kernel]
etc.

Printouts. Please use the naming I outlined above, that's how we 
refer to these kernels within arch/x86/.

(The above code is pseudocode, untested.)

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] x86, add hypervisor name to dump_stack()

2012-10-24 Thread Prarit Bhargava


On 10/24/2012 05:49 AM, Ingo Molnar wrote:
> 
> * Prarit Bhargava  wrote:
> 
>> Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
>> bare-metal boots can get difficult very quickly.  While there are ways to
>> decipher the output and determine if the output is from a virtual guest,
>> the in-kernel hypervisors now have a single registration point and set
>> x86_hyper.  We can use this to output a single extra line on virtual
>> machines that indicates the hypervisor type.
>>
>> Signed-off-by: Prarit Bhargava 
>> Cc: Avi Kivity 
>> Cc: Gleb Natapov 
>> Cc: Alex Williamson 
>> Cc: Marcelo Tostatti 
>> Cc: Ingo Molnar 
>> Cc: kvm@vger.kernel.org
>> Cc: x...@kernel.org
>> ---
>>  arch/x86/kernel/dumpstack.c |3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
>> index ae42418b..75a635e 100644
>> --- a/arch/x86/kernel/dumpstack.c
>> +++ b/arch/x86/kernel/dumpstack.c
>> @@ -17,6 +17,7 @@
>>  #include 
>>  
>>  #include 
>> +#include 
>>  
>>  
>>  int panic_on_unrecovered_nmi;
>> @@ -193,6 +194,8 @@ void dump_stack(void)
>>  init_utsname()->release,
>>  (int)strcspn(init_utsname()->version, " "),
>>  init_utsname()->version);
>> +if (x86_hyper && x86_hyper->name)
>> +printk("Hypervisor: %s\n",  x86_hyper->name);
>>  show_trace(NULL, NULL, &stack, bp);
> 
> Looks useful, but please don't waste a full new line on it but 
> embedd it in the already existing status line that prints 
> details like release and version.

Ingo, I thought about doing that but since x86_hyper can be NULL (... maybe it
should initialized to "Bare-metal" or "No Hypervisor"?) I didn't want to break
up the printk line.  I'll look into doing it a different way...

P.

> 
> Thanks,
> 
>   Ingo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] x86, add hypervisor name to dump_stack()

2012-10-24 Thread Ingo Molnar

* Prarit Bhargava  wrote:

> Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
> bare-metal boots can get difficult very quickly.  While there are ways to
> decipher the output and determine if the output is from a virtual guest,
> the in-kernel hypervisors now have a single registration point and set
> x86_hyper.  We can use this to output a single extra line on virtual
> machines that indicates the hypervisor type.
> 
> Signed-off-by: Prarit Bhargava 
> Cc: Avi Kivity 
> Cc: Gleb Natapov 
> Cc: Alex Williamson 
> Cc: Marcelo Tostatti 
> Cc: Ingo Molnar 
> Cc: kvm@vger.kernel.org
> Cc: x...@kernel.org
> ---
>  arch/x86/kernel/dumpstack.c |3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
> index ae42418b..75a635e 100644
> --- a/arch/x86/kernel/dumpstack.c
> +++ b/arch/x86/kernel/dumpstack.c
> @@ -17,6 +17,7 @@
>  #include 
>  
>  #include 
> +#include 
>  
>  
>  int panic_on_unrecovered_nmi;
> @@ -193,6 +194,8 @@ void dump_stack(void)
>   init_utsname()->release,
>   (int)strcspn(init_utsname()->version, " "),
>   init_utsname()->version);
> + if (x86_hyper && x86_hyper->name)
> + printk("Hypervisor: %s\n",  x86_hyper->name);
>   show_trace(NULL, NULL, &stack, bp);

Looks useful, but please don't waste a full new line on it but 
embedd it in the already existing status line that prints 
details like release and version.

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 14/17] target-i386: Add vmare as a known name to Hypervisor vendor.

2012-10-12 Thread Don Slutz
Part of "target-i386: Add way to expose VMWare CPUID"

Also adds some other known names (kvm, hyperv) to Hypervisor vendor.

This allows "hypervisor-vendor=vmware3" instead of
"hypervisor-vendor=VMwareVMware,hypervisor-level=2,hypervisor-features=0".

And "hypervisor-vendor=vmware" instead of
"hypervisor-vendor=VMwareVMware,hypervisor-level=0x10,hypervisor-features=0".

This is based on:

VMware documention on CPUIDs (Mechanisms to determine if software is
running in a VMware virtual machine):
  
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

Signed-off-by: Don Slutz 
---
 target-i386/cpu.c |   58 -
 target-i386/cpu.h |9 
 2 files changed, 66 insertions(+), 1 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index f058add..c8466ec 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1203,6 +1203,23 @@ static char *x86_cpuid_get_hv_vendor(Object *obj, Error 
**errp)
 }
 value[CPUID_VENDOR_SZ] = '\0';
 
+/* Convert known names */
+if (!strcmp(value, CPUID_HV_VENDOR_HYPERV) &&
+env->cpuid_hv_level == CPUID_HV_LEVEL_HYPERV_CPUID_MIN &&
+env->cpuid_hv_features_set == CPUID_HV_FEATURES_HYPERV) {
+pstrcpy(value, sizeof(value), "hyperv");
+} else if (!strcmp(value, CPUID_HV_VENDOR_VMWARE) &&
+env->cpuid_hv_features_set == CPUID_HV_FEATURES_VMWARE) {
+if (env->cpuid_hv_level == CPUID_HV_LEVEL_VMWARE_4) {
+pstrcpy(value, sizeof(value), "vmware4");
+} else if (env->cpuid_hv_level == CPUID_HV_LEVEL_VMWARE_3) {
+pstrcpy(value, sizeof(value), "vmware3");
+}
+} else if (!strcmp(value, CPUID_HV_VENDOR_KVM) &&
+   (env->cpuid_hv_level == CPUID_HV_LEVEL_KVM_0 ||
+env->cpuid_hv_level == CPUID_HV_LEVEL_KVM_1)) {
+pstrcpy(value, sizeof(value), "kvm");
+}
 return value;
 }
 
@@ -1216,7 +1233,46 @@ static void x86_cpuid_set_hv_vendor(Object *obj, const 
char *value,
 
 memset(adj_value, 0, sizeof(adj_value));
 
-pstrcpy(adj_value, sizeof(adj_value), value);
+/* Convert known names */
+if (!strcmp(value, "hyperv")) {
+if (!env->cpuid_hv_level_set) {
+object_property_set_int(obj, CPUID_HV_LEVEL_HYPERV_CPUID_MIN,
+"hypervisor-level", errp);
+}
+if (!env->cpuid_hv_features_set) {
+object_property_set_int(obj, CPUID_HV_FEATURES_HYPERV,
+"hypervisor-features", errp);
+}
+pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_HYPERV);
+} else if (!strcmp(value, "vmware") || !strcmp(value, "vmware4")) {
+if (!env->cpuid_hv_level_set) {
+object_property_set_int(obj, CPUID_HV_LEVEL_VMWARE_4,
+"hypervisor-level", errp);
+}
+if (!env->cpuid_hv_features_set) {
+object_property_set_int(obj, CPUID_HV_FEATURES_VMWARE,
+"hypervisor-features", errp);
+}
+pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_VMWARE);
+} else if (!strcmp(value, "vmware3")) {
+if (!env->cpuid_hv_level_set) {
+object_property_set_int(obj, CPUID_HV_LEVEL_VMWARE_3,
+"hypervisor-level", errp);
+}
+if (!env->cpuid_hv_features_set) {
+object_property_set_int(obj, CPUID_HV_FEATURES_VMWARE,
+"hypervisor-features", errp);
+}
+pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_VMWARE);
+} else if (!strcmp(value, "kvm")) {
+if (!env->cpuid_hv_level_set) {
+object_property_set_int(obj, CPUID_HV_LEVEL_KVM_1,
+"hypervisor-level", errp);
+}
+pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_KVM);
+} else {
+pstrcpy(adj_value, sizeof(adj_value), value);
+}
 
 env->cpuid_hv_vendor1 = 0;
 env->cpuid_hv_vendor2 = 0;
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 6ceef05..a387d82 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -498,6 +498,15 @@
 #define CPUID_HV_VENDOR_HYPERV "Microsoft Hv"
 #define CPUID_HV_FEATURES_HYPERV 0x31237648 /* "Hv#1" */
 
+#define CPUID_HV_LEVEL_VMWARE_3 0x4002
+#define CPUID_HV_LEVEL_VMWARE_4 0x4010
+#define CPUID_HV_VENDOR_VMWARE "VMwareVMware"
+#define CPUID_HV_FEATURES_VMWARE 0
+
+#define CPUID_HV_LEVEL_KVM_0  0
+#define CPUID_HV_LEVEL_KVM_1  0x4001
+#define CPUID_HV_VENDOR_KVM "KVMKVMKVM"
+
 #define CPUID_MWAIT_IBE (1 << 1) /* Interrupts can exit capability */
 #define CPUID_MWAIT_EMX (1 << 0) /* enumeration supported */
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/major

[PATCH] x86, add hypervisor name to dump_stack()

2012-10-10 Thread Prarit Bhargava
Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and
bare-metal boots can get difficult very quickly.  While there are ways to
decipher the output and determine if the output is from a virtual guest,
the in-kernel hypervisors now have a single registration point and set
x86_hyper.  We can use this to output a single extra line on virtual
machines that indicates the hypervisor type.

Signed-off-by: Prarit Bhargava 
Cc: Avi Kivity 
Cc: Gleb Natapov 
Cc: Alex Williamson 
Cc: Marcelo Tostatti 
Cc: Ingo Molnar 
Cc: kvm@vger.kernel.org
Cc: x...@kernel.org
---
 arch/x86/kernel/dumpstack.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index ae42418b..75a635e 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -17,6 +17,7 @@
 #include 
 
 #include 
+#include 
 
 
 int panic_on_unrecovered_nmi;
@@ -193,6 +194,8 @@ void dump_stack(void)
init_utsname()->release,
(int)strcspn(init_utsname()->version, " "),
init_utsname()->version);
+   if (x86_hyper && x86_hyper->name)
+   printk("Hypervisor: %s\n",  x86_hyper->name);
show_trace(NULL, NULL, &stack, bp);
 }
 EXPORT_SYMBOL(dump_stack);
-- 
1.7.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] kvm: switch to symbolic name for irq_states size

2012-07-19 Thread Michael S. Tsirkin
Use PIC_NUM_PINS instead of hard-coded 16 for pic pins.

Signed-off-by: Michael S. Tsirkin 
---
 arch/x86/kvm/irq.h  | 2 +-
 virt/kvm/irq_comm.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
index 2086f2b..2d03568 100644
--- a/arch/x86/kvm/irq.h
+++ b/arch/x86/kvm/irq.h
@@ -70,7 +70,7 @@ struct kvm_pic {
struct kvm_io_device dev_slave;
struct kvm_io_device dev_eclr;
void (*ack_notifier)(void *opaque, int irq);
-   unsigned long irq_states[16];
+   unsigned long irq_states[PIC_NUM_PINS];
 };
 
 struct kvm_pic *kvm_create_pic(struct kvm *kvm);
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index 83402d7..7118be0 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -321,11 +321,11 @@ static int setup_routing_entry(struct 
kvm_irq_routing_table *rt,
switch (ue->u.irqchip.irqchip) {
case KVM_IRQCHIP_PIC_MASTER:
e->set = kvm_set_pic_irq;
-   max_pin = 16;
+   max_pin = PIC_NUM_PINS;
break;
case KVM_IRQCHIP_PIC_SLAVE:
e->set = kvm_set_pic_irq;
-   max_pin = 16;
+   max_pin = PIC_NUM_PINS;
delta = 8;
break;
case KVM_IRQCHIP_IOAPIC:
-- 
MST
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] kvm tools: Simplfy disk read write function name

2012-06-04 Thread Asias He
We read and write in sectors by default. It makes little sense to add
the extra _sector string for read and write ops/function name.

Signed-off-by: Asias He 
---
 tools/kvm/disk/blk.c   |4 ++--
 tools/kvm/disk/core.c  |8 
 tools/kvm/disk/qcow.c  |   12 ++--
 tools/kvm/disk/raw.c   |   18 +-
 tools/kvm/include/kvm/disk-image.h |   16 
 5 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/tools/kvm/disk/blk.c b/tools/kvm/disk/blk.c
index 1b06155..cf853c1 100644
--- a/tools/kvm/disk/blk.c
+++ b/tools/kvm/disk/blk.c
@@ -7,8 +7,8 @@
  * raw image and blk dev are similar, so reuse raw image ops.
  */
 static struct disk_image_operations blk_dev_ops = {
-   .read_sector= raw_image__read_sector,
-   .write_sector   = raw_image__write_sector,
+   .read   = raw_image__read,
+   .write  = raw_image__write,
 };
 
 static bool is_mounted(struct stat *st)
diff --git a/tools/kvm/disk/core.c b/tools/kvm/disk/core.c
index d1d2d59..e214359 100644
--- a/tools/kvm/disk/core.c
+++ b/tools/kvm/disk/core.c
@@ -193,8 +193,8 @@ ssize_t disk_image__read(struct disk_image *disk, u64 
sector, const struct iovec
if (debug_iodelay)
msleep(debug_iodelay);
 
-   if (disk->ops->read_sector) {
-   total = disk->ops->read_sector(disk, sector, iov, iovcount, 
param);
+   if (disk->ops->read) {
+   total = disk->ops->read(disk, sector, iov, iovcount, param);
if (total < 0) {
pr_info("disk_image__read error: total=%ld\n", 
(long)total);
return total;
@@ -221,12 +221,12 @@ ssize_t disk_image__write(struct disk_image *disk, u64 
sector, const struct iove
if (debug_iodelay)
msleep(debug_iodelay);
 
-   if (disk->ops->write_sector) {
+   if (disk->ops->write) {
/*
 * Try writev based operation first
 */
 
-   total = disk->ops->write_sector(disk, sector, iov, iovcount, 
param);
+   total = disk->ops->write(disk, sector, iov, iovcount, param);
if (total < 0) {
pr_info("disk_image__write error: total=%ld\n", 
(long)total);
return total;
diff --git a/tools/kvm/disk/qcow.c b/tools/kvm/disk/qcow.c
index 23f11f2..b3221c4 100644
--- a/tools/kvm/disk/qcow.c
+++ b/tools/kvm/disk/qcow.c
@@ -1180,15 +1180,15 @@ static int qcow_disk_close(struct disk_image *disk)
 }
 
 static struct disk_image_operations qcow_disk_readonly_ops = {
-   .read_sector= qcow_read_sector,
-   .close  = qcow_disk_close,
+   .read   = qcow_read_sector,
+   .close  = qcow_disk_close,
 };
 
 static struct disk_image_operations qcow_disk_ops = {
-   .read_sector= qcow_read_sector,
-   .write_sector   = qcow_write_sector,
-   .flush  = qcow_disk_flush,
-   .close  = qcow_disk_close,
+   .read   = qcow_read_sector,
+   .write  = qcow_write_sector,
+   .flush  = qcow_disk_flush,
+   .close  = qcow_disk_close,
 };
 
 static int qcow_read_refcount_table(struct qcow *q)
diff --git a/tools/kvm/disk/raw.c b/tools/kvm/disk/raw.c
index d2df814..42ca9f1 100644
--- a/tools/kvm/disk/raw.c
+++ b/tools/kvm/disk/raw.c
@@ -6,7 +6,7 @@
 #include 
 #endif
 
-ssize_t raw_image__read_sector(struct disk_image *disk, u64 sector, const 
struct iovec *iov,
+ssize_t raw_image__read(struct disk_image *disk, u64 sector, const struct 
iovec *iov,
int iovcount, void *param)
 {
u64 offset = sector << SECTOR_SHIFT;
@@ -21,7 +21,7 @@ ssize_t raw_image__read_sector(struct disk_image *disk, u64 
sector, const struct
 #endif
 }
 
-ssize_t raw_image__write_sector(struct disk_image *disk, u64 sector, const 
struct iovec *iov,
+ssize_t raw_image__write(struct disk_image *disk, u64 sector, const struct 
iovec *iov,
int iovcount, void *param)
 {
u64 offset = sector << SECTOR_SHIFT;
@@ -36,7 +36,7 @@ ssize_t raw_image__write_sector(struct disk_image *disk, u64 
sector, const struc
 #endif
 }
 
-ssize_t raw_image__read_sector_mmap(struct disk_image *disk, u64 sector, const 
struct iovec *iov,
+ssize_t raw_image__read_mmap(struct disk_image *disk, u64 sector, const struct 
iovec *iov,
int iovcount, void *param)
 {
u64 offset = sector << SECTOR_SHIFT;
@@ -54,7 +54,7 @@ ssize_t raw_image__read_sector_mmap(struct disk_image *disk, 
u64 sector, const s
return total;
 }
 
-ssize_t raw_image__write_sector_mmap(struct disk_image *disk, u64 sector, 
const struct iovec *iov,
+ssize_t raw_image__write_mmap(struct disk_image *disk, u64 sector, const 
struct iovec *io

Re: [PATCH 12/38] powerpc/booke: Provide exception macros with interrupt name

2012-03-21 Thread Kumar Gala

On Mar 21, 2012, at 1:19 PM, Scott Wood wrote:

> On 03/21/2012 01:04 PM, Kumar Gala wrote:
>> 
>> On Feb 28, 2012, at 6:09 PM, Alexander Graf wrote:
>> 
>>> From: Scott Wood 
>>> 
>>> DO_KVM will need to identify the particular exception type.
>>> 
>>> There is an existing set of arbitrary numbers that Linux passes,
>>> but it's an undocumented mess that sort of corresponds to server/classic
>>> exception vectors but not really.
>> 
>> So what do the new names correspond to?
> 
> The names are Linux-defined.  The values are IVOR numbers.
> 
>> What header is defining MACHINE_CHECK, BOOKE_INTERRUPT_EXTERNAL, etc
>> (asm/kvm_asm.h)?
> 
> Yes, it's asm/kvm_asm.h at the moment.
> 
> It's actually BOOKE_INTERRUPT_MACHINE_CHECK, etc.  The exception macros
> paste on BOOKE_INTERRUPT_ when they use it, to keep the macro users from
> having to wrap lines even more often.
> 
>> If so we really should move these out of
>> asm/kvm_asm.h and into something a bit more appropriate.
> 
> Yes, that was one of the things I had been planning to fix post-RFC.
> Any preference what header it should be in?  asm/reg_booke.h seems to be
> the least bad option of the existing headers -- or perhaps move
> head_booke.h to arch/powerpc/include/asm.

asm/reg_booke.h seems the least painful right now.  head_booke.h is only used 
on 32-bit so that's not the best choice at this point.  We could create an 
 in addition to the one in arch/powerpc/kernel/

> Long-term it would also be nice for this to replace, rather than
> supplement, the current numbers, though as Ben pointed out there are a
> number of places throughout the code that will have to be fixed for that
> to happen.

Yeah, not too worried about that.  More just wanting it to be clear what one 
has to 'update' if adding support for a new exception.

- k--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 12/38] powerpc/booke: Provide exception macros with interrupt name

2012-03-21 Thread Scott Wood
On 03/21/2012 01:04 PM, Kumar Gala wrote:
> 
> On Feb 28, 2012, at 6:09 PM, Alexander Graf wrote:
> 
>> From: Scott Wood 
>>
>> DO_KVM will need to identify the particular exception type.
>>
>> There is an existing set of arbitrary numbers that Linux passes,
>> but it's an undocumented mess that sort of corresponds to server/classic
>> exception vectors but not really.
> 
> So what do the new names correspond to?

The names are Linux-defined.  The values are IVOR numbers.

> What header is defining MACHINE_CHECK, BOOKE_INTERRUPT_EXTERNAL, etc
> (asm/kvm_asm.h)?

Yes, it's asm/kvm_asm.h at the moment.

It's actually BOOKE_INTERRUPT_MACHINE_CHECK, etc.  The exception macros
paste on BOOKE_INTERRUPT_ when they use it, to keep the macro users from
having to wrap lines even more often.

> If so we really should move these out of
> asm/kvm_asm.h and into something a bit more appropriate.

Yes, that was one of the things I had been planning to fix post-RFC.
Any preference what header it should be in?  asm/reg_booke.h seems to be
the least bad option of the existing headers -- or perhaps move
head_booke.h to arch/powerpc/include/asm.

Long-term it would also be nice for this to replace, rather than
supplement, the current numbers, though as Ben pointed out there are a
number of places throughout the code that will have to be fixed for that
to happen.

-Scott

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/56] powerpc/booke: Provide exception macros with interrupt name

2012-03-15 Thread Alexander Graf
From: Scott Wood 

DO_KVM will need to identify the particular exception type.

There is an existing set of arbitrary numbers that Linux passes,
but it's an undocumented mess that sort of corresponds to server/classic
exception vectors but not really.

Signed-off-by: Scott Wood 
Signed-off-by: Alexander Graf 
---
 arch/powerpc/kernel/head_44x.S   |   23 +--
 arch/powerpc/kernel/head_booke.h |   41 ++
 arch/powerpc/kernel/head_fsl_booke.S |   52 +-
 3 files changed, 68 insertions(+), 48 deletions(-)

diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index 7dd2981..d1192c5 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -248,10 +248,11 @@ _ENTRY(_start);
 
 interrupt_base:
/* Critical Input Interrupt */
-   CRITICAL_EXCEPTION(0x0100, CriticalInput, unknown_exception)
+   CRITICAL_EXCEPTION(0x0100, CRITICAL, CriticalInput, unknown_exception)
 
/* Machine Check Interrupt */
-   CRITICAL_EXCEPTION(0x0200, MachineCheck, machine_check_exception)
+   CRITICAL_EXCEPTION(0x0200, MACHINE_CHECK, MachineCheck, \
+  machine_check_exception)
MCHECK_EXCEPTION(0x0210, MachineCheckA, machine_check_exception)
 
/* Data Storage Interrupt */
@@ -261,7 +262,8 @@ interrupt_base:
INSTRUCTION_STORAGE_EXCEPTION
 
/* External Input Interrupt */
-   EXCEPTION(0x0500, ExternalInput, do_IRQ, EXC_XFER_LITE)
+   EXCEPTION(0x0500, BOOKE_INTERRUPT_EXTERNAL, ExternalInput, \
+ do_IRQ, EXC_XFER_LITE)
 
/* Alignment Interrupt */
ALIGNMENT_EXCEPTION
@@ -273,29 +275,32 @@ interrupt_base:
 #ifdef CONFIG_PPC_FPU
FP_UNAVAILABLE_EXCEPTION
 #else
-   EXCEPTION(0x2010, FloatingPointUnavailable, unknown_exception, 
EXC_XFER_EE)
+   EXCEPTION(0x2010, BOOKE_INTERRUPT_FP_UNAVAIL, \
+ FloatingPointUnavailable, unknown_exception, EXC_XFER_EE)
 #endif
/* System Call Interrupt */
START_EXCEPTION(SystemCall)
-   NORMAL_EXCEPTION_PROLOG
+   NORMAL_EXCEPTION_PROLOG(BOOKE_INTERRUPT_SYSCALL)
EXC_XFER_EE_LITE(0x0c00, DoSyscall)
 
/* Auxiliary Processor Unavailable Interrupt */
-   EXCEPTION(0x2020, AuxillaryProcessorUnavailable, unknown_exception, 
EXC_XFER_EE)
+   EXCEPTION(0x2020, BOOKE_INTERRUPT_AP_UNAVAIL, \
+ AuxillaryProcessorUnavailable, unknown_exception, EXC_XFER_EE)
 
/* Decrementer Interrupt */
DECREMENTER_EXCEPTION
 
/* Fixed Internal Timer Interrupt */
/* TODO: Add FIT support */
-   EXCEPTION(0x1010, FixedIntervalTimer, unknown_exception, EXC_XFER_EE)
+   EXCEPTION(0x1010, BOOKE_INTERRUPT_FIT, FixedIntervalTimer, \
+ unknown_exception, EXC_XFER_EE)
 
/* Watchdog Timer Interrupt */
/* TODO: Add watchdog support */
 #ifdef CONFIG_BOOKE_WDT
-   CRITICAL_EXCEPTION(0x1020, WatchdogTimer, WatchdogException)
+   CRITICAL_EXCEPTION(0x1020, WATCHDOG, WatchdogTimer, WatchdogException)
 #else
-   CRITICAL_EXCEPTION(0x1020, WatchdogTimer, unknown_exception)
+   CRITICAL_EXCEPTION(0x1020, WATCHDOG, WatchdogTimer, unknown_exception)
 #endif
 
/* Data TLB Error Interrupt */
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index fc921bf..06ab353 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -2,6 +2,8 @@
 #define __HEAD_BOOKE_H__
 
 #include /* for STACK_FRAME_REGS_MARKER */
+#include 
+
 /*
  * Macros used for common Book-e exception handling
  */
@@ -28,7 +30,7 @@
  */
 #define THREAD_NORMSAVE(offset)(THREAD_NORMSAVES + (offset * 4))
 
-#define NORMAL_EXCEPTION_PROLOG
 \
+#define NORMAL_EXCEPTION_PROLOG(intno) 
 \
mtspr   SPRN_SPRG_WSCRATCH0, r10;   /* save one register */  \
mfspr   r10, SPRN_SPRG_THREAD;   \
stw r11, THREAD_NORMSAVE(0)(r10);\
@@ -113,7 +115,7 @@
  * registers as the normal prolog above. Instead we use a portion of the
  * critical/machine check exception stack at low physical addresses.
  */
-#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, exc_level_srr0, exc_level_srr1) \
+#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, intno, exc_level_srr0, 
exc_level_srr1) \
mtspr   SPRN_SPRG_WSCRATCH_##exc_level,r8;   \
BOOKE_LOAD_EXC_LEVEL_STACK(exc_level);/* r8 points to the exc_level 
stack*/ \
stw r9,GPR9(r8);/* save various registers  */\
@@ -162,12 +164,13 @@
SAVE_4GPRS(3, r11);  \
SAVE_2GPRS(7, r11)
 
-#define CRITICAL_EXCEPTION_PROLOG \
-   EXC_LEVEL_EXCEPTION_PROLOG(CRIT, S

[PATCH 12/38] powerpc/booke: Provide exception macros with interrupt name

2012-02-28 Thread Alexander Graf
From: Scott Wood 

DO_KVM will need to identify the particular exception type.

There is an existing set of arbitrary numbers that Linux passes,
but it's an undocumented mess that sort of corresponds to server/classic
exception vectors but not really.

Signed-off-by: Scott Wood 
Signed-off-by: Alexander Graf 
---
 arch/powerpc/kernel/head_44x.S   |   23 +--
 arch/powerpc/kernel/head_booke.h |   41 ++
 arch/powerpc/kernel/head_fsl_booke.S |   52 +-
 3 files changed, 68 insertions(+), 48 deletions(-)

diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index 7dd2981..d1192c5 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -248,10 +248,11 @@ _ENTRY(_start);
 
 interrupt_base:
/* Critical Input Interrupt */
-   CRITICAL_EXCEPTION(0x0100, CriticalInput, unknown_exception)
+   CRITICAL_EXCEPTION(0x0100, CRITICAL, CriticalInput, unknown_exception)
 
/* Machine Check Interrupt */
-   CRITICAL_EXCEPTION(0x0200, MachineCheck, machine_check_exception)
+   CRITICAL_EXCEPTION(0x0200, MACHINE_CHECK, MachineCheck, \
+  machine_check_exception)
MCHECK_EXCEPTION(0x0210, MachineCheckA, machine_check_exception)
 
/* Data Storage Interrupt */
@@ -261,7 +262,8 @@ interrupt_base:
INSTRUCTION_STORAGE_EXCEPTION
 
/* External Input Interrupt */
-   EXCEPTION(0x0500, ExternalInput, do_IRQ, EXC_XFER_LITE)
+   EXCEPTION(0x0500, BOOKE_INTERRUPT_EXTERNAL, ExternalInput, \
+ do_IRQ, EXC_XFER_LITE)
 
/* Alignment Interrupt */
ALIGNMENT_EXCEPTION
@@ -273,29 +275,32 @@ interrupt_base:
 #ifdef CONFIG_PPC_FPU
FP_UNAVAILABLE_EXCEPTION
 #else
-   EXCEPTION(0x2010, FloatingPointUnavailable, unknown_exception, 
EXC_XFER_EE)
+   EXCEPTION(0x2010, BOOKE_INTERRUPT_FP_UNAVAIL, \
+ FloatingPointUnavailable, unknown_exception, EXC_XFER_EE)
 #endif
/* System Call Interrupt */
START_EXCEPTION(SystemCall)
-   NORMAL_EXCEPTION_PROLOG
+   NORMAL_EXCEPTION_PROLOG(BOOKE_INTERRUPT_SYSCALL)
EXC_XFER_EE_LITE(0x0c00, DoSyscall)
 
/* Auxiliary Processor Unavailable Interrupt */
-   EXCEPTION(0x2020, AuxillaryProcessorUnavailable, unknown_exception, 
EXC_XFER_EE)
+   EXCEPTION(0x2020, BOOKE_INTERRUPT_AP_UNAVAIL, \
+ AuxillaryProcessorUnavailable, unknown_exception, EXC_XFER_EE)
 
/* Decrementer Interrupt */
DECREMENTER_EXCEPTION
 
/* Fixed Internal Timer Interrupt */
/* TODO: Add FIT support */
-   EXCEPTION(0x1010, FixedIntervalTimer, unknown_exception, EXC_XFER_EE)
+   EXCEPTION(0x1010, BOOKE_INTERRUPT_FIT, FixedIntervalTimer, \
+ unknown_exception, EXC_XFER_EE)
 
/* Watchdog Timer Interrupt */
/* TODO: Add watchdog support */
 #ifdef CONFIG_BOOKE_WDT
-   CRITICAL_EXCEPTION(0x1020, WatchdogTimer, WatchdogException)
+   CRITICAL_EXCEPTION(0x1020, WATCHDOG, WatchdogTimer, WatchdogException)
 #else
-   CRITICAL_EXCEPTION(0x1020, WatchdogTimer, unknown_exception)
+   CRITICAL_EXCEPTION(0x1020, WATCHDOG, WatchdogTimer, unknown_exception)
 #endif
 
/* Data TLB Error Interrupt */
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index fc921bf..06ab353 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -2,6 +2,8 @@
 #define __HEAD_BOOKE_H__
 
 #include /* for STACK_FRAME_REGS_MARKER */
+#include 
+
 /*
  * Macros used for common Book-e exception handling
  */
@@ -28,7 +30,7 @@
  */
 #define THREAD_NORMSAVE(offset)(THREAD_NORMSAVES + (offset * 4))
 
-#define NORMAL_EXCEPTION_PROLOG
 \
+#define NORMAL_EXCEPTION_PROLOG(intno) 
 \
mtspr   SPRN_SPRG_WSCRATCH0, r10;   /* save one register */  \
mfspr   r10, SPRN_SPRG_THREAD;   \
stw r11, THREAD_NORMSAVE(0)(r10);\
@@ -113,7 +115,7 @@
  * registers as the normal prolog above. Instead we use a portion of the
  * critical/machine check exception stack at low physical addresses.
  */
-#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, exc_level_srr0, exc_level_srr1) \
+#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, intno, exc_level_srr0, 
exc_level_srr1) \
mtspr   SPRN_SPRG_WSCRATCH_##exc_level,r8;   \
BOOKE_LOAD_EXC_LEVEL_STACK(exc_level);/* r8 points to the exc_level 
stack*/ \
stw r9,GPR9(r8);/* save various registers  */\
@@ -162,12 +164,13 @@
SAVE_4GPRS(3, r11);  \
SAVE_2GPRS(7, r11)
 
-#define CRITICAL_EXCEPTION_PROLOG \
-   EXC_LEVEL_EXCEPTION_PROLOG(CRIT, S

[PATCH 12/37] powerpc/booke: Provide exception macros with interrupt name

2012-02-24 Thread Alexander Graf
From: Scott Wood 

DO_KVM will need to identify the particular exception type.

There is an existing set of arbitrary numbers that Linux passes,
but it's an undocumented mess that sort of corresponds to server/classic
exception vectors but not really.

Signed-off-by: Scott Wood 
Signed-off-by: Alexander Graf 
---
 arch/powerpc/kernel/head_44x.S   |   23 +--
 arch/powerpc/kernel/head_booke.h |   41 ++
 arch/powerpc/kernel/head_fsl_booke.S |   52 +-
 3 files changed, 68 insertions(+), 48 deletions(-)

diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index 7dd2981..d1192c5 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -248,10 +248,11 @@ _ENTRY(_start);
 
 interrupt_base:
/* Critical Input Interrupt */
-   CRITICAL_EXCEPTION(0x0100, CriticalInput, unknown_exception)
+   CRITICAL_EXCEPTION(0x0100, CRITICAL, CriticalInput, unknown_exception)
 
/* Machine Check Interrupt */
-   CRITICAL_EXCEPTION(0x0200, MachineCheck, machine_check_exception)
+   CRITICAL_EXCEPTION(0x0200, MACHINE_CHECK, MachineCheck, \
+  machine_check_exception)
MCHECK_EXCEPTION(0x0210, MachineCheckA, machine_check_exception)
 
/* Data Storage Interrupt */
@@ -261,7 +262,8 @@ interrupt_base:
INSTRUCTION_STORAGE_EXCEPTION
 
/* External Input Interrupt */
-   EXCEPTION(0x0500, ExternalInput, do_IRQ, EXC_XFER_LITE)
+   EXCEPTION(0x0500, BOOKE_INTERRUPT_EXTERNAL, ExternalInput, \
+ do_IRQ, EXC_XFER_LITE)
 
/* Alignment Interrupt */
ALIGNMENT_EXCEPTION
@@ -273,29 +275,32 @@ interrupt_base:
 #ifdef CONFIG_PPC_FPU
FP_UNAVAILABLE_EXCEPTION
 #else
-   EXCEPTION(0x2010, FloatingPointUnavailable, unknown_exception, 
EXC_XFER_EE)
+   EXCEPTION(0x2010, BOOKE_INTERRUPT_FP_UNAVAIL, \
+ FloatingPointUnavailable, unknown_exception, EXC_XFER_EE)
 #endif
/* System Call Interrupt */
START_EXCEPTION(SystemCall)
-   NORMAL_EXCEPTION_PROLOG
+   NORMAL_EXCEPTION_PROLOG(BOOKE_INTERRUPT_SYSCALL)
EXC_XFER_EE_LITE(0x0c00, DoSyscall)
 
/* Auxiliary Processor Unavailable Interrupt */
-   EXCEPTION(0x2020, AuxillaryProcessorUnavailable, unknown_exception, 
EXC_XFER_EE)
+   EXCEPTION(0x2020, BOOKE_INTERRUPT_AP_UNAVAIL, \
+ AuxillaryProcessorUnavailable, unknown_exception, EXC_XFER_EE)
 
/* Decrementer Interrupt */
DECREMENTER_EXCEPTION
 
/* Fixed Internal Timer Interrupt */
/* TODO: Add FIT support */
-   EXCEPTION(0x1010, FixedIntervalTimer, unknown_exception, EXC_XFER_EE)
+   EXCEPTION(0x1010, BOOKE_INTERRUPT_FIT, FixedIntervalTimer, \
+ unknown_exception, EXC_XFER_EE)
 
/* Watchdog Timer Interrupt */
/* TODO: Add watchdog support */
 #ifdef CONFIG_BOOKE_WDT
-   CRITICAL_EXCEPTION(0x1020, WatchdogTimer, WatchdogException)
+   CRITICAL_EXCEPTION(0x1020, WATCHDOG, WatchdogTimer, WatchdogException)
 #else
-   CRITICAL_EXCEPTION(0x1020, WatchdogTimer, unknown_exception)
+   CRITICAL_EXCEPTION(0x1020, WATCHDOG, WatchdogTimer, unknown_exception)
 #endif
 
/* Data TLB Error Interrupt */
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index fc921bf..06ab353 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -2,6 +2,8 @@
 #define __HEAD_BOOKE_H__
 
 #include /* for STACK_FRAME_REGS_MARKER */
+#include 
+
 /*
  * Macros used for common Book-e exception handling
  */
@@ -28,7 +30,7 @@
  */
 #define THREAD_NORMSAVE(offset)(THREAD_NORMSAVES + (offset * 4))
 
-#define NORMAL_EXCEPTION_PROLOG
 \
+#define NORMAL_EXCEPTION_PROLOG(intno) 
 \
mtspr   SPRN_SPRG_WSCRATCH0, r10;   /* save one register */  \
mfspr   r10, SPRN_SPRG_THREAD;   \
stw r11, THREAD_NORMSAVE(0)(r10);\
@@ -113,7 +115,7 @@
  * registers as the normal prolog above. Instead we use a portion of the
  * critical/machine check exception stack at low physical addresses.
  */
-#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, exc_level_srr0, exc_level_srr1) \
+#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, intno, exc_level_srr0, 
exc_level_srr1) \
mtspr   SPRN_SPRG_WSCRATCH_##exc_level,r8;   \
BOOKE_LOAD_EXC_LEVEL_STACK(exc_level);/* r8 points to the exc_level 
stack*/ \
stw r9,GPR9(r8);/* save various registers  */\
@@ -162,12 +164,13 @@
SAVE_4GPRS(3, r11);  \
SAVE_2GPRS(7, r11)
 
-#define CRITICAL_EXCEPTION_PROLOG \
-   EXC_LEVEL_EXCEPTION_PROLOG(CRIT, S

Re: [Qemu-devel] [PATCHv3 1/4] pci_bridge: user-friendly default bus name

2012-02-22 Thread Anthony Liguori

On 02/20/2012 04:52 PM, Michael S. Tsirkin wrote:

For a pci bridge device, if we don't override
the name with custom code, the bus will be addressed as
.0, where id is the id specified by the user.

Since PCI Bridge devices have a single bus each, we don't need
the index: address the bus using the parent device name.
This is better since this way users don't care about
our internal bus/device distinctions.

As far as I could see, we only have built-in
bridges at this point which always override the
name. So this change will only affect ioh3420.c.

Signed-off-by: Michael S. Tsirkin


Reviewed-by: Anthony Liguori 

I think we're safe here from a compatibility perspective.

Regards,

Anthony Liguori


---
  hw/pci_bridge.c |   10 ++
  1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/hw/pci_bridge.c b/hw/pci_bridge.c
index fea3873..8a6 100644
--- a/hw/pci_bridge.c
+++ b/hw/pci_bridge.c
@@ -314,6 +314,16 @@ int pci_bridge_initfn(PCIDevice *dev)
  pci_set_word(dev->config + PCI_SEC_STATUS,
   PCI_STATUS_66MHZ | PCI_STATUS_FAST_BACK);

+/*
+ * If we don't specify the name, the bus will be addressed as.0, where
+ * id is the device id.
+ * Since PCI Bridge devices have a single bus each, we don't need the 
index:
+ * let users address the bus using the device name.
+ */
+if (!br->bus_name&&  dev->qdev.id&&  *dev->qdev.id) {
+   br->bus_name = dev->qdev.id;
+}
+
  qbus_create_inplace(&sec_bus->qbus,&pci_bus_info,&dev->qdev,
  br->bus_name);
  sec_bus->parent_dev = dev;


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 1/4] pci_bridge: user-friendly default bus name

2012-02-20 Thread Michael S. Tsirkin
For a pci bridge device, if we don't override
the name with custom code, the bus will be addressed as
.0, where id is the id specified by the user.

Since PCI Bridge devices have a single bus each, we don't need
the index: address the bus using the parent device name.
This is better since this way users don't care about
our internal bus/device distinctions.

As far as I could see, we only have built-in
bridges at this point which always override the
name. So this change will only affect ioh3420.c.

Signed-off-by: Michael S. Tsirkin 
---
 hw/pci_bridge.c |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/hw/pci_bridge.c b/hw/pci_bridge.c
index fea3873..8a6 100644
--- a/hw/pci_bridge.c
+++ b/hw/pci_bridge.c
@@ -314,6 +314,16 @@ int pci_bridge_initfn(PCIDevice *dev)
 pci_set_word(dev->config + PCI_SEC_STATUS,
  PCI_STATUS_66MHZ | PCI_STATUS_FAST_BACK);
 
+/*
+ * If we don't specify the name, the bus will be addressed as .0, where
+ * id is the device id.
+ * Since PCI Bridge devices have a single bus each, we don't need the 
index:
+ * let users address the bus using the device name.
+ */
+if (!br->bus_name && dev->qdev.id && *dev->qdev.id) {
+   br->bus_name = dev->qdev.id;
+}
+
 qbus_create_inplace(&sec_bus->qbus, &pci_bus_info, &dev->qdev,
 br->bus_name);
 sec_bus->parent_dev = dev;
-- 
1.7.9.111.gf3fb0

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/30] powerpc/booke: Provide exception macros with interrupt name

2012-02-17 Thread Alexander Graf
From: Scott Wood 

DO_KVM will need to identify the particular exception type.

There is an existing set of arbitrary numbers that Linux passes,
but it's an undocumented mess that sort of corresponds to server/classic
exception vectors but not really.

Signed-off-by: Scott Wood 
Signed-off-by: Alexander Graf 
---
 arch/powerpc/kernel/head_44x.S   |   23 +--
 arch/powerpc/kernel/head_booke.h |   41 ++
 arch/powerpc/kernel/head_fsl_booke.S |   52 +-
 3 files changed, 68 insertions(+), 48 deletions(-)

diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index 7dd2981..d1192c5 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -248,10 +248,11 @@ _ENTRY(_start);
 
 interrupt_base:
/* Critical Input Interrupt */
-   CRITICAL_EXCEPTION(0x0100, CriticalInput, unknown_exception)
+   CRITICAL_EXCEPTION(0x0100, CRITICAL, CriticalInput, unknown_exception)
 
/* Machine Check Interrupt */
-   CRITICAL_EXCEPTION(0x0200, MachineCheck, machine_check_exception)
+   CRITICAL_EXCEPTION(0x0200, MACHINE_CHECK, MachineCheck, \
+  machine_check_exception)
MCHECK_EXCEPTION(0x0210, MachineCheckA, machine_check_exception)
 
/* Data Storage Interrupt */
@@ -261,7 +262,8 @@ interrupt_base:
INSTRUCTION_STORAGE_EXCEPTION
 
/* External Input Interrupt */
-   EXCEPTION(0x0500, ExternalInput, do_IRQ, EXC_XFER_LITE)
+   EXCEPTION(0x0500, BOOKE_INTERRUPT_EXTERNAL, ExternalInput, \
+ do_IRQ, EXC_XFER_LITE)
 
/* Alignment Interrupt */
ALIGNMENT_EXCEPTION
@@ -273,29 +275,32 @@ interrupt_base:
 #ifdef CONFIG_PPC_FPU
FP_UNAVAILABLE_EXCEPTION
 #else
-   EXCEPTION(0x2010, FloatingPointUnavailable, unknown_exception, 
EXC_XFER_EE)
+   EXCEPTION(0x2010, BOOKE_INTERRUPT_FP_UNAVAIL, \
+ FloatingPointUnavailable, unknown_exception, EXC_XFER_EE)
 #endif
/* System Call Interrupt */
START_EXCEPTION(SystemCall)
-   NORMAL_EXCEPTION_PROLOG
+   NORMAL_EXCEPTION_PROLOG(BOOKE_INTERRUPT_SYSCALL)
EXC_XFER_EE_LITE(0x0c00, DoSyscall)
 
/* Auxiliary Processor Unavailable Interrupt */
-   EXCEPTION(0x2020, AuxillaryProcessorUnavailable, unknown_exception, 
EXC_XFER_EE)
+   EXCEPTION(0x2020, BOOKE_INTERRUPT_AP_UNAVAIL, \
+ AuxillaryProcessorUnavailable, unknown_exception, EXC_XFER_EE)
 
/* Decrementer Interrupt */
DECREMENTER_EXCEPTION
 
/* Fixed Internal Timer Interrupt */
/* TODO: Add FIT support */
-   EXCEPTION(0x1010, FixedIntervalTimer, unknown_exception, EXC_XFER_EE)
+   EXCEPTION(0x1010, BOOKE_INTERRUPT_FIT, FixedIntervalTimer, \
+ unknown_exception, EXC_XFER_EE)
 
/* Watchdog Timer Interrupt */
/* TODO: Add watchdog support */
 #ifdef CONFIG_BOOKE_WDT
-   CRITICAL_EXCEPTION(0x1020, WatchdogTimer, WatchdogException)
+   CRITICAL_EXCEPTION(0x1020, WATCHDOG, WatchdogTimer, WatchdogException)
 #else
-   CRITICAL_EXCEPTION(0x1020, WatchdogTimer, unknown_exception)
+   CRITICAL_EXCEPTION(0x1020, WATCHDOG, WatchdogTimer, unknown_exception)
 #endif
 
/* Data TLB Error Interrupt */
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index fc921bf..06ab353 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -2,6 +2,8 @@
 #define __HEAD_BOOKE_H__
 
 #include /* for STACK_FRAME_REGS_MARKER */
+#include 
+
 /*
  * Macros used for common Book-e exception handling
  */
@@ -28,7 +30,7 @@
  */
 #define THREAD_NORMSAVE(offset)(THREAD_NORMSAVES + (offset * 4))
 
-#define NORMAL_EXCEPTION_PROLOG
 \
+#define NORMAL_EXCEPTION_PROLOG(intno) 
 \
mtspr   SPRN_SPRG_WSCRATCH0, r10;   /* save one register */  \
mfspr   r10, SPRN_SPRG_THREAD;   \
stw r11, THREAD_NORMSAVE(0)(r10);\
@@ -113,7 +115,7 @@
  * registers as the normal prolog above. Instead we use a portion of the
  * critical/machine check exception stack at low physical addresses.
  */
-#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, exc_level_srr0, exc_level_srr1) \
+#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, intno, exc_level_srr0, 
exc_level_srr1) \
mtspr   SPRN_SPRG_WSCRATCH_##exc_level,r8;   \
BOOKE_LOAD_EXC_LEVEL_STACK(exc_level);/* r8 points to the exc_level 
stack*/ \
stw r9,GPR9(r8);/* save various registers  */\
@@ -162,12 +164,13 @@
SAVE_4GPRS(3, r11);  \
SAVE_2GPRS(7, r11)
 
-#define CRITICAL_EXCEPTION_PROLOG \
-   EXC_LEVEL_EXCEPTION_PROLOG(CRIT, S

Re: [RFC PATCH 13/16] powerpc/booke: Provide exception macros with interrupt name

2012-02-17 Thread Benjamin Herrenschmidt
On Tue, 2011-12-20 at 19:34 -0600, Scott Wood wrote:
> 
> There is an existing set of arbitrary numbers that Linux passes,
> but it's an undocumented mess that sort of corresponds to
> server/classic
> exception vectors but not really.
> 
> FIXME: Replace the existing trap numbering rather than add to it.

While this is a good idea, the problem is that we do have quite a few
things here or there that check regs->trap and act based on the trap
number, so we'd have to find them all and replace those comparison with
something symbolic.

Cheers,
Ben.


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm tool: Make kvm structure to carry name copy

2012-02-04 Thread Cyrill Gorcunov
On Sat, Feb 04, 2012 at 02:57:23PM +0200, Pekka Enberg wrote:
> On Sat, 4 Feb 2012, Cyrill Gorcunov wrote:
> >Index: linux-2.6.git/tools/kvm/kvm.c
> >===
> >--- linux-2.6.git.orig/tools/kvm/kvm.c
> >+++ linux-2.6.git/tools/kvm/kvm.c
> >@@ -254,6 +254,7 @@ int kvm__exit(struct kvm *kvm)
> > kvm__arch_delete_ram(kvm);
> > kvm_ipc__stop();
> > kvm__remove_socket(kvm->name);
> >+free((void *)kvm->name);
> 
> Please fix the struct definition and drop the cast.
> 

I believe having it as const char * might save us some
potential troubles, but sure, here we go ;)

Cyrill
---
kvm tool: Make kvm structure to carry name copy

If default guest name is used (which is the default
case) the kvm might end up carrying the pointer to
a name which is allocated on stack.

kvm_cmd_run_init
  (on stack) default_name
  kvm__init(..., default_name)
kvm->name = default_name

So make it to carry a copy of name.

Signed-off-by: Cyrill Gorcunov 
---

 tools/kvm/kvm.c  |9 +++--
 tools/kvm/powerpc/include/kvm/kvm-arch.h |2 +-
 tools/kvm/x86/include/kvm/kvm-arch.h |2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

Index: linux-2.6.git/tools/kvm/kvm.c
===
--- linux-2.6.git.orig/tools/kvm/kvm.c
+++ linux-2.6.git/tools/kvm/kvm.c
@@ -254,6 +254,7 @@ int kvm__exit(struct kvm *kvm)
kvm__arch_delete_ram(kvm);
    kvm_ipc__stop();
kvm__remove_socket(kvm->name);
+   free(kvm->name);
free(kvm);
 
return 0;
@@ -377,6 +378,12 @@ struct kvm *kvm__init(const char *kvm_de
    goto cleanup;
}
 
+   kvm->name = strdup(name);
+   if (!kvm->name) {
+   ret = -ENOMEM;
+   goto cleanup;
+   }
+
if (kvm__check_extensions(kvm)) {
pr_err("A required KVM extention is not supported by OS");
ret = -ENOSYS;
@@ -384,8 +391,6 @@ struct kvm *kvm__init(const char *kvm_de
 
kvm__arch_init(kvm, hugetlbfs_path, ram_size);
 
-   kvm->name = name;
-
kvm_ipc__start(kvm__create_socket(kvm));
kvm_ipc__register_handler(KVM_IPC_PID, kvm__pid);
return kvm;
Index: linux-2.6.git/tools/kvm/powerpc/include/kvm/kvm-arch.h
===
--- linux-2.6.git.orig/tools/kvm/powerpc/include/kvm/kvm-arch.h
+++ linux-2.6.git/tools/kvm/powerpc/include/kvm/kvm-arch.h
@@ -64,7 +64,7 @@ struct kvm {
unsigned long   fdt_gra;
unsigned long   initrd_gra;
unsigned long   initrd_size;
-   const char  *name;
+   char*name;
int vm_state;
 };
 
Index: linux-2.6.git/tools/kvm/x86/include/kvm/kvm-arch.h
===
--- linux-2.6.git.orig/tools/kvm/x86/include/kvm/kvm-arch.h
+++ linux-2.6.git/tools/kvm/x86/include/kvm/kvm-arch.h
@@ -48,7 +48,7 @@ struct kvm {
struct disk_image   **disks;
int nr_disks;
 
-   const char  *name;
+   char*name;
 
int vm_state;
 };
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm tool: Make kvm structure to carry name copy

2012-02-04 Thread Pekka Enberg

On Sat, 4 Feb 2012, Cyrill Gorcunov wrote:

Index: linux-2.6.git/tools/kvm/kvm.c
===
--- linux-2.6.git.orig/tools/kvm/kvm.c
+++ linux-2.6.git/tools/kvm/kvm.c
@@ -254,6 +254,7 @@ int kvm__exit(struct kvm *kvm)
kvm__arch_delete_ram(kvm);
kvm_ipc__stop();
kvm__remove_socket(kvm->name);
+   free((void *)kvm->name);


Please fix the struct definition and drop the cast.


free(kvm);

return 0;
@@ -377,6 +378,12 @@ struct kvm *kvm__init(const char *kvm_de

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm tool: Make kvm structure to carry name copy

2012-02-04 Thread Cyrill Gorcunov
On Sat, Feb 04, 2012 at 04:20:05PM +0400, Cyrill Gorcunov wrote:
> On Sat, Feb 04, 2012 at 02:15:36PM +0200, Pekka Enberg wrote:
> > On Fri, 3 Feb 2012, Cyrill Gorcunov wrote:
> > >If guest name is used (which is default case) the kvm might end
> > >up carrying the pointer to name which is allocated on stack.
> > >
> > >kvm_cmd_run_init
> > > (on stack) default_name
> > > kvm__init(..., default_name)
> > >   kvm->name = default_name
> > >
> > >So I think better to allow kvm to carry own copy
> > >of guest name. 64 symbols should be more than enough.
> > >
> > >Signed-off-by: Cyrill Gorcunov 
> > >---
> > >
> > >I hope I didn't miss anything?
> > 
> > Can't we just use strdup()?
> > 
> 
> Yeah, I think this will be even better, I'll update.
> 

Something like below I think.

    Cyrill
---
Subject: [PATCH] kvm tool: Make kvm structure to carry name copy

If default guest name is used (which is the default
case) the kvm might end up carrying the pointer to
a name which is allocated on stack.

kvm_cmd_run_init
  (on stack) default_name
  kvm__init(..., default_name)
kvm->name = default_name

So make it to carry a copy of name.

Signed-off-by: Cyrill Gorcunov 
---

 tools/kvm/kvm.c |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Index: linux-2.6.git/tools/kvm/kvm.c
===
--- linux-2.6.git.orig/tools/kvm/kvm.c
+++ linux-2.6.git/tools/kvm/kvm.c
@@ -254,6 +254,7 @@ int kvm__exit(struct kvm *kvm)
kvm__arch_delete_ram(kvm);
kvm_ipc__stop();
kvm__remove_socket(kvm->name);
+   free((void *)kvm->name);
    free(kvm);
 
return 0;
@@ -377,6 +378,12 @@ struct kvm *kvm__init(const char *kvm_de
goto cleanup;
}
 
+   kvm->name = strdup(name);
+   if (!kvm->name) {
+   ret = -ENOMEM;
+   goto cleanup;
+   }
+
if (kvm__check_extensions(kvm)) {
pr_err("A required KVM extention is not supported by OS");
ret = -ENOSYS;
@@ -384,8 +391,6 @@ struct kvm *kvm__init(const char *kvm_de
 
kvm__arch_init(kvm, hugetlbfs_path, ram_size);
 
-   kvm->name = name;
-
kvm_ipc__start(kvm__create_socket(kvm));
kvm_ipc__register_handler(KVM_IPC_PID, kvm__pid);
return kvm;
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   3   >