implement ADD_FEATURES similar to EXCLUDE_FEATURES

it allows to add any feature to selected pre-defined CPUID model
This commit is contained in:
Stanislav Shwartsman 2024-11-03 23:01:00 +02:00
parent 35001a23ae
commit 0c33c6153e
9 changed files with 45 additions and 9 deletions

View File

@ -145,6 +145,12 @@
# sapphire_rapids Intel(R) Xeon(R) w9-3475X (Sappire Rapids)
# arrow_lake 15th Gen Intel(R) Core(TM) Ultra 5 245K (ArrowLake)
#
# ADD_FEATURES:
# Enable one of more CPU feature in the CPU configuration selected by MODEL.
# Could be useful for testing CPU with newer imaginary configurations by
# adding a specific feature or set of features to existing MODEL. The list
# of features to add supplied through space or comma separated string.
#
# EXCLUDE_FEATURES:
# Disable one of more CPU feature from CPU configuration selected by MODEL.
# Could be useful for testing CPU without a specific feature or set of

View File

@ -7,7 +7,7 @@ Brief summary :
- Implemented AMX-TF32 ISA extension
- Added initial support for AVX10_1 ISA extension and AVX10 CPUID leaf 0x24 (to be enabled in Xeon Granite Rapids)
- CPUID: Added Arrow Lake CPU definition
- CPUID: Support for disabling of one of more CPU feature from CPUID configuration (see "exclude_features" in bochsrc sample and documentation)
- CPUID: Support for enabling/disabling of one of more CPU features from CPUID configuration (see "add_features" and "exclude_features" in bochsrc sample and documentation)
- Bugfixes for CPU emulation correctness (critical bugfixes for WAITPKG, LASS, XSAVEC/XSAVES, CPUID and SHA1 ISA implementation)
- USB: Added the USB Debugger support for xHCI and UHCI
- Added USB boot option (requires BIOS from https://github.com/fysnet/i440fx)
@ -29,7 +29,7 @@ Detailed change log :
- CPUID:
- Added Arrow Lake CPU definition
- Features AVX-VNNI, AVX-IFMA, AVX-VNNI-INT8, AVX-VNNI-INT16, AVX_NE_CONVERT, GFNI, VAES/VPCLMULQDQ, SHA512, SM3/SM4, CMPCCXADD, LASS, SERIALIZE, UINTR
- Support for disabling of one of more CPU feature from CPUID configuration (see "exclude_features" in bochsrc sample and documentation)
- Support for enabling/disabling of one of more CPU features from CPUID configuration (see "add_features" and "exclude_features" in bochsrc sample and documentation)
- Configure and compile
- Fixed compilation of plugin version with debugger enabled on Windows

View File

@ -33,6 +33,7 @@ cpuid
level
family
model
add_features
exclude_features
stepping
vendor_string

View File

@ -613,10 +613,17 @@ void bx_init_options()
"Choose pre-defined CPU configuration",
cpu_names, 0, 0);
new bx_param_string_c(cpu_param,
"add_features",
"Add these features to selected pre-defined CPU configuration",
"Choose features to add to selected pre-defined CPU configuration",
"",
BX_PATHNAME_LEN);
new bx_param_string_c(cpu_param,
"exclude_features",
"Exclude these features from CPU configuration",
"Choose features to exclude from selected CPU configuration",
"Exclude these features from selected pre-defined CPU configuration",
"Choose features to exclude from selected pre-defined CPU configuration",
"",
BX_PATHNAME_LEN);

View File

@ -1385,7 +1385,7 @@ public: // for now...
~BX_CPU_C();
void initialize(void);
void exclude_cpuid_features(const char *feature_list);
void add_remove_cpuid_features(const char *feature_list, bool add);
void init_statistics(void);
void after_restore_state(void);
void register_state(void);

View File

@ -115,7 +115,7 @@ static bx_cpuid_t *cpuid_factory(BX_CPU_C *cpu)
#include <string>
void BX_CPU_C::exclude_cpuid_features(const char *input)
void BX_CPU_C::add_remove_cpuid_features(const char *input, bool add)
{
// Use as delimiters: space, tab, newline, and comma
static const char *delimiters = " \t\n,";
@ -130,8 +130,12 @@ void BX_CPU_C::exclude_cpuid_features(const char *input)
if (i > start) {
std::string feature_name(input + start, input + i);
int feature = match_cpu_feature(feature_name.c_str());
if (feature >= 0)
BX_CPU_THIS_PTR cpuid->disable_cpu_extension(feature);
if (feature >= 0) {
if (add)
BX_CPU_THIS_PTR cpuid->enable_cpu_extension(feature);
else
BX_CPU_THIS_PTR cpuid->disable_cpu_extension(feature);
}
else
BX_PANIC(("CPUID: unknown feature name \"%s\" cannot be disabled", feature_name.c_str()));
}
@ -161,7 +165,10 @@ void BX_CPU_C::initialize(void)
BX_INFO(("initialized CPU model %s", cpu_model_name));
const char* features_to_exclude = SIM->get_param_string(BXPN_CPU_EXCLUDE_FEATURES)->getptr();
exclude_cpuid_features(features_to_exclude);
add_remove_cpuid_features(features_to_exclude, false);
const char* features_to_eadd = SIM->get_param_string(BXPN_CPU_ADD_FEATURES)->getptr();
add_remove_cpuid_features(features_to_exclude, true);
}
BX_CPU_THIS_PTR cpuid->get_cpu_extensions(BX_CPU_THIS_PTR ia_extensions_bitmask);

View File

@ -3411,6 +3411,13 @@ supported configurations. When this option is used and the value
is different from 'bx_generic', the parameters of the <link linkend="bochsopt-cpuid">CPUID</link>
option have no effect anymore. See the <xref linkend="cpu-models"> for supported values.
</para>
<para><command>add_features</command></para>
<para>
Enable one of more CPU feature in the CPU configuration selected by MODEL.
Could be useful for testing CPU with newer imaginary configurations by
adding a specific feature or set of features to existing MODEL. The list
of features to add supplied through space or comma separated string.
</para>
<para><command>exclude_features</command></para>
<para>
Disable one of more CPU feature from CPU configuration selected by MODEL.

View File

@ -136,6 +136,13 @@ supported configurations. When this option is used and the value
is different from 'bx_generic', the parameters of the CPUID option
have no effect anymore. See the bochsrc sample for supported values.
add_features:
Enable one of more CPU feature in the CPU configuration selected by MODEL.
Could be useful for testing CPU with newer imaginary configurations by
adding a specific feature or set of features to existing MODEL. The list
of features to add supplied through space or comma separated string.
exclude_features:
Disable one of more CPU feature from CPU configuration selected by MODEL.

View File

@ -39,6 +39,7 @@
#define BXPN_CPU_NCORES "cpu.n_cores"
#define BXPN_CPU_NTHREADS "cpu.n_threads"
#define BXPN_CPU_MODEL "cpu.model"
#define BXPN_CPU_ADD_FEATURES "cpu.add_features"
#define BXPN_CPU_EXCLUDE_FEATURES "cpu.exclude_features"
#define BXPN_IPS "cpu.ips"
#define BXPN_SMP_QUANTUM "cpu.quantum"