qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: Alexander Graf <agraf@suse.de>, qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, "Andreas Fa\"rber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [RFC PATCH] target-ppc: Register CPU class per family only when needed
Date: Mon, 16 Mar 2015 15:58:46 +1100	[thread overview]
Message-ID: <55066306.9060906@ozlabs.ru> (raw)
In-Reply-To: <54F85756.6040904@suse.de>

On 03/06/2015 12:17 AM, Alexander Graf wrote:
>
>
> On 05.03.15 02:56, Alexey Kardashevskiy wrote:
>> At the moment when running in KVM mode, QEMU registers "host" class to
>> match the current CPU PVR value. It also registers another CPU class
>> with a CPU family name os if we run QEMU on POWER7 machine, "host" and
>> "POWER7" classes are created, this way we can always use "-cpu POWER7"
>> on the actual POWER7 machine.
>>
>> The existing code uses DeviceClass::desc field of the CPU class as
>> a source for the class name; it was pointed out that it is wrong to use
>> user-visible string as a type name.
>>
>> This adds a common CPU class name into PowerPCCPUClass struct.
>> This makes registration of a CPU named after the family conditional -
>> PowerPCCPUClass::common_cpu_name has to be non-zero. Only POWER7/POWER8
>> families have this field initialized by now.
>>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>
> LGTM. Andreas, do you agree?


Ping?


>
>
> Alex
>
>
>> ---
>>   target-ppc/cpu-qom.h        |  1 +
>>   target-ppc/kvm.c            | 11 ++++++-----
>>   target-ppc/translate_init.c |  2 ++
>>   3 files changed, 9 insertions(+), 5 deletions(-)
>>
>> diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h
>> index 6967a80..4b471d7 100644
>> --- a/target-ppc/cpu-qom.h
>> +++ b/target-ppc/cpu-qom.h
>> @@ -55,6 +55,7 @@ typedef struct PowerPCCPUClass {
>>       DeviceRealize parent_realize;
>>       void (*parent_reset)(CPUState *cpu);
>>
>> +    const char *common_cpu_name;
>>       uint32_t pvr;
>>       bool (*pvr_match)(struct PowerPCCPUClass *pcc, uint32_t pvr);
>>       uint64_t pcr_mask;
>> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
>> index b479471..3f2df65 100644
>> --- a/target-ppc/kvm.c
>> +++ b/target-ppc/kvm.c
>> @@ -2221,7 +2221,6 @@ static int kvm_ppc_register_host_cpu_type(void)
>>       };
>>       uint32_t host_pvr = mfpvr();
>>       PowerPCCPUClass *pvr_pcc;
>> -    DeviceClass *dc;
>>
>>       pvr_pcc = ppc_cpu_class_by_pvr(host_pvr);
>>       if (pvr_pcc == NULL) {
>> @@ -2235,10 +2234,12 @@ static int kvm_ppc_register_host_cpu_type(void)
>>
>>       /* Register generic family CPU class for a family */
>>       pvr_pcc = ppc_cpu_get_family_class(pvr_pcc);
>> -    dc = DEVICE_CLASS(pvr_pcc);
>> -    type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc));
>> -    type_info.name = g_strdup_printf("%s-"TYPE_POWERPC_CPU, dc->desc);
>> -    type_register(&type_info);
>> +    if (pvr_pcc->common_cpu_name) {
>> +        type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc));
>> +        type_info.name = g_strdup_printf("%s-"TYPE_POWERPC_CPU,
>> +                                         pvr_pcc->common_cpu_name);
>> +        type_register(&type_info);
>> +    }
>>
>>       return 0;
>>   }
>> diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
>> index df1a62c..3d0be66 100644
>> --- a/target-ppc/translate_init.c
>> +++ b/target-ppc/translate_init.c
>> @@ -8117,6 +8117,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
>>       dc->fw_name = "PowerPC,POWER7";
>>       dc->desc = "POWER7";
>>       dc->props = powerpc_servercpu_properties;
>> +    pcc->common_cpu_name = "POWER7";
>>       pcc->pvr_match = ppc_pvr_match_power7;
>>       pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06;
>>       pcc->init_proc = init_proc_POWER7;
>> @@ -8193,6 +8194,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)
>>       dc->fw_name = "PowerPC,POWER8";
>>       dc->desc = "POWER8";
>>       dc->props = powerpc_servercpu_properties;
>> +    pcc->common_cpu_name = "POWER8";
>>       pcc->pvr_match = ppc_pvr_match_power8;
>>       pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06;
>>       pcc->init_proc = init_proc_POWER8;
>>


-- 
Alexey

  reply	other threads:[~2015-03-16  4:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-05  1:56 [Qemu-devel] [RFC PATCH] target-ppc: Register CPU class per family only when needed Alexey Kardashevskiy
2015-03-05 13:17 ` Alexander Graf
2015-03-16  4:58   ` Alexey Kardashevskiy [this message]
2015-03-16 10:40     ` Andreas Färber
2015-03-16 22:47       ` Alexey Kardashevskiy
2015-07-08  6:37         ` Alexey Kardashevskiy
2015-07-08  6:41           ` Alexey Kardashevskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55066306.9060906@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).