spapr: add "compat" machine option
v3 cover spapr: add "compat" machine option
The further I go, more questions I get.
Here are 6 patches.
The first three is what I would like to have in QEMU to support "compat" option for a CPU. The option now accepts "power6"/"power7" as after all we will limit number of threads per core (not in this series though) and since 2.05 does not limit number of threads at all, referring to actual CPU models seems right.
The last three is what I would suggest doing if we needed ability to enable/disable CPU features the way x86 does this. I used "VSX" as an example but this is just an example so "-cpu host,-vsx,+vsx,vsx=on" works. Using this, I suspect I could try converting x86's parser for "-cpu", would it work?
btw I am sure there must be macro like BITNR (convert mask with 1 bit set to a number of the bit which is set) but I failed to find it. What did I miss?
Please, comment. Thanks.
Alexey Kardashevskiy (6):
cpu: add suboptions support
target-ppc: make use of new -cpu suboptions handling
target-ppc: add "compat" CPU option
qemu-option: support +foo/-foo command line agruments
bitops: add BITNR macro
target-ppc: demonstrate new "vsx" property
hw/ppc/spapr.c | 13 +++++++- include/qemu/bitops.h | 12 ++++++++ include/qom/cpu.h | 29 ++++++++++++++++++ include/sysemu/sysemu.h | 1 + qom/cpu.c | 27 +++++++++++++++++ target-ppc/cpu-models.h | 10 +++++++ target-ppc/cpu.h | 4 +++ target-ppc/translate_init.c | 73 +++++++++++++++++++++++++++++++++++++++++++++ util/qemu-option.c | 6 ++++ vl.c | 42 ++++++++++++++++++++++++++ 10 files changed, 216 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.4.rc4
PATCH v3 1/6 cpu: add suboptions support
This adds suboptions support for -cpu.
--- include/qom/cpu.h | 29 +++++++++++++++++++++++++++++ include/sysemu/sysemu.h | 1 + qom/cpu.c | 27 +++++++++++++++++++++++++++ vl.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+)
include/qom/cpu.h +29 -0
@@ -124,6 +124,7 @@ typedef struct CPUClass { int cpuid, void *opaque);int (*write_elf32_qemunote)(WriteCoreDumpFunction f,CPUState *cpu,void *opaque); +void (*parse_options)(CPUState *cpu,Error **errp);const struct VMStateDescription *vmsd;int gdb_num_core_regs;
@@ -327,6 +328,34 @@ static inline hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr addr)#endif /** +* cpu_parse_options: +* @cpu: The CPU to set options for. +*/ +static inline int cpu_parse_options (CPUState *cpu) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); +Error *err =NULL ; + +if (cc->parse_options) { + cc->parse_options (cpu, &err); +if (err) { +return -1 ; + } + } + +/* No callback, let arch do it the old way */ +return 0 ; +} + +/** +* cpu_default_parse_options_func: +* The default handler for CPUClass::parse_options +* @cpu: the CPU to set option for. +* @errp: the handling error descriptor. +*/ +void cpu_default_parse_options_func (CPUState *cpu,Error **errp); + +/** * cpu_reset: * @cpu: The CPU whose state is to be reset. */
include/sysemu/sysemu.h +1 -0
@@ -190,6 +190,7 @@ char *get_boot_devices_list(size_t *size);DeviceState *get_boot_device (uint32_t position);QemuOpts *qemu_get_machine_opts (void ); +QemuOpts *qemu_get_cpu_opts (void );bool usb_enabled (bool default_usb);
qom/cpu.c +27 -0
@@ -24,6 +24,8 @@#include "qemu/notify.h" #include "qemu/log.h" #include "sysemu/sysemu.h" +#include "qapi/qmp/qerror.h" +#include "qemu/config-file.h" bool cpu_exists (int64_t id) {
@@ -186,6 +188,31 @@ void cpu_reset(CPUState *cpu) } } +static int cpu_set_property (const char *name,const char *value,void *opaque) +{ +Error *err =NULL ; + +if (strcmp (name,"type" ) ==0 ) { +return 0 ; + } + +object_property_parse (opaque, value, name, &err); +if (err !=NULL ) { +qerror_report_err (err); +error_free (err); +return -1 ; + } + +return 0 ; +} + +void cpu_default_parse_options_func (CPUState *cpu,Error **errp) +{ +if (qemu_opt_foreach (qemu_get_cpu_opts (), cpu_set_property, cpu,1 )) { +error_setg (errp,"Bad option" ); + } +} +static void cpu_common_reset (CPUState *cpu) {CPUClass *cc =CPU_GET_CLASS (cpu);
vl.c +42 -0
67 lines not on this page · raw message
Signature · 1 line
1.8.4.rc4
Re: [Qemu-devel] [PATCH v3 1/6] cpu: add suboptions support
Quoted 101 lines · Alexey Kardashevskiy
This adds suboptions support for -cpu.
Cc Andreas Färber <[email protected]>Signed-off-by Alexey Kardashevskiy <[email protected]>--- include/qom/cpu.h | 29 +++++++++++++++++++++++++++++ include/sysemu/sysemu.h | 1 + qom/cpu.c | 27 +++++++++++++++++++++++++++ vl.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+)include/qom/cpu.h +29
-0@@ -124,6 +124,7 @@ typedef struct CPUClass { int cpuid, void *opaque);int (*write_elf32_qemunote)(WriteCoreDumpFunction f,CPUState *cpu,void *opaque); +void (*parse_options)(CPUState *cpu,Error **errp);const struct VMStateDescription *vmsd;int gdb_num_core_regs;@@ -327,6 +328,34 @@ static inline hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr addr)#endif /** +* cpu_parse_options: +* @cpu: The CPU to set options for. +*/ +static inline int cpu_parse_options (CPUState *cpu) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); +Error *err =NULL ; + +if (cc->parse_options) { + cc->parse_options (cpu, &err); +if (err) { +return -1 ; + } + } + +/* No callback, let arch do it the old way */ +return 0 ; +} + +/** +* cpu_default_parse_options_func: +* The default handler for CPUClass::parse_options +* @cpu: the CPU to set option for. +* @errp: the handling error descriptor. +*/ +void cpu_default_parse_options_func (CPUState *cpu,Error **errp); + +/** * cpu_reset: * @cpu: The CPU whose state is to be reset. */ include/sysemu/sysemu.h +1
-0@@ -190,6 +190,7 @@ char *get_boot_devices_list(size_t *size);DeviceState *get_boot_device (uint32_t position);QemuOpts *qemu_get_machine_opts (void ); +QemuOpts *qemu_get_cpu_opts (void );bool usb_enabled (bool default_usb);qom/cpu.c +16
-0@@ -24,6 +24,8 @@#include "qemu/notify.h" #include "qemu/log.h" #include "sysemu/sysemu.h" +#include "qapi/qmp/qerror.h" +#include "qemu/config-file.h" bool cpu_exists (int64_t id) {@@ -186,6 +188,31 @@ void cpu_reset(CPUState *cpu) } } +static int cpu_set_property (const char *name,const char *value,void *opaque) +{ +Error *err =NULL ; + +if (strcmp (name,"type" ) ==0 ) { +return 0 ; + } + +object_property_parse (opaque, value, name, &err); +if (err !=NULL ) { +qerror_report_err (err); +error_free (err); +return -1 ; + }
qom/cpu.c void cpu_reset(CPUState *cpu) · line 214
Quoted 10 lines
qom/cpu.c +10
-0+ +return 0 ; +} + +void cpu_default_parse_options_func (CPUState *cpu,Error **errp) +{ +if (qemu_opt_foreach (qemu_get_cpu_opts (), cpu_set_property, cpu,1 )) { +error_setg (errp,"Bad option" ); + } +}
btw there is a problem - all this qemu_opt stuff normally lives in vl.c so this patch does not compile with linux-user target.
How to solve this properly before I continue spamming the list? :)
Signature · 1 line
Alexey
Re: [Qemu-devel] [PATCH v3 1/6] cpu: add suboptions support
Il 30/11/2013 11:10, Alexey Kardashevskiy ha scritto:
Quoted 2 lines
btw there is a problem - all this
qemu_optstuff normally lives invl.cso this patch does not compile with linux-user target.
Which qemu_opt exactly?
Perhaps you can just move it to util/qemu-option.c or something like that.
Paolo
Quoted 2 lines
How to solve this properly before I continue spamming the list? :)
Re: [Qemu-devel] [PATCH v3 1/6] cpu: add suboptions support
Quoted 7 lines · Paolo Bonzini
Il 30/11/2013 11:10, Alexey Kardashevskiy ha scritto:
Quoted 2 lines
btw there is a problem - all this
qemu_optstuff normally lives invl.cso this patch does not compile with linux-user target.Which
qemu_optexactly?Perhaps you can just move it to
util/qemu-option.cor something like that.
Hm. Doublechecked. I copied qemu_get_cpu_opts() from qemu_get_machine_opts() and put it in vl.c but it can perfectly live in qom/cpu.c along with cpu_default_parse_options_func() and others. Thanks for the hint.
Quoted 6 lines
Paolo
Quoted 2 lines
How to solve this properly before I continue spamming the list? :)
Signature · 1 line
Alexey
PATCH v3 2/6 target-ppc: make use of new -cpu suboptions handling
In reply to Alexey KardashevskiyThis enables -cpu subobtions parser. No option is supported yet.
--- hw/ppc/spapr.c | 4 +++- target-ppc/translate_init.c | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +3 -1
@@ -1101,7 +1101,7 @@ static SaveVMHandlers savevm_htab_handlers = {static void ppc_spapr_init (QEMUMachineInitArgs *args) {ram_addr_t ram_size = args->ram_size; -const char *cpu_model = args->cpu_model; +const char *cpu_model;const char *kernel_filename = args->kernel_filename;const char *kernel_cmdline = args->kernel_cmdline;const char *initrd_filename = args->initrd_filename;
@@ -1121,6 +1121,8 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args) msi_supported = true; + cpu_model =qemu_opt_get (qemu_get_cpu_opts (),"type" ); + spapr =g_malloc0 (sizeof (*spapr));QLIST_INIT (&spapr->phbs);
target-ppc/translate_init.c +5 -0
@@ -7381,6 +7381,10 @@ static void init_ppc_proc(PowerPCCPU *cpu)/* PowerPC implementation specific initialisations (SPRs, timers, ...) */ (*pcc->init_proc)(env); +if (cpu_parse_options (CPU (cpu))) { +exit (1 ); + } +/* MSR bits & flags consistency checks */ if (env->msr_mask & (1 <<25 )) {switch (env->flags & (POWERPC_FLAG_SPE |POWERPC_FLAG_VRE )) {
@@ -8674,6 +8678,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)#endif dc->fw_name ="PowerPC,UNKNOWN" ; + cc->parse_options = cpu_default_parse_options_func; }static const TypeInfo ppc_cpu_type_info = {
Signature · 1 line
1.8.4.rc4
PATCH v3 3/6 target-ppc: add "compat" CPU option
In reply to Alexey KardashevskiyTo be able to boot a guest on the hardware which is newer than the guest actually supports, PowerISA defines a logical PVR per every PowerISA specification version from 2.04.
This adds the "compat" option which takes values 205 or 206 and forces QEMU to boot the guest with a logical PVR (CPU_POWERPC_LOGICAL_2_05 or CPU_POWERPC_LOGICAL_2_06) which is stored in the "cpu-version" property of CPU device nodes.
---
Changes:
v3:
* "compat" option accepts "power6" and "power7" now
--- hw/ppc/spapr.c | 9 +++++++ target-ppc/cpu-models.h | 10 ++++++++ target-ppc/cpu.h | 4 +++ target-ppc/translate_init.c | 61 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+)
hw/ppc/spapr.c +9 -0
@@ -206,6 +206,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr)CPU_FOREACH (cpu) {DeviceClass *dc =DEVICE_GET_CLASS (cpu); +CPUPPCState *env = &POWERPC_CPU (cpu)->env;uint32_t associativity[] = {cpu_to_be32 (0x5 ),cpu_to_be32 (0x0 ),cpu_to_be32 (0x0 ),
@@ -238,6 +239,14 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr)if (ret <0 ) {return ret; } + +if (env->compat) { + ret =fdt_setprop (fdt, offset,"cpu-version" , + &env->compat,sizeof (env->compat)); +if (ret <0 ) { +return ret; + } + } }return ret; }
target-ppc/cpu-models.h +10 -0
@@ -583,6 +583,16 @@ enum {CPU_POWERPC_RS64II =0x00340000 ,CPU_POWERPC_RS64III =0x00360000 ,CPU_POWERPC_RS64IV =0x00370000 , + +/* Logical CPUs */ +CPU_POWERPC_LOGICAL_MASK =0xFFFFFFFF , +CPU_POWERPC_LOGICAL_2_04 =0x0F000001 , +CPU_POWERPC_LOGICAL_2_05 =0x0F000002 , +CPU_POWERPC_LOGICAL_2_06 =0x0F000003 , +CPU_POWERPC_LOGICAL_2_06_PLUS =0x0F100003 , +CPU_POWERPC_LOGICAL_2_07 =0x0F000004 , + CPU_POWERPC_LOGICAL_2_08 = 0x0F000005, + #endif /* defined(TARGET_PPC64) *//* Original POWER */ /* XXX: should be POWER (RIOS), RSC3308, RSC4608,
target-ppc/cpu.h +4 -0
@@ -1006,6 +1006,9 @@ struct CPUPPCState {/* Device control registers */ ppc_dcr_t *dcr_env; +/* Architecture compatibility mode PVR */ +uint32_t compat; +int dcache_line_size;int icache_line_size;
@@ -1330,6 +1333,7 @@ static inline int cpu_mmu_index (CPUPPCState *env)#define SPR_BOOKE_DVC1 (0x13E)#define SPR_BOOKE_DVC2 (0x13F)#define SPR_BOOKE_TSR (0x150) +#define SPR_PCR (0x152)#define SPR_BOOKE_TCR (0x154)#define SPR_BOOKE_TLB0PS (0x158)#define SPR_BOOKE_TLB1PS (0x159)
target-ppc/translate_init.c +61 -0
87 lines not on this page · raw message
Signature · 1 line
1.8.4.rc4
PATCH v3 4/6 qemu-option: support +foo/-foo command line agruments
In reply to Alexey KardashevskiyThis converts +foo/-foo to "foo=on"/"foo=off" respectively when QEMU parser is used for the command line options.
"-cpu" parsers in x86 and other architectures should be unaffected by this change.
--- util/qemu-option.c | 6 ++++++ 1 file changed, 6 insertions(+)
util/qemu-option.c +6 -0
@@ -890,6 +890,12 @@ static int opts_do_parse(QemuOpts *opts, const char *params,if (strncmp (option,"no" ,2 ) ==0 ) {memmove (option, option+2 ,strlen (option+2 )+1 );pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"-" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"+" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"on" ); }else {pstrcpy (value,sizeof (value),"on" ); }
Signature · 1 line
1.8.4.rc4
Re: [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 18 lines
This converts +foo/-foo to "foo=on"/"foo=off" respectively when QEMU parser is used for the command line options.
"-cpu" parsers in x86 and other architectures should be unaffected by this change.
Signed-off-by Alexey Kardashevskiy <[email protected]>--- util/qemu-option.c | 6 ++++++ 1 file changed, 6 insertions(+)util/qemu-option.c +0
-0@@ -890,6 +890,12 @@ static int opts_do_parse(QemuOpts *opts, const char *params,if (strncmp (option,"no" ,2 ) ==0 ) {memmove (option, option+2 ,strlen (option+2 )+1 );
util/qemu-option.c static int opts_do_parse(QemuOpts *opts, const char *params, · line 901
Quoted 10 lines
util/qemu-option.c +6
-0pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"-" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"+" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"on" ); }else {pstrcpy (value,sizeof (value),"on" ); }
This looks like an interesting idea! However this is much too big a change to just CC ppc folks on...
Jan, I wonder if this might break slirp's hostfwd option?
Not sure what other options potentially starting with '-' might be affected. Test cases would be a helpful way of demonstrating that this change does not have undesired side effects.
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments
Quoted 33 lines · Andreas Färber
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 18 lines
This converts +foo/-foo to "foo=on"/"foo=off" respectively when QEMU parser is used for the command line options.
"-cpu" parsers in x86 and other architectures should be unaffected by this change.
Signed-off-by Alexey Kardashevskiy <[email protected]>--- util/qemu-option.c | 6 ++++++ 1 file changed, 6 insertions(+)util/qemu-option.c +0
-0@@ -890,6 +890,12 @@ static int opts_do_parse(QemuOpts *opts, const char *params,if (strncmp (option,"no" ,2 ) ==0 ) {memmove (option, option+2 ,strlen (option+2 )+1 );util/qemu-option.c static int opts_do_parse(QemuOpts *opts, const char *params, · line 901
Quoted 10 lines
util/qemu-option.c +6
-0pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"-" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"+" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"on" ); }else {pstrcpy (value,sizeof (value),"on" ); }This looks like an interesting idea! However this is much too big a change to just CC ppc folks on...
Quoted 1 line
Jan, I wonder if this might break slirp's hostfwd option?
hostfwd starts with ":" in the simplest case - or what pattern do you have in mind?
Jan
Quoted 8 lines
Not sure what other options potentially starting with '-' might be affected. Test cases would be a helpful way of demonstrating that this change does not have undesired side effects.
Regards,
Andreas
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments
Am 11.11.2013 13:52, schrieb Jan Kiszka:
Quoted 34 lines · Andreas Färber
Quoted 33 lines
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 18 lines
This converts +foo/-foo to "foo=on"/"foo=off" respectively when QEMU parser is used for the command line options.
"-cpu" parsers in x86 and other architectures should be unaffected by this change.
Signed-off-by Alexey Kardashevskiy <[email protected]>--- util/qemu-option.c | 6 ++++++ 1 file changed, 6 insertions(+)util/qemu-option.c +0
-0@@ -890,6 +890,12 @@ static int opts_do_parse(QemuOpts *opts, const char *params,if (strncmp (option,"no" ,2 ) ==0 ) {memmove (option, option+2 ,strlen (option+2 )+1 );util/qemu-option.c static int opts_do_parse(QemuOpts *opts, const char *params, · line 901
Quoted 10 lines
util/qemu-option.c +6
-0pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"-" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"+" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"on" ); }else {pstrcpy (value,sizeof (value),"on" ); }This looks like an interesting idea! However this is much too big a change to just CC ppc folks on...
Quoted 4 lines
Quoted 1 line
Jan, I wonder if this might break slirp's hostfwd option?
hostfwd starts with ":" in the simplest case - or what pattern do you have in mind?
Ah right, I had :8022-:22 or so in mind and mixed up optional host name with optional source port.
Basically I'm checking for anything which is using the generic QemuOpts parsing and where a literal + or - may lead to unexpected parsing changes with this patch. Without having looked up more context for this hunk, it should not affect foo=-bar but only where foo= is optional, such as type names for driver= starting with either character (not aware of such types though).
Andreas
Quoted 3 lines
Quoted 3 lines
Not sure what other options potentially starting with '-' might be affected. Test cases would be a helpful way of demonstrating that this change does not have undesired side effects.
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments
In reply to Andreas FärberQuoted 33 lines · On Mon, 11 Nov 2013 13:41:05 +0100 Andreas Färber <[email protected]> wrote:
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 18 lines
This converts +foo/-foo to "foo=on"/"foo=off" respectively when QEMU parser is used for the command line options.
"-cpu" parsers in x86 and other architectures should be unaffected by this change.
Signed-off-by Alexey Kardashevskiy <[email protected]>--- util/qemu-option.c | 6 ++++++ 1 file changed, 6 insertions(+)util/qemu-option.c +0
-0@@ -890,6 +890,12 @@ static int opts_do_parse(QemuOpts *opts, const char *params,if (strncmp (option,"no" ,2 ) ==0 ) {memmove (option, option+2 ,strlen (option+2 )+1 );util/qemu-option.c static int opts_do_parse(QemuOpts *opts, const char *params, · line 901
Quoted 10 lines
util/qemu-option.c +6
-0pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"-" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"+" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"on" ); }else {pstrcpy (value,sizeof (value),"on" ); }This looks like an interesting idea! However this is much too big a change to just CC ppc folks on...
Quoted 5 lines
Jan, I wonder if this might break slirp's hostfwd option?
Not sure what other options potentially starting with '-' might be affected. Test cases would be a helpful way of demonstrating that this change does not have undesired side effects.
on x86 there is several value fixups for compatibility reason and a manual value parsing in cpu_x86_parse_featurestr(), so above won't just work there.
Quoted 8 lines
Regards,
AndreasSignature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments
Quoted 36 lines · Igor Mammedov
Quoted 33 lines · On Mon, 11 Nov 2013 13:41:05 +0100 Andreas Färber <[email protected]> wrote:
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 18 lines
This converts +foo/-foo to "foo=on"/"foo=off" respectively when QEMU parser is used for the command line options.
"-cpu" parsers in x86 and other architectures should be unaffected by this change.
Signed-off-by Alexey Kardashevskiy <[email protected]>--- util/qemu-option.c | 6 ++++++ 1 file changed, 6 insertions(+)util/qemu-option.c +0
-0@@ -890,6 +890,12 @@ static int opts_do_parse(QemuOpts *opts, const char *params,if (strncmp (option,"no" ,2 ) ==0 ) {memmove (option, option+2 ,strlen (option+2 )+1 );util/qemu-option.c static int opts_do_parse(QemuOpts *opts, const char *params, · line 901
Quoted 10 lines
util/qemu-option.c +6
-0pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"-" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"+" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"on" ); }else {pstrcpy (value,sizeof (value),"on" ); }This looks like an interesting idea! However this is much too big a change to just CC ppc folks on...
Quoted 7 lines
Quoted 5 lines
Jan, I wonder if this might break slirp's hostfwd option?
Not sure what other options potentially starting with '-' might be affected. Test cases would be a helpful way of demonstrating that this change does not have undesired side effects.
on x86 there is several value fixups for compatibility reason and a manual value parsing in
cpu_x86_parse_featurestr(), so above won't just work there.
What particular x86 CPU option cannot be handled the way as PPC's "VSX" is handled two patches below? As I see, even static properties will work there fine.
Signature · 1 line
Alexey
Re: [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments
Quoted 42 lines · On Tue, 12 Nov 2013 10:49:58 +1100 Alexey Kardashevskiy <[email protected]> wrote:
Quoted 41 lines · Igor Mammedov
Quoted 38 lines · On Mon, 11 Nov 2013 13:41:05 +0100 Andreas Färber <[email protected]> wrote:
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 18 lines
This converts +foo/-foo to "foo=on"/"foo=off" respectively when QEMU parser is used for the command line options.
"-cpu" parsers in x86 and other architectures should be unaffected by this change.
Signed-off-by Alexey Kardashevskiy <[email protected]>--- util/qemu-option.c | 6 ++++++ 1 file changed, 6 insertions(+)util/qemu-option.c +0
-0@@ -890,6 +890,12 @@ static int opts_do_parse(QemuOpts *opts, const char *params,if (strncmp (option,"no" ,2 ) ==0 ) {memmove (option, option+2 ,strlen (option+2 )+1 );util/qemu-option.c static int opts_do_parse(QemuOpts *opts, const char *params, · line 901
Quoted 10 lines
util/qemu-option.c +6
-0pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"-" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"+" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"on" ); }else {pstrcpy (value,sizeof (value),"on" ); }This looks like an interesting idea! However this is much too big a change to just CC ppc folks on...
Jan, I wonder if this might break slirp's hostfwd option?
Not sure what other options potentially starting with '-' might be affected. Test cases would be a helpful way of demonstrating that this change does not have undesired side effects.
Quoted 7 lines
Quoted 2 lines
on x86 there is several value fixups for compatibility reason and a manual value parsing in
cpu_x86_parse_featurestr(), so above won't just work there.What particular x86 CPU option cannot be handled the way as PPC's "VSX" is handled two patches below? As I see, even static properties will work there fine.
There is legacy code that is kept for CLI compatibility reasons. Please, look at following features in cpu_x86_parse_featurestr():
xlevel, tsc-freq hv-spinlocks
the rest feature flags on x86 should be handled just fine by your patch, once x86properties series is applied.
that's why we are talking about parser hook that could be overridden by target if necessary.
PS:
extending QemuOpts to parsing +/-opts format, seems like good workaround above problem. But I was under impression that general movement was to convert custom formats to canonical format "prop=value".
Quoted 5 lines
Signature · 2 lines
-- Alexey
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments
Quoted 49 lines · Igor Mammedov
Quoted 46 lines · On Tue, 12 Nov 2013 10:49:58 +1100 Alexey Kardashevskiy <[email protected]> wrote:
Quoted 43 lines · Igor Mammedov
Quoted 33 lines · On Mon, 11 Nov 2013 13:41:05 +0100 Andreas Färber <[email protected]> wrote:
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 18 lines
This converts +foo/-foo to "foo=on"/"foo=off" respectively when QEMU parser is used for the command line options.
"-cpu" parsers in x86 and other architectures should be unaffected by this change.
Signed-off-by Alexey Kardashevskiy <[email protected]>--- util/qemu-option.c | 6 ++++++ 1 file changed, 6 insertions(+)util/qemu-option.c +0
-0@@ -890,6 +890,12 @@ static int opts_do_parse(QemuOpts *opts, const char *params,if (strncmp (option,"no" ,2 ) ==0 ) {memmove (option, option+2 ,strlen (option+2 )+1 );util/qemu-option.c static int opts_do_parse(QemuOpts *opts, const char *params, · line 901
Quoted 10 lines
util/qemu-option.c +6
-0pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"-" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"+" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"on" ); }else {pstrcpy (value,sizeof (value),"on" ); }This looks like an interesting idea! However this is much too big a change to just CC ppc folks on...
Quoted 5 lines
Jan, I wonder if this might break slirp's hostfwd option?
Not sure what other options potentially starting with '-' might be affected. Test cases would be a helpful way of demonstrating that this change does not have undesired side effects.
on x86 there is several value fixups for compatibility reason and a manual value parsing in
cpu_x86_parse_featurestr(), so above won't just work there.
Quoted 6 lines
Quoted 3 lines
What particular x86 CPU option cannot be handled the way as PPC's "VSX" is handled two patches below? As I see, even static properties will work there fine.
There is legacy code that is kept for CLI compatibility reasons. Please, look at following features in
cpu_x86_parse_featurestr():
xlevel, tsc-freq hv-spinlocks
Ok, I do not know for sure if static properties support setters/getters (they do not if I remember correct) but what does prevent these x86 properties from being _dynamic_?
Quoted 5 lines
the rest feature flags on x86 should be handled just fine by your patch, once x86properties series is applied.
that's why we are talking about parser hook that could be overridden by target if necessary.
This part confuses me the most. I thought I added the hook and I did not change other than PPC archs so my patches should have gone quite easily to upstream but instead I was told (I think I was but I could misunderstand) that other folks may be unhappy that my stuff does not support +foo/-foo (which could be added later).
Could you please point me to the x86properties patch(es) which everybody is waiting for? Thanks!
Quoted 4 lines
PS:
extending QemuOpts to parsing +/-opts format, seems like good workaround above problem. But I was under impression that general movement was to convert custom formats to canonical format "prop=value".
Heh. I do not understand movements in the qemu project most of the time :) I thought I could have added "compat" to PowerPC CPU as others did but I was so wrong :)
Signature · 3 lines
With best regards Alexey Kardashevskiy -- icq: 52150396
Re: [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments
Am 12.11.2013 13:39, schrieb Alexey Kardashevskiy:
Quoted 9 lines · Igor Mammedov
Quoted 4 lines
PS:
extending QemuOpts to parsing +/-opts format, seems like good workaround above problem. But I was under impression that general movement was to convert custom formats to canonical format "prop=value".Heh. I do not understand movements in the qemu project most of the time :) I thought I could have added "compat" to PowerPC CPU as others did but I was so wrong :)
Hey, I instructed you how to do exactly that, with a const char * argument, but you chose rather to experiment more with QemuOpts. ;) Don't blame us! :-)
Cheers,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments
Quoted 7 lines · Andreas Färber
Am 12.11.2013 13:39, schrieb Alexey Kardashevskiy:
Quoted 6 lines · Igor Mammedov
Quoted 4 lines
PS:
extending QemuOpts to parsing +/-opts format, seems like good workaround above problem. But I was under impression that general movement was to convert custom formats to canonical format "prop=value".
Quoted 7 lines
Quoted 3 lines
Heh. I do not understand movements in the qemu project most of the time :) I thought I could have added "compat" to PowerPC CPU as others did but I was so wrong :)
Hey, I instructed you how to do exactly that, with a const char * argument, but you chose rather to experiment more with QemuOpts. ;) Don't blame us! :-)
So instead of reusing QemuOpts infrastructure, you suggest to re-implement the parser one more time, don't you? I still cannot believe it.
Signature · 1 line
Alexey
Re: [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments
In reply to Andreas FärberIl 12/11/2013 13:45, Andreas Färber ha scritto:
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Heh. I do not understand movements in the qemu project most of the time :) I thought I could have added "compat" to PowerPC CPU as others did but I was so wrong :)
Hey, I instructed you how to do exactly that, with a const char * argument, but you chose rather to experiment more with QemuOpts. ;) Don't blame us! :-)
At least you had a healthy dose of smileys! :) (Me too, apparently).
I like Alexey's idea.
Paolo
Re: [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments
In reply to Alexey KardashevskiyQuoted 53 lines · On Tue, 12 Nov 2013 23:39:27 +1100 Alexey Kardashevskiy <[email protected]> wrote:
Quoted 52 lines · Igor Mammedov
Quoted 49 lines · On Tue, 12 Nov 2013 10:49:58 +1100 Alexey Kardashevskiy <[email protected]> wrote:
Quoted 36 lines · Igor Mammedov
Quoted 33 lines · On Mon, 11 Nov 2013 13:41:05 +0100 Andreas Färber <[email protected]> wrote:
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 18 lines
This converts +foo/-foo to "foo=on"/"foo=off" respectively when QEMU parser is used for the command line options.
"-cpu" parsers in x86 and other architectures should be unaffected by this change.
Signed-off-by Alexey Kardashevskiy <[email protected]>--- util/qemu-option.c | 6 ++++++ 1 file changed, 6 insertions(+)util/qemu-option.c +0
-0@@ -890,6 +890,12 @@ static int opts_do_parse(QemuOpts *opts, const char *params,if (strncmp (option,"no" ,2 ) ==0 ) {memmove (option, option+2 ,strlen (option+2 )+1 );util/qemu-option.c static int opts_do_parse(QemuOpts *opts, const char *params, · line 901
Quoted 10 lines
util/qemu-option.c +6
-0pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"-" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"+" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"on" ); }else {pstrcpy (value,sizeof (value),"on" ); }This looks like an interesting idea! However this is much too big a change to just CC ppc folks on...
Quoted 7 lines
Quoted 5 lines
Jan, I wonder if this might break slirp's hostfwd option?
Not sure what other options potentially starting with '-' might be affected. Test cases would be a helpful way of demonstrating that this change does not have undesired side effects.
on x86 there is several value fixups for compatibility reason and a manual value parsing in
cpu_x86_parse_featurestr(), so above won't just work there.What particular x86 CPU option cannot be handled the way as PPC's "VSX" is handled two patches below? As I see, even static properties will work there fine.
Quoted 7 lines
Quoted 3 lines
There is legacy code that is kept for CLI compatibility reasons. Please, look at following features in
cpu_x86_parse_featurestr():
xlevel, tsc-freq hv-spinlocksOk, I do not know for sure if static properties support setters/getters (they do not if I remember correct) but what does prevent these x86 properties from being _dynamic_?
nothing, except of:
* it's better to keep CPU device model clean from legacy hacks so that legacy silent fixups of invalid values won't be available via other interfaces except of CLI. That will force users to use correct property names/values and not break old users that use legacy CLI options.
Quoted 7 lines
Quoted 6 lines
the rest feature flags on x86 should be handled just fine by your patch, once x86properties series is applied.
that's why we are talking about parser hook that could be overridden by target if necessary.
Quoted 8 lines
This part confuses me the most. I thought I added the hook and I did not change other than PPC archs so my patches should have gone quite easily to upstream but instead I was told (I think I was but I could misunderstand) that other folks may be unhappy that my stuff does not support +foo/-foo (which could be added later).
Could you please point me to the x86properties patch(es) which everybody is waiting for? Thanks!
latest is available at
https://github.com/imammedo/qemu/tree/x86-cpu-properties.v10.1
which basically is a rebase with fixed conflicts of v9
http://comments.gmane.org/gmane.comp.emulators.qemu/222284
Quoted 15 lines
Quoted 4 lines
PS:
extending QemuOpts to parsing +/-opts format, seems like good workaround above problem. But I was under impression that general movement was to convert custom formats to canonical format "prop=value".Heh. I do not understand movements in the qemu project most of the time :) I thought I could have added "compat" to PowerPC CPU as others did but I was so wrong :)
Signature · 3 lines
With best regards Alexey Kardashevskiy -- icq: 52150396
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments
Quoted 81 lines · Igor Mammedov
Quoted 53 lines · On Tue, 12 Nov 2013 23:39:27 +1100 Alexey Kardashevskiy <[email protected]> wrote:
Quoted 52 lines · Igor Mammedov
Quoted 49 lines · On Tue, 12 Nov 2013 10:49:58 +1100 Alexey Kardashevskiy <[email protected]> wrote:
Quoted 36 lines · Igor Mammedov
Quoted 33 lines · On Mon, 11 Nov 2013 13:41:05 +0100 Andreas Färber <[email protected]> wrote:
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 18 lines
This converts +foo/-foo to "foo=on"/"foo=off" respectively when QEMU parser is used for the command line options.
"-cpu" parsers in x86 and other architectures should be unaffected by this change.
Signed-off-by Alexey Kardashevskiy <[email protected]>--- util/qemu-option.c | 6 ++++++ 1 file changed, 6 insertions(+)util/qemu-option.c +0
-0@@ -890,6 +890,12 @@ static int opts_do_parse(QemuOpts *opts, const char *params,if (strncmp (option,"no" ,2 ) ==0 ) {memmove (option, option+2 ,strlen (option+2 )+1 );util/qemu-option.c static int opts_do_parse(QemuOpts *opts, const char *params, · line 901
Quoted 10 lines
util/qemu-option.c +6
-0pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"-" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"+" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"on" ); }else {pstrcpy (value,sizeof (value),"on" ); }This looks like an interesting idea! However this is much too big a change to just CC ppc folks on...
Quoted 7 lines
Quoted 5 lines
Jan, I wonder if this might break slirp's hostfwd option?
Not sure what other options potentially starting with '-' might be affected. Test cases would be a helpful way of demonstrating that this change does not have undesired side effects.
on x86 there is several value fixups for compatibility reason and a manual value parsing in
cpu_x86_parse_featurestr(), so above won't just work there.What particular x86 CPU option cannot be handled the way as PPC's "VSX" is handled two patches below? As I see, even static properties will work there fine.
Quoted 7 lines
Quoted 3 lines
There is legacy code that is kept for CLI compatibility reasons. Please, look at following features in
cpu_x86_parse_featurestr():
xlevel, tsc-freq hv-spinlocksOk, I do not know for sure if static properties support setters/getters (they do not if I remember correct) but what does prevent these x86 properties from being _dynamic_?
nothing, except of:
* it's better to keep CPU device model clean from legacy hacks so that legacy silent fixups of invalid values won't be available via other interfaces except of CLI. That will force users to use correct property names/values and not break old users that use legacy CLI options.Quoted 12 lines
Quoted 5 lines
the rest feature flags on x86 should be handled just fine by your patch, once x86properties series is applied.
that's why we are talking about parser hook that could be overridden by target if necessary.
This part confuses me the most. I thought I added the hook and I did not change other than PPC archs so my patches should have gone quite easily to upstream but instead I was told (I think I was but I could misunderstand) that other folks may be unhappy that my stuff does not support +foo/-foo (which could be added later).
Quoted 6 lines
Quoted 2 lines
Could you please point me to the x86properties patch(es) which everybody is waiting for? Thanks!
latest is available at
https://github.com/imammedo/qemu/tree/x86-cpu-properties.v10.1
which basically is a rebase with fixed conflicts of v9
http://comments.gmane.org/gmane.comp.emulators.qemu/222284
Wow. This explains a lot. Thanks. Is there any plan to use QemuOpts for all of this, instead of cpu_x86_parse_featurestr()?
Signature · 1 line
Alexey
Re: [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments
Quoted 84 lines · On Wed, 13 Nov 2013 13:07:26 +1100 Alexey Kardashevskiy <[email protected]> wrote:
Quoted 83 lines · Igor Mammedov
Quoted 53 lines · On Tue, 12 Nov 2013 23:39:27 +1100 Alexey Kardashevskiy <[email protected]> wrote:
Quoted 52 lines · Igor Mammedov
Quoted 49 lines · On Tue, 12 Nov 2013 10:49:58 +1100 Alexey Kardashevskiy <[email protected]> wrote:
Quoted 36 lines · Igor Mammedov
Quoted 33 lines · On Mon, 11 Nov 2013 13:41:05 +0100 Andreas Färber <[email protected]> wrote:
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 18 lines
This converts +foo/-foo to "foo=on"/"foo=off" respectively when QEMU parser is used for the command line options.
"-cpu" parsers in x86 and other architectures should be unaffected by this change.
Signed-off-by Alexey Kardashevskiy <[email protected]>--- util/qemu-option.c | 6 ++++++ 1 file changed, 6 insertions(+)util/qemu-option.c +0
-0@@ -890,6 +890,12 @@ static int opts_do_parse(QemuOpts *opts, const char *params,if (strncmp (option,"no" ,2 ) ==0 ) {memmove (option, option+2 ,strlen (option+2 )+1 );util/qemu-option.c static int opts_do_parse(QemuOpts *opts, const char *params, · line 901
Quoted 10 lines
util/qemu-option.c +6
-0pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"-" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"off" ); + }else if (strncmp (option,"+" ,1 ) ==0 ) { +memmove (option, option+1 ,strlen (option+1 )+1 ); +pstrcpy (value,sizeof (value),"on" ); }else {pstrcpy (value,sizeof (value),"on" ); }This looks like an interesting idea! However this is much too big a change to just CC ppc folks on...
Quoted 7 lines
Quoted 5 lines
Jan, I wonder if this might break slirp's hostfwd option?
Not sure what other options potentially starting with '-' might be affected. Test cases would be a helpful way of demonstrating that this change does not have undesired side effects.
on x86 there is several value fixups for compatibility reason and a manual value parsing in
cpu_x86_parse_featurestr(), so above won't just work there.What particular x86 CPU option cannot be handled the way as PPC's "VSX" is handled two patches below? As I see, even static properties will work there fine.
Quoted 7 lines
Quoted 3 lines
There is legacy code that is kept for CLI compatibility reasons. Please, look at following features in
cpu_x86_parse_featurestr():
xlevel, tsc-freq hv-spinlocksOk, I do not know for sure if static properties support setters/getters (they do not if I remember correct) but what does prevent these x86 properties from being _dynamic_?
nothing, except of:
* it's better to keep CPU device model clean from legacy hacks so that legacy silent fixups of invalid values won't be available via other interfaces except of CLI. That will force users to use correct property names/values and not break old users that use legacy CLI options.Quoted 14 lines
Quoted 5 lines
the rest feature flags on x86 should be handled just fine by your patch, once x86properties series is applied.
that's why we are talking about parser hook that could be overridden by target if necessary.
This part confuses me the most. I thought I added the hook and I did not change other than PPC archs so my patches should have gone quite easily to upstream but instead I was told (I think I was but I could misunderstand) that other folks may be unhappy that my stuff does not support +foo/-foo (which could be added later).
Could you please point me to the x86properties patch(es) which everybody is waiting for? Thanks!
Quoted 8 lines
Quoted 4 lines
latest is available at
https://github.com/imammedo/qemu/tree/x86-cpu-properties.v10.1
which basically is a rebase with fixed conflicts of v9
http://comments.gmane.org/gmane.comp.emulators.qemu/222284Wow. This explains a lot. Thanks. Is there any plan to use QemuOpts for all of this, instead of
cpu_x86_parse_featurestr()?
the plan was to keep, +/-/fixups as legacy in target specific code (x86, sparc) not polluting the rest targets. For not affected targets use only foo=val notation in CLI/monitor.
So providing a generic parser of cpu_model string for most targets and having a hook override with custom parser on x86,sparc would be one of simplest solutions.
Quoted 4 lines
Signature · 2 lines
-- Alexey
Signature · 2 lines
Regards, Igor
Re: [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments
In reply to Igor MammedovIl 12/11/2013 10:58, Igor Mammedov ha scritto:
Quoted 3 lines
extending QemuOpts to parsing ±opts format, seems like good workaround above problem. But I was under impression that general movement was to convert custom formats to canonical format "prop=value".
I think the general movement is to convert things to QemuOpts. As long as all compound options use QemuOpts, they are consistent and any syntactic sugar will apply to all in the same way.
I, for one, can never remember if it is =on, =true, =yes (and interestingly =no works but =yes doesn't). So I welcome a new completely different syntax that doesn't have this problem. :)
Paolo
PATCH v3 5/6 bitops: add BITNR macro
In reply to Alexey KardashevskiyThis adds a macro to calculate the highest bit set. If used on constant values, no code will be generated.
--- include/qemu/bitops.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
include/qemu/bitops.h +12 -0
@@ -23,6 +23,18 @@#define BIT_WORD (nr) ((nr) / BITS_PER_LONG)#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#define __BITNR (m, n) ((m) == ((m) & (1<<(n)))) ? (n) : +#define BITNR (m) \ + __BITNR((m), 31) __BITNR((m), 30) __BITNR((m), 29) __BITNR((m), 28) \ + __BITNR((m), 27) __BITNR((m), 26) __BITNR((m), 25) __BITNR((m), 24) \ + __BITNR((m), 23) __BITNR((m), 22) __BITNR((m), 21) __BITNR((m), 20) \ + __BITNR((m), 19) __BITNR((m), 18) __BITNR((m), 17) __BITNR((m), 16) \ + __BITNR((m), 15) __BITNR((m), 14) __BITNR((m), 13) __BITNR((m), 12) \ + __BITNR((m), 11) __BITNR((m), 10) __BITNR((m), 9) __BITNR((m), 8) \ + __BITNR((m), 7) __BITNR((m), 6) __BITNR((m), 5) __BITNR((m), 4) \ + __BITNR((m), 3) __BITNR((m), 2) __BITNR((m), 1) __BITNR((m), 0) \ + -1 +/** * set_bit - Set a bit in memory * @nr: the bit to set
Signature · 1 line
1.8.4.rc4
Re: [Qemu-devel] [PATCH v3 5/6] bitops: add BITNR macro
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 1 line
This adds a macro to calculate the highest bit set.
Isn't that already available as ffs / clz GCC builtin with wrapper in qemu/bitops.h? What's the difference to your macro? CC'ing Paolo.
Andreas
Quoted 32 lines
If used on constant
values, no code will be generated.Signed-off-by Alexey Kardashevskiy <[email protected]>--- include/qemu/bitops.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)include/qemu/bitops.h +12
-0@@ -23,6 +23,18 @@#define BIT_WORD (nr) ((nr) / BITS_PER_LONG)#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#define __BITNR (m, n) ((m) == ((m) & (1<<(n)))) ? (n) : +#define BITNR (m) \ + __BITNR((m), 31) __BITNR((m), 30) __BITNR((m), 29) __BITNR((m), 28) \ + __BITNR((m), 27) __BITNR((m), 26) __BITNR((m), 25) __BITNR((m), 24) \ + __BITNR((m), 23) __BITNR((m), 22) __BITNR((m), 21) __BITNR((m), 20) \ + __BITNR((m), 19) __BITNR((m), 18) __BITNR((m), 17) __BITNR((m), 16) \ + __BITNR((m), 15) __BITNR((m), 14) __BITNR((m), 13) __BITNR((m), 12) \ + __BITNR((m), 11) __BITNR((m), 10) __BITNR((m), 9) __BITNR((m), 8) \ + __BITNR((m), 7) __BITNR((m), 6) __BITNR((m), 5) __BITNR((m), 4) \ + __BITNR((m), 3) __BITNR((m), 2) __BITNR((m), 1) __BITNR((m), 0) \ + -1 +/** * set_bit - Set a bit in memory * @nr: the bit to set
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v3 5/6] bitops: add BITNR macro
Quoted 6 lines · Andreas Färber
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 1 line
This adds a macro to calculate the highest bit set.
Isn't that already available as ffs / clz GCC builtin with wrapper in
qemu/bitops.h? What's the difference to your macro? CC'ing Paolo.
I am ignorant and did not know this simple fact. Sorry. Drop this patch.
Quoted 36 lines
Andreas
Quoted 32 lines
If used on constant
values, no code will be generated.Signed-off-by Alexey Kardashevskiy <[email protected]>--- include/qemu/bitops.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)include/qemu/bitops.h +12
-0@@ -23,6 +23,18 @@#define BIT_WORD (nr) ((nr) / BITS_PER_LONG)#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#define __BITNR (m, n) ((m) == ((m) & (1<<(n)))) ? (n) : +#define BITNR (m) \ + __BITNR((m), 31) __BITNR((m), 30) __BITNR((m), 29) __BITNR((m), 28) \ + __BITNR((m), 27) __BITNR((m), 26) __BITNR((m), 25) __BITNR((m), 24) \ + __BITNR((m), 23) __BITNR((m), 22) __BITNR((m), 21) __BITNR((m), 20) \ + __BITNR((m), 19) __BITNR((m), 18) __BITNR((m), 17) __BITNR((m), 16) \ + __BITNR((m), 15) __BITNR((m), 14) __BITNR((m), 13) __BITNR((m), 12) \ + __BITNR((m), 11) __BITNR((m), 10) __BITNR((m), 9) __BITNR((m), 8) \ + __BITNR((m), 7) __BITNR((m), 6) __BITNR((m), 5) __BITNR((m), 4) \ + __BITNR((m), 3) __BITNR((m), 2) __BITNR((m), 1) __BITNR((m), 0) \ + -1 +/** * set_bit - Set a bit in memory * @nr: the bit to set
Signature · 1 line
Alexey
Re: [Qemu-devel] [PATCH v3 5/6] bitops: add BITNR macro
In reply to Andreas FärberQuoted 5 lines · Andreas Färber
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 1 line
This adds a macro to calculate the highest bit set.
Isn't that already available as ffs / clz GCC builtin with wrapper in
qemu/bitops.h? What's the difference to your macro? CC'ing Paolo.
I looked further and did not find any use of ffs/clz so I wonder what did you mean about bitops.h and what did I miss? I am confused.
So I would suggest the following instead (if I really needed this BITNR but I really do not :) )
===
bitops: add BITNR macro
This adds a macro to calculate the highest single bit set. If more than one bit is set, returns -1.
include/qemu/bitops.h +2 -0
@@ -23,6 +23,8 @@#define BIT_WORD (nr) ((nr) / BITS_PER_LONG)#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#define BITNR (m) (__builtin_popcount(m) == 1)?(__builtin_ffs(m) - 1) : -1 +/** * set_bit - Set a bit in memory * @nr: the bit to set
===
Quoted 37 lines
Andreas
Quoted 32 lines
If used on constant
values, no code will be generated.Signed-off-by Alexey Kardashevskiy <[email protected]>--- include/qemu/bitops.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)include/qemu/bitops.h +12
-0@@ -23,6 +23,18 @@#define BIT_WORD (nr) ((nr) / BITS_PER_LONG)#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#define __BITNR (m, n) ((m) == ((m) & (1<<(n)))) ? (n) : +#define BITNR (m) \ + __BITNR((m), 31) __BITNR((m), 30) __BITNR((m), 29) __BITNR((m), 28) \ + __BITNR((m), 27) __BITNR((m), 26) __BITNR((m), 25) __BITNR((m), 24) \ + __BITNR((m), 23) __BITNR((m), 22) __BITNR((m), 21) __BITNR((m), 20) \ + __BITNR((m), 19) __BITNR((m), 18) __BITNR((m), 17) __BITNR((m), 16) \ + __BITNR((m), 15) __BITNR((m), 14) __BITNR((m), 13) __BITNR((m), 12) \ + __BITNR((m), 11) __BITNR((m), 10) __BITNR((m), 9) __BITNR((m), 8) \ + __BITNR((m), 7) __BITNR((m), 6) __BITNR((m), 5) __BITNR((m), 4) \ + __BITNR((m), 3) __BITNR((m), 2) __BITNR((m), 1) __BITNR((m), 0) \ + -1 +/** * set_bit - Set a bit in memory * @nr: the bit to set
Signature · 1 line
Alexey
Re: [Qemu-devel] [PATCH v3 5/6] bitops: add BITNR macro
Il 13/11/2013 03:40, Alexey Kardashevskiy ha scritto:
Quoted 2 lines
I looked further and did not find any use of ffs/clz so I wonder what did you mean about
bitops.hand what did I miss? I am confused.
It's host-utils.h actually. The reason for the wrappers is twofold:
(1) provide 32/64-bit functions instead of int/long/longlong;
(2) support GCC <3.4.
The wrappers are not usable where you have constant expressions as in your case. So your original patch is good IMO, except for the __ at the beginning of __BITNR.
Paolo
Quoted 8 lines
So I would suggest the following instead (if I really needed this BITNR but I really do not :) )
===
bitops: add BITNR macroThis adds a macro to calculate the highest single bit set. If more than one bit is set, returns -1.
Re: [Qemu-devel] [PATCH v3 5/6] bitops: add BITNR macro
Quoted 6 lines · Paolo Bonzini
Il 13/11/2013 03:40, Alexey Kardashevskiy ha scritto:
Quoted 2 lines
I looked further and did not find any use of ffs/clz so I wonder what did you mean about
bitops.hand what did I miss? I am confused.It's
host-utils.hactually. The reason for the wrappers is twofold:
Quoted 7 lines
(1) provide 32/64-bit functions instead of int/long/longlong;
(2) support GCC <3.4.
The wrappers are not usable where you have constant expressions as in your case. So your original patch is good IMO, except for the __ at the beginning of
__BITNR.
There are 2 macros, one (BITNR) uses the other (__BITNR). What would the good name be for BITNR then?
Quoted 12 lines
Paolo
Quoted 8 lines
So I would suggest the following instead (if I really needed this BITNR but I really do not :) )
===
bitops: add BITNR macroThis adds a macro to calculate the highest single bit set. If more than one bit is set, returns -1.
Signature · 1 line
Alexey
Re: [Qemu-devel] [PATCH v3 5/6] bitops: add BITNR macro
Il 14/11/2013 06:51, Alexey Kardashevskiy ha scritto:
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
The wrappers are not usable where you have constant expressions as in your case. So your original patch is good IMO, except for the __ at the beginning of
__BITNR.There are 2 macros, one (BITNR) uses the other (
__BITNR). What would the good name be for BITNR then?
I don't know, perhaps BITNR and BITNR_?
Names starting with __ or _+uppercase are reserved by the C standard.
Paolo
PATCH v3 6/6 target-ppc: demonstrate new "vsx" property
In reply to Alexey KardashevskiyThis patch is to demonstrate a static property handling in PowerPC. Running QEMU with -cpu host,-vsx disables VSX bit in PowerPCCPU::env::flags.
--- target-ppc/translate_init.c | 7 +++++++ 1 file changed, 7 insertions(+)
target-ppc/translate_init.c +7 -0
@@ -29,6 +29,7 @@#include "mmu-hash64.h" #include "qemu/error-report.h" #include "qapi/visitor.h" +#include "hw/qdev-properties.h" //#define PPC_DUMP_CPU //#define PPC_DEBUG_SPR
@@ -8740,6 +8741,12 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) dc->fw_name ="PowerPC,UNKNOWN" ; cc->parse_options = cpu_default_parse_options_func; + +static Property powerpc_properties[] = { +DEFINE_PROP_BIT ("vsx" , PowerPCCPU, env.flags,BITNR (POWERPC_FLAG_VSX ), false), +DEFINE_PROP_END_OF_LIST (), + }; + dc->props = powerpc_properties; }static const TypeInfo ppc_cpu_type_info = {
Signature · 1 line
1.8.4.rc4
Re: [Qemu-devel] [PATCH v3 6/6] target-ppc: demonstrate new "vsx" property
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 24 lines
This patch is to demonstrate a static property handling in PowerPC. Running QEMU with -cpu host,-vsx disables VSX bit in
PowerPCCPU::env::flags.Signed-off-by Alexey Kardashevskiy <[email protected]>--- target-ppc/translate_init.c | 7 +++++++ 1 file changed, 7 insertions(+)target-ppc/translate_init.c +1
-0@@ -29,6 +29,7 @@#include "mmu-hash64.h" #include "qemu/error-report.h" #include "qapi/visitor.h" +#include "hw/qdev-properties.h" //#define PPC_DUMP_CPU //#define PPC_DEBUG_SPR @@ -8740,6 +8741,12 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) dc->fw_name ="PowerPC,UNKNOWN" ;
target-ppc/translate_init.c static void ppc_cpu_class_init(ObjectClass *oc, void *data) · line 8752
Quoted 10 lines
target-ppc/translate_init.c +6
-0cc->parse_options = cpu_default_parse_options_func; + +static Property powerpc_properties[] = { +DEFINE_PROP_BIT ("vsx" , PowerPCCPU, env.flags,BITNR (POWERPC_FLAG_VSX ), false), +DEFINE_PROP_END_OF_LIST (), + }; + dc->props = powerpc_properties; }static const TypeInfo ppc_cpu_type_info = {
This type of static property looks good to me, but two problems apart from the BITNR() discussed elsewhere:
1) Won't the default value of false always disable VSX for all models including POWER7 and higher?
2) Please move the array out of the function to just before the containing function.
Igor has been facing a similar issue in his refactoring of x86 models and I believe evaluated to define the properties per model so that they have different defaults. Another way is overwriting that default in the model's instance_init or via globals specific to the subtype.
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v3 6/6] target-ppc: demonstrate new "vsx" property
Quoted 34 lines · Andreas Färber
Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy:
Quoted 33 lines
This patch is to demonstrate a static property handling in PowerPC. Running QEMU with -cpu host,-vsx disables VSX bit in
PowerPCCPU::env::flags.Signed-off-by Alexey Kardashevskiy <[email protected]>--- target-ppc/translate_init.c | 7 +++++++ 1 file changed, 7 insertions(+)target-ppc/translate_init.c +7
-0@@ -29,6 +29,7 @@#include "mmu-hash64.h" #include "qemu/error-report.h" #include "qapi/visitor.h" +#include "hw/qdev-properties.h" //#define PPC_DUMP_CPU //#define PPC_DEBUG_SPR @@ -8740,6 +8741,12 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) dc->fw_name ="PowerPC,UNKNOWN" ; cc->parse_options = cpu_default_parse_options_func; + +static Property powerpc_properties[] = { +DEFINE_PROP_BIT ("vsx" , PowerPCCPU, env.flags,BITNR (POWERPC_FLAG_VSX ), false), +DEFINE_PROP_END_OF_LIST (), + }; + dc->props = powerpc_properties; }
Quoted 7 lines
target-ppc/translate_init.c static void ppc_cpu_class_init(ObjectClass *oc, void *data) · line 8752
Quoted 1 line
target-ppc/translate_init.c +0
-0static const TypeInfo ppc_cpu_type_info = {This type of static property looks good to me, but two problems apart from the
BITNR()discussed elsewhere:1) Won't the default value of false always disable VSX for all models including POWER7 and higher?
I am not really planning on defining properties per CPU feature, this all was just to demonstrate an ability to define those.
But even if I was planning, I would set default to true and move the whole set of properties to POWER7 family and that would be it.
Quoted 2 lines
2) Please move the array out of the function to just before the containing function.
Again, this is just to show. But. Why do you want those properties to be outside of the function? Less visibility is usually a good thing, no?
Quoted 4 lines
Igor has been facing a similar issue in his refactoring of x86 models and I believe evaluated to define the properties per model so that they have different defaults. Another way is overwriting that default in the model's
instance_initor via globals specific to the subtype.
Current x86 in QEMU does not have those CPU families as POWERPC does, correct? So we have more flexibility with properties and everything...
Signature · 1 line
Alexey
Re: [Qemu-devel] [PATCH v3 6/6] target-ppc: demonstrate new "vsx" property
Am 14.11.2013 06:20, schrieb Alexey Kardashevskiy:
Quoted 6 lines · Andreas Färber
Quoted 2 lines
2) Please move the array out of the function to just before the containing function.
Again, this is just to show. But. Why do you want those properties to be outside of the function? Less visibility is usually a good thing, no?
We used to have ->props = (...[]) {...}; and Anthony specifically refactored it to have a static variable one level down, just before the function assigning it. It was a scripted conversion in the context of QOM introduction, maybe the archives will give you insight about why exactly it was done.
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg