qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ewan Hai <ewanhai-oc@zhaoxin.com>
To: Zhao Liu <zhao1.liu@intel.com>
Cc: <pbonzini@redhat.com>, <qemu-devel@nongnu.org>,
	<ewanhai@zhaoxin.com>, <cobechen@zhaoxin.com>,
	<TonyWWang@zhaoxin.com>
Subject: Re: [PATCH v2 3/4] target/i386: Introduce Zhaoxin Shijidadao-Client CPU model
Date: Tue, 25 Nov 2025 16:57:04 +0800	[thread overview]
Message-ID: <d20164c5-291c-4646-86cb-fddc69542599@zhaoxin.com> (raw)
In-Reply-To: <aSVcOX5WvJYjIEbM@intel.com>

On 11/25/25 3:35 PM, Zhao Liu wrote:
> 
> 
>> +        /*
>> +         * TODO: When the Linux kernel introduces other existing definitions
>> +         * for this leaf, remember to update the definitions here.
>> +         */
> 
> This TODO seems a bit vague; it's best to explicitly list the existing
> features that are currently missing. Otherwise, maintainers won't be
> able to understand or clean up this TODO either.
> 

I agree. The same problem also exists in the YongFeng vCPU model. For this
series, I can drop the vague TODO and instead add a more explicit comment that
documents which CPUID.C000_0001.EDX bits are intentionally missing today. In
addition, I can post a small follow-up cleanup patch to fix the YongFeng model
in the same way, so the two Zhaoxin models stay consistent. If you prefer, I can
also fold the YongFeng comment update into this series as an extra patch.

As background, current Zhaoxin CPUs implement several CPUID.(EAX=0xC0000001,
ECX=0):EDX feature bits that are not yet defined in the Linux kernel, for
example SM2/SM2_EN, SM3/SM4 and their enable bits, PARALLAX/PARALLAX_EN,
TM3/TM3_EN, RNG2/RNG2_EN, PHE2/PHE2_EN, and RSA/RSA_EN.

We previously tried to upstream all these extra feature bits in one
patch(https://lore.kernel.org/all/20230414095334.8743-1-TonyWWang-oc@zhaoxin.com/),
but the maintainer rejected it because there was no in-tree code using these
features yet. So our current plan is to add the CPUID bits together with real
kernel users step by step.

>> +        .features[FEAT_C000_0001_EDX] =
>> +            CPUID_C000_0001_EDX_PMM_EN | CPUID_C000_0001_EDX_PMM |
>> +            CPUID_C000_0001_EDX_PHE_EN | CPUID_C000_0001_EDX_PHE |
>> +            CPUID_C000_0001_EDX_ACE2 |
>> +            CPUID_C000_0001_EDX_XCRYPT_EN | CPUID_C000_0001_EDX_XCRYPT |
>> +            CPUID_C000_0001_EDX_XSTORE_EN | CPUID_C000_0001_EDX_XSTORE,
> 
> ...
> 
>> +        .model_id = "Zhaoxin Shijidadao-Client Processor",
>> +        .cache_info = &shijidadao_cache_info,
>> +        .versions = (X86CPUVersionDefinition[]) {
>> +            { .version = 1 },
>> +            {
>> +                .version = 2,
>> +                .note = "with more XSAVE features",
> 
> it's better to mention "without smap" as well.
>

Sure, I will update the note to say "with more XSAVE features but without SMAP".

> (Based on my personal experience, the absence of SMAP seems a bit
> odd. Could it be a hardware bug in a specific stepping?)
> 

This is not a stepping-specific silicon bug. For this product family, SMAP
support was intentionally not enabled in the final product because our internal
performance evaluation showed an unacceptable performance impact in certain
workloads. The v2 CPU model therefore keeps "smap" off to reflect the actual
shipped behavior, while the v1 definition with SMAP enabled is kept for
customers who need to model early v1 silicon where SMAP is still available.

>> +                .props = (PropValue[]) {
>> +                    { "xsavec", "on" },
>> +                    { "xgetbv1", "on" },
>> +                    { "xsaves", "on"},
>> +                    { "vmx-xsaves", "on"},
>> +                    { "smap", "off" },
>> +                    { /* end of list */ }
>> +                },
>> +            },
> 
> BTW, if the differences aren't too significant, is it possible to merge
> the server and client models? :)
> 

From the user point of view, I slightly prefer keeping separate
Shijidadao-Client and Shijidadao-Server models.

The main reason is that customers who want a "full-feature" vCPU that behaves
very close to a specific physical product can simply pick the corresponding
model name, without having to remember a set of extra "-cpu ..., +-feature"
overrides. If we merge everything into a single Shijidadao model that
corresponds to a more restricted baseline, users who want the full configuration
would need to explicitly enable multiple features (such as the additional XSAVE
bits) on the command line, which is easier to get wrong and less user-friendly.

This is also aligned with how QEMU models other vendors' micro-architectures
where client and server products have slightly different feature sets.

Thanks again for the review!

Best regards,
Ewan.



  reply	other threads:[~2025-11-25  9:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-27 10:21 [PATCH v2 0/4] target/i386: Add support for Zhaoxin Shijidadao vCPU models Ewan Hai
2025-10-27 10:21 ` [PATCH v2 1/4] target/i386: Add an option in X86CPUDefinition to control CPUID 0x1f Ewan Hai
2025-11-25  7:37   ` Zhao Liu
2025-10-27 10:21 ` [PATCH v2 2/4] target/i386: Add cache model for Zhaoxin Shijidadao vCPUs Ewan Hai
2025-11-25  7:15   ` Zhao Liu
2025-10-27 10:21 ` [PATCH v2 3/4] target/i386: Introduce Zhaoxin Shijidadao-Client CPU model Ewan Hai
2025-11-25  7:35   ` Zhao Liu
2025-11-25  8:57     ` Ewan Hai [this message]
2025-12-15  9:03       ` Zhao Liu
2025-10-27 10:21 ` [PATCH v2 4/4] target/i386: Introduce Zhaoxin Shijidadao-Server " Ewan Hai

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=d20164c5-291c-4646-86cb-fddc69542599@zhaoxin.com \
    --to=ewanhai-oc@zhaoxin.com \
    --cc=TonyWWang@zhaoxin.com \
    --cc=cobechen@zhaoxin.com \
    --cc=ewanhai@zhaoxin.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhao1.liu@intel.com \
    /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).